elementary - modified content_set/get/unset part names to be simple names.
[framework/uifw/elementary.git] / src / lib / elm_panel.c
index be50fbb..b4de56d 100644 (file)
@@ -1,24 +1,10 @@
 #include <Elementary.h>
 #include "elm_priv.h"
-
-/**
- * @defgroup Panel Panel
- *
- * A panel is a type of animated container that contains subobjects.  It
- * can be expanded or contracted.
- *
- * Orientations are as follows:
- * ELM_PANEL_ORIENT_TOP
- * ELM_PANEL_ORIENT_BOTTOM
- * ELM_PANEL_ORIENT_LEFT
- * ELM_PANEL_ORIENT_RIGHT
- * NOTE: Only LEFT and RIGHT orientations are implemented.
- *
- * THIS WIDGET IS UNDER CONSTRUCTION!
- */
+#include "els_scroller.h"
+#include "els_box.h"
 
 typedef struct _Widget_Data Widget_Data;
-struct _Widget_Data 
+struct _Widget_Data
 {
    Evas_Object *scr, *bx, *content;
    Elm_Panel_Orient orient;
@@ -34,8 +20,8 @@ static void _resize(void *data, Evas *evas, Evas_Object *obj, void *event);
 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
 static void _toggle_panel(void *data, Evas_Object *obj, const char *emission, const char *source);
 
-static void 
-_del_hook(Evas_Object *obj) 
+static void
+_del_hook(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
@@ -55,11 +41,12 @@ _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
      }
 }
 
-static void 
-_theme_hook(Evas_Object *obj) 
+static void
+_theme_hook(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
+   _elm_widget_mirrored_reload(obj);
    if (wd->scr)
      {
         Evas_Object *edj;
@@ -105,7 +92,7 @@ _elm_panel_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas
 
    /* Try Focus cycle in subitem */
    if (!wd->hidden)
-      return elm_widget_focus_next_get(cur, dir, next);
+     return elm_widget_focus_next_get(cur, dir, next);
 
    /* Return */
    *next = (Evas_Object *)obj;
@@ -118,29 +105,29 @@ _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
-        emission, source);
+                           emission, source);
 }
 
 static void
-_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
+_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
-        emission, source, func_cb, data);
+                                   emission, source, func_cb, data);
 }
 
 static void
-_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
+_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    edje_object_signal_callback_del_full(
-        elm_smart_scroller_edje_object_get(wd->scr), emission, source,
-        func_cb, data);
+      elm_smart_scroller_edje_object_get(wd->scr), emission, source,
+      func_cb, data);
 }
 
-static void 
-_sizing_eval(Evas_Object *obj) 
+static void
+_sizing_eval(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Coord mw = -1, mh = -1;
@@ -148,7 +135,7 @@ _sizing_eval(Evas_Object *obj)
    Evas_Coord w, h;
    if (!wd) return;
    evas_object_smart_calculate(wd->bx);
-   edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), 
+   edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
                              &mw, &mh);
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
    if (w < mw) w = mw;
@@ -167,7 +154,7 @@ _sizing_eval(Evas_Object *obj)
    evas_object_size_hint_max_set(obj, -1, -1);
 }
 
-static void 
+static void
 _resize(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
@@ -182,29 +169,29 @@ _resize(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *ev
      }
 }
 
-static void 
-_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data) 
+static void
+_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
 {
    Widget_Data *wd = data;
    if (!wd) return;
    _els_box_layout(o, priv, EINA_TRUE, EINA_FALSE, EINA_FALSE);
 }
 
-static void 
-_toggle_panel(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__) 
+static void
+_toggle_panel(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
-   if (wd->hidden) 
+   if (wd->hidden)
      {
-        edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), 
+        edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
                                 "elm,action,show", "elm");
         wd->hidden = EINA_FALSE;
         evas_object_repeat_events_set(obj, EINA_FALSE);
      }
    else
      {
-        edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), 
+        edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
                                 "elm,action,hide", "elm");
         wd->hidden = EINA_TRUE;
         evas_object_repeat_events_set(obj, EINA_TRUE);
