2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
7 typedef struct _Testitem
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_Object_Item *glit = event_info;
55 Evas_Object *gl = elm_object_item_widget_get(glit);
56 int val = (int)(long) elm_object_item_data_get(glit);
57 Elm_Object_Item *glit1, *glit2, *glit3;
60 glit1 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 1), glit,
61 ELM_GENLIST_ITEM_NONE, NULL, NULL);
62 glit2 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 2), glit,
63 ELM_GENLIST_ITEM_NONE, NULL, NULL);
64 glit3 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 3), glit,
65 ELM_GENLIST_ITEM_TREE, NULL, NULL);
67 elm_genlist_item_tooltip_text_set(glit1, "Testing A");
68 elm_genlist_item_tooltip_text_set(glit2, "Testing B");
69 elm_genlist_item_tooltip_text_set(glit3, "Testing C");
73 gltt_con(void *data __UNUSED__,
74 Evas_Object *obj __UNUSED__,
77 Elm_Object_Item *glit = event_info;
78 elm_genlist_item_subitems_clear(glit);
82 gltt_exp_req(void *data __UNUSED__,
83 Evas_Object *obj __UNUSED__,
86 Elm_Object_Item *glit = event_info;
87 elm_genlist_item_expanded_set(glit, EINA_TRUE);
91 gltt_con_req(void *data __UNUSED__,
92 Evas_Object *obj __UNUSED__,
95 Elm_Object_Item *glit = event_info;
96 elm_genlist_item_expanded_set(glit, EINA_FALSE);
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_image_file_set(ic, buf, NULL);
120 elm_image_resizable_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_image_file_set(ic, buf, NULL);
135 elm_image_resizable_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_image_file_set(ic, buf, NULL);
151 elm_image_object_size_get(ic, &w, &h);
152 elm_image_resizable_set(ic, 0, 0);
153 elm_win_screen_size_get(tt, NULL, NULL, &sw, &sh);
154 if ((w > sw) || (h > sh))
157 if ((float)w / (float)sw >= 0.8)
158 sc = ((float)sw * 0.8) / (float)w;
159 else if ((float)h / (float)sh >= 0.8)
160 sc = ((float)sh * 0.8) / (float)h;
161 if (sc) elm_object_scale_set(ic, sc);
167 _tt_item_label(void *data __UNUSED__,
168 Evas_Object *obj __UNUSED__,
170 void *item __UNUSED__)
172 Evas_Object *l = elm_label_add(tt);
173 elm_object_text_set(l, "Something useful here?<ps/>"
174 "No probably not, but this is a super long label<ps/>"
175 "which probably breaks on your system, now doesn't it?<ps/>"
176 "Yeah, I thought so.");
177 elm_label_line_wrap_set(l, ELM_WRAP_MIXED);
182 _tt_item_icon_del(void *data,
183 Evas_Object *obj __UNUSED__,
186 // test to check for del_cb behavior!
187 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
188 (long)data, event_info);
192 _tt_text_replace(void *data __UNUSED__,
194 void *event_info __UNUSED__)
196 static int count = 0;
198 snprintf(buf, sizeof(buf), "count=%d", count);
200 elm_object_tooltip_text_set(obj, buf);
204 _tt_timer_del(void *data __UNUSED__,
207 void *event_info __UNUSED__)
209 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
211 ecore_timer_del(timer);
215 _tt_text_replace_timer_cb(void *data)
217 _tt_text_replace(NULL, data, NULL);
222 _tt_text_replace_timed(void *data __UNUSED__,
224 void *event_info __UNUSED__)
226 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
229 ecore_timer_del(timer);
230 evas_object_data_del(obj, "test-timer");
231 elm_object_text_set(obj, "Simple text tooltip, click to start"
236 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
237 evas_object_data_set(obj, "test-timer", timer);
238 elm_object_text_set(obj, "Simple text tooltip, click to stop changed"
243 _tt_icon(void *data __UNUSED__,
244 Evas_Object *obj __UNUSED__,
247 Evas_Object *ic = elm_icon_add(tt);
249 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
250 elm_app_data_dir_get());
251 elm_image_file_set(ic, buf, NULL);
252 elm_image_resizable_set(ic, 0, 0);
253 evas_object_resize(ic, 64, 64);
258 _tt_icon2(void *data __UNUSED__,
259 Evas_Object *obj __UNUSED__,
262 Evas_Object *ic = elm_icon_add(tt);
264 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
265 elm_image_file_set(ic, buf, NULL);
266 elm_image_resizable_set(ic, 0, 0);
267 evas_object_resize(ic, 64, 64);
272 _tt_icon_del(void *data,
273 Evas_Object *obj __UNUSED__,
276 // test to check for del_cb behavior!
277 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
278 (long)data, event_info);
282 _tt_icon_replace_timer_cb(void *data)
284 static int current = 0;
286 elm_object_tooltip_content_cb_set
287 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
294 _tt_icon_replace_timed(void *data __UNUSED__,
296 void *event_info __UNUSED__)
298 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
301 ecore_timer_del(timer);
302 evas_object_data_del(obj, "test-timer");
303 elm_object_text_set(obj, "Icon tooltip, click to start changed"
308 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
309 evas_object_data_set(obj, "test-timer", timer);
310 elm_object_text_set(obj, "Icon tooltip, click to stop changed timed");
314 _tt_style_replace_timer_cb(void *data)
316 static int current = 0;
317 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
323 _tt_style_replace_timed(void *data __UNUSED__,
325 void *event_info __UNUSED__)
327 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
330 ecore_timer_del(timer);
331 evas_object_data_del(obj, "test-timer");
332 elm_object_text_set(obj, "Icon tooltip style, click to start"
337 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
338 evas_object_data_set(obj, "test-timer", timer);
339 elm_object_text_set(obj, "Icon tooltip style, click to stop changed"
344 _tt_visible_lock_toggle(void *data __UNUSED__,
346 void *event_info __UNUSED__)
348 static int locked = 0;
353 elm_object_text_set(obj, "Locked tooltip visibility");
354 elm_object_tooltip_text_set(obj, "This tooltip is locked"
355 " visible,<br/> click the button"
357 elm_object_tooltip_show(obj);
361 elm_object_text_set(obj, "Unlocked tooltip visibility");
362 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
363 " visible,<br/> click the button"
365 elm_object_tooltip_hide(obj);
370 test_tooltip(void *data __UNUSED__,
371 Evas_Object *obj __UNUSED__,
372 void *event_info __UNUSED__)
374 Evas_Object *win, *bx, *tb, *bt, *se, *lst;
375 Elm_Object_Item *tb_it;
376 Elm_Object_Item *lit;
378 win = elm_win_util_standard_add("tooltip", "Tooltip");
379 elm_win_autodel_set(win, EINA_TRUE);
381 bx = elm_box_add(win);
382 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
384 elm_win_resize_object_add(win, bx);
385 evas_object_show(bx);
387 tb = elm_toolbar_add(win);
388 elm_toolbar_homogeneous_set(tb, 0);
389 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
390 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
391 elm_box_pack_end(bx, tb);
392 evas_object_show(tb);
394 tb_it = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
395 elm_object_item_tooltip_text_set(tb_it, "Opens a file");
397 tb_it = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
398 elm_object_item_tooltip_content_cb_set
399 (tb_it, _tt_item_icon, (void *)456L, _tt_item_icon_del);
400 elm_object_item_tooltip_style_set(tb_it, "transparent");
402 bt = elm_button_add(win);
403 elm_object_text_set(bt, "Simple text tooltip");
404 elm_object_tooltip_text_set(bt, "Simple text tooltip");
405 elm_box_pack_end(bx, bt);
406 evas_object_show(bt);
408 bt = elm_button_add(win);
409 elm_object_text_set(bt, "Simple text tooltip, click to change");
410 elm_object_tooltip_text_set(bt, "Initial");
411 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
412 elm_box_pack_end(bx, bt);
413 evas_object_show(bt);
415 bt = elm_button_add(win);
416 elm_object_text_set(bt, "Simple text tooltip, click to start"
418 elm_object_tooltip_text_set(bt, "Initial");
419 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
421 elm_box_pack_end(bx, bt);
422 evas_object_show(bt);
423 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
426 bt = elm_button_add(win);
427 elm_object_text_set(bt, "Icon tooltip");
428 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
430 elm_box_pack_end(bx, bt);
431 evas_object_show(bt);
433 bt = elm_button_add(win);
434 elm_object_text_set(bt, "Icon tooltip, click to start changed timed");
435 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
436 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
438 elm_box_pack_end(bx, bt);
439 evas_object_show(bt);
440 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
443 bt = elm_button_add(win);
444 elm_object_text_set(bt, "Transparent Icon tooltip");
445 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
446 elm_object_tooltip_style_set(bt, "transparent");
447 elm_box_pack_end(bx, bt);
448 evas_object_show(bt);
450 bt = elm_button_add(win);
451 elm_object_text_set(bt, "Icon tooltip style, click to start changed"
453 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
454 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
456 elm_box_pack_end(bx, bt);
457 evas_object_show(bt);
458 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
461 bt = elm_button_add(win);
462 elm_object_text_set(bt, "Unlocked tooltip visibility");
463 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br/>"
464 " click the button to lock!");
465 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
467 elm_box_pack_end(bx, bt);
468 evas_object_show(bt);
470 se = elm_entry_add(win);
471 elm_entry_scrollable_set(se, EINA_TRUE);
472 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
473 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
474 elm_scroller_policy_set(se, ELM_SCROLLER_POLICY_OFF,
475 ELM_SCROLLER_POLICY_OFF);
476 elm_object_text_set(se, "Hello, some entry here!");
477 elm_object_tooltip_text_set(se, "Type something here!");
478 elm_entry_single_line_set(se, EINA_TRUE);
479 elm_box_pack_end(bx, se);
480 evas_object_show(se);
482 lst = elm_list_add(win);
483 lit = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
484 elm_object_item_tooltip_content_cb_set(lit, _tt_item_label, NULL, NULL);
485 elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE);
486 lit = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
487 elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon, NULL, NULL);
488 lit = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL);
489 elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon2, NULL, NULL);
490 elm_object_item_tooltip_style_set(lit, "transparent");
491 elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE);
492 lit = elm_list_item_append(lst, "Insanely Big Icon Tooltip", NULL, NULL, NULL, NULL);
493 elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon3, NULL, NULL);
494 elm_object_item_tooltip_style_set(lit, "transparent");
495 elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE);
496 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
498 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
499 evas_object_size_hint_min_set(lst, 100, 100);
501 elm_box_pack_end(bx, lst);
502 evas_object_show(lst);
504 evas_object_resize(win, 320, 580);
505 evas_object_show(win);
509 test_tooltip2(void *data __UNUSED__,
510 Evas_Object *obj __UNUSED__,
511 void *event_info __UNUSED__)
513 Evas_Object *win, *bx, *grid, *gl;
514 Elm_Object_Item *glit1, *glit2, *glit3;
515 static Testitem ti[144];
531 win = elm_win_util_standard_add("tooltip2", "Tooltip 2");
532 elm_win_autodel_set(win, EINA_TRUE);
534 bx = elm_box_add(win);
535 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
537 elm_win_resize_object_add(win, bx);
538 evas_object_show(bx);
540 grid = elm_gengrid_add(win);
541 elm_gengrid_item_size_set(grid, 100, 100);
542 elm_gengrid_horizontal_set(grid, EINA_FALSE);
543 elm_gengrid_multi_select_set(grid, EINA_TRUE);
544 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
545 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
548 gic.item_style = "default";
549 gic.func.text_get = grdt_lbl_get;
550 gic.func.content_get = grdt_content_get;
553 for (i = 0; i < 9; i++)
555 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(),
559 ti[i].path = eina_stringshare_add(buf);
560 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
563 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
565 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
567 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
570 elm_box_pack_end(bx, grid);
571 evas_object_show(grid);
573 gl = elm_genlist_add(win);
574 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
575 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
578 itct.item_style = "default";
579 itct.func.text_get = gltt_text_get;
581 glit1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
582 ELM_GENLIST_ITEM_TREE, NULL, NULL);
583 glit2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
584 ELM_GENLIST_ITEM_TREE, NULL, NULL);
585 glit3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
586 ELM_GENLIST_ITEM_NONE, NULL, NULL);
588 elm_genlist_item_tooltip_text_set(glit1, "Testing 1");
589 elm_genlist_item_tooltip_text_set(glit2, "Testing 2");
590 elm_genlist_item_tooltip_text_set(glit3, "Testing 3");
592 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
593 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
595 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
596 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
598 elm_box_pack_end(bx, gl);
599 evas_object_show(gl);
601 evas_object_resize(win, 320, 480);
602 evas_object_show(win);