In case a user sets min-value of the item, the toolbar shouldn't set the min-value...
[framework/uifw/elementary.git] / src / lib / elm_mapbuf.c
index 1c52ba8..4608872 100644 (file)
@@ -1,12 +1,6 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
-/**
- * @defgroup Mapbuf Mapbuf
- *
- * This holds 1 content object and uses an Evas Map to move/resize etc. it.
- */
-
 typedef struct _Widget_Data Widget_Data;
 
 struct _Widget_Data
@@ -72,10 +66,10 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
    if (!wd) return;
    if (sub == wd->content)
      {
-       evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+        evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
                                             _changed_size_hints, obj);
-       wd->content = NULL;
-       _sizing_eval(obj);
+        wd->content = NULL;
+        _sizing_eval(obj);
      }
 }
 
@@ -95,13 +89,13 @@ _mapbuf(Evas_Object *obj)
         evas_map_smooth_set(m, wd->smooth);
         evas_map_alpha_set(m, wd->alpha);
         evas_object_map_set(wd->content, m);
-        evas_object_map_enable_set(wd->content, wd->enabled);
+        evas_object_map_enable_set(wd->content, EINA_TRUE);
         evas_map_free(m);
      }
    else
      {
         evas_object_map_set(wd->content, NULL);
-        evas_object_map_enable_set(wd->content, 0);
+        evas_object_map_enable_set(wd->content, EINA_FALSE);
         evas_object_move(wd->content, x, y);
         evas_object_resize(wd->content, w, h);
      }
@@ -121,17 +115,15 @@ _configure(Evas_Object *obj)
         if ((x != x2) || (y != y2))
           {
              if (!wd->enabled)
-                evas_object_move(wd->content, x, y);
+               evas_object_move(wd->content, x, y);
              else
                {
-                  
+
                   Evas *e = evas_object_evas_get(obj);
                   evas_smart_objects_calculate(e);
                   evas_nochange_push(e);
-//                  printf("x-------------------- %i %i\n", x, y);
                   evas_object_move(wd->content, x, y);
                   evas_smart_objects_calculate(e);
-//                  printf("y--------------------\n");
                   evas_nochange_pop(e);
                }
           }
@@ -148,71 +140,18 @@ _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, vo
 
 static void
 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{    
+{
    _configure(data);
 }
 
-/**
- * Add a new mapbuf to the parent
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Mapbuf
- */
-EAPI Evas_Object *
-elm_mapbuf_add(Evas_Object *parent)
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
 {
-   Evas_Object *obj;
-   Evas *e;
+   ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd;
 
-   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
-   
-   ELM_SET_WIDTYPE(widtype, "mapbuf");
-   elm_widget_type_set(obj, "mapbuf");
-   elm_widget_sub_object_add(parent, obj);
-   elm_widget_data_set(obj, wd);
-   elm_widget_del_hook_set(obj, _del_hook);
-   elm_widget_theme_hook_set(obj, _theme_hook);
-   elm_widget_can_focus_set(obj, EINA_FALSE);
-
-   wd->clip = evas_object_rectangle_add(e);
-   evas_object_static_clip_set(wd->clip, EINA_TRUE);
-   evas_object_pass_events_set(wd->clip, EINA_TRUE);
-   evas_object_color_set(wd->clip, 0, 0, 0, 0);
-
-   evas_object_event_callback_add(wd->clip, EVAS_CALLBACK_MOVE, _move, obj);
-   evas_object_event_callback_add(wd->clip, EVAS_CALLBACK_RESIZE, _resize, obj);
-   evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
-  
-   elm_widget_resize_object_set(obj, wd->clip);
-   
-   wd->enabled = 0;
-   wd->alpha = 1;
-   wd->smooth = 1;
-   
-   _sizing_eval(obj);
-   return obj;
-}
-
-/**
- * Set the mapbuf front content
- *
- * 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_mapbuf_content_unset() function.
- *
- * @param obj The mapbuf object
- * @param content The content will be filled in this mapbuf object
- *
- * @ingroup Mapbuf
- */
-EAPI void
-elm_mapbuf_content_set(Evas_Object *obj, Evas_Object *content)
-{
-   ELM_CHECK_WIDTYPE(obj, widtype);
-   Widget_Data *wd = elm_widget_data_get(obj);
+   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_del(wd->content);
@@ -220,13 +159,13 @@ elm_mapbuf_content_set(Evas_Object *obj, Evas_Object *content)
    if (content)
      {
         evas_object_data_set(content, "_elm_leaveme", (void *)1);
-       elm_widget_sub_object_add(content, obj);
-       evas_object_smart_member_add(content, obj);
+        elm_widget_sub_object_add(obj, content);
+        evas_object_smart_member_add(content, obj);
         evas_object_clip_set(content, wd->clip);
         evas_object_color_set(wd->clip, 255, 255, 255, 255);
-       evas_object_event_callback_add(content,
+        evas_object_event_callback_add(content,
                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-                                      _changed_size_hints, obj);
+                                       _changed_size_hints, obj);
      }
    else
      evas_object_color_set(wd->clip, 0, 0, 0, 0);
@@ -234,61 +173,76 @@ elm_mapbuf_content_set(Evas_Object *obj, Evas_Object *content)
    _configure(obj);
 }
 
-/**
- * Get the mapbuf front content
- *
- * Return the content object which is set for this widget.
- *
- * @param obj The mapbuf object
- * @return The content that is being used
- *
- * @ingroup Mapbuf
- */
-EAPI Evas_Object *
-elm_mapbuf_content_get(const Evas_Object *obj)
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
+   Widget_Data *wd;
+
+   if (part && strcmp(part, "default")) return NULL;
+   wd = elm_widget_data_get(obj);
    if (!wd) return NULL;
    return wd->content;
 }
 
