aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/bin/test_multibuttonentry.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/elementary/src/bin/test_multibuttonentry.c226
1 files changed, 226 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_multibuttonentry.c b/libraries/elementary/src/bin/test_multibuttonentry.c
new file mode 100644
index 0000000..d5d983c
--- /dev/null
+++ b/libraries/elementary/src/bin/test_multibuttonentry.c
@@ -0,0 +1,226 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#ifndef ELM_LIB_QUICKLAUNCH
6
7static void
8_item_selected_cb(void *data __UNUSED__,
9 Evas_Object *obj __UNUSED__,
10 void *event_info)
11{
12 Elm_Object_Item *mbe_it = event_info;
13 printf("selected item = %s\n", elm_object_item_text_get(mbe_it));
14}
15
16// "item,added" smart callback of multibuttonentry.
17static void
18_item_added_cb(void *data __UNUSED__,
19 Evas_Object *obj __UNUSED__,
20 void *event_info)
21{
22 Elm_Object_Item *mbe_it = event_info;
23 printf("added item = %s\n", elm_object_item_text_get(mbe_it));
24}
25
26// "item,deleted" smart callback
27static void
28_item_deleted_cb(void *data __UNUSED__,
29 Evas_Object *obj __UNUSED__,
30 void *event_info __UNUSED__)
31{
32 printf("deleted item\n");
33}
34
35// "item,clicked" smart callback
36static void
37_item_clicked_cb(void *data __UNUSED__,
38 Evas_Object *obj __UNUSED__,
39 void *event_info )
40{
41 Elm_Object_Item *mbe_it = event_info;
42 printf("clicked item = %s\n", elm_object_item_text_get(mbe_it));
43}
44
45static void
46_mbe_clicked_cb(void *data __UNUSED__,
47 Evas_Object *obj,
48 void *event_info __UNUSED__ )
49{
50 //Unset the multibuttonentry to contracted mode of single line
51 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
52 printf("A multibuttonentry is clicked!\n");
53 Evas_Object *entry;
54 entry = elm_multibuttonentry_entry_get(obj);
55 if (!entry)
56 {
57 printf("%s entry is NULL\n", __func__);
58 }
59
60 Evas_Coord x, y, w, h;
61 Evas_Coord mbe_x, mbe_y, mbe_w, mbe_h;
62 evas_object_geometry_get(obj, &mbe_x, &mbe_y, &mbe_w, &mbe_h);
63 evas_object_geometry_get(entry, &x, &y, &w, &h);
64 printf("%s mbe x :%d y:%d w :%d h:%d\n", __func__, mbe_x, mbe_y, mbe_w, mbe_h);
65 printf("%s wd->entry x :%d y:%d w :%d h:%d\n", __func__, x, y, w, h);
66}
67
68static void
69_mbe_unfocused_cb(void *data __UNUSED__,
70 Evas_Object *obj,
71 void *event_info __UNUSED__ )
72{
73 //Set the multibuttonentry to contracted mode of single line
74 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
75 printf("multibuttonentry unfocused!\n");
76}
77
78static void
79_mbe_focused_cb(void *data __UNUSED__,
80 Evas_Object *obj __UNUSED__,
81 void *event_info __UNUSED__ )
82{
83 printf("multibuttonentry focused!\n");
84}
85
86// "expanded" smart callback
87static void
88_expanded_cb(void *data __UNUSED__,
89 Evas_Object *obj __UNUSED__,
90 void *event_info __UNUSED__)
91{
92 printf("expanded!\n");
93}
94
95// "contracted" smart callback
96static void
97_contracted_cb(void *data __UNUSED__,
98 Evas_Object *obj __UNUSED__,
99 void *event_info __UNUSED__)
100{
101 printf("contracted!\n");
102}
103
104// "contracted,state,changed" smart callback
105static void
106_shrink_state_changed_cb(void *data __UNUSED__,
107 Evas_Object *obj __UNUSED__,
108 void *event_info __UNUSED__)
109{
110 printf("contracted state changed! \n");
111}
112
113// "item verified" confirm callback
114static Eina_Bool
115_item_filter_cb(Evas_Object *obj __UNUSED__,
116 const char* item_label,
117 void *item_data __UNUSED__,
118 void *data __UNUSED__)
119{
120 printf("%s, label: %s\n", __func__, item_label);
121
122 return EINA_TRUE;
123}
124
125static void
126_button_clicked_cb(void *data __UNUSED__,
127 Evas_Object *obj __UNUSED__,
128 void *event_info __UNUSED__)
129{
130 printf("%s button is clicked\n", __func__);
131}
132
133static Evas_Object*
134_add_multibuttonentry(Evas_Object *parent)
135{
136 Evas_Object *scr = NULL;
137 Evas_Object *mbe = NULL;
138 void *data = NULL;
139
140 scr = elm_scroller_add(parent);
141 elm_scroller_bounce_set(scr, EINA_FALSE, EINA_TRUE);
142 elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF,ELM_SCROLLER_POLICY_AUTO);
143 evas_object_show(scr);
144
145 mbe = elm_multibuttonentry_add(parent);
146 elm_object_text_set(mbe, "To: ");
147 elm_object_part_text_set(mbe, "guide", "Tap to add recipient");
148 evas_object_size_hint_weight_set(mbe, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149 evas_object_size_hint_align_set(mbe, EVAS_HINT_FILL, EVAS_HINT_FILL);
150 elm_object_content_set(scr, mbe);
151
152 // Add item verify callback to Multibuttonentry
153 elm_multibuttonentry_item_filter_append(mbe, _item_filter_cb, data);
154
155 // Add "item,selected","item,added", "item,deleted", "clicked", "unfocused",
156 // "expanded", "contracted" and "contracted,state,changed" smart callback
157 evas_object_smart_callback_add(mbe, "item,selected", _item_selected_cb, NULL);
158 evas_object_smart_callback_add(mbe, "item,added", _item_added_cb, NULL);
159 evas_object_smart_callback_add(mbe, "item,deleted", _item_deleted_cb, NULL);
160 evas_object_smart_callback_add(mbe, "item,clicked", _item_clicked_cb, NULL);
161
162 evas_object_smart_callback_add(mbe, "clicked", _mbe_clicked_cb, NULL);
163 evas_object_smart_callback_add(mbe, "focused", _mbe_focused_cb, NULL);
164 evas_object_smart_callback_add(mbe, "unfocused", _mbe_unfocused_cb, NULL);
165
166 evas_object_smart_callback_add(mbe, "expanded", _expanded_cb, NULL);
167 evas_object_smart_callback_add(mbe, "contracted", _contracted_cb, NULL);
168 evas_object_smart_callback_add(mbe, "shrink,state,changed", _shrink_state_changed_cb, NULL);
169
170 evas_object_resize(mbe, 220, 300);
171 elm_object_focus_set(mbe, EINA_TRUE);
172
173 return scr;
174}
175
176static Evas_Object*
177_add_buttons(Evas_Object *parent)
178{
179 Evas_Object *bx = NULL;
180 Evas_Object *btn;
181
182 bx = elm_box_add(parent);
183 elm_box_horizontal_set(bx, EINA_TRUE);
184 elm_box_homogeneous_set(bx, EINA_TRUE);
185
186 btn = elm_button_add(parent);
187 evas_object_smart_callback_add(btn, "clicked", _button_clicked_cb, NULL);
188 elm_object_text_set(btn, "click");
189 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
190 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
191 elm_box_pack_end(bx, btn);
192 evas_object_show(btn);
193
194 return bx;
195}
196
197void
198test_multibuttonentry(void *data __UNUSED__,
199 Evas_Object *obj __UNUSED__,
200 void *event_info __UNUSED__)
201{
202 Evas_Object *win, *sc, *bx;
203 Evas_Object *ly;
204 char buf[PATH_MAX];
205
206 win = elm_win_util_standard_add("multibuttonentry", "MultiButtonEntry");
207 elm_win_autodel_set(win, EINA_TRUE);
208
209 ly = elm_layout_add(win);
210 snprintf(buf, sizeof(buf), "%s/objects/multibuttonentry.edj", elm_app_data_dir_get());
211 elm_layout_file_set(ly, buf, "multibuttonentry_test");
212 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213 elm_win_resize_object_add(win, ly);
214 evas_object_show(ly);
215
216 sc = _add_multibuttonentry(ly);
217 elm_object_part_content_set(ly, "multibuttonentry", sc);
218
219 bx = _add_buttons(ly);
220 elm_object_part_content_set(ly, "box", bx);
221
222 evas_object_resize(win, 320, 480);
223 evas_object_show(win);
224 elm_object_focus_set(sc, EINA_TRUE);
225}
226#endif