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_gen_item_widget_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__,
111 Evas_Object *obj __UNUSED__,
113 void *item __UNUSED__)
115 Evas_Object *ic = elm_icon_add(tt);
117 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
118 elm_app_data_dir_get());
119 elm_icon_file_set(ic, buf, NULL);
120 elm_icon_scale_set(ic, 0, 0);
121 evas_object_resize(ic, 64, 64);
126 _tt_item_icon2(void *data __UNUSED__,
127 Evas_Object *obj __UNUSED__,
129 void *item __UNUSED__)
131 Evas_Object *ic = elm_icon_add(tt);
133 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
134 elm_icon_file_set(ic, buf, NULL);
135 elm_icon_scale_set(ic, 0, 0);
140 _tt_item_icon3(void *data __UNUSED__,
141 Evas_Object *obj __UNUSED__,
143 void *item __UNUSED__)
145 Evas_Object *ic = elm_icon_add(tt);
147 snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
148 elm_icon_file_set(ic, buf, NULL);
149 elm_icon_scale_set(ic, 0, 0);
154 _tt_item_label(void *data __UNUSED__,
155 Evas_Object *obj __UNUSED__,
157 void *item __UNUSED__)
159 Evas_Object *l = elm_label_add(tt);
160 elm_object_text_set(l, "Something useful here?<ps>"
161 "No probably not, but this is a super long label<ps>"
162 "which probably breaks on your system, now doesn't it?<ps>"
163 "Yeah, I thought so.");
164 elm_label_line_wrap_set(l, ELM_WRAP_MIXED);
169 _tt_item_icon_del(void *data,
170 Evas_Object *obj __UNUSED__,
173 // test to check for del_cb behavior!
174 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
175 (long)data, event_info);
179 _tt_text_replace(void *data __UNUSED__,
181 void *event_info __UNUSED__)
183 static int count = 0;
185 snprintf(buf, sizeof(buf), "count=%d", count);
187 elm_object_tooltip_text_set(obj, buf);
191 _tt_timer_del(void *data __UNUSED__,
194 void *event_info __UNUSED__)
196 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
198 ecore_timer_del(timer);
202 _tt_text_replace_timer_cb(void *data)
204 _tt_text_replace(NULL, data, NULL);
209 _tt_text_replace_timed(void *data __UNUSED__,
211 void *event_info __UNUSED__)
213 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
216 ecore_timer_del(timer);
217 evas_object_data_del(obj, "test-timer");
218 elm_object_text_set(obj, "Simple text tooltip, click to start"
223 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
224 evas_object_data_set(obj, "test-timer", timer);
225 elm_object_text_set(obj, "Simple text tooltip, click to stop changed"
230 _tt_icon(void *data __UNUSED__,
231 Evas_Object *obj __UNUSED__,
234 Evas_Object *ic = elm_icon_add(tt);
236 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
237 elm_app_data_dir_get());
238 elm_icon_file_set(ic, buf, NULL);
239 elm_icon_scale_set(ic, 0, 0);
240 evas_object_resize(ic, 64, 64);
245 _tt_icon2(void *data __UNUSED__,
246 Evas_Object *obj __UNUSED__,
249 Evas_Object *ic = elm_icon_add(tt);
251 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
252 elm_icon_file_set(ic, buf, NULL);
253 elm_icon_scale_set(ic, 0, 0);
254 evas_object_resize(ic, 64, 64);
259 _tt_icon_del(void *data,
260 Evas_Object *obj __UNUSED__,
263 // test to check for del_cb behavior!
264 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
265 (long)data, event_info);
269 _tt_icon_replace_timer_cb(void *data)
271 static int current = 0;
273 elm_object_tooltip_content_cb_set
274 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
281 _tt_icon_replace_timed(void *data __UNUSED__,
283 void *event_info __UNUSED__)
285 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
288 ecore_timer_del(timer);
289 evas_object_data_del(obj, "test-timer");
290 elm_object_text_set(obj, "Icon tooltip, click to start changed"
295 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
296 evas_object_data_set(obj, "test-timer", timer);
297 elm_object_text_set(obj, "Icon tooltip, click to stop changed timed");
301 _tt_style_replace_timer_cb(void *data)
303 static int current = 0;
304 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
310 _tt_style_replace_timed(void *data __UNUSED__,
312 void *event_info __UNUSED__)
314 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
317 ecore_timer_del(timer);
318 evas_object_data_del(obj, "test-timer");
319 elm_object_text_set(obj, "Icon tooltip style, click to start"
324 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
325 evas_object_data_set(obj, "test-timer", timer);
326 elm_object_text_set(obj, "Icon tooltip style, click to stop changed"
331 _tt_visible_lock_toggle(void *data __UNUSED__,
333 void *event_info __UNUSED__)
335 static int locked = 0;
340 elm_object_text_set(obj, "Locked tooltip visibility");
341 elm_object_tooltip_text_set(obj, "This tooltip is locked"
342 " visible,<br> click the button"
344 elm_object_tooltip_show(obj);
348 elm_object_text_set(obj, "Unlocked tooltip visibility");
349 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
350 " visible,<br> click the button"
352 elm_object_tooltip_hide(obj);
357 test_tooltip(void *data __UNUSED__,
358 Evas_Object *obj __UNUSED__,
359 void *event_info __UNUSED__)
361 Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
362 Elm_Toolbar_Item *ti;
365 win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
366 elm_win_title_set(win, "Tooltip");
367 elm_win_autodel_set(win, EINA_TRUE);
369 bg = elm_bg_add(win);
370 elm_win_resize_object_add(win, bg);
371 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
373 evas_object_show(bg);
375 bx = elm_box_add(win);
376 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
378 elm_win_resize_object_add(win, bx);
379 evas_object_show(bx);
381 tb = elm_toolbar_add(win);
382 elm_toolbar_homogeneous_set(tb, 0);
383 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
384 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
385 elm_box_pack_end(bx, tb);
386 evas_object_show(tb);
388 ti = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
389 elm_toolbar_item_tooltip_text_set(ti, "Opens a file");
391 ti = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
392 elm_toolbar_item_tooltip_content_cb_set
393 (ti, _tt_item_icon, (void *)456L, _tt_item_icon_del);
394 elm_toolbar_item_tooltip_style_set(ti, "transparent");
396 bt = elm_button_add(win);
397 elm_object_text_set(bt, "Simple text tooltip");
398 elm_object_tooltip_text_set(bt, "Simple text tooltip");
399 elm_box_pack_end(bx, bt);
400 evas_object_show(bt);
402 bt = elm_button_add(win);
403 elm_object_text_set(bt, "Simple text tooltip, click to change");
404 elm_object_tooltip_text_set(bt, "Initial");
405 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
406 elm_box_pack_end(bx, bt);
407 evas_object_show(bt);
409 bt = elm_button_add(win);
410 elm_object_text_set(bt, "Simple text tooltip, click to start"
412 elm_object_tooltip_text_set(bt, "Initial");
413 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
415 elm_box_pack_end(bx, bt);
416 evas_object_show(bt);
417 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
420 bt = elm_button_add(win);
421 elm_object_text_set(bt, "Icon tooltip");
422 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
424 elm_box_pack_end(bx, bt);
425 evas_object_show(bt);
427 bt = elm_button_add(win);
428 elm_object_text_set(bt, "Icon tooltip, click to start changed timed");
429 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
430 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
432 elm_box_pack_end(bx, bt);
433 evas_object_show(bt);
434 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
437 bt = elm_button_add(win);
438 elm_object_text_set(bt, "Transparent Icon tooltip");
439 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
440 elm_object_tooltip_style_set(bt, "transparent");
441 elm_box_pack_end(bx, bt);
442 evas_object_show(bt);
444 bt = elm_button_add(win);
445 elm_object_text_set(bt, "Icon tooltip style, click to start changed"
447 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
448 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
450 elm_box_pack_end(bx, bt);
451 evas_object_show(bt);
452 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
455 bt = elm_button_add(win);
456 elm_object_text_set(bt, "Unlocked tooltip visibility");
457 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br>"
458 " click the button to lock!");
459 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
461 elm_box_pack_end(bx, bt);
462 evas_object_show(bt);
464 se = elm_entry_add(win);
465 elm_entry_scrollable_set(se, EINA_TRUE);
466 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
467 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
468 elm_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF,
469 ELM_SCROLLER_POLICY_OFF);
470 elm_entry_entry_set(se, "Hello, some scrolled entry here!");
471 elm_object_tooltip_text_set(se, "Type something here!");
472 elm_entry_single_line_set(se, 1);
473 elm_box_pack_end(bx, se);
474 evas_object_show(se);
476 lst = elm_list_add(win);
477 li = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
478 elm_list_item_tooltip_content_cb_set(li, _tt_item_label, NULL, NULL);
479 elm_list_item_tooltip_size_restrict_disable(li, EINA_TRUE);
480 li = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
481 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL);
482 li = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL);
483 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon2, NULL, NULL);
484 elm_list_item_tooltip_style_set(li, "transparent");
485 elm_list_item_tooltip_size_restrict_disable(li, EINA_TRUE);
486 li = elm_list_item_append(lst, "Insanely Big Icon Tooltip", NULL, NULL, NULL, NULL);
487 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon3, NULL, NULL);
488 elm_list_item_tooltip_style_set(li, "transparent");
489 elm_list_item_tooltip_size_restrict_disable(li, EINA_TRUE);
490 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
492 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
493 evas_object_size_hint_min_set(lst, 100, 100);
495 elm_box_pack_end(bx, lst);
496 evas_object_show(lst);
498 evas_object_resize(win, 320, 580);
499 evas_object_show(win);
503 test_tooltip2(void *data __UNUSED__,
504 Evas_Object *obj __UNUSED__,
505 void *event_info __UNUSED__)
507 Evas_Object *win, *bg, *bx, *grid, *gl;
508 Elm_Genlist_Item *it1, *it2, *it3;
509 static Testitem ti[144];
525 win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC);
526 elm_win_title_set(win, "Tooltip 2");
527 elm_win_autodel_set(win, EINA_TRUE);
529 bg = elm_bg_add(win);
530 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
532 elm_win_resize_object_add(win, bg);
533 evas_object_show(bg);
535 bx = elm_box_add(win);
536 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
538 elm_win_resize_object_add(win, bx);
539 evas_object_show(bx);
541 grid = elm_gengrid_add(win);
542 elm_gengrid_item_size_set(grid, 100, 100);
543 elm_gengrid_horizontal_set(grid, EINA_FALSE);
544 elm_gengrid_multi_select_set(grid, EINA_TRUE);
545 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
546 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
549 gic.item_style = "default";
550 gic.func.label_get = grdt_lbl_get;
551 gic.func.icon_get = grdt_icon_get;
554 for (i = 0; i < 9; i++)
556 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(),
560 ti[i].path = eina_stringshare_add(buf);
561 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
564 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
566 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
568 elm_gen_item_selected_set(ti[i].item, EINA_TRUE);
571 elm_box_pack_end(bx, grid);
572 evas_object_show(grid);
574 gl = elm_genlist_add(win);
575 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
576 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
579 itct.item_style = "default";
580 itct.func.label_get = gltt_label_get;
582 it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
583 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
584 it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
585 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
586 it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
587 ELM_GENLIST_ITEM_NONE, NULL, NULL);
589 elm_genlist_item_tooltip_text_set(it1, "Testing 1");
590 elm_genlist_item_tooltip_text_set(it2, "Testing 2");
591 elm_genlist_item_tooltip_text_set(it3, "Testing 3");
593 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
594 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
596 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
597 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
599 elm_box_pack_end(bx, gl);
600 evas_object_show(gl);
602 evas_object_resize(win, 320, 480);
603 evas_object_show(win);