1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 # include "elementary_config.h"
6 #ifndef ELM_LIB_QUICKLAUNCH
8 typedef struct _Testitem
10 Elm_Object_Item *item;
16 static Elm_Gengrid_Item_Class gic;
19 grd_lbl_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
21 const Testitem *ti = data;
23 snprintf(buf, sizeof(buf), "Photo %s", ti->path);
28 grd_content_get(void *data, Evas_Object *obj, const char *part)
30 const Testitem *ti = data;
31 if (!strcmp(part, "elm.swallow.icon"))
33 Evas_Object *icon = elm_bg_add(obj);
34 elm_bg_file_set(icon, ti->path, NULL);
35 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,
37 evas_object_show(icon);
43 static Elm_Genlist_Item_Class itct;
46 glt_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
48 Elm_Object_Item *glit = event_info;
49 Evas_Object *gl = elm_genlist_item_genlist_get(glit);
50 int val = (int) elm_object_item_data_get(glit);
51 Elm_Object_Item *glit1, *glit2, *glit3;
54 glit1 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 1), glit,
55 ELM_GENLIST_ITEM_NONE, NULL, NULL);
56 glit2 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 2), glit,
57 ELM_GENLIST_ITEM_NONE, NULL, NULL);
58 glit3 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 3), glit,
59 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
61 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND2);
62 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND2);
63 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_HAND1);
68 glt_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
70 Elm_Object_Item *glit = event_info;
71 elm_genlist_item_subitems_clear(glit);
75 glt_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
77 Elm_Object_Item *glit = event_info;
78 elm_genlist_item_expanded_set(glit, EINA_TRUE);
82 glt_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
84 Elm_Object_Item *glit = event_info;
85 elm_genlist_item_expanded_set(glit, EINA_FALSE);
89 glt_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
92 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
97 test_cursor(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
99 Evas_Object *win, *bg, *bx, *bt, *list, *entry, *ck;
100 Elm_Object_Item *lit;
102 win = elm_win_add(NULL, "cursor", ELM_WIN_BASIC);
103 elm_win_title_set(win, "Cursor");
104 elm_win_autodel_set(win, EINA_TRUE);
106 bg = elm_bg_add(win);
107 elm_win_resize_object_add(win, bg);
108 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
109 evas_object_show(bg);
110 elm_object_cursor_set(bg, ELM_CURSOR_CIRCLE);
112 bx = elm_box_add(win);
113 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114 elm_win_resize_object_add(win, bx);
115 evas_object_show(bx);
117 ck = elm_clock_add(win);
118 elm_object_cursor_set(ck, ELM_CURSOR_CLOCK);
119 elm_box_pack_end(bx, ck);
120 evas_object_show(ck);
122 bt = elm_button_add(win);
123 elm_object_cursor_set(bt, ELM_CURSOR_COFFEE_MUG);
124 elm_object_text_set(bt, "Coffee Mug");
125 elm_box_pack_end(bx, bt);
126 evas_object_show(bt);
128 bt = elm_button_add(win);
129 elm_object_cursor_set(bt, ELM_CURSOR_CLOCK);
130 elm_object_text_set(bt, "Cursor unset");
131 elm_object_cursor_unset(bt);
132 elm_box_pack_end(bx, bt);
133 evas_object_show(bt);
135 list = elm_list_add(win);
136 elm_box_pack_end(bx, list);
137 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
138 evas_object_size_hint_fill_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
139 elm_object_cursor_set(list, ELM_CURSOR_WATCH);
140 lit = elm_list_item_append(list, "watch over list | hand1", NULL, NULL, NULL,
142 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND1);
143 lit = elm_list_item_append(list, "watch over list | hand2", NULL, NULL, NULL,
145 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
147 evas_object_show(list);
149 entry = elm_entry_add(win);
150 elm_entry_scrollable_set(entry, EINA_TRUE);
151 elm_object_text_set(entry, "Xterm cursor");
152 elm_entry_single_line_set(entry, EINA_TRUE);
153 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
154 evas_object_size_hint_fill_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
155 elm_box_pack_end(bx, entry);
156 evas_object_show(entry);
157 elm_object_cursor_set(entry, ELM_CURSOR_XTERM);
159 evas_object_resize(win, 320, 480);
160 evas_object_show(win);
164 test_cursor2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
166 Evas_Object *win, *bg, *bx, *o, *grid, *gl;
167 Elm_Object_Item *glit1, *glit2, *glit3;
168 Elm_Object_Item *tb_it;
169 Elm_Object_Item *lit;
171 static Testitem ti[144];
186 win = elm_win_add(NULL, "cursor2", ELM_WIN_BASIC);
187 elm_win_title_set(win, "Cursor 2");
188 elm_win_autodel_set(win, EINA_TRUE);
190 bg = elm_bg_add(win);
191 elm_win_resize_object_add(win, bg);
192 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193 evas_object_show(bg);
195 bx = elm_box_add(win);
196 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
197 elm_win_resize_object_add(win, bx);
198 evas_object_show(bx);
200 o = elm_toolbar_add(win);
201 elm_toolbar_homogeneous_set(o, 0);
202 evas_object_size_hint_weight_set(o, 0.0, 0.0);
203 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
204 tb_it = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL);
205 elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
206 tb_it = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL);
207 elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
208 elm_toolbar_item_cursor_unset(tb_it);
209 tb_it = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL);
210 elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_XTERM);
211 elm_box_pack_end(bx, o);
214 o = elm_list_add(win);
215 elm_box_pack_end(bx, o);
216 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
218 lit = elm_list_item_append(o, "cursor bogosity", NULL, NULL, NULL, NULL);
219 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
220 lit = elm_list_item_append(o, "cursor unset", NULL, NULL, NULL, NULL);
221 elm_object_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
222 elm_object_item_cursor_unset(lit);
223 lit = elm_list_item_append(o, "cursor xterm", NULL, NULL, NULL, NULL);
224 elm_object_item_cursor_set(lit, ELM_CURSOR_XTERM);
228 gl = elm_genlist_add(win);
229 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
230 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
231 evas_object_show(gl);
233 itct.item_style = "default";
234 itct.func.text_get = glt_text_get;
236 glit1 = elm_genlist_item_append(gl, &itct, (void *) 1, NULL,
237 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
238 glit2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
239 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
240 glit3 = elm_genlist_item_append(gl, &itct, (void *) 3, NULL,
241 ELM_GENLIST_ITEM_NONE, NULL, NULL);
243 elm_genlist_item_cursor_set(glit1, ELM_CURSOR_HAND1);
244 elm_genlist_item_cursor_set(glit2, ELM_CURSOR_HAND1);
245 elm_genlist_item_cursor_set(glit3, ELM_CURSOR_CROSS);
247 evas_object_smart_callback_add(gl, "expand,request", glt_exp_req, gl);
248 evas_object_smart_callback_add(gl, "contract,request", glt_con_req, gl);
249 evas_object_smart_callback_add(gl, "expanded", glt_exp, gl);
250 evas_object_smart_callback_add(gl, "contracted", glt_con, gl);
252 elm_box_pack_end(bx, gl);
254 grid = elm_gengrid_add(win);
255 elm_gengrid_item_size_set(grid, 130, 130);
256 elm_gengrid_horizontal_set(grid, EINA_FALSE);
257 elm_gengrid_multi_select_set(grid, EINA_TRUE);
258 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
259 evas_object_size_hint_fill_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
261 gic.item_style = "default";
262 gic.func.text_get = grd_lbl_get;
263 gic.func.content_get = grd_content_get;
266 for (i = 0; i < 3 * 3; i++)
268 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
271 ti[i].path = eina_stringshare_add(buf);
272 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
274 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_HAND1);
276 elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_CLOCK);
278 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
280 elm_box_pack_end(bx, grid);
281 evas_object_show(grid);
283 evas_object_resize(win, 320, 480);
284 evas_object_show(win);
288 test_cursor3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
290 Evas_Object *win, *bg, *bx, *o;
291 Elm_Object_Item *lit;
294 win = elm_win_add(NULL, "cursor3", ELM_WIN_BASIC);
295 elm_win_title_set(win, "Cursor 3");
296 elm_win_autodel_set(win, EINA_TRUE);
298 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
299 elm_theme_extension_add(NULL, buf);
301 bg = elm_bg_add(win);
302 elm_win_resize_object_add(win, bg);
303 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
304 evas_object_show(bg);
306 bx = elm_box_add(win);
307 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
308 elm_win_resize_object_add(win, bx);
309 evas_object_show(bx);
311 o = elm_button_add(win);
312 elm_object_cursor_set(o, ELM_CURSOR_HAND1);
313 elm_object_cursor_engine_only_set(o, EINA_FALSE);
314 elm_object_text_set(o, "hand1");
315 elm_box_pack_end(bx, o);
318 o = elm_button_add(win);
319 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
320 elm_object_text_set(o, "hand2 x");
321 elm_box_pack_end(bx, o);
324 o = elm_button_add(win);
325 elm_object_cursor_set(o, ELM_CURSOR_HAND2);
326 elm_object_cursor_engine_only_set(o, EINA_FALSE);
327 elm_object_text_set(o, "hand2");
328 elm_box_pack_end(bx, o);
331 o = elm_button_add(win);
332 elm_object_cursor_set(o, "hand3");
333 elm_object_cursor_engine_only_set(o, EINA_FALSE);
334 elm_object_text_set(o, "hand3");
335 elm_box_pack_end(bx, o);
338 o = elm_button_add(win);
339 elm_object_cursor_set(o, "hand3");
340 elm_object_cursor_engine_only_set(o, EINA_FALSE);
341 elm_object_cursor_style_set(o, "transparent");
342 elm_object_text_set(o, "hand3 transparent");
343 elm_box_pack_end(bx, o);
346 o = elm_button_add(win);
347 elm_object_cursor_set(o, "hand3");
348 elm_object_cursor_engine_only_set(o, EINA_FALSE);
349 elm_object_cursor_unset(o);
350 elm_object_text_set(o, "unset");
351 elm_box_pack_end(bx, o);
354 o = elm_button_add(win);
355 elm_object_cursor_set(o, "hand4");
356 elm_object_text_set(o, "not existent");
357 elm_box_pack_end(bx, o);
360 elm_cursor_engine_only_set(0);
361 o = elm_button_add(win);
362 elm_object_cursor_set(o, "hand2");
363 elm_object_text_set(o, "hand 2 engine only config false");
364 elm_box_pack_end(bx, o);
367 elm_cursor_engine_only_set(1);
368 o = elm_button_add(win);
369 elm_object_cursor_set(o, "hand2");
370 elm_object_text_set(o, "hand 2 engine only config true");
371 elm_box_pack_end(bx, o);
374 o = elm_list_add(win);
375 elm_box_pack_end(bx, o);
376 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
377 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
378 lit = elm_list_item_append(o, "cursor hand2 x", NULL, NULL, NULL, NULL);
379 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
380 lit = elm_list_item_append(o, "cursor hand2", NULL, NULL, NULL, NULL);
381 elm_object_item_cursor_set(lit, ELM_CURSOR_HAND2);
382 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
383 lit = elm_list_item_append(o, "cursor hand3", NULL, NULL, NULL, NULL);
384 elm_object_item_cursor_set(lit, "hand3");
385 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
386 lit = elm_list_item_append(o, "cursor hand3 transparent", NULL, NULL,
388 elm_object_item_cursor_set(lit, "hand3");
389 elm_object_item_cursor_style_set(lit, "transparent");
390 elm_object_item_cursor_engine_only_set(lit, EINA_FALSE);
394 evas_object_resize(win, 320, 480);
395 evas_object_show(win);
399 test_cursor4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
401 Evas_Object *win, *bg, *bx, *ly, *bt;
404 win = elm_win_add(NULL, "cursor layout", ELM_WIN_BASIC);
405 elm_win_title_set(win, "Cursor Layout");
406 elm_win_autodel_set(win, EINA_TRUE);
408 snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
410 bg = elm_bg_add(win);
411 elm_win_resize_object_add(win, bg);
412 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
413 evas_object_show(bg);
415 bx = elm_box_add(win);
416 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
417 elm_win_resize_object_add(win, bx);
418 evas_object_show(bx);
420 ly = elm_layout_add(win);
421 elm_layout_file_set(ly, buf, "test/layout/events");
422 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
423 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
424 elm_object_cursor_set(ly, ELM_CURSOR_HAND1);
425 elm_box_pack_end(bx, ly);
426 evas_object_show(ly);
428 ly = elm_layout_add(win);
429 elm_layout_file_set(ly, buf, "test/layout/noevents");
430 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
431 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
432 elm_object_cursor_set(ly, ELM_CURSOR_XTERM);
433 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
434 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
435 elm_box_pack_end(bx, ly);
436 evas_object_show(ly);
438 ly = elm_layout_add(win);
439 elm_layout_file_set(ly, buf, "test/layout/parts2");
440 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
441 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
442 elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
443 elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
444 elm_box_pack_end(bx, ly);
445 evas_object_show(ly);
447 ly = elm_layout_add(win);
448 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
449 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
450 elm_layout_file_set(ly, buf, "test/layout/swallow");
451 bt = elm_button_add(win);
452 elm_object_text_set(bt, "Cursor over obj");
453 elm_object_part_content_set(ly, "swallow1", bt);
454 elm_object_cursor_set(bt, ELM_CURSOR_PIRATE);
455 bt = elm_button_add(win);
456 elm_object_text_set(bt, "Cursor over part");
457 elm_object_part_content_set(ly, "swallow2", bt);
458 elm_layout_part_cursor_set(ly, "swallow2", ELM_CURSOR_PIRATE);
459 elm_box_pack_end(bx, ly);
460 evas_object_show(ly);
462 evas_object_resize(win, 320, 480);
463 evas_object_show(win);