elementary/check - content_set/get/unset
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 28 Oct 2011 08:57:33 +0000 (08:57 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 28 Oct 2011 08:57:33 +0000 (08:57 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@64487 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

doc/widgets/widget_preview_check2.c
doc/widgets/widget_preview_check3.c
src/bin/test_check.c
src/bin/test_toggle.c
src/edje_externals/elm_check.c
src/edje_externals/elm_toggle.c
src/examples/check_example_01.c
src/lib/Elementary.h.in
src/lib/elm_check.c
src/lib/elm_toggle.c

index 84e4c66..d62cc3b 100644 (file)
@@ -9,7 +9,7 @@ elm_object_text_set(o, "Check");
 
 Evas_Object *o2 = elm_icon_add(win);
 elm_icon_standard_set(o2, "home");
-elm_check_icon_set(o, o2);
+elm_object_content_set(o, o2);
 evas_object_show(o2);
 
 #include "widget_preview_tmpl_foot.c"
index b027770..6e4ab64 100644 (file)
@@ -7,7 +7,7 @@ evas_object_show(o);
 
 Evas_Object *o2 = elm_icon_add(win);
 elm_icon_standard_set(o2, "home");
-elm_check_icon_set(o, o2);
+elm_object_content_set(o, o2);
 evas_object_show(o2);
 
 #include "widget_preview_tmpl_foot.c"
index be807d2..0de6bdc 100644 (file)
@@ -31,7 +31,7 @@ test_check(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
    elm_object_text_set(ck, "Icon sized to check");
-   elm_check_icon_set(ck, ic);
+   elm_object_content_set(ck, ic);
    elm_check_state_set(ck, 1);
    elm_box_pack_end(bx, ck);
    evas_object_show(ck);
@@ -43,7 +43,7 @@ test_check(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    elm_icon_scale_set(ic, 0, 0);
    ck = elm_check_add(win);
    elm_object_text_set(ck, "Icon no scale");
-   elm_check_icon_set(ck, ic);
+   elm_object_content_set(ck, ic);
    elm_box_pack_end(bx, ck);
    evas_object_show(ck);
    evas_object_show(ic);
@@ -61,7 +61,7 @@ test_check(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
    elm_object_text_set(ck, "Disabled check");
-   elm_check_icon_set(ck, ic);
+   elm_object_content_set(ck, ic);
    elm_check_state_set(ck, 1);
    elm_box_pack_end(bx, ck);
    elm_object_disabled_set(ck, 1);
@@ -73,7 +73,7 @@ test_check(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    elm_icon_file_set(ic, buf, NULL);
    elm_icon_scale_set(ic, 0, 0);
    ck = elm_check_add(win);
-   elm_check_icon_set(ck, ic);
+   elm_object_content_set(ck, ic);
    elm_box_pack_end(bx, ck);
    evas_object_show(ck);
    evas_object_show(ic);
index 5ca11d9..9fb813f 100644 (file)
@@ -33,7 +33,7 @@ test_toggle(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
    elm_object_text_set(tg, "Icon sized to toggle");
-   elm_check_icon_set(tg, ic);
+   elm_object_content_set(tg, ic);
    elm_check_state_set(tg, 1);
    elm_object_text_part_set(tg, "on", "Yes");
    elm_object_text_part_set(tg, "off", "No");
@@ -49,7 +49,7 @@ test_toggle(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    tg = elm_check_add(win);
    elm_object_style_set(tg, "toggle");
    elm_object_text_set(tg, "Icon no scale");
-   elm_check_icon_set(tg, ic);
+   elm_object_content_set(tg, ic);
    elm_box_pack_end(bx, tg);
    evas_object_show(tg);
    evas_object_show(ic);
@@ -62,7 +62,7 @@ test_toggle(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
    tg = elm_check_add(win);
    elm_object_style_set(tg, "toggle");
    elm_object_text_set(tg, "Icon no scale");
-   elm_check_icon_set(tg, ic);
+   elm_object_content_set(tg, ic);
    elm_object_disabled_set(tg, 1);
    elm_box_pack_end(bx, tg);
    evas_object_show(tg);
@@ -83,7 +83,7 @@ test_toggle(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
 
    tg = elm_check_add(win);
    elm_object_style_set(tg, "toggle");
-   elm_check_icon_set(tg, ic);
+   elm_object_content_set(tg, ic);
    elm_box_pack_end(bx, tg);
    evas_object_show(tg);
    evas_object_show(ic);
index 985a39c..0c3fd0a 100644 (file)
@@ -21,7 +21,7 @@ external_check_state_set(void *data __UNUSED__, Evas_Object *obj, const void *fr
    if (p->label)
      elm_object_text_set(obj, p->label);
    if (p->icon)
-     elm_check_icon_set(obj, p->icon);
+     elm_object_content_set(obj, p->icon);
    if (p->state_exists)
      elm_check_state_set(obj, p->state);
 }
@@ -43,7 +43,7 @@ external_check_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Ext
          {
             Evas_Object *icon = external_common_param_icon_get(obj, param);
             if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
-            elm_check_icon_set(obj, icon);
+            elm_object_content_set(obj, icon);
             return EINA_TRUE;
          }
      }
index 86c0437..7d9e097 100644 (file)
@@ -24,7 +24,7 @@ external_toggle_state_set(void *data __UNUSED__, Evas_Object *obj, const void *f
    if (p->label)
      elm_object_text_set(obj, p->label);
    if (p->icon)
-     elm_check_icon_set(obj, p->icon);
+     elm_object_content_set(obj, p->icon);
 
    if (p->on)
      elm_object_text_part_set(obj, "on", p->on);
@@ -52,7 +52,7 @@ external_toggle_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Ex
          {
             Evas_Object *icon = external_common_param_icon_get(obj, param);
             if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
-            elm_check_icon_set(obj, icon);
+            elm_object_content_set(obj, icon);
             return EINA_TRUE;
          }
      }
index 40c4a2b..2f5e99a 100644 (file)
@@ -40,7 +40,7 @@ elm_main(int argc, char **argv)
    cb2 = elm_check_add(win);
    elm_object_text_set(cb2, "another checkbox");
    elm_check_state_set(cb2, EINA_TRUE);
-   elm_check_icon_set(cb2, icon);
+   elm_object_content_set(cb2, icon);
    evas_object_move(cb2, 10, 50);
    evas_object_resize(cb2, 200, 30);
    evas_object_show(cb2);
index dd018b7..8897d55 100644 (file)
@@ -6170,7 +6170,7 @@ extern "C" {
     *
     * Default text parts of the button widget that you can use for are:
     *
-    * @li "elm.text" - Title label of the button
+    * @li "elm.text" - Label of the button
     *
     * Follow through a complete example @ref button_example_01 "here".
     * @{
@@ -7658,7 +7658,7 @@ extern "C" {
     * If you want to keep that old content object, use the
     * elm_toggle_icon_unset() function.
     *
-    * @deprecated use elm_check_icon_set() instead.
+    * @deprecated use elm_object_content_set() instead.
     */
    EINA_DEPRECATED EAPI void         elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
    /**
@@ -7671,7 +7671,7 @@ extern "C" {
     *
     * @see elm_toggle_icon_set()
     *
-    * @deprecated use elm_check_icon_get() instead.
+    * @deprecated use elm_object_content_get() instead.
     */
    EINA_DEPRECATED EAPI Evas_Object *elm_toggle_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
    /**
@@ -7684,7 +7684,7 @@ extern "C" {
     *
     * @see elm_toggle_icon_set()
     *
-    * @deprecated use elm_check_icon_unset() instead.
+    * @deprecated use elm_object_content_unset() instead.
     */
    EINA_DEPRECATED EAPI Evas_Object *elm_toggle_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
    /**
@@ -19668,7 +19668,16 @@ extern "C" {
     * "changed" - This is called whenever the user changes the state of one of
     *             the check object(event_info is NULL).
     *
-    * @ref tutorial_check should give you a firm grasp of how to use this widget.
+    * Default contents parts of the check widget that you can use for are:
+    *
+    * @li "elm.swallow.content" - A icon of the check
+    *
+    * Default text parts of the check widget that you can use for are:
+    *
+    * @li "elm.text" - Label of the check
+    *
+    * @ref tutorial_check should give you a firm grasp of how to use this widget
+    * .
     * @{
     */
    /**
@@ -19704,16 +19713,16 @@ extern "C" {
     *
     * Once the icon object is set, a previously set one will be deleted.
     * If you want to keep that old content object, use the
-    * elm_check_icon_unset() function.
+    * elm_object_content_unset() function.
     */
-   EAPI void         elm_check_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
+   EINA_DEPRECATED EAPI void         elm_check_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
    /**
     * @brief Get the icon object of the check object
     *
     * @param obj The check object
     * @return The icon object
     */
-   EAPI Evas_Object *elm_check_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+   EINA_DEPRECATED EAPI Evas_Object *elm_check_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
    /**
     * @brief Unset the icon used for the check object
     *
@@ -19722,7 +19731,7 @@ extern "C" {
     *
     * Unparent and return the icon object which was set for this widget.
     */
-   EAPI Evas_Object *elm_check_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
+   EINA_DEPRECATED EAPI Evas_Object *elm_check_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
    /**
     * @brief Set the on/off state of the check object
     *
index 7f08900..7038c71 100644 (file)
@@ -25,6 +25,10 @@ static void _signal_check_on(void *data, Evas_Object *obj, const char *emission,
 static void _signal_check_toggle(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _on_focus_hook(void *data, Evas_Object *obj);
 static void _activate_hook(Evas_Object *obj);
+static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
+static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
+static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
+
 static void _activate(Evas_Object *obj);
 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
                              Evas_Callback_Type type, void *event_info);
@@ -203,6 +207,51 @@ _activate_hook(Evas_Object *obj)
 }
 
 static void
+_content_set_hook(Evas_Object *obj, const char *part __UNUSED__, Evas_Object *content)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->icon == content) return;
+   if (wd->icon) evas_object_del(wd->icon);
+   wd->icon = content;
+   if (content)
+     {
+        elm_widget_sub_object_add(obj, content);
+        evas_object_event_callback_add(content,
+                                       EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+                                       _changed_size_hints, obj);
+        edje_object_part_swallow(wd->chk, "elm.swallow.content", content);
+        edje_object_signal_emit(wd->chk, "elm,state,icon,visible", "elm");
+        edje_object_message_signal_process(wd->chk);
+     }
+   _sizing_eval(obj);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   return wd->icon;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   if (!wd->icon) return NULL;
+   Evas_Object *icon = wd->icon;
+   elm_widget_sub_object_del(obj, wd->icon);
+   edje_object_part_unswallow(wd->chk, wd->icon);
+   wd->icon = NULL;
+   return icon;
+}
+
+static void
 _activate(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
@@ -347,6 +396,9 @@ elm_check_add(Evas_Object *parent)
    elm_widget_event_hook_set(obj, _event_hook);
    elm_widget_text_set_hook_set(obj, _elm_check_label_set);
    elm_widget_text_get_hook_set(obj, _elm_check_label_get);
+   elm_widget_content_set_hook_set(obj, _content_set_hook);
+   elm_widget_content_get_hook_set(obj, _content_get_hook);
+   elm_widget_content_unset_hook_set(obj, _content_unset_hook);
 
    wd->chk = edje_object_add(e);
    _elm_theme_object_set(obj, wd->chk, "check", "base", "default");
@@ -406,45 +458,19 @@ elm_check_states_labels_get(const Evas_Object *obj, const char **ontext, const c
 EAPI void
 elm_check_icon_set(Evas_Object *obj, Evas_Object *icon)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return;
-   if (wd->icon == icon) return;
-   if (wd->icon) evas_object_del(wd->icon);
-   wd->icon = icon;
-   if (icon)
-     {
-        elm_widget_sub_object_add(obj, icon);
-        evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-                                       _changed_size_hints, obj);
-        edje_object_part_swallow(wd->chk, "elm.swallow.content", icon);
-        edje_object_signal_emit(wd->chk, "elm,state,icon,visible", "elm");
-        edje_object_message_signal_process(wd->chk);
-     }
-   _sizing_eval(obj);
+   _content_set_hook(obj, NULL, icon);
 }
 
 EAPI Evas_Object *
 elm_check_icon_get(const Evas_Object *obj)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return NULL;
-   return wd->icon;
+   return _content_get_hook(obj, NULL);
 }
 
 EAPI Evas_Object *
 elm_check_icon_unset(Evas_Object *obj)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return NULL;
-   if (!wd->icon) return NULL;
-   Evas_Object *icon = wd->icon;
-   elm_widget_sub_object_del(obj, wd->icon);
-   edje_object_part_unswallow(wd->chk, wd->icon);
-   wd->icon = NULL;
-   return icon;
+   return _content_unset_hook(obj, NULL);
 }
 
 EAPI void
index b4c8edb..e2b195e 100644 (file)
@@ -28,19 +28,19 @@ elm_toggle_label_get(const Evas_Object *obj)
 EAPI void
 elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon)
 {
-   elm_check_icon_set(obj, icon);
+   elm_object_content_set(obj, icon);
 }
 
 EAPI Evas_Object *
 elm_toggle_icon_get(const Evas_Object *obj)
 {
-   return elm_check_icon_get(obj);
+   return elm_object_content_get(obj);
 }
 
 EAPI Evas_Object *
 elm_toggle_icon_unset(Evas_Object *obj)
 {
-   return elm_check_icon_unset(obj);
+   return elm_object_content_unset(obj);
 }
 
 EAPI void