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_text_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__)
146 Evas_Object *ic = elm_icon_add(tt);
149 snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
150 elm_icon_file_set(ic, buf, NULL);
151 elm_icon_size_get(ic, &w, &h);
152 elm_win_screen_size_get(tt, NULL, NULL, &sw, &sh);
153 if ((w > sw) || (h > sh))
156 if ((float)w / (float)sw >= 0.8)
157 sc = ((float)sw * 0.8) / (float)w;
158 else if ((float)h / (float)sh >= 0.8)
159 sc = ((float)sh * 0.8) / (float)h;
160 if (sc) elm_object_scale_set(ic, sc);
166 _tt_item_label(void *data __UNUSED__,
167 Evas_Object *obj __UNUSED__,
169 void *item __UNUSED__)
171 Evas_Object *l = elm_label_add(tt);
172 elm_object_text_set(l, "Something useful here?<ps>"
173 "No probably not, but this is a super long label<ps>"
174 "which probably breaks on your system, now doesn't it?<ps>"
175 "Yeah, I thought so.");
176 elm_label_line_wrap_set(l, ELM_WRAP_MIXED);
181 _tt_item_icon_del(void *data,
182 Evas_Object *obj __UNUSED__,
185 // test to check for del_cb behavior!
186 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
187 (long)data, event_info);
191 _tt_text_replace(void *data __UNUSED__,
193 void *event_info __UNUSED__)
195 static int count = 0;
197 snprintf(buf, sizeof(buf), "count=%d", count);
199 elm_object_tooltip_text_set(obj, buf);
203 _tt_timer_del(void *data __UNUSED__,
206 void *event_info __UNUSED__)
208 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
210 ecore_timer_del(timer);
214 _tt_text_replace_timer_cb(void *data)
216 _tt_text_replace(NULL, data, NULL);
221 _tt_text_replace_timed(void *data __UNUSED__,
223 void *event_info __UNUSED__)
225 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
228 ecore_timer_del(timer);
229 evas_object_data_del(obj, "test-timer");
230 elm_object_text_set(obj, "Simple text tooltip, click to start"
235 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
236 evas_object_data_set(obj, "test-timer", timer);
237 elm_object_text_set(obj, "Simple text tooltip, click to stop changed"
242 _tt_icon(void *data __UNUSED__,
243 Evas_Object *obj __UNUSED__,
246 Evas_Object *ic = elm_icon_add(tt);
248 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
249 elm_app_data_dir_get());
250 elm_icon_file_set(ic, buf, NULL);
251 elm_icon_scale_set(ic, 0, 0);
252 evas_object_resize(ic, 64, 64);
257 _tt_icon2(void *data __UNUSED__,
258 Evas_Object *obj __UNUSED__,
261 Evas_Object *ic = elm_icon_add(tt);
263 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
264 elm_icon_file_set(ic, buf, NULL);
265 elm_icon_scale_set(ic, 0, 0);
266 evas_object_resize(ic, 64, 64);
271 _tt_icon_del(void *data,
272 Evas_Object *obj __UNUSED__,
275 // test to check for del_cb behavior!
276 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
277 (long)data, event_info);
281 _tt_icon_replace_timer_cb(void *data)
283 static int current = 0;
285 elm_object_tooltip_content_cb_set
286 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
293 _tt_icon_replace_timed(void *data __UNUSED__,
295 void *event_info __UNUSED__)
297 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
300 ecore_timer_del(timer);
301 evas_object_data_del(obj, "test-timer");
302 elm_object_text_set(obj, "Icon tooltip, click to start changed"
307 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
308 evas_object_data_set(obj, "test-timer", timer);
309 elm_object_text_set(obj, "Icon tooltip, click to stop changed timed");
313 _tt_style_replace_timer_cb(void *data)
315 static int current = 0;
316 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
322 _tt_style_replace_timed(void *data __UNUSED__,
324 void *event_info __UNUSED__)
326 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
329 ecore_timer_del(timer);
330 evas_object_data_del(obj, "test-timer");
331 elm_object_text_set(obj, "Icon tooltip style, click to start"
336 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
337 evas_object_data_set(obj, "test-timer", timer);
338 elm_object_text_set(obj, "Icon tooltip style, click to stop changed"
343 _tt_visible_lock_toggle(void *data __UNUSED__,
345 void *event_info __UNUSED__)
347 static int locked = 0;
352 elm_object_text_set(obj, "Locked tooltip visibility");
353 elm_object_tooltip_text_set(obj, "This tooltip is locked"
354 " visible,<br> click the button"
356 elm_object_tooltip_show(obj);
360 elm_object_text_set(obj, "Unlocked tooltip visibility");
361 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
362 " visible,<br> click the button"
364 elm_object_tooltip_hide(obj);
369 test_tooltip(void *data __UNUSED__,
370 Evas_Object *obj __UNUSED__,
371 void *event_info __UNUSED__)
373 Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
374 Elm_Object_Item *tb_it;
377 win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
378 elm_win_title_set(win, "Tooltip");
379 elm_win_autodel_set(win, EINA_TRUE);
381 bg = elm_bg_add(win);
382 elm_win_resize_object_add(win, bg);
383 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
385 evas_object_show(bg);
387 bx = elm_box_add(win);
388 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
390 elm_win_resize_object_add(win, bx);
391 evas_object_show(bx);
393 tb = elm_toolbar_add(win);
394 elm_toolbar_homogeneous_set(tb, 0);
395 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
396 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
397 elm_box_pack_end(bx, tb);
398 evas_object_show(tb);
400 tb_it = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
401 elm_toolbar_item_tooltip_text_set(tb_it, "Opens a file");
403 tb_it = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
404 elm_toolbar_item_tooltip_content_cb_set
405 (tb_it, _tt_item_icon, (void *)456L, _tt_item_icon_del);
406 elm_toolbar_item_tooltip_style_set(tb_it, "transparent");
408 bt = elm_button_add(win);
409 elm_object_text_set(bt, "Simple text tooltip");
410 elm_object_tooltip_text_set(bt, "Simple text tooltip");
411 elm_box_pack_end(bx, bt);
412 evas_object_show(bt);
414 bt = elm_button_add(win);
415 elm_object_text_set(bt, "Simple text tooltip, click to change");
416 elm_object_tooltip_text_set(bt, "Initial");
417 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
418 elm_box_pack_end(bx, bt);
419 evas_object_show(bt);
421 bt = elm_button_add(win);
422 elm_object_text_set(bt, "Simple text tooltip, click to start"
424 elm_object_tooltip_text_set(bt, "Initial");
425 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
427 elm_box_pack_end(bx, bt);
428 evas_object_show(bt);
429 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
432 bt = elm_button_add(win);
433 elm_object_text_set(bt, "Icon tooltip");
434 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
436 elm_box_pack_end(bx, bt);
437 evas_object_show(bt);
439 bt = elm_button_add(win);
440 elm_object_text_set(bt, "Icon tooltip, click to start changed timed");
441 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
442 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
444 elm_box_pack_end(bx, bt);
445 evas_object_show(bt);
446 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
449 bt = elm_button_add(win);
450 elm_object_text_set(bt, "Transparent Icon tooltip");
451 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
452 elm_object_tooltip_style_set(bt, "transparent");
453 elm_box_pack_end(bx, bt);
454 evas_object_show(bt);
456 bt = elm_button_add(win);
457 elm_object_text_set(bt, "Icon tooltip style, click to start changed"
459 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
460 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
462 elm_box_pack_end(bx, bt);
463 evas_object_show(bt);
464 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
467 bt = elm_button_add(win);
468 elm_object_text_set(bt, "Unlocked tooltip visibility");
469 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br>"
470 " click the button to lock!");
471 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
473 elm_box_pack_end(bx, bt);
474 evas_object_show(bt);
476 se = elm_entry_add(win);
477 elm_entry_scrollable_set(se, EINA_TRUE);
478 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
479 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
480 elm_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF,
481 ELM_SCROLLER_POLICY_OFF);
482 elm_entry_entry_set(se, "Hello, some scrolled entry here!");
483 elm_object_tooltip_text_set(se, "Type something here!");
484 elm_entry_single_line_set(se, 1);
485 elm_box_pack_end(bx, se);
486 evas_object_show(se);
488 lst = elm_list_add(win);
489 li = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
490 elm_list_item_tooltip_content_cb_set(li, _tt_item_label, NULL, NULL);
491 elm_list_item_tooltip_window_mode(li, EINA_TRUE);
492 li = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
493 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL);
494 li = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL);
495 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon2, NULL, NULL);
496 elm_list_item_tooltip_style_set(li, "transparent");
497 elm_list_item_tooltip_window_mode(li, EINA_TRUE);
498 li = elm_list_item_append(lst, "Insanely Big Icon Tooltip", NULL, NULL, NULL, NULL);
499 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon3, NULL, NULL);
500 elm_list_item_tooltip_style_set(li, "transparent");
501 elm_list_item_tooltip_window_mode(li, EINA_TRUE);
502 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
504 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
505 evas_object_size_hint_min_set(lst, 100, 100);
507 elm_box_pack_end(bx, lst);
508 evas_object_show(lst);
510 evas_object_resize(win, 320, 580);
511 evas_object_show(win);
515 test_tooltip2(void *data __UNUSED__,
516 Evas_Object *obj __UNUSED__,
517 void *event_info __UNUSED__)
519 Evas_Object *win, *bg, *bx, *grid, *gl;
520 Elm_Genlist_Item *it1, *it2, *it3;
521 static Testitem ti[144];
537 win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC);
538 elm_win_title_set(win, "Tooltip 2");
539 elm_win_autodel_set(win, EINA_TRUE);
541 bg = elm_bg_add(win);
542 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
544 elm_win_resize_object_add(win, bg);
545 evas_object_show(bg);
547 bx = elm_box_add(win);
548 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
550 elm_win_resize_object_add(win, bx);
551 evas_object_show(bx);
553 grid = elm_gengrid_add(win);
554 elm_gengrid_item_size_set(grid, 100, 100);
555 elm_gengrid_horizontal_set(grid, EINA_FALSE);
556 elm_gengrid_multi_select_set(grid, EINA_TRUE);
557 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
558 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
561 gic.item_style = "default";
562 gic.func.text_get = grdt_lbl_get;
563 gic.func.content_get = grdt_content_get;
566 for (i = 0; i < 9; i++)
568 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(),
572 ti[i].path = eina_stringshare_add(buf);
573 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
576 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
578 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
580 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
583 elm_box_pack_end(bx, grid);
584 evas_object_show(grid);
586 gl = elm_genlist_add(win);
587 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
588 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
591 itct.item_style = "default";
592 itct.func.text_get = gltt_text_get;
594 it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
595 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
596 it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
597 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
598 it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
599 ELM_GENLIST_ITEM_NONE, NULL, NULL);
601 elm_genlist_item_tooltip_text_set(it1, "Testing 1");
602 elm_genlist_item_tooltip_text_set(it2, "Testing 2");
603 elm_genlist_item_tooltip_text_set(it3, "Testing 3");
605 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
606 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
608 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
609 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
611 elm_box_pack_end(bx, gl);
612 evas_object_show(gl);
614 evas_object_resize(win, 320, 480);
615 evas_object_show(win);