2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
7 static Evas_Object *g_popup = NULL;
11 _response_cb(void *data, Evas_Object *obj __UNUSED__,
12 void *event_info __UNUSED__)
14 Evas_Object *popup_data = evas_object_data_get(data, "im");
15 if (popup_data) evas_object_del(popup_data);
16 evas_object_hide(data);
17 evas_object_del(data);
21 _g_popup_response_cb(void *data, Evas_Object *obj __UNUSED__,
22 void *event_info __UNUSED__)
24 evas_object_hide(data);
28 _block_clicked_cb(void *data __UNUSED__, Evas_Object *obj,
29 void *event_info __UNUSED__)
31 printf("\nblock,clicked callback\n");
32 Evas_Object *popup_data = evas_object_data_get(obj, "im");
33 if (popup_data) evas_object_del(popup_data);
38 _item_selected_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
41 printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
45 _list_click(void *data __UNUSED__, Evas_Object *obj,
46 void *event_info __UNUSED__)
48 Elm_Object_Item *it = elm_list_selected_item_get(obj);
50 elm_list_item_selected_set(it, EINA_FALSE);
54 _popup_center_text_cb(void *data, Evas_Object *obj __UNUSED__,
55 void *event_info __UNUSED__)
59 popup = elm_popup_add(data);
60 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61 elm_object_text_set(popup, "This Popup has content area and "
62 "timeout value is 3 seconds");
63 elm_popup_timeout_set(popup, 3.0);
64 evas_object_smart_callback_add(popup, "timeout", _response_cb, popup);
65 evas_object_show(popup);
69 _popup_center_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
70 void *event_info __UNUSED__)
75 popup = elm_popup_add(data);
76 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77 elm_object_text_set(popup, "This Popup has content area and "
78 "action area set, action area has one button Close");
79 btn = elm_button_add(popup);
80 elm_object_text_set(btn, "Close");
81 elm_object_part_content_set(popup, "button1", btn);
82 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
83 evas_object_show(popup);
87 _popup_center_title_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
88 void *event_info __UNUSED__)
93 popup = elm_popup_add(data);
94 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
95 elm_object_text_set(popup, "This Popup has title area, content area and "
96 "action area set, action area has one button Close");
97 elm_object_part_text_set(popup, "title,text", "Title");
98 btn = elm_button_add(popup);
99 elm_object_text_set(btn, "Close");
100 elm_object_part_content_set(popup, "button1", btn);
101 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
102 evas_object_show(popup);
106 _popup_center_title_text_block_clicked_event_cb(void *data,
107 Evas_Object *obj __UNUSED__,
108 void *event_info __UNUSED__)
112 popup = elm_popup_add(data);
113 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114 elm_object_text_set(popup, "This Popup has title area and content area. "
115 "When clicked on blocked event region, popup gets "
117 elm_object_part_text_set(popup, "title,text", "Title");
118 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
120 evas_object_show(popup);
124 _popup_bottom_title_text_3button_cb(void *data, Evas_Object *obj __UNUSED__,
125 void *event_info __UNUSED__)
128 Evas_Object *icon, *btn1, *btn2, *btn3;
131 popup = elm_popup_add(data);
132 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
133 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
134 elm_object_text_set(popup, "This Popup has title area, content area and "
135 "action area set with content being character wrapped. "
136 "action area has three buttons OK, Cancel and Close");
137 elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
138 elm_object_part_text_set(popup, "title,text", "Title");
139 icon = elm_icon_add(popup);
140 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
141 elm_app_data_dir_get());
142 elm_image_file_set(icon, buf, NULL);
143 elm_object_part_content_set(popup, "title,icon", icon);
144 btn1 = elm_button_add(popup);
145 elm_object_text_set(btn1, "OK");
146 elm_object_part_content_set(popup, "button1", btn1);
147 btn2 = elm_button_add(popup);
148 elm_object_text_set(btn2, "Cancel");
149 elm_object_part_content_set(popup, "button2", btn2);
150 btn3 = elm_button_add(popup);
151 elm_object_text_set(btn3, "Close");
152 elm_object_part_content_set(popup, "button3", btn3);
153 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
154 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
155 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
156 evas_object_show(popup);
160 _popup_center_title_content_3button_cb(void *data, Evas_Object *obj __UNUSED__,
161 void *event_info __UNUSED__)
164 Evas_Object *icon, *btn, *btn1, *btn2, *btn3;
167 popup = elm_popup_add(data);
168 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169 btn = elm_button_add(popup);
170 elm_object_text_set(btn, "Content");
171 icon = elm_icon_add(btn);
172 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
173 elm_app_data_dir_get());
174 elm_image_file_set(icon, buf, NULL);
175 elm_object_content_set(btn, icon);
176 elm_object_content_set(popup, btn);
177 elm_object_part_text_set(popup, "title,text", "Title");
178 btn1 = elm_button_add(popup);
179 elm_object_text_set(btn1, "OK");
180 elm_object_part_content_set(popup, "button1", btn1);
181 btn2 = elm_button_add(popup);
182 elm_object_text_set(btn2, "Cancel");
183 elm_object_part_content_set(popup, "button2", btn2);
184 btn3 = elm_button_add(popup);
185 elm_object_text_set(btn3, "Close");
186 elm_object_part_content_set(popup, "button3", btn3);
187 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
188 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
189 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
190 evas_object_show(popup);
194 _popup_center_title_item_3button_cb(void *data, Evas_Object *obj __UNUSED__,
195 void *event_info __UNUSED__)
199 Evas_Object *popup, *icon1, *btn1, *btn2, *btn3;
201 popup = elm_popup_add(data);
202 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
203 icon1 = elm_icon_add(popup);
204 elm_object_part_text_set(popup, "title,text", "Title");
205 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
206 elm_app_data_dir_get());
207 elm_image_file_set(icon1, buf, NULL);
208 for (i = 0; i < 10; i++)
210 snprintf(buf, sizeof(buf), "Item%u", i+1);
212 elm_popup_item_append(popup, buf, icon1, _item_selected_cb, NULL);
214 elm_popup_item_append(popup, buf, NULL, _item_selected_cb, NULL);
216 btn1 = elm_button_add(popup);
217 elm_object_text_set(btn1, "OK");
218 elm_object_part_content_set(popup, "button1", btn1);
219 btn2 = elm_button_add(popup);
220 elm_object_text_set(btn2, "Cancel");
221 elm_object_part_content_set(popup, "button2", btn2);
222 btn3 = elm_button_add(popup);
223 elm_object_text_set(btn3, "Close");
224 elm_object_part_content_set(popup, "button3", btn3);
225 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
226 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
227 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
228 evas_object_show(popup);
232 _restack_btn_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
238 popup_data = evas_object_data_get(data, "im");
239 if (popup_data) return;
241 im = evas_object_image_filled_add(evas_object_evas_get(obj));
242 snprintf(buf, sizeof(buf), "%s/images/%s",
243 elm_app_data_dir_get(), "twofish.jpg");
244 evas_object_image_file_set(im, buf, NULL);
245 evas_object_move(im, 40, 40);
246 evas_object_resize(im, 320, 320);
247 evas_object_show(im);
248 evas_object_data_set((Evas_Object *)data, "im", im);
250 evas_object_raise((Evas_Object *)data);
254 _popup_center_title_text_2button_restack_cb(void *data, Evas_Object *obj __UNUSED__,
255 void *event_info __UNUSED__)
258 Evas_Object *btn, *btn2;
260 popup = elm_popup_add(data);
261 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
262 elm_object_text_set(popup, "When you click the 'Restack' button, "
263 "an image will be located under this popup");
264 elm_object_part_text_set(popup, "title,text", "Title");
265 btn = elm_button_add(popup);
266 elm_object_text_set(btn, "Restack");
267 elm_object_part_content_set(popup, "button1", btn);
268 evas_object_smart_callback_add(btn, "clicked", _restack_btn_clicked, popup);
269 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
272 btn2 = elm_button_add(popup);
273 elm_object_text_set(btn2, "Close");
274 elm_object_part_content_set(popup, "button2", btn2);
275 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
277 evas_object_show(popup);
281 _popup_center_text_1button_hide_show_cb(void *data, Evas_Object *obj __UNUSED__,
282 void *event_info __UNUSED__)
290 sprintf(str, "You have checked this popup %d times.", times);
291 elm_object_text_set(g_popup, str);
292 evas_object_show(g_popup);
296 g_popup = elm_popup_add(data);
297 evas_object_size_hint_weight_set(g_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
298 elm_object_text_set(g_popup, "Hide this popup by using the button."
299 "When you click list item again, you can see this popup.");
300 btn = elm_button_add(g_popup);
301 elm_object_text_set(btn, "Hide");
302 elm_object_part_content_set(g_popup, "button1", btn);
303 evas_object_smart_callback_add(btn, "clicked", _g_popup_response_cb, g_popup);
305 evas_object_show(g_popup);
309 _popup_transparent_cb(void *data, Evas_Object *obj __UNUSED__,
310 void *event_info __UNUSED__)
315 popup = elm_popup_add(data);
316 elm_object_style_set(popup, "transparent");
317 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
318 elm_object_text_set(popup, "This Popup has transparent background");
319 btn = elm_button_add(popup);
320 elm_object_text_set(btn, "Close");
321 elm_object_part_content_set(popup, "button1", btn);
322 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
323 evas_object_show(popup);
327 test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
328 void *event_info __UNUSED__)
330 Evas_Object *win, *list;
332 win = elm_win_util_standard_add("popup", "Popup");
333 elm_win_autodel_set(win, EINA_TRUE);
335 list = elm_list_add(win);
336 elm_win_resize_object_add(win, list);
337 elm_list_mode_set(list, ELM_LIST_LIMIT);
338 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
339 evas_object_smart_callback_add(list, "selected", _list_click, NULL);
341 elm_list_item_append(list, "popup-center-text", NULL, NULL,
342 _popup_center_text_cb, win);
343 elm_list_item_append(list, "popup-center-text + 1 button", NULL, NULL,
344 _popup_center_text_1button_cb, win);
345 elm_list_item_append(list, "popup-center-title + text + 1 button", NULL,
346 NULL, _popup_center_title_text_1button_cb, win);
348 elm_list_item_append(list,
349 "popup-center-title + text (block,clicked handling)",
351 _popup_center_title_text_block_clicked_event_cb, win);
352 elm_list_item_append(list, "popup-bottom-title + text + 3 buttons", NULL,
353 NULL, _popup_bottom_title_text_3button_cb, win);
354 elm_list_item_append(list, "popup-center-title + content + 3 buttons", NULL,
355 NULL, _popup_center_title_content_3button_cb, win);
356 elm_list_item_append(list, "popup-center-title + items + 3 buttons", NULL,
357 NULL, _popup_center_title_item_3button_cb, win);
358 elm_list_item_append(list, "popup-center-title + text + 2 buttons (check restacking)", NULL, NULL,
359 _popup_center_title_text_2button_restack_cb, win);
360 elm_list_item_append(list, "popup-center-text + 1 button (check hide, show)", NULL, NULL,
361 _popup_center_text_1button_hide_show_cb, win);
362 elm_list_item_append(list, "popup-transparent", NULL, NULL,
363 _popup_transparent_cb, win);
365 evas_object_show(list);
366 evas_object_show(win);
367 evas_object_resize(win, 480, 400);