1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 typedef struct _Testitem
9 Elm_Gengrid_Item *item;
15 static Elm_Gengrid_Item_Class gic;
18 grdt_lbl_get(void *data,
19 Evas_Object *obj __UNUSED__,
20 const char *part __UNUSED__)
22 const Testitem *ti = data;
24 snprintf(buf, sizeof(buf), "Photo %s", ti->path);
29 grdt_icon_get(void *data,
33 const Testitem *ti = data;
34 if (!strcmp(part, "elm.swallow.icon"))
36 Evas_Object *icon = elm_bg_add(obj);
37 elm_bg_file_set(icon, ti->path, NULL);
38 evas_object_size_hint_aspect_set(icon,
39 EVAS_ASPECT_CONTROL_VERTICAL,
41 evas_object_show(icon);
47 static Elm_Genlist_Item_Class itct;
50 gltt_exp(void *data __UNUSED__,
51 Evas_Object *obj __UNUSED__,
54 Elm_Genlist_Item *it = event_info;
55 Evas_Object *gl = elm_genlist_item_genlist_get(it);
56 int val = (int)(long)elm_genlist_item_data_get(it);
57 Elm_Genlist_Item *it1, *it2, *it3;
60 it1 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 1), it,
61 ELM_GENLIST_ITEM_NONE, NULL, NULL);
62 it2 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 2), it,
63 ELM_GENLIST_ITEM_NONE, NULL, NULL);
64 it3 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 3), it,
65 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
67 elm_genlist_item_tooltip_text_set(it1, "Testing A");
68 elm_genlist_item_tooltip_text_set(it2, "Testing B");
69 elm_genlist_item_tooltip_text_set(it3, "Testing C");
73 gltt_con(void *data __UNUSED__,
74 Evas_Object *obj __UNUSED__,
77 Elm_Genlist_Item *it = event_info;
78 elm_genlist_item_subitems_clear(it);
82 gltt_exp_req(void *data __UNUSED__,
83 Evas_Object *obj __UNUSED__,
86 Elm_Genlist_Item *it = event_info;
87 elm_genlist_item_expanded_set(it, 1);
91 gltt_con_req(void *data __UNUSED__,
92 Evas_Object *obj __UNUSED__,
95 Elm_Genlist_Item *it = event_info;
96 elm_genlist_item_expanded_set(it, 0);
100 gltt_label_get(void *data,
101 Evas_Object *obj __UNUSED__,
102 const char *part __UNUSED__)
105 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
110 _tt_item_icon(void *data __UNUSED__,
112 void *item __UNUSED__)
114 Evas_Object *ic = elm_icon_add(obj);
116 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
118 elm_icon_file_set(ic, buf, NULL);
119 elm_icon_scale_set(ic, 0, 0);
120 evas_object_resize(ic, 64, 64);
125 _tt_item_icon2(void *data __UNUSED__,
127 void *item __UNUSED__)
129 Evas_Object *ic = elm_icon_add(obj);
131 snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
132 elm_icon_file_set(ic, buf, NULL);
133 elm_icon_scale_set(ic, 0, 0);
138 _tt_item_icon_del(void *data,
139 Evas_Object *obj __UNUSED__,
142 // test to check for del_cb behavior!
143 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
144 (long)data, event_info);
148 _tt_text_replace(void *data __UNUSED__,
150 void *event_info __UNUSED__)
152 static int count = 0;
154 snprintf(buf, sizeof(buf), "count=%d", count);
156 elm_object_tooltip_text_set(obj, buf);
160 _tt_timer_del(void *data __UNUSED__,
163 void *event_info __UNUSED__)
165 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
167 ecore_timer_del(timer);
171 _tt_text_replace_timer_cb(void *data)
173 _tt_text_replace(NULL, data, NULL);
178 _tt_text_replace_timed(void *data __UNUSED__,
180 void *event_info __UNUSED__)
182 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
185 ecore_timer_del(timer);
186 evas_object_data_del(obj, "test-timer");
187 elm_object_text_set(obj, "Simple text tooltip, click to start"
192 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
193 evas_object_data_set(obj, "test-timer", timer);
194 elm_object_text_set(obj, "Simple text tooltip, click to stop changed"
199 _tt_icon(void *data __UNUSED__,
202 Evas_Object *ic = elm_icon_add(obj);
204 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
206 elm_icon_file_set(ic, buf, NULL);
207 elm_icon_scale_set(ic, 0, 0);
208 evas_object_resize(ic, 64, 64);
213 _tt_icon2(void *data __UNUSED__,
216 Evas_Object *ic = elm_icon_add(obj);
218 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", PACKAGE_DATA_DIR);
219 elm_icon_file_set(ic, buf, NULL);
220 elm_icon_scale_set(ic, 0, 0);
221 evas_object_resize(ic, 64, 64);
226 _tt_icon_del(void *data,
227 Evas_Object *obj __UNUSED__,
230 // test to check for del_cb behavior!
231 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
232 (long)data, event_info);
236 _tt_icon_replace_timer_cb(void *data)
238 static int current = 0;
240 elm_object_tooltip_content_cb_set
241 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
248 _tt_icon_replace_timed(void *data __UNUSED__,
250 void *event_info __UNUSED__)
252 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
255 ecore_timer_del(timer);
256 evas_object_data_del(obj, "test-timer");
257 elm_object_text_set(obj, "Icon tooltip, click to start changed"
262 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
263 evas_object_data_set(obj, "test-timer", timer);
264 elm_object_text_set(obj, "Icon tooltip, click to stop changed timed");
268 _tt_style_replace_timer_cb(void *data)
270 static int current = 0;
271 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
277 _tt_style_replace_timed(void *data __UNUSED__,
279 void *event_info __UNUSED__)
281 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
284 ecore_timer_del(timer);
285 evas_object_data_del(obj, "test-timer");
286 elm_object_text_set(obj, "Icon tooltip style, click to start"
291 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
292 evas_object_data_set(obj, "test-timer", timer);
293 elm_object_text_set(obj, "Icon tooltip style, click to stop changed"
298 _tt_visible_lock_toggle(void *data __UNUSED__,
300 void *event_info __UNUSED__)
302 static int locked = 0;
307 elm_object_text_set(obj, "Locked tooltip visibility");
308 elm_object_tooltip_text_set(obj, "This tooltip is locked"
309 " visible,<br> click the button"
311 elm_object_tooltip_show(obj);
315 elm_object_text_set(obj, "Unlocked tooltip visibility");
316 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
317 " visible,<br> click the button"
319 elm_object_tooltip_hide(obj);
324 test_tooltip(void *data __UNUSED__,
325 Evas_Object *obj __UNUSED__,
326 void *event_info __UNUSED__)
328 Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
329 Elm_Toolbar_Item *ti;
332 win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
333 elm_win_title_set(win, "Tooltip");
334 elm_win_autodel_set(win, 1);
336 bg = elm_bg_add(win);
337 elm_win_resize_object_add(win, bg);
338 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
340 evas_object_show(bg);
342 bx = elm_box_add(win);
343 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
345 elm_win_resize_object_add(win, bx);
346 evas_object_show(bx);
348 tb = elm_toolbar_add(win);
349 elm_toolbar_homogeneous_set(tb, 0);
350 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
351 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
352 elm_box_pack_end(bx, tb);
353 evas_object_show(tb);
355 ti = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
356 elm_toolbar_item_tooltip_text_set(ti, "Opens a file");
358 ti = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
359 elm_toolbar_item_tooltip_content_cb_set
360 (ti, _tt_item_icon, (void *)456L, _tt_item_icon_del);
361 elm_toolbar_item_tooltip_style_set(ti, "transparent");
363 bt = elm_button_add(win);
364 elm_object_text_set(bt, "Simple text tooltip");
365 elm_object_tooltip_text_set(bt, "Simple text tooltip");
366 elm_box_pack_end(bx, bt);
367 evas_object_show(bt);
369 bt = elm_button_add(win);
370 elm_object_text_set(bt, "Simple text tooltip, click to change");
371 elm_object_tooltip_text_set(bt, "Initial");
372 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
373 elm_box_pack_end(bx, bt);
374 evas_object_show(bt);
376 bt = elm_button_add(win);
377 elm_object_text_set(bt, "Simple text tooltip, click to start"
379 elm_object_tooltip_text_set(bt, "Initial");
380 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
382 elm_box_pack_end(bx, bt);
383 evas_object_show(bt);
384 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
387 bt = elm_button_add(win);
388 elm_object_text_set(bt, "Icon tooltip");
389 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
391 elm_box_pack_end(bx, bt);
392 evas_object_show(bt);
394 bt = elm_button_add(win);
395 elm_object_text_set(bt, "Icon tooltip, click to start changed timed");
396 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
397 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
399 elm_box_pack_end(bx, bt);
400 evas_object_show(bt);
401 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
404 bt = elm_button_add(win);
405 elm_object_text_set(bt, "Transparent Icon tooltip");
406 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
407 elm_object_tooltip_style_set(bt, "transparent");
408 elm_box_pack_end(bx, bt);
409 evas_object_show(bt);
411 bt = elm_button_add(win);
412 elm_object_text_set(bt, "Icon tooltip style, click to start changed"
414 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
415 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
417 elm_box_pack_end(bx, bt);
418 evas_object_show(bt);
419 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
422 bt = elm_button_add(win);
423 elm_object_text_set(bt, "Unlocked tooltip visibility");
424 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br>"
425 " click the button to lock!");
426 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
428 elm_box_pack_end(bx, bt);
429 evas_object_show(bt);
431 se = elm_entry_add(win);
432 elm_entry_scrollable_set(se, EINA_TRUE);
433 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
434 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
435 elm_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF,
436 ELM_SCROLLER_POLICY_OFF);
437 elm_entry_entry_set(se, "Hello, some scrolled entry here!");
438 elm_object_tooltip_text_set(se, "Type something here!");
439 elm_entry_single_line_set(se, 1);
440 elm_box_pack_end(bx, se);
441 evas_object_show(se);
443 lst = elm_list_add(win);
444 li = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
445 elm_list_item_tooltip_text_set(li, "Something useful here?");
446 li = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
447 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL);
448 li = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL);
449 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon2, NULL, NULL);
450 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
452 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
453 evas_object_size_hint_min_set(lst, 100, 100);
455 elm_box_pack_end(bx, lst);
456 evas_object_show(lst);
458 evas_object_resize(win, 320, 580);
459 evas_object_show(win);
463 test_tooltip2(void *data __UNUSED__,
464 Evas_Object *obj __UNUSED__,
465 void *event_info __UNUSED__)
467 Evas_Object *win, *bg, *bx, *grid, *gl;
468 Elm_Genlist_Item *it1, *it2, *it3;
469 static Testitem ti[144];
485 win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC);
486 elm_win_title_set(win, "Tooltip 2");
487 elm_win_autodel_set(win, 1);
489 bg = elm_bg_add(win);
490 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
492 elm_win_resize_object_add(win, bg);
493 evas_object_show(bg);
495 bx = elm_box_add(win);
496 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
498 elm_win_resize_object_add(win, bx);
499 evas_object_show(bx);
501 grid = elm_gengrid_add(win);
502 elm_gengrid_item_size_set(grid, 100, 100);
503 elm_gengrid_horizontal_set(grid, EINA_FALSE);
504 elm_gengrid_multi_select_set(grid, EINA_TRUE);
505 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
506 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
509 gic.item_style = "default";
510 gic.func.label_get = grdt_lbl_get;
511 gic.func.icon_get = grdt_icon_get;
514 for (i = 0; i < 9; i++)
516 snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR,
520 ti[i].path = eina_stringshare_add(buf);
521 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
524 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
526 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
528 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
531 elm_box_pack_end(bx, grid);
532 evas_object_show(grid);
534 gl = elm_genlist_add(win);
535 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
536 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
539 itct.item_style = "default";
540 itct.func.label_get = gltt_label_get;
542 it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
543 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
544 it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
545 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
546 it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
547 ELM_GENLIST_ITEM_NONE, NULL, NULL);
549 elm_genlist_item_tooltip_text_set(it1, "Testing 1");
550 elm_genlist_item_tooltip_text_set(it2, "Testing 2");
551 elm_genlist_item_tooltip_text_set(it3, "Testing 3");
553 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
554 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
556 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
557 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
559 elm_box_pack_end(bx, gl);
560 evas_object_show(gl);
562 evas_object_resize(win, 320, 480);
563 evas_object_show(win);