3 #define SMART_NAME "e_pan"
4 #define API_ENTRY E_Smart_Data * sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
5 #define INTERNAL_ENTRY E_Smart_Data * sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
6 typedef struct _E_Smart_Data E_Smart_Data;
10 Evas_Object *smart_obj, *child_obj;
11 Evas_Coord x, y, w, h;
12 Evas_Coord child_w, child_h, px, py;
15 /* local subsystem functions */
16 static void _e_smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
17 static void _e_smart_child_resize_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
19 static void _e_smart_reconfigure(E_Smart_Data *sd);
20 static void _e_smart_add(Evas_Object *obj);
21 static void _e_smart_del(Evas_Object *obj);
22 static void _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
23 static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
24 static void _e_smart_show(Evas_Object *obj);
25 static void _e_smart_hide(Evas_Object *obj);
26 static void _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
27 static void _e_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
28 static void _e_smart_clip_unset(Evas_Object *obj);
29 static void _e_smart_init(void);
31 /* local subsystem globals */
32 static Evas_Smart *_e_smart = NULL;
34 /* externally accessible functions */
39 return evas_object_smart_add(evas, _e_smart);
43 e_pan_child_set(Evas_Object *obj, Evas_Object *child)
46 if (child == sd->child_obj) return;
49 evas_object_clip_unset(sd->child_obj);
50 evas_object_smart_member_del(sd->child_obj);
51 evas_object_event_callback_del(sd->child_obj, EVAS_CALLBACK_FREE, _e_smart_child_del_hook);
52 evas_object_event_callback_del(sd->child_obj, EVAS_CALLBACK_RESIZE, _e_smart_child_resize_hook);
59 sd->child_obj = child;
60 evas_object_smart_member_add(sd->child_obj, sd->smart_obj);
61 evas_object_geometry_get(sd->child_obj, NULL, NULL,
62 &sd->child_w, &sd->child_h);
63 evas_object_event_callback_add(child, EVAS_CALLBACK_FREE,
64 _e_smart_child_del_hook, sd);
65 evas_object_event_callback_add(child, EVAS_CALLBACK_RESIZE,
66 _e_smart_child_resize_hook, sd);
67 evas_object_color_get(sd->smart_obj, &r, &g, &b, &a);
68 evas_object_color_set(sd->child_obj, r, g, b, a);
69 evas_object_clip_set(sd->child_obj, evas_object_clip_get(sd->smart_obj));
70 if (evas_object_visible_get(sd->smart_obj))
71 evas_object_show(sd->child_obj);
72 else evas_object_hide(sd->child_obj);
73 _e_smart_reconfigure(sd);
75 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
79 e_pan_child_get(Evas_Object *obj)
81 API_ENTRY return NULL;
86 e_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
89 if (x > (sd->child_w - sd->w)) x = sd->child_w - sd->w;
90 if (y > (sd->child_h - sd->h)) y = sd->child_h - sd->h;
93 if ((x == sd->px) && (y == sd->py)) return;
96 _e_smart_reconfigure(sd);
97 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
101 e_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
109 e_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
114 if (sd->w < sd->child_w) *x = sd->child_w - sd->w;
119 if (sd->h < sd->child_h) *y = sd->child_h - sd->h;
125 e_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
128 if (w) *w = sd->child_w;
129 if (h) *h = sd->child_h;
132 /* local subsystem functions */
134 _e_smart_child_del_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
139 sd->child_obj = NULL;
140 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
144 _e_smart_child_resize_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
150 if (!sd->child_obj) return;
151 evas_object_geometry_get(sd->child_obj, NULL, NULL, &w, &h);
152 if ((w != sd->child_w) || (h != sd->child_h))
156 _e_smart_reconfigure(sd);
158 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
162 _e_smart_reconfigure(E_Smart_Data *sd)
165 evas_object_move(sd->child_obj, sd->x - sd->px, sd->y - sd->py);
169 _e_smart_add(Evas_Object *obj)
173 sd = E_NEW(E_Smart_Data, 1);
180 evas_object_smart_data_set(obj, sd);
184 _e_smart_del(Evas_Object *obj)
187 e_pan_child_set(obj, NULL);
192 _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
197 _e_smart_reconfigure(sd);
201 _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
206 _e_smart_reconfigure(sd);
207 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
211 _e_smart_show(Evas_Object *obj)
215 evas_object_show(sd->child_obj);
219 _e_smart_hide(Evas_Object *obj)
223 evas_object_hide(sd->child_obj);
227 _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
231 evas_object_color_set(sd->child_obj, r, g, b, a);
235 _e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
239 evas_object_clip_set(sd->child_obj, clip);
243 _e_smart_clip_unset(Evas_Object *obj)
247 evas_object_clip_unset(sd->child_obj);
250 /* never need to touch this */
255 if (_e_smart) return;
257 static const Evas_Smart_Class sc =
260 EVAS_SMART_CLASS_VERSION,
278 _e_smart = evas_smart_class_new(&sc);