1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 # include "elementary_config.h"
6 #ifndef ELM_LIB_QUICKLAUNCH
8 // XXX: show all type of cursors in the elementary_test. this needs to be the first test
10 typedef struct _Testitem
12 Elm_Object_Item *item;
18 static Elm_Gengrid_Item_Class gic;
21 grd_lbl_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
23 const Testitem *ti = data;
25 snprintf(buf, sizeof(buf), "Photo %s", ti->path);
30 grd_content_get(void *data, Evas_Object *obj, const char *part)
32 const Testitem *ti = data;
33 if (!strcmp(part, "elm.swallow.icon"))
35 Evas_Object *icon = elm_bg_add(obj);
36 elm_bg_file_set(icon, ti->path, NULL);
37 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,
39 evas_object_show(icon);
45 static Elm_Genlist_Item_Class itct;
48 glt_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
50 Elm_Object_Item *glit = event_info;
51 Evas_Object *gl = elm_object_item_widget_get(glit);
52 int val = (int)(long) elm_object_item_data_get(glit);
53 Elm_Object_Item *glit1, *glit2, *glit3;
56 glit1 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 1), glit,
57 ELM_GENLIST_ITEM_NONE, NULL, NULL);
58 glit2 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 2), glit,
59 ELM_GENLIST_ITEM_NONE, NULL, NULL);
60 glit3 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 3), glit,
61 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
63 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND2);
64 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND2);
65 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_HAND1);
70 glt_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
72 Elm_Object_Item *glit = event_info;
73 elm_genlist_item_subitems_clear(glit);
77 glt_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
79 Elm_Object_Item *glit = event_info;
80 elm_genlist_item_expanded_set(glit, EINA_TRUE);
84 glt_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
86 Elm_Object_Item *glit = event_info;
87 elm_genlist_item_expanded_set(glit, EINA_FALSE);
91 glt_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
94 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
99 test_cursor(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
101 Evas_Object *win, *bg, *bx, *bt, *list, *entry, *ck;
102 Elm_Object_Item *lit;
104 win = elm_win_add(NULL, "cursor", ELM_WIN_BASIC);
105 elm_win_title_set(win, "Cursor");
106 elm_win_autodel_set(win, EINA_TRUE);
108 bg = elm_bg_add(win);
109 elm_win_resize_object_add(win, bg);
110 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
111 evas_object_show(bg);
112 elm_object_cursor_set(bg, ELM_CURSOR_CIRCLE);
114 bx = elm_box_add(win);
115 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116 elm_win_resize_object_add(win, bx);
117 evas_object_show(bx);
119 ck = elm_clock_add(win);
120 elm_object_cursor_set(ck, ELM_CURSOR_CLOCK);
121 elm_box_pack_end(bx, ck);
122 evas_object_show(ck);
124 bt = elm_button_add(win);
125 elm_object_cursor_set(bt, ELM_CURSOR_COFFEE_MUG);
126 elm_object_text_set(bt, "Coffee Mug");
127 elm_box_pack_end(bx, bt);
128 evas_object_show(bt);
130 bt = elm_button_add(win);
131 elm_object_cursor_set(bt, ELM_CURSOR_CLOCK);
132 elm_object_text_set(bt, "Cursor unset");
133 elm_object_cursor_unset(bt);
134 elm_box_pack_end(bx, bt);
135 evas_object_show(bt);
137 list = elm_list_add(win);
138 elm_box_pack_end(bx, list);
139 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
140 evas_object_size_hint_fill_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
141 elm_object_cursor_set(list, ELM_CURSOR_WATCH);
142 lit = elm_list_item_append(list, "watch over list | hand1", NULL, NULL, NULL,
144 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND1);
145 lit = elm_list_item_append(list, "watch over list | hand2", NULL, NULL, NULL,
147 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
149 evas_object_show(list);
151 entry = elm_entry_add(win);
152 elm_entry_scrollable_set(entry, EINA_TRUE);
153 elm_object_text_set(entry, "Xterm cursor");
154 elm_entry_single_line_set(entry, EINA_TRUE);
155 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
156 evas_object_size_hint_fill_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
157 elm_box_pack_end(bx, entry);
158 evas_object_show(entry);
159 elm_object_cursor_set(entry, ELM_CURSOR_XTERM);
161 evas_object_resize(win, 320, 480);
162 evas_object_show(win);
166 test_cursor2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
168 Evas_Object *win, *bg, *bx, *o, *grid, *gl;
169 Elm_Object_Item *glit1, *glit2, *glit3;
170 Elm_Object_Item *tb_it;
171 Elm_Object_Item *lit;
173 static Testitem ti[144];
188 win = elm_win_add(NULL, "cursor2", ELM_WIN_BASIC);
189 elm_win_title_set(win, "Cursor 2");
190 elm_win_autodel_set(win, EINA_TRUE);
192 bg = elm_bg_add(win);
193 elm_win_resize_object_add(win, bg);
194 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
195 evas_object_show(bg);
197 bx = elm_box_add(win);
198 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
199 elm_win_resize_object_add(win, bx);
200 evas_object_show(bx);
202 o = elm_toolbar_add(win);
203 elm_toolbar_homogeneous_set(o, 0);
204 evas_object_size_hint_weight_set(o, 0.0, 0.0);
205 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
206 tb_it = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL);
207 elm_object_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
208 tb_it = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL);
209 elm_object_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
210 elm_object_item_cursor_unset(tb_it);
211 tb_it = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL);
212 elm_object_item_cursor_set(tb_it, ELM_CURSOR_XTERM);
213 elm_box_pack_end(bx, o);
216 o = elm_list_add(win);
217 elm_box_pack_end(bx, o);
218 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
219 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
220 lit = elm_list_item_append(o, "cursor bogosity", NULL, NULL, NULL, NULL);
221 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
222 lit = elm_list_item_append(o, "cursor unset", NULL, NULL, NULL, NULL);
223 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
224 elm_object_item_cursor_unset(lit);
225 lit = elm_list_item_append(o, "cursor xterm", NULL, NULL, NULL, NULL);
226 elm_object_item_cursor_set(lit, ELM_CURSOR_XTERM);
230 gl = elm_genlist_add(win);
231 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
232 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
233 evas_object_show(gl);
235 itct.item_style = "default";
236 itct.func.text_get = glt_text_get;
238 glit1 = elm_genlist_item_append(gl, &itct, (void *) 1, NULL,
239 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
240 glit2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
241 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
242 glit3 = elm_genlist_item_append(gl, &itct, (void *) 3, NULL,
243 ELM_GENLIST_ITEM_NONE, NULL, NULL);
245 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND1);
246 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND1);
247 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_CROSS);
249 evas_object_smart_callback_add(gl, "expand,request", glt_exp_req, gl);
250 evas_object_smart_callback_add(gl, "contract,request", glt_con_req, gl);
251 evas_object_smart_callback_add(gl, "expanded", glt_exp, gl);
252 evas_object_smart_callback_add(gl, "contracted", glt_con, gl);
254 elm_box_pack_end(bx, gl);
256 grid = elm_gengrid_add(win);
257 elm_gengrid_item_size_set(grid, 130, 130);
258 elm_gengrid_horizontal_set(grid, EINA_FALSE);
259 elm_gengrid_multi_select_set(grid, EINA_TRUE);
260 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
261 evas_object_size_hint_fill_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
263 gic.item_style = "default";
264 gic.func.text_get = grd_lbl_get;
265 gic.func.content_get = grd_content_get;
268 for (i = 0; i < 3 * 3; i++)
270 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
273 ti[i].path = eina_stringshare_add(buf);
274 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
276 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_HAND1);
278 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_CLOCK);
280 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
282 elm_box_pack_end(bx, grid);
283 evas_object_show(grid);
285 evas_object_resize(win, 320, 480);
286 evas_object_show(win);
290 test_cursor3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
292 Evas_Object *win, *bg, *bx, *o;
293 Elm_Object_Item *lit;
296 win = elm_win_add(NULL, "cursor3", ELM_WIN_BASIC);
297 elm_win_title_set(win, "Cursor 3");
298 elm_win_autodel_set(win, EINA_TRUE);
300 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
301 elm_theme_extension_add(NULL, buf);
303 bg = elm_bg_add(win);
304 elm_win_resize_object_add(win, bg);
305 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
306 evas_object_show(bg);
308 bx = elm_box_add(win);
309 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
310 elm_win_resize_object_add(win, bx);
311 evas_object_show(bx);
313 o = elm_button_add(win);
314 elm_object_cursor_set(o, ELM_CURSOR_HAND1);
315 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
316 elm_object_text_set(o, "hand1");
317 elm_box_pack_end(bx, o);
320 o = elm_button_add(win);
321 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
322 elm_object_text_set(o, "hand2 x");
323 elm_box_pack_end(bx, o);
326 o = elm_button_add(win);
327 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
328 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
329 elm_object_text_set(o, "hand2");
330 elm_box_pack_end(bx, o);
333 o = elm_button_add(win);
334 elm_object_cursor_set(o, "hand3");
335 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
336 elm_object_text_set(o, "hand3");
337 elm_box_pack_end(bx, o);
340 o = elm_button_add(win);
341 elm_object_cursor_set(o, "hand3");
342 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
343 elm_object_cursor_style_set(o, "transparent");
344 elm_object_text_set(o, "hand3 transparent");
345 elm_box_pack_end(bx, o);
348 o = elm_button_add(win);
349 elm_object_cursor_set(o, "hand3");
350 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
351 elm_object_cursor_unset(o);
352 elm_object_text_set(o, "unset");
353 elm_box_pack_end(bx, o);
356 o = elm_button_add(win);
357 elm_object_cursor_set(o, "hand4");
358 elm_object_text_set(o, "not existent");
359 elm_box_pack_end(bx, o);
362 elm_config_cursor_engine_only_set(EINA_FALSE);
363 o = elm_button_add(win);
364 elm_object_cursor_set(o, "hand2");
365 elm_object_text_set(o, "hand 2 engine only config false");
366 elm_box_pack_end(bx, o);
369 elm_config_cursor_engine_only_set(EINA_TRUE);
370 o = elm_button_add(win);
371 elm_object_cursor_set(o, "hand2");
372 elm_object_text_set(o, "hand 2 engine only config true");
373 elm_box_pack_end(bx, o);
376 o = elm_list_add(win);
377 elm_box_pack_end(bx, o);
378 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
379 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
380 lit = elm_list_item_append(o, "cursor hand2 x", NULL, NULL, NULL, NULL);
381 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
382 lit = elm_list_item_append(o, "cursor hand2", NULL, NULL, NULL, NULL);
383 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
384 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
385 lit = elm_list_item_append(o, "cursor hand3", NULL, NULL, NULL, NULL);
386 elm_object_item_cursor_set(lit, "hand3");
387 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
388 lit = elm_list_item_append(o, "cursor hand3 transparent", NULL, NULL,
390 elm_object_item_cursor_set(lit, "hand3");
391 elm_object_item_cursor_style_set(lit, "transparent");
392 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
396 evas_object_resize(win, 320, 480);
397 evas_object_show(win);
401 test_cursor4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
403 Evas_Object *win, *bg, *bx, *ly, *bt;
406 win = elm_win_add(NULL, "cursor layout", ELM_WIN_BASIC);
407 elm_win_title_set(win, "Cursor Layout");
408 elm_win_autodel_set(win, EINA_TRUE);
410 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
412 bg = elm_bg_add(win);
413 elm_win_resize_object_add(win, bg);
414 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
415 evas_object_show(bg);
417 bx = elm_box_add(win);
418 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
419 elm_win_resize_object_add(win, bx);
420 evas_object_show(bx);
422 ly = elm_layout_add(win);
423 elm_layout_file_set(ly, buf, "test/layout/events");
424 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
425 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
426 elm_object_cursor_set(ly, ELM_CURSOR_HAND1);
427 elm_box_pack_end(bx, ly);
428 evas_object_show(ly);
430 ly = elm_layout_add(win);
431 elm_layout_file_set(ly, buf, "test/layout/noevents");
432 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
433 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
434 elm_object_cursor_set(ly, ELM_CURSOR_XTERM);
435 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
436 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
437 elm_box_pack_end(bx, ly);
438 evas_object_show(ly);
440 ly = elm_layout_add(win);
441 elm_layout_file_set(ly, buf, "test/layout/parts2");
442 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
443 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
444 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
445 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
446 elm_box_pack_end(bx, ly);
447 evas_object_show(ly);
449 ly = elm_layout_add(win);
450 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
451 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
452 elm_layout_file_set(ly, buf, "test/layout/swallow");
453 bt = elm_button_add(win);
454 elm_object_text_set(bt, "Cursor over obj");
455 elm_object_part_content_set(ly, "swallow1", bt);
456 elm_object_cursor_set(bt, ELM_CURSOR_PIRATE);
457 bt = elm_button_add(win);
458 elm_object_text_set(bt, "Cursor over part");
459 elm_object_part_content_set(ly, "swallow2", bt);
460 elm_layout_part_cursor_set(ly, "swallow2", ELM_CURSOR_PIRATE);
461 elm_box_pack_end(bx, ly);
462 evas_object_show(ly);
464 evas_object_resize(win, 320, 480);
465 evas_object_show(win);