1 /* Test for Focus Chain Linear*/
2 #include <Elementary.h>
4 # include "elementary_config.h"
6 #ifndef ELM_LIB_QUICKLAUNCH
9 _event(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
11 if (type == EVAS_CALLBACK_KEY_DOWN)
13 else if (type == EVAS_CALLBACK_KEY_UP)
17 Evas_Event_Key_Down *ev = event_info;
18 printf("%s\n", ev->key);
20 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
25 _on_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *einfo __UNUSED__)
27 //Evas_Event_Key_Down *event = einfo;
28 //printf("%s %p Key %s Parent %p\n", evas_object_type_get(obj),
29 // obj, event->keyname, evas_object_smart_parent_get(obj));
33 _disable(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
35 Evas_Object *bt = data;
36 elm_object_disabled_set(bt, EINA_TRUE);
40 _enable(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
42 Evas_Object *bt = data;
43 elm_object_disabled_set(bt, EINA_FALSE);
47 my_show(Evas_Object *obj)
49 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
51 evas_object_show(obj);
55 test_focus(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
60 win = elm_win_add(NULL, "focus", ELM_WIN_BASIC);
61 elm_win_title_set(win, "Focus");
62 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
63 evas_object_resize(win, 800, 600);
64 elm_object_event_callback_add(win, _event, NULL);
65 elm_win_autodel_set(win, EINA_TRUE);
71 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
73 elm_win_resize_object_add(win, bg);
77 Evas_Object *mainbx = elm_box_add(win);
78 elm_box_horizontal_set(mainbx, EINA_TRUE);
79 elm_win_resize_object_add(win, mainbx);
80 evas_object_size_hint_weight_set(mainbx, EVAS_HINT_EXPAND,
85 Evas_Object *bx = elm_box_add(win);
86 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
88 elm_box_pack_end(mainbx, bx);
92 Evas_Object *lb = elm_label_add(win);
93 elm_object_text_set(lb,
94 "<b>Use Tab and Shift+Tab</b>"
96 evas_object_size_hint_weight_set(lb, 0.0, 0.0);
97 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL,
99 elm_box_pack_end(bx, lb);
104 Evas_Object *tg = elm_toggle_add(win);
105 elm_toggle_states_labels_set(tg, "Yes", "No");
106 elm_box_pack_end(bx, tg);
111 Evas_Object *en = elm_entry_add(win);
112 elm_entry_scrollable_set(en, EINA_TRUE);
113 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
114 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
115 elm_entry_entry_set(en, "This is a single line");
116 elm_entry_single_line_set(en, 1);
117 elm_box_pack_end(bx, en);
122 Evas_Object *bx2 = elm_box_add(win);
123 elm_box_horizontal_set(bx2, EINA_TRUE);
124 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
126 evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
127 elm_box_pack_end(bx, bx2);
132 bt = elm_button_add(win);
133 elm_object_text_set(bt, "Box");
134 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
136 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
138 elm_object_disabled_set(bt, EINA_TRUE);
139 elm_box_pack_end(bx2, bt);
144 Evas_Object *sc = elm_scroller_add(win);
145 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND,
147 evas_object_size_hint_align_set(sc, EVAS_HINT_FILL,
149 elm_scroller_bounce_set(sc, 1, 1);
150 elm_scroller_content_min_limit(sc, 1, 1);
151 elm_box_pack_end(bx2, sc);
156 bt = elm_button_add(win);
157 elm_object_text_set(bt, "Scroller");
158 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
160 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
161 elm_object_event_callback_add(bt, _event, NULL);
162 elm_scroller_content_set(sc, bt);
164 elm_object_event_callback_del(bt, _event, NULL);
173 bt = elm_button_add(win);
174 elm_object_text_set(bt, "Box");
175 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
177 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
178 elm_box_pack_end(bx, bt);
183 Evas_Object *bx2 = elm_box_add(win);
184 elm_box_horizontal_set(bx2, EINA_TRUE);
185 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
187 evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
188 elm_box_pack_end(bx, bx2);
193 Evas_Object *bx3 = elm_box_add(win);
194 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL,
196 evas_object_size_hint_weight_set(bx3, 0.0, 0.0);
197 elm_box_pack_end(bx2, bx3);
203 bt = elm_button_add(win);
204 elm_object_text_set(bt, "Box");
205 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
207 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
208 elm_box_pack_end(bx3, bt);
214 Evas_Object *sc = elm_scroller_add(win);
215 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND,
217 evas_object_size_hint_align_set(sc, EVAS_HINT_FILL,
219 elm_scroller_bounce_set(sc, 0, 1);
220 elm_scroller_content_min_limit(sc, 1, 0);
221 elm_box_pack_end(bx2, sc);
224 Evas_Object *bx3 = elm_box_add(win);
225 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL,
227 evas_object_size_hint_weight_set(bx3, 0.0, 0.0);
228 elm_scroller_content_set(sc, bx3);
234 bt = elm_button_add(win);
235 elm_object_text_set(bt, "BX Scroller");
236 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
238 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
239 elm_box_pack_end(bx3, bt);
248 Evas_Object *ly = elm_layout_add(win);
249 snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
250 elm_layout_file_set(ly, buf, "twolines");
251 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND,
253 elm_box_pack_end(mainbx, ly);
257 Evas_Object *bx2 = elm_box_add(win);
258 elm_box_horizontal_set(bx2, EINA_TRUE);
259 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
261 evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
262 elm_layout_content_set(ly, "element1", bx2);
268 bt = elm_button_add(win);
269 elm_object_text_set(bt, "Layout");
270 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
272 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
273 elm_box_pack_end(bx2, bt);
275 elm_object_focus_custom_chain_prepend(bx2, bt, NULL);
280 Evas_Object *bx2 = elm_box_add(win);
281 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
283 evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
284 elm_layout_content_set(ly, "element2", bx2);
289 bt = elm_button_add(win);
290 elm_object_text_set(bt, "Disable");
291 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
293 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
294 elm_box_pack_end(bx2, bt);
295 evas_object_smart_callback_add(bt, "clicked", _disable, bt);
297 elm_object_focus_custom_chain_prepend(bx2, bt, NULL);
300 bt2 = elm_button_add(win);
301 elm_object_text_set(bt2, "Enable");
302 evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL,
304 evas_object_size_hint_weight_set(bt2, 0.0, 0.0);
305 elm_box_pack_end(bx2, bt2);
306 evas_object_smart_callback_add(bt2, "clicked", _enable, bt);
308 elm_object_focus_custom_chain_append(bx2, bt2, NULL);
315 Evas_Object *bx = elm_box_add(win);
316 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
318 elm_box_pack_end(mainbx, bx);
322 Evas_Object *fr = elm_frame_add(win);
323 elm_object_text_set(fr, "Frame");
324 elm_box_pack_end(bx, fr);
325 evas_object_show(fr);
328 Evas_Object *tb = elm_table_add(win);
329 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
330 elm_frame_content_set(fr, tb);
332 for (j = 0; j < 1; j++)
333 for (i = 0; i < 2; i++)
336 bt = elm_button_add(win);
337 elm_object_text_set(bt, "Table");
338 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
340 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
341 elm_table_pack(tb, bt, i, j, 1, 1);
348 Evas_Object *fr = elm_bubble_add(win);
349 elm_bubble_label_set(fr, "Bubble");
350 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
351 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL,
353 elm_box_pack_end(bx, fr);
354 evas_object_show(fr);
357 Evas_Object *tb = elm_table_add(win);
358 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
359 elm_bubble_content_set(fr, tb);
361 for (j = 0; j < 2; j++)
362 for (i = 0; i < 1; i++)
365 bt = elm_button_add(win);
366 elm_object_text_set(bt, "Table");
367 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
369 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
370 elm_table_pack(tb, bt, i, j, 1, 1);