diff options
Diffstat (limited to 'libraries/elementary/src/examples/segment_control_example.c')
-rw-r--r-- | libraries/elementary/src/examples/segment_control_example.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/libraries/elementary/src/examples/segment_control_example.c b/libraries/elementary/src/examples/segment_control_example.c new file mode 100644 index 0000000..bd98037 --- /dev/null +++ b/libraries/elementary/src/examples/segment_control_example.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /** | ||
2 | * Simple Elementary's <b>segment_control widget</b> example, illustrating its | ||
3 | * usage and API. | ||
4 | * | ||
5 | * See stdout/stderr for output. Compile with: | ||
6 | * | ||
7 | * @verbatim | ||
8 | * gcc -g segment_control_example.c -o segment_control_example `pkg-config --cflags --libs elementary` | ||
9 | * @endverbatim | ||
10 | */ | ||
11 | |||
12 | #include <Elementary.h> | ||
13 | |||
14 | static void | ||
15 | _on_done(void *data, | ||
16 | Evas_Object *obj, | ||
17 | void *event_info) | ||
18 | { | ||
19 | elm_exit(); | ||
20 | } | ||
21 | |||
22 | EAPI_MAIN int | ||
23 | elm_main(int argc, char **argv) | ||
24 | { | ||
25 | Evas_Object *win, *bg, *sc, *ic; | ||
26 | Elm_Object_Item *seg_it; | ||
27 | int count, idx; | ||
28 | |||
29 | win = elm_win_add(NULL, "segment_control", ELM_WIN_BASIC); | ||
30 | elm_win_title_set(win, "Segment Control Example"); | ||
31 | evas_object_smart_callback_add(win, "delete,request", _on_done, NULL); | ||
32 | |||
33 | bg = elm_bg_add(win); | ||
34 | elm_win_resize_object_add(win, bg); | ||
35 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
36 | evas_object_show(bg); | ||
37 | |||
38 | sc = elm_segment_control_add(win); | ||
39 | evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
40 | elm_win_resize_object_add(win, sc); | ||
41 | evas_object_show(sc); | ||
42 | |||
43 | elm_segment_control_item_add(sc, NULL, "only text"); | ||
44 | |||
45 | ic = elm_icon_add(win); | ||
46 | elm_icon_standard_set(ic, "close"); | ||
47 | elm_segment_control_item_add(sc, ic, NULL); | ||
48 | |||
49 | ic = elm_icon_add(win); | ||
50 | elm_icon_standard_set(ic, "home"); | ||
51 | elm_segment_control_item_add(sc, ic, "Home"); | ||
52 | |||
53 | ic = elm_icon_add(win); | ||
54 | elm_icon_standard_set(ic, "close"); | ||
55 | elm_segment_control_item_add(sc, ic, ""); | ||
56 | |||
57 | count = elm_segment_control_item_count_get(sc); | ||
58 | elm_segment_control_item_insert_at(sc, NULL, "Inserted at", count - 1); | ||
59 | |||
60 | seg_it = elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2); | ||
61 | elm_object_item_del(seg_it); | ||
62 | |||
63 | elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2); | ||
64 | elm_segment_control_item_del_at(sc, 2); | ||
65 | |||
66 | seg_it = elm_segment_control_item_get(sc, 0); | ||
67 | elm_object_item_text_set(seg_it, "Only Text"); | ||
68 | |||
69 | count = elm_segment_control_item_count_get(sc); | ||
70 | seg_it = elm_segment_control_item_get(sc, count / 2); | ||
71 | elm_segment_control_item_selected_set(seg_it, EINA_TRUE); | ||
72 | seg_it = elm_segment_control_item_selected_get(sc); | ||
73 | idx = elm_segment_control_item_index_get(seg_it); | ||
74 | printf("Item selected: %i\n", idx); | ||
75 | |||
76 | evas_object_show(win); | ||
77 | |||
78 | elm_run(); | ||
79 | elm_shutdown(); | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | ELM_MAIN() | ||