From 1182a56653ca37242f48ed85ad7bdb09297c6b61 Mon Sep 17 00:00:00 2001 From: Andreas Volz Date: Mon, 27 Dec 2010 12:00:52 +0000 Subject: [PATCH] - wrap elmxx type access functions - change example to demonstrate type save and type unsave External access (now commited from my second system...) SVN revision: 55761 --- compile.sh | 2 +- .../src/elementaryxx/external/main.cpp | 21 ++++++++++++-- elementaryxx/include/elementaryxx/Object.h | 20 +++++++++++++ elementaryxx/src/Object.cpp | 28 +++++++++++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/compile.sh b/compile.sh index 739a2c9..f566cf5 100755 --- a/compile.sh +++ b/compile.sh @@ -1,5 +1,5 @@ #!/bin/bash -#test + PKG="eflxx einaxx evasxx diff --git a/eflxx_examples/src/elementaryxx/external/main.cpp b/eflxx_examples/src/elementaryxx/external/main.cpp index 3834f91..3dcd9a8 100644 --- a/eflxx_examples/src/elementaryxx/external/main.cpp +++ b/eflxx_examples/src/elementaryxx/external/main.cpp @@ -47,10 +47,12 @@ int main (int argc, char **argv) edje->setLayer (0); edje->show (); + // This access is type unsafe as a cast is done without checking prior the type! Eflxx::CountedPtr ext_eo (edje->getPart ("Button01")->getExternalObject ()); Elmxx::Button *button = static_cast (&(*ext_eo)); button->setLabel ("This is a changed button"); + // This access is type unsafe as a cast is done without checking prior the type! Eflxx::CountedPtr ext_eo2 (edje->getPart ("List01")->getExternalObject ()); Elmxx::List *list = static_cast (&(*ext_eo2)); assert (list->append ("1. Line", NULL, NULL)); @@ -59,11 +61,24 @@ int main (int argc, char **argv) assert (list->append ("4. Line", NULL, NULL)); list->go (); + // The code below accesses a Edje External widget (here: Elementary Progressbar) in a type save way Eflxx::CountedPtr ext_eo3 (edje->getPart ("Progressbar01")->getExternalObject ()); - Elmxx::Progressbar *progressbar = static_cast (&(*ext_eo3)); - progressbar->setLabel ("This is the status"); - progressbar->setValue (0.5); + cout << "Edje Widget type: " << ext_eo3->getType () << endl; + if (ext_eo3->getType () == "elm_widget") + { + Elmxx::Object *elm_object = static_cast (&(*ext_eo3)); + cout << "Elm Widget type: " << elm_object->getWidgetType () << endl; + if (elm_object->getWidgetType () == "progressbar") + { + Elmxx::Progressbar *progressbar = static_cast (elm_object); + progressbar->setLabel ("This is the status"); + progressbar->setValue (0.5); + progressbar->obj(); + } + } + + // This External access is save as it only calls the ExternalParam interface Eflxx::CountedPtr part (edje->getPart ("Slider01")); Edjexx::ExternalParam param ("value", 5.0f); diff --git a/elementaryxx/include/elementaryxx/Object.h b/elementaryxx/include/elementaryxx/Object.h index 4be5887..093ee14 100644 --- a/elementaryxx/include/elementaryxx/Object.h +++ b/elementaryxx/include/elementaryxx/Object.h @@ -24,6 +24,26 @@ public: virtual void focus (); + /*! + * Check if the given Evas Object is an Elementary widget. + */ + bool checkWidget (); + + /*! + * Get the first parent of the given object that is an Elementary widget. + */ + Eflxx::CountedPtr getParentWidget (); + + /*! + * Get the top level parent of an Elementary widget. + */ + Eflxx::CountedPtr getTopWidget (); + + /*! + * Get the string that represents this Elementary widget. + */ + const std::string getWidgetType (); + /*void elm_object_scroll_hold_push(Evas_Object *obj); void elm_object_scroll_hold_pop(Evas_Object *obj); void elm_object_scroll_freeze_push(Evas_Object *obj); diff --git a/elementaryxx/src/Object.cpp b/elementaryxx/src/Object.cpp index 62731de..920fc9b 100644 --- a/elementaryxx/src/Object.cpp +++ b/elementaryxx/src/Object.cpp @@ -79,4 +79,32 @@ void Object::focus () elm_object_focus (o); } +bool Object::checkWidget () +{ + return elm_object_widget_check (o); +} + +Eflxx::CountedPtr Object::getParentWidget () +{ + Evas_Object *eo = elm_object_parent_widget_get (o); + + Evasxx::Object *ret_o = Evasxx::Object::wrap (eo); + + return Eflxx::CountedPtr (ret_o); +} + +Eflxx::CountedPtr Object::getTopWidget () +{ + Evas_Object *eo = elm_object_top_widget_get (o); + + Evasxx::Object *ret_o = Evasxx::Object::wrap (eo); + + return Eflxx::CountedPtr (ret_o); +} + +const std::string Object::getWidgetType () +{ + return elm_object_widget_type_get (o); +} + } // end namespace Elmxx