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_icon_del(void *data,
126 Evas_Object *obj __UNUSED__,
129 // test to check for del_cb behavior!
130 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
131 (long)data, event_info);
135 _tt_text_replace(void *data __UNUSED__,
137 void *event_info __UNUSED__)
139 static int count = 0;
141 snprintf(buf, sizeof(buf), "count=%d", count);
143 elm_object_tooltip_text_set(obj, buf);
147 _tt_timer_del(void *data __UNUSED__,
150 void *event_info __UNUSED__)
152 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
154 ecore_timer_del(timer);
158 _tt_text_replace_timer_cb(void *data)
160 _tt_text_replace(NULL, data, NULL);
165 _tt_text_replace_timed(void *data __UNUSED__,
167 void *event_info __UNUSED__)
169 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
172 ecore_timer_del(timer);
173 evas_object_data_del(obj, "test-timer");
174 elm_button_label_set(obj, "Simple text tooltip, click to start"
179 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
180 evas_object_data_set(obj, "test-timer", timer);
181 elm_button_label_set(obj, "Simple text tooltip, click to stop changed"
186 _tt_icon(void *data __UNUSED__,
189 Evas_Object *ic = elm_icon_add(obj);
191 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
193 elm_icon_file_set(ic, buf, NULL);
194 elm_icon_scale_set(ic, 0, 0);
195 evas_object_resize(ic, 64, 64);
200 _tt_icon2(void *data __UNUSED__,
203 Evas_Object *ic = elm_icon_add(obj);
205 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", PACKAGE_DATA_DIR);
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_icon_del(void *data,
214 Evas_Object *obj __UNUSED__,
217 // test to check for del_cb behavior!
218 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
219 (long)data, event_info);
223 _tt_icon_replace_timer_cb(void *data)
225 static int current = 0;
227 elm_object_tooltip_content_cb_set
228 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
235 _tt_icon_replace_timed(void *data __UNUSED__,
237 void *event_info __UNUSED__)
239 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
242 ecore_timer_del(timer);
243 evas_object_data_del(obj, "test-timer");
244 elm_button_label_set(obj, "Icon tooltip, click to start changed"
249 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
250 evas_object_data_set(obj, "test-timer", timer);
251 elm_button_label_set(obj, "Icon tooltip, click to stop changed timed");
255 _tt_style_replace_timer_cb(void *data)
257 static int current = 0;
258 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
264 _tt_style_replace_timed(void *data __UNUSED__,
266 void *event_info __UNUSED__)
268 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
271 ecore_timer_del(timer);
272 evas_object_data_del(obj, "test-timer");
273 elm_button_label_set(obj, "Icon tooltip style, click to start"
278 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
279 evas_object_data_set(obj, "test-timer", timer);
280 elm_button_label_set(obj, "Icon tooltip style, click to stop changed"
285 _tt_visible_lock_toggle(void *data __UNUSED__,
287 void *event_info __UNUSED__)
289 static int locked = 0;
294 elm_button_label_set(obj, "Locked tooltip visibility");
295 elm_object_tooltip_text_set(obj, "This tooltip is locked"
296 " visible,<br> click the button"
298 elm_object_tooltip_show(obj);
302 elm_button_label_set(obj, "Unlocked tooltip visibility");
303 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
304 " visible,<br> click the button"
306 elm_object_tooltip_hide(obj);
311 test_tooltip(void *data __UNUSED__,
312 Evas_Object *obj __UNUSED__,
313 void *event_info __UNUSED__)
315 Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
316 Elm_Toolbar_Item *ti;
319 win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
320 elm_win_title_set(win, "Tooltip");
321 elm_win_autodel_set(win, 1);
323 bg = elm_bg_add(win);
324 elm_win_resize_object_add(win, bg);
325 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
327 evas_object_show(bg);
329 bx = elm_box_add(win);
330 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
332 elm_win_resize_object_add(win, bx);
333 evas_object_show(bx);
335 tb = elm_toolbar_add(win);
336 elm_toolbar_homogenous_set(tb, 0);
337 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
338 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
339 elm_box_pack_end(bx, tb);
340 evas_object_show(tb);
342 ti = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
343 elm_toolbar_item_tooltip_text_set(ti, "Opens a file");
345 ti = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
346 elm_toolbar_item_tooltip_content_cb_set
347 (ti, _tt_item_icon, (void *)456L, _tt_item_icon_del);
348 elm_toolbar_item_tooltip_style_set(ti, "transparent");
350 bt = elm_button_add(win);
351 elm_button_label_set(bt, "Simple text tooltip");
352 elm_object_tooltip_text_set(bt, "Simple text tooltip");
353 elm_box_pack_end(bx, bt);
354 evas_object_show(bt);
356 bt = elm_button_add(win);
357 elm_button_label_set(bt, "Simple text tooltip, click to change");
358 elm_object_tooltip_text_set(bt, "Initial");
359 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
360 elm_box_pack_end(bx, bt);
361 evas_object_show(bt);
363 bt = elm_button_add(win);
364 elm_button_label_set(bt, "Simple text tooltip, click to start"
366 elm_object_tooltip_text_set(bt, "Initial");
367 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
369 elm_box_pack_end(bx, bt);
370 evas_object_show(bt);
371 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
374 bt = elm_button_add(win);
375 elm_button_label_set(bt, "Icon tooltip");
376 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
378 elm_box_pack_end(bx, bt);
379 evas_object_show(bt);
381 bt = elm_button_add(win);
382 elm_button_label_set(bt, "Icon tooltip, click to start changed timed");
383 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
384 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
386 elm_box_pack_end(bx, bt);
387 evas_object_show(bt);
388 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
391 bt = elm_button_add(win);
392 elm_button_label_set(bt, "Transparent Icon tooltip");
393 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
394 elm_object_tooltip_style_set(bt, "transparent");
395 elm_box_pack_end(bx, bt);
396 evas_object_show(bt);
398 bt = elm_button_add(win);
399 elm_button_label_set(bt, "Icon tooltip style, click to start changed"
401 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
402 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
404 elm_box_pack_end(bx, bt);
405 evas_object_show(bt);
406 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
409 bt = elm_button_add(win);
410 elm_button_label_set(bt, "Unlocked tooltip visibility");
411 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br>"
412 " click the button to lock!");
413 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
415 elm_box_pack_end(bx, bt);
416 evas_object_show(bt);
418 se = elm_scrolled_entry_add(win);
419 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
420 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
421 elm_scrolled_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF,
422 ELM_SCROLLER_POLICY_OFF);
423 elm_scrolled_entry_entry_set(se, "Hello, some scrolled entry here!");
424 elm_object_tooltip_text_set(se, "Type something here!");
425 elm_scrolled_entry_single_line_set(se, 1);
426 elm_box_pack_end(bx, se);
427 evas_object_show(se);
429 lst = elm_list_add(win);
430 li = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
431 elm_list_item_tooltip_text_set(li, "Something useful here?");
432 li = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
433 elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL);
434 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
436 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
437 evas_object_size_hint_min_set(lst, 100, 100);
439 elm_box_pack_end(bx, lst);
440 evas_object_show(lst);
442 evas_object_resize(win, 320, 580);
443 evas_object_show(win);
447 test_tooltip2(void *data __UNUSED__,
448 Evas_Object *obj __UNUSED__,
449 void *event_info __UNUSED__)
451 Evas_Object *win, *bg, *bx, *grid, *gl;
452 Elm_Genlist_Item *it1, *it2, *it3;
453 static Testitem ti[144];
469 win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC);
470 elm_win_title_set(win, "Tooltip 2");
471 elm_win_autodel_set(win, 1);
473 bg = elm_bg_add(win);
474 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
476 elm_win_resize_object_add(win, bg);
477 evas_object_show(bg);
479 bx = elm_box_add(win);
480 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
482 elm_win_resize_object_add(win, bx);
483 evas_object_show(bx);
485 grid = elm_gengrid_add(win);
486 elm_gengrid_item_size_set(grid, 100, 100);
487 elm_gengrid_horizontal_set(grid, EINA_FALSE);
488 elm_gengrid_multi_select_set(grid, EINA_TRUE);
489 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
490 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
493 gic.item_style = "default";
494 gic.func.label_get = grdt_lbl_get;
495 gic.func.icon_get = grdt_icon_get;
498 for (i = 0; i < 9; i++)
500 snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR,
504 ti[i].path = eina_stringshare_add(buf);
505 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
508 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
510 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
512 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
515 elm_box_pack_end(bx, grid);
516 evas_object_show(grid);
518 gl = elm_genlist_add(win);
519 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
520 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
523 itct.item_style = "default";
524 itct.func.label_get = gltt_label_get;
526 it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
527 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
528 it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
529 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
530 it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
531 ELM_GENLIST_ITEM_NONE, NULL, NULL);
533 elm_genlist_item_tooltip_text_set(it1, "Testing 1");
534 elm_genlist_item_tooltip_text_set(it2, "Testing 2");
535 elm_genlist_item_tooltip_text_set(it3, "Testing 3");
537 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
538 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
540 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
541 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
543 elm_box_pack_end(bx, gl);
544 evas_object_show(gl);
546 evas_object_resize(win, 320, 480);
547 evas_object_show(win);