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_content_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",
117 elm_app_data_dir_get());
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__,
126 Evas_Object *obj __UNUSED__,
128 void *item __UNUSED__)
130 Evas_Object *ic = elm_icon_add(tt);
132 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
133 elm_icon_file_set(ic, buf, NULL);
134 elm_icon_scale_set(ic, 0, 0);
139 _tt_item_icon3(void *data __UNUSED__,
140 Evas_Object *obj __UNUSED__,
142 void *item __UNUSED__)
144 Evas_Object *ic = elm_icon_add(tt);
146 snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
147 elm_icon_file_set(ic, buf, NULL);
148 elm_icon_scale_set(ic, 0, 0);
153 _tt_item_label(void *data __UNUSED__,
154 Evas_Object *obj __UNUSED__,
156 void *item __UNUSED__)
158 Evas_Object *l = elm_label_add(tt);
159 elm_object_text_set(l, "Something useful here?<ps>"
160 "No probably not, but this is a super long label<ps>"
161 "which probably breaks on your system, now doesn't it?<ps>"
162 "Yeah, I thought so.");
163 elm_label_line_wrap_set(l, ELM_WRAP_MIXED);
168 _tt_item_icon_del(void *data,
169 Evas_Object *obj __UNUSED__,
172 // test to check for del_cb behavior!
173 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
174 (long)data, event_info);
178 _tt_text_replace(void *data __UNUSED__,
180 void *event_info __UNUSED__)
182 static int count = 0;
184 snprintf(buf, sizeof(buf), "count=%d", count);
186 elm_object_tooltip_text_set(obj, buf);
190 _tt_timer_del(void *data __UNUSED__,
193 void *event_info __UNUSED__)
195 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
197 ecore_timer_del(timer);
201 _tt_text_replace_timer_cb(void *data)
203 _tt_text_replace(NULL, data, NULL);
208 _tt_text_replace_timed(void *data __UNUSED__,
210 void *event_info __UNUSED__)
212 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
215 ecore_timer_del(timer);
216 evas_object_data_del(obj, "test-timer");
217 elm_object_text_set(obj, "Simple text tooltip, click to start"
222 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
223 evas_object_data_set(obj, "test-timer", timer);
224 elm_object_text_set(obj, "Simple text tooltip, click to stop changed"
229 _tt_icon(void *data __UNUSED__,
232 Evas_Object *ic = elm_icon_add(obj);
234 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
235 elm_app_data_dir_get());
236 elm_icon_file_set(ic, buf, NULL);
237 elm_icon_scale_set(ic, 0, 0);
238 evas_object_resize(ic, 64, 64);
243 _tt_icon2(void *data __UNUSED__,
246 Evas_Object *ic = elm_icon_add(obj);
248 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
249 elm_icon_file_set(ic, buf, NULL);
250 elm_icon_scale_set(ic, 0, 0);
251 evas_object_resize(ic, 64, 64);
256 _tt_icon_del(void *data,
257 Evas_Object *obj __UNUSED__,
260 // test to check for del_cb behavior!
261 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
262 (long)data, event_info);
266 _tt_icon_replace_timer_cb(void *data)
268 static int current = 0;
270 elm_object_tooltip_content_cb_set
271 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
278 _tt_icon_replace_timed(void *data __UNUSED__,
280 void *event_info __UNUSED__)
282 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
285 ecore_timer_del(timer);
286 evas_object_data_del(obj, "test-timer");
287 elm_object_text_set(obj, "Icon tooltip, click to start changed"
292 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
293 evas_object_data_set(obj, "test-timer", timer);
294 elm_object_text_set(obj, "Icon tooltip, click to stop changed timed");
298 _tt_style_replace_timer_cb(void *data)
300 static int current = 0;
301 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
307 _tt_style_replace_timed(void *data __UNUSED__,
309 void *event_info __UNUSED__)
311 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
314 ecore_timer_del(timer);
315 evas_object_data_del(obj, "test-timer");
316 elm_object_text_set(obj, "Icon tooltip style, click to start"
321 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
322 evas_object_data_set(obj, "test-timer", timer);
323 elm_object_text_set(obj, "Icon tooltip style, click to stop changed"
328 _tt_visible_lock_toggle(void *data __UNUSED__,
330 void *event_info __UNUSED__)
332 static int locked = 0;
337 elm_object_text_set(obj, "Locked tooltip visibility");
338 elm_object_tooltip_text_set(obj, "This tooltip is locked"
339 " visible,<br> click the button"
341 elm_object_tooltip_show(obj);
345 elm_object_text_set(obj, "Unlocked tooltip visibility");
346 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
347 " visible,<br> click the button"
349 elm_object_tooltip_hide(obj);
354 test_tooltip(void *data __UNUSED__,
355 Evas_Object *obj __UNUSED__,
356 void *event_info __UNUSED__)
358 Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
359 Elm_Toolbar_Item *ti;
362 win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
363 elm_win_title_set(win, "Tooltip");
364 elm_win_autodel_set(win, EINA_TRUE);
366 bg = elm_bg_add(win);
367 elm_win_resize_object_add(win, bg);
368 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
370 evas_object_show(bg);
372 bx = elm_box_add(win);
373 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
375 elm_win_resize_object_add(win, bx);
376 evas_object_show(bx);
378 tb = elm_toolbar_add(win);
379 elm_toolbar_homogeneous_set(tb, 0);
380 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
381 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
382 elm_box_pack_end(bx, tb);
383 evas_object_show(tb);
385 ti = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
386 elm_toolbar_item_tooltip_text_set(ti, "Opens a file");
388 ti = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
389 elm_toolbar_item_tooltip_content_cb_set
390 (ti, _tt_item_icon, (void *)456L, _tt_item_icon_del);
391 elm_toolbar_item_tooltip_style_set(ti, "transparent");
393 bt = elm_button_add(win);
394 elm_object_text_set(bt, "Simple text tooltip");
395 elm_object_tooltip_text_set(bt, "Simple text tooltip");
396 elm_box_pack_end(bx, bt);
397 evas_object_show(bt);
399 bt = elm_button_add(win);
400 elm_object_text_set(bt, "Simple text tooltip, click to change");
401 elm_object_tooltip_text_set(bt, "Initial");
402 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
403 elm_box_pack_end(bx, bt);
404 evas_object_show(bt);
406 bt = elm_button_add(win);
407 elm_object_text_set(bt, "Simple text tooltip, click to start"
409 elm_object_tooltip_text_set(bt, "Initial");
410 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
412 elm_box_pack_end(bx, bt);
413 evas_object_show(bt);
414 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
417 bt = elm_button_add(win);
418 elm_object_text_set(bt, "Icon tooltip");
419 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
421 elm_box_pack_end(bx, bt);
422 evas_object_show(bt);
424 bt = elm_button_add(win);
425 elm_object_text_set(bt, "Icon tooltip, click to start changed timed");
426 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
427 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
429 elm_box_pack_end(bx, bt);
430 evas_object_show(bt);
431 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
434 bt = elm_button_add(win);
435 elm_object_text_set(bt, "Transparent Icon tooltip");
436 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
437 elm_object_tooltip_style_set(bt, "transparent");
438 elm_box_pack_end(bx, bt);
439 evas_object_show(bt);
441 bt = elm_button_add(win);
442 elm_object_text_set(bt, "Icon tooltip style, click to start changed"
444 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
445 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
447 elm_box_pack_end(bx, bt);
448 evas_object_show(bt);
449 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
452 bt = elm_button_add(win);
453 elm_object_text_set(bt, "Unlocked tooltip visibility");
454 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br>"
455 " click the button to lock!");
456 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
458 elm_box_pack_end(bx, bt);
459 evas_object_show(bt);
461 se = elm_entry_add(win);
462 elm_entry_scrollable_set(se, EINA_TRUE);
463 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
464 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
465 elm_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF,
466 ELM_SCROLLER_POLICY_OFF);
467 elm_entry_entry_set(se, "Hello, some scrolled entry here!");
468 elm_object_tooltip_text_set(se, "Type something here!");
469 elm_entry_single_line_set(se, 1);
470 elm_box_pack_end(bx, se);
471 evas_object_show(se);
473 lst = elm_list_add(win);
474 li = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
475 elm_list_item_tooltip_text_set(li, "Something useful here?");
476 li = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
477 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL);
478 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
480 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
481 evas_object_size_hint_min_set(lst, 100, 100);
483 elm_box_pack_end(bx, lst);
484 evas_object_show(lst);
486 evas_object_resize(win, 320, 580);
487 evas_object_show(win);
491 test_tooltip2(void *data __UNUSED__,
492 Evas_Object *obj __UNUSED__,
493 void *event_info __UNUSED__)
495 Evas_Object *win, *bg, *bx, *grid, *gl;
496 Elm_Genlist_Item *it1, *it2, *it3;
497 static Testitem ti[144];
513 win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC);
514 elm_win_title_set(win, "Tooltip 2");
515 elm_win_autodel_set(win, EINA_TRUE);
517 bg = elm_bg_add(win);
518 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
520 elm_win_resize_object_add(win, bg);
521 evas_object_show(bg);
523 bx = elm_box_add(win);
524 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
526 elm_win_resize_object_add(win, bx);
527 evas_object_show(bx);
529 grid = elm_gengrid_add(win);
530 elm_gengrid_item_size_set(grid, 100, 100);
531 elm_gengrid_horizontal_set(grid, EINA_FALSE);
532 elm_gengrid_multi_select_set(grid, EINA_TRUE);
533 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
534 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
537 gic.item_style = "default";
538 gic.func.label_get = grdt_lbl_get;
539 gic.func.content_get = grdt_content_get;
542 for (i = 0; i < 9; i++)
544 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(),
548 ti[i].path = eina_stringshare_add(buf);
549 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
552 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
554 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
556 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
559 elm_box_pack_end(bx, grid);
560 evas_object_show(grid);
562 gl = elm_genlist_add(win);
563 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
564 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
567 itct.item_style = "default";
568 itct.func.label_get = gltt_label_get;
570 it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
571 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
572 it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
573 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
574 it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
575 ELM_GENLIST_ITEM_NONE, NULL, NULL);
577 elm_genlist_item_tooltip_text_set(it1, "Testing 1");
578 elm_genlist_item_tooltip_text_set(it2, "Testing 2");
579 elm_genlist_item_tooltip_text_set(it3, "Testing 3");
581 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
582 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
584 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
585 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
587 elm_box_pack_end(bx, gl);
588 evas_object_show(gl);
590 evas_object_resize(win, 320, 480);
591 evas_object_show(win);