elementary/check - content_set/get/unset
[framework/uifw/elementary.git] / src / bin / test_toggle.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 void
7 test_toggle(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
8 {
9    Evas_Object *win, *bg, *bx, *ic, *tg;
10    char buf[PATH_MAX];
11
12    win = elm_win_add(NULL, "toggles", ELM_WIN_BASIC);
13    elm_win_title_set(win, "Toggles");
14    elm_win_autodel_set(win, 1);
15
16    bg = elm_bg_add(win);
17    elm_win_resize_object_add(win, bg);
18    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
19    evas_object_show(bg);
20
21    bx = elm_box_add(win);
22    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
23    elm_win_resize_object_add(win, bx);
24    evas_object_show(bx);
25
26    ic = elm_icon_add(win);
27    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
28    elm_icon_file_set(ic, buf, NULL);
29    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
30
31    tg = elm_toggle_add(win);
32    evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
33    evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
34    elm_object_text_set(tg, "Icon sized to toggle");
35    elm_object_content_set(tg, ic);
36    elm_check_state_set(tg, 1);
37    elm_object_text_part_set(tg, "on", "Yes");
38    elm_object_text_part_set(tg, "off", "No");
39    elm_box_pack_end(bx, tg);
40    evas_object_show(tg);
41    evas_object_show(ic);
42
43    ic = elm_icon_add(win);
44    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
45    elm_icon_file_set(ic, buf, NULL);
46    elm_icon_scale_set(ic, 0, 0);
47
48    tg = elm_toggle_add(win);
49    elm_object_text_set(tg, "Icon no scale");
50    elm_object_content_set(tg, ic);
51    elm_box_pack_end(bx, tg);
52    evas_object_show(tg);
53    evas_object_show(ic);
54
55    ic = elm_icon_add(win);
56    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
57    elm_icon_file_set(ic, buf, NULL);
58    elm_icon_scale_set(ic, 0, 0);
59
60    tg = elm_toggle_add(win);
61    elm_object_text_set(tg, "Icon no scale");
62    elm_object_content_set(tg, ic);
63    elm_object_disabled_set(tg, 1);
64    elm_box_pack_end(bx, tg);
65    evas_object_show(tg);
66    evas_object_show(ic);
67
68    tg = elm_toggle_add(win);
69    elm_object_text_set(tg, "Label Only");
70    elm_toggle_states_labels_set(tg, "Big long fun times label",
71                                 "Small long happy fun label");
72    elm_box_pack_end(bx, tg);
73    evas_object_show(tg);
74
75    ic = elm_icon_add(win);
76    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
77    elm_icon_file_set(ic, buf, NULL);
78    elm_icon_scale_set(ic, 0, 0);
79
80    tg = elm_check_add(win);
81    elm_object_style_set(tg, "toggle");
82    elm_object_content_set(tg, ic);
83    elm_box_pack_end(bx, tg);
84    evas_object_show(tg);
85    evas_object_show(ic);
86
87    evas_object_show(win);
88 }
89 #endif