1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 # include "elementary_config.h"
6 #ifndef ELM_LIB_QUICKLAUNCH
10 // XXX: show all type of cursors in the elementary_test. this needs to be the first test
12 >>>>>>> remotes/origin/upstream
13 typedef struct _Testitem
15 Elm_Object_Item *item;
21 static Elm_Gengrid_Item_Class gic;
24 grd_lbl_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
26 const Testitem *ti = data;
28 snprintf(buf, sizeof(buf), "Photo %s", ti->path);
33 grd_content_get(void *data, Evas_Object *obj, const char *part)
35 const Testitem *ti = data;
36 if (!strcmp(part, "elm.swallow.icon"))
38 Evas_Object *icon = elm_bg_add(obj);
39 elm_bg_file_set(icon, ti->path, NULL);
40 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,
42 evas_object_show(icon);
48 static Elm_Genlist_Item_Class itct;
51 glt_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
53 Elm_Object_Item *glit = event_info;
55 Evas_Object *gl = elm_genlist_item_genlist_get(glit);
56 int val = (int) 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_SUBITEMS, NULL, NULL);
67 Evas_Object *gl = elm_object_item_widget_get(glit);
68 int val = (int)(long) elm_object_item_data_get(glit);
69 Elm_Object_Item *glit1, *glit2, *glit3;
72 glit1 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 1), glit,
73 ELM_GENLIST_ITEM_NONE, NULL, NULL);
74 glit2 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 2), glit,
75 ELM_GENLIST_ITEM_NONE, NULL, NULL);
76 glit3 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 3), glit,
77 ELM_GENLIST_ITEM_TREE, NULL, NULL);
78 >>>>>>> remotes/origin/upstream
80 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND2);
81 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND2);
82 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_HAND1);
87 glt_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
89 Elm_Object_Item *glit = event_info;
90 elm_genlist_item_subitems_clear(glit);
94 glt_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
96 Elm_Object_Item *glit = event_info;
97 elm_genlist_item_expanded_set(glit, EINA_TRUE);
101 glt_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
103 Elm_Object_Item *glit = event_info;
104 elm_genlist_item_expanded_set(glit, EINA_FALSE);
108 glt_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
111 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
116 test_cursor(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
118 Evas_Object *win, *bg, *bx, *bt, *list, *entry, *ck;
119 Elm_Object_Item *lit;
121 win = elm_win_add(NULL, "cursor", ELM_WIN_BASIC);
122 elm_win_title_set(win, "Cursor");
123 elm_win_autodel_set(win, EINA_TRUE);
125 bg = elm_bg_add(win);
126 elm_win_resize_object_add(win, bg);
127 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
128 evas_object_show(bg);
129 elm_object_cursor_set(bg, ELM_CURSOR_CIRCLE);
131 bx = elm_box_add(win);
132 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
133 elm_win_resize_object_add(win, bx);
134 evas_object_show(bx);
136 ck = elm_clock_add(win);
137 elm_object_cursor_set(ck, ELM_CURSOR_CLOCK);
138 elm_box_pack_end(bx, ck);
139 evas_object_show(ck);
141 bt = elm_button_add(win);
142 elm_object_cursor_set(bt, ELM_CURSOR_COFFEE_MUG);
143 elm_object_text_set(bt, "Coffee Mug");
144 elm_box_pack_end(bx, bt);
145 evas_object_show(bt);
147 bt = elm_button_add(win);
148 elm_object_cursor_set(bt, ELM_CURSOR_CLOCK);
149 elm_object_text_set(bt, "Cursor unset");
150 elm_object_cursor_unset(bt);
151 elm_box_pack_end(bx, bt);
152 evas_object_show(bt);
154 list = elm_list_add(win);
155 elm_box_pack_end(bx, list);
156 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
157 evas_object_size_hint_fill_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
158 elm_object_cursor_set(list, ELM_CURSOR_WATCH);
159 lit = elm_list_item_append(list, "watch over list | hand1", NULL, NULL, NULL,
161 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND1);
162 lit = elm_list_item_append(list, "watch over list | hand2", NULL, NULL, NULL,
164 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
166 evas_object_show(list);
168 entry = elm_entry_add(win);
169 elm_entry_scrollable_set(entry, EINA_TRUE);
170 elm_object_text_set(entry, "Xterm cursor");
171 elm_entry_single_line_set(entry, EINA_TRUE);
172 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
173 evas_object_size_hint_fill_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
174 elm_box_pack_end(bx, entry);
175 evas_object_show(entry);
176 elm_object_cursor_set(entry, ELM_CURSOR_XTERM);
178 evas_object_resize(win, 320, 480);
179 evas_object_show(win);
183 test_cursor2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
185 Evas_Object *win, *bg, *bx, *o, *grid, *gl;
186 Elm_Object_Item *glit1, *glit2, *glit3;
187 Elm_Object_Item *tb_it;
188 Elm_Object_Item *lit;
190 static Testitem ti[144];
205 win = elm_win_add(NULL, "cursor2", ELM_WIN_BASIC);
206 elm_win_title_set(win, "Cursor 2");
207 elm_win_autodel_set(win, EINA_TRUE);
209 bg = elm_bg_add(win);
210 elm_win_resize_object_add(win, bg);
211 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
212 evas_object_show(bg);
214 bx = elm_box_add(win);
215 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 elm_win_resize_object_add(win, bx);
217 evas_object_show(bx);
219 o = elm_toolbar_add(win);
220 elm_toolbar_homogeneous_set(o, 0);
221 evas_object_size_hint_weight_set(o, 0.0, 0.0);
222 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
223 tb_it = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL);
224 elm_object_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
225 tb_it = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL);
226 elm_object_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
227 elm_object_item_cursor_unset(tb_it);
228 tb_it = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL);
229 elm_object_item_cursor_set(tb_it, ELM_CURSOR_XTERM);
230 elm_box_pack_end(bx, o);
233 o = elm_list_add(win);
234 elm_box_pack_end(bx, o);
235 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
236 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
237 lit = elm_list_item_append(o, "cursor bogosity", NULL, NULL, NULL, NULL);
238 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
239 lit = elm_list_item_append(o, "cursor unset", NULL, NULL, NULL, NULL);
240 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
241 elm_object_item_cursor_unset(lit);
242 lit = elm_list_item_append(o, "cursor xterm", NULL, NULL, NULL, NULL);
243 elm_object_item_cursor_set(lit, ELM_CURSOR_XTERM);
247 gl = elm_genlist_add(win);
248 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
249 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
250 evas_object_show(gl);
252 itct.item_style = "default";
253 itct.func.text_get = glt_text_get;
255 glit1 = elm_genlist_item_append(gl, &itct, (void *) 1, NULL,
257 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
258 glit2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
259 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
261 ELM_GENLIST_ITEM_TREE, NULL, NULL);
262 glit2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
263 ELM_GENLIST_ITEM_TREE, NULL, NULL);
264 >>>>>>> remotes/origin/upstream
265 glit3 = elm_genlist_item_append(gl, &itct, (void *) 3, NULL,
266 ELM_GENLIST_ITEM_NONE, NULL, NULL);
268 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND1);
269 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND1);
270 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_CROSS);
272 evas_object_smart_callback_add(gl, "expand,request", glt_exp_req, gl);
273 evas_object_smart_callback_add(gl, "contract,request", glt_con_req, gl);
274 evas_object_smart_callback_add(gl, "expanded", glt_exp, gl);
275 evas_object_smart_callback_add(gl, "contracted", glt_con, gl);
277 elm_box_pack_end(bx, gl);
279 grid = elm_gengrid_add(win);
280 elm_gengrid_item_size_set(grid, 130, 130);
281 elm_gengrid_horizontal_set(grid, EINA_FALSE);
282 elm_gengrid_multi_select_set(grid, EINA_TRUE);
283 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
284 evas_object_size_hint_fill_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
286 gic.item_style = "default";
287 gic.func.text_get = grd_lbl_get;
288 gic.func.content_get = grd_content_get;
291 for (i = 0; i < 3 * 3; i++)
293 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
296 ti[i].path = eina_stringshare_add(buf);
297 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
299 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_HAND1);
301 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_CLOCK);
303 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
305 elm_box_pack_end(bx, grid);
306 evas_object_show(grid);
308 evas_object_resize(win, 320, 480);
309 evas_object_show(win);
313 test_cursor3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
315 Evas_Object *win, *bg, *bx, *o;
316 Elm_Object_Item *lit;
319 win = elm_win_add(NULL, "cursor3", ELM_WIN_BASIC);
320 elm_win_title_set(win, "Cursor 3");
321 elm_win_autodel_set(win, EINA_TRUE);
323 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
324 elm_theme_extension_add(NULL, buf);
326 bg = elm_bg_add(win);
327 elm_win_resize_object_add(win, bg);
328 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
329 evas_object_show(bg);
331 bx = elm_box_add(win);
332 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
333 elm_win_resize_object_add(win, bx);
334 evas_object_show(bx);
336 o = elm_button_add(win);
337 elm_object_cursor_set(o, ELM_CURSOR_HAND1);
339 elm_object_cursor_engine_only_set(o, EINA_FALSE);
341 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
342 >>>>>>> remotes/origin/upstream
343 elm_object_text_set(o, "hand1");
344 elm_box_pack_end(bx, o);
347 o = elm_button_add(win);
348 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
349 elm_object_text_set(o, "hand2 x");
350 elm_box_pack_end(bx, o);
353 o = elm_button_add(win);
354 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
356 elm_object_cursor_engine_only_set(o, EINA_FALSE);
358 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
359 >>>>>>> remotes/origin/upstream
360 elm_object_text_set(o, "hand2");
361 elm_box_pack_end(bx, o);
364 o = elm_button_add(win);
365 elm_object_cursor_set(o, "hand3");
367 elm_object_cursor_engine_only_set(o, EINA_FALSE);
369 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
370 >>>>>>> remotes/origin/upstream
371 elm_object_text_set(o, "hand3");
372 elm_box_pack_end(bx, o);
375 o = elm_button_add(win);
376 elm_object_cursor_set(o, "hand3");
378 elm_object_cursor_engine_only_set(o, EINA_FALSE);
380 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
381 >>>>>>> remotes/origin/upstream
382 elm_object_cursor_style_set(o, "transparent");
383 elm_object_text_set(o, "hand3 transparent");
384 elm_box_pack_end(bx, o);
387 o = elm_button_add(win);
388 elm_object_cursor_set(o, "hand3");
390 elm_object_cursor_engine_only_set(o, EINA_FALSE);
392 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
393 >>>>>>> remotes/origin/upstream
394 elm_object_cursor_unset(o);
395 elm_object_text_set(o, "unset");
396 elm_box_pack_end(bx, o);
399 o = elm_button_add(win);
400 elm_object_cursor_set(o, "hand4");
401 elm_object_text_set(o, "not existent");
402 elm_box_pack_end(bx, o);
406 elm_cursor_engine_only_set(0);
408 elm_config_cursor_engine_only_set(EINA_FALSE);
409 >>>>>>> remotes/origin/upstream
410 o = elm_button_add(win);
411 elm_object_cursor_set(o, "hand2");
412 elm_object_text_set(o, "hand 2 engine only config false");
413 elm_box_pack_end(bx, o);
417 elm_cursor_engine_only_set(1);
419 elm_config_cursor_engine_only_set(EINA_TRUE);
420 >>>>>>> remotes/origin/upstream
421 o = elm_button_add(win);
422 elm_object_cursor_set(o, "hand2");
423 elm_object_text_set(o, "hand 2 engine only config true");
424 elm_box_pack_end(bx, o);
427 o = elm_list_add(win);
428 elm_box_pack_end(bx, o);
429 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
430 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
431 lit = elm_list_item_append(o, "cursor hand2 x", NULL, NULL, NULL, NULL);
432 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
433 lit = elm_list_item_append(o, "cursor hand2", NULL, NULL, NULL, NULL);
434 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
435 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
436 lit = elm_list_item_append(o, "cursor hand3", NULL, NULL, NULL, NULL);
437 elm_object_item_cursor_set(lit, "hand3");
438 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
439 lit = elm_list_item_append(o, "cursor hand3 transparent", NULL, NULL,
441 elm_object_item_cursor_set(lit, "hand3");
442 elm_object_item_cursor_style_set(lit, "transparent");
443 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
447 evas_object_resize(win, 320, 480);
448 evas_object_show(win);
452 test_cursor4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
454 Evas_Object *win, *bg, *bx, *ly, *bt;
457 win = elm_win_add(NULL, "cursor layout", ELM_WIN_BASIC);
458 elm_win_title_set(win, "Cursor Layout");
459 elm_win_autodel_set(win, EINA_TRUE);
461 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
463 bg = elm_bg_add(win);
464 elm_win_resize_object_add(win, bg);
465 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
466 evas_object_show(bg);
468 bx = elm_box_add(win);
469 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
470 elm_win_resize_object_add(win, bx);
471 evas_object_show(bx);
473 ly = elm_layout_add(win);
474 elm_layout_file_set(ly, buf, "test/layout/events");
475 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
476 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
477 elm_object_cursor_set(ly, ELM_CURSOR_HAND1);
478 elm_box_pack_end(bx, ly);
479 evas_object_show(ly);
481 ly = elm_layout_add(win);
482 elm_layout_file_set(ly, buf, "test/layout/noevents");
483 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
485 elm_object_cursor_set(ly, ELM_CURSOR_XTERM);
486 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
487 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
488 elm_box_pack_end(bx, ly);
489 evas_object_show(ly);
491 ly = elm_layout_add(win);
492 elm_layout_file_set(ly, buf, "test/layout/parts2");
493 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
494 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
495 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
496 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
497 elm_box_pack_end(bx, ly);
498 evas_object_show(ly);
500 ly = elm_layout_add(win);
501 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
502 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
503 elm_layout_file_set(ly, buf, "test/layout/swallow");
504 bt = elm_button_add(win);
505 elm_object_text_set(bt, "Cursor over obj");
506 elm_object_part_content_set(ly, "swallow1", bt);
507 elm_object_cursor_set(bt, ELM_CURSOR_PIRATE);
508 bt = elm_button_add(win);
509 elm_object_text_set(bt, "Cursor over part");
510 elm_object_part_content_set(ly, "swallow2", bt);
511 elm_layout_part_cursor_set(ly, "swallow2", ELM_CURSOR_PIRATE);
512 elm_box_pack_end(bx, ly);
513 evas_object_show(ly);
515 evas_object_resize(win, 320, 480);
516 evas_object_show(win);