@@ -238,28 +225,64 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
    return EINA_TRUE;
 }
 
-/**
- * Adds a panel object
- *
- * @param parent The parent object
- *
- * @return The panel object, or NULL on failure
- *
- * @ingroup Panel
- */
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd;
+
+   if (part && strcmp(part, "default")) return;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->content == content) return;
+   if (wd->content)
+     evas_object_box_remove_all(wd->bx, EINA_TRUE);
+   wd->content = content;
+   if (content)
+     {
+        evas_object_box_append(wd->bx, wd->content);
+        evas_object_show(wd->content);
+     }
+   _sizing_eval(obj);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd;
+
+   if (part && strcmp(part, "default")) return NULL;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   return wd->content;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd;
+   Evas_Object *content;
+   if (part && strcmp(part, "default")) return NULL;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   if (!wd->content) return NULL;
+   content = wd->content;
+   evas_object_box_remove_all(wd->bx, EINA_FALSE);
+   wd->content = NULL;
+   return content;
+}
+
 EAPI Evas_Object *
-elm_panel_add(Evas_Object *parent) 
+elm_panel_add(Evas_Object *parent)
 {
    Evas_Object *obj;
-   Evas *evas;
+   Evas *e;
    Widget_Data *wd;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
 
-   wd = ELM_NEW(Widget_Data);
-   evas = evas_object_evas_get(parent);
-   if (!evas) return NULL;
-   obj = elm_widget_add(evas);
    ELM_SET_WIDTYPE(widtype, "panel");
    elm_widget_type_set(obj, "panel");
    elm_widget_sub_object_add(parent, obj);
@@ -273,27 +296,30 @@ elm_panel_add(Evas_Object *parent)
    elm_widget_focus_next_hook_set(obj, _elm_panel_focus_next_hook);
    elm_widget_can_focus_set(obj, EINA_TRUE);
    elm_widget_event_hook_set(obj, _event_hook);
+   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->scr = elm_smart_scroller_add(evas);
+   wd->scr = elm_smart_scroller_add(e);
    elm_smart_scroller_widget_set(wd->scr, obj);
    _theme_hook(obj);
    elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_FALSE);
    elm_widget_resize_object_set(obj, wd->scr);
-   elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF, 
+   elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
                                  ELM_SMART_SCROLLER_POLICY_OFF);
 
    wd->hidden = EINA_FALSE;
    wd->orient = ELM_PANEL_ORIENT_LEFT;
 
-   wd->bx = evas_object_box_add(evas);
+   wd->bx = evas_object_box_add(e);
    evas_object_size_hint_align_set(wd->bx, 0.5, 0.5);
    evas_object_box_layout_set(wd->bx, _layout, wd, NULL);
    elm_widget_sub_object_add(obj, wd->bx);
    elm_smart_scroller_child_set(wd->scr, wd->bx);
    evas_object_show(wd->bx);
 
-   edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr), 
-                                   "elm,action,panel,toggle", "*", 
+   edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
+                                   "elm,action,panel,toggle", "*",
                                    _toggle_panel, obj);
 
    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
@@ -303,150 +329,65 @@ elm_panel_add(Evas_Object *parent)
    return obj;
 }
 
-/**
- * Sets the orientation of the panel
- *
- * @param parent The parent object
- * @param orient The panel orientation.  Can be one of the following:
- * ELM_PANEL_ORIENT_TOP
- * ELM_PANEL_ORIENT_BOTTOM
- * ELM_PANEL_ORIENT_LEFT
- * ELM_PANEL_ORIENT_RIGHT
- *
- * NOTE: Only LEFT and RIGHT orientations are implemented.
- *
- * @ingroup Panel
- */
-EAPI void 
-elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient) 
+EAPI void
+elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    wd->orient = orient;
-   switch (orient) 
+   switch (orient)
      {
-     case ELM_PANEL_ORIENT_TOP:
-        elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "top");
-        break;
-     case ELM_PANEL_ORIENT_BOTTOM:
-        elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "bottom");
-        break;
-     case ELM_PANEL_ORIENT_LEFT:
-        if (!elm_widget_mirrored_get(obj))
-          elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left");
-        else
-          elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "right");
-        break;
-     case ELM_PANEL_ORIENT_RIGHT:
-        if (!elm_widget_mirrored_get(obj))
-          elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "right");
-        else
-          elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left");
-        break;
+      case ELM_PANEL_ORIENT_TOP:
+         elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "top");
+         break;
+      case ELM_PANEL_ORIENT_BOTTOM:
+         elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "bottom");
+         break;
+      case ELM_PANEL_ORIENT_LEFT:
+         if (!elm_widget_mirrored_get(obj))
+           elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left");
+         else
+           elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "right");
+         break;
+      case ELM_PANEL_ORIENT_RIGHT:
+         if (!elm_widget_mirrored_get(obj))
+           elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "right");
+         else
+           elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left");
+         break;
      }
 
    _sizing_eval(obj);
 }
 
