[genlist] apply r71140 with local enhancement
[framework/uifw/elementary.git] / src / lib / elm_bg.c
index 21a4a7b..df29d5b 100644 (file)
@@ -8,9 +8,10 @@ struct _Widget_Data
    Evas_Object *base, *rect, *img, *overlay;
    const char  *file, *group;
    Elm_Bg_Option option;
-   struct {
-      Evas_Coord w, h;
-   } load_opts;
+   struct
+     {
+        Evas_Coord w, h;
+     } load_opts;
 };
 
 static const char *widtype = NULL;
@@ -18,6 +19,9 @@ static const char *widtype = NULL;
 static void _del_hook(Evas_Object *obj);
 static void _theme_hook(Evas_Object *obj);
 static void _custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info);
+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
 _del_hook(Evas_Object *obj)
@@ -113,6 +117,56 @@ _custom_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void
    evas_object_size_hint_max_set(wd->img, mw, mh);
 }
 
+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, "overlay")) return;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   if (content == wd->overlay) return;
+   if (wd->overlay) evas_object_del(wd->overlay);
+
+   wd->overlay = content;
+   if (content)
+     {
+        edje_object_part_swallow(wd->base, "elm.swallow.content", content);
+        elm_widget_sub_object_add(obj, content);
+     }
+
+   _custom_resize(wd, NULL, NULL, NULL);
+}
+
+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, "overlay")) return NULL;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   return wd->overlay;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd;
+   Evas_Object *overlay;
+   if (part && strcmp(part, "overlay")) return NULL;
+   wd = elm_widget_data_get(obj);
+   if (!wd || !wd->overlay) return NULL;
+   overlay = wd->overlay;
+   elm_widget_sub_object_del(obj, wd->overlay);
+   edje_object_part_unswallow(wd->base, wd->overlay);
+   wd->overlay = NULL;
+   _custom_resize(wd, NULL, NULL, NULL);
+   return overlay;
+}
+
 EAPI Evas_Object *
 elm_bg_add(Evas_Object *parent)
 {
@@ -128,6 +182,10 @@ elm_bg_add(Evas_Object *parent)
    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->base = edje_object_add(e);
@@ -141,10 +199,10 @@ elm_bg_add(Evas_Object *parent)
    return obj;
 }
 
-EAPI void
+EAPI Eina_Bool
 elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
    Widget_Data *wd = elm_widget_data_get(obj);
    const char *p;
 
@@ -159,7 +217,7 @@ elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
         wd->file = NULL;
         eina_stringshare_del(wd->group);
         wd->group = NULL;
-        return;
+        return EINA_TRUE;
      }
    eina_stringshare_replace(&wd->file, file);
    eina_stringshare_replace(&wd->group, group);
@@ -179,6 +237,8 @@ elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
    edje_object_part_swallow(wd->base, "elm.swallow.background", wd->img);
    elm_widget_sub_object_add(obj, wd->img);
    _custom_resize(wd, NULL, NULL, NULL);
+
+   return EINA_TRUE;
 }
 
 EAPI void
@@ -188,6 +248,8 @@ elm_bg_file_get(const Evas_Object *obj, const char **file, const char **group)
    Widget_Data *wd = elm_widget_data_get(obj);
    if (file) *file = wd->file;
    if (group) *group = wd->group;
+
+   return;
 }
 
 EAPI void
@@ -199,12 +261,14 @@ elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
    wd = elm_widget_data_get(obj);
    wd->option = option;
    _custom_resize(wd, NULL, NULL, NULL);
+
+   return;
 }
 
 EAPI Elm_Bg_Option
 elm_bg_option_get(const Evas_Object *obj)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype) 0;
+   ELM_CHECK_WIDTYPE(obj, widtype) ELM_BG_OPTION_LAST;
    Widget_Data *wd;
 
    wd = elm_widget_data_get(obj);
@@ -226,6 +290,8 @@ elm_bg_color_set(Evas_Object *obj, int r, int g, int b)
         _custom_resize(wd, NULL, NULL, NULL);
      }
    evas_object_color_set(wd->rect, r, g, b, 255);
+
+   return;
 }
 
 EAPI void
@@ -236,52 +302,8 @@ elm_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b)
 
    wd = elm_widget_data_get(obj);
    evas_object_color_get(wd->rect, r, g, b, NULL);
-}
-
-EAPI void
-elm_bg_overlay_set(Evas_Object *obj, Evas_Object *overlay)
-{
-   ELM_CHECK_WIDTYPE(obj, widtype);
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return;
-   if (wd->overlay)
-     {
-        evas_object_del(wd->overlay);
-        wd->overlay = NULL;
-     }
-   if (overlay)
-     {
-        wd->overlay = overlay;
-        edje_object_part_swallow(wd->base, "elm.swallow.content", wd->overlay);
-        elm_widget_sub_object_add(obj, wd->overlay);
-     }
 
-   _custom_resize(wd, NULL, NULL, NULL);
-}
-
-EAPI Evas_Object *
-elm_bg_overlay_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->overlay;
-}
-
-EAPI Evas_Object *
-elm_bg_overlay_unset(Evas_Object *obj)
-{
-   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   Evas_Object *overlay;
-   if (!wd) return NULL;
-   if (!wd->overlay) return NULL;
-   overlay = wd->overlay;
-   elm_widget_sub_object_del(obj, wd->overlay);
-   edje_object_part_unswallow(wd->base, wd->overlay);
-   wd->overlay = NULL;
-   _custom_resize(wd, NULL, NULL, NULL);
-   return overlay;
+   return;
 }
 
 EAPI void
@@ -296,5 +318,7 @@ elm_bg_load_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
    if (!wd->img) return;
    if (!(((p = strrchr(wd->file, '.'))) && (!strcasecmp(p, ".edj"))))
      evas_object_image_load_size_set(wd->img, w, h);
+
+   return;
 }