1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
8 _response_cb(void *data, Evas_Object *obj __UNUSED__,
9 void *event_info __UNUSED__)
11 evas_object_hide(data);
12 evas_object_del(data);
16 _block_clicked_cb(void *data __UNUSED__, Evas_Object *obj,
17 void *event_info __UNUSED__)
19 printf("\nblock,clicked callback\n");
24 _item_selected_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
27 printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
31 _list_click(void *data __UNUSED__, Evas_Object *obj,
32 void *event_info __UNUSED__)
34 Elm_Object_Item *it = elm_list_selected_item_get(obj);
36 elm_list_item_selected_set(it, EINA_FALSE);
40 _popup_center_text_cb(void *data, Evas_Object *obj __UNUSED__,
41 void *event_info __UNUSED__)
45 popup = elm_popup_add(data);
46 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
47 elm_object_text_set(popup, "This Popup has content area and "
48 "timeout value is 3 seconds");
49 elm_popup_timeout_set(popup, 3.0);
50 evas_object_smart_callback_add(popup, "timeout", _response_cb, popup);
51 evas_object_show(popup);
55 _popup_center_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
56 void *event_info __UNUSED__)
61 popup = elm_popup_add(data);
62 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63 elm_object_text_set(popup, "This Popup has content area and "
64 "action area set, action area has one button Close");
65 btn = elm_button_add(popup);
66 elm_object_text_set(btn, "Close");
67 elm_object_part_content_set(popup, "button1", btn);
68 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
69 evas_object_show(popup);
73 _popup_center_title_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
74 void *event_info __UNUSED__)
79 popup = elm_popup_add(data);
80 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
81 elm_object_text_set(popup, "This Popup has title area, content area and "
82 "action area set, action area has one button Close");
83 elm_object_part_text_set(popup, "title,text", "Title");
84 btn = elm_button_add(popup);
85 elm_object_text_set(btn, "Close");
86 elm_object_part_content_set(popup, "button1", btn);
87 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
88 evas_object_show(popup);
92 _popup_center_title_text_block_clicked_event_cb(void *data,
93 Evas_Object *obj __UNUSED__,
94 void *event_info __UNUSED__)
98 popup = elm_popup_add(data);
99 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
100 elm_object_text_set(popup, "This Popup has title area and content area. "
101 "When clicked on blocked event region, popup gets "
103 elm_object_part_text_set(popup, "title,text", "Title");
104 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
106 evas_object_show(popup);
110 _popup_bottom_title_text_3button_cb(void *data, Evas_Object *obj __UNUSED__,
111 void *event_info __UNUSED__)
114 Evas_Object *icon, *btn1, *btn2, *btn3;
117 popup = elm_popup_add(data);
118 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
119 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
120 elm_object_text_set(popup, "This Popup has title area, content area and "
121 "action area set with content being character wrapped. "
122 "action area has three buttons OK, Cancel and Close");
123 elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
124 elm_object_part_text_set(popup, "title,text", "Title");
125 icon = elm_icon_add(popup);
126 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
127 elm_app_data_dir_get());
128 elm_icon_file_set(icon, buf, NULL);
129 elm_object_part_content_set(popup, "title,icon", icon);
130 btn1 = elm_button_add(popup);
131 elm_object_text_set(btn1, "OK");
132 elm_object_part_content_set(popup, "button1", btn1);
133 btn2 = elm_button_add(popup);
134 elm_object_text_set(btn2, "Cancel");
135 elm_object_part_content_set(popup, "button2", btn2);
136 btn3 = elm_button_add(popup);
137 elm_object_text_set(btn3, "Close");
138 elm_object_part_content_set(popup, "button3", btn3);
139 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
140 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
141 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
142 evas_object_show(popup);
146 _popup_center_title_content_3button_cb(void *data, Evas_Object *obj __UNUSED__,
147 void *event_info __UNUSED__)
150 Evas_Object *icon, *btn, *btn1, *btn2, *btn3;
153 popup = elm_popup_add(data);
154 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
155 btn = elm_button_add(popup);
156 elm_object_text_set(btn, "Content");
157 icon = elm_icon_add(btn);
158 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
159 elm_app_data_dir_get());
160 elm_icon_file_set(icon, buf, NULL);
161 elm_object_content_set(btn, icon);
162 elm_object_content_set(popup, btn);
163 elm_object_part_text_set(popup, "title,text", "Title");
164 btn1 = elm_button_add(popup);
165 elm_object_text_set(btn1, "OK");
166 elm_object_part_content_set(popup, "button1", btn1);
167 btn2 = elm_button_add(popup);
168 elm_object_text_set(btn2, "Cancel");
169 elm_object_part_content_set(popup, "button2", btn2);
170 btn3 = elm_button_add(popup);
171 elm_object_text_set(btn3, "Close");
172 elm_object_part_content_set(popup, "button3", btn3);
173 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
174 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
175 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
176 evas_object_show(popup);
180 _popup_center_title_item_3button_cb(void *data, Evas_Object *obj __UNUSED__,
181 void *event_info __UNUSED__)
185 Evas_Object *popup, *icon1, *btn1, *btn2, *btn3;
187 popup = elm_popup_add(data);
188 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
189 icon1 = elm_icon_add(popup);
190 elm_object_part_text_set(popup, "title,text", "Title");
191 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
192 elm_app_data_dir_get());
193 elm_icon_file_set(icon1, buf, NULL);
194 for (i = 0; i < 10; i++)
196 snprintf(buf, sizeof(buf), "Item%u", i+1);
198 elm_popup_item_append(popup, buf, icon1, _item_selected_cb, NULL);
200 elm_popup_item_append(popup, buf, NULL, _item_selected_cb, NULL);
202 btn1 = elm_button_add(popup);
203 elm_object_text_set(btn1, "OK");
204 elm_object_part_content_set(popup, "button1", btn1);
205 btn2 = elm_button_add(popup);
206 elm_object_text_set(btn2, "Cancel");
207 elm_object_part_content_set(popup, "button2", btn2);
208 btn3 = elm_button_add(popup);
209 elm_object_text_set(btn3, "Close");
210 elm_object_part_content_set(popup, "button3", btn3);
211 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
212 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
213 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
214 evas_object_show(popup);
218 test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
219 void *event_info __UNUSED__)
221 Evas_Object *win, *bg, *list;
223 win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
224 elm_win_title_set(win, "popup");
225 elm_win_autodel_set(win, EINA_TRUE);
227 bg = elm_bg_add(win);
228 elm_win_resize_object_add(win, bg);
229 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
230 evas_object_show(bg);
232 list = elm_list_add(win);
233 elm_win_resize_object_add(win, list);
234 elm_list_mode_set(list, ELM_LIST_LIMIT);
235 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
236 evas_object_smart_callback_add(list, "selected", _list_click, NULL);
238 elm_list_item_append(list, "popup-center-text", NULL, NULL,
239 _popup_center_text_cb, win);
240 elm_list_item_append(list, "popup-center-text + 1 button", NULL, NULL,
241 _popup_center_text_1button_cb, win);
242 elm_list_item_append(list, "popup-center-title + text + 1 button", NULL,
243 NULL, _popup_center_title_text_1button_cb, win);
245 elm_list_item_append(list,
246 "popup-center-title + text (block,clicked handling)",
248 _popup_center_title_text_block_clicked_event_cb, win);
249 elm_list_item_append(list, "popup-bottom-title + text + 3 buttons", NULL,
250 NULL, _popup_bottom_title_text_3button_cb, win);
251 elm_list_item_append(list, "popup-center-title + content + 3 buttons", NULL,
252 NULL, _popup_center_title_content_3button_cb, win);
253 elm_list_item_append(list, "popup-center-title + items + 3 buttons", NULL,
254 NULL, _popup_center_title_item_3button_cb, win);
256 evas_object_show(list);
257 evas_object_show(win);
258 evas_object_resize(win, 480, 800);