diff options
Diffstat (limited to 'libraries/edje/src/lib/edje_container.c')
-rw-r--r-- | libraries/edje/src/lib/edje_container.c | 955 |
1 files changed, 0 insertions, 955 deletions
diff --git a/libraries/edje/src/lib/edje_container.c b/libraries/edje/src/lib/edje_container.c deleted file mode 100644 index 357d607..0000000 --- a/libraries/edje/src/lib/edje_container.c +++ /dev/null | |||
@@ -1,955 +0,0 @@ | |||
1 | #include "edje_private.h" | ||
2 | #include "edje_container.h" | ||
3 | |||
4 | #if 0 | ||
5 | |||
6 | static void | ||
7 | _edje_container_relayout(Smart_Data *sd) | ||
8 | { | ||
9 | Eina_List *l; | ||
10 | Evas_Coord x, y, w, h, sw; | ||
11 | Edje_Item *ei; | ||
12 | |||
13 | if (sd->freeze > 0) return; | ||
14 | if (!sd->need_layout) return; | ||
15 | |||
16 | if (sd->w < sd->min_w) sw = sd->min_w; | ||
17 | else if (sd->w > sd->max_w) sw = sd->max_w; | ||
18 | else sw = sd->w; | ||
19 | |||
20 | y = 0; | ||
21 | x = 0; | ||
22 | w = 0; | ||
23 | h = 0; | ||
24 | |||
25 | EINA_LIST_FOREACH(sd->children, l, ei) | ||
26 | { | ||
27 | if (sd->homogenous) h = sd->min_row_h; | ||
28 | |||
29 | ei->y = y; | ||
30 | ei->h = h; | ||
31 | // ei->w = w; | ||
32 | // ei->h = h; | ||
33 | } | ||
34 | |||
35 | sd->need_layout = 0; | ||
36 | } | ||
37 | |||
38 | static void | ||
39 | _edje_container_recalc(Smart_Data *sd) | ||
40 | { | ||
41 | Eina_List *l; | ||
42 | Edje_Item *ei; | ||
43 | int any_max_h = 0, any_max_w = 0; | ||
44 | int i; | ||
45 | |||
46 | if (sd->freeze > 0) return; | ||
47 | if (!sd->changed) return; | ||
48 | |||
49 | sd->min_h = 0; | ||
50 | sd->max_h = -1; | ||
51 | sd->min_w = 0; | ||
52 | sd->max_w = -1; | ||
53 | sd->min_row_h = 0; | ||
54 | sd->max_row_h = -1; | ||
55 | sd->contents_h = 0; | ||
56 | sd->contents_w = 0; | ||
57 | |||
58 | for (i = 0; i < sd->cols; i++) | ||
59 | { | ||
60 | sd->min_w += sd->colinfo[i].minw; | ||
61 | if (sd->colinfo[i].maxw >= 0) | ||
62 | { | ||
63 | if (sd->max_w >= 0) | ||
64 | sd->max_w += sd->colinfo[i].maxw; | ||
65 | else | ||
66 | sd->max_w = sd->colinfo[i].maxw; | ||
67 | } | ||
68 | else | ||
69 | any_max_w = 1; | ||
70 | } | ||
71 | if (any_max_w) sd->max_w = -1; | ||
72 | |||
73 | if (sd->w < sd->min_w) | ||
74 | sd->contents_w = sd->min_w; | ||
75 | else if ((sd->max_w >= 0) && (sd->w < sd->max_w)) | ||
76 | sd->w = sd->max_w; | ||
77 | |||
78 | EINA_LIST_FOREACH(sd->children, l, ei) | ||
79 | { | ||
80 | if (ei->minh > sd->min_row_h) | ||
81 | sd->min_row_h = ei->minh; | ||
82 | if (sd->max_row_h >= 0) | ||
83 | { | ||
84 | if (ei->maxh >= 0) | ||
85 | { | ||
86 | if (sd->max_row_h > ei->maxh) | ||
87 | sd->max_row_h = ei->maxh; | ||
88 | } | ||
89 | else | ||
90 | any_max_h = 1; | ||
91 | } | ||
92 | sd->min_h += ei->minh; | ||
93 | if (ei->maxh >= 0) | ||
94 | { | ||
95 | if (sd->max_h >= 0) | ||
96 | sd->max_h += ei->maxh; | ||
97 | else | ||
98 | sd->max_h = ei->maxh; | ||
99 | } | ||
100 | else | ||
101 | any_max_h = 1; | ||
102 | } | ||
103 | if (any_max_h) | ||
104 | { | ||
105 | sd->max_h = -1; | ||
106 | sd->max_row_h = -1; | ||
107 | } | ||
108 | if (sd->homogenous) | ||
109 | { | ||
110 | sd->min_h = eina_list_count(sd->children) * sd->min_row_h; | ||
111 | } | ||
112 | |||
113 | sd->changed = 0; | ||
114 | sd->change_child = 0; | ||
115 | sd->change_child_list = 0; | ||
116 | sd->change_cols = 0; | ||
117 | |||
118 | sd->need_layout = 1; | ||
119 | _edje_container_relayout(sd); | ||
120 | } | ||
121 | |||
122 | static void | ||
123 | _edje_item_recalc(Edje_Item *ei) | ||
124 | { | ||
125 | int i; | ||
126 | |||
127 | if (ei->freeze > 0) return; | ||
128 | if (!ei->recalc) return; | ||
129 | if (!ei->sd) return; | ||
130 | |||
131 | ei->minh = 0; | ||
132 | ei->maxh = -1; | ||
133 | for (i = 0; i < ((Smart_Data *)(ei->sd))->cols; i++) | ||
134 | { | ||
135 | if (ei->cells[i].minh > ei->minh) ei->minh = ei->cells[i].minh; | ||
136 | if (ei->cells[i].maxh >= 0) | ||
137 | { | ||
138 | if (ei->maxh >= 0) | ||
139 | { | ||
140 | if (ei->cells[i].maxh < ei->maxh) | ||
141 | ei->maxh = ei->cells[i].maxh; | ||
142 | } | ||
143 | else | ||
144 | ei->maxh = ei->cells[i].maxh; | ||
145 | } | ||
146 | if (((Smart_Data *)(ei->sd))->colinfo[i].minw < ei->cells[i].minw) | ||
147 | ((Smart_Data *)(ei->sd))->colinfo[i].minw = ei->cells[i].minw; | ||
148 | if (((Smart_Data *)(ei->sd))->colinfo[i].maxw >= 0) | ||
149 | { | ||
150 | if (ei->cells[i].maxw >= 0) | ||
151 | { | ||
152 | if (((Smart_Data *)(ei->sd))->colinfo[i].maxw > ei->cells[i].maxw) | ||
153 | ((Smart_Data *)(ei->sd))->colinfo[i].maxw = ei->cells[i].maxw; | ||
154 | } | ||
155 | } | ||
156 | else | ||
157 | ((Smart_Data *)(ei->sd))->colinfo[i].maxw = ei->cells[i].maxw; | ||
158 | } | ||
159 | |||
160 | ei->recalc = 0; | ||
161 | |||
162 | _edje_container_recalc(ei->sd); | ||
163 | } | ||
164 | |||
165 | |||
166 | /*****************************/ | ||
167 | /** | ||
168 | * @endcond | ||
169 | */ | ||
170 | |||
171 | /*============================================================================* | ||
172 | * Global * | ||
173 | *============================================================================*/ | ||
174 | |||
175 | /*============================================================================* | ||
176 | * API * | ||
177 | *============================================================================*/ | ||
178 | |||
179 | /** | ||
180 | * @addtogroup Edje_container_Group Container | ||
181 | * | ||
182 | * @brief These functions provides an abstraction layer between the application | ||
183 | * code and the interface, while allowing extremely flexible dynamic layouts | ||
184 | * and animations. | ||
185 | * | ||
186 | * For more information, you can look at the @ref tutorial_list_page. | ||
187 | * | ||
188 | * @{ | ||
189 | */ | ||
190 | |||
191 | /** | ||
192 | * @brief Create an edje item. | ||
193 | * | ||
194 | * @param cl The edje item of type Edje_Item_Class. | ||
195 | * @param data The edje item data. | ||
196 | * | ||
197 | * @return The new edje item created. | ||
198 | * | ||
199 | * This function creates an new edje item. The edje item data can be | ||
200 | * retrieved with edje_item_data_get(). | ||
201 | * | ||
202 | * @see edje_item_del() | ||
203 | * @see edje_item_data_set() | ||
204 | * @see edje_item_data_get() | ||
205 | * | ||
206 | */ | ||
207 | |||
208 | Edje_Item * | ||
209 | edje_item_add(Edje_Item_Class *cl, void *data) | ||
210 | { | ||
211 | Edje_Item *ei; | ||
212 | |||
213 | ei = calloc(sizeof(Edje_Item), 1); | ||
214 | |||
215 | ei->class = cl; | ||
216 | ei->class_data = data; | ||
217 | |||
218 | return ei; | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * @brief Delete an edje item. | ||
223 | * | ||
224 | * @param ei The edje item to be deleted. | ||
225 | * | ||
226 | * This function deletes the edje item from memory. | ||
227 | * | ||
228 | * @see edje_item_add() | ||
229 | * @see edje_item_data_set() | ||
230 | * @see edje_item_data_get() | ||
231 | * | ||
232 | */ | ||
233 | |||
234 | void | ||
235 | edje_item_del(Edje_Item *ei) | ||
236 | { | ||
237 | Smart_Data *sd; | ||
238 | |||
239 | sd = ei->sd; | ||
240 | if (ei->object) evas_object_del(ei->object); | ||
241 | if (ei->overlay_object) evas_object_del(ei->overlay_object); | ||
242 | free(ei); | ||
243 | if (!sd) return; | ||
244 | sd->changed = 1; | ||
245 | sd->change_child_list = 1; | ||
246 | _edje_container_recalc(sd); | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * @brief Return the smart object of the edje item. | ||
251 | * | ||
252 | * @param ei The edje item which the smart object of type Evas_Object is get | ||
253 | * from. | ||
254 | * | ||
255 | * This function returns the smart object in the edje item. | ||
256 | * | ||
257 | */ | ||
258 | |||
259 | Evas_Object * | ||
260 | edje_item_container_get(Edje_Item *ei) | ||
261 | { | ||
262 | if (!ei->sd) return NULL; | ||
263 | return ((Smart_Data *)(ei->sd))->smart_obj; | ||
264 | } | ||
265 | |||
266 | /* an arbitrary data pointer to use to track other data */ | ||
267 | /** | ||
268 | * @brief Set the edje item data. | ||
269 | * | ||
270 | * @param ei The edje item of type Edje_Item_Class. | ||
271 | * @param data The edje item data. | ||
272 | * | ||
273 | * This function set the data of the edje item. The edje item data can be | ||
274 | * retrieved with edje_item_data_get(). | ||
275 | * | ||
276 | * @see edje_item_add() | ||
277 | * @see edje_item_del() | ||
278 | * @see edje_item_data_get() | ||
279 | * | ||
280 | */ | ||
281 | |||
282 | void | ||
283 | edje_item_data_set(Edje_Item *ei, void *data) | ||
284 | { | ||
285 | ei->data = data; | ||
286 | } | ||
287 | |||
288 | /** | ||
289 | * @brief Get the data of the edje item. | ||
290 | * | ||
291 | * @param ei The edje item of type Edje_Item_Class. | ||
292 | * | ||
293 | * This function get the data of the edje item set by edje_item_data_set(). | ||
294 | * | ||
295 | * @see edje_item_data_set() | ||
296 | * @see edje_item_add() | ||
297 | * @see edje_item_del() | ||
298 | * | ||
299 | */ | ||
300 | |||
301 | void * | ||
302 | edje_item_data_get(Edje_Item *ei) | ||
303 | { | ||
304 | return ei->data; | ||
305 | } | ||
306 | |||
307 | /* this object covers the entire item */ | ||
308 | |||
309 | void | ||
310 | edje_item_overlay_object_set(Edje_Item *ei, Evas_Object *obj) | ||
311 | { | ||
312 | if (ei->overlay_object) | ||
313 | { | ||
314 | /* FIXME: if it changed - remove...*/ | ||
315 | } | ||
316 | ei->overlay_object = obj; | ||
317 | if (ei->sd) | ||
318 | evas_object_smart_member_add(((Smart_Data *)(ei->sd))->smart_obj, obj); | ||
319 | } | ||
320 | |||
321 | |||
322 | |||
323 | Evas_Object * | ||
324 | edje_item_overlay_object_get(Edje_Item *ei) | ||
325 | { | ||
326 | return ei->overlay_object; | ||
327 | } | ||
328 | |||
329 | /* this object goes under entire item */ | ||
330 | void | ||
331 | edje_item_object_set(Edje_Item *ei, Evas_Object *obj) | ||
332 | { | ||
333 | if (ei->object) | ||
334 | { | ||
335 | /* FIXME: if it changed - remove...*/ | ||
336 | } | ||
337 | ei->object = obj; | ||
338 | if (ei->sd) | ||
339 | evas_object_smart_member_add(((Smart_Data *)(ei->sd))->smart_obj, obj); | ||
340 | } | ||
341 | |||
342 | Evas_Object * | ||
343 | edje_item_object_get(Edje_Item *ei) | ||
344 | { | ||
345 | return ei->object; | ||
346 | } | ||
347 | |||
348 | /* optionally you can manage each column's object yourself OR let Edje do it */ | ||
349 | void | ||
350 | edje_item_object_column_set(Edje_Item *ei, int col, Evas_Object *obj) | ||
351 | { | ||
352 | if (ei->cells_num <= (col + 1)) | ||
353 | { | ||
354 | /* FIXME: unsafe realloc */ | ||
355 | ei->cells = realloc(ei->cells, sizeof(Edje_Item_Cell) * col); | ||
356 | ei->cells_num = col + 1; | ||
357 | } | ||
358 | ei->cells[col].obj = obj; | ||
359 | } | ||
360 | |||
361 | Evas_Object * | ||
362 | edje_item_object_column_get(Edje_Item *ei, int col) | ||
363 | { | ||
364 | if (ei->cells_num <= (col + 1)) return NULL; | ||
365 | return ei->cells[col].obj; | ||
366 | } | ||
367 | |||
368 | /* query the item for the items preferred co-ords */ | ||
369 | void | ||
370 | edje_item_geometry_get(Edje_Item *ei, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) | ||
371 | { | ||
372 | if (!ei->sd) | ||
373 | { | ||
374 | if (x) *x = 0; | ||
375 | if (y) *y = 0; | ||
376 | if (w) *w = 0; | ||
377 | if (h) *h = 0; | ||
378 | return; | ||
379 | } | ||
380 | if (x) *x = ((Smart_Data *)(ei->sd))->x; | ||
381 | if (y) *y = ((Smart_Data *)(ei->sd))->y + ei->y; | ||
382 | if (w) *w = ((Smart_Data *)(ei->sd))->w; | ||
383 | if (h) *h = ei->h; | ||
384 | } | ||
385 | |||
386 | /* freeze and thaw items if u are about to do a bunch of changes */ | ||
387 | int | ||
388 | edje_item_freeze(Edje_Item *ei) | ||
389 | { | ||
390 | ei->freeze++; | ||
391 | return ei->freeze; | ||
392 | } | ||
393 | |||
394 | int | ||
395 | edje_item_thaw(Edje_Item *ei) | ||
396 | { | ||
397 | ei->freeze--; | ||
398 | if (ei->freeze > 0) return ei->freeze; | ||
399 | if (!ei->sd) return ei->freeze; | ||
400 | if (ei->recalc) _edje_item_recalc(ei); | ||
401 | return ei->freeze; | ||
402 | } | ||
403 | |||
404 | /* column info */ | ||
405 | void | ||
406 | edje_item_column_size_set(Edje_Item *ei, int col, Evas_Coord minw, Evas_Coord maxw, Evas_Coord minh, Evas_Coord maxh) | ||
407 | { | ||
408 | if (ei->cells_num <= (col + 1)) | ||
409 | { | ||
410 | /* FIXME: unsafe realloc */ | ||
411 | ei->cells = realloc(ei->cells, sizeof(Edje_Item_Cell) * col); | ||
412 | ei->cells_num = col + 1; | ||
413 | } | ||
414 | if ((ei->cells[col].minw == minw) && | ||
415 | (ei->cells[col].minh == minh) && | ||
416 | (ei->cells[col].maxw == maxw) && | ||
417 | (ei->cells[col].maxh == maxh)) return; | ||
418 | ei->cells[col].minh = minh; | ||
419 | ei->cells[col].maxh = maxh; | ||
420 | ei->cells[col].minw = minw; | ||
421 | ei->cells[col].maxw = maxw; | ||
422 | ei->recalc = 1; | ||
423 | if (ei->sd) | ||
424 | { | ||
425 | ((Smart_Data *)(ei->sd))->changed = 1; | ||
426 | ((Smart_Data *)(ei->sd))->change_child = 1; | ||
427 | } | ||
428 | _edje_item_recalc(ei); | ||
429 | } | ||
430 | |||
431 | void | ||
432 | edje_item_column_size_get(Edje_Item *ei, int col, Evas_Coord *minw, Evas_Coord *maxw, Evas_Coord *minh, Evas_Coord *maxh) | ||
433 | { | ||
434 | if (ei->cells_num <= (col + 1)) | ||
435 | { | ||
436 | if (minw) *minw = 0; | ||
437 | if (minh) *minh = 0; | ||
438 | if (maxw) *maxw = -1; | ||
439 | if (maxh) *maxh = -1; | ||
440 | } | ||
441 | if (minw) *minw = ei->cells[col].minw; | ||
442 | if (minh) *minh = ei->cells[col].minh; | ||
443 | if (maxw) *maxw = ei->cells[col].maxw; | ||
444 | if (maxh) *maxh = ei->cells[col].maxh; | ||
445 | } | ||
446 | |||
447 | /* selection stuff */ | ||
448 | void | ||
449 | edje_item_select(Edje_Item *ei) | ||
450 | { | ||
451 | ei->selected = 1; | ||
452 | /* FIXME: trigger item to change visually */ | ||
453 | } | ||
454 | |||
455 | void | ||
456 | edje_item_unselect(Edje_Item *ei) | ||
457 | { | ||
458 | ei->selected = 0; | ||
459 | /* FIXME: trigger item to change visually */ | ||
460 | } | ||
461 | |||
462 | /* focus stuff - only 1 can be focuesd */ | ||
463 | void | ||
464 | edje_item_focus(Edje_Item *ei) | ||
465 | { | ||
466 | // ei->focused = 1; | ||
467 | } | ||
468 | |||
469 | void | ||
470 | edje_item_unfocus(Edje_Item *ei) | ||
471 | { | ||
472 | // ei->focused = 0; | ||
473 | } | ||
474 | |||
475 | /* disable/enable stuff - stops focus and selection working on these items */ | ||
476 | void | ||
477 | edje_item_enable(Edje_Item *ei) | ||
478 | { | ||
479 | // ei->disabled = 0; | ||
480 | } | ||
481 | |||
482 | void | ||
483 | edje_item_disable(Edje_Item *ei) | ||
484 | { | ||
485 | // ei->disabled = 1; | ||
486 | } | ||
487 | |||
488 | /* item utils */ | ||
489 | int | ||
490 | edje_item_selected_get(Edje_Item *ei) | ||
491 | { | ||
492 | return ei->selected; | ||
493 | } | ||
494 | |||
495 | int | ||
496 | edje_item_focused_get(Edje_Item *ei) | ||
497 | { | ||
498 | return ei->focused; | ||
499 | } | ||
500 | |||
501 | int | ||
502 | edje_item_disabled_get(Edje_Item *ei) | ||
503 | { | ||
504 | return ei->disabled; | ||
505 | } | ||
506 | |||
507 | /***** container calls *****/ | ||
508 | |||
509 | int | ||
510 | edje_container_freeze(Evas_Object *obj) | ||
511 | { | ||
512 | Smart_Data *sd; | ||
513 | |||
514 | sd = evas_object_smart_data_get(obj); | ||
515 | if (!sd) return 0; | ||
516 | sd->freeze++; | ||
517 | return sd->freeze; | ||
518 | } | ||
519 | |||
520 | int | ||
521 | edje_container_thaw(Evas_Object *obj) | ||
522 | { | ||
523 | Smart_Data *sd; | ||
524 | |||
525 | sd = evas_object_smart_data_get(obj); | ||
526 | if (!sd) return 0; | ||
527 | sd->freeze--; | ||
528 | if (sd->freeze <= 0) _edje_container_recalc(sd); | ||
529 | return sd->freeze; | ||
530 | } | ||
531 | |||
532 | void | ||
533 | edje_container_item_append(Evas_Object *obj, Edje_Item *ei) | ||
534 | { | ||
535 | Smart_Data *sd; | ||
536 | |||
537 | sd = evas_object_smart_data_get(obj); | ||
538 | if (!sd) return; | ||
539 | sd->children = eina_list_append(sd->children, ei); | ||
540 | sd->changed = 1; | ||
541 | sd->change_child_list = 1; | ||
542 | sd->rows = eina_list_count(sd->children); | ||
543 | _edje_container_recalc(sd); | ||
544 | } | ||
545 | |||
546 | void | ||
547 | edje_container_item_prepend(Evas_Object *obj, Edje_Item *ei) | ||
548 | { | ||
549 | Smart_Data *sd; | ||
550 | |||
551 | sd = evas_object_smart_data_get(obj); | ||
552 | if (!sd) return; | ||
553 | sd->children = eina_list_prepend(sd->children, ei); | ||
554 | sd->changed = 1; | ||
555 | sd->change_child_list = 1; | ||
556 | sd->rows = eina_list_count(sd->children); | ||
557 | _edje_container_recalc(sd); | ||
558 | } | ||
559 | |||
560 | void | ||
561 | edje_container_item_append_relative(Evas_Object *obj, Edje_Item *ei, Edje_Item *rel) | ||
562 | { | ||
563 | Smart_Data *sd; | ||
564 | |||
565 | sd = evas_object_smart_data_get(obj); | ||
566 | if (!sd) return; | ||
567 | sd->children = eina_list_append_relative(sd->children, ei, rel); | ||
568 | sd->changed = 1; | ||
569 | sd->change_child_list = 1; | ||
570 | sd->rows = eina_list_count(sd->children); | ||
571 | _edje_container_recalc(sd); | ||
572 | } | ||
573 | |||
574 | void | ||
575 | edje_container_item_prepend_relative(Evas_Object *obj, Edje_Item *ei, Edje_Item *rel) | ||
576 | { | ||
577 | Smart_Data *sd; | ||
578 | |||
579 | sd = evas_object_smart_data_get(obj); | ||
580 | if (!sd) return; | ||
581 | sd->children = eina_list_prepend_relative(sd->children, ei, rel); | ||
582 | sd->changed = 1; | ||
583 | sd->change_child_list = 1; | ||
584 | sd->rows = eina_list_count(sd->children); | ||
585 | _edje_container_recalc(sd); | ||
586 | } | ||
587 | |||
588 | void | ||
589 | edje_container_item_insert(Evas_Object *obj, Edje_Item *ei, int n) | ||
590 | { | ||
591 | Smart_Data *sd; | ||
592 | void *rel; | ||
593 | |||
594 | sd = evas_object_smart_data_get(obj); | ||
595 | if (!sd) return; | ||
596 | rel = eina_list_nth(sd->children, n); | ||
597 | if (!rel) | ||
598 | sd->children = eina_list_append(sd->children, ei); | ||
599 | else | ||
600 | sd->children = eina_list_append_relative(sd->children, ei, rel); | ||
601 | sd->changed = 1; | ||
602 | sd->change_child_list = 1; | ||
603 | sd->rows = eina_list_count(sd->children); | ||
604 | _edje_container_recalc(sd); | ||
605 | } | ||
606 | |||
607 | void | ||
608 | edje_container_item_remove(Evas_Object *obj, Edje_Item *ei) | ||
609 | { | ||
610 | Smart_Data *sd; | ||
611 | |||
612 | sd = evas_object_smart_data_get(obj); | ||
613 | if (!sd) return; | ||
614 | sd->children = eina_list_remove(sd->children, ei); | ||
615 | sd->changed = 1; | ||
616 | sd->change_child_list = 1; | ||
617 | sd->rows = eina_list_count(sd->children); | ||
618 | _edje_container_recalc(sd); | ||
619 | } | ||
620 | |||
621 | void | ||
622 | edje_container_columns_set(Evas_Object *obj, int cols) | ||
623 | { | ||
624 | Smart_Data *sd; | ||
625 | |||
626 | sd = evas_object_smart_data_get(obj); | ||
627 | if (!sd) return; | ||
628 | if (sd->cols == cols) return; | ||
629 | sd->colinfo = realloc(sd->colinfo, cols * sizeof(Smart_Data_Colinfo)); | ||
630 | if (cols > sd->cols) | ||
631 | { | ||
632 | int i; | ||
633 | |||
634 | for (i = sd->cols; i < cols; i++) | ||
635 | { | ||
636 | sd->colinfo[i].minw = 0; | ||
637 | sd->colinfo[i].maxw = -1; | ||
638 | } | ||
639 | } | ||
640 | sd->cols = cols; | ||
641 | sd->changed = 1; | ||
642 | sd->change_cols = 1; | ||
643 | _edje_container_recalc(sd); | ||
644 | } | ||
645 | |||
646 | int | ||
647 | edje_container_columns_get(Evas_Object *obj) | ||
648 | { | ||
649 | Smart_Data *sd; | ||
650 | |||
651 | sd = evas_object_smart_data_get(obj); | ||
652 | if (!sd) return 0; | ||
653 | return sd->cols; | ||
654 | } | ||
655 | |||
656 | void | ||
657 | edje_container_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) | ||
658 | { | ||
659 | Smart_Data *sd; | ||
660 | |||
661 | sd = evas_object_smart_data_get(obj); | ||
662 | if (!sd) return; | ||
663 | if (sd->changed) | ||
664 | { | ||
665 | int freeze; | ||
666 | |||
667 | freeze = sd->freeze; | ||
668 | sd->freeze = 0; | ||
669 | _edje_container_recalc(sd); | ||
670 | sd->freeze = freeze; | ||
671 | } | ||
672 | if (minw) *minw = sd->min_w; | ||
673 | if (minh) *minh = sd->min_h; | ||
674 | } | ||
675 | |||
676 | void | ||
677 | edje_container_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh) | ||
678 | { | ||
679 | Smart_Data *sd; | ||
680 | |||
681 | sd = evas_object_smart_data_get(obj); | ||
682 | if (!sd) return; | ||
683 | if (sd->changed) | ||
684 | { | ||
685 | int freeze; | ||
686 | |||
687 | freeze = sd->freeze; | ||
688 | sd->freeze = 0; | ||
689 | _edje_container_recalc(sd); | ||
690 | sd->freeze = freeze; | ||
691 | } | ||
692 | if (maxw) *maxw = sd->max_w; | ||
693 | if (maxh) *maxh = sd->max_h; | ||
694 | } | ||
695 | |||
696 | void | ||
697 | edje_containter_align_set(Evas_Object *obj, double halign, double valign) | ||
698 | { | ||
699 | Smart_Data *sd; | ||
700 | |||
701 | sd = evas_object_smart_data_get(obj); | ||
702 | if (!sd) return; | ||
703 | if ((sd->align_x == halign) && (sd->align_y == valign)) return; | ||
704 | sd->align_x = halign; | ||
705 | sd->align_y = valign; | ||
706 | sd->need_layout = 1; | ||
707 | _edje_container_relayout(sd); | ||
708 | } | ||
709 | |||
710 | void | ||
711 | edje_container_align_get(Evas_Object *obj, double *halign, double *valign) | ||
712 | { | ||
713 | Smart_Data *sd; | ||
714 | |||
715 | sd = evas_object_smart_data_get(obj); | ||
716 | if (!sd) return; | ||
717 | if (halign) *halign = sd->align_x; | ||
718 | if (valign) *valign = sd->align_y; | ||
719 | } | ||
720 | |||
721 | int | ||
722 | edje_container_count_get(Evas_Object *obj) | ||
723 | { | ||
724 | Smart_Data *sd; | ||
725 | |||
726 | sd = evas_object_smart_data_get(obj); | ||
727 | if (!sd) return 0; | ||
728 | return eina_list_count(sd->children); | ||
729 | } | ||
730 | |||
731 | Edje_Item * | ||
732 | edje_container_item_first_get(Evas_Object *obj) | ||
733 | { | ||
734 | Smart_Data *sd; | ||
735 | |||
736 | sd = evas_object_smart_data_get(obj); | ||
737 | if (!sd) return NULL; | ||
738 | if (!sd->children) return NULL; | ||
739 | return eina_list_data_get(sd->children); | ||
740 | } | ||
741 | |||
742 | Edje_Item * | ||
743 | edje_container_item_last_get(Evas_Object *obj) | ||
744 | { | ||
745 | Smart_Data *sd; | ||
746 | |||
747 | sd = evas_object_smart_data_get(obj); | ||
748 | if (!sd) return NULL; | ||
749 | if (!sd->children) return NULL; | ||
750 | return0 eina_list_data_get(eina_list_last(sd->children)); | ||
751 | } | ||
752 | |||
753 | Edje_Item * | ||
754 | edje_container_item_nth_get(Evas_Object *obj, int n) | ||
755 | { | ||
756 | Smart_Data *sd; | ||
757 | |||
758 | sd = evas_object_smart_data_get(obj); | ||
759 | if (!sd) return NULL; | ||
760 | return eina_list_nth(sd->children, n); | ||
761 | } | ||
762 | |||
763 | void | ||
764 | edje_container_homogenous_size_set(Evas_Object *obj, int homog) | ||
765 | { | ||
766 | Smart_Data *sd; | ||
767 | |||
768 | sd = evas_object_smart_data_get(obj); | ||
769 | if (!sd) return; | ||
770 | if (((homog) && (sd->homogenous)) || | ||
771 | ((!homog) && (!sd->homogenous))) return; | ||
772 | sd->homogenous = homog; | ||
773 | sd->changed = 1; | ||
774 | sd->change_child = 1; | ||
775 | _edje_container_recalc(sd); | ||
776 | } | ||
777 | |||
778 | int | ||
779 | edje_container_homogenous_size_get(Evas_Object *obj) | ||
780 | { | ||
781 | Smart_Data *sd; | ||
782 | |||
783 | sd = evas_object_smart_data_get(obj); | ||
784 | if (!sd) return 0; | ||
785 | return sd->homogenous; | ||
786 | } | ||
787 | |||
788 | void | ||
789 | edje_container_scroll_set(Evas_Object *obj, double pos, double shift) | ||
790 | { | ||
791 | Smart_Data *sd; | ||
792 | |||
793 | sd = evas_object_smart_data_get(obj); | ||
794 | if (!sd) return; | ||
795 | if ((sd->scroll_y == pos) && (sd->scroll_x == shift)) return; | ||
796 | sd->scroll_y = pos; | ||
797 | sd->scroll_x = shift; | ||
798 | sd->need_layout = 1; | ||
799 | _edje_container_relayout(sd); | ||
800 | } | ||
801 | |||
802 | void | ||
803 | edje_container_scroll_get(Evas_Object *obj, double *pos, double *shift) | ||
804 | { | ||
805 | Smart_Data *sd; | ||
806 | |||
807 | sd = evas_object_smart_data_get(obj); | ||
808 | if (!sd) return; | ||
809 | if (pos) *pos = sd->scroll_y; | ||
810 | if (shift) *shift = sd->scroll_x; | ||
811 | } | ||
812 | |||
813 | static void _smart_init(void); | ||
814 | static void _smart_add(Evas_Object * obj); | ||
815 | static void _smart_del(Evas_Object * obj); | ||
816 | static void _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y); | ||
817 | static void _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h); | ||
818 | static void _smart_show(Evas_Object * obj); | ||
819 | static void _smart_hide(Evas_Object * obj); | ||
820 | static void _smart_color_set(Evas_Object * obj, int r, int g, int b, int a); | ||
821 | static void _smart_clip_set(Evas_Object * obj, Evas_Object * clip); | ||
822 | static void _smart_clip_unset(Evas_Object * obj); | ||
823 | |||
824 | static Evas_Smart *smart = NULL; | ||
825 | |||
826 | Evas_Object * | ||
827 | edje_container_object_add(Evas *evas) | ||
828 | { | ||
829 | _smart_init(); | ||
830 | return evas_object_smart_add(evas, smart); | ||
831 | } | ||
832 | |||
833 | /*******************************************/ | ||
834 | /* Internal smart object required routines */ | ||
835 | /*******************************************/ | ||
836 | static void | ||
837 | _smart_init(void) | ||
838 | { | ||
839 | if (smart) return; | ||
840 | { | ||
841 | static const Evas_Smart_Class sc = | ||
842 | { | ||
843 | E_OBJ_NAME, | ||
844 | _smart_add, | ||
845 | _smart_del, | ||
846 | _smart_move, | ||
847 | _smart_resize, | ||
848 | _smart_show, | ||
849 | _smart_hide, | ||
850 | _smart_color_set, | ||
851 | _smart_clip_set, | ||
852 | _smart_clip_unset, | ||
853 | NULL, | ||
854 | NULL, | ||
855 | NULL | ||
856 | }; | ||
857 | smart = evas_smart_class_new(&sc); | ||
858 | } | ||
859 | } | ||
860 | |||
861 | static void | ||
862 | _smart_add(Evas_Object *obj) | ||
863 | { | ||
864 | Smart_Data *sd; | ||
865 | |||
866 | sd = calloc(1, sizeof(Smart_Data)); | ||
867 | if (!sd) return; | ||
868 | // evas_object_smart_member_add(sd->obj, obj); | ||
869 | evas_object_smart_data_set(obj, sd); | ||
870 | sd->smart_obj = obj; | ||
871 | } | ||
872 | |||
873 | static void | ||
874 | _smart_del(Evas_Object *obj) | ||
875 | { | ||
876 | Smart_Data *sd; | ||
877 | |||
878 | sd = evas_object_smart_data_get(obj); | ||
879 | if (!sd) return; | ||
880 | if (sd->colinfo) free(sd->colinfo); | ||
881 | // evas_object_del(sd->obj); | ||
882 | free(sd); | ||
883 | } | ||
884 | |||
885 | static void | ||
886 | _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) | ||
887 | { | ||
888 | Smart_Data *sd; | ||
889 | |||
890 | sd = evas_object_smart_data_get(obj); | ||
891 | if (!sd) return; | ||
892 | // evas_object_move(sd->obj, x, y); | ||
893 | } | ||
894 | |||
895 | static void | ||
896 | _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) | ||
897 | { | ||
898 | Smart_Data *sd; | ||
899 | |||
900 | sd = evas_object_smart_data_get(obj); | ||
901 | if (!sd) return; | ||
902 | // evas_object_resize(sd->obj, w, h); | ||
903 | } | ||
904 | |||
905 | static void | ||
906 | _smart_show(Evas_Object *obj) | ||
907 | { | ||
908 | Smart_Data *sd; | ||
909 | |||
910 | sd = evas_object_smart_data_get(obj); | ||
911 | if (!sd) return; | ||
912 | // evas_object_show(sd->obj); | ||
913 | } | ||
914 | |||
915 | static void | ||
916 | _smart_hide(Evas_Object *obj) | ||
917 | { | ||
918 | Smart_Data *sd; | ||
919 | |||
920 | sd = evas_object_smart_data_get(obj); | ||
921 | if (!sd) return; | ||
922 | // evas_object_hide(sd->obj); | ||
923 | } | ||
924 | |||
925 | static void | ||
926 | _smart_color_set(Evas_Object *obj, int r, int g, int b, int a) | ||
927 | { | ||
928 | Smart_Data *sd; | ||
929 | |||
930 | sd = evas_object_smart_data_get(obj); | ||
931 | if (!sd) return; | ||
932 | // evas_object_color_set(sd->obj, r, g, b, a); | ||
933 | } | ||
934 | |||
935 | static void | ||
936 | _smart_clip_set(Evas_Object *obj, Evas_Object *clip) | ||
937 | { | ||
938 | Smart_Data *sd; | ||
939 | |||
940 | sd = evas_object_smart_data_get(obj); | ||
941 | if (!sd) return; | ||
942 | // evas_object_clip_set(sd->obj, clip); | ||
943 | } | ||
944 | |||
945 | static void | ||
946 | _smart_clip_unset(Evas_Object *obj) | ||
947 | { | ||
948 | Smart_Data *sd; | ||
949 | |||
950 | sd = evas_object_smart_data_get(obj); | ||
951 | if (!sd) return; | ||
952 | // evas_object_clip_unset(sd->obj); | ||
953 | } | ||
954 | |||
955 | #endif | ||