1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
13 static const char *widtype = NULL;
14 static void _del_hook(Evas_Object *obj);
15 static void _sizing_eval(Evas_Object *obj);
16 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
18 static const char SIG_REALIZE[] = "realize";
19 static const char SIG_UNREALIZE[] = "unrealize";
21 static const Evas_Smart_Cb_Description _signals[] = {
28 _del_hook(Evas_Object *obj)
30 Widget_Data *wd = elm_widget_data_get(obj);
32 if (wd->eval_job) ecore_job_del(wd->eval_job);
37 _focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
39 Widget_Data *wd = elm_widget_data_get(obj);
42 if ((!wd) || (!wd->content)) return EINA_FALSE;
44 return elm_widget_focus_next_get(cur, dir, next);
48 _sizing_eval(Evas_Object *obj)
50 Widget_Data *wd = elm_widget_data_get(obj);
51 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
54 if (!wd->content) return;
55 evas_object_size_hint_min_get(wd->content, &minw, &minh);
56 evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
57 evas_object_size_hint_min_set(obj, minw, minh);
58 evas_object_size_hint_max_set(obj, maxw, maxh);
64 Evas_Object *obj = data;
65 Evas_Coord x, y, w, h, cvx, cvy, cvw, cvh;
66 Widget_Data *wd = elm_widget_data_get(obj);
70 evas_object_geometry_get(obj, &x, &y, &w, &h);
71 evas_output_viewport_get(evas_object_evas_get(obj),
72 &cvx, &cvy, &cvw, &cvh);
73 if (ELM_RECTS_INTERSECT(x, y, w, h, cvx, cvy, cvw, cvh))
76 evas_object_smart_callback_call(obj, SIG_REALIZE, NULL);
81 evas_object_smart_callback_call(obj, SIG_UNREALIZE, NULL);
86 _eval(Evas_Object *obj)
88 Widget_Data *wd = elm_widget_data_get(obj);
91 if (wd->eval_job) ecore_job_del(wd->eval_job);
92 wd->eval_job = ecore_job_add(_eval_do, obj);
96 _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
102 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
108 _child_change(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
114 _child_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
116 Evas_Object *fobj = data;
117 Widget_Data *wd = elm_widget_data_get(fobj);
119 if (wd->content != obj) return;
120 evas_object_event_callback_del_full(wd->content,
121 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
123 evas_object_event_callback_del_full(wd->content,
130 elm_factory_add(Evas_Object *parent)
136 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
138 ELM_SET_WIDTYPE(widtype, "factory");
139 elm_widget_type_set(obj, "factory");
140 elm_widget_sub_object_add(parent, obj);
141 elm_widget_data_set(obj, wd);
142 elm_widget_del_hook_set(obj, _del_hook);
143 elm_widget_focus_next_hook_set(obj, _focus_next_hook);
144 elm_widget_can_focus_set(obj, EINA_FALSE);
146 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, NULL);
147 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
149 evas_object_smart_callbacks_descriptions_set(obj, _signals);
156 elm_factory_content_set(Evas_Object *obj, Evas_Object *content)
158 ELM_CHECK_WIDTYPE(obj, widtype);
159 Widget_Data *wd = elm_widget_data_get(obj);
161 if (wd->content == content) return;
162 if (wd->content) evas_object_del(wd->content);
163 wd->content = content;
164 elm_widget_resize_object_set(obj, wd->content);
165 evas_object_event_callback_add(wd->content, EVAS_CALLBACK_DEL,
167 evas_object_event_callback_add(wd->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
173 elm_factory_content_get(const Evas_Object *obj)
175 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
176 Widget_Data *wd = elm_widget_data_get(obj);
177 if (!wd) return NULL;