aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/bin/test_button.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/elementary/src/bin/test_button.c')
-rw-r--r--libraries/elementary/src/bin/test_button.c169
1 files changed, 169 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_button.c b/libraries/elementary/src/bin/test_button.c
new file mode 100644
index 0000000..be5d655
--- /dev/null
+++ b/libraries/elementary/src/bin/test_button.c
@@ -0,0 +1,169 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#ifndef ELM_LIB_QUICKLAUNCH
6static void
7_bt_repeated(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
8{
9 static int count;
10 char buf[16];
11
12 snprintf(buf, sizeof(buf), "count=%d", count++);
13 if (count >= 10000)
14 count = 0;
15 elm_object_text_set(obj, buf);
16}
17
18static void
19_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
20{
21 int param = (int)(long)(data);
22
23 printf("clicked event on Button:%d\n", param);
24}
25
26static void
27_bt_unpressed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
28{
29 int param = (int)(long)(data);
30
31 printf("unpressed event on Button:%d\n", param);
32}
33
34void
35test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
36{
37 Evas_Object *win, *scr, *bx, *ic, *bt;
38 char buf[PATH_MAX];
39
40 win = elm_win_util_standard_add("buttons", "Buttons");
41 elm_win_autodel_set(win, EINA_TRUE);
42
43 scr = elm_scroller_add(win);
44 elm_scroller_bounce_set(scr, EINA_FALSE, EINA_TRUE);
45 elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
46 elm_win_resize_object_add(win, scr);
47 evas_object_show(scr);
48 evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
49
50 bx = elm_box_add(win);
51 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
52 elm_object_content_set(scr, bx);
53 evas_object_show(bx);
54
55 ic = elm_icon_add(win);
56 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
57 elm_icon_file_set(ic, buf, NULL);
58 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
59 bt = elm_button_add(win);
60 elm_object_text_set(bt, "Icon sized to button");
61 elm_object_part_content_set(bt, "icon", ic);
62 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)1);
63 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)1);
64 elm_box_pack_end(bx, bt);
65 evas_object_show(bt);
66 evas_object_show(ic);
67
68 ic = elm_icon_add(bx);
69 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
70 elm_icon_file_set(ic, buf, NULL);
71 elm_icon_resizable_set(ic, 0, 0);
72 bt = elm_button_add(win);
73 elm_object_text_set(bt, "Icon no scale");
74 elm_object_part_content_set(bt, "icon", ic);
75 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)2);
76 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)2);
77 elm_box_pack_end(bx, bt);
78 evas_object_show(bt);
79 evas_object_show(ic);
80
81 ic = elm_icon_add(win);
82 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
83 elm_icon_file_set(ic, buf, NULL);
84 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
85 bt = elm_button_add(win);
86 elm_object_text_set(bt, "Disabled Button");
87 elm_object_part_content_set(bt, "icon", ic);
88 elm_object_disabled_set(bt, EINA_TRUE);
89 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)3);
90 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)3);
91 elm_box_pack_end(bx, bt);
92 evas_object_show(bt);
93 evas_object_show(ic);
94
95 ic = elm_icon_add(win);
96 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
97 elm_icon_file_set(ic, buf, NULL);
98 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
99 bt = elm_button_add(win);
100 elm_object_part_content_set(bt, "icon", ic);
101 elm_object_disabled_set(bt, EINA_TRUE);
102 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)4);
103 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)4);
104 elm_box_pack_end(bx, bt);
105 evas_object_show(bt);
106 evas_object_show(ic);
107
108 bt = elm_button_add(win);
109 elm_object_text_set(bt, "Label Only");
110 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)5);
111 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)5);
112 elm_box_pack_end(bx, bt);
113 evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL);
114 elm_button_autorepeat_set(bt, EINA_TRUE);
115 elm_button_autorepeat_initial_timeout_set(bt, 2.0);
116 elm_button_autorepeat_gap_timeout_set(bt, 0.5);
117 evas_object_show(bt);
118
119 ic = elm_icon_add(win);
120 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
121 elm_icon_file_set(ic, buf, NULL);
122 elm_icon_resizable_set(ic, 0, 0);
123 bt = elm_button_add(win);
124 elm_object_part_content_set(bt, "icon", ic);
125 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)6);
126 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)6);
127 elm_box_pack_end(bx, bt);
128 evas_object_show(bt);
129 evas_object_show(ic);
130
131 bt = elm_button_add(win);
132 elm_object_style_set(bt, "anchor");
133 elm_object_text_set(bt, "Anchor style");
134 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)7);
135 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)7);
136 elm_box_pack_end(bx, bt);
137 evas_object_show(bt);
138
139 ic = elm_icon_add(win);
140 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
141 elm_icon_file_set(ic, buf, NULL);
142 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
143 bt = elm_button_add(win);
144 elm_object_style_set(bt, "anchor");
145 elm_object_part_content_set(bt, "icon", ic);
146 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)8);
147 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)8);
148 elm_box_pack_end(bx, bt);
149 evas_object_show(bt);
150 evas_object_show(ic);
151
152 ic = elm_icon_add(win);
153 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
154 elm_icon_file_set(ic, buf, NULL);
155 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
156 bt = elm_button_add(win);
157 elm_object_access_info_set(bt, "This is some custom text describing this widget");
158 elm_object_style_set(bt, "anchor");
159 elm_object_part_content_set(bt, "icon", ic);
160 elm_object_disabled_set(bt, EINA_TRUE);
161 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)9);
162 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)9);
163 elm_box_pack_end(bx, bt);
164 evas_object_show(bt);
165 evas_object_show(ic);
166 evas_object_resize(win, 320, 480);
167 evas_object_show(win);
168}
169#endif