2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
8 _response_cb(void *data, Evas_Object *obj __UNUSED__,
9 void *event_info __UNUSED__)
11 Evas_Object *popup_data = evas_object_data_get(data, "im");
12 if (popup_data) evas_object_del(popup_data);
13 evas_object_hide(data);
14 evas_object_del(data);
18 _block_clicked_cb(void *data __UNUSED__, Evas_Object *obj,
19 void *event_info __UNUSED__)
21 printf("\nblock,clicked callback\n");
22 Evas_Object *popup_data = evas_object_data_get(obj, "im");
23 if (popup_data) evas_object_del(popup_data);
28 _item_selected_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
31 printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
35 _list_click(void *data __UNUSED__, Evas_Object *obj,
36 void *event_info __UNUSED__)
38 Elm_Object_Item *it = elm_list_selected_item_get(obj);
40 elm_list_item_selected_set(it, EINA_FALSE);
44 _popup_center_text_cb(void *data, Evas_Object *obj __UNUSED__,
45 void *event_info __UNUSED__)
49 popup = elm_popup_add(data);
50 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
51 elm_object_text_set(popup, "This Popup has content area and "
52 "timeout value is 3 seconds");
53 elm_popup_timeout_set(popup, 3.0);
54 evas_object_smart_callback_add(popup, "timeout", _response_cb, popup);
55 evas_object_show(popup);
59 _popup_center_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
60 void *event_info __UNUSED__)
65 popup = elm_popup_add(data);
66 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67 elm_object_text_set(popup, "This Popup has content area and "
68 "action area set, action area has one button Close");
69 btn = elm_button_add(popup);
70 elm_object_text_set(btn, "Close");
71 elm_object_part_content_set(popup, "button1", btn);
72 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
73 evas_object_show(popup);
77 _popup_center_title_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
78 void *event_info __UNUSED__)
83 popup = elm_popup_add(data);
84 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
85 elm_object_text_set(popup, "This Popup has title area, content area and "
86 "action area set, action area has one button Close");
87 elm_object_part_text_set(popup, "title,text", "Title");
88 btn = elm_button_add(popup);
89 elm_object_text_set(btn, "Close");
90 elm_object_part_content_set(popup, "button1", btn);
91 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
92 evas_object_show(popup);
96 _popup_center_title_text_block_clicked_event_cb(void *data,
97 Evas_Object *obj __UNUSED__,
98 void *event_info __UNUSED__)
102 popup = elm_popup_add(data);
103 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
104 elm_object_text_set(popup, "This Popup has title area and content area. "
105 "When clicked on blocked event region, popup gets "
107 elm_object_part_text_set(popup, "title,text", "Title");
108 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
110 evas_object_show(popup);
114 _popup_bottom_title_text_3button_cb(void *data, Evas_Object *obj __UNUSED__,
115 void *event_info __UNUSED__)
118 Evas_Object *icon, *btn1, *btn2, *btn3;
121 popup = elm_popup_add(data);
122 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
123 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124 elm_object_text_set(popup, "This Popup has title area, content area and "
125 "action area set with content being character wrapped. "
126 "action area has three buttons OK, Cancel and Close");
127 elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
128 elm_object_part_text_set(popup, "title,text", "Title");
129 icon = elm_icon_add(popup);
130 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
131 elm_app_data_dir_get());
132 elm_icon_file_set(icon, buf, NULL);
133 elm_object_part_content_set(popup, "title,icon", icon);
134 btn1 = elm_button_add(popup);
135 elm_object_text_set(btn1, "OK");
136 elm_object_part_content_set(popup, "button1", btn1);
137 btn2 = elm_button_add(popup);
138 elm_object_text_set(btn2, "Cancel");
139 elm_object_part_content_set(popup, "button2", btn2);
140 btn3 = elm_button_add(popup);
141 elm_object_text_set(btn3, "Close");
142 elm_object_part_content_set(popup, "button3", btn3);
143 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
144 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
145 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
146 evas_object_show(popup);
150 _popup_center_title_content_3button_cb(void *data, Evas_Object *obj __UNUSED__,
151 void *event_info __UNUSED__)
154 Evas_Object *icon, *btn, *btn1, *btn2, *btn3;
157 popup = elm_popup_add(data);
158 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
159 btn = elm_button_add(popup);
160 elm_object_text_set(btn, "Content");
161 icon = elm_icon_add(btn);
162 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
163 elm_app_data_dir_get());
164 elm_icon_file_set(icon, buf, NULL);
165 elm_object_content_set(btn, icon);
166 elm_object_content_set(popup, btn);
167 elm_object_part_text_set(popup, "title,text", "Title");
168 btn1 = elm_button_add(popup);
169 elm_object_text_set(btn1, "OK");
170 elm_object_part_content_set(popup, "button1", btn1);
171 btn2 = elm_button_add(popup);
172 elm_object_text_set(btn2, "Cancel");
173 elm_object_part_content_set(popup, "button2", btn2);
174 btn3 = elm_button_add(popup);
175 elm_object_text_set(btn3, "Close");
176 elm_object_part_content_set(popup, "button3", btn3);
177 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
178 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
179 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
180 evas_object_show(popup);
184 _popup_center_title_item_3button_cb(void *data, Evas_Object *obj __UNUSED__,
185 void *event_info __UNUSED__)
189 Evas_Object *popup, *icon1, *btn1, *btn2, *btn3;
191 popup = elm_popup_add(data);
192 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193 icon1 = elm_icon_add(popup);
194 elm_object_part_text_set(popup, "title,text", "Title");
195 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
196 elm_app_data_dir_get());
197 elm_icon_file_set(icon1, buf, NULL);
198 for (i = 0; i < 10; i++)
200 snprintf(buf, sizeof(buf), "Item%u", i+1);
202 elm_popup_item_append(popup, buf, icon1, _item_selected_cb, NULL);
204 elm_popup_item_append(popup, buf, NULL, _item_selected_cb, NULL);
206 btn1 = elm_button_add(popup);
207 elm_object_text_set(btn1, "OK");
208 elm_object_part_content_set(popup, "button1", btn1);
209 btn2 = elm_button_add(popup);
210 elm_object_text_set(btn2, "Cancel");
211 elm_object_part_content_set(popup, "button2", btn2);
212 btn3 = elm_button_add(popup);
213 elm_object_text_set(btn3, "Close");
214 elm_object_part_content_set(popup, "button3", btn3);
215 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
216 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
217 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
218 evas_object_show(popup);
222 _restack_btn_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
228 popup_data = evas_object_data_get(data, "im");
229 if (popup_data) return;
231 im = evas_object_image_filled_add(evas_object_evas_get(obj));
232 snprintf(buf, sizeof(buf), "%s/images/%s",
233 elm_app_data_dir_get(), "twofish.jpg");
234 evas_object_image_file_set(im, buf, NULL);
235 evas_object_move(im, 40, 40);
236 evas_object_resize(im, 320, 320);
237 evas_object_show(im);
238 evas_object_data_set((Evas_Object *)data, "im", im);
240 evas_object_raise((Evas_Object *)data);
244 _popup_center_title_text_2button_restack_cb(void *data, Evas_Object *obj __UNUSED__,
245 void *event_info __UNUSED__)
248 Evas_Object *btn, *btn2;
250 popup = elm_popup_add(data);
251 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
252 elm_object_text_set(popup, "When you click the 'Restack' button, "
253 "an image will be located under this popup");
254 elm_object_part_text_set(popup, "title,text", "Title");
255 btn = elm_button_add(popup);
256 elm_object_text_set(btn, "Restack");
257 elm_object_part_content_set(popup, "button1", btn);
258 evas_object_smart_callback_add(btn, "clicked", _restack_btn_clicked, popup);
259 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
262 btn2 = elm_button_add(popup);
263 elm_object_text_set(btn2, "Close");
264 elm_object_part_content_set(popup, "button2", btn2);
265 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
267 evas_object_show(popup);
271 test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
272 void *event_info __UNUSED__)
274 Evas_Object *win, *list;
276 win = elm_win_util_standard_add("popup", "Popup");
277 elm_win_autodel_set(win, EINA_TRUE);
279 list = elm_list_add(win);
280 elm_win_resize_object_add(win, list);
281 elm_list_mode_set(list, ELM_LIST_LIMIT);
282 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
283 evas_object_smart_callback_add(list, "selected", _list_click, NULL);
285 elm_list_item_append(list, "popup-center-text", NULL, NULL,
286 _popup_center_text_cb, win);
287 elm_list_item_append(list, "popup-center-text + 1 button", NULL, NULL,
288 _popup_center_text_1button_cb, win);
289 elm_list_item_append(list, "popup-center-title + text + 1 button", NULL,
290 NULL, _popup_center_title_text_1button_cb, win);
292 elm_list_item_append(list,
293 "popup-center-title + text (block,clicked handling)",
295 _popup_center_title_text_block_clicked_event_cb, win);
296 elm_list_item_append(list, "popup-bottom-title + text + 3 buttons", NULL,
297 NULL, _popup_bottom_title_text_3button_cb, win);
298 elm_list_item_append(list, "popup-center-title + content + 3 buttons", NULL,
299 NULL, _popup_center_title_content_3button_cb, win);
300 elm_list_item_append(list, "popup-center-title + items + 3 buttons", NULL,
301 NULL, _popup_center_title_item_3button_cb, win);
302 elm_list_item_append(list, "popup-center-title + text + 2 buttons (check restacking)", NULL, NULL,
303 _popup_center_title_text_2button_restack_cb, win);
305 evas_object_show(list);
306 evas_object_show(win);
307 evas_object_resize(win, 480, 800);