-/**
- * Unset the mapbuf front content
- *
- * Unparent and return the content object which was set for this widget.
- *
- * @param obj The mapbuf object
- * @return The content that was being used
- *
- * @ingroup Mapbuf
- */
-EAPI Evas_Object *
-elm_mapbuf_content_unset(Evas_Object *obj)
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
+   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;
    elm_widget_sub_object_del(obj, content);
    evas_object_smart_member_del(content);
    evas_object_color_set(wd->clip, 0, 0, 0, 0);
-   evas_object_clip_unset(content);
    evas_object_data_del(content, "_elm_leaveme");
-   wd->content = NULL;
    return content;
 }
 
-/**
- * Set the mapbuf enabled state
- *
- * @param obj The mapbuf object
- * @param enabled The value to set the enabled state to
- *
- * @ingroup Mapbuf
- */
+EAPI Evas_Object *
+elm_mapbuf_add(Evas_Object *parent)
+{
+   Evas_Object *obj;
+   Evas *e;
+   Widget_Data *wd;
+
+   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
+
+   ELM_SET_WIDTYPE(widtype, "mapbuf");
+   elm_widget_type_set(obj, "mapbuf");
+   elm_widget_sub_object_add(parent, obj);
+   elm_widget_data_set(obj, wd);
+   elm_widget_del_hook_set(obj, _del_hook);
+   elm_widget_theme_hook_set(obj, _theme_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);
+   elm_widget_can_focus_set(obj, EINA_FALSE);
+
+   wd->clip = evas_object_rectangle_add(e);
+   evas_object_static_clip_set(wd->clip, EINA_TRUE);
+   evas_object_pass_events_set(wd->clip, EINA_TRUE);
+   evas_object_color_set(wd->clip, 0, 0, 0, 0);
+
+   evas_object_event_callback_add(wd->clip, EVAS_CALLBACK_MOVE, _move, obj);
+   evas_object_event_callback_add(wd->clip, EVAS_CALLBACK_RESIZE, _resize, obj);
+   evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
+
+   elm_widget_resize_object_set(obj, wd->clip);
+
+   wd->enabled = 0;
+   wd->alpha = 1;
+   wd->smooth = 1;
+
+   _sizing_eval(obj);
+   return obj;
+}
+
 EAPI void
 elm_mapbuf_enabled_set(Evas_Object *obj, Eina_Bool enabled)
 {
@@ -301,14 +255,6 @@ elm_mapbuf_enabled_set(Evas_Object *obj, Eina_Bool enabled)
    _configure(obj);
 }
 
-/**
- * Get the mapbuf enabled state
- *
- * @param obj The mapbuf object
- * @return The value that the enabled state is set to
- *
- * @ingroup Mapbuf
- */
 EAPI Eina_Bool
 elm_mapbuf_enabled_get(const Evas_Object *obj)
 {
@@ -318,14 +264,6 @@ elm_mapbuf_enabled_get(const Evas_Object *obj)
    return wd->enabled;
 }
 
-/**
- * Sets the mapbuf smooth state
- *
- * @param obj The mapbuf object
- * @param smooth The value of the smooth state of @p obj
- *
- * @ingroup Mapbuf
- */
 EAPI void
 elm_mapbuf_smooth_set(Evas_Object *obj, Eina_Bool smooth)
 {
@@ -337,14 +275,6 @@ elm_mapbuf_smooth_set(Evas_Object *obj, Eina_Bool smooth)
    _configure(obj);
 }
 
-/**
- * Gets the mapbuf smooth state
- *
- * @param obj The mapbuf object
- * @return The value of the smooth state of @p obj
- *
- * @ingroup Mapbuf
- */
 EAPI Eina_Bool
 elm_mapbuf_smooth_get(const Evas_Object *obj)
 {
@@ -354,14 +284,6 @@ elm_mapbuf_smooth_get(const Evas_Object *obj)
    return wd->smooth;
 }
 
-/**
- * Enables/disables the mapbuf alpha channel
- *
- * @param obj The mapbuf object
- * @param alpha The state of the alpha channel
- *
- * @ingroup Mapbuf
- */
 EAPI void
 elm_mapbuf_alpha_set(Evas_Object *obj, Eina_Bool alpha)
 {
@@ -373,14 +295,6 @@ elm_mapbuf_alpha_set(Evas_Object *obj, Eina_Bool alpha)
    _configure(obj);
 }
 
-/**
- * Gets the state of the mapbuf alpha channel
- *
- * @param obj The mapbuf object
- * @return The state of the alpha channel
- *
- * @ingroup Mapbuf
- */
 EAPI Eina_Bool
 elm_mapbuf_alpha_get(const Evas_Object *obj)
 {