1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
8 Evas_Object *content, *clip;
14 static const char *widtype = NULL;
15 static void _del_hook(Evas_Object *obj);
16 static void _theme_hook(Evas_Object *obj);
17 static void _sizing_eval(Evas_Object *obj);
18 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
19 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
22 _del_hook(Evas_Object *obj)
24 Widget_Data *wd = elm_widget_data_get(obj);
30 _theme_hook(Evas_Object *obj)
32 Widget_Data *wd = elm_widget_data_get(obj);
38 _sizing_eval(Evas_Object *obj)
40 Widget_Data *wd = elm_widget_data_get(obj);
41 Evas_Coord minw = -1, minh = -1;
42 Evas_Coord maxw = -1, maxh = -1;
46 evas_object_size_hint_min_get(wd->content, &minw, &minh);
47 evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
49 evas_object_size_hint_min_set(obj, minw, minh);
50 evas_object_size_hint_max_set(obj, maxw, maxh);
54 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
56 Widget_Data *wd = elm_widget_data_get(data);
62 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
64 Widget_Data *wd = elm_widget_data_get(obj);
65 Evas_Object *sub = event_info;
67 if (sub == wd->content)
69 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
70 _changed_size_hints, obj);
77 _mapbuf(Evas_Object *obj)
79 Widget_Data *wd = elm_widget_data_get(obj);
80 Evas_Coord x, y, w, h;
82 evas_object_geometry_get(wd->clip, &x, &y, &w, &h);
88 evas_map_util_points_populate_from_geometry(m, x, y, w, h, 0);
89 evas_map_smooth_set(m, wd->smooth);
90 evas_map_alpha_set(m, wd->alpha);
91 evas_object_map_set(wd->content, m);
92 evas_object_map_enable_set(wd->content, wd->enabled);
97 evas_object_map_set(wd->content, NULL);
98 evas_object_map_enable_set(wd->content, 0);
99 evas_object_move(wd->content, x, y);
100 evas_object_resize(wd->content, w, h);
105 _configure(Evas_Object *obj)
107 Widget_Data *wd = elm_widget_data_get(obj);
111 Evas_Coord x, y, w, h, x2, y2;
113 evas_object_geometry_get(wd->clip, &x, &y, &w, &h);
114 evas_object_geometry_get(wd->content, &x2, &y2, NULL, NULL);
115 if ((x != x2) || (y != y2))
118 evas_object_move(wd->content, x, y);
122 Evas *e = evas_object_evas_get(obj);
123 evas_smart_objects_calculate(e);
124 evas_nochange_push(e);
125 // printf("x-------------------- %i %i\n", x, y);
126 evas_object_move(wd->content, x, y);
127 evas_smart_objects_calculate(e);
128 // printf("y--------------------\n");
129 evas_nochange_pop(e);
132 evas_object_resize(wd->content, w, h);
138 _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
144 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
150 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
152 ELM_CHECK_WIDTYPE(obj, widtype);
155 if (part && strcmp(part, "default")) return;
156 wd = elm_widget_data_get(obj);
158 if (wd->content == content) return;
159 if (wd->content) evas_object_del(wd->content);
160 wd->content = content;
163 evas_object_data_set(content, "_elm_leaveme", (void *)1);
164 elm_widget_sub_object_add(obj, content);
165 evas_object_smart_member_add(content, obj);
166 evas_object_clip_set(content, wd->clip);
167 evas_object_color_set(wd->clip, 255, 255, 255, 255);
168 evas_object_event_callback_add(content,
169 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
170 _changed_size_hints, obj);
173 evas_object_color_set(wd->clip, 0, 0, 0, 0);
179 _content_get_hook(const Evas_Object *obj, const char *part)
181 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
184 if (part && strcmp(part, "default")) return NULL;
185 wd = elm_widget_data_get(obj);
186 if (!wd) return NULL;
191 _content_unset_hook(Evas_Object *obj, const char *part)
193 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
195 Evas_Object *content;
197 if (part && strcmp(part, "default")) return NULL;
198 wd = elm_widget_data_get(obj);
199 if (!wd) return NULL;
200 if (!wd->content) return NULL;
201 content = wd->content;
202 elm_widget_sub_object_del(obj, content);
203 evas_object_event_callback_add(content,
204 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
205 _changed_size_hints, obj);
206 evas_object_smart_member_del(content);
207 evas_object_color_set(wd->clip, 0, 0, 0, 0);
208 evas_object_clip_unset(content);
209 evas_object_data_del(content, "_elm_leaveme");
215 elm_mapbuf_add(Evas_Object *parent)
221 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
223 ELM_SET_WIDTYPE(widtype, "mapbuf");
224 elm_widget_type_set(obj, "mapbuf");
225 elm_widget_sub_object_add(parent, obj);
226 elm_widget_data_set(obj, wd);
227 elm_widget_del_hook_set(obj, _del_hook);
228 elm_widget_theme_hook_set(obj, _theme_hook);
229 elm_widget_content_set_hook_set(obj, _content_set_hook);
230 elm_widget_content_get_hook_set(obj, _content_get_hook);
231 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
232 elm_widget_can_focus_set(obj, EINA_FALSE);
234 wd->clip = evas_object_rectangle_add(e);
235 evas_object_static_clip_set(wd->clip, EINA_TRUE);
236 evas_object_pass_events_set(wd->clip, EINA_TRUE);
237 evas_object_color_set(wd->clip, 0, 0, 0, 0);
239 evas_object_event_callback_add(wd->clip, EVAS_CALLBACK_MOVE, _move, obj);
240 evas_object_event_callback_add(wd->clip, EVAS_CALLBACK_RESIZE, _resize, obj);
241 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
243 elm_widget_resize_object_set(obj, wd->clip);
254 elm_mapbuf_enabled_set(Evas_Object *obj, Eina_Bool enabled)
256 ELM_CHECK_WIDTYPE(obj, widtype);
257 Widget_Data *wd = elm_widget_data_get(obj);
259 if (wd->enabled == enabled) return;
260 wd->enabled = enabled;
261 if (wd->content) evas_object_static_clip_set(wd->content, wd->enabled);
266 elm_mapbuf_enabled_get(const Evas_Object *obj)
268 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
269 Widget_Data *wd = elm_widget_data_get(obj);
270 if (!wd) return EINA_FALSE;
275 elm_mapbuf_smooth_set(Evas_Object *obj, Eina_Bool smooth)
277 ELM_CHECK_WIDTYPE(obj, widtype);
278 Widget_Data *wd = elm_widget_data_get(obj);
280 if (wd->smooth == smooth) return;
286 elm_mapbuf_smooth_get(const Evas_Object *obj)
288 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
289 Widget_Data *wd = elm_widget_data_get(obj);
290 if (!wd) return EINA_FALSE;
295 elm_mapbuf_alpha_set(Evas_Object *obj, Eina_Bool alpha)
297 ELM_CHECK_WIDTYPE(obj, widtype);
298 Widget_Data *wd = elm_widget_data_get(obj);
300 if (wd->alpha == alpha) return;
306 elm_mapbuf_alpha_get(const Evas_Object *obj)
308 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
309 Widget_Data *wd = elm_widget_data_get(obj);
310 if (!wd) return EINA_FALSE;