diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/lib/edje_util.c | 4761 |
1 files changed, 0 insertions, 4761 deletions
diff --git a/libraries/edje/src/lib/edje_util.c b/libraries/edje/src/lib/edje_util.c deleted file mode 100644 index 4ce22b5..0000000 --- a/libraries/edje/src/lib/edje_util.c +++ /dev/null | |||
@@ -1,4761 +0,0 @@ | |||
1 | #include "edje_private.h" | ||
2 | |||
3 | typedef struct _Edje_Box_Layout Edje_Box_Layout; | ||
4 | struct _Edje_Box_Layout | ||
5 | { | ||
6 | EINA_RBTREE; | ||
7 | Evas_Object_Box_Layout func; | ||
8 | void *(*layout_data_get)(void *); | ||
9 | void (*layout_data_free)(void *); | ||
10 | void *data; | ||
11 | void (*free_data)(void *); | ||
12 | char name[]; | ||
13 | }; | ||
14 | |||
15 | static Eina_Hash *_edje_color_class_hash = NULL; | ||
16 | static Eina_Hash *_edje_color_class_member_hash = NULL; | ||
17 | |||
18 | static Eina_Hash *_edje_text_class_hash = NULL; | ||
19 | static Eina_Hash *_edje_text_class_member_hash = NULL; | ||
20 | |||
21 | static Eina_Rbtree *_edje_box_layout_registry = NULL; | ||
22 | |||
23 | char *_edje_fontset_append = NULL; | ||
24 | FLOAT_T _edje_scale = ZERO; | ||
25 | Eina_Bool _edje_password_show_last = EINA_FALSE; | ||
26 | FLOAT_T _edje_password_show_last_timeout = ZERO; | ||
27 | int _edje_freeze_val = 0; | ||
28 | int _edje_freeze_calc_count = 0; | ||
29 | Eina_List *_edje_freeze_calc_list = NULL; | ||
30 | |||
31 | typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data; | ||
32 | struct _Edje_List_Foreach_Data | ||
33 | { | ||
34 | Eina_List *list; | ||
35 | }; | ||
36 | |||
37 | typedef struct _Edje_List_Refcount Edje_List_Refcount; | ||
38 | struct _Edje_List_Refcount | ||
39 | { | ||
40 | EINA_REFCOUNT; | ||
41 | |||
42 | Eina_List *lookup; | ||
43 | }; | ||
44 | |||
45 | static Eina_Bool _edje_color_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata); | ||
46 | static Eina_Bool _edje_text_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata); | ||
47 | static void _edje_object_image_preload_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
48 | static void _edje_object_signal_preload_cb(void *data, Evas_Object *obj, const char *emission, const char *source); | ||
49 | |||
50 | Edje_Real_Part *_edje_real_part_recursive_get_helper(const Edje *ed, char **path); | ||
51 | |||
52 | |||
53 | static void | ||
54 | _edje_class_member_direct_del(const char *class, Edje_List_Refcount *lookup, Eina_Hash *hash) | ||
55 | { | ||
56 | Eina_List *members; | ||
57 | |||
58 | members = eina_hash_find(hash, class); | ||
59 | members = eina_list_remove_list(members, lookup->lookup); | ||
60 | eina_hash_set(hash, class, members); | ||
61 | free(lookup); | ||
62 | } | ||
63 | |||
64 | static void | ||
65 | _edje_class_member_add(Edje *ed, Eina_Hash **ehash, Eina_Hash **ghash, const char *class) | ||
66 | { | ||
67 | Edje_List_Refcount *lookup; | ||
68 | Eina_List *members; | ||
69 | |||
70 | if ((!ed) || (!ehash) || (!ghash) || (!class)) return; | ||
71 | |||
72 | lookup = eina_hash_find(*ehash, class); | ||
73 | if (lookup) | ||
74 | { | ||
75 | EINA_REFCOUNT_REF(lookup); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | lookup = malloc(sizeof (Edje_List_Refcount)); | ||
80 | if (!lookup) return ; | ||
81 | EINA_REFCOUNT_INIT(lookup); | ||
82 | |||
83 | /* Get members list */ | ||
84 | members = eina_hash_find(*ghash, class); | ||
85 | |||
86 | /* Update the member list */ | ||
87 | lookup->lookup = members = eina_list_prepend(members, ed); | ||
88 | |||
89 | /* Don't loose track of members list */ | ||
90 | if (!*ehash) | ||
91 | *ehash = eina_hash_string_small_new(NULL); | ||
92 | eina_hash_add(*ehash, class, lookup); | ||
93 | |||
94 | /* Reset the member list to the right pointer */ | ||
95 | if (!*ghash) | ||
96 | *ghash = eina_hash_string_superfast_new(NULL); | ||
97 | eina_hash_set(*ghash, class, members); | ||
98 | } | ||
99 | |||
100 | static void | ||
101 | _edje_class_member_del(Eina_Hash **ehash, Eina_Hash **ghash, const char *class) | ||
102 | { | ||
103 | Edje_List_Refcount *lookup; | ||
104 | Eina_List *members; | ||
105 | |||
106 | if ((!ehash) || (!ghash) || (!class)) return; | ||
107 | members = eina_hash_find(*ghash, class); | ||
108 | if (!members) return; | ||
109 | |||
110 | lookup = eina_hash_find(*ehash, class); | ||
111 | if (!lookup) return ; | ||
112 | |||
113 | EINA_REFCOUNT_UNREF(lookup) | ||
114 | { | ||
115 | members = eina_list_remove_list(members, lookup->lookup); | ||
116 | eina_hash_set(*ghash, class, members); | ||
117 | |||
118 | eina_hash_del(*ehash, class, lookup); | ||
119 | free(lookup); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | static Eina_Bool | ||
124 | member_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) | ||
125 | { | ||
126 | eina_list_free(data); | ||
127 | return EINA_TRUE; | ||
128 | } | ||
129 | |||
130 | static void | ||
131 | _edje_class_members_free(Eina_Hash **ghash) | ||
132 | { | ||
133 | if (!ghash || !*ghash) return; | ||
134 | eina_hash_foreach(*ghash, member_list_free, NULL); | ||
135 | eina_hash_free(*ghash); | ||
136 | *ghash = NULL; | ||
137 | } | ||
138 | |||
139 | /************************** API Routines **************************/ | ||
140 | |||
141 | #define FASTFREEZE 1 | ||
142 | |||
143 | EAPI void | ||
144 | edje_freeze(void) | ||
145 | { | ||
146 | #ifdef FASTFREEZE | ||
147 | _edje_freeze_val++; | ||
148 | INF("fr ++ ->%i", _edje_freeze_val); | ||
149 | #else | ||
150 | // FIXME: could just have a global freeze instead of per object | ||
151 | // above i tried.. but this broke some things. notable e17's menus. why? | ||
152 | Eina_List *l; | ||
153 | Evas_Object *data; | ||
154 | |||
155 | EINA_LIST_FOREACH(_edje_edjes, l, data) | ||
156 | edje_object_freeze(data); | ||
157 | #endif | ||
158 | } | ||
159 | |||
160 | #ifdef FASTFREEZE | ||
161 | static void | ||
162 | _edje_thaw_edje(Edje *ed) | ||
163 | { | ||
164 | unsigned int i; | ||
165 | |||
166 | for (i = 0; i < ed->table_parts_size; i++) | ||
167 | { | ||
168 | Edje_Real_Part *rp; | ||
169 | |||
170 | rp = ed->table_parts[i]; | ||
171 | if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) | ||
172 | { | ||
173 | Edje *ed2; | ||
174 | |||
175 | ed2 = _edje_fetch(rp->swallowed_object); | ||
176 | if (ed2) _edje_thaw_edje(ed2); | ||
177 | } | ||
178 | } | ||
179 | if ((ed->recalc) && (ed->freeze <= 0)) _edje_recalc_do(ed); | ||
180 | } | ||
181 | #endif | ||
182 | |||
183 | EAPI void | ||
184 | edje_thaw(void) | ||
185 | { | ||
186 | #ifdef FASTFREEZE | ||
187 | _edje_freeze_val--; | ||
188 | INF("fr -- ->%i", _edje_freeze_val); | ||
189 | if ((_edje_freeze_val <= 0) && (_edje_freeze_calc_count > 0)) | ||
190 | { | ||
191 | Edje *ed; | ||
192 | |||
193 | _edje_freeze_calc_count = 0; | ||
194 | EINA_LIST_FREE(_edje_freeze_calc_list, ed) | ||
195 | { | ||
196 | _edje_thaw_edje(ed); | ||
197 | ed->freeze_calc = 0; | ||
198 | } | ||
199 | } | ||
200 | #else | ||
201 | Evas_Object *data; | ||
202 | |||
203 | // FIXME: could just have a global freeze instead of per object | ||
204 | // comment as above.. why? | ||
205 | Eina_List *l; | ||
206 | |||
207 | EINA_LIST_FOREACH(_edje_edjes, l, data) | ||
208 | edje_object_thaw(data); | ||
209 | #endif | ||
210 | } | ||
211 | |||
212 | EAPI void | ||
213 | edje_fontset_append_set(const char *fonts) | ||
214 | { | ||
215 | if (_edje_fontset_append) | ||
216 | free(_edje_fontset_append); | ||
217 | _edje_fontset_append = fonts ? strdup(fonts) : NULL; | ||
218 | } | ||
219 | |||
220 | EAPI const char * | ||
221 | edje_fontset_append_get(void) | ||
222 | { | ||
223 | return _edje_fontset_append; | ||
224 | } | ||
225 | |||
226 | EAPI void | ||
227 | edje_scale_set(double scale) | ||
228 | { | ||
229 | Eina_List *l; | ||
230 | Evas_Object *data; | ||
231 | |||
232 | if (_edje_scale == FROM_DOUBLE(scale)) return; | ||
233 | _edje_scale = FROM_DOUBLE(scale); | ||
234 | EINA_LIST_FOREACH(_edje_edjes, l, data) | ||
235 | edje_object_calc_force(data); | ||
236 | } | ||
237 | |||
238 | EAPI double | ||
239 | edje_scale_get(void) | ||
240 | { | ||
241 | return TO_DOUBLE(_edje_scale); | ||
242 | } | ||
243 | |||
244 | EAPI void | ||
245 | edje_password_show_last_set(Eina_Bool password_show_last) | ||
246 | { | ||
247 | if (_edje_password_show_last == password_show_last) return; | ||
248 | _edje_password_show_last = password_show_last; | ||
249 | } | ||
250 | |||
251 | EAPI void | ||
252 | edje_password_show_last_timeout_set(double password_show_last_timeout) | ||
253 | { | ||
254 | if (_edje_password_show_last_timeout == FROM_DOUBLE(password_show_last_timeout)) return; | ||
255 | _edje_password_show_last_timeout = FROM_DOUBLE(password_show_last_timeout); | ||
256 | } | ||
257 | |||
258 | EAPI Eina_Bool | ||
259 | edje_object_scale_set(Evas_Object *obj, double scale) | ||
260 | { | ||
261 | Edje *ed; | ||
262 | |||
263 | ed = _edje_fetch(obj); | ||
264 | if (!ed) return EINA_FALSE; | ||
265 | if (ed->scale == scale) return EINA_TRUE; | ||
266 | ed->scale = FROM_DOUBLE(scale); | ||
267 | edje_object_calc_force(obj); | ||
268 | return EINA_TRUE; | ||
269 | } | ||
270 | |||
271 | EAPI double | ||
272 | edje_object_scale_get(const Evas_Object *obj) | ||
273 | { | ||
274 | Edje *ed; | ||
275 | |||
276 | ed = _edje_fetch(obj); | ||
277 | if (!ed) return 0.0; | ||
278 | return TO_DOUBLE(ed->scale); | ||
279 | } | ||
280 | |||
281 | EAPI Eina_Bool | ||
282 | edje_object_mirrored_get(const Evas_Object *obj) | ||
283 | { | ||
284 | Edje *ed; | ||
285 | |||
286 | ed = _edje_fetch(obj); | ||
287 | if (!ed) return EINA_FALSE; | ||
288 | |||
289 | return ed->is_rtl; | ||
290 | } | ||
291 | |||
292 | void | ||
293 | _edje_object_orientation_inform(Evas_Object *obj) | ||
294 | { | ||
295 | if (edje_object_mirrored_get(obj)) | ||
296 | edje_object_signal_emit(obj, "edje,state,rtl", "edje"); | ||
297 | else | ||
298 | edje_object_signal_emit(obj, "edje,state,ltr", "edje"); | ||
299 | } | ||
300 | |||
301 | EAPI void | ||
302 | edje_object_mirrored_set(Evas_Object *obj, Eina_Bool rtl) | ||
303 | { | ||
304 | Edje *ed; | ||
305 | unsigned int i; | ||
306 | |||
307 | ed = _edje_fetch(obj); | ||
308 | if (!ed) return; | ||
309 | if (ed->is_rtl == rtl) return; | ||
310 | |||
311 | ed->is_rtl = rtl; | ||
312 | |||
313 | for (i = 0 ; i < ed->table_parts_size ; i++) | ||
314 | { | ||
315 | Edje_Real_Part *ep; | ||
316 | const char *s; | ||
317 | double v; | ||
318 | |||
319 | ep = ed->table_parts[i]; | ||
320 | s = ep->param1.description->state.name, | ||
321 | v = ep->param1.description->state.value; | ||
322 | _edje_part_description_apply(ed, ep, s, v , NULL, 0.0); | ||
323 | ep->chosen_description = ep->param1.description; | ||
324 | } | ||
325 | _edje_recalc_do(ed); | ||
326 | |||
327 | _edje_object_orientation_inform(obj); | ||
328 | |||
329 | return; | ||
330 | } | ||
331 | |||
332 | EAPI const char * | ||
333 | edje_object_data_get(const Evas_Object *obj, const char *key) | ||
334 | { | ||
335 | Edje *ed; | ||
336 | |||
337 | ed = _edje_fetch(obj); | ||
338 | if ((!ed) || (!key)) | ||
339 | return NULL; | ||
340 | if (!ed->collection) return NULL; | ||
341 | if (!ed->collection->data) return NULL; | ||
342 | return edje_string_get(eina_hash_find(ed->collection->data, key)); | ||
343 | } | ||
344 | |||
345 | EAPI int | ||
346 | edje_object_freeze(Evas_Object *obj) | ||
347 | { | ||
348 | Edje *ed; | ||
349 | unsigned int i; | ||
350 | |||
351 | ed = _edje_fetch(obj); | ||
352 | if (!ed) return 0; | ||
353 | for (i = 0; i < ed->table_parts_size; i++) | ||
354 | { | ||
355 | Edje_Real_Part *rp; | ||
356 | rp = ed->table_parts[i]; | ||
357 | if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) | ||
358 | edje_object_freeze(rp->swallowed_object); | ||
359 | } | ||
360 | return _edje_freeze(ed); | ||
361 | } | ||
362 | |||
363 | EAPI int | ||
364 | edje_object_thaw(Evas_Object *obj) | ||
365 | { | ||
366 | Edje *ed; | ||
367 | unsigned int i; | ||
368 | |||
369 | ed = _edje_fetch(obj); | ||
370 | if (!ed) return 0; | ||
371 | for (i = 0; i < ed->table_parts_size; i++) | ||
372 | { | ||
373 | Edje_Real_Part *rp; | ||
374 | |||
375 | rp = ed->table_parts[i]; | ||
376 | if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) | ||
377 | edje_object_thaw(rp->swallowed_object); | ||
378 | } | ||
379 | return _edje_thaw(ed); | ||
380 | } | ||
381 | |||
382 | EAPI Eina_Bool | ||
383 | edje_color_class_set(const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3) | ||
384 | { | ||
385 | Eina_List *members; | ||
386 | Edje_Color_Class *cc; | ||
387 | |||
388 | if (!color_class) return EINA_FALSE; | ||
389 | |||
390 | cc = eina_hash_find(_edje_color_class_hash, color_class); | ||
391 | if (!cc) | ||
392 | { | ||
393 | cc = calloc(1, sizeof(Edje_Color_Class)); | ||
394 | if (!cc) return EINA_FALSE; | ||
395 | cc->name = eina_stringshare_add(color_class); | ||
396 | if (!cc->name) | ||
397 | { | ||
398 | free(cc); | ||
399 | return EINA_FALSE; | ||
400 | } | ||
401 | if (!_edje_color_class_hash) | ||
402 | _edje_color_class_hash = eina_hash_string_superfast_new(NULL); | ||
403 | eina_hash_add(_edje_color_class_hash, color_class, cc); | ||
404 | } | ||
405 | |||
406 | if (r < 0) r = 0; | ||
407 | else if (r > 255) r = 255; | ||
408 | if (g < 0) g = 0; | ||
409 | else if (g > 255) g = 255; | ||
410 | if (b < 0) b = 0; | ||
411 | else if (b > 255) b = 255; | ||
412 | if (a < 0) a = 0; | ||
413 | else if (a > 255) a = 255; | ||
414 | if ((cc->r == r) && (cc->g == g) && | ||
415 | (cc->b == b) && (cc->a == a) && | ||
416 | (cc->r2 == r2) && (cc->g2 == g2) && | ||
417 | (cc->b2 == b2) && (cc->a2 == a2) && | ||
418 | (cc->r3 == r3) && (cc->g3 == g3) && | ||
419 | (cc->b3 == b3) && (cc->a3 == a3)) | ||
420 | return EINA_TRUE; | ||
421 | cc->r = r; | ||
422 | cc->g = g; | ||
423 | cc->b = b; | ||
424 | cc->a = a; | ||
425 | cc->r2 = r2; | ||
426 | cc->g2 = g2; | ||
427 | cc->b2 = b2; | ||
428 | cc->a2 = a2; | ||
429 | cc->r3 = r3; | ||
430 | cc->g3 = g3; | ||
431 | cc->b3 = b3; | ||
432 | cc->a3 = a3; | ||
433 | |||
434 | members = eina_hash_find(_edje_color_class_member_hash, color_class); | ||
435 | while (members) | ||
436 | { | ||
437 | Edje *ed; | ||
438 | |||
439 | ed = eina_list_data_get(members); | ||
440 | ed->dirty = 1; | ||
441 | ed->recalc_call = 1; | ||
442 | #ifdef EDJE_CALC_CACHE | ||
443 | ed->all_part_change = 1; | ||
444 | #endif | ||
445 | _edje_recalc(ed); | ||
446 | _edje_emit(ed, "color_class,set", color_class); | ||
447 | members = eina_list_next(members); | ||
448 | } | ||
449 | return EINA_TRUE; | ||
450 | } | ||
451 | |||
452 | EAPI Eina_Bool | ||
453 | edje_color_class_get(const char *color_class, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3) | ||
454 | { | ||
455 | Edje_Color_Class *cc; | ||
456 | |||
457 | if (!color_class) | ||
458 | cc = NULL; | ||
459 | else | ||
460 | cc = eina_hash_find(_edje_color_class_hash, color_class); | ||
461 | |||
462 | if (cc) | ||
463 | { | ||
464 | #define X(C) if (C) *C = cc->C | ||
465 | #define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) | ||
466 | S(r, g, b, a); | ||
467 | S(r2, g2, b2, a2); | ||
468 | S(r3, g3, b3, a3); | ||
469 | #undef S | ||
470 | #undef X | ||
471 | return EINA_TRUE; | ||
472 | } | ||
473 | else | ||
474 | { | ||
475 | #define X(C) if (C) *C = 0 | ||
476 | #define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) | ||
477 | S(r, g, b, a); | ||
478 | S(r2, g2, b2, a2); | ||
479 | S(r3, g3, b3, a3); | ||
480 | #undef S | ||
481 | #undef X | ||
482 | return EINA_FALSE; | ||
483 | } | ||
484 | } | ||
485 | |||
486 | void | ||
487 | edje_color_class_del(const char *color_class) | ||
488 | { | ||
489 | Edje_Color_Class *cc; | ||
490 | Eina_List *members; | ||
491 | |||
492 | if (!color_class) return; | ||
493 | |||
494 | cc = eina_hash_find(_edje_color_class_hash, color_class); | ||
495 | if (!cc) return; | ||
496 | |||
497 | eina_hash_del(_edje_color_class_hash, color_class, cc); | ||
498 | eina_stringshare_del(cc->name); | ||
499 | free(cc); | ||
500 | |||
501 | members = eina_hash_find(_edje_color_class_member_hash, color_class); | ||
502 | while (members) | ||
503 | { | ||
504 | Edje *ed; | ||
505 | |||
506 | ed = eina_list_data_get(members); | ||
507 | ed->dirty = 1; | ||
508 | ed->recalc_call = 1; | ||
509 | #ifdef EDJE_CALC_CACHE | ||
510 | ed->all_part_change = 1; | ||
511 | #endif | ||
512 | _edje_recalc(ed); | ||
513 | _edje_emit(ed, "color_class,del", color_class); | ||
514 | members = eina_list_next(members); | ||
515 | } | ||
516 | } | ||
517 | |||
518 | Eina_List * | ||
519 | edje_color_class_list(void) | ||
520 | { | ||
521 | Edje_List_Foreach_Data fdata; | ||
522 | |||
523 | if (!_edje_color_class_member_hash) return NULL; | ||
524 | |||
525 | memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); | ||
526 | eina_hash_foreach(_edje_color_class_member_hash, | ||
527 | _edje_color_class_list_foreach, &fdata); | ||
528 | |||
529 | return fdata.list; | ||
530 | } | ||
531 | |||
532 | static Eina_Bool | ||
533 | _edje_color_class_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) | ||
534 | { | ||
535 | Edje_List_Foreach_Data *fd; | ||
536 | |||
537 | fd = fdata; | ||
538 | fd->list = eina_list_append(fd->list, strdup(key)); | ||
539 | return EINA_TRUE; | ||
540 | } | ||
541 | |||
542 | EAPI Eina_Bool | ||
543 | edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3) | ||
544 | { | ||
545 | Edje *ed; | ||
546 | Eina_List *l; | ||
547 | Edje_Color_Class *cc; | ||
548 | unsigned int i; | ||
549 | |||
550 | ed = _edje_fetch(obj); | ||
551 | if ((!ed) || (!color_class)) return EINA_FALSE; | ||
552 | if (r < 0) r = 0; | ||
553 | else if (r > 255) r = 255; | ||
554 | if (g < 0) g = 0; | ||
555 | else if (g > 255) g = 255; | ||
556 | if (b < 0) b = 0; | ||
557 | else if (b > 255) b = 255; | ||
558 | if (a < 0) a = 0; | ||
559 | else if (a > 255) a = 255; | ||
560 | color_class = eina_stringshare_add(color_class); | ||
561 | if (!color_class) return EINA_FALSE; | ||
562 | EINA_LIST_FOREACH(ed->color_classes, l, cc) | ||
563 | { | ||
564 | if (cc->name == color_class) | ||
565 | { | ||
566 | eina_stringshare_del(color_class); | ||
567 | |||
568 | if ((cc->r == r) && (cc->g == g) && | ||
569 | (cc->b == b) && (cc->a == a) && | ||
570 | (cc->r2 == r2) && (cc->g2 == g2) && | ||
571 | (cc->b2 == b2) && (cc->a2 == a2) && | ||
572 | (cc->r3 == r3) && (cc->g3 == g3) && | ||
573 | (cc->b3 == b3) && (cc->a3 == a3)) | ||
574 | return EINA_TRUE; | ||
575 | cc->r = r; | ||
576 | cc->g = g; | ||
577 | cc->b = b; | ||
578 | cc->a = a; | ||
579 | cc->r2 = r2; | ||
580 | cc->g2 = g2; | ||
581 | cc->b2 = b2; | ||
582 | cc->a2 = a2; | ||
583 | cc->r3 = r3; | ||
584 | cc->g3 = g3; | ||
585 | cc->b3 = b3; | ||
586 | cc->a3 = a3; | ||
587 | ed->dirty = 1; | ||
588 | ed->recalc_call = 1; | ||
589 | #ifdef EDJE_CALC_CACHE | ||
590 | ed->all_part_change = 1; | ||
591 | #endif | ||
592 | _edje_recalc(ed); | ||
593 | return EINA_TRUE; | ||
594 | } | ||
595 | } | ||
596 | cc = malloc(sizeof(Edje_Color_Class)); | ||
597 | if (!cc) | ||
598 | { | ||
599 | eina_stringshare_del(color_class); | ||
600 | return EINA_FALSE; | ||
601 | } | ||
602 | cc->name = color_class; | ||
603 | cc->r = r; | ||
604 | cc->g = g; | ||
605 | cc->b = b; | ||
606 | cc->a = a; | ||
607 | cc->r2 = r2; | ||
608 | cc->g2 = g2; | ||
609 | cc->b2 = b2; | ||
610 | cc->a2 = a2; | ||
611 | cc->r3 = r3; | ||
612 | cc->g3 = g3; | ||
613 | cc->b3 = b3; | ||
614 | cc->a3 = a3; | ||
615 | ed->color_classes = eina_list_append(ed->color_classes, cc); | ||
616 | ed->dirty = 1; | ||
617 | ed->recalc_call = 1; | ||
618 | #ifdef EDJE_CALC_CACHE | ||
619 | ed->all_part_change = 1; | ||
620 | #endif | ||
621 | |||
622 | for (i = 0; i < ed->table_parts_size; i++) | ||
623 | { | ||
624 | Edje_Real_Part *rp; | ||
625 | |||
626 | rp = ed->table_parts[i]; | ||
627 | if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) | ||
628 | edje_object_color_class_set(rp->swallowed_object, color_class, | ||
629 | r, g, b, a, r2, g2, b2, a2, r3, g3, b3, | ||
630 | a3); | ||
631 | } | ||
632 | |||
633 | _edje_recalc(ed); | ||
634 | _edje_emit(ed, "color_class,set", color_class); | ||
635 | return EINA_TRUE; | ||
636 | } | ||
637 | |||
638 | EAPI Eina_Bool | ||
639 | edje_object_color_class_get(const Evas_Object *obj, const char *color_class, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3) | ||
640 | { | ||
641 | Edje *ed = _edje_fetch(obj); | ||
642 | Edje_Color_Class *cc = _edje_color_class_find(ed, color_class); | ||
643 | |||
644 | if (cc) | ||
645 | { | ||
646 | #define X(C) if (C) *C = cc->C | ||
647 | #define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) | ||
648 | S(r, g, b, a); | ||
649 | S(r2, g2, b2, a2); | ||
650 | S(r3, g3, b3, a3); | ||
651 | #undef S | ||
652 | #undef X | ||
653 | return EINA_TRUE; | ||
654 | } | ||
655 | else | ||
656 | { | ||
657 | #define X(C) if (C) *C = 0 | ||
658 | #define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) | ||
659 | S(r, g, b, a); | ||
660 | S(r2, g2, b2, a2); | ||
661 | S(r3, g3, b3, a3); | ||
662 | #undef S | ||
663 | #undef X | ||
664 | return EINA_FALSE; | ||
665 | } | ||
666 | } | ||
667 | |||
668 | void | ||
669 | edje_object_color_class_del(Evas_Object *obj, const char *color_class) | ||
670 | { | ||
671 | Edje *ed; | ||
672 | Eina_List *l; | ||
673 | Edje_Color_Class *cc = NULL; | ||
674 | unsigned int i; | ||
675 | |||
676 | if (!color_class) return; | ||
677 | |||
678 | ed = _edje_fetch(obj); | ||
679 | EINA_LIST_FOREACH(ed->color_classes, l, cc) | ||
680 | { | ||
681 | if (!strcmp(cc->name, color_class)) | ||
682 | { | ||
683 | ed->color_classes = eina_list_remove(ed->color_classes, cc); | ||
684 | eina_stringshare_del(cc->name); | ||
685 | free(cc); | ||
686 | break; | ||
687 | } | ||
688 | } | ||
689 | |||
690 | for (i = 0; i < ed->table_parts_size; i++) | ||
691 | { | ||
692 | Edje_Real_Part *rp; | ||
693 | |||
694 | rp = ed->table_parts[i]; | ||
695 | if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) | ||
696 | edje_object_color_class_del(rp->swallowed_object, color_class); | ||
697 | } | ||
698 | |||
699 | ed->dirty = 1; | ||
700 | ed->recalc_call = 1; | ||
701 | #ifdef EDJE_CALC_CACHE | ||
702 | ed->all_part_change = 1; | ||
703 | #endif | ||
704 | _edje_recalc(ed); | ||
705 | _edje_emit(ed, "color_class,del", color_class); | ||
706 | } | ||
707 | |||
708 | EAPI Eina_Bool | ||
709 | edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size) | ||
710 | { | ||
711 | Eina_List *members; | ||
712 | Edje_Text_Class *tc; | ||
713 | |||
714 | if (!text_class) return EINA_FALSE; | ||
715 | if (!font) font = ""; | ||
716 | |||
717 | tc = eina_hash_find(_edje_text_class_hash, text_class); | ||
718 | /* Create new text class */ | ||
719 | if (!tc) | ||
720 | { | ||
721 | tc = calloc(1, sizeof(Edje_Text_Class)); | ||
722 | if (!tc) return EINA_FALSE; | ||
723 | tc->name = eina_stringshare_add(text_class); | ||
724 | if (!tc->name) | ||
725 | { | ||
726 | free(tc); | ||
727 | return EINA_FALSE; | ||
728 | } | ||
729 | if (!_edje_text_class_hash) _edje_text_class_hash = eina_hash_string_superfast_new(NULL); | ||
730 | eina_hash_add(_edje_text_class_hash, text_class, tc); | ||
731 | |||
732 | tc->font = eina_stringshare_add(font); | ||
733 | tc->size = size; | ||
734 | return EINA_FALSE; | ||
735 | } | ||
736 | |||
737 | /* If the class found is the same just return */ | ||
738 | if ((tc->size == size) && (tc->font) && (!strcmp(tc->font, font))) | ||
739 | return EINA_TRUE; | ||
740 | |||
741 | /* Update the class found */ | ||
742 | eina_stringshare_del(tc->font); | ||
743 | tc->font = eina_stringshare_add(font); | ||
744 | if (!tc->font) | ||
745 | { | ||
746 | eina_hash_del(_edje_text_class_hash, text_class, tc); | ||
747 | free(tc); | ||
748 | return EINA_FALSE; | ||
749 | } | ||
750 | tc->size = size; | ||
751 | |||
752 | /* Tell all members of the text class to recalc */ | ||
753 | members = eina_hash_find(_edje_text_class_member_hash, text_class); | ||
754 | while (members) | ||
755 | { | ||
756 | Edje *ed; | ||
757 | |||
758 | ed = eina_list_data_get(members); | ||
759 | ed->dirty = 1; | ||
760 | ed->recalc_call = 1; | ||
761 | _edje_textblock_style_all_update(ed); | ||
762 | #ifdef EDJE_CALC_CACHE | ||
763 | ed->text_part_change = 1; | ||
764 | #endif | ||
765 | _edje_recalc(ed); | ||
766 | members = eina_list_next(members); | ||
767 | } | ||
768 | return EINA_TRUE; | ||
769 | } | ||
770 | |||
771 | void | ||
772 | edje_text_class_del(const char *text_class) | ||
773 | { | ||
774 | Edje_Text_Class *tc; | ||
775 | Eina_List *members; | ||
776 | |||
777 | if (!text_class) return; | ||
778 | |||
779 | tc = eina_hash_find(_edje_text_class_hash, text_class); | ||
780 | if (!tc) return; | ||
781 | |||
782 | eina_hash_del(_edje_text_class_hash, text_class, tc); | ||
783 | eina_stringshare_del(tc->name); | ||
784 | eina_stringshare_del(tc->font); | ||
785 | free(tc); | ||
786 | |||
787 | members = eina_hash_find(_edje_text_class_member_hash, text_class); | ||
788 | while (members) | ||
789 | { | ||
790 | Edje *ed; | ||
791 | |||
792 | ed = eina_list_data_get(members); | ||
793 | ed->dirty = 1; | ||
794 | _edje_textblock_style_all_update(ed); | ||
795 | #ifdef EDJE_CALC_CACHE | ||
796 | ed->text_part_change = 1; | ||
797 | #endif | ||
798 | _edje_recalc(ed); | ||
799 | members = eina_list_next(members); | ||
800 | } | ||
801 | } | ||
802 | |||
803 | Eina_List * | ||
804 | edje_text_class_list(void) | ||
805 | { | ||
806 | Edje_List_Foreach_Data fdata; | ||
807 | |||
808 | memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); | ||
809 | eina_hash_foreach(_edje_text_class_member_hash, | ||
810 | _edje_text_class_list_foreach, &fdata); | ||
811 | return fdata.list; | ||
812 | } | ||
813 | |||
814 | static Eina_Bool | ||
815 | _edje_text_class_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) | ||
816 | { | ||
817 | Edje_List_Foreach_Data *fd; | ||
818 | |||
819 | fd = fdata; | ||
820 | fd->list = eina_list_append(fd->list, eina_stringshare_add(key)); | ||
821 | return EINA_TRUE; | ||
822 | } | ||
823 | |||
824 | EAPI Eina_Bool | ||
825 | edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size) | ||
826 | { | ||
827 | Edje *ed; | ||
828 | Eina_List *l; | ||
829 | Edje_Text_Class *tc; | ||
830 | unsigned int i; | ||
831 | |||
832 | ed = _edje_fetch(obj); | ||
833 | if ((!ed) || (!text_class)) return EINA_FALSE; | ||
834 | |||
835 | /* for each text_class in the edje */ | ||
836 | EINA_LIST_FOREACH(ed->text_classes, l, tc) | ||
837 | { | ||
838 | if ((tc->name) && (!strcmp(tc->name, text_class))) | ||
839 | { | ||
840 | /* Match and the same, return */ | ||
841 | if ((tc->font) && (font) && (!strcmp(tc->font, font)) && | ||
842 | (tc->size == size)) | ||
843 | return EINA_TRUE; | ||
844 | |||
845 | /* No font but size is the same, return */ | ||
846 | if ((!tc->font) && (!font) && (tc->size == size)) return EINA_TRUE; | ||
847 | |||
848 | /* Update new text class properties */ | ||
849 | if (tc->font) eina_stringshare_del(tc->font); | ||
850 | if (font) tc->font = eina_stringshare_add(font); | ||
851 | else tc->font = NULL; | ||
852 | tc->size = size; | ||
853 | |||
854 | /* Update edje */ | ||
855 | ed->dirty = 1; | ||
856 | ed->recalc_call = 1; | ||
857 | #ifdef EDJE_CALC_CACHE | ||
858 | ed->text_part_change = 1; | ||
859 | #endif | ||
860 | _edje_recalc(ed); | ||
861 | return EINA_TRUE; | ||
862 | } | ||
863 | } | ||
864 | |||
865 | /* No matches, create a new text class */ | ||
866 | tc = calloc(1, sizeof(Edje_Text_Class)); | ||
867 | if (!tc) return EINA_FALSE; | ||
868 | tc->name = eina_stringshare_add(text_class); | ||
869 | if (!tc->name) | ||
870 | { | ||
871 | free(tc); | ||
872 | return EINA_FALSE; | ||
873 | } | ||
874 | if (font) tc->font = eina_stringshare_add(font); | ||
875 | else tc->font = NULL; | ||
876 | tc->size = size; | ||
877 | |||
878 | for (i = 0; i < ed->table_parts_size; i++) | ||
879 | { | ||
880 | Edje_Real_Part *rp; | ||
881 | |||
882 | rp = ed->table_parts[i]; | ||
883 | if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) | ||
884 | edje_object_text_class_set(rp->swallowed_object, text_class, | ||
885 | font, size); | ||
886 | } | ||
887 | |||
888 | /* Add to edje's text class list */ | ||
889 | ed->text_classes = eina_list_append(ed->text_classes, tc); | ||
890 | ed->dirty = 1; | ||
891 | ed->recalc_call = 1; | ||
892 | #ifdef EDJE_CALC_CACHE | ||
893 | ed->text_part_change = 1; | ||
894 | #endif | ||
895 | _edje_textblock_style_all_update(ed); | ||
896 | _edje_recalc(ed); | ||
897 | return EINA_TRUE; | ||
898 | } | ||
899 | |||
900 | EAPI Eina_Bool | ||
901 | edje_object_part_exists(const Evas_Object *obj, const char *part) | ||
902 | { | ||
903 | Edje *ed; | ||
904 | Edje_Real_Part *rp; | ||
905 | |||
906 | ed = _edje_fetch(obj); | ||
907 | if ((!ed) || (!part)) return EINA_FALSE; | ||
908 | rp = _edje_real_part_recursive_get(ed, part); | ||
909 | if (!rp) return EINA_FALSE; | ||
910 | return EINA_TRUE; | ||
911 | } | ||
912 | |||
913 | EAPI const Evas_Object * | ||
914 | edje_object_part_object_get(const Evas_Object *obj, const char *part) | ||
915 | { | ||
916 | Edje *ed; | ||
917 | Edje_Real_Part *rp; | ||
918 | |||
919 | ed = _edje_fetch(obj); | ||
920 | if ((!ed) || (!part)) return NULL; | ||
921 | |||
922 | /* Need to recalc before providing the object. */ | ||
923 | _edje_recalc_do(ed); | ||
924 | |||
925 | rp = _edje_real_part_recursive_get(ed, part); | ||
926 | if (!rp) return NULL; | ||
927 | return rp->object; | ||
928 | } | ||
929 | |||
930 | EAPI Eina_Bool | ||
931 | edje_object_part_geometry_get(const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h ) | ||
932 | { | ||
933 | Edje *ed; | ||
934 | Edje_Real_Part *rp; | ||
935 | |||
936 | ed = _edje_fetch(obj); | ||
937 | if ((!ed) || (!part)) | ||
938 | { | ||
939 | if (x) *x = 0; | ||
940 | if (y) *y = 0; | ||
941 | if (w) *w = 0; | ||
942 | if (h) *h = 0; | ||
943 | return EINA_FALSE; | ||
944 | } | ||
945 | |||
946 | /* Need to recalc before providing the object. */ | ||
947 | _edje_recalc_do(ed); | ||
948 | |||
949 | rp = _edje_real_part_recursive_get(ed, part); | ||
950 | if (!rp) | ||
951 | { | ||
952 | if (x) *x = 0; | ||
953 | if (y) *y = 0; | ||
954 | if (w) *w = 0; | ||
955 | if (h) *h = 0; | ||
956 | return EINA_FALSE; | ||
957 | } | ||
958 | if (x) *x = rp->x; | ||
959 | if (y) *y = rp->y; | ||
960 | if (w) *w = rp->w; | ||
961 | if (h) *h = rp->h; | ||
962 | return EINA_TRUE; | ||
963 | } | ||
964 | |||
965 | EAPI void | ||
966 | edje_object_item_provider_set(Evas_Object *obj, Edje_Item_Provider_Cb func, void *data) | ||
967 | { | ||
968 | Edje *ed; | ||
969 | |||
970 | ed = _edje_fetch(obj); | ||
971 | if (!ed) return; | ||
972 | ed->item_provider.func = func; | ||
973 | ed->item_provider.data = data; | ||
974 | } | ||
975 | |||
976 | /* FIXDOC: New Function */ | ||
977 | EAPI void | ||
978 | edje_object_text_change_cb_set(Evas_Object *obj, Edje_Text_Change_Cb func, void *data) | ||
979 | { | ||
980 | Edje *ed; | ||
981 | unsigned int i; | ||
982 | |||
983 | ed = _edje_fetch(obj); | ||
984 | if (!ed) return; | ||
985 | ed->text_change.func = func; | ||
986 | ed->text_change.data = data; | ||
987 | |||
988 | for (i = 0; i < ed->table_parts_size; i++) | ||
989 | { | ||
990 | Edje_Real_Part *rp; | ||
991 | |||
992 | rp = ed->table_parts[i]; | ||
993 | if ((rp->part->type == EDJE_PART_TYPE_GROUP) && (rp->swallowed_object)) | ||
994 | edje_object_text_change_cb_set(rp->swallowed_object, func, data); | ||
995 | } | ||
996 | } | ||
997 | |||
998 | Eina_Bool | ||
999 | _edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) | ||
1000 | { | ||
1001 | if ((!rp->text.text) && (!text)) | ||
1002 | return EINA_FALSE; | ||
1003 | if ((rp->text.text) && (text) && | ||
1004 | (!strcmp(rp->text.text, text))) | ||
1005 | return EINA_FALSE; | ||
1006 | if (rp->text.text) | ||
1007 | { | ||
1008 | eina_stringshare_del(rp->text.text); | ||
1009 | rp->text.text = NULL; | ||
1010 | } | ||
1011 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1012 | _edje_entry_text_markup_set(rp, text); | ||
1013 | else | ||
1014 | if (text) rp->text.text = eina_stringshare_add(text); | ||
1015 | rp->edje->dirty = 1; | ||
1016 | rp->edje->recalc_call = 1; | ||
1017 | rp->edje->recalc_hints = 1; | ||
1018 | #ifdef EDJE_CALC_CACHE | ||
1019 | rp->invalidate = 1; | ||
1020 | #endif | ||
1021 | _edje_recalc(rp->edje); | ||
1022 | if (rp->edje->text_change.func) | ||
1023 | rp->edje->text_change.func(rp->edje->text_change.data, obj, part); | ||
1024 | return EINA_TRUE; | ||
1025 | } | ||
1026 | |||
1027 | Eina_Bool | ||
1028 | _edje_object_part_text_raw_append(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) | ||
1029 | { | ||
1030 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1031 | _edje_entry_text_markup_append(rp, text); | ||
1032 | else if (text) | ||
1033 | { | ||
1034 | if (rp->text.text) | ||
1035 | { | ||
1036 | char *new = NULL; | ||
1037 | int len_added = strlen(text); | ||
1038 | int len_old = strlen(rp->text.text); | ||
1039 | new = malloc(len_old + len_added + 1); | ||
1040 | memcpy(new, rp->text.text, len_old); | ||
1041 | memcpy(new + len_old, text, len_added); | ||
1042 | new[len_old + len_added] = '\0'; | ||
1043 | eina_stringshare_replace(&rp->text.text, new); | ||
1044 | free(new); | ||
1045 | } | ||
1046 | else | ||
1047 | { | ||
1048 | eina_stringshare_replace(&rp->text.text, text); | ||
1049 | } | ||
1050 | } | ||
1051 | rp->edje->dirty = 1; | ||
1052 | rp->edje->recalc_call = 1; | ||
1053 | #ifdef EDJE_CALC_CACHE | ||
1054 | rp->invalidate = 1; | ||
1055 | #endif | ||
1056 | _edje_recalc(rp->edje); | ||
1057 | if (rp->edje->text_change.func) | ||
1058 | rp->edje->text_change.func(rp->edje->text_change.data, obj, part); | ||
1059 | return EINA_TRUE; | ||
1060 | } | ||
1061 | |||
1062 | EAPI void | ||
1063 | edje_object_part_text_style_user_push(Evas_Object *obj, const char *part, | ||
1064 | const char *style) | ||
1065 | { | ||
1066 | Edje *ed; | ||
1067 | Edje_Real_Part *rp; | ||
1068 | Evas_Textblock_Style *ts; | ||
1069 | |||
1070 | ed = _edje_fetch(obj); | ||
1071 | if ((!ed) || (!part) || (!style)) return; | ||
1072 | rp = _edje_real_part_recursive_get(ed, part); | ||
1073 | if (!rp) return; | ||
1074 | if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return; | ||
1075 | |||
1076 | ts = evas_textblock_style_new(); | ||
1077 | evas_textblock_style_set(ts, style); | ||
1078 | evas_object_textblock_style_user_push(rp->object, ts); | ||
1079 | evas_textblock_style_free(ts); | ||
1080 | ed->recalc_hints = 1; | ||
1081 | } | ||
1082 | |||
1083 | EAPI void | ||
1084 | edje_object_part_text_style_user_pop(Evas_Object *obj, const char *part) | ||
1085 | { | ||
1086 | Edje *ed; | ||
1087 | Edje_Real_Part *rp; | ||
1088 | |||
1089 | ed = _edje_fetch(obj); | ||
1090 | if ((!ed) || (!part)) return; | ||
1091 | rp = _edje_real_part_recursive_get(ed, part); | ||
1092 | if (!rp) return; | ||
1093 | if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return; | ||
1094 | |||
1095 | evas_object_textblock_style_user_pop(rp->object); | ||
1096 | ed->recalc_hints = 1; | ||
1097 | } | ||
1098 | |||
1099 | EAPI const char * | ||
1100 | edje_object_part_text_style_user_peek(const Evas_Object *obj, const char *part) | ||
1101 | { | ||
1102 | Edje *ed; | ||
1103 | Edje_Real_Part *rp; | ||
1104 | const Evas_Textblock_Style *ts; | ||
1105 | |||
1106 | ed = _edje_fetch(obj); | ||
1107 | if ((!ed) || (!part)) return NULL; | ||
1108 | rp = _edje_real_part_recursive_get(ed, part); | ||
1109 | if (!rp) return NULL; | ||
1110 | if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return NULL; | ||
1111 | |||
1112 | ts = evas_object_textblock_style_user_peek(rp->object); | ||
1113 | if (ts) | ||
1114 | return evas_textblock_style_get(ts); | ||
1115 | else | ||
1116 | return NULL; | ||
1117 | } | ||
1118 | |||
1119 | EAPI Eina_Bool | ||
1120 | edje_object_part_text_set(Evas_Object *obj, const char *part, const char *text) | ||
1121 | { | ||
1122 | Edje *ed; | ||
1123 | Edje_Real_Part *rp; | ||
1124 | |||
1125 | ed = _edje_fetch(obj); | ||
1126 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1127 | rp = _edje_real_part_recursive_get(ed, part); | ||
1128 | if (!rp) return EINA_FALSE; | ||
1129 | if ((rp->part->type != EDJE_PART_TYPE_TEXT) && | ||
1130 | (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return EINA_FALSE; | ||
1131 | return _edje_object_part_text_raw_set(obj, rp, part, text); | ||
1132 | } | ||
1133 | |||
1134 | EAPI const char * | ||
1135 | edje_object_part_text_get(const Evas_Object *obj, const char *part) | ||
1136 | { | ||
1137 | Edje *ed; | ||
1138 | Edje_Real_Part *rp; | ||
1139 | |||
1140 | ed = _edje_fetch(obj); | ||
1141 | if ((!ed) || (!part)) return NULL; | ||
1142 | |||
1143 | /* Need to recalc before providing the object. */ | ||
1144 | _edje_recalc_do(ed); | ||
1145 | |||
1146 | rp = _edje_real_part_recursive_get(ed, part); | ||
1147 | if (!rp) return NULL; | ||
1148 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1149 | return _edje_entry_text_get(rp); | ||
1150 | else | ||
1151 | { | ||
1152 | if (rp->part->type == EDJE_PART_TYPE_TEXT) return rp->text.text; | ||
1153 | if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) | ||
1154 | return evas_object_textblock_text_markup_get(rp->object); | ||
1155 | } | ||
1156 | return NULL; | ||
1157 | } | ||
1158 | |||
1159 | char * | ||
1160 | _edje_text_escape(const char *text) | ||
1161 | { | ||
1162 | Eina_Strbuf *txt; | ||
1163 | char *ret; | ||
1164 | const char *text_end; | ||
1165 | size_t text_len; | ||
1166 | |||
1167 | if (!text) return NULL; | ||
1168 | |||
1169 | txt = eina_strbuf_new(); | ||
1170 | text_len = strlen(text); | ||
1171 | |||
1172 | text_end = text + text_len; | ||
1173 | while (text < text_end) | ||
1174 | { | ||
1175 | int advance; | ||
1176 | const char *escaped = evas_textblock_string_escape_get(text, &advance); | ||
1177 | if (!escaped) | ||
1178 | { | ||
1179 | eina_strbuf_append_char(txt, text[0]); | ||
1180 | advance = 1; | ||
1181 | } | ||
1182 | else | ||
1183 | eina_strbuf_append(txt, escaped); | ||
1184 | |||
1185 | text += advance; | ||
1186 | } | ||
1187 | |||
1188 | ret = eina_strbuf_string_steal(txt); | ||
1189 | eina_strbuf_free(txt); | ||
1190 | return ret; | ||
1191 | } | ||
1192 | |||
1193 | char * | ||
1194 | _edje_text_unescape(const char *text) | ||
1195 | { | ||
1196 | Eina_Strbuf *txt; | ||
1197 | char *ret; | ||
1198 | const char *text_end, *last, *escape_start; | ||
1199 | size_t text_len; | ||
1200 | |||
1201 | if (!text) return NULL; | ||
1202 | |||
1203 | txt = eina_strbuf_new(); | ||
1204 | text_len = strlen(text); | ||
1205 | |||
1206 | text_end = text + text_len; | ||
1207 | last = text; | ||
1208 | escape_start = NULL; | ||
1209 | for (; text < text_end; text++) | ||
1210 | { | ||
1211 | if (*text == '&') | ||
1212 | { | ||
1213 | size_t len; | ||
1214 | const char *str; | ||
1215 | |||
1216 | if (last) | ||
1217 | { | ||
1218 | len = text - last; | ||
1219 | str = last; | ||
1220 | } | ||
1221 | else | ||
1222 | { | ||
1223 | len = text - escape_start; | ||
1224 | str = escape_start; | ||
1225 | } | ||
1226 | |||
1227 | if (len > 0) | ||
1228 | eina_strbuf_append_n(txt, str, len); | ||
1229 | |||
1230 | escape_start = text; | ||
1231 | last = NULL; | ||
1232 | } | ||
1233 | else if ((*text == ';') && (escape_start)) | ||
1234 | { | ||
1235 | size_t len; | ||
1236 | const char *str = evas_textblock_escape_string_range_get(escape_start, text); | ||
1237 | |||
1238 | if (str) | ||
1239 | len = strlen(str); | ||
1240 | else | ||
1241 | { | ||
1242 | str = escape_start; | ||
1243 | len = text + 1 - escape_start; | ||
1244 | } | ||
1245 | |||
1246 | eina_strbuf_append_n(txt, str, len); | ||
1247 | |||
1248 | escape_start = NULL; | ||
1249 | last = text + 1; | ||
1250 | } | ||
1251 | } | ||
1252 | |||
1253 | if (!last && escape_start) | ||
1254 | last = escape_start; | ||
1255 | |||
1256 | if (last && (text > last)) | ||
1257 | { | ||
1258 | size_t len = text - last; | ||
1259 | eina_strbuf_append_n(txt, last, len); | ||
1260 | } | ||
1261 | |||
1262 | ret = eina_strbuf_string_steal(txt); | ||
1263 | eina_strbuf_free(txt); | ||
1264 | return ret; | ||
1265 | } | ||
1266 | |||
1267 | EAPI Eina_Bool | ||
1268 | edje_object_part_text_unescaped_set(Evas_Object *obj, const char *part, const char *text_to_escape) | ||
1269 | { | ||
1270 | Edje *ed; | ||
1271 | Edje_Real_Part *rp; | ||
1272 | Eina_Bool ret = EINA_FALSE; | ||
1273 | |||
1274 | ed = _edje_fetch(obj); | ||
1275 | if ((!ed) || (!part)) return ret; | ||
1276 | rp = _edje_real_part_recursive_get(ed, part); | ||
1277 | if (!rp) return ret; | ||
1278 | if (rp->part->type == EDJE_PART_TYPE_TEXT) | ||
1279 | ret = _edje_object_part_text_raw_set(obj, rp, part, text_to_escape); | ||
1280 | else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) | ||
1281 | { | ||
1282 | char *text = _edje_text_escape(text_to_escape); | ||
1283 | |||
1284 | ret = _edje_object_part_text_raw_set(obj, rp, part, text); | ||
1285 | free(text); | ||
1286 | } | ||
1287 | return ret; | ||
1288 | } | ||
1289 | |||
1290 | EAPI char * | ||
1291 | edje_object_part_text_unescaped_get(const Evas_Object *obj, const char *part) | ||
1292 | { | ||
1293 | Edje *ed; | ||
1294 | Edje_Real_Part *rp; | ||
1295 | |||
1296 | ed = _edje_fetch(obj); | ||
1297 | if ((!ed) || (!part)) return NULL; | ||
1298 | |||
1299 | /* Need to recalc before providing the object. */ | ||
1300 | _edje_recalc_do(ed); | ||
1301 | |||
1302 | rp = _edje_real_part_recursive_get(ed, part); | ||
1303 | if (!rp) return NULL; | ||
1304 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1305 | { | ||
1306 | const char *t = _edje_entry_text_get(rp); | ||
1307 | return _edje_text_unescape(t); | ||
1308 | } | ||
1309 | else | ||
1310 | { | ||
1311 | if (rp->part->type == EDJE_PART_TYPE_TEXT) return strdup(rp->text.text); | ||
1312 | if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) | ||
1313 | { | ||
1314 | const char *t = evas_object_textblock_text_markup_get(rp->object); | ||
1315 | return _edje_text_unescape(t); | ||
1316 | } | ||
1317 | } | ||
1318 | return NULL; | ||
1319 | } | ||
1320 | |||
1321 | EAPI const char * | ||
1322 | edje_object_part_text_selection_get(const Evas_Object *obj, const char *part) | ||
1323 | { | ||
1324 | Edje *ed; | ||
1325 | Edje_Real_Part *rp; | ||
1326 | |||
1327 | ed = _edje_fetch(obj); | ||
1328 | if ((!ed) || (!part)) return NULL; | ||
1329 | rp = _edje_real_part_recursive_get(ed, part); | ||
1330 | if (!rp) return NULL; | ||
1331 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1332 | return _edje_entry_selection_get(rp); | ||
1333 | return NULL; | ||
1334 | } | ||
1335 | |||
1336 | EAPI void | ||
1337 | edje_object_part_text_select_none(const Evas_Object *obj, const char *part) | ||
1338 | { | ||
1339 | Edje *ed; | ||
1340 | Edje_Real_Part *rp; | ||
1341 | |||
1342 | ed = _edje_fetch(obj); | ||
1343 | if ((!ed) || (!part)) return; | ||
1344 | rp = _edje_real_part_recursive_get(ed, part); | ||
1345 | if (!rp) return; | ||
1346 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1347 | _edje_entry_select_none(rp); | ||
1348 | } | ||
1349 | |||
1350 | EAPI void | ||
1351 | edje_object_part_text_select_all(const Evas_Object *obj, const char *part) | ||
1352 | { | ||
1353 | Edje *ed; | ||
1354 | Edje_Real_Part *rp; | ||
1355 | |||
1356 | ed = _edje_fetch(obj); | ||
1357 | if ((!ed) || (!part)) return; | ||
1358 | rp = _edje_real_part_recursive_get(ed, part); | ||
1359 | if (!rp) return; | ||
1360 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1361 | _edje_entry_select_all(rp); | ||
1362 | } | ||
1363 | |||
1364 | EAPI void | ||
1365 | edje_object_part_text_insert(Evas_Object *obj, const char *part, const char *text) | ||
1366 | { | ||
1367 | Edje *ed; | ||
1368 | Edje_Real_Part *rp; | ||
1369 | |||
1370 | ed = _edje_fetch(obj); | ||
1371 | if ((!ed) || (!part)) return; | ||
1372 | rp = _edje_real_part_recursive_get(ed, part); | ||
1373 | if (!rp) return; | ||
1374 | if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; | ||
1375 | if (rp->part->entry_mode <= EDJE_ENTRY_EDIT_MODE_NONE) return; | ||
1376 | _edje_entry_text_markup_insert(rp, text); | ||
1377 | rp->edje->dirty = 1; | ||
1378 | rp->edje->recalc_call = 1; | ||
1379 | rp->edje->recalc_hints = 1; | ||
1380 | #ifdef EDJE_CALC_CACHE | ||
1381 | rp->invalidate = 1; | ||
1382 | #endif | ||
1383 | _edje_recalc(rp->edje); | ||
1384 | if (rp->edje->text_change.func) | ||
1385 | rp->edje->text_change.func(rp->edje->text_change.data, obj, part); | ||
1386 | } | ||
1387 | |||
1388 | EAPI void | ||
1389 | edje_object_part_text_append(Evas_Object *obj, const char *part, const char *text) | ||
1390 | { | ||
1391 | Edje *ed; | ||
1392 | Edje_Real_Part *rp; | ||
1393 | |||
1394 | ed = _edje_fetch(obj); | ||
1395 | if ((!ed) || (!part)) return; | ||
1396 | rp = _edje_real_part_recursive_get(ed, part); | ||
1397 | if (!rp) return; | ||
1398 | if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; | ||
1399 | _edje_object_part_text_raw_append(obj, rp, part, text); | ||
1400 | rp->edje->dirty = 1; | ||
1401 | rp->edje->recalc_call = 1; | ||
1402 | rp->edje->recalc_hints = 1; | ||
1403 | #ifdef EDJE_CALC_CACHE | ||
1404 | rp->invalidate = 1; | ||
1405 | #endif | ||
1406 | _edje_recalc(rp->edje); | ||
1407 | if (rp->edje->text_change.func) | ||
1408 | rp->edje->text_change.func(rp->edje->text_change.data, obj, part); | ||
1409 | } | ||
1410 | |||
1411 | EAPI const Eina_List * | ||
1412 | edje_object_part_text_anchor_list_get(const Evas_Object *obj, const char *part) | ||
1413 | { | ||
1414 | Edje *ed; | ||
1415 | Edje_Real_Part *rp; | ||
1416 | |||
1417 | ed = _edje_fetch(obj); | ||
1418 | if ((!ed) || (!part)) return NULL; | ||
1419 | rp = _edje_real_part_recursive_get(ed, part); | ||
1420 | if (!rp) return NULL; | ||
1421 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1422 | return _edje_entry_anchors_list(rp); | ||
1423 | return NULL; | ||
1424 | } | ||
1425 | |||
1426 | EAPI const Eina_List * | ||
1427 | edje_object_part_text_anchor_geometry_get(const Evas_Object *obj, const char *part, const char *anchor) | ||
1428 | { | ||
1429 | Edje *ed; | ||
1430 | Edje_Real_Part *rp; | ||
1431 | |||
1432 | ed = _edje_fetch(obj); | ||
1433 | if ((!ed) || (!part)) return NULL; | ||
1434 | rp = _edje_real_part_recursive_get(ed, part); | ||
1435 | if (!rp) return NULL; | ||
1436 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1437 | return _edje_entry_anchor_geometry_get(rp, anchor); | ||
1438 | return NULL; | ||
1439 | } | ||
1440 | |||
1441 | EAPI const Eina_List * | ||
1442 | edje_object_part_text_item_list_get(const Evas_Object *obj, const char *part) | ||
1443 | { | ||
1444 | Edje *ed; | ||
1445 | Edje_Real_Part *rp; | ||
1446 | |||
1447 | ed = _edje_fetch(obj); | ||
1448 | if ((!ed) || (!part)) return NULL; | ||
1449 | rp = _edje_real_part_recursive_get(ed, part); | ||
1450 | if (!rp) return NULL; | ||
1451 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1452 | return _edje_entry_items_list(rp); | ||
1453 | return NULL; | ||
1454 | } | ||
1455 | |||
1456 | EAPI Eina_Bool | ||
1457 | edje_object_part_text_item_geometry_get(const Evas_Object *obj, const char *part, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) | ||
1458 | { | ||
1459 | Edje *ed; | ||
1460 | Edje_Real_Part *rp; | ||
1461 | |||
1462 | ed = _edje_fetch(obj); | ||
1463 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1464 | rp = _edje_real_part_recursive_get(ed, part); | ||
1465 | if (!rp) return EINA_FALSE; | ||
1466 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1467 | return _edje_entry_item_geometry_get(rp, item, cx, cy, cw, ch); | ||
1468 | return EINA_FALSE; | ||
1469 | } | ||
1470 | |||
1471 | EAPI void | ||
1472 | edje_object_part_text_cursor_geometry_get(const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) | ||
1473 | { | ||
1474 | Edje *ed; | ||
1475 | Edje_Real_Part *rp; | ||
1476 | |||
1477 | ed = _edje_fetch(obj); | ||
1478 | if (x) *x = 0; | ||
1479 | if (y) *y = 0; | ||
1480 | if (w) *w = 0; | ||
1481 | if (h) *h = 0; | ||
1482 | if ((!ed) || (!part)) return; | ||
1483 | rp = _edje_real_part_recursive_get(ed, part); | ||
1484 | if (!rp) return; | ||
1485 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1486 | { | ||
1487 | _edje_entry_cursor_geometry_get(rp, x, y, w, h); | ||
1488 | if (x) *x -= rp->edje->x; | ||
1489 | if (y) *y -= rp->edje->y; | ||
1490 | } | ||
1491 | return; | ||
1492 | } | ||
1493 | |||
1494 | EAPI void | ||
1495 | edje_object_part_text_user_insert(const Evas_Object *obj, const char *part, const char *text) | ||
1496 | { | ||
1497 | Edje *ed; | ||
1498 | Edje_Real_Part *rp; | ||
1499 | |||
1500 | ed = _edje_fetch(obj); | ||
1501 | if ((!ed) || (!part)) return; | ||
1502 | rp = _edje_real_part_recursive_get(ed, part); | ||
1503 | if (!rp) return; | ||
1504 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1505 | _edje_entry_user_insert(rp, text); | ||
1506 | } | ||
1507 | |||
1508 | EAPI void | ||
1509 | edje_object_part_text_select_allow_set(const Evas_Object *obj, const char *part, Eina_Bool allow) | ||
1510 | { | ||
1511 | Edje *ed; | ||
1512 | Edje_Real_Part *rp; | ||
1513 | |||
1514 | ed = _edje_fetch(obj); | ||
1515 | if ((!ed) || (!part)) return; | ||
1516 | rp = _edje_real_part_recursive_get(ed, part); | ||
1517 | if (!rp) return; | ||
1518 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1519 | _edje_entry_select_allow_set(rp, allow); | ||
1520 | } | ||
1521 | |||
1522 | EAPI void | ||
1523 | edje_object_part_text_select_abort(const Evas_Object *obj, const char *part) | ||
1524 | { | ||
1525 | Edje *ed; | ||
1526 | Edje_Real_Part *rp; | ||
1527 | |||
1528 | ed = _edje_fetch(obj); | ||
1529 | if ((!ed) || (!part)) return; | ||
1530 | rp = _edje_real_part_recursive_get(ed, part); | ||
1531 | if (!rp) return; | ||
1532 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1533 | _edje_entry_select_abort(rp); | ||
1534 | } | ||
1535 | |||
1536 | EAPI void | ||
1537 | edje_object_part_text_select_begin(const Evas_Object *obj, const char *part) | ||
1538 | { | ||
1539 | Edje *ed; | ||
1540 | Edje_Real_Part *rp; | ||
1541 | |||
1542 | ed = _edje_fetch(obj); | ||
1543 | if ((!ed) || (!part)) return; | ||
1544 | rp = _edje_real_part_recursive_get(ed, part); | ||
1545 | if (!rp) return; | ||
1546 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1547 | _edje_entry_select_begin(rp); | ||
1548 | } | ||
1549 | |||
1550 | EAPI void | ||
1551 | edje_object_part_text_select_extend(const Evas_Object *obj, const char *part) | ||
1552 | { | ||
1553 | Edje *ed; | ||
1554 | Edje_Real_Part *rp; | ||
1555 | |||
1556 | ed = _edje_fetch(obj); | ||
1557 | if ((!ed) || (!part)) return; | ||
1558 | rp = _edje_real_part_recursive_get(ed, part); | ||
1559 | if (!rp) return; | ||
1560 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1561 | _edje_entry_select_extend(rp); | ||
1562 | } | ||
1563 | |||
1564 | EAPI void * | ||
1565 | edje_object_part_text_imf_context_get(const Evas_Object *obj, const char *part) | ||
1566 | { | ||
1567 | Edje *ed; | ||
1568 | Edje_Real_Part *rp; | ||
1569 | |||
1570 | ed = _edje_fetch(obj); | ||
1571 | if ((!ed) || (!part)) return NULL; | ||
1572 | |||
1573 | rp = _edje_real_part_recursive_get(ed, (char *)part); | ||
1574 | if (!rp) return NULL; | ||
1575 | |||
1576 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1577 | return _edje_entry_imf_context_get(rp); | ||
1578 | else | ||
1579 | return NULL; | ||
1580 | } | ||
1581 | |||
1582 | EAPI Eina_Bool | ||
1583 | edje_object_part_text_cursor_next(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1584 | { | ||
1585 | Edje *ed; | ||
1586 | Edje_Real_Part *rp; | ||
1587 | |||
1588 | ed = _edje_fetch(obj); | ||
1589 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1590 | rp = _edje_real_part_recursive_get(ed, part); | ||
1591 | if (!rp) return EINA_FALSE; | ||
1592 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1593 | { | ||
1594 | return _edje_entry_cursor_next(rp, cur); | ||
1595 | } | ||
1596 | return EINA_FALSE; | ||
1597 | } | ||
1598 | |||
1599 | EAPI Eina_Bool | ||
1600 | edje_object_part_text_cursor_prev(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1601 | { | ||
1602 | Edje *ed; | ||
1603 | Edje_Real_Part *rp; | ||
1604 | |||
1605 | ed = _edje_fetch(obj); | ||
1606 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1607 | rp = _edje_real_part_recursive_get(ed, part); | ||
1608 | if (!rp) return EINA_FALSE; | ||
1609 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1610 | { | ||
1611 | return _edje_entry_cursor_prev(rp, cur); | ||
1612 | } | ||
1613 | return EINA_FALSE; | ||
1614 | } | ||
1615 | |||
1616 | EAPI Eina_Bool | ||
1617 | edje_object_part_text_cursor_up(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1618 | { | ||
1619 | Edje *ed; | ||
1620 | Edje_Real_Part *rp; | ||
1621 | |||
1622 | ed = _edje_fetch(obj); | ||
1623 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1624 | rp = _edje_real_part_recursive_get(ed, part); | ||
1625 | if (!rp) return EINA_FALSE; | ||
1626 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1627 | { | ||
1628 | return _edje_entry_cursor_up(rp, cur); | ||
1629 | } | ||
1630 | return EINA_FALSE; | ||
1631 | } | ||
1632 | |||
1633 | EAPI Eina_Bool | ||
1634 | edje_object_part_text_cursor_down(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1635 | { | ||
1636 | Edje *ed; | ||
1637 | Edje_Real_Part *rp; | ||
1638 | |||
1639 | ed = _edje_fetch(obj); | ||
1640 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1641 | rp = _edje_real_part_recursive_get(ed, part); | ||
1642 | if (!rp) return EINA_FALSE; | ||
1643 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1644 | { | ||
1645 | return _edje_entry_cursor_down(rp, cur); | ||
1646 | } | ||
1647 | return EINA_FALSE; | ||
1648 | } | ||
1649 | |||
1650 | EAPI void | ||
1651 | edje_object_part_text_cursor_begin_set(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1652 | { | ||
1653 | Edje *ed; | ||
1654 | Edje_Real_Part *rp; | ||
1655 | |||
1656 | ed = _edje_fetch(obj); | ||
1657 | if ((!ed) || (!part)) return; | ||
1658 | rp = _edje_real_part_recursive_get(ed, part); | ||
1659 | if (!rp) return; | ||
1660 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1661 | { | ||
1662 | _edje_entry_cursor_begin(rp, cur); | ||
1663 | } | ||
1664 | } | ||
1665 | |||
1666 | EAPI void | ||
1667 | edje_object_part_text_cursor_end_set(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1668 | { | ||
1669 | Edje *ed; | ||
1670 | Edje_Real_Part *rp; | ||
1671 | |||
1672 | ed = _edje_fetch(obj); | ||
1673 | if ((!ed) || (!part)) return; | ||
1674 | rp = _edje_real_part_recursive_get(ed, part); | ||
1675 | if (!rp) return; | ||
1676 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1677 | { | ||
1678 | _edje_entry_cursor_end(rp, cur); | ||
1679 | } | ||
1680 | } | ||
1681 | |||
1682 | EAPI void | ||
1683 | edje_object_part_text_cursor_copy(Evas_Object *obj, const char *part, Edje_Cursor src, Edje_Cursor dst) | ||
1684 | { | ||
1685 | Edje *ed; | ||
1686 | Edje_Real_Part *rp; | ||
1687 | |||
1688 | ed = _edje_fetch(obj); | ||
1689 | if ((!ed) || (!part)) return; | ||
1690 | rp = _edje_real_part_recursive_get(ed, part); | ||
1691 | if (!rp) return; | ||
1692 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1693 | { | ||
1694 | _edje_entry_cursor_copy(rp, src, dst); | ||
1695 | } | ||
1696 | } | ||
1697 | |||
1698 | EAPI void | ||
1699 | edje_object_part_text_cursor_line_begin_set(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1700 | { | ||
1701 | Edje *ed; | ||
1702 | Edje_Real_Part *rp; | ||
1703 | |||
1704 | ed = _edje_fetch(obj); | ||
1705 | if ((!ed) || (!part)) return; | ||
1706 | rp = _edje_real_part_recursive_get(ed, part); | ||
1707 | if (!rp) return; | ||
1708 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1709 | { | ||
1710 | _edje_entry_cursor_line_begin(rp, cur); | ||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | EAPI void | ||
1715 | edje_object_part_text_cursor_line_end_set(Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1716 | { | ||
1717 | Edje *ed; | ||
1718 | Edje_Real_Part *rp; | ||
1719 | |||
1720 | ed = _edje_fetch(obj); | ||
1721 | if ((!ed) || (!part)) return; | ||
1722 | rp = _edje_real_part_recursive_get(ed, part); | ||
1723 | if (!rp) return; | ||
1724 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1725 | { | ||
1726 | _edje_entry_cursor_line_end(rp, cur); | ||
1727 | } | ||
1728 | } | ||
1729 | |||
1730 | EAPI Eina_Bool | ||
1731 | edje_object_part_text_cursor_coord_set(Evas_Object *obj, const char *part, | ||
1732 | Edje_Cursor cur, Evas_Coord x, Evas_Coord y) | ||
1733 | { | ||
1734 | Edje *ed; | ||
1735 | Edje_Real_Part *rp; | ||
1736 | |||
1737 | ed = _edje_fetch(obj); | ||
1738 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1739 | rp = _edje_real_part_recursive_get(ed, part); | ||
1740 | if (!rp) return EINA_FALSE; | ||
1741 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1742 | { | ||
1743 | return _edje_entry_cursor_coord_set(rp, cur, x, y); | ||
1744 | } | ||
1745 | return EINA_FALSE; | ||
1746 | } | ||
1747 | |||
1748 | EAPI Eina_Bool | ||
1749 | edje_object_part_text_cursor_is_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1750 | { | ||
1751 | Edje *ed; | ||
1752 | Edje_Real_Part *rp; | ||
1753 | |||
1754 | ed = _edje_fetch(obj); | ||
1755 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1756 | rp = _edje_real_part_recursive_get(ed, part); | ||
1757 | if (!rp) return EINA_FALSE; | ||
1758 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1759 | { | ||
1760 | return _edje_entry_cursor_is_format_get(rp, cur); | ||
1761 | } | ||
1762 | return EINA_FALSE; | ||
1763 | } | ||
1764 | |||
1765 | EAPI Eina_Bool | ||
1766 | edje_object_part_text_cursor_is_visible_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1767 | { | ||
1768 | Edje *ed; | ||
1769 | Edje_Real_Part *rp; | ||
1770 | |||
1771 | ed = _edje_fetch(obj); | ||
1772 | if ((!ed) || (!part)) return 0; | ||
1773 | rp = _edje_real_part_recursive_get(ed, part); | ||
1774 | if (!rp) return 0; | ||
1775 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1776 | { | ||
1777 | return _edje_entry_cursor_is_visible_format_get(rp, cur); | ||
1778 | } | ||
1779 | return 0; | ||
1780 | } | ||
1781 | |||
1782 | EAPI char * | ||
1783 | edje_object_part_text_cursor_content_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1784 | { | ||
1785 | Edje *ed; | ||
1786 | Edje_Real_Part *rp; | ||
1787 | |||
1788 | ed = _edje_fetch(obj); | ||
1789 | if ((!ed) || (!part)) return NULL; | ||
1790 | rp = _edje_real_part_recursive_get(ed, part); | ||
1791 | if (!rp) return NULL; | ||
1792 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1793 | { | ||
1794 | return _edje_entry_cursor_content_get(rp, cur); | ||
1795 | } | ||
1796 | return NULL; | ||
1797 | } | ||
1798 | |||
1799 | EAPI void | ||
1800 | edje_object_part_text_cursor_pos_set(Evas_Object *obj, const char *part, Edje_Cursor cur, int pos) | ||
1801 | { | ||
1802 | Edje *ed; | ||
1803 | Edje_Real_Part *rp; | ||
1804 | |||
1805 | ed = _edje_fetch(obj); | ||
1806 | if ((!ed) || (!part)) return; | ||
1807 | rp = _edje_real_part_recursive_get(ed, part); | ||
1808 | if (!rp) return; | ||
1809 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1810 | { | ||
1811 | _edje_entry_cursor_pos_set(rp, cur, pos); | ||
1812 | } | ||
1813 | } | ||
1814 | |||
1815 | EAPI int | ||
1816 | edje_object_part_text_cursor_pos_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) | ||
1817 | { | ||
1818 | Edje *ed; | ||
1819 | Edje_Real_Part *rp; | ||
1820 | |||
1821 | ed = _edje_fetch(obj); | ||
1822 | if ((!ed) || (!part)) return 0; | ||
1823 | rp = _edje_real_part_recursive_get(ed, part); | ||
1824 | if (!rp) return 0; | ||
1825 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1826 | { | ||
1827 | return _edje_entry_cursor_pos_get(rp, cur); | ||
1828 | } | ||
1829 | return 0; | ||
1830 | } | ||
1831 | |||
1832 | EAPI void | ||
1833 | edje_object_part_text_imf_context_reset(const Evas_Object *obj, const char *part) | ||
1834 | { | ||
1835 | Edje *ed; | ||
1836 | Edje_Real_Part *rp; | ||
1837 | |||
1838 | ed = _edje_fetch(obj); | ||
1839 | if ((!ed) || (!part)) return; | ||
1840 | rp = _edje_real_part_recursive_get(ed, part); | ||
1841 | if (!rp) return; | ||
1842 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1843 | { | ||
1844 | _edje_entry_imf_context_reset(rp); | ||
1845 | } | ||
1846 | } | ||
1847 | |||
1848 | EAPI void | ||
1849 | edje_object_part_text_input_panel_layout_set(Evas_Object *obj, const char *part, Edje_Input_Panel_Layout layout) | ||
1850 | { | ||
1851 | Edje *ed; | ||
1852 | Edje_Real_Part *rp; | ||
1853 | |||
1854 | ed = _edje_fetch(obj); | ||
1855 | if ((!ed) || (!part)) return; | ||
1856 | rp = _edje_real_part_recursive_get(ed, part); | ||
1857 | if (!rp) return; | ||
1858 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1859 | { | ||
1860 | _edje_entry_input_panel_layout_set(rp, layout); | ||
1861 | } | ||
1862 | } | ||
1863 | |||
1864 | EAPI Edje_Input_Panel_Layout | ||
1865 | edje_object_part_text_input_panel_layout_get(const Evas_Object *obj, const char *part) | ||
1866 | { | ||
1867 | Edje *ed; | ||
1868 | Edje_Real_Part *rp; | ||
1869 | |||
1870 | ed = _edje_fetch(obj); | ||
1871 | if ((!ed) || (!part)) return EDJE_INPUT_PANEL_LAYOUT_INVALID; | ||
1872 | rp = _edje_real_part_recursive_get(ed, part); | ||
1873 | if (!rp) return EINA_FALSE; | ||
1874 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1875 | { | ||
1876 | return _edje_entry_input_panel_layout_get(rp); | ||
1877 | } | ||
1878 | return EDJE_INPUT_PANEL_LAYOUT_INVALID; | ||
1879 | } | ||
1880 | |||
1881 | EAPI void | ||
1882 | edje_object_part_text_autocapital_type_set(Evas_Object *obj, const char *part, Edje_Text_Autocapital_Type autocapital_type) | ||
1883 | { | ||
1884 | Edje *ed; | ||
1885 | Edje_Real_Part *rp; | ||
1886 | |||
1887 | ed = _edje_fetch(obj); | ||
1888 | if ((!ed) || (!part)) return; | ||
1889 | rp = _edje_real_part_recursive_get(ed, part); | ||
1890 | if (!rp) return; | ||
1891 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1892 | { | ||
1893 | _edje_entry_autocapital_type_set(rp, autocapital_type); | ||
1894 | } | ||
1895 | } | ||
1896 | |||
1897 | EAPI Edje_Text_Autocapital_Type | ||
1898 | edje_object_part_text_autocapital_type_get(const Evas_Object *obj, const char *part) | ||
1899 | { | ||
1900 | Edje *ed; | ||
1901 | Edje_Real_Part *rp; | ||
1902 | |||
1903 | ed = _edje_fetch(obj); | ||
1904 | if ((!ed) || (!part)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; | ||
1905 | rp = _edje_real_part_recursive_get(ed, part); | ||
1906 | if (!rp) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; | ||
1907 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1908 | { | ||
1909 | return _edje_entry_autocapital_type_get(rp); | ||
1910 | } | ||
1911 | return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; | ||
1912 | } | ||
1913 | |||
1914 | EAPI void | ||
1915 | edje_object_part_text_prediction_allow_set(Evas_Object *obj, const char *part, Eina_Bool prediction) | ||
1916 | { | ||
1917 | Edje *ed; | ||
1918 | Edje_Real_Part *rp; | ||
1919 | |||
1920 | ed = _edje_fetch(obj); | ||
1921 | if ((!ed) || (!part)) return; | ||
1922 | rp = _edje_real_part_recursive_get(ed, part); | ||
1923 | if (!rp) return; | ||
1924 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1925 | { | ||
1926 | _edje_entry_prediction_allow_set(rp, prediction); | ||
1927 | } | ||
1928 | } | ||
1929 | |||
1930 | EAPI Eina_Bool | ||
1931 | edje_object_part_text_prediction_allow_get(const Evas_Object *obj, const char *part) | ||
1932 | { | ||
1933 | Edje *ed; | ||
1934 | Edje_Real_Part *rp; | ||
1935 | |||
1936 | ed = _edje_fetch(obj); | ||
1937 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1938 | rp = _edje_real_part_recursive_get(ed, part); | ||
1939 | if (!rp) return EINA_FALSE; | ||
1940 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1941 | { | ||
1942 | return _edje_entry_prediction_allow_get(rp); | ||
1943 | } | ||
1944 | return EINA_FALSE; | ||
1945 | } | ||
1946 | |||
1947 | EAPI void | ||
1948 | edje_object_part_text_input_panel_enabled_set(Evas_Object *obj, const char *part, Eina_Bool enabled) | ||
1949 | { | ||
1950 | Edje *ed; | ||
1951 | Edje_Real_Part *rp; | ||
1952 | |||
1953 | ed = _edje_fetch(obj); | ||
1954 | if ((!ed) || (!part)) return; | ||
1955 | rp = _edje_real_part_recursive_get(ed, part); | ||
1956 | if (!rp) return; | ||
1957 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1958 | { | ||
1959 | _edje_entry_input_panel_enabled_set(rp, enabled); | ||
1960 | } | ||
1961 | } | ||
1962 | |||
1963 | EAPI Eina_Bool | ||
1964 | edje_object_part_text_input_panel_enabled_get(const Evas_Object *obj, const char *part) | ||
1965 | { | ||
1966 | Edje *ed; | ||
1967 | Edje_Real_Part *rp; | ||
1968 | |||
1969 | ed = _edje_fetch(obj); | ||
1970 | if ((!ed) || (!part)) return EINA_FALSE; | ||
1971 | rp = _edje_real_part_recursive_get(ed, part); | ||
1972 | if (!rp) return EINA_FALSE; | ||
1973 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1974 | { | ||
1975 | return _edje_entry_input_panel_enabled_get(rp); | ||
1976 | } | ||
1977 | return EINA_FALSE; | ||
1978 | } | ||
1979 | |||
1980 | EAPI void | ||
1981 | edje_object_part_text_input_panel_show(const Evas_Object *obj, const char *part) | ||
1982 | { | ||
1983 | Edje *ed; | ||
1984 | Edje_Real_Part *rp; | ||
1985 | |||
1986 | ed = _edje_fetch(obj); | ||
1987 | if ((!ed) || (!part)) return; | ||
1988 | rp = _edje_real_part_recursive_get(ed, part); | ||
1989 | if (!rp) return; | ||
1990 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
1991 | _edje_entry_input_panel_show(rp); | ||
1992 | } | ||
1993 | |||
1994 | EAPI void | ||
1995 | edje_object_part_text_input_panel_hide(const Evas_Object *obj, const char *part) | ||
1996 | { | ||
1997 | Edje *ed; | ||
1998 | Edje_Real_Part *rp; | ||
1999 | |||
2000 | ed = _edje_fetch(obj); | ||
2001 | if ((!ed) || (!part)) return; | ||
2002 | rp = _edje_real_part_recursive_get(ed, part); | ||
2003 | if (!rp) return; | ||
2004 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2005 | _edje_entry_input_panel_hide(rp); | ||
2006 | } | ||
2007 | |||
2008 | EAPI void | ||
2009 | edje_object_part_text_input_panel_language_set(Evas_Object *obj, const char *part, Edje_Input_Panel_Lang lang) | ||
2010 | { | ||
2011 | Edje *ed; | ||
2012 | Edje_Real_Part *rp; | ||
2013 | |||
2014 | ed = _edje_fetch(obj); | ||
2015 | if ((!ed) || (!part)) return; | ||
2016 | rp = _edje_real_part_recursive_get(ed, part); | ||
2017 | if (!rp) return; | ||
2018 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2019 | { | ||
2020 | _edje_entry_input_panel_language_set(rp, lang); | ||
2021 | } | ||
2022 | } | ||
2023 | |||
2024 | EAPI Edje_Input_Panel_Lang | ||
2025 | edje_object_part_text_input_panel_language_get(const Evas_Object *obj, const char *part) | ||
2026 | { | ||
2027 | Edje *ed; | ||
2028 | Edje_Real_Part *rp; | ||
2029 | |||
2030 | ed = _edje_fetch(obj); | ||
2031 | if ((!ed) || (!part)) return EDJE_INPUT_PANEL_LANG_AUTOMATIC; | ||
2032 | rp = _edje_real_part_recursive_get(ed, part); | ||
2033 | if (!rp) return EDJE_INPUT_PANEL_LANG_AUTOMATIC; | ||
2034 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2035 | { | ||
2036 | return _edje_entry_input_panel_language_get(rp); | ||
2037 | } | ||
2038 | return EDJE_INPUT_PANEL_LANG_AUTOMATIC; | ||
2039 | } | ||
2040 | |||
2041 | EAPI void | ||
2042 | edje_object_part_text_input_panel_imdata_set(Evas_Object *obj, const char *part, const void *data, int len) | ||
2043 | { | ||
2044 | Edje *ed; | ||
2045 | Edje_Real_Part *rp; | ||
2046 | |||
2047 | ed = _edje_fetch(obj); | ||
2048 | if ((!ed) || (!part)) return; | ||
2049 | rp = _edje_real_part_recursive_get(ed, part); | ||
2050 | if (!rp) return; | ||
2051 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2052 | { | ||
2053 | _edje_entry_input_panel_imdata_set(rp, data, len); | ||
2054 | } | ||
2055 | } | ||
2056 | |||
2057 | EAPI void | ||
2058 | edje_object_part_text_input_panel_imdata_get(const Evas_Object *obj, const char *part, void *data, int *len) | ||
2059 | { | ||
2060 | Edje *ed; | ||
2061 | Edje_Real_Part *rp; | ||
2062 | |||
2063 | ed = _edje_fetch(obj); | ||
2064 | if ((!ed) || (!part)) return; | ||
2065 | rp = _edje_real_part_recursive_get(ed, part); | ||
2066 | if (!rp) return; | ||
2067 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2068 | { | ||
2069 | _edje_entry_input_panel_imdata_get(rp, data, len); | ||
2070 | } | ||
2071 | } | ||
2072 | |||
2073 | EAPI void | ||
2074 | edje_object_part_text_input_panel_return_key_type_set(Evas_Object *obj, const char *part, Edje_Input_Panel_Return_Key_Type return_key_type) | ||
2075 | { | ||
2076 | Edje *ed; | ||
2077 | Edje_Real_Part *rp; | ||
2078 | |||
2079 | ed = _edje_fetch(obj); | ||
2080 | if ((!ed) || (!part)) return; | ||
2081 | rp = _edje_real_part_recursive_get(ed, part); | ||
2082 | if (!rp) return; | ||
2083 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2084 | { | ||
2085 | _edje_entry_input_panel_return_key_type_set(rp, return_key_type); | ||
2086 | } | ||
2087 | } | ||
2088 | |||
2089 | EAPI Edje_Input_Panel_Return_Key_Type | ||
2090 | edje_object_part_text_input_panel_return_key_type_get(const Evas_Object *obj, const char *part) | ||
2091 | { | ||
2092 | Edje *ed; | ||
2093 | Edje_Real_Part *rp; | ||
2094 | |||
2095 | ed = _edje_fetch(obj); | ||
2096 | if ((!ed) || (!part)) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; | ||
2097 | rp = _edje_real_part_recursive_get(ed, part); | ||
2098 | if (!rp) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; | ||
2099 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2100 | { | ||
2101 | return _edje_entry_input_panel_return_key_type_get(rp); | ||
2102 | } | ||
2103 | return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; | ||
2104 | } | ||
2105 | |||
2106 | EAPI void | ||
2107 | edje_object_part_text_input_panel_return_key_disabled_set(Evas_Object *obj, const char *part, Eina_Bool disabled) | ||
2108 | { | ||
2109 | Edje *ed; | ||
2110 | Edje_Real_Part *rp; | ||
2111 | |||
2112 | ed = _edje_fetch(obj); | ||
2113 | if ((!ed) || (!part)) return; | ||
2114 | rp = _edje_real_part_recursive_get(ed, part); | ||
2115 | if (!rp) return; | ||
2116 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2117 | { | ||
2118 | _edje_entry_input_panel_return_key_disabled_set(rp, disabled); | ||
2119 | } | ||
2120 | } | ||
2121 | |||
2122 | EAPI Eina_Bool | ||
2123 | edje_object_part_text_input_panel_return_key_disabled_get(const Evas_Object *obj, const char *part) | ||
2124 | { | ||
2125 | Edje *ed; | ||
2126 | Edje_Real_Part *rp; | ||
2127 | |||
2128 | ed = _edje_fetch(obj); | ||
2129 | if ((!ed) || (!part)) return EINA_FALSE; | ||
2130 | rp = _edje_real_part_recursive_get(ed, part); | ||
2131 | if (!rp) return EINA_FALSE; | ||
2132 | if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) | ||
2133 | { | ||
2134 | return _edje_entry_input_panel_return_key_disabled_get(rp); | ||
2135 | } | ||
2136 | return EINA_FALSE; | ||
2137 | } | ||
2138 | |||
2139 | EAPI void | ||
2140 | edje_object_text_insert_filter_callback_add(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data) | ||
2141 | { | ||
2142 | Edje *ed; | ||
2143 | Edje_Text_Insert_Filter_Callback *cb; | ||
2144 | |||
2145 | ed = _edje_fetch(obj); | ||
2146 | if ((!ed) || (!part)) return; | ||
2147 | cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback)); | ||
2148 | cb->part = eina_stringshare_add(part); | ||
2149 | cb->func = func; | ||
2150 | cb->data = (void *)data; | ||
2151 | ed->text_insert_filter_callbacks = | ||
2152 | eina_list_append(ed->text_insert_filter_callbacks, cb); | ||
2153 | } | ||
2154 | |||
2155 | EAPI void * | ||
2156 | edje_object_text_insert_filter_callback_del(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func) | ||
2157 | { | ||
2158 | Edje *ed; | ||
2159 | Edje_Text_Insert_Filter_Callback *cb; | ||
2160 | Eina_List *l; | ||
2161 | |||
2162 | ed = _edje_fetch(obj); | ||
2163 | if ((!ed) || (!part)) return NULL; | ||
2164 | EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) | ||
2165 | { | ||
2166 | if ((!strcmp(cb->part, part)) && (cb->func == func)) | ||
2167 | { | ||
2168 | void *data = cb->data; | ||
2169 | ed->text_insert_filter_callbacks = | ||
2170 | eina_list_remove_list(ed->text_insert_filter_callbacks, l); | ||
2171 | eina_stringshare_del(cb->part); | ||
2172 | free(cb); | ||
2173 | return data; | ||
2174 | } | ||
2175 | } | ||
2176 | return NULL; | ||
2177 | } | ||
2178 | |||
2179 | EAPI void * | ||
2180 | edje_object_text_insert_filter_callback_del_full(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data) | ||
2181 | { | ||
2182 | Edje *ed; | ||
2183 | Edje_Text_Insert_Filter_Callback *cb; | ||
2184 | Eina_List *l; | ||
2185 | |||
2186 | ed = _edje_fetch(obj); | ||
2187 | if ((!ed) || (!part)) return NULL; | ||
2188 | EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) | ||
2189 | { | ||
2190 | if ((!strcmp(cb->part, part)) && (cb->func == func) && | ||
2191 | (cb->data == data)) | ||
2192 | { | ||
2193 | void *tmp = cb->data; | ||
2194 | ed->text_insert_filter_callbacks = | ||
2195 | eina_list_remove_list(ed->text_insert_filter_callbacks, l); | ||
2196 | eina_stringshare_del(cb->part); | ||
2197 | free(cb); | ||
2198 | return tmp; | ||
2199 | } | ||
2200 | } | ||
2201 | return NULL; | ||
2202 | } | ||
2203 | |||
2204 | EAPI void | ||
2205 | edje_object_text_markup_filter_callback_add(Evas_Object *obj, const char *part, Edje_Markup_Filter_Cb func, void *data) | ||
2206 | { | ||
2207 | Edje *ed; | ||
2208 | Edje_Markup_Filter_Callback *cb; | ||
2209 | |||
2210 | ed = _edje_fetch(obj); | ||
2211 | if ((!ed) || (!part)) return; | ||
2212 | cb = calloc(1, sizeof(Edje_Markup_Filter_Callback)); | ||
2213 | cb->part = eina_stringshare_add(part); | ||
2214 | cb->func = func; | ||
2215 | cb->data = (void *)data; | ||
2216 | ed->markup_filter_callbacks = | ||
2217 | eina_list_append(ed->markup_filter_callbacks, cb); | ||
2218 | } | ||
2219 | |||
2220 | EAPI void * | ||
2221 | edje_object_text_markup_filter_callback_del(Evas_Object *obj, const char *part, Edje_Markup_Filter_Cb func) | ||
2222 | { | ||
2223 | Edje *ed; | ||
2224 | Edje_Markup_Filter_Callback *cb; | ||
2225 | Eina_List *l; | ||
2226 | |||
2227 | ed = _edje_fetch(obj); | ||
2228 | if ((!ed) || (!part)) return NULL; | ||
2229 | EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) | ||
2230 | { | ||
2231 | if ((!strcmp(cb->part, part)) && (cb->func == func)) | ||
2232 | { | ||
2233 | void *data = cb->data; | ||
2234 | ed->markup_filter_callbacks = | ||
2235 | eina_list_remove_list(ed->markup_filter_callbacks, l); | ||
2236 | eina_stringshare_del(cb->part); | ||
2237 | free(cb); | ||
2238 | return data; | ||
2239 | } | ||
2240 | } | ||
2241 | return NULL; | ||
2242 | } | ||
2243 | |||
2244 | EAPI void * | ||
2245 | edje_object_text_markup_filter_callback_del_full(Evas_Object *obj, const char *part, Edje_Markup_Filter_Cb func, void *data) | ||
2246 | { | ||
2247 | Edje *ed; | ||
2248 | Edje_Markup_Filter_Callback *cb; | ||
2249 | Eina_List *l; | ||
2250 | |||
2251 | ed = _edje_fetch(obj); | ||
2252 | if ((!ed) || (!part)) return NULL; | ||
2253 | EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) | ||
2254 | { | ||
2255 | if ((!strcmp(cb->part, part)) && (cb->func == func) && | ||
2256 | (cb->data == data)) | ||
2257 | { | ||
2258 | void *tmp = cb->data; | ||
2259 | ed->markup_filter_callbacks = | ||
2260 | eina_list_remove_list(ed->markup_filter_callbacks, l); | ||
2261 | eina_stringshare_del(cb->part); | ||
2262 | free(cb); | ||
2263 | return tmp; | ||
2264 | } | ||
2265 | } | ||
2266 | return NULL; | ||
2267 | } | ||
2268 | |||
2269 | EAPI Eina_Bool | ||
2270 | edje_object_part_swallow(Evas_Object *obj, const char *part, Evas_Object *obj_swallow) | ||
2271 | { | ||
2272 | Edje *ed; | ||
2273 | Edje_Real_Part *rp; | ||
2274 | |||
2275 | ed = _edje_fetch(obj); | ||
2276 | if ((!ed) || (!part)) return EINA_FALSE; | ||
2277 | |||
2278 | /* Need to recalc before providing the object. */ | ||
2279 | // XXX: I guess this is not required, removing for testing purposes | ||
2280 | // XXX: uncomment if you see glitches in e17 or others. | ||
2281 | // XXX: by Gustavo, January 21th 2009. | ||
2282 | // XXX: I got a backtrace with over 30000 calls without this, | ||
2283 | // XXX: only with 32px shelves. The problem is probably somewhere else, | ||
2284 | // XXX: but until it's found, leave this here. | ||
2285 | // XXX: by Sachiel, January 21th 2009, 19:30 UTC | ||
2286 | _edje_recalc_do(ed); | ||
2287 | |||
2288 | rp = evas_object_data_get(obj_swallow, "\377 edje.swallowing_part"); | ||
2289 | if (rp) | ||
2290 | { | ||
2291 | /* The object is already swallowed somewhere, unswallow it first */ | ||
2292 | edje_object_part_unswallow(rp->edje->obj, obj_swallow); | ||
2293 | } | ||
2294 | |||
2295 | rp = _edje_real_part_recursive_get(ed, part); | ||
2296 | if (!rp) | ||
2297 | { | ||
2298 | DBG("cannot swallow part %s: part not exist!", part); | ||
2299 | return EINA_FALSE; | ||
2300 | } | ||
2301 | if (rp->part->type != EDJE_PART_TYPE_SWALLOW) | ||
2302 | { | ||
2303 | ERR("cannot swallow part %s: not swallow type!", rp->part->name); | ||
2304 | return EINA_FALSE; | ||
2305 | } | ||
2306 | _edje_real_part_swallow(rp, obj_swallow, EINA_TRUE); | ||
2307 | return EINA_TRUE; | ||
2308 | } | ||
2309 | |||
2310 | static void | ||
2311 | _recalc_extern_parent(Evas_Object *obj) | ||
2312 | { | ||
2313 | Evas_Object *parent; | ||
2314 | Edje *ed; | ||
2315 | |||
2316 | parent = evas_object_smart_parent_get(obj); | ||
2317 | ed = _edje_fetch(parent); | ||
2318 | |||
2319 | ed->dirty = 1; | ||
2320 | ed->recalc_call = 1; // ZZZ: ??? | ||
2321 | _edje_recalc(ed); | ||
2322 | } | ||
2323 | |||
2324 | EAPI void | ||
2325 | edje_extern_object_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) | ||
2326 | { | ||
2327 | Edje_Real_Part *rp; | ||
2328 | |||
2329 | evas_object_size_hint_min_set(obj, minw, minh); | ||
2330 | rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); | ||
2331 | if (rp) | ||
2332 | { | ||
2333 | rp->swallow_params.min.w = minw; | ||
2334 | rp->swallow_params.min.h = minh; | ||
2335 | |||
2336 | _recalc_extern_parent(obj); | ||
2337 | } | ||
2338 | } | ||
2339 | |||
2340 | EAPI void | ||
2341 | edje_extern_object_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh) | ||
2342 | { | ||
2343 | Edje_Real_Part *rp; | ||
2344 | |||
2345 | evas_object_size_hint_max_set(obj, maxw, maxh); | ||
2346 | rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); | ||
2347 | if (rp) | ||
2348 | { | ||
2349 | rp->swallow_params.max.w = maxw; | ||
2350 | rp->swallow_params.max.h = maxh; | ||
2351 | |||
2352 | _recalc_extern_parent(obj); | ||
2353 | } | ||
2354 | } | ||
2355 | |||
2356 | EAPI void | ||
2357 | edje_extern_object_aspect_set(Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah) | ||
2358 | { | ||
2359 | Edje_Real_Part *rp; | ||
2360 | Evas_Aspect_Control asp; | ||
2361 | |||
2362 | asp = EVAS_ASPECT_CONTROL_NONE; | ||
2363 | switch (aspect) | ||
2364 | { | ||
2365 | case EDJE_ASPECT_CONTROL_NONE: asp = EVAS_ASPECT_CONTROL_NONE; break; | ||
2366 | case EDJE_ASPECT_CONTROL_NEITHER: asp = EVAS_ASPECT_CONTROL_NEITHER; break; | ||
2367 | case EDJE_ASPECT_CONTROL_HORIZONTAL: asp = EVAS_ASPECT_CONTROL_HORIZONTAL; break; | ||
2368 | case EDJE_ASPECT_CONTROL_VERTICAL: asp = EVAS_ASPECT_CONTROL_VERTICAL; break; | ||
2369 | case EDJE_ASPECT_CONTROL_BOTH: asp = EVAS_ASPECT_CONTROL_BOTH; break; | ||
2370 | default: break; | ||
2371 | } | ||
2372 | if (aw < 1) aw = 1; | ||
2373 | if (ah < 1) ah = 1; | ||
2374 | evas_object_size_hint_aspect_set(obj, asp, aw, ah); | ||
2375 | rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); | ||
2376 | if (rp) | ||
2377 | { | ||
2378 | rp->swallow_params.aspect.mode = aspect; | ||
2379 | rp->swallow_params.aspect.w = aw; | ||
2380 | rp->swallow_params.aspect.h = ah; | ||
2381 | _recalc_extern_parent(obj); | ||
2382 | } | ||
2383 | } | ||
2384 | |||
2385 | struct edje_box_layout_builtin { | ||
2386 | const char *name; | ||
2387 | Evas_Object_Box_Layout cb; | ||
2388 | }; | ||
2389 | |||
2390 | static Evas_Object_Box_Layout | ||
2391 | _edje_box_layout_builtin_find(const char *name) | ||
2392 | { | ||
2393 | const struct edje_box_layout_builtin _edje_box_layout_builtin[] = { | ||
2394 | {"horizontal", evas_object_box_layout_horizontal}, | ||
2395 | {"horizontal_flow", evas_object_box_layout_flow_horizontal}, | ||
2396 | {"horizontal_homogeneous", evas_object_box_layout_homogeneous_horizontal}, | ||
2397 | {"horizontal_max", evas_object_box_layout_homogeneous_max_size_horizontal}, | ||
2398 | {"stack", evas_object_box_layout_stack}, | ||
2399 | {"vertical", evas_object_box_layout_vertical}, | ||
2400 | {"vertical_flow", evas_object_box_layout_flow_vertical}, | ||
2401 | {"vertical_homogeneous", evas_object_box_layout_homogeneous_vertical}, | ||
2402 | {"vertical_max", evas_object_box_layout_homogeneous_max_size_vertical}, | ||
2403 | {NULL, NULL} | ||
2404 | }; | ||
2405 | const struct edje_box_layout_builtin *base; | ||
2406 | |||
2407 | switch (name[0]) | ||
2408 | { | ||
2409 | case 'h': | ||
2410 | base = _edje_box_layout_builtin + 0; | ||
2411 | break; | ||
2412 | case 's': | ||
2413 | base = _edje_box_layout_builtin + 4; | ||
2414 | break; | ||
2415 | case 'v': | ||
2416 | base = _edje_box_layout_builtin + 5; | ||
2417 | break; | ||
2418 | default: | ||
2419 | return NULL; | ||
2420 | } | ||
2421 | |||
2422 | for (; (base->name) && (base->name[0] == name[0]); base++) | ||
2423 | if (strcmp(base->name, name) == 0) | ||
2424 | return base->cb; | ||
2425 | |||
2426 | return NULL; | ||
2427 | } | ||
2428 | |||
2429 | static Eina_Rbtree_Direction | ||
2430 | _edje_box_layout_external_node_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data) | ||
2431 | { | ||
2432 | Edje_Box_Layout *l = (Edje_Box_Layout *)left; | ||
2433 | Edje_Box_Layout *r = (Edje_Box_Layout *)right; | ||
2434 | |||
2435 | if (strcmp(l->name, r->name) < 0) | ||
2436 | return EINA_RBTREE_RIGHT; | ||
2437 | else | ||
2438 | return EINA_RBTREE_LEFT; | ||
2439 | } | ||
2440 | |||
2441 | static int | ||
2442 | _edje_box_layout_external_find_cmp(const Eina_Rbtree *node, const void *key, __UNUSED__ int length, __UNUSED__ void *data) | ||
2443 | { | ||
2444 | Edje_Box_Layout *l = (Edje_Box_Layout *)node; | ||
2445 | return strcmp(key, l->name); | ||
2446 | } | ||
2447 | |||
2448 | static Edje_Box_Layout * | ||
2449 | _edje_box_layout_external_find(const char *name) | ||
2450 | { | ||
2451 | return (Edje_Box_Layout *)eina_rbtree_inline_lookup | ||
2452 | (_edje_box_layout_registry, name, 0, _edje_box_layout_external_find_cmp, | ||
2453 | NULL); | ||
2454 | } | ||
2455 | |||
2456 | Eina_Bool | ||
2457 | _edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data)) | ||
2458 | { | ||
2459 | const Edje_Box_Layout *l; | ||
2460 | |||
2461 | if (!name) return EINA_FALSE; | ||
2462 | |||
2463 | *cb = _edje_box_layout_builtin_find(name); | ||
2464 | if (*cb) | ||
2465 | { | ||
2466 | *free_data = NULL; | ||
2467 | *data = NULL; | ||
2468 | return EINA_TRUE; | ||
2469 | } | ||
2470 | |||
2471 | l = _edje_box_layout_external_find(name); | ||
2472 | if (!l) return EINA_FALSE; | ||
2473 | |||
2474 | *cb = l->func; | ||
2475 | *free_data = l->layout_data_free; | ||
2476 | if (l->layout_data_get) | ||
2477 | *data = l->layout_data_get(l->data); | ||
2478 | else | ||
2479 | *data = NULL; | ||
2480 | |||
2481 | return EINA_TRUE; | ||
2482 | } | ||
2483 | |||
2484 | static void | ||
2485 | _edje_box_layout_external_free(Eina_Rbtree *node, __UNUSED__ void *data) | ||
2486 | { | ||
2487 | Edje_Box_Layout *l = (Edje_Box_Layout *)node; | ||
2488 | |||
2489 | if (l->data && l->free_data) | ||
2490 | l->free_data(l->data); | ||
2491 | free(l); | ||
2492 | } | ||
2493 | |||
2494 | static Edje_Box_Layout * | ||
2495 | _edje_box_layout_external_new(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data) | ||
2496 | { | ||
2497 | Edje_Box_Layout *l; | ||
2498 | size_t name_len; | ||
2499 | |||
2500 | name_len = strlen(name) + 1; | ||
2501 | l = malloc(sizeof(Edje_Box_Layout) + name_len); | ||
2502 | if (!l) return NULL; | ||
2503 | |||
2504 | l->func = func; | ||
2505 | l->layout_data_get = layout_data_get; | ||
2506 | l->layout_data_free = layout_data_free; | ||
2507 | l->free_data = free_data; | ||
2508 | l->data = data; | ||
2509 | |||
2510 | memcpy(l->name, name, name_len); | ||
2511 | |||
2512 | return l; | ||
2513 | } | ||
2514 | |||
2515 | EAPI void | ||
2516 | edje_box_layout_register(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data) | ||
2517 | { | ||
2518 | Edje_Box_Layout *l; | ||
2519 | |||
2520 | if (!name) return; | ||
2521 | |||
2522 | if (_edje_box_layout_builtin_find(name)) | ||
2523 | { | ||
2524 | ERR("Cannot register layout '%s': would override builtin!", | ||
2525 | name); | ||
2526 | |||
2527 | if (data && free_data) free_data(data); | ||
2528 | return; | ||
2529 | } | ||
2530 | |||
2531 | l = _edje_box_layout_external_find(name); | ||
2532 | if (!l) | ||
2533 | { | ||
2534 | if (!func) | ||
2535 | { | ||
2536 | if (data && free_data) free_data(data); | ||
2537 | return; | ||
2538 | } | ||
2539 | |||
2540 | l = _edje_box_layout_external_new | ||
2541 | (name, func, layout_data_get, layout_data_free, free_data, data); | ||
2542 | if (!l) | ||
2543 | return; | ||
2544 | |||
2545 | _edje_box_layout_registry = eina_rbtree_inline_insert | ||
2546 | (_edje_box_layout_registry, (Eina_Rbtree *)l, | ||
2547 | _edje_box_layout_external_node_cmp, NULL); | ||
2548 | } | ||
2549 | else | ||
2550 | { | ||
2551 | if (func) | ||
2552 | { | ||
2553 | if (l->data && l->free_data) l->free_data(l->data); | ||
2554 | |||
2555 | l->func = func; | ||
2556 | l->layout_data_get = layout_data_get; | ||
2557 | l->layout_data_free = layout_data_free; | ||
2558 | l->free_data = free_data; | ||
2559 | l->data = data; | ||
2560 | } | ||
2561 | else | ||
2562 | { | ||
2563 | if (data && free_data) free_data(data); | ||
2564 | |||
2565 | _edje_box_layout_registry = eina_rbtree_inline_remove | ||
2566 | (_edje_box_layout_registry, (Eina_Rbtree *)l, | ||
2567 | _edje_box_layout_external_node_cmp, NULL); | ||
2568 | _edje_box_layout_external_free((Eina_Rbtree *)l, NULL); | ||
2569 | } | ||
2570 | } | ||
2571 | } | ||
2572 | |||
2573 | EAPI void | ||
2574 | edje_object_part_unswallow(Evas_Object *obj __UNUSED__, Evas_Object *obj_swallow) | ||
2575 | { | ||
2576 | Edje_Real_Part *rp; | ||
2577 | |||
2578 | if (!obj_swallow) return; | ||
2579 | |||
2580 | rp = (Edje_Real_Part *)evas_object_data_get(obj_swallow, "\377 edje.swallowing_part"); | ||
2581 | if (!rp) | ||
2582 | return; | ||
2583 | if (rp->part->type != EDJE_PART_TYPE_SWALLOW) | ||
2584 | { | ||
2585 | ERR("cannot unswallow part %s: not swallow type!", rp->part->name); | ||
2586 | return; | ||
2587 | } | ||
2588 | if (rp->swallowed_object == obj_swallow) | ||
2589 | { | ||
2590 | evas_object_smart_member_del(rp->swallowed_object); | ||
2591 | evas_object_event_callback_del_full(rp->swallowed_object, | ||
2592 | EVAS_CALLBACK_FREE, | ||
2593 | _edje_object_part_swallow_free_cb, | ||
2594 | rp->edje->obj); | ||
2595 | evas_object_event_callback_del_full(rp->swallowed_object, | ||
2596 | EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
2597 | _edje_object_part_swallow_changed_hints_cb, | ||
2598 | rp); | ||
2599 | evas_object_clip_unset(rp->swallowed_object); | ||
2600 | evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); | ||
2601 | |||
2602 | if (rp->part->mouse_events) | ||
2603 | _edje_callbacks_del(rp->swallowed_object, rp->edje); | ||
2604 | _edje_callbacks_focus_del(rp->swallowed_object, rp->edje); | ||
2605 | |||
2606 | rp->swallowed_object = NULL; | ||
2607 | rp->swallow_params.min.w = 0; | ||
2608 | rp->swallow_params.min.h = 0; | ||
2609 | rp->swallow_params.max.w = 0; | ||
2610 | rp->swallow_params.max.h = 0; | ||
2611 | rp->edje->dirty = 1; | ||
2612 | rp->edje->recalc_call = 1; | ||
2613 | #ifdef EDJE_CALC_CACHE | ||
2614 | rp->invalidate = 1; | ||
2615 | #endif | ||
2616 | _edje_recalc_do(rp->edje); | ||
2617 | return; | ||
2618 | } | ||
2619 | } | ||
2620 | |||
2621 | EAPI Evas_Object * | ||
2622 | edje_object_part_swallow_get(const Evas_Object *obj, const char *part) | ||
2623 | { | ||
2624 | Edje *ed; | ||
2625 | Edje_Real_Part *rp; | ||
2626 | |||
2627 | ed = _edje_fetch(obj); | ||
2628 | if ((!ed) || (!part)) return NULL; | ||
2629 | |||
2630 | /* Need to recalc before providing the object. */ | ||
2631 | _edje_recalc_do(ed); | ||
2632 | |||
2633 | rp = _edje_real_part_recursive_get(ed, part); | ||
2634 | if (!rp) return NULL; | ||
2635 | return rp->swallowed_object; | ||
2636 | } | ||
2637 | |||
2638 | EAPI void | ||
2639 | edje_object_size_min_get(const Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) | ||
2640 | { | ||
2641 | Edje *ed; | ||
2642 | |||
2643 | ed = _edje_fetch(obj); | ||
2644 | if ((!ed) || (!ed->collection)) | ||
2645 | { | ||
2646 | if (minw) *minw = 0; | ||
2647 | if (minh) *minh = 0; | ||
2648 | return; | ||
2649 | } | ||
2650 | if (minw) *minw = ed->collection->prop.min.w; | ||
2651 | if (minh) *minh = ed->collection->prop.min.h; | ||
2652 | } | ||
2653 | |||
2654 | EAPI void | ||
2655 | edje_object_size_max_get(const Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh) | ||
2656 | { | ||
2657 | Edje *ed; | ||
2658 | |||
2659 | ed = _edje_fetch(obj); | ||
2660 | if ((!ed) || (!ed->collection)) | ||
2661 | { | ||
2662 | if (maxw) *maxw = 0; | ||
2663 | if (maxh) *maxh = 0; | ||
2664 | return; | ||
2665 | } | ||
2666 | |||
2667 | /* Need to recalc before providing the object. */ | ||
2668 | _edje_recalc_do(ed); | ||
2669 | |||
2670 | if (ed->collection->prop.max.w == 0) | ||
2671 | { | ||
2672 | /* XXX TODO: convert maxw to 0, fix things that break. */ | ||
2673 | if (maxw) *maxw = EDJE_INF_MAX_W; | ||
2674 | } | ||
2675 | else | ||
2676 | { | ||
2677 | if (maxw) *maxw = ed->collection->prop.max.w; | ||
2678 | } | ||
2679 | if (ed->collection->prop.max.h == 0) | ||
2680 | { | ||
2681 | /* XXX TODO: convert maxh to 0, fix things that break. */ | ||
2682 | if (maxh) *maxh = EDJE_INF_MAX_H; | ||
2683 | } | ||
2684 | else | ||
2685 | { | ||
2686 | if (maxh) *maxh = ed->collection->prop.max.h; | ||
2687 | } | ||
2688 | } | ||
2689 | |||
2690 | EAPI void | ||
2691 | edje_object_calc_force(Evas_Object *obj) | ||
2692 | { | ||
2693 | Edje *ed; | ||
2694 | int pf, pf2; | ||
2695 | |||
2696 | ed = _edje_fetch(obj); | ||
2697 | if (!ed) return; | ||
2698 | ed->dirty = 1; | ||
2699 | #ifdef EDJE_CALC_CACHE | ||
2700 | ed->all_part_change = 1; | ||
2701 | #endif | ||
2702 | |||
2703 | pf2 = _edje_freeze_val; | ||
2704 | pf = ed->freeze; | ||
2705 | |||
2706 | _edje_freeze_val = 0; | ||
2707 | ed->freeze = 0; | ||
2708 | |||
2709 | _edje_recalc_do(ed); | ||
2710 | |||
2711 | ed->freeze = pf; | ||
2712 | _edje_freeze_val = pf2; | ||
2713 | } | ||
2714 | |||
2715 | EAPI void | ||
2716 | edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) | ||
2717 | { | ||
2718 | edje_object_size_min_restricted_calc(obj, minw, minh, 0, 0); | ||
2719 | } | ||
2720 | |||
2721 | EAPI Eina_Bool | ||
2722 | edje_object_parts_extends_calc(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) | ||
2723 | { | ||
2724 | Edje *ed; | ||
2725 | Evas_Coord xx1 = INT_MAX, yy1 = INT_MAX; | ||
2726 | Evas_Coord xx2 = 0, yy2 = 0; | ||
2727 | unsigned int i; | ||
2728 | |||
2729 | ed = _edje_fetch(obj); | ||
2730 | if (!ed) | ||
2731 | { | ||
2732 | if (x) *x = 0; | ||
2733 | if (y) *y = 0; | ||
2734 | if (w) *w = 0; | ||
2735 | if (h) *h = 0; | ||
2736 | return EINA_FALSE; | ||
2737 | } | ||
2738 | |||
2739 | ed->calc_only = 1; | ||
2740 | |||
2741 | /* Need to recalc before providing the object. */ | ||
2742 | ed->dirty = 1; | ||
2743 | _edje_recalc_do(ed); | ||
2744 | |||
2745 | for (i = 0; i < ed->table_parts_size; i++) | ||
2746 | { | ||
2747 | Edje_Real_Part *rp; | ||
2748 | Evas_Coord rpx1, rpy1; | ||
2749 | Evas_Coord rpx2, rpy2; | ||
2750 | |||
2751 | rp = ed->table_parts[i]; | ||
2752 | |||
2753 | rpx1 = rp->x; | ||
2754 | rpy1 = rp->y; | ||
2755 | rpx2 = rpx1 + rp->w; | ||
2756 | rpy2 = rpy1 + rp->h; | ||
2757 | |||
2758 | if (xx1 > rpx1) xx1 = rpx1; | ||
2759 | if (yy1 > rpy1) yy1 = rpy1; | ||
2760 | if (xx2 < rpx2) xx2 = rpx2; | ||
2761 | if (yy2 < rpy2) yy2 = rpy2; | ||
2762 | } | ||
2763 | |||
2764 | ed->calc_only = 0; | ||
2765 | |||
2766 | if (x) *x = xx1; | ||
2767 | if (y) *y = yy1; | ||
2768 | if (w) *w = xx2 - xx1; | ||
2769 | if (h) *h = yy2 - yy1; | ||
2770 | |||
2771 | return EINA_TRUE; | ||
2772 | } | ||
2773 | |||
2774 | EAPI void | ||
2775 | edje_object_size_min_restricted_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord restrictedw, Evas_Coord restrictedh) | ||
2776 | { | ||
2777 | Edje *ed; | ||
2778 | Evas_Coord pw, ph; | ||
2779 | int maxw, maxh; | ||
2780 | int okw, okh; | ||
2781 | int reset_maxwh; | ||
2782 | Edje_Real_Part *pep = NULL; | ||
2783 | Eina_Bool has_non_fixed_tb = EINA_FALSE; | ||
2784 | |||
2785 | ed = _edje_fetch(obj); | ||
2786 | if ((!ed) || (!ed->collection)) | ||
2787 | { | ||
2788 | if (minw) *minw = restrictedw; | ||
2789 | if (minh) *minh = restrictedh; | ||
2790 | return; | ||
2791 | } | ||
2792 | reset_maxwh = 1; | ||
2793 | ed->calc_only = 1; | ||
2794 | pw = ed->w; | ||
2795 | ph = ed->h; | ||
2796 | |||
2797 | again: | ||
2798 | ed->w = restrictedw; | ||
2799 | ed->h = restrictedh; | ||
2800 | |||
2801 | maxw = 0; | ||
2802 | maxh = 0; | ||
2803 | |||
2804 | do | ||
2805 | { | ||
2806 | unsigned int i; | ||
2807 | |||
2808 | okw = okh = 0; | ||
2809 | ed->dirty = 1; | ||
2810 | #ifdef EDJE_CALC_CACHE | ||
2811 | ed->all_part_change = 1; | ||
2812 | #endif | ||
2813 | _edje_recalc_do(ed); | ||
2814 | if (reset_maxwh) | ||
2815 | { | ||
2816 | maxw = 0; | ||
2817 | maxh = 0; | ||
2818 | } | ||
2819 | pep = NULL; | ||
2820 | has_non_fixed_tb = EINA_FALSE; | ||
2821 | for (i = 0; i < ed->table_parts_size; i++) | ||
2822 | { | ||
2823 | Edje_Real_Part *ep; | ||
2824 | int w, h; | ||
2825 | int didw; | ||
2826 | |||
2827 | ep = ed->table_parts[i]; | ||
2828 | w = ep->w - ep->req.w; | ||
2829 | h = ep->h - ep->req.h; | ||
2830 | didw = 0; | ||
2831 | if (ep->chosen_description) | ||
2832 | { | ||
2833 | if (!ep->chosen_description->fixed.w) | ||
2834 | { | ||
2835 | if ((ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)) | ||
2836 | { | ||
2837 | Evas_Coord tb_mw; | ||
2838 | evas_object_textblock_size_formatted_get(ep->object, | ||
2839 | &tb_mw, NULL); | ||
2840 | tb_mw -= ep->req.w; | ||
2841 | if (tb_mw > w) | ||
2842 | { | ||
2843 | w = tb_mw; | ||
2844 | } | ||
2845 | has_non_fixed_tb = EINA_TRUE; | ||
2846 | } | ||
2847 | if (w > maxw) | ||
2848 | { | ||
2849 | maxw = w; | ||
2850 | okw = 1; | ||
2851 | pep = ep; | ||
2852 | didw = 1; | ||
2853 | } | ||
2854 | } | ||
2855 | if (!ep->chosen_description->fixed.h) | ||
2856 | { | ||
2857 | if (!((ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && | ||
2858 | (!((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x) && | ||
2859 | (didw))) | ||
2860 | { | ||
2861 | if (h > maxh) | ||
2862 | { | ||
2863 | maxh = h; | ||
2864 | okh = 1; | ||
2865 | pep = ep; | ||
2866 | } | ||
2867 | } | ||
2868 | |||
2869 | if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) | ||
2870 | { | ||
2871 | has_non_fixed_tb = EINA_TRUE; | ||
2872 | } | ||
2873 | } | ||
2874 | } | ||
2875 | } | ||
2876 | if (okw) | ||
2877 | { | ||
2878 | ed->w += maxw; | ||
2879 | if (ed->w < restrictedw) ed->w = restrictedw; | ||
2880 | } | ||
2881 | if (okh) | ||
2882 | { | ||
2883 | ed->h += maxh; | ||
2884 | if (ed->h < restrictedh) ed->h = restrictedh; | ||
2885 | } | ||
2886 | if ((ed->w > 4000) || (ed->h > 4000)) | ||
2887 | { | ||
2888 | /* Only print it if we have a non-fixed textblock. | ||
2889 | * We should possibly avoid all of this if in this case, but in | ||
2890 | * the meanwhile, just doing this. */ | ||
2891 | if (!has_non_fixed_tb) | ||
2892 | { | ||
2893 | if (pep) | ||
2894 | ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.", | ||
2895 | ed->path, ed->group, pep->part->name); | ||
2896 | else | ||
2897 | ERR("file %s, group %s overflowed 4000x4000 with minimum size of %dx%d. Continuing discarding faulty parts.", | ||
2898 | ed->path, ed->group, ed->w, ed->h); | ||
2899 | } | ||
2900 | |||
2901 | if (reset_maxwh) | ||
2902 | { | ||
2903 | reset_maxwh = 0; | ||
2904 | goto again; | ||
2905 | } | ||
2906 | } | ||
2907 | } | ||
2908 | while (okw || okh); | ||
2909 | ed->min.w = ed->w; | ||
2910 | ed->min.h = ed->h; | ||
2911 | |||
2912 | if (minw) *minw = ed->min.w; | ||
2913 | if (minh) *minh = ed->min.h; | ||
2914 | |||
2915 | ed->w = pw; | ||
2916 | ed->h = ph; | ||
2917 | ed->dirty = 1; | ||
2918 | #ifdef EDJE_CALC_CACHE | ||
2919 | ed->all_part_change = 1; | ||
2920 | #endif | ||
2921 | _edje_recalc(ed); | ||
2922 | ed->calc_only = 0; | ||
2923 | } | ||
2924 | |||
2925 | /* FIXME: Correctly return other states */ | ||
2926 | EAPI const char * | ||
2927 | edje_object_part_state_get(const Evas_Object *obj, const char *part, double *val_ret) | ||
2928 | { | ||
2929 | Edje *ed; | ||
2930 | Edje_Real_Part *rp; | ||
2931 | |||
2932 | ed = _edje_fetch(obj); | ||
2933 | if ((!ed) || (!part)) | ||
2934 | { | ||
2935 | if (val_ret) *val_ret = 0; | ||
2936 | return ""; | ||
2937 | } | ||
2938 | |||
2939 | /* Need to recalc before providing the object. */ | ||
2940 | _edje_recalc_do(ed); | ||
2941 | |||
2942 | rp = _edje_real_part_recursive_get(ed, part); | ||
2943 | if (!rp) | ||
2944 | { | ||
2945 | if (val_ret) *val_ret = 0; | ||
2946 | INF("part not found"); | ||
2947 | return ""; | ||
2948 | } | ||
2949 | if (rp->chosen_description) | ||
2950 | { | ||
2951 | if (val_ret) *val_ret = rp->chosen_description->state.value; | ||
2952 | if (rp->chosen_description->state.name) | ||
2953 | return rp->chosen_description->state.name; | ||
2954 | return "default"; | ||
2955 | } | ||
2956 | else | ||
2957 | { | ||
2958 | if (rp->param1.description) | ||
2959 | { | ||
2960 | if (val_ret) *val_ret = rp->param1.description->state.value; | ||
2961 | if (rp->param1.description->state.name) | ||
2962 | return rp->param1.description->state.name; | ||
2963 | return "default"; | ||
2964 | } | ||
2965 | } | ||
2966 | if (val_ret) *val_ret = 0; | ||
2967 | return ""; | ||
2968 | } | ||
2969 | |||
2970 | EAPI Edje_Drag_Dir | ||
2971 | edje_object_part_drag_dir_get(const Evas_Object *obj, const char *part) | ||
2972 | { | ||
2973 | Edje *ed; | ||
2974 | Edje_Real_Part *rp; | ||
2975 | |||
2976 | ed = _edje_fetch(obj); | ||
2977 | if ((!ed) || (!part)) return EDJE_DRAG_DIR_NONE; | ||
2978 | |||
2979 | /* Need to recalc before providing the object. */ | ||
2980 | _edje_recalc_do(ed); | ||
2981 | |||
2982 | rp = _edje_real_part_recursive_get(ed, part); | ||
2983 | if (!rp) return EDJE_DRAG_DIR_NONE; | ||
2984 | if ((rp->part->dragable.x) && (rp->part->dragable.y)) return EDJE_DRAG_DIR_XY; | ||
2985 | else if (rp->part->dragable.x) return EDJE_DRAG_DIR_X; | ||
2986 | else if (rp->part->dragable.y) return EDJE_DRAG_DIR_Y; | ||
2987 | return EDJE_DRAG_DIR_NONE; | ||
2988 | } | ||
2989 | |||
2990 | EAPI Eina_Bool | ||
2991 | edje_object_part_drag_value_set(Evas_Object *obj, const char *part, double dx, double dy) | ||
2992 | { | ||
2993 | Edje *ed; | ||
2994 | Edje_Real_Part *rp; | ||
2995 | |||
2996 | ed = _edje_fetch(obj); | ||
2997 | if ((!ed) || (!part)) return EINA_FALSE; | ||
2998 | rp = _edje_real_part_recursive_get(ed, part); | ||
2999 | if (!rp) return EINA_FALSE; | ||
3000 | if (!rp->drag) return EINA_FALSE; | ||
3001 | if (rp->drag->down.count > 0) return EINA_FALSE; | ||
3002 | if (rp->part->dragable.confine_id != -1) | ||
3003 | { | ||
3004 | dx = CLAMP(dx, 0.0, 1.0); | ||
3005 | dy = CLAMP(dy, 0.0, 1.0); | ||
3006 | } | ||
3007 | if (rp->part->dragable.x < 0) dx = 1.0 - dx; | ||
3008 | if (rp->part->dragable.y < 0) dy = 1.0 - dy; | ||
3009 | if ((rp->drag->val.x == FROM_DOUBLE(dx)) && (rp->drag->val.y == FROM_DOUBLE(dy))) return EINA_TRUE; | ||
3010 | rp->drag->val.x = FROM_DOUBLE(dx); | ||
3011 | rp->drag->val.y = FROM_DOUBLE(dy); | ||
3012 | #ifdef EDJE_CALC_CACHE | ||
3013 | rp->invalidate = 1; | ||
3014 | #endif | ||
3015 | _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y); | ||
3016 | _edje_emit(rp->edje, "drag,set", rp->part->name); | ||
3017 | return EINA_TRUE; | ||
3018 | } | ||
3019 | |||
3020 | /* FIXME: Should this be x and y instead of dx/dy? */ | ||
3021 | EAPI Eina_Bool | ||
3022 | edje_object_part_drag_value_get(const Evas_Object *obj, const char *part, double *dx, double *dy) | ||
3023 | { | ||
3024 | Edje *ed; | ||
3025 | Edje_Real_Part *rp; | ||
3026 | double ddx, ddy; | ||
3027 | |||
3028 | ed = _edje_fetch(obj); | ||
3029 | if ((!ed) || (!part)) | ||
3030 | { | ||
3031 | if (dx) *dx = 0; | ||
3032 | if (dy) *dy = 0; | ||
3033 | return EINA_FALSE; | ||
3034 | } | ||
3035 | |||
3036 | /* Need to recalc before providing the object. */ | ||
3037 | _edje_recalc_do(ed); | ||
3038 | |||
3039 | rp = _edje_real_part_recursive_get(ed, part); | ||
3040 | if (!rp || !rp->drag) | ||
3041 | { | ||
3042 | if (dx) *dx = 0; | ||
3043 | if (dy) *dy = 0; | ||
3044 | return EINA_FALSE; | ||
3045 | } | ||
3046 | ddx = TO_DOUBLE(rp->drag->val.x); | ||
3047 | ddy = TO_DOUBLE(rp->drag->val.y); | ||
3048 | if (rp->part->dragable.x < 0) ddx = 1.0 - ddx; | ||
3049 | if (rp->part->dragable.y < 0) ddy = 1.0 - ddy; | ||
3050 | if (dx) *dx = ddx; | ||
3051 | if (dy) *dy = ddy; | ||
3052 | return EINA_TRUE; | ||
3053 | } | ||
3054 | |||
3055 | EAPI Eina_Bool | ||
3056 | edje_object_part_drag_size_set(Evas_Object *obj, const char *part, double dw, double dh) | ||
3057 | { | ||
3058 | Edje *ed; | ||
3059 | Edje_Real_Part *rp; | ||
3060 | |||
3061 | ed = _edje_fetch(obj); | ||
3062 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3063 | rp = _edje_real_part_recursive_get(ed, part); | ||
3064 | if (!rp) return EINA_FALSE; | ||
3065 | if (!rp->drag) return EINA_FALSE; | ||
3066 | if (dw < 0.0) dw = 0.0; | ||
3067 | else if (dw > 1.0) dw = 1.0; | ||
3068 | if (dh < 0.0) dh = 0.0; | ||
3069 | else if (dh > 1.0) dh = 1.0; | ||
3070 | if ((rp->drag->size.x == FROM_DOUBLE(dw)) && (rp->drag->size.y == FROM_DOUBLE(dh))) return EINA_TRUE; | ||
3071 | rp->drag->size.x = FROM_DOUBLE(dw); | ||
3072 | rp->drag->size.y = FROM_DOUBLE(dh); | ||
3073 | rp->edje->dirty = 1; | ||
3074 | rp->edje->recalc_call = 1; | ||
3075 | #ifdef EDJE_CALC_CACHE | ||
3076 | rp->invalidate = 1; | ||
3077 | #endif | ||
3078 | _edje_recalc(rp->edje); | ||
3079 | return EINA_TRUE; | ||
3080 | } | ||
3081 | |||
3082 | EAPI Eina_Bool | ||
3083 | edje_object_part_drag_size_get(const Evas_Object *obj, const char *part, double *dw, double *dh) | ||
3084 | { | ||
3085 | Edje *ed; | ||
3086 | Edje_Real_Part *rp; | ||
3087 | |||
3088 | ed = _edje_fetch(obj); | ||
3089 | if ((!ed) || (!part)) | ||
3090 | { | ||
3091 | if (dw) *dw = 0; | ||
3092 | if (dh) *dh = 0; | ||
3093 | return EINA_FALSE; | ||
3094 | } | ||
3095 | |||
3096 | /* Need to recalc before providing the object. */ | ||
3097 | _edje_recalc_do(ed); | ||
3098 | |||
3099 | rp = _edje_real_part_recursive_get(ed, part); | ||
3100 | if (!rp || !rp->drag) | ||
3101 | { | ||
3102 | if (dw) *dw = 0; | ||
3103 | if (dh) *dh = 0; | ||
3104 | return EINA_FALSE; | ||
3105 | } | ||
3106 | if (dw) *dw = TO_DOUBLE(rp->drag->size.x); | ||
3107 | if (dh) *dh = TO_DOUBLE(rp->drag->size.y); | ||
3108 | return EINA_TRUE; | ||
3109 | } | ||
3110 | |||
3111 | EAPI Eina_Bool | ||
3112 | edje_object_part_drag_step_set(Evas_Object *obj, const char *part, double dx, double dy) | ||
3113 | { | ||
3114 | Edje *ed; | ||
3115 | Edje_Real_Part *rp; | ||
3116 | |||
3117 | ed = _edje_fetch(obj); | ||
3118 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3119 | rp = _edje_real_part_recursive_get(ed, part); | ||
3120 | if (!rp) return EINA_FALSE; | ||
3121 | if (!rp->drag) return EINA_FALSE; | ||
3122 | if (dx < 0.0) dx = 0.0; | ||
3123 | else if (dx > 1.0) dx = 1.0; | ||
3124 | if (dy < 0.0) dy = 0.0; | ||
3125 | else if (dy > 1.0) dy = 1.0; | ||
3126 | rp->drag->step.x = FROM_DOUBLE(dx); | ||
3127 | rp->drag->step.y = FROM_DOUBLE(dy); | ||
3128 | #ifdef EDJE_CALC_CACHE | ||
3129 | rp->invalidate = 1; | ||
3130 | #endif | ||
3131 | return EINA_TRUE; | ||
3132 | } | ||
3133 | |||
3134 | EAPI Eina_Bool | ||
3135 | edje_object_part_drag_step_get(const Evas_Object *obj, const char *part, double *dx, double *dy) | ||
3136 | { | ||
3137 | Edje *ed; | ||
3138 | Edje_Real_Part *rp; | ||
3139 | |||
3140 | ed = _edje_fetch(obj); | ||
3141 | if ((!ed) || (!part)) | ||
3142 | { | ||
3143 | if (dx) *dx = 0; | ||
3144 | if (dy) *dy = 0; | ||
3145 | return EINA_FALSE; | ||
3146 | } | ||
3147 | |||
3148 | /* Need to recalc before providing the object. */ | ||
3149 | _edje_recalc_do(ed); | ||
3150 | |||
3151 | rp = _edje_real_part_recursive_get(ed, part); | ||
3152 | if (!rp || !rp->drag) | ||
3153 | { | ||
3154 | if (dx) *dx = 0; | ||
3155 | if (dy) *dy = 0; | ||
3156 | return EINA_FALSE; | ||
3157 | } | ||
3158 | if (dx) *dx = TO_DOUBLE(rp->drag->step.x); | ||
3159 | if (dy) *dy = TO_DOUBLE(rp->drag->step.y); | ||
3160 | return EINA_TRUE; | ||
3161 | } | ||
3162 | |||
3163 | EAPI Eina_Bool | ||
3164 | edje_object_part_drag_page_set(Evas_Object *obj, const char *part, double dx, double dy) | ||
3165 | { | ||
3166 | Edje *ed; | ||
3167 | Edje_Real_Part *rp; | ||
3168 | |||
3169 | ed = _edje_fetch(obj); | ||
3170 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3171 | rp = _edje_real_part_recursive_get(ed, part); | ||
3172 | if (!rp) return EINA_FALSE; | ||
3173 | if (!rp->drag) return EINA_FALSE; | ||
3174 | if (dx < 0.0) dx = 0.0; | ||
3175 | else if (dx > 1.0) dx = 1.0; | ||
3176 | if (dy < 0.0) dy = 0.0; | ||
3177 | else if (dy > 1.0) dy = 1.0; | ||
3178 | rp->drag->page.x = FROM_DOUBLE(dx); | ||
3179 | rp->drag->page.y = FROM_DOUBLE(dy); | ||
3180 | #ifdef EDJE_CALC_CACHE | ||
3181 | rp->invalidate = 1; | ||
3182 | #endif | ||
3183 | return EINA_TRUE; | ||
3184 | } | ||
3185 | |||
3186 | EAPI Eina_Bool | ||
3187 | edje_object_part_drag_page_get(const Evas_Object *obj, const char *part, double *dx, double *dy) | ||
3188 | { | ||
3189 | Edje *ed; | ||
3190 | Edje_Real_Part *rp; | ||
3191 | |||
3192 | ed = _edje_fetch(obj); | ||
3193 | if ((!ed) || (!part)) | ||
3194 | { | ||
3195 | if (dx) *dx = 0; | ||
3196 | if (dy) *dy = 0; | ||
3197 | return EINA_FALSE; | ||
3198 | } | ||
3199 | |||
3200 | /* Need to recalc before providing the object. */ | ||
3201 | _edje_recalc_do(ed); | ||
3202 | |||
3203 | rp = _edje_real_part_recursive_get(ed, part); | ||
3204 | if (!rp || !rp->drag) | ||
3205 | { | ||
3206 | if (dx) *dx = 0; | ||
3207 | if (dy) *dy = 0; | ||
3208 | return EINA_FALSE; | ||
3209 | } | ||
3210 | if (dx) *dx = TO_DOUBLE(rp->drag->page.x); | ||
3211 | if (dy) *dy = TO_DOUBLE(rp->drag->page.y); | ||
3212 | return EINA_TRUE; | ||
3213 | } | ||
3214 | |||
3215 | EAPI Eina_Bool | ||
3216 | edje_object_part_drag_step(Evas_Object *obj, const char *part, double dx, double dy) | ||
3217 | { | ||
3218 | Edje *ed; | ||
3219 | Edje_Real_Part *rp; | ||
3220 | FLOAT_T px, py; | ||
3221 | |||
3222 | ed = _edje_fetch(obj); | ||
3223 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3224 | rp = _edje_real_part_recursive_get(ed, part); | ||
3225 | if (!rp) return EINA_FALSE; | ||
3226 | if (!rp->drag) return EINA_FALSE; | ||
3227 | if (rp->drag->down.count > 0) return EINA_FALSE; | ||
3228 | px = rp->drag->val.x; | ||
3229 | py = rp->drag->val.y; | ||
3230 | rp->drag->val.x = ADD(px, MUL(FROM_DOUBLE(dx), | ||
3231 | MUL(rp->drag->step.x, rp->part->dragable.x))); | ||
3232 | rp->drag->val.y = ADD(py, MUL(FROM_DOUBLE(dy), | ||
3233 | MUL(rp->drag->step.y, rp->part->dragable.y))); | ||
3234 | rp->drag->val.x = CLAMP (rp->drag->val.x, ZERO, FROM_DOUBLE(1.0)); | ||
3235 | rp->drag->val.y = CLAMP (rp->drag->val.y, ZERO, FROM_DOUBLE(1.0)); | ||
3236 | if ((px == rp->drag->val.x) && (py == rp->drag->val.y)) return EINA_TRUE; | ||
3237 | #ifdef EDJE_CALC_CACHE | ||
3238 | rp->invalidate = 1; | ||
3239 | #endif | ||
3240 | _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y); | ||
3241 | _edje_emit(rp->edje, "drag,step", rp->part->name); | ||
3242 | return EINA_TRUE; | ||
3243 | } | ||
3244 | |||
3245 | EAPI Eina_Bool | ||
3246 | edje_object_part_drag_page(Evas_Object *obj, const char *part, double dx, double dy) | ||
3247 | { | ||
3248 | Edje *ed; | ||
3249 | Edje_Real_Part *rp; | ||
3250 | FLOAT_T px, py; | ||
3251 | |||
3252 | ed = _edje_fetch(obj); | ||
3253 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3254 | rp = _edje_real_part_recursive_get(ed, part); | ||
3255 | if (!rp) return EINA_FALSE; | ||
3256 | if (!rp->drag) return EINA_FALSE; | ||
3257 | if (rp->drag->down.count > 0) return EINA_FALSE; | ||
3258 | px = rp->drag->val.x; | ||
3259 | py = rp->drag->val.y; | ||
3260 | rp->drag->val.x = ADD(px, MUL(FROM_DOUBLE(dx), MUL(rp->drag->page.x, rp->part->dragable.x))); | ||
3261 | rp->drag->val.y = ADD(py, MUL(FROM_DOUBLE(dy), MUL(rp->drag->page.y, rp->part->dragable.y))); | ||
3262 | rp->drag->val.x = CLAMP (rp->drag->val.x, ZERO, FROM_DOUBLE(1.0)); | ||
3263 | rp->drag->val.y = CLAMP (rp->drag->val.y, ZERO, FROM_DOUBLE(1.0)); | ||
3264 | if ((px == rp->drag->val.x) && (py == rp->drag->val.y)) return EINA_TRUE; | ||
3265 | #ifdef EDJE_CALC_CACHE | ||
3266 | rp->invalidate = 1; | ||
3267 | #endif | ||
3268 | _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y); | ||
3269 | _edje_emit(rp->edje, "drag,page", rp->part->name); | ||
3270 | return EINA_TRUE; | ||
3271 | } | ||
3272 | |||
3273 | void | ||
3274 | _edje_box_init(void) | ||
3275 | { | ||
3276 | |||
3277 | } | ||
3278 | |||
3279 | void | ||
3280 | _edje_box_shutdown(void) | ||
3281 | { | ||
3282 | if (!_edje_box_layout_registry) | ||
3283 | return; | ||
3284 | |||
3285 | eina_rbtree_delete | ||
3286 | (_edje_box_layout_registry, _edje_box_layout_external_free, NULL); | ||
3287 | _edje_box_layout_registry = NULL; | ||
3288 | } | ||
3289 | |||
3290 | EAPI Eina_Bool | ||
3291 | edje_object_part_box_append(Evas_Object *obj, const char *part, Evas_Object *child) | ||
3292 | { | ||
3293 | Edje *ed; | ||
3294 | Edje_Real_Part *rp; | ||
3295 | |||
3296 | ed = _edje_fetch(obj); | ||
3297 | if ((!ed) || (!part) || (!child)) return EINA_FALSE; | ||
3298 | |||
3299 | rp = _edje_real_part_recursive_get(ed, part); | ||
3300 | if (!rp) return EINA_FALSE; | ||
3301 | if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; | ||
3302 | |||
3303 | return _edje_real_part_box_append(rp, child); | ||
3304 | } | ||
3305 | |||
3306 | EAPI Eina_Bool | ||
3307 | edje_object_part_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child) | ||
3308 | { | ||
3309 | Edje *ed; | ||
3310 | Edje_Real_Part *rp; | ||
3311 | |||
3312 | ed = _edje_fetch(obj); | ||
3313 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3314 | |||
3315 | rp = _edje_real_part_recursive_get(ed, part); | ||
3316 | if (!rp) return EINA_FALSE; | ||
3317 | if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; | ||
3318 | |||
3319 | return _edje_real_part_box_prepend(rp, child); | ||
3320 | } | ||
3321 | |||
3322 | EAPI Eina_Bool | ||
3323 | edje_object_part_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference) | ||
3324 | { | ||
3325 | Edje *ed; | ||
3326 | Edje_Real_Part *rp; | ||
3327 | |||
3328 | ed = _edje_fetch(obj); | ||
3329 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3330 | |||
3331 | rp = _edje_real_part_recursive_get(ed, part); | ||
3332 | if (!rp) return EINA_FALSE; | ||
3333 | if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; | ||
3334 | |||
3335 | return _edje_real_part_box_insert_before(rp, child, reference); | ||
3336 | } | ||
3337 | |||
3338 | EAPI Eina_Bool | ||
3339 | edje_object_part_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos) | ||
3340 | { | ||
3341 | Edje *ed; | ||
3342 | Edje_Real_Part *rp; | ||
3343 | |||
3344 | ed = _edje_fetch(obj); | ||
3345 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3346 | |||
3347 | rp = _edje_real_part_recursive_get(ed, part); | ||
3348 | if (!rp) return EINA_FALSE; | ||
3349 | if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; | ||
3350 | |||
3351 | return _edje_real_part_box_insert_at(rp, child, pos); | ||
3352 | } | ||
3353 | |||
3354 | EAPI Evas_Object * | ||
3355 | edje_object_part_box_remove(Evas_Object *obj, const char *part, Evas_Object *child) | ||
3356 | { | ||
3357 | Edje *ed; | ||
3358 | Edje_Real_Part *rp; | ||
3359 | |||
3360 | ed = _edje_fetch(obj); | ||
3361 | if ((!ed) || (!part)) return NULL; | ||
3362 | |||
3363 | rp = _edje_real_part_recursive_get(ed, part); | ||
3364 | if (!rp) return NULL; | ||
3365 | if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL; | ||
3366 | |||
3367 | return _edje_real_part_box_remove(rp, child); | ||
3368 | } | ||
3369 | |||
3370 | EAPI Evas_Object * | ||
3371 | edje_object_part_box_remove_at(Evas_Object *obj, const char *part, unsigned int pos) | ||
3372 | { | ||
3373 | Edje *ed; | ||
3374 | Edje_Real_Part *rp; | ||
3375 | |||
3376 | ed = _edje_fetch(obj); | ||
3377 | if ((!ed) || (!part)) return NULL; | ||
3378 | |||
3379 | rp = _edje_real_part_recursive_get(ed, part); | ||
3380 | if (!rp) return NULL; | ||
3381 | if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL; | ||
3382 | |||
3383 | return _edje_real_part_box_remove_at(rp, pos); | ||
3384 | } | ||
3385 | |||
3386 | EAPI Eina_Bool | ||
3387 | edje_object_part_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear) | ||
3388 | { | ||
3389 | Edje *ed; | ||
3390 | Edje_Real_Part *rp; | ||
3391 | |||
3392 | ed = _edje_fetch(obj); | ||
3393 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3394 | |||
3395 | rp = _edje_real_part_recursive_get(ed, part); | ||
3396 | if (!rp) return EINA_FALSE; | ||
3397 | if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; | ||
3398 | |||
3399 | return _edje_real_part_box_remove_all(rp, clear); | ||
3400 | |||
3401 | } | ||
3402 | |||
3403 | static void | ||
3404 | _edje_box_child_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *child __UNUSED__, void *einfo __UNUSED__) | ||
3405 | { | ||
3406 | Edje_Real_Part *rp = data; | ||
3407 | |||
3408 | rp->edje->dirty = 1; | ||
3409 | rp->edje->recalc_call = 1; | ||
3410 | #ifdef EDJE_CALC_CACHE | ||
3411 | rp->invalidate = 1; | ||
3412 | #endif | ||
3413 | _edje_recalc(rp->edje); | ||
3414 | } | ||
3415 | |||
3416 | static void | ||
3417 | _edje_box_child_add(Edje_Real_Part *rp, Evas_Object *child) | ||
3418 | { | ||
3419 | evas_object_event_callback_add | ||
3420 | (child, EVAS_CALLBACK_DEL, _edje_box_child_del_cb, rp); | ||
3421 | |||
3422 | rp->edje->dirty = 1; | ||
3423 | rp->edje->recalc_call = 1; | ||
3424 | #ifdef EDJE_CALC_CACHE | ||
3425 | rp->invalidate = 1; | ||
3426 | #endif | ||
3427 | _edje_recalc(rp->edje); | ||
3428 | } | ||
3429 | |||
3430 | static void | ||
3431 | _edje_box_child_remove(Edje_Real_Part *rp, Evas_Object *child) | ||
3432 | { | ||
3433 | evas_object_event_callback_del_full | ||
3434 | (child, EVAS_CALLBACK_DEL, _edje_box_child_del_cb, rp); | ||
3435 | |||
3436 | rp->edje->dirty = 1; | ||
3437 | rp->edje->recalc_call = 1; | ||
3438 | #ifdef EDJE_CALC_CACHE | ||
3439 | rp->invalidate = 1; | ||
3440 | #endif | ||
3441 | _edje_recalc(rp->edje); | ||
3442 | } | ||
3443 | |||
3444 | Eina_Bool | ||
3445 | _edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj) | ||
3446 | { | ||
3447 | Evas_Object_Box_Option *opt; | ||
3448 | |||
3449 | opt = evas_object_box_append(rp->object, child_obj); | ||
3450 | if (!opt) return EINA_FALSE; | ||
3451 | |||
3452 | if (!_edje_box_layout_add_child(rp, child_obj)) | ||
3453 | { | ||
3454 | evas_object_box_remove(rp->object, child_obj); | ||
3455 | return EINA_FALSE; | ||
3456 | } | ||
3457 | |||
3458 | _edje_box_child_add(rp, child_obj); | ||
3459 | |||
3460 | return EINA_TRUE; | ||
3461 | } | ||
3462 | |||
3463 | Eina_Bool | ||
3464 | _edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj) | ||
3465 | { | ||
3466 | Evas_Object_Box_Option *opt; | ||
3467 | |||
3468 | opt = evas_object_box_prepend(rp->object, child_obj); | ||
3469 | if (!opt) return EINA_FALSE; | ||
3470 | |||
3471 | if (!_edje_box_layout_add_child(rp, child_obj)) | ||
3472 | { | ||
3473 | evas_object_box_remove(rp->object, child_obj); | ||
3474 | return EINA_FALSE; | ||
3475 | } | ||
3476 | |||
3477 | _edje_box_child_add(rp, child_obj); | ||
3478 | |||
3479 | return EINA_TRUE; | ||
3480 | } | ||
3481 | |||
3482 | Eina_Bool | ||
3483 | _edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref) | ||
3484 | { | ||
3485 | Evas_Object_Box_Option *opt; | ||
3486 | |||
3487 | opt = evas_object_box_insert_before(rp->object, child_obj, ref); | ||
3488 | if (!opt) return EINA_FALSE; | ||
3489 | |||
3490 | if (!_edje_box_layout_add_child(rp, child_obj)) | ||
3491 | { | ||
3492 | evas_object_box_remove(rp->object, child_obj); | ||
3493 | return EINA_FALSE; | ||
3494 | } | ||
3495 | |||
3496 | _edje_box_child_add(rp, child_obj); | ||
3497 | |||
3498 | return EINA_TRUE; | ||
3499 | } | ||
3500 | |||
3501 | Eina_Bool | ||
3502 | _edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos) | ||
3503 | { | ||
3504 | Evas_Object_Box_Option *opt; | ||
3505 | |||
3506 | opt = evas_object_box_insert_at(rp->object, child_obj, pos); | ||
3507 | if (!opt) return EINA_FALSE; | ||
3508 | |||
3509 | if (!_edje_box_layout_add_child(rp, child_obj)) | ||
3510 | { | ||
3511 | evas_object_box_remove(rp->object, child_obj); | ||
3512 | return EINA_FALSE; | ||
3513 | } | ||
3514 | |||
3515 | _edje_box_child_add(rp, child_obj); | ||
3516 | |||
3517 | return EINA_TRUE; | ||
3518 | } | ||
3519 | |||
3520 | Evas_Object * | ||
3521 | _edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj) | ||
3522 | { | ||
3523 | if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL; | ||
3524 | if (!evas_object_box_remove(rp->object, child_obj)) return NULL; | ||
3525 | _edje_box_layout_remove_child(rp, child_obj); | ||
3526 | _edje_box_child_remove(rp, child_obj); | ||
3527 | return child_obj; | ||
3528 | } | ||
3529 | |||
3530 | Evas_Object * | ||
3531 | _edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos) | ||
3532 | { | ||
3533 | Evas_Object_Box_Option *opt; | ||
3534 | Evas_Object_Box_Data *priv; | ||
3535 | Evas_Object *child_obj; | ||
3536 | |||
3537 | priv = evas_object_smart_data_get(rp->object); | ||
3538 | opt = eina_list_nth(priv->children, pos); | ||
3539 | if (!opt) return NULL; | ||
3540 | child_obj = opt->obj; | ||
3541 | if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL; | ||
3542 | if (!evas_object_box_remove_at(rp->object, pos)) return NULL; | ||
3543 | _edje_box_layout_remove_child(rp, child_obj); | ||
3544 | _edje_box_child_remove(rp, child_obj); | ||
3545 | return child_obj; | ||
3546 | } | ||
3547 | |||
3548 | Eina_Bool | ||
3549 | _edje_real_part_box_remove_all(Edje_Real_Part *rp, Eina_Bool clear) | ||
3550 | { | ||
3551 | Eina_List *children; | ||
3552 | int i = 0; | ||
3553 | |||
3554 | children = evas_object_box_children_get(rp->object); | ||
3555 | while (children) | ||
3556 | { | ||
3557 | Evas_Object *child_obj = children->data; | ||
3558 | if (evas_object_data_get(child_obj, "\377 edje.box_item")) | ||
3559 | i++; | ||
3560 | else | ||
3561 | { | ||
3562 | _edje_box_layout_remove_child(rp, child_obj); | ||
3563 | _edje_box_child_remove(rp, child_obj); | ||
3564 | if (!evas_object_box_remove_at(rp->object, i)) | ||
3565 | return EINA_FALSE; | ||
3566 | if (clear) | ||
3567 | evas_object_del(child_obj); | ||
3568 | } | ||
3569 | children = eina_list_remove_list(children, children); | ||
3570 | } | ||
3571 | return EINA_TRUE; | ||
3572 | } | ||
3573 | |||
3574 | static void | ||
3575 | _edje_table_child_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *child __UNUSED__, void *einfo __UNUSED__) | ||
3576 | { | ||
3577 | Edje_Real_Part *rp = data; | ||
3578 | |||
3579 | rp->edje->dirty = 1; | ||
3580 | rp->edje->recalc_call = 1; | ||
3581 | #ifdef EDJE_CALC_CACHE | ||
3582 | rp->invalidate = 1; | ||
3583 | #endif | ||
3584 | _edje_recalc(rp->edje); | ||
3585 | } | ||
3586 | |||
3587 | static void | ||
3588 | _edje_table_child_add(Edje_Real_Part *rp, Evas_Object *child) | ||
3589 | { | ||
3590 | evas_object_event_callback_add | ||
3591 | (child, EVAS_CALLBACK_DEL, _edje_table_child_del_cb, rp); | ||
3592 | |||
3593 | rp->edje->dirty = 1; | ||
3594 | rp->edje->recalc_call = 1; | ||
3595 | #ifdef EDJE_CALC_CACHE | ||
3596 | rp->invalidate = 1; | ||
3597 | #endif | ||
3598 | _edje_recalc(rp->edje); | ||
3599 | } | ||
3600 | |||
3601 | static void | ||
3602 | _edje_table_child_remove(Edje_Real_Part *rp, Evas_Object *child) | ||
3603 | { | ||
3604 | evas_object_event_callback_del_full | ||
3605 | (child, EVAS_CALLBACK_DEL, _edje_table_child_del_cb, rp); | ||
3606 | |||
3607 | rp->edje->dirty = 1; | ||
3608 | rp->edje->recalc_call = 1; | ||
3609 | #ifdef EDJE_CALC_CACHE | ||
3610 | rp->invalidate = 1; | ||
3611 | #endif | ||
3612 | _edje_recalc(rp->edje); | ||
3613 | } | ||
3614 | |||
3615 | EAPI Evas_Object * | ||
3616 | edje_object_part_table_child_get(Evas_Object *obj, const char *part, unsigned int col, unsigned int row) | ||
3617 | { | ||
3618 | Edje *ed; | ||
3619 | Edje_Real_Part *rp; | ||
3620 | |||
3621 | ed = _edje_fetch(obj); | ||
3622 | if ((!ed) || (!part)) return NULL; | ||
3623 | |||
3624 | rp = _edje_real_part_recursive_get(ed, part); | ||
3625 | if (!rp) return NULL; | ||
3626 | if (rp->part->type != EDJE_PART_TYPE_TABLE) return NULL; | ||
3627 | |||
3628 | return evas_object_table_child_get(rp->object, col, row); | ||
3629 | } | ||
3630 | |||
3631 | EAPI Eina_Bool | ||
3632 | edje_object_part_table_pack(Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan) | ||
3633 | { | ||
3634 | Edje *ed; | ||
3635 | Edje_Real_Part *rp; | ||
3636 | |||
3637 | ed = _edje_fetch(obj); | ||
3638 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3639 | |||
3640 | rp = _edje_real_part_recursive_get(ed, part); | ||
3641 | if (!rp) return EINA_FALSE; | ||
3642 | if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; | ||
3643 | |||
3644 | return _edje_real_part_table_pack(rp, child_obj, col, row, colspan, rowspan); | ||
3645 | } | ||
3646 | |||
3647 | EAPI Eina_Bool | ||
3648 | edje_object_part_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child_obj) | ||
3649 | { | ||
3650 | Edje *ed; | ||
3651 | Edje_Real_Part *rp; | ||
3652 | |||
3653 | ed = _edje_fetch(obj); | ||
3654 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3655 | |||
3656 | rp = _edje_real_part_recursive_get(ed, part); | ||
3657 | if (!rp) return EINA_FALSE; | ||
3658 | if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; | ||
3659 | |||
3660 | return _edje_real_part_table_unpack(rp, child_obj); | ||
3661 | } | ||
3662 | |||
3663 | EAPI Eina_Bool | ||
3664 | edje_object_part_table_col_row_size_get(const Evas_Object *obj, const char *part, int *cols, int *rows) | ||
3665 | { | ||
3666 | Edje *ed; | ||
3667 | Edje_Real_Part *rp; | ||
3668 | |||
3669 | ed = _edje_fetch(obj); | ||
3670 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3671 | |||
3672 | rp = _edje_real_part_recursive_get(ed, part); | ||
3673 | if (!rp) return EINA_FALSE; | ||
3674 | if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; | ||
3675 | |||
3676 | evas_object_table_col_row_size_get(rp->object, cols, rows); | ||
3677 | return EINA_TRUE; | ||
3678 | } | ||
3679 | |||
3680 | EAPI Eina_Bool | ||
3681 | edje_object_part_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear) | ||
3682 | { | ||
3683 | Edje *ed; | ||
3684 | Edje_Real_Part *rp; | ||
3685 | |||
3686 | ed = _edje_fetch(obj); | ||
3687 | if ((!ed) || (!part)) return EINA_FALSE; | ||
3688 | |||
3689 | rp = _edje_real_part_recursive_get(ed, part); | ||
3690 | if (!rp) return EINA_FALSE; | ||
3691 | if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; | ||
3692 | |||
3693 | _edje_real_part_table_clear(rp, clear); | ||
3694 | return EINA_TRUE; | ||
3695 | } | ||
3696 | |||
3697 | static void | ||
3698 | _edje_perspective_obj_del(void *data, __UNUSED__ Evas *e, __UNUSED__ Evas_Object *obj, __UNUSED__ void *event_info) | ||
3699 | { | ||
3700 | Edje_Perspective *ps = data; | ||
3701 | Evas_Object *o; | ||
3702 | |||
3703 | EINA_LIST_FREE(ps->users, o) | ||
3704 | { | ||
3705 | Edje *ed; | ||
3706 | |||
3707 | ed = evas_object_smart_data_get(o); | ||
3708 | if (!ed) continue; | ||
3709 | ed->persp = NULL; | ||
3710 | ed->dirty = 1; | ||
3711 | ed->recalc_call = 1; | ||
3712 | _edje_recalc_do(ed); | ||
3713 | } | ||
3714 | free(ps); | ||
3715 | } | ||
3716 | |||
3717 | EAPI Edje_Perspective * | ||
3718 | edje_perspective_new(Evas *e) | ||
3719 | { | ||
3720 | Edje_Perspective *ps; | ||
3721 | Evas_Coord vx, vy, vw, vh; | ||
3722 | |||
3723 | if (!e) return NULL; | ||
3724 | ps = calloc(1, sizeof(Edje_Perspective)); | ||
3725 | ps->obj = evas_object_rectangle_add(e); | ||
3726 | evas_object_data_set(ps->obj, "_edje_perspective", ps); | ||
3727 | evas_object_event_callback_add(ps->obj, EVAS_CALLBACK_DEL, _edje_perspective_obj_del, ps); | ||
3728 | evas_output_viewport_get(e, &vx, &vy, &vw, &vh); | ||
3729 | ps->e = e; | ||
3730 | ps->px = vx + (vw / 2); | ||
3731 | ps->py = vy + (vh / 2); | ||
3732 | ps->z0 = 0; | ||
3733 | ps->foc = 1000; | ||
3734 | return ps; | ||
3735 | } | ||
3736 | |||
3737 | EAPI void | ||
3738 | edje_perspective_free(Edje_Perspective *ps) | ||
3739 | { | ||
3740 | if (!ps) return; | ||
3741 | evas_object_del(ps->obj); | ||
3742 | } | ||
3743 | |||
3744 | EAPI void | ||
3745 | edje_perspective_set(Edje_Perspective *ps, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc) | ||
3746 | { | ||
3747 | Eina_List *l; | ||
3748 | Evas_Object *o; | ||
3749 | |||
3750 | if (!ps) return; | ||
3751 | if ((ps->px == px) && (ps->py == py) && (ps->z0 == z0) && (ps->foc == foc)) return; | ||
3752 | ps->px = px; | ||
3753 | ps->py = py; | ||
3754 | ps->z0 = z0; | ||
3755 | ps->foc = foc; | ||
3756 | EINA_LIST_FOREACH(ps->users, l, o) | ||
3757 | { | ||
3758 | Edje *ed; | ||
3759 | |||
3760 | ed = evas_object_smart_data_get(o); | ||
3761 | if (!ed) continue; | ||
3762 | if (!ed->persp) | ||
3763 | { | ||
3764 | ed->dirty = 1; | ||
3765 | ed->recalc_call = 1; | ||
3766 | _edje_recalc_do(ed); | ||
3767 | } | ||
3768 | } | ||
3769 | if (ps->global) | ||
3770 | { | ||
3771 | EINA_LIST_FOREACH(_edje_edjes, l, o) | ||
3772 | { | ||
3773 | Edje *ed; | ||
3774 | |||
3775 | ed = evas_object_smart_data_get(o); | ||
3776 | if (!ed) continue; | ||
3777 | if (!ed->persp) | ||
3778 | { | ||
3779 | ed->dirty = 1; | ||
3780 | ed->recalc_call = 1; | ||
3781 | _edje_recalc_do(ed); | ||
3782 | } | ||
3783 | } | ||
3784 | } | ||
3785 | } | ||
3786 | |||
3787 | EAPI void | ||
3788 | edje_perspective_global_set(Edje_Perspective *ps, Eina_Bool global) | ||
3789 | { | ||
3790 | Evas_Object *o; | ||
3791 | Eina_List *l; | ||
3792 | |||
3793 | if (!ps) return; | ||
3794 | if (ps->global == global) return; | ||
3795 | if (global) | ||
3796 | { | ||
3797 | o = evas_object_name_find(evas_object_evas_get(ps->obj), | ||
3798 | "_edje_perspective"); | ||
3799 | if (o) evas_object_name_set(o, NULL); | ||
3800 | evas_object_name_set(ps->obj, "_edje_perspective"); | ||
3801 | } | ||
3802 | else | ||
3803 | evas_object_name_set(ps->obj, NULL); | ||
3804 | ps->global = global; | ||
3805 | EINA_LIST_FOREACH(_edje_edjes, l, o) | ||
3806 | { | ||
3807 | Edje *ed; | ||
3808 | |||
3809 | ed = evas_object_smart_data_get(o); | ||
3810 | if (!ed) continue; | ||
3811 | if (!ed->persp) | ||
3812 | { | ||
3813 | ed->dirty = 1; | ||
3814 | ed->recalc_call = 1; | ||
3815 | _edje_recalc_do(ed); | ||
3816 | } | ||
3817 | } | ||
3818 | } | ||
3819 | |||
3820 | EAPI Eina_Bool | ||
3821 | edje_perspective_global_get(const Edje_Perspective *ps) | ||
3822 | { | ||
3823 | if (!ps) return EINA_FALSE; | ||
3824 | return ps->global; | ||
3825 | } | ||
3826 | |||
3827 | EAPI const Edje_Perspective * | ||
3828 | edje_evas_global_perspective_get(const Evas *e) | ||
3829 | { | ||
3830 | Evas_Object *obj; | ||
3831 | |||
3832 | if (!e) return NULL; | ||
3833 | obj = evas_object_name_find(e, "_edje_perspective"); | ||
3834 | if (!obj) return NULL; | ||
3835 | return evas_object_data_get(obj, "_edje_perspective"); | ||
3836 | } | ||
3837 | |||
3838 | EAPI void | ||
3839 | edje_object_perspective_set(Evas_Object *obj, Edje_Perspective *ps) | ||
3840 | { | ||
3841 | Edje *ed; | ||
3842 | |||
3843 | ed = evas_object_smart_data_get(obj); | ||
3844 | if (!ed) return; | ||
3845 | if (ed->persp == ps) return; | ||
3846 | if (ed->persp != ps) | ||
3847 | { | ||
3848 | if (ed->persp) | ||
3849 | ed->persp->users = eina_list_remove(ed->persp->users, obj); | ||
3850 | } | ||
3851 | ed->persp = ps; | ||
3852 | if (ps) ps->users = eina_list_append(ps->users, obj); | ||
3853 | ed->dirty = 1; | ||
3854 | ed->recalc_call = 1; | ||
3855 | _edje_recalc_do(ed); | ||
3856 | } | ||
3857 | |||
3858 | EAPI const Edje_Perspective * | ||
3859 | edje_object_perspective_get(const Evas_Object *obj) | ||
3860 | { | ||
3861 | Edje *ed; | ||
3862 | |||
3863 | ed = evas_object_smart_data_get(obj); | ||
3864 | if (!ed) return NULL; | ||
3865 | return ed->persp; | ||
3866 | } | ||
3867 | |||
3868 | #define EDJE_PRELOAD_EMISSION "preload,done" | ||
3869 | #define EDJE_PRELOAD_SOURCE NULL | ||
3870 | |||
3871 | EAPI Eina_Bool | ||
3872 | edje_object_preload(Evas_Object *obj, Eina_Bool cancel) | ||
3873 | { | ||
3874 | Edje *ed; | ||
3875 | int count; | ||
3876 | unsigned int i; | ||
3877 | |||
3878 | ed = _edje_fetch(obj); | ||
3879 | if (!ed) return EINA_FALSE; | ||
3880 | |||
3881 | _edje_recalc_do(ed); | ||
3882 | |||
3883 | for (i = 0, count = 0; i < ed->table_parts_size; i++) | ||
3884 | { | ||
3885 | Edje_Real_Part *rp; | ||
3886 | Edje_Part *ep; | ||
3887 | |||
3888 | rp = ed->table_parts[i]; | ||
3889 | ep = rp->part; | ||
3890 | |||
3891 | if (ep->type == EDJE_PART_TYPE_IMAGE || | ||
3892 | (ep->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)) | ||
3893 | count++; | ||
3894 | } | ||
3895 | |||
3896 | ed->preload_count = count; | ||
3897 | |||
3898 | if (count > 0) | ||
3899 | { | ||
3900 | for (i = 0; i < ed->table_parts_size; i++) | ||
3901 | { | ||
3902 | Edje_Real_Part *rp; | ||
3903 | Edje_Part *ep; | ||
3904 | |||
3905 | rp = ed->table_parts[i]; | ||
3906 | ep = rp->part; | ||
3907 | |||
3908 | if (ep->type == EDJE_PART_TYPE_IMAGE) | ||
3909 | { | ||
3910 | const char *file = NULL; | ||
3911 | const char *key = NULL; | ||
3912 | |||
3913 | evas_object_event_callback_del_full(rp->object, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed); | ||
3914 | |||
3915 | evas_object_image_file_get(rp->object, &file, &key); | ||
3916 | if (!file && !key) | ||
3917 | { | ||
3918 | ed->preload_count--; | ||
3919 | } | ||
3920 | else | ||
3921 | { | ||
3922 | evas_object_event_callback_add(rp->object, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed); | ||
3923 | evas_object_image_preload(rp->object, cancel); | ||
3924 | } | ||
3925 | count--; | ||
3926 | } | ||
3927 | else if (ep->type == EDJE_PART_TYPE_GROUP) | ||
3928 | { | ||
3929 | if (rp->swallowed_object) { | ||
3930 | char *tmp; | ||
3931 | |||
3932 | if (rp->part->name) | ||
3933 | { | ||
3934 | tmp = alloca(strlen(rp->part->name) + 2); | ||
3935 | sprintf(tmp, "%s:", rp->part->name); | ||
3936 | |||
3937 | edje_object_signal_callback_del(obj, EDJE_PRELOAD_EMISSION, tmp, _edje_object_signal_preload_cb); | ||
3938 | edje_object_signal_callback_add(obj, EDJE_PRELOAD_EMISSION, tmp, _edje_object_signal_preload_cb, ed); | ||
3939 | edje_object_preload(rp->swallowed_object, cancel); | ||
3940 | } | ||
3941 | else | ||
3942 | { | ||
3943 | ed->preload_count--; | ||
3944 | } | ||
3945 | |||
3946 | count--; | ||
3947 | } | ||
3948 | } | ||
3949 | } | ||
3950 | } | ||
3951 | else | ||
3952 | { | ||
3953 | _edje_emit(ed, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE); | ||
3954 | } | ||
3955 | |||
3956 | return EINA_TRUE; | ||
3957 | } | ||
3958 | |||
3959 | EAPI void | ||
3960 | edje_object_update_hints_set(Evas_Object *obj, Eina_Bool update) | ||
3961 | { | ||
3962 | Edje *ed; | ||
3963 | |||
3964 | ed = _edje_fetch(obj); | ||
3965 | if (!ed) return ; | ||
3966 | if (ed->update_hints == !!update) return ; | ||
3967 | |||
3968 | ed->update_hints = !!update; | ||
3969 | if (update) ed->recalc_hints = 1; | ||
3970 | } | ||
3971 | |||
3972 | EAPI Eina_Bool | ||
3973 | edje_object_update_hints_get(Evas_Object *obj) | ||
3974 | { | ||
3975 | Edje *ed; | ||
3976 | |||
3977 | ed = _edje_fetch(obj); | ||
3978 | if (!ed) return EINA_FALSE; | ||
3979 | |||
3980 | return ed->update_hints; | ||
3981 | } | ||
3982 | |||
3983 | Eina_Bool | ||
3984 | _edje_real_part_table_pack(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan) | ||
3985 | { | ||
3986 | Eina_Bool ret = | ||
3987 | evas_object_table_pack(rp->object, child_obj, col, row, colspan, rowspan); | ||
3988 | |||
3989 | _edje_table_child_add(rp, child_obj); | ||
3990 | |||
3991 | return ret; | ||
3992 | } | ||
3993 | |||
3994 | Eina_Bool | ||
3995 | _edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj) | ||
3996 | { | ||
3997 | Eina_Bool ret = evas_object_table_unpack(rp->object, child_obj); | ||
3998 | |||
3999 | if (ret) | ||
4000 | _edje_table_child_remove(rp, child_obj); | ||
4001 | |||
4002 | return ret; | ||
4003 | } | ||
4004 | |||
4005 | void | ||
4006 | _edje_real_part_table_clear(Edje_Real_Part *rp, Eina_Bool clear) | ||
4007 | { | ||
4008 | Eina_List *children; | ||
4009 | |||
4010 | children = evas_object_table_children_get(rp->object); | ||
4011 | while (children) | ||
4012 | { | ||
4013 | Evas_Object *child_obj = children->data; | ||
4014 | |||
4015 | _edje_table_child_remove(rp, child_obj); | ||
4016 | if (!evas_object_data_get(child_obj, "\377 edje.table_item")) | ||
4017 | { | ||
4018 | evas_object_table_unpack(rp->object, child_obj); | ||
4019 | if (clear) | ||
4020 | evas_object_del(child_obj); | ||
4021 | } | ||
4022 | children = eina_list_remove_list(children, children); | ||
4023 | } | ||
4024 | } | ||
4025 | |||
4026 | Edje_Real_Part * | ||
4027 | _edje_real_part_recursive_get(const Edje *ed, const char *part) | ||
4028 | { | ||
4029 | Edje_Real_Part *rp; | ||
4030 | char **path; | ||
4031 | |||
4032 | path = eina_str_split(part, EDJE_PART_PATH_SEPARATOR_STRING, 0); | ||
4033 | if (!path) return NULL; | ||
4034 | |||
4035 | rp = _edje_real_part_recursive_get_helper(ed, path); | ||
4036 | |||
4037 | free(*path); | ||
4038 | free(path); | ||
4039 | return rp; | ||
4040 | } | ||
4041 | |||
4042 | Evas_Object * | ||
4043 | _edje_children_get(Edje_Real_Part *rp, const char *partid) | ||
4044 | { | ||
4045 | Evas_Object *child; | ||
4046 | Eina_List *l; | ||
4047 | long int v; | ||
4048 | char *p; | ||
4049 | |||
4050 | if (!partid) return NULL; | ||
4051 | |||
4052 | switch (rp->part->type) | ||
4053 | { | ||
4054 | case EDJE_PART_TYPE_EXTERNAL: | ||
4055 | return _edje_external_content_get(rp->swallowed_object, partid); | ||
4056 | case EDJE_PART_TYPE_BOX: | ||
4057 | l = evas_object_box_children_get(rp->object); | ||
4058 | break; | ||
4059 | case EDJE_PART_TYPE_TABLE: | ||
4060 | l = evas_object_table_children_get(rp->object); | ||
4061 | break; | ||
4062 | default: | ||
4063 | return NULL; | ||
4064 | } | ||
4065 | |||
4066 | v = strtol(partid, &p, 10); | ||
4067 | if ((*p == '\0') && (v >= 0)) | ||
4068 | { | ||
4069 | child = eina_list_nth(l, v); | ||
4070 | } | ||
4071 | else | ||
4072 | { | ||
4073 | Evas_Object *cur; | ||
4074 | child = NULL; | ||
4075 | EINA_LIST_FREE(l, cur) | ||
4076 | { | ||
4077 | const char *name = evas_object_name_get(cur); | ||
4078 | if ((name) && (!strcmp(name, partid))) | ||
4079 | { | ||
4080 | child = cur; | ||
4081 | break; | ||
4082 | } | ||
4083 | } | ||
4084 | } | ||
4085 | eina_list_free(l); | ||
4086 | |||
4087 | return child; | ||
4088 | } | ||
4089 | |||
4090 | /* rebuild alternative path */ | ||
4091 | char * | ||
4092 | _edje_merge_path(const char *alias, char * const *path) | ||
4093 | { | ||
4094 | char *tmp; | ||
4095 | unsigned int length = 1; | ||
4096 | unsigned int alias_length; | ||
4097 | unsigned int i; | ||
4098 | |||
4099 | if (!alias) return NULL; | ||
4100 | |||
4101 | alias_length = strlen(alias); | ||
4102 | |||
4103 | for (i = 0; path[i]; i++) | ||
4104 | length += strlen(path[i]) + 1; | ||
4105 | |||
4106 | tmp = malloc(sizeof (char) * (length + alias_length + 2)); | ||
4107 | memcpy(tmp, alias, alias_length); | ||
4108 | tmp[alias_length] = '\0'; | ||
4109 | |||
4110 | for (i = 0; path[i]; i++) | ||
4111 | { | ||
4112 | strcat(tmp, EDJE_PART_PATH_SEPARATOR_STRING); | ||
4113 | strcat(tmp, path[i]); | ||
4114 | } | ||
4115 | |||
4116 | return tmp; | ||
4117 | } | ||
4118 | |||
4119 | |||
4120 | Edje_Real_Part * | ||
4121 | _edje_real_part_recursive_get_helper(const Edje *ed, char **path) | ||
4122 | { | ||
4123 | Edje_Real_Part *rp; | ||
4124 | Evas_Object *child; | ||
4125 | char *idx = NULL; | ||
4126 | |||
4127 | if (!path[0]) | ||
4128 | return NULL; | ||
4129 | |||
4130 | if (ed->collection && ed->collection->alias) | ||
4131 | { | ||
4132 | char *alias; | ||
4133 | |||
4134 | alias = _edje_merge_path(eina_hash_find(ed->collection->alias, path[0]), path + 1); | ||
4135 | if (alias) { | ||
4136 | rp = _edje_real_part_recursive_get(ed, alias); | ||
4137 | free(alias); | ||
4138 | return rp; | ||
4139 | } | ||
4140 | } | ||
4141 | |||
4142 | //printf(" lookup: %s on %s\n", path[0], ed->parent ? ed->parent : "-"); | ||
4143 | idx = strchr(path[0], EDJE_PART_PATH_SEPARATOR_INDEXL); | ||
4144 | if (idx) | ||
4145 | { | ||
4146 | char *end; | ||
4147 | |||
4148 | end = strchr(idx + 1, EDJE_PART_PATH_SEPARATOR_INDEXR); | ||
4149 | if (end) | ||
4150 | { | ||
4151 | *end = '\0'; | ||
4152 | *idx = '\0'; | ||
4153 | idx++; | ||
4154 | } | ||
4155 | } | ||
4156 | |||
4157 | rp = _edje_real_part_get(ed, path[0]); | ||
4158 | if (!path[1] && !idx) return rp; | ||
4159 | if (!rp) return NULL; | ||
4160 | |||
4161 | switch (rp->part->type) | ||
4162 | { | ||
4163 | case EDJE_PART_TYPE_GROUP: | ||
4164 | if (!rp->swallowed_object) return NULL; | ||
4165 | ed = _edje_fetch(rp->swallowed_object); | ||
4166 | if (!ed) return NULL; | ||
4167 | path++; | ||
4168 | return _edje_real_part_recursive_get_helper(ed, path); | ||
4169 | case EDJE_PART_TYPE_BOX: | ||
4170 | case EDJE_PART_TYPE_TABLE: | ||
4171 | case EDJE_PART_TYPE_EXTERNAL: | ||
4172 | if (!idx) return rp; | ||
4173 | path++; | ||
4174 | |||
4175 | child = _edje_children_get(rp, idx); | ||
4176 | |||
4177 | ed = _edje_fetch(child); | ||
4178 | |||
4179 | if (!ed) return NULL; | ||
4180 | return _edje_real_part_recursive_get_helper(ed, path); | ||
4181 | default: | ||
4182 | return NULL; | ||
4183 | } | ||
4184 | } | ||
4185 | |||
4186 | /* Private Routines */ | ||
4187 | Edje_Real_Part * | ||
4188 | _edje_real_part_get(const Edje *ed, const char *part) | ||
4189 | { | ||
4190 | unsigned int i; | ||
4191 | |||
4192 | if (!part) return NULL; | ||
4193 | |||
4194 | for (i = 0; i < ed->table_parts_size; i++) | ||
4195 | { | ||
4196 | Edje_Real_Part *rp; | ||
4197 | |||
4198 | rp = ed->table_parts[i]; | ||
4199 | if ((rp->part->name) && (!strcmp(rp->part->name, part))) return rp; | ||
4200 | } | ||
4201 | return NULL; | ||
4202 | } | ||
4203 | |||
4204 | Edje_Color_Class * | ||
4205 | _edje_color_class_find(Edje *ed, const char *color_class) | ||
4206 | { | ||
4207 | Eina_List *l; | ||
4208 | Edje_Color_Class *cc = NULL; | ||
4209 | |||
4210 | if ((!ed) || (!color_class)) return NULL; | ||
4211 | |||
4212 | /* first look through the object scope */ | ||
4213 | EINA_LIST_FOREACH(ed->color_classes, l, cc) | ||
4214 | if ((cc->name) && (!strcmp(color_class, cc->name))) return cc; | ||
4215 | |||
4216 | /* next look through the global scope */ | ||
4217 | cc = eina_hash_find(_edje_color_class_hash, color_class); | ||
4218 | if (cc) return cc; | ||
4219 | |||
4220 | /* finally, look through the file scope */ | ||
4221 | EINA_LIST_FOREACH(ed->file->color_classes, l, cc) | ||
4222 | if ((cc->name) && (!strcmp(color_class, cc->name))) return cc; | ||
4223 | |||
4224 | return NULL; | ||
4225 | } | ||
4226 | |||
4227 | void | ||
4228 | _edje_color_class_member_add(Edje *ed, const char *color_class) | ||
4229 | { | ||
4230 | _edje_class_member_add(ed, &ed->members.color_class, &_edje_color_class_member_hash, color_class); | ||
4231 | } | ||
4232 | |||
4233 | void | ||
4234 | _edje_color_class_member_direct_del(const char *color_class, void *l) | ||
4235 | { | ||
4236 | _edje_class_member_direct_del(color_class, l, _edje_color_class_member_hash); | ||
4237 | } | ||
4238 | |||
4239 | void | ||
4240 | _edje_color_class_member_del(Edje *ed, const char *color_class) | ||
4241 | { | ||
4242 | if ((!ed) || (!color_class)) return; | ||
4243 | |||
4244 | _edje_class_member_del(&ed->members.color_class, &_edje_color_class_member_hash, color_class); | ||
4245 | } | ||
4246 | |||
4247 | void | ||
4248 | _edje_color_class_members_free(void) | ||
4249 | { | ||
4250 | if (!_edje_color_class_member_hash) return; | ||
4251 | eina_hash_foreach(_edje_color_class_member_hash, member_list_free, NULL); | ||
4252 | eina_hash_free(_edje_color_class_member_hash); | ||
4253 | _edje_color_class_member_hash = NULL; | ||
4254 | } | ||
4255 | |||
4256 | static Eina_Bool | ||
4257 | color_class_hash_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) | ||
4258 | { | ||
4259 | Edje_Color_Class *cc; | ||
4260 | |||
4261 | cc = data; | ||
4262 | if (cc->name) eina_stringshare_del(cc->name); | ||
4263 | free(cc); | ||
4264 | return EINA_TRUE; | ||
4265 | } | ||
4266 | |||
4267 | void | ||
4268 | _edje_color_class_hash_free(void) | ||
4269 | { | ||
4270 | if (!_edje_color_class_hash) return; | ||
4271 | eina_hash_foreach(_edje_color_class_hash, color_class_hash_list_free, NULL); | ||
4272 | eina_hash_free(_edje_color_class_hash); | ||
4273 | _edje_color_class_hash = NULL; | ||
4274 | } | ||
4275 | |||
4276 | void | ||
4277 | _edje_color_class_on_del(Edje *ed, Edje_Part *ep) | ||
4278 | { | ||
4279 | unsigned int i; | ||
4280 | |||
4281 | if ((ep->default_desc) && (ep->default_desc->color_class)) | ||
4282 | _edje_color_class_member_del(ed, ep->default_desc->color_class); | ||
4283 | |||
4284 | for (i = 0; i < ep->other.desc_count; ++i) | ||
4285 | if (ep->other.desc[i]->color_class) | ||
4286 | _edje_color_class_member_del(ed, ep->other.desc[i]->color_class); | ||
4287 | } | ||
4288 | |||
4289 | Edje_Text_Class * | ||
4290 | _edje_text_class_find(Edje *ed, const char *text_class) | ||
4291 | { | ||
4292 | Eina_List *l; | ||
4293 | Edje_Text_Class *tc; | ||
4294 | |||
4295 | if ((!ed) || (!text_class)) return NULL; | ||
4296 | EINA_LIST_FOREACH(ed->text_classes, l, tc) | ||
4297 | if ((tc->name) && (!strcmp(text_class, tc->name))) return tc; | ||
4298 | return eina_hash_find(_edje_text_class_hash, text_class); | ||
4299 | } | ||
4300 | |||
4301 | void | ||
4302 | _edje_text_class_member_direct_del(const char *text_class, | ||
4303 | void *l) | ||
4304 | { | ||
4305 | _edje_class_member_direct_del(text_class, l, _edje_text_class_member_hash); | ||
4306 | } | ||
4307 | |||
4308 | void | ||
4309 | _edje_text_class_member_add(Edje *ed, const char *text_class) | ||
4310 | { | ||
4311 | _edje_class_member_add(ed, &ed->members.text_class, &_edje_text_class_member_hash, text_class); | ||
4312 | } | ||
4313 | |||
4314 | void | ||
4315 | _edje_text_class_member_del(Edje *ed, const char *text_class) | ||
4316 | { | ||
4317 | if ((!ed) || (!text_class)) return; | ||
4318 | |||
4319 | _edje_class_member_del(&ed->members.text_class, &_edje_text_class_member_hash, text_class); | ||
4320 | } | ||
4321 | |||
4322 | void | ||
4323 | _edje_text_class_members_free(void) | ||
4324 | { | ||
4325 | _edje_class_members_free(&_edje_text_class_member_hash); | ||
4326 | } | ||
4327 | |||
4328 | static Eina_Bool | ||
4329 | text_class_hash_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) | ||
4330 | { | ||
4331 | Edje_Text_Class *tc; | ||
4332 | |||
4333 | tc = data; | ||
4334 | if (tc->name) eina_stringshare_del(tc->name); | ||
4335 | if (tc->font) eina_stringshare_del(tc->font); | ||
4336 | free(tc); | ||
4337 | return EINA_TRUE; | ||
4338 | } | ||
4339 | |||
4340 | void | ||
4341 | _edje_text_class_hash_free(void) | ||
4342 | { | ||
4343 | if (!_edje_text_class_hash) return; | ||
4344 | eina_hash_foreach(_edje_text_class_hash, text_class_hash_list_free, NULL); | ||
4345 | eina_hash_free(_edje_text_class_hash); | ||
4346 | _edje_text_class_hash = NULL; | ||
4347 | } | ||
4348 | |||
4349 | Edje * | ||
4350 | _edje_fetch(const Evas_Object *obj) | ||
4351 | { | ||
4352 | Edje *ed; | ||
4353 | |||
4354 | if (!evas_object_smart_type_check(obj, "edje")) | ||
4355 | return NULL; | ||
4356 | ed = evas_object_smart_data_get(obj); | ||
4357 | if ((ed) && (ed->delete_me)) return NULL; | ||
4358 | return ed; | ||
4359 | } | ||
4360 | |||
4361 | int | ||
4362 | _edje_freeze(Edje *ed) | ||
4363 | { | ||
4364 | ed->freeze++; | ||
4365 | // printf("FREEZE %i\n", ed->freeze); | ||
4366 | return ed->freeze; | ||
4367 | } | ||
4368 | |||
4369 | int | ||
4370 | _edje_thaw(Edje *ed) | ||
4371 | { | ||
4372 | ed->freeze--; | ||
4373 | if (ed->freeze < 0) | ||
4374 | { | ||
4375 | // printf("-------------########### OVER THAW\n"); | ||
4376 | ed->freeze = 0; | ||
4377 | } | ||
4378 | if ((ed->freeze == 0) && (ed->recalc)) | ||
4379 | { | ||
4380 | // printf("thaw recalc\n"); | ||
4381 | _edje_recalc(ed); | ||
4382 | } | ||
4383 | return ed->freeze; | ||
4384 | } | ||
4385 | |||
4386 | int | ||
4387 | _edje_block(Edje *ed) | ||
4388 | { | ||
4389 | _edje_ref(ed); | ||
4390 | ed->block++; | ||
4391 | return ed->block; | ||
4392 | } | ||
4393 | |||
4394 | int | ||
4395 | _edje_unblock(Edje *ed) | ||
4396 | { | ||
4397 | int ret = 0; | ||
4398 | |||
4399 | if (!ed) return ret; | ||
4400 | |||
4401 | ed->block--; | ||
4402 | if (ed->block == 0) ed->block_break = 0; | ||
4403 | ret = ed->block; | ||
4404 | _edje_unref(ed); | ||
4405 | return ret; | ||
4406 | } | ||
4407 | |||
4408 | int | ||
4409 | _edje_block_break(Edje *ed) | ||
4410 | { | ||
4411 | if (ed->block_break) return 1; | ||
4412 | return 0; | ||
4413 | } | ||
4414 | |||
4415 | void | ||
4416 | _edje_block_violate(Edje *ed) | ||
4417 | { | ||
4418 | if (ed->block > 0) ed->block_break = 1; | ||
4419 | } | ||
4420 | |||
4421 | void | ||
4422 | _edje_object_part_swallow_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
4423 | { | ||
4424 | Evas_Object *edje_obj; | ||
4425 | |||
4426 | edje_obj = data; | ||
4427 | edje_object_part_unswallow(edje_obj, obj); | ||
4428 | return; | ||
4429 | } | ||
4430 | |||
4431 | static void | ||
4432 | _edje_real_part_swallow_hints_update(Edje_Real_Part *rp) | ||
4433 | { | ||
4434 | const char *type; | ||
4435 | |||
4436 | type = evas_object_type_get(rp->swallowed_object); | ||
4437 | |||
4438 | rp->swallow_params.min.w = 0; | ||
4439 | rp->swallow_params.min.h = 0; | ||
4440 | rp->swallow_params.max.w = -1; | ||
4441 | rp->swallow_params.max.h = -1; | ||
4442 | if ((type) && (!strcmp(type, "edje"))) | ||
4443 | { | ||
4444 | Evas_Coord w, h; | ||
4445 | |||
4446 | #if 0 | ||
4447 | edje_object_size_min_get(rp->swallowed_object, &w, &h); | ||
4448 | rp->swallow_params.min.w = w; | ||
4449 | rp->swallow_params.min.h = h; | ||
4450 | #endif | ||
4451 | edje_object_size_max_get(rp->swallowed_object, &w, &h); | ||
4452 | rp->swallow_params.max.w = w; | ||
4453 | rp->swallow_params.max.h = h; | ||
4454 | } | ||
4455 | else if ((type) && ((!strcmp(type, "text")) || (!strcmp(type, "polygon")) || | ||
4456 | (!strcmp(type, "line")))) | ||
4457 | { | ||
4458 | Evas_Coord w, h; | ||
4459 | |||
4460 | evas_object_geometry_get(rp->swallowed_object, NULL, NULL, &w, &h); | ||
4461 | #if 0 | ||
4462 | rp->swallow_params.min.w = w; | ||
4463 | rp->swallow_params.min.h = h; | ||
4464 | #endif | ||
4465 | rp->swallow_params.max.w = w; | ||
4466 | rp->swallow_params.max.h = h; | ||
4467 | } | ||
4468 | { | ||
4469 | Evas_Coord w1, h1, w2, h2, aw, ah; | ||
4470 | Evas_Aspect_Control am; | ||
4471 | |||
4472 | evas_object_size_hint_min_get(rp->swallowed_object, &w1, &h1); | ||
4473 | evas_object_size_hint_max_get(rp->swallowed_object, &w2, &h2); | ||
4474 | evas_object_size_hint_aspect_get(rp->swallowed_object, &am, &aw, &ah); | ||
4475 | rp->swallow_params.min.w = w1; | ||
4476 | rp->swallow_params.min.h = h1; | ||
4477 | if (w2 > 0) rp->swallow_params.max.w = w2; | ||
4478 | if (h2 > 0) rp->swallow_params.max.h = h2; | ||
4479 | switch (am) | ||
4480 | { | ||
4481 | case EVAS_ASPECT_CONTROL_NONE: | ||
4482 | rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NONE; | ||
4483 | break; | ||
4484 | case EVAS_ASPECT_CONTROL_NEITHER: | ||
4485 | rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NEITHER; | ||
4486 | break; | ||
4487 | case EVAS_ASPECT_CONTROL_HORIZONTAL: | ||
4488 | rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_HORIZONTAL; | ||
4489 | break; | ||
4490 | case EVAS_ASPECT_CONTROL_VERTICAL: | ||
4491 | rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_VERTICAL; | ||
4492 | break; | ||
4493 | case EVAS_ASPECT_CONTROL_BOTH: | ||
4494 | rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_BOTH; | ||
4495 | break; | ||
4496 | default: | ||
4497 | break; | ||
4498 | } | ||
4499 | rp->swallow_params.aspect.w = aw; | ||
4500 | rp->swallow_params.aspect.h = ah; | ||
4501 | evas_object_data_set(rp->swallowed_object, "\377 edje.swallowing_part", rp); | ||
4502 | } | ||
4503 | |||
4504 | #ifdef EDJE_CALC_CACHE | ||
4505 | rp->invalidate = 1; | ||
4506 | #endif | ||
4507 | } | ||
4508 | |||
4509 | void | ||
4510 | _edje_object_part_swallow_changed_hints_cb(void *data, __UNUSED__ Evas *e, __UNUSED__ Evas_Object *obj, __UNUSED__ void *event_info) | ||
4511 | { | ||
4512 | Edje_Real_Part *rp; | ||
4513 | |||
4514 | rp = data; | ||
4515 | _edje_real_part_swallow_hints_update(rp); | ||
4516 | rp->edje->dirty = 1; | ||
4517 | rp->edje->recalc_call = 1; | ||
4518 | _edje_recalc(rp->edje); | ||
4519 | return; | ||
4520 | } | ||
4521 | |||
4522 | void | ||
4523 | _edje_real_part_swallow(Edje_Real_Part *rp, | ||
4524 | Evas_Object *obj_swallow, | ||
4525 | Eina_Bool hints_update) | ||
4526 | { | ||
4527 | if (rp->swallowed_object) | ||
4528 | { | ||
4529 | if (rp->swallowed_object != obj_swallow) | ||
4530 | { | ||
4531 | _edje_real_part_swallow_clear(rp); | ||
4532 | rp->swallowed_object = NULL; | ||
4533 | } | ||
4534 | else | ||
4535 | { | ||
4536 | if (hints_update) | ||
4537 | _edje_real_part_swallow_hints_update(rp); | ||
4538 | rp->edje->dirty = 1; | ||
4539 | rp->edje->recalc_call = 1; | ||
4540 | rp->edje->recalc_hints = 1; | ||
4541 | _edje_recalc(rp->edje); | ||
4542 | return; | ||
4543 | } | ||
4544 | } | ||
4545 | #ifdef EDJE_CALC_CACHE | ||
4546 | rp->invalidate = 1; | ||
4547 | #endif | ||
4548 | if (!obj_swallow) return; | ||
4549 | rp->swallowed_object = obj_swallow; | ||
4550 | evas_object_smart_member_add(rp->swallowed_object, rp->edje->obj); | ||
4551 | if (rp->clip_to) | ||
4552 | evas_object_clip_set(rp->swallowed_object, rp->clip_to->object); | ||
4553 | else evas_object_clip_set(rp->swallowed_object, rp->edje->base.clipper); | ||
4554 | evas_object_stack_above(rp->swallowed_object, rp->object); | ||
4555 | evas_object_event_callback_add(rp->swallowed_object, | ||
4556 | EVAS_CALLBACK_DEL, | ||
4557 | _edje_object_part_swallow_free_cb, | ||
4558 | rp->edje->obj); | ||
4559 | evas_object_event_callback_add(rp->swallowed_object, | ||
4560 | EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
4561 | _edje_object_part_swallow_changed_hints_cb, | ||
4562 | rp); | ||
4563 | |||
4564 | if (hints_update) | ||
4565 | _edje_real_part_swallow_hints_update(rp); | ||
4566 | |||
4567 | if (rp->part->mouse_events) | ||
4568 | { | ||
4569 | _edje_callbacks_add(obj_swallow, rp->edje, rp); | ||
4570 | if (rp->part->repeat_events) | ||
4571 | evas_object_repeat_events_set(obj_swallow, 1); | ||
4572 | if (rp->part->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB) | ||
4573 | evas_object_pointer_mode_set(obj_swallow, rp->part->pointer_mode); | ||
4574 | evas_object_pass_events_set(obj_swallow, 0); | ||
4575 | } | ||
4576 | else | ||
4577 | evas_object_pass_events_set(obj_swallow, 1); | ||
4578 | _edje_callbacks_focus_add(rp->swallowed_object, rp->edje, rp); | ||
4579 | |||
4580 | if (rp->part->precise_is_inside) | ||
4581 | evas_object_precise_is_inside_set(obj_swallow, 1); | ||
4582 | |||
4583 | rp->edje->dirty = 1; | ||
4584 | rp->edje->recalc_call = 1; | ||
4585 | rp->edje->recalc_hints = 1; | ||
4586 | _edje_recalc(rp->edje); | ||
4587 | } | ||
4588 | |||
4589 | void | ||
4590 | _edje_real_part_swallow_clear(Edje_Real_Part *rp) | ||
4591 | { | ||
4592 | evas_object_smart_member_del(rp->swallowed_object); | ||
4593 | evas_object_event_callback_del_full(rp->swallowed_object, | ||
4594 | EVAS_CALLBACK_FREE, | ||
4595 | _edje_object_part_swallow_free_cb, | ||
4596 | rp->edje->obj); | ||
4597 | evas_object_event_callback_del_full(rp->swallowed_object, | ||
4598 | EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
4599 | _edje_object_part_swallow_changed_hints_cb, | ||
4600 | rp); | ||
4601 | evas_object_clip_unset(rp->swallowed_object); | ||
4602 | evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); | ||
4603 | if (rp->part->mouse_events) | ||
4604 | _edje_callbacks_del(rp->swallowed_object, rp->edje); | ||
4605 | _edje_callbacks_focus_del(rp->swallowed_object, rp->edje); | ||
4606 | } | ||
4607 | |||
4608 | static void | ||
4609 | _edje_object_preload(Edje *ed) | ||
4610 | { | ||
4611 | ed->preload_count--; | ||
4612 | if (!ed->preload_count) | ||
4613 | _edje_emit(ed, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE); | ||
4614 | } | ||
4615 | |||
4616 | static void | ||
4617 | _edje_object_image_preload_cb(void *data, __UNUSED__ Evas *e, Evas_Object *obj, __UNUSED__ void *event_info) | ||
4618 | { | ||
4619 | Edje *ed = data; | ||
4620 | |||
4621 | evas_object_event_callback_del_full(obj, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed); | ||
4622 | _edje_object_preload(ed); | ||
4623 | } | ||
4624 | |||
4625 | static void | ||
4626 | _edje_object_signal_preload_cb(void *data, Evas_Object *obj, __UNUSED__ const char *emission, __UNUSED__ const char *source) | ||
4627 | { | ||
4628 | Edje *ed = data; | ||
4629 | |||
4630 | edje_object_signal_callback_del(obj, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb); | ||
4631 | _edje_object_preload(ed); | ||
4632 | } | ||
4633 | |||
4634 | /** | ||
4635 | * @internal | ||
4636 | * | ||
4637 | * for edje_cc | ||
4638 | */ | ||
4639 | EAPI void | ||
4640 | _edje_program_remove(Edje_Part_Collection *edc, Edje_Program *p) | ||
4641 | { | ||
4642 | Edje_Program ***array; | ||
4643 | unsigned int *count; | ||
4644 | unsigned int i; | ||
4645 | |||
4646 | if (!p->signal && !p->source) | ||
4647 | { | ||
4648 | array = &edc->programs.nocmp; | ||
4649 | count = &edc->programs.nocmp_count; | ||
4650 | } | ||
4651 | else if (p->signal && !strpbrk(p->signal, "*?[\\") | ||
4652 | && p->source && !strpbrk(p->source, "*?[\\")) | ||
4653 | { | ||
4654 | array = &edc->programs.strcmp; | ||
4655 | count = &edc->programs.strcmp_count; | ||
4656 | } | ||
4657 | else if (p->signal && edje_program_is_strncmp(p->signal) | ||
4658 | && p->source && edje_program_is_strncmp(p->source)) | ||
4659 | { | ||
4660 | array = &edc->programs.strncmp; | ||
4661 | count = &edc->programs.strncmp_count; | ||
4662 | } | ||
4663 | else if (p->signal && edje_program_is_strrncmp(p->signal) | ||
4664 | && p->source && edje_program_is_strrncmp(p->source)) | ||
4665 | { | ||
4666 | array = &edc->programs.strrncmp; | ||
4667 | count = &edc->programs.strrncmp_count; | ||
4668 | } | ||
4669 | else | ||
4670 | { | ||
4671 | array = &edc->programs.fnmatch; | ||
4672 | count = &edc->programs.fnmatch_count; | ||
4673 | } | ||
4674 | |||
4675 | for (i = 0; i < *count; ++i) | ||
4676 | if ((*array)[i] == p) | ||
4677 | { | ||
4678 | memmove(*array + i, *array + i + 1, sizeof (Edje_Program *) * (*count - i -1)); | ||
4679 | (*count)--; | ||
4680 | break; | ||
4681 | } | ||
4682 | } | ||
4683 | |||
4684 | /** | ||
4685 | * @internal | ||
4686 | * | ||
4687 | * for edje_cc | ||
4688 | */ | ||
4689 | EAPI void | ||
4690 | _edje_program_insert(Edje_Part_Collection *edc, Edje_Program *p) | ||
4691 | { | ||
4692 | Edje_Program ***array; | ||
4693 | unsigned int *count; | ||
4694 | |||
4695 | if (!p->signal && !p->source) | ||
4696 | { | ||
4697 | array = &edc->programs.nocmp; | ||
4698 | count = &edc->programs.nocmp_count; | ||
4699 | } | ||
4700 | else if (p->signal && !strpbrk(p->signal, "*?[\\") | ||
4701 | && p->source && !strpbrk(p->source, "*?[\\")) | ||
4702 | { | ||
4703 | array = &edc->programs.strcmp; | ||
4704 | count = &edc->programs.strcmp_count; | ||
4705 | } | ||
4706 | else if (p->signal && edje_program_is_strncmp(p->signal) | ||
4707 | && p->source && edje_program_is_strncmp(p->source)) | ||
4708 | { | ||
4709 | array = &edc->programs.strncmp; | ||
4710 | count = &edc->programs.strncmp_count; | ||
4711 | } | ||
4712 | else if (p->signal && edje_program_is_strrncmp(p->signal) | ||
4713 | && p->source && edje_program_is_strrncmp(p->source)) | ||
4714 | { | ||
4715 | array = &edc->programs.strrncmp; | ||
4716 | count = &edc->programs.strrncmp_count; | ||
4717 | } | ||
4718 | else | ||
4719 | { | ||
4720 | array = &edc->programs.fnmatch; | ||
4721 | count = &edc->programs.fnmatch_count; | ||
4722 | } | ||
4723 | |||
4724 | *array = realloc(*array, sizeof (Edje_Program *) * (*count + 1)); | ||
4725 | (*array)[(*count)++] = p; | ||
4726 | } | ||
4727 | |||
4728 | const char * | ||
4729 | edje_string_get(const Edje_String *es) | ||
4730 | { | ||
4731 | /* FIXME: Handle localization here */ | ||
4732 | if (!es) return NULL; | ||
4733 | return es->str; | ||
4734 | } | ||
4735 | |||
4736 | const char * | ||
4737 | edje_string_id_get(const Edje_String *es) | ||
4738 | { | ||
4739 | /* FIXME: Handle localization here */ | ||
4740 | if (!es) return NULL; | ||
4741 | return es->str; | ||
4742 | } | ||
4743 | |||
4744 | static void | ||
4745 | _cb_subobj_del(void *data, __UNUSED__ Evas *e, Evas_Object *obj, __UNUSED__ void *event_info) | ||
4746 | { | ||
4747 | Edje *ed = data; | ||
4748 | ed->subobjs = eina_list_remove(ed->subobjs, obj); | ||
4749 | evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, | ||
4750 | _cb_subobj_del, ed); | ||
4751 | } | ||
4752 | |||
4753 | void | ||
4754 | _edje_subobj_register(Edje *ed, Evas_Object *ob) | ||
4755 | { | ||
4756 | ed->subobjs = eina_list_append(ed->subobjs, ob); | ||
4757 | evas_object_event_callback_add(ob, EVAS_CALLBACK_DEL, | ||
4758 | _cb_subobj_del, ed); | ||
4759 | } | ||
4760 | |||
4761 | /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ | ||