1 #include <Elementary.h>
\r
2 #include "elm_priv.h"
\r
6 * @defgroup Popup Popup
\r
7 * @ingroup Elementary
\r
9 * This is a popup widget. it can be used to display information/ get information from user.
\r
12 typedef struct _Widget_Data Widget_Data;
\r
13 typedef struct _Action_Area_Data Action_Area_Data;
\r
15 struct _Widget_Data
\r
17 Evas_Object *notify;
\r
18 Evas_Object *layout;
\r
19 Evas_Object *parent;
\r
20 const char *title_area;
\r
21 Evas_Object *title_icon;
\r
22 Evas_Object *content_area;
\r
23 Evas_Object *desc_label;
\r
24 Evas_Object *action_area;
\r
25 Eina_List *button_list;
\r
28 Evas_Object *content;
\r
29 Elm_Notify_Orient notify_orient;
\r
31 Eina_Bool delete_me : 1;
\r
34 struct _Action_Area_Data
\r
41 static const char *widtype = NULL;
\r
42 static void _del_hook(Evas_Object *obj);
\r
43 static void _theme_hook(Evas_Object *obj);
\r
44 static void _sizing_eval(Evas_Object *obj);
\r
45 static void _elm_popup_buttons_add_valist(Evas_Object *obj, const char *first_button_text, va_list args);
\r
46 static Evas_Object* _elm_popup_add_button(Evas_Object *obj, const char *text, int response_id);
\r
47 static void _action_area_clicked(void *data, Evas_Object *obj, void *event_info);
\r
48 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info);
\r
49 static void _show(void *data, Evas *e, Evas_Object *obj, void *event_info);
\r
50 static void _hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
\r
53 _del_parent(void *data, Evas *e, Evas_Object *obj, void *evet_info)
\r
55 Evas_Object *pop = data;
\r
56 Widget_Data *wd = elm_widget_data_get(pop);
\r
59 if (wd->parent == obj)
\r
61 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _del_parent, pop);
\r
67 _del_job(void *data)
\r
69 Evas_Object *obj = data;
\r
70 evas_object_del(obj);
\r
74 _del_hook(Evas_Object *obj)
\r
76 Widget_Data *wd = elm_widget_data_get(obj);
\r
83 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _del_parent, obj);
\r
84 wd->del_job = ecore_job_add(_del_job, wd->parent);
\r
92 _del_pre_hook(Evas_Object *obj)
\r
94 Widget_Data *wd = elm_widget_data_get(obj);
\r
95 Action_Area_Data *action_data = NULL;
\r
96 Eina_List *list = NULL;
\r
99 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_SHOW, _show, NULL);
\r
100 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_HIDE, _hide, NULL);
\r
101 EINA_LIST_FOREACH(wd->button_list, list, action_data)
\r
104 action_data = NULL;
\r
106 eina_list_free(wd->button_list);
\r
110 _theme_hook(Evas_Object *obj)
\r
112 Widget_Data *wd = elm_widget_data_get(obj);
\r
114 Eina_List *list = NULL;
\r
115 Action_Area_Data *action_data = NULL;
\r
119 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
120 elm_notify_orient_set(wd->notify, wd->notify_orient);
\r
121 edje_object_message_signal_process(elm_layout_edje_get(wd->layout));
\r
122 if (wd->action_area)
\r
124 snprintf(buf, sizeof(buf), "buttons%d", wd->no_of_buttons);
\r
125 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(obj));
\r
126 EINA_LIST_FOREACH(wd->button_list, list, action_data)
\r
128 snprintf(buf, sizeof(buf), "popup_button/%s", elm_widget_style_get(obj));
\r
129 elm_object_style_set(action_data->btn, buf);
\r
131 snprintf(buf, sizeof(buf), "actionbtn%d", index);
\r
132 elm_layout_content_set(wd->action_area, buf, action_data->btn);
\r
134 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
136 if (wd->content_area)
\r
138 elm_layout_theme_set(wd->content_area, "popup", "content", elm_widget_style_get(obj));
\r
139 if (wd->desc_label)
\r
141 snprintf(buf, sizeof(buf), "popup_description/%s", elm_widget_style_get(obj));
\r
142 elm_object_style_set(wd->desc_label, buf);
\r
143 elm_layout_content_set(wd->content_area, "elm.swallow.content", wd->desc_label);
\r
145 else if(wd->content)
\r
147 elm_layout_content_set(wd->content_area, "elm.swallow.content", wd->content);
\r
149 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
153 edje_object_part_text_set(elm_layout_edje_get(wd->layout), "elm.swallow.title", wd->title_area);
\r
159 _sizing_eval(Evas_Object *obj)
\r
161 Widget_Data *wd = elm_widget_data_get(obj);
\r
162 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
\r
165 edje_object_size_min_calc(elm_layout_edje_get(wd->layout), &minw, &minh);
\r
166 evas_object_size_hint_min_set(obj, minw, minh);
\r
167 evas_object_size_hint_max_set(obj, maxw, maxh);
\r
171 _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
173 _sizing_eval(data);
\r
177 _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
\r
179 evas_object_hide((Evas_Object*)data);
\r
180 evas_object_smart_callback_call((Evas_Object *)data, "response", (void *)ELM_POPUP_RESPONSE_NONE);
\r
183 static Ecore_Event_Handler* _elm_wnd_map_handler = NULL;
\r
186 _wnd_map_notify(void *data, int type, void *event)
\r
189 Evas_Object* obj = (Evas_Object*)data;
\r
191 if (obj && _elm_wnd_map_handler)
\r
193 e = evas_object_evas_get(obj);
\r
197 /* Render given object again, previous frame was discarded. */
\r
199 ecore_event_handler_del(_elm_wnd_map_handler);
\r
200 _elm_wnd_map_handler = NULL;
\r
209 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
211 Widget_Data *wd = elm_widget_data_get(obj);
\r
214 if (wd->parent) evas_object_show(wd->parent);
\r
215 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
217 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,show", "elm");
\r
218 edje_object_message_signal_process(wd->layout);
\r
219 evas_object_show(obj);
\r
220 if (e && !_elm_wnd_map_handler)
\r
222 int curr_rmethod = 0;
\r
223 int gl_rmethod = 0;
\r
225 curr_rmethod = evas_output_method_get(e);
\r
226 gl_rmethod = evas_render_method_lookup("gl_x11");
\r
228 if (!curr_rmethod) return;
\r
229 if (!gl_rmethod) return;
\r
230 if (curr_rmethod == gl_rmethod)
\r
231 _elm_wnd_map_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, _wnd_map_notify, obj);
\r
236 _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
238 Widget_Data *wd = elm_widget_data_get(obj);
\r
240 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,hide", "elm");
\r
241 edje_object_message_signal_process(wd->layout);
\r
242 if (wd->parent) evas_object_hide(wd->parent);
\r
243 evas_object_hide(obj);
\r
247 _action_area_clicked(void *data, Evas_Object *obj, void *event_info)
\r
249 Action_Area_Data *adata = NULL;
\r
250 adata = (Action_Area_Data *)data;
\r
252 if (!adata) return;
\r
253 evas_object_smart_callback_call(adata->obj, "response", (void *)adata->response_id);
\r
254 evas_object_hide(adata->obj);
\r
257 static Evas_Object*
\r
258 _elm_popup_add_button(Evas_Object *obj, const char *text, int response_id)
\r
261 Widget_Data *wd = elm_widget_data_get(obj);
\r
264 if (!wd) return NULL;
\r
265 Action_Area_Data *adata = ELM_NEW(Action_Area_Data);
\r
266 btn = elm_button_add(obj);
\r
267 snprintf(buf, sizeof(buf), "popup_button/%s", elm_widget_style_get(obj));
\r
268 elm_object_style_set(btn, buf);
\r
269 elm_button_label_set(btn, text);
\r
270 adata->response_id = response_id;
\r
273 wd->button_list = eina_list_append(wd->button_list, adata);
\r
274 evas_object_smart_callback_add(btn, "clicked", _action_area_clicked, adata);
\r
279 _elm_popup_buttons_add_valist(Evas_Object *obj, const char *first_button_text, va_list args)
\r
281 const char *text = NULL;
\r
287 if (first_button_text == NULL) return;
\r
288 Widget_Data *wd = elm_widget_data_get(obj);
\r
290 text = first_button_text;
\r
291 response = va_arg(args, int);
\r
292 while (text != NULL)
\r
294 btn = _elm_popup_add_button(obj, text, response);
\r
296 snprintf(buf, sizeof(buf), "actionbtn%d", index);
\r
297 elm_layout_content_set(wd->action_area, buf, btn);
\r
298 evas_object_event_callback_add(wd->action_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
299 _changed_size_hints, obj);
\r
300 text = va_arg(args, char*);
\r
301 if (text == NULL) break;
\r
302 response = va_arg(args, int);
\r
307 _elm_popup_timeout(void *data, Evas_Object *obj, void *event_info)
\r
309 evas_object_hide((Evas_Object*)data);
\r
310 evas_object_smart_callback_call((Evas_Object *)data, "response", (void *)ELM_POPUP_RESPONSE_TIMEOUT);
\r
314 _elm_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
\r
316 int res_id = ELM_POPUP_RESPONSE_NONE;
\r
317 int *id = (int *)data;
\r
319 ecore_main_loop_quit();
\r
324 response_cb(void *data, Evas_Object *obj, void *event_info)
\r
326 int res_id = (int) event_info;
\r
327 int *id = (int *)data;
\r
329 ecore_main_loop_quit();
\r
333 * Add a new Popup object.
\r
335 * @param[in] parent_app The parent object
\r
336 * @return The new object or NULL if it cannot be created
\r
341 elm_popup_add(Evas_Object *parent_app)
\r
346 Evas_Object *parent;
\r
347 Evas_Coord x,y,w,h;
\r
350 unsigned char *prop_data = NULL;
\r
352 Ecore_X_Window_Type type;
\r
355 //FIXME: Keep this window always on top
\r
356 parent = elm_win_add(parent_app, "popup", ELM_WIN_DIALOG_BASIC);
\r
357 elm_win_borderless_set(parent, EINA_TRUE);
\r
358 elm_win_alpha_set(parent, EINA_TRUE);
\r
359 elm_win_raise(parent);
\r
360 ecore_x_window_geometry_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &x, &y, &w, &h);
\r
361 ret = ecore_x_window_prop_property_get(ecore_x_window_root_get(ecore_x_window_focus_get()), ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
\r
362 ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
\r
363 if (ret && prop_data) memcpy(&rotation, prop_data, sizeof(int));
\r
364 if (prop_data) free(prop_data);
\r
365 evas_object_resize(parent, w, h);
\r
366 evas_object_move(parent, x, y);
\r
367 if (rotation != -1)
\r
368 elm_win_rotation_with_resize_set(parent, rotation);
\r
372 parent = parent_app;
\r
374 wd = ELM_NEW(Widget_Data);
\r
375 e = evas_object_evas_get(parent);
\r
376 obj = elm_widget_add(e);
\r
377 ELM_SET_WIDTYPE(widtype, "popup");
\r
378 elm_widget_type_set(obj, "popup");
\r
379 elm_widget_sub_object_add(parent, obj);
\r
380 elm_widget_data_set(obj, wd);
\r
381 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
\r
382 elm_widget_del_hook_set(obj, _del_hook);
\r
383 elm_widget_theme_hook_set(obj, _theme_hook);
\r
384 elm_widget_can_focus_set(obj, EINA_FALSE);
\r
386 wd->notify = elm_notify_add(parent);
\r
387 elm_widget_sub_object_add(obj, wd->notify);
\r
388 elm_widget_resize_object_set(obj, wd->notify);
\r
389 elm_notify_orient_set(wd->notify, ELM_NOTIFY_ORIENT_CENTER);
\r
390 wd->notify_orient = ELM_NOTIFY_ORIENT_CENTER;
\r
391 elm_notify_repeat_events_set(wd->notify, EINA_FALSE);
\r
392 evas_object_size_hint_weight_set(wd->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
393 evas_object_size_hint_align_set(wd->notify, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
395 wd->layout = elm_layout_add(parent);
\r
396 evas_object_size_hint_weight_set(wd->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
397 evas_object_size_hint_align_set(wd->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
399 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
400 elm_notify_content_set(wd->notify, wd->layout);
\r
402 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _show, NULL);
\r
403 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _hide, NULL);
\r
404 wd->rot_angle = rotation;
\r
407 wd->parent = parent;
\r
408 elm_object_style_set(wd->notify, "popup");
\r
409 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, _del_parent, obj);
\r
412 ecore_x_netwm_window_type_get(elm_win_xwindow_get(parent), &type);
\r
413 if (type == ECORE_X_WINDOW_TYPE_DIALOG)
\r
415 elm_object_style_set(wd->notify, "popup");
\r
423 * Add a new Popup object.
\r
425 * @param[in] parent The parent object
\r
426 * @param[in] title text to be displayed in title area.
\r
427 * @param[in] desc_text text to be displayed in description area.
\r
428 * @param[in] no_of_buttons Number of buttons to be packed in action area.
\r
429 * @param[in] first_button_text button text
\r
430 * @param[in] Varargs response ID for first button, then additional buttons followed by response id's ending with NULL
\r
431 * @return The new object or NULL if it cannot be created
\r
436 elm_popup_with_buttons_add(Evas_Object *parent, char *title, char *desc_text,int no_of_buttons, char *first_button_text, ...)
\r
438 Evas_Object *popup;
\r
439 popup = elm_popup_add(parent);
\r
440 Widget_Data *wd = elm_widget_data_get(popup);
\r
445 elm_popup_desc_set(popup, desc_text);
\r
449 elm_popup_title_label_set(popup, title);
\r
451 if (first_button_text)
\r
454 va_start(args, first_button_text);
\r
455 wd->action_area = elm_layout_add(popup);
\r
456 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
457 snprintf(buf,sizeof(buf), "buttons%d", no_of_buttons);
\r
458 wd->no_of_buttons = no_of_buttons;
\r
459 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(popup));
\r
460 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,visible", "elm");
\r
461 if (wd->title_area)
\r
463 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
465 _elm_popup_buttons_add_valist (popup, first_button_text, args);
\r
468 edje_object_message_signal_process(wd->layout);
\r
469 _sizing_eval(popup);
\r
476 * This Set's the description text in content area of Popup widget.
\r
478 * @param[in] obj The Popup object
\r
479 * @param[in] text description text.
\r
484 elm_popup_desc_set(Evas_Object *obj, const char *text)
\r
486 ELM_CHECK_WIDTYPE(obj, widtype);
\r
487 Widget_Data *wd = elm_widget_data_get(obj);
\r
491 if (wd->content_area)
\r
493 evas_object_del(wd->content_area);
\r
494 wd->content_area = NULL;
\r
496 wd->content_area = elm_layout_add(obj);
\r
497 elm_layout_theme_set(wd->content_area, "popup", "content", elm_widget_style_get(obj));
\r
498 wd->desc_label = elm_label_add(obj);
\r
499 snprintf(buf, sizeof(buf), "popup_description/%s", elm_widget_style_get(obj));
\r
500 elm_object_style_set(wd->desc_label, buf);
\r
501 elm_label_line_wrap_set(wd->desc_label, EINA_TRUE);
\r
502 elm_label_label_set(wd->desc_label, text);
\r
503 evas_object_size_hint_weight_set(wd->desc_label, EVAS_HINT_EXPAND, 0.0);
\r
504 evas_object_size_hint_align_set(wd->desc_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
505 evas_object_show(wd->desc_label);
\r
506 elm_layout_content_set(wd->content_area, "elm.swallow.content", wd->desc_label);
\r
507 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
508 evas_object_event_callback_add(wd->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
509 _changed_size_hints, obj);
\r
514 * This Get's the description text packed in content area of popup object.
\r
516 * @param[in] obj The Popup object
\r
517 * @return description text.
\r
522 elm_popup_desc_get(Evas_Object *obj)
\r
524 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
525 Widget_Data *wd = elm_widget_data_get(obj);
\r
527 if (!wd) return NULL;
\r
528 return elm_label_label_get(wd->desc_label);
\r
532 * This Set's the title text in title area of popup object.
\r
534 * @param[in] obj The popup object
\r
535 * @param[in] text The title text
\r
540 elm_popup_title_label_set(Evas_Object *obj, const char *text)
\r
542 ELM_CHECK_WIDTYPE(obj, widtype);
\r
543 Widget_Data *wd = elm_widget_data_get(obj);
\r
546 eina_stringshare_replace(&wd->title_area, text);
\r
547 edje_object_part_text_set(elm_layout_edje_get(wd->layout), "elm.swallow.title", text);
\r
548 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,visible", "elm");
\r
549 if (wd->action_area)
\r
550 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
551 if (wd->title_icon)
\r
552 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,icon,visible", "elm");
\r
553 edje_object_message_signal_process(wd->layout);
\r
558 * This Get's the title text packed in title area of popup object.
\r
560 * @param[in] obj The Popup object
\r
561 * @return title text
\r
566 elm_popup_title_label_get(Evas_Object *obj)
\r
568 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
569 Widget_Data *wd = elm_widget_data_get(obj);
\r
571 if (!wd) return NULL;
\r
572 return wd->title_area;
\r
576 * This Set's the icon in the title area of Popup object.
\r
578 * @param[in] obj The popup object
\r
579 * @param[in] icon The title icon
\r
584 elm_popup_title_icon_set(Evas_Object *obj, Evas_Object *icon)
\r
586 ELM_CHECK_WIDTYPE(obj, widtype);
\r
587 Widget_Data *wd = elm_widget_data_get(obj);
\r
590 if (wd->title_icon)
\r
592 evas_object_del(wd->title_icon);
\r
593 wd->title_icon = NULL;
\r
595 wd->title_icon = icon;
\r
596 elm_layout_content_set(wd->layout, "elm.swallow.title.icon", wd->title_icon);
\r
597 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,icon,visible", "elm");
\r
598 edje_object_message_signal_process(wd->layout);
\r
603 * This Get's the icon packed in title area of Popup object.
\r
605 * @param[in] obj The Popup object
\r
606 * @return title icon
\r
611 elm_popup_title_icon_get(Evas_Object *obj)
\r
613 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
614 Widget_Data *wd = elm_widget_data_get(obj);
\r
616 if (!wd) return NULL;
\r
617 return wd->title_icon;
\r
621 * This Set's the content widget in content area of Popup object.
\r
623 * @param[in] obj The popup object
\r
624 * @param[in] content The content widget
\r
629 elm_popup_content_set(Evas_Object *obj, Evas_Object *content)
\r
631 ELM_CHECK_WIDTYPE(obj, widtype);
\r
632 Widget_Data *wd = elm_widget_data_get(obj);
\r
635 if (wd->content == content) return;
\r
636 if (wd->content_area)
\r
638 evas_object_del(wd->content_area);
\r
639 wd->content_area = NULL;
\r
641 wd->content = content;
\r
644 wd->content_area = elm_layout_add(obj);
\r
645 elm_layout_theme_set(wd->content_area, "popup","content", elm_widget_style_get(obj));
\r
646 elm_layout_content_set(wd->content_area, "elm.swallow.content", content);
\r
647 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
648 evas_object_event_callback_add(wd->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
649 _changed_size_hints, obj);
\r
655 * This Get's the content widget packed in content area of Popup object.
\r
657 * @param[in] obj The Popup object
\r
658 * @return content packed in popup widget
\r
663 elm_popup_content_get(Evas_Object *obj)
\r
665 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
666 Widget_Data *wd = elm_widget_data_get(obj);
\r
668 if (!wd) return NULL;
\r
669 return wd->content;
\r
673 * Adds the buttons in to the action area of popup object.
\r
675 * @param[in] obj The popup object
\r
676 * @param[in] no_of_buttons Number of buttons that has to be packed in action area.
\r
677 * @param[in] first_button_text Label of first button
\r
678 * @param[in] Varargs Response ID(Elm_Popup_Response/ any integer value) for first button, then additional buttons along with their response id ending with NULL.
\r
682 elm_popup_buttons_add(Evas_Object *obj,int no_of_buttons, char *first_button_text, ...)
\r
684 ELM_CHECK_WIDTYPE(obj, widtype);
\r
685 Widget_Data *wd = elm_widget_data_get(obj);
\r
690 va_start(args, first_button_text);
\r
691 if (wd->action_area)
\r
693 evas_object_del(wd->action_area);
\r
694 wd->action_area = NULL;
\r
696 wd->action_area = elm_layout_add(obj);
\r
697 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
698 evas_object_size_hint_weight_set(wd->action_area, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
699 evas_object_size_hint_align_set(wd->action_area, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
700 snprintf(buf, sizeof(buf), "buttons%d", no_of_buttons);
\r
701 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(obj));
\r
702 wd->no_of_buttons = no_of_buttons;
\r
703 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,visible", "elm");
\r
704 if (wd->title_area)
\r
705 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
706 _elm_popup_buttons_add_valist (obj, first_button_text, args);
\r
708 edje_object_message_signal_process(wd->layout);
\r
713 * This Set's the time before the popup window is hidden,
\r
714 * and ELM_POPUP_RESPONSE_TIMEOUT is sent along with response signal.
\r
716 * @param[in] obj The popup object
\r
717 * @param[in] timeout The timeout value in seconds.
\r
722 elm_popup_timeout_set(Evas_Object *obj, int timeout)
\r
724 ELM_CHECK_WIDTYPE(obj, widtype);
\r
725 Widget_Data *wd = elm_widget_data_get(obj);
\r
728 elm_notify_timeout_set(wd->notify, timeout);
\r
729 evas_object_smart_callback_add(wd->notify, "notify,timeout", _elm_popup_timeout, obj);
\r
733 * This Set's the mode of popup, by default ELM_POPUP_TYPE_NONE is set i.e, popup
\r
734 * will not close when clicked outside. if ELM_POPUP_TYPE_ALERT is set, popup will close
\r
735 * when clicked outside, and ELM_POPUP_RESPONSE_NONE is sent along with response signal.
\r
737 * @param[in] obj The popup object
\r
738 * @param[in] mode Elm_Popup_Mode
\r
743 elm_popup_mode_set(Evas_Object *obj, Elm_Popup_Mode mode)
\r
745 ELM_CHECK_WIDTYPE(obj, widtype);
\r
746 Widget_Data *wd = elm_widget_data_get(obj);
\r
749 if (mode == ELM_POPUP_TYPE_ALERT)
\r
750 evas_object_smart_callback_add(wd->notify, "block,clicked", _block_clicked_cb, obj);
\r
752 evas_object_smart_callback_del(wd->notify, "block,clicked", _block_clicked_cb);
\r
756 * This Hides the popup by emitting response signal.
\r
758 * @param[in] obj The popup object
\r
759 * @param[in] response_id response ID of the signal to be emitted along with response signal
\r
764 elm_popup_response(Evas_Object *obj, int response_id)
\r
766 ELM_CHECK_WIDTYPE(obj, widtype);
\r
767 Widget_Data *wd = elm_widget_data_get(obj);
\r
770 evas_object_hide(obj);
\r
771 evas_object_smart_callback_call((Evas_Object *)obj, "response", (void *)response_id);
\r
775 * This API controls the direction from which popup will appear and location of popup.
\r
776 * @param[in] obj The popup object
\r
777 * @param[in] orient the orientation of the popup
\r
782 elm_popup_orient_set(Evas_Object *obj, Elm_Popup_Orient orient)
\r
784 ELM_CHECK_WIDTYPE(obj, widtype);
\r
785 Widget_Data *wd = elm_widget_data_get(obj);
\r
786 Elm_Notify_Orient notify_orient = -1;
\r
791 case ELM_POPUP_ORIENT_TOP:
\r
792 notify_orient = ELM_NOTIFY_ORIENT_TOP;
\r
794 case ELM_POPUP_ORIENT_CENTER:
\r
795 notify_orient = ELM_NOTIFY_ORIENT_CENTER;
\r
797 case ELM_POPUP_ORIENT_BOTTOM:
\r
798 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM;
\r
800 case ELM_POPUP_ORIENT_LEFT:
\r
801 notify_orient = ELM_NOTIFY_ORIENT_LEFT;
\r
803 case ELM_POPUP_ORIENT_RIGHT:
\r
804 notify_orient = ELM_NOTIFY_ORIENT_RIGHT;
\r
806 case ELM_POPUP_ORIENT_TOP_LEFT:
\r
807 notify_orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
\r
809 case ELM_POPUP_ORIENT_TOP_RIGHT:
\r
810 notify_orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
\r
812 case ELM_POPUP_ORIENT_BOTTOM_LEFT:
\r
813 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
\r
815 case ELM_POPUP_ORIENT_BOTTOM_RIGHT:
\r
816 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
\r
819 wd->notify_orient = notify_orient;
\r
820 elm_notify_orient_set(wd->notify, notify_orient);
\r
824 * Applications which do not pass any window to popup need to take care of rotation, only when popup is already shown.
\r
825 * @param obj The popup object
\r
826 * @param rot_angle the angle to which popup has to be rotated.
\r
831 elm_popup_rotation_set(Evas_Object *obj, int rot_angle)
\r
833 ELM_CHECK_WIDTYPE(obj, widtype);
\r
834 Widget_Data *wd = elm_widget_data_get(obj);
\r
839 if (wd->rot_angle != rot_angle)
\r
841 elm_win_rotation_with_resize_set(wd->parent,rot_angle);
\r
842 wd->rot_angle = rot_angle;
\r
848 * Blocks in a main loop until popup either emits response signal or is exited due
\r
849 * to exit signal, when exit signal is received dialog responds with ELM_POPUP_RESPONSE_NONE
\r
850 * response ID else returns the response ID from response signal emission.
\r
851 * before entering the main loop popup calls evas_object_show on the popup for you.
\r
852 * you can force popup to return at any time by calling elm_popup_responsec to emit the
\r
853 * response signal. destroying the popup during elm_popup_run is a very bad idea.
\r
854 * typical usage of this function may be
\r
855 * int result = elm_popup_run(popup);
\r
858 * case ELM_POPUP_RESPONSE_OK:
\r
859 * do_something_specific_to_app();
\r
860 * evas_object_del(popup);
\r
862 * case ELM_POPUP_RESPONSE_CANCEL:
\r
863 * do_nothing_popup_was_cancelled();
\r
864 * evas_object_del(popup);
\r
866 * case ELM_POPUP_RESPONSE_NONE:
\r
868 * evas_object_del(popup);
\r
871 * do not run elm_popup_run in a timer/idler callback.
\r
872 * when popup returns with signal ELM_POPUP_RESPONSE_NONE, then exit the application using elm_exit
\r
873 * by calling any post exit application code.
\r
875 * @param[in] obj The popup object
\r
879 elm_popup_run(Evas_Object *obj)
\r
882 Ecore_Event_Handler *_elm_exit_handler = NULL;
\r
883 /*Finger waggle warning*/
\r
884 _elm_dangerous_call_check(__FUNCTION__);
\r
885 evas_object_show(obj);
\r
886 evas_object_smart_callback_add(obj, "response", response_cb, &response_id);
\r
887 _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, &response_id);
\r
888 ecore_main_loop_begin();
\r
889 if (_elm_exit_handler)
\r
891 ecore_event_handler_del(_elm_exit_handler);
\r
892 _elm_exit_handler = NULL;
\r
894 return response_id;
\r