1 #include <Elementary_Cursor.h>
3 # include "elementary_config.h"
5 #include <Elementary.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_TREE, 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, *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_util_standard_add("cursor2", "Cursor 2");
189 elm_win_autodel_set(win, EINA_TRUE);
191 bx = elm_box_add(win);
192 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193 elm_win_resize_object_add(win, bx);
194 evas_object_show(bx);
196 o = elm_toolbar_add(win);
197 elm_toolbar_homogeneous_set(o, 0);
198 evas_object_size_hint_weight_set(o, 0.0, 0.0);
199 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
200 tb_it = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL);
201 elm_object_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
202 tb_it = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL);
203 elm_object_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
204 elm_object_item_cursor_unset(tb_it);
205 tb_it = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL);
206 elm_object_item_cursor_set(tb_it, ELM_CURSOR_XTERM);
207 elm_box_pack_end(bx, o);
210 o = elm_list_add(win);
211 elm_box_pack_end(bx, o);
212 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
214 lit = elm_list_item_append(o, "cursor bogosity", NULL, NULL, NULL, NULL);
215 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
216 lit = elm_list_item_append(o, "cursor unset", NULL, NULL, NULL, NULL);
217 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
218 elm_object_item_cursor_unset(lit);
219 lit = elm_list_item_append(o, "cursor xterm", NULL, NULL, NULL, NULL);
220 elm_object_item_cursor_set(lit, ELM_CURSOR_XTERM);
224 gl = elm_genlist_add(win);
225 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
226 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
227 evas_object_show(gl);
229 itct.item_style = "default";
230 itct.func.text_get = glt_text_get;
232 glit1 = elm_genlist_item_append(gl, &itct, (void *) 1, NULL,
233 ELM_GENLIST_ITEM_TREE, NULL, NULL);
234 glit2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
235 ELM_GENLIST_ITEM_TREE, NULL, NULL);
236 glit3 = elm_genlist_item_append(gl, &itct, (void *) 3, NULL,
237 ELM_GENLIST_ITEM_NONE, NULL, NULL);
239 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND1);
240 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND1);
241 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_CROSS);
243 evas_object_smart_callback_add(gl, "expand,request", glt_exp_req, gl);
244 evas_object_smart_callback_add(gl, "contract,request", glt_con_req, gl);
245 evas_object_smart_callback_add(gl, "expanded", glt_exp, gl);
246 evas_object_smart_callback_add(gl, "contracted", glt_con, gl);
248 elm_box_pack_end(bx, gl);
250 grid = elm_gengrid_add(win);
251 elm_gengrid_item_size_set(grid, 130, 130);
252 elm_gengrid_horizontal_set(grid, EINA_FALSE);
253 elm_gengrid_multi_select_set(grid, EINA_TRUE);
254 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
255 evas_object_size_hint_fill_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
257 gic.item_style = "default";
258 gic.func.text_get = grd_lbl_get;
259 gic.func.content_get = grd_content_get;
262 for (i = 0; i < 3 * 3; i++)
264 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
267 ti[i].path = eina_stringshare_add(buf);
268 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
270 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_HAND1);
272 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_CLOCK);
274 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
276 elm_box_pack_end(bx, grid);
277 evas_object_show(grid);
279 evas_object_resize(win, 320, 480);
280 evas_object_show(win);
284 test_cursor3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
286 Evas_Object *win, *bx, *o;
287 Elm_Object_Item *lit;
290 win = elm_win_util_standard_add("cursor3", "Cursor 3");
291 elm_win_autodel_set(win, EINA_TRUE);
293 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
294 elm_theme_extension_add(NULL, buf);
296 bx = elm_box_add(win);
297 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
298 elm_win_resize_object_add(win, bx);
299 evas_object_show(bx);
301 o = elm_button_add(win);
302 elm_object_cursor_set(o, ELM_CURSOR_HAND1);
303 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
304 elm_object_text_set(o, "hand1");
305 elm_box_pack_end(bx, o);
308 o = elm_button_add(win);
309 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
310 elm_object_text_set(o, "hand2 x");
311 elm_box_pack_end(bx, o);
314 o = elm_button_add(win);
315 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
316 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
317 elm_object_text_set(o, "hand2");
318 elm_box_pack_end(bx, o);
321 o = elm_button_add(win);
322 elm_object_cursor_set(o, "hand3");
323 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
324 elm_object_text_set(o, "hand3");
325 elm_box_pack_end(bx, o);
328 o = elm_button_add(win);
329 elm_object_cursor_set(o, "hand3");
330 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
331 elm_object_cursor_style_set(o, "transparent");
332 elm_object_text_set(o, "hand3 transparent");
333 elm_box_pack_end(bx, o);
336 o = elm_button_add(win);
337 elm_object_cursor_set(o, "hand3");
338 elm_object_cursor_theme_search_enabled_set(o, EINA_FALSE);
339 elm_object_cursor_unset(o);
340 elm_object_text_set(o, "unset");
341 elm_box_pack_end(bx, o);
344 o = elm_button_add(win);
345 elm_object_cursor_set(o, "hand4");
346 elm_object_text_set(o, "not existent");
347 elm_box_pack_end(bx, o);
350 elm_config_cursor_engine_only_set(EINA_FALSE);
351 o = elm_button_add(win);
352 elm_object_cursor_set(o, "hand2");
353 elm_object_text_set(o, "hand 2 engine only config false");
354 elm_box_pack_end(bx, o);
357 elm_config_cursor_engine_only_set(EINA_TRUE);
358 o = elm_button_add(win);
359 elm_object_cursor_set(o, "hand2");
360 elm_object_text_set(o, "hand 2 engine only config true");
361 elm_box_pack_end(bx, o);
364 o = elm_list_add(win);
365 elm_box_pack_end(bx, o);
366 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
367 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
368 lit = elm_list_item_append(o, "cursor hand2 x", NULL, NULL, NULL, NULL);
369 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
370 lit = elm_list_item_append(o, "cursor hand2", NULL, NULL, NULL, NULL);
371 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
372 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
373 lit = elm_list_item_append(o, "cursor hand3", NULL, NULL, NULL, NULL);
374 elm_object_item_cursor_set(lit, "hand3");
375 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
376 lit = elm_list_item_append(o, "cursor hand3 transparent", NULL, NULL,
378 elm_object_item_cursor_set(lit, "hand3");
379 elm_object_item_cursor_style_set(lit, "transparent");
380 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
384 evas_object_resize(win, 320, 480);
385 evas_object_show(win);
389 test_cursor4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
391 Evas_Object *win, *bx, *ly, *bt;
394 win = elm_win_util_standard_add("cursor layout", "Cursor Layout");
395 elm_win_autodel_set(win, EINA_TRUE);
397 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
399 bx = elm_box_add(win);
400 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
401 elm_win_resize_object_add(win, bx);
402 evas_object_show(bx);
404 ly = elm_layout_add(win);
405 elm_layout_file_set(ly, buf, "test/layout/events");
406 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
407 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
408 elm_object_cursor_set(ly, ELM_CURSOR_HAND1);
409 elm_box_pack_end(bx, ly);
410 evas_object_show(ly);
412 ly = elm_layout_add(win);
413 elm_layout_file_set(ly, buf, "test/layout/noevents");
414 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
415 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
416 elm_object_cursor_set(ly, ELM_CURSOR_XTERM);
417 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
418 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
419 elm_box_pack_end(bx, ly);
420 evas_object_show(ly);
422 ly = elm_layout_add(win);
423 elm_layout_file_set(ly, buf, "test/layout/parts2");
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_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
427 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
428 elm_box_pack_end(bx, ly);
429 evas_object_show(ly);
431 ly = elm_layout_add(win);
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_layout_file_set(ly, buf, "test/layout/swallow");
435 bt = elm_button_add(win);
436 elm_object_text_set(bt, "Cursor over obj");
437 elm_object_part_content_set(ly, "swallow1", bt);
438 elm_object_cursor_set(bt, ELM_CURSOR_PIRATE);
439 bt = elm_button_add(win);
440 elm_object_text_set(bt, "Cursor over part");
441 elm_object_part_content_set(ly, "swallow2", bt);
442 elm_layout_part_cursor_set(ly, "swallow2", ELM_CURSOR_PIRATE);
443 elm_box_pack_end(bx, ly);
444 evas_object_show(ly);
446 evas_object_resize(win, 320, 480);
447 evas_object_show(win);