-/**
- * Get the orientation of the panel.
- *
- * @param obj The panel object
- * @return The Elm_Panel_Orient, or ELM_PANEL_ORIENT_LEFT on failure.
- *
- * @ingroup Panel
- */
 EAPI Elm_Panel_Orient
 elm_panel_orient_get(const Evas_Object *obj)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) ELM_PANEL_ORIENT_LEFT;
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return ELM_PANEL_ORIENT_LEFT;
-   return wd->orient;   
+   return wd->orient;
 }
 
-/**
- * Set the content of the panel.
- *
- * Once the content object is set, a previously set one will be deleted.
- * If you want to keep that old content object, use the
- * elm_panel_content_unset() function.
- *
- * @param obj The panel object
- * @param content The panel content
- *
- * @ingroup Panel
- */
 EAPI void
 elm_panel_content_set(Evas_Object *obj, Evas_Object *content)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return;
-   if (wd->content == content) return;
-   if (wd->content)
-     evas_object_box_remove_all(wd->bx, EINA_TRUE);
-   wd->content = content;
-   if (content)
-     {
-       evas_object_box_append(wd->bx, wd->content);
-       evas_object_show(wd->content);
-     }
-   _sizing_eval(obj);
+   _content_set_hook(obj, NULL, content);
 }
 
-/**
- * Get the content of the panel.
- *
- * Return the content object which is set for this widget.
- *
- * @param obj The panel object
- * @return The content that is being used
- *
- * @ingroup Panel
- */
 EAPI Evas_Object *
 elm_panel_content_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->content;
+   return _content_get_hook(obj, NULL);
 }
 
-/**
- * Unset the content of the panel.
- *
- * Unparent and return the content object which was set for this widget.
- *
- * @param obj The panel object
- * @return The content that was being used
- *
- * @ingroup Panel
- */
 EAPI Evas_Object *
 elm_panel_content_unset(Evas_Object *obj)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   Evas_Object *content;
-   if (!wd) return NULL;
-   if (!wd->content) return NULL;
-   content = wd->content;
-   evas_object_box_remove_all(wd->bx, EINA_FALSE);
-   wd->content = NULL;
-   return content;
+   return _content_unset_hook(obj, NULL);
 }
 
-/**
- * Set the state of the panel.
- *
- * @param obj The panel object
- * @param hidden If true, the panel will run the edje animation to contract
- *
- * @ingroup Panel
- */
 EAPI void
 elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden)
 {
@@ -457,14 +398,6 @@ elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden)
    _toggle_panel(obj, NULL, "elm,action,panel,toggle", "*");
 }
 
-/**
- * Get the state of the panel.
- *
- * @param obj The panel object
- * @param hidden If true, the panel is in the "hide" state
- *
- * @ingroup Panel
- */
 EAPI Eina_Bool
 elm_panel_hidden_get(const Evas_Object *obj)
 {
@@ -474,19 +407,11 @@ elm_panel_hidden_get(const Evas_Object *obj)
    return wd->hidden;
 }
 
-/**
- * Toggle the state of the panel from code
- *
- * @param obj The panel object
- *
- * @ingroup Panel
- */
 EAPI void
 elm_panel_toggle(Evas_Object *obj)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->hidden = !(wd->hidden);
    _toggle_panel(obj, NULL, "elm,action,panel,toggle", "*");
 }