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
27 Elm_Notify_Orient notify_orient;
\r
29 Eina_Bool delete_me : 1;
\r
32 struct _Action_Area_Data
\r
39 static const char *widtype = NULL;
\r
40 static void _del_hook(Evas_Object *obj);
\r
41 static void _theme_hook(Evas_Object *obj);
\r
42 static void _sizing_eval(Evas_Object *obj);
\r
43 static void _elm_popup_buttons_add_valist(Evas_Object *obj, const char *first_button_text, va_list args);
\r
44 static Evas_Object* _elm_popup_add_button(Evas_Object *obj, const char *text, int response_id);
\r
45 static void _action_area_clicked(void *data, Evas_Object *obj, void *event_info);
\r
46 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info);
\r
47 static void _show(void *data, Evas *e, Evas_Object *obj, void *event_info);
\r
48 static void _hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
\r
51 _del_parent(void *data, Evas *e, Evas_Object *obj, void *evet_info)
\r
53 Evas_Object *pop = data;
\r
54 Widget_Data *wd = elm_widget_data_get(pop);
\r
57 if (wd->parent == obj)
\r
59 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _del_parent, pop);
\r
65 _del_job(void *data)
\r
67 Evas_Object *obj = data;
\r
68 evas_object_del(obj);
\r
72 _del_hook(Evas_Object *obj)
\r
74 Widget_Data *wd = elm_widget_data_get(obj);
\r
81 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _del_parent, obj);
\r
82 wd->del_job = ecore_job_add(_del_job, wd->parent);
\r
90 _del_pre_hook(Evas_Object *obj)
\r
92 Widget_Data *wd = elm_widget_data_get(obj);
\r
93 Action_Area_Data *action_data = NULL;
\r
94 Eina_List *list = NULL;
\r
97 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_SHOW, _show, NULL);
\r
98 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_HIDE, _hide, NULL);
\r
99 EINA_LIST_FOREACH(wd->button_list, list, action_data)
\r
102 action_data = NULL;
\r
104 eina_list_free(wd->button_list);
\r
108 _theme_hook(Evas_Object *obj)
\r
110 Widget_Data *wd = elm_widget_data_get(obj);
\r
112 Eina_List *list = NULL;
\r
113 Action_Area_Data *action_data = NULL;
\r
116 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
117 elm_notify_orient_set(wd->notify, wd->notify_orient);
\r
118 edje_object_message_signal_process(elm_layout_edje_get(wd->layout));
\r
120 if (wd->action_area)
\r
122 EINA_LIST_FOREACH(wd->button_list, list, action_data)
\r
124 snprintf(buf, sizeof(buf), "popup_button/%s", elm_widget_style_get(obj));
\r
125 elm_object_style_set(action_data->btn, buf);
\r
128 if (wd->content_area)
\r
130 elm_layout_theme_set(wd->content_area, "popup", "content", elm_widget_style_get(obj));
\r
131 if (wd->desc_label)
\r
133 snprintf(buf, sizeof(buf), "popup_description/%s", elm_widget_style_get(obj));
\r
134 elm_object_style_set(wd->desc_label, buf);
\r
141 _sizing_eval(Evas_Object *obj)
\r
143 Widget_Data *wd = elm_widget_data_get(obj);
\r
144 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
\r
147 edje_object_size_min_calc(elm_layout_edje_get(wd->layout), &minw, &minh);
\r
148 evas_object_size_hint_min_set(obj, minw, minh);
\r
149 evas_object_size_hint_max_set(obj, maxw, maxh);
\r
153 _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
155 _sizing_eval(data);
\r
159 _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
\r
161 evas_object_hide((Evas_Object*)data);
\r
162 evas_object_smart_callback_call((Evas_Object *)data, "response", (void *)ELM_POPUP_RESPONSE_NONE);
\r
165 static Ecore_Event_Handler* _elm_wnd_map_handler = NULL;
\r
168 _wnd_map_notify(void *data, int type, void *event)
\r
171 Evas_Object* obj = (Evas_Object*)data;
\r
173 if (obj && _elm_wnd_map_handler)
\r
175 e = evas_object_evas_get(obj);
\r
179 /* Render given object again, previous frame was discarded. */
\r
181 ecore_event_handler_del(_elm_wnd_map_handler);
\r
182 _elm_wnd_map_handler = NULL;
\r
191 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
193 Widget_Data *wd = elm_widget_data_get(obj);
\r
196 if (wd->parent) evas_object_show(wd->parent);
\r
197 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
199 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,show", "elm");
\r
200 edje_object_message_signal_process(wd->layout);
\r
201 evas_object_show(obj);
\r
202 if (e && !_elm_wnd_map_handler)
\r
204 int curr_rmethod = 0;
\r
205 int gl_rmethod = 0;
\r
207 curr_rmethod = evas_output_method_get(e);
\r
208 gl_rmethod = evas_render_method_lookup("gl_x11");
\r
210 if (!curr_rmethod) return;
\r
211 if (!gl_rmethod) return;
\r
212 if (curr_rmethod == gl_rmethod)
\r
213 _elm_wnd_map_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, _wnd_map_notify, obj);
\r
218 _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
220 Widget_Data *wd = elm_widget_data_get(obj);
\r
223 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,hide", "elm");
\r
224 edje_object_message_signal_process(wd->layout);
\r
225 if (wd->parent) evas_object_hide(wd->parent);
\r
226 evas_object_hide(obj);
\r
230 _action_area_clicked(void *data, Evas_Object *obj, void *event_info)
\r
232 Action_Area_Data *adata = NULL;
\r
233 adata = (Action_Area_Data *)data;
\r
235 if (!adata) return;
\r
236 evas_object_smart_callback_call(adata->obj, "response", (void *)adata->response_id);
\r
237 evas_object_hide(adata->obj);
\r
240 static Evas_Object*
\r
241 _elm_popup_add_button(Evas_Object *obj, const char *text, int response_id)
\r
244 Widget_Data *wd = elm_widget_data_get(obj);
\r
247 if (!wd) return NULL;
\r
248 Action_Area_Data *adata = ELM_NEW(Action_Area_Data);
\r
249 btn = elm_button_add(obj);
\r
250 snprintf(buf, sizeof(buf), "popup_button/%s", elm_widget_style_get(obj));
\r
251 elm_object_style_set(btn, buf);
\r
252 elm_button_label_set(btn, text);
\r
253 adata->response_id = response_id;
\r
256 wd->button_list = eina_list_append(wd->button_list, adata);
\r
257 evas_object_smart_callback_add(btn, "clicked", _action_area_clicked, adata);
\r
262 _elm_popup_buttons_add_valist(Evas_Object *obj, const char *first_button_text, va_list args)
\r
264 const char *text = NULL;
\r
270 if (first_button_text == NULL) return;
\r
271 Widget_Data *wd = elm_widget_data_get(obj);
\r
273 text = first_button_text;
\r
274 response = va_arg(args, int);
\r
275 while (text != NULL)
\r
277 btn = _elm_popup_add_button(obj, text, response);
\r
279 snprintf(buf, sizeof(buf), "actionbtn%d", index);
\r
280 elm_layout_content_set(wd->action_area, buf, btn);
\r
281 evas_object_event_callback_add(wd->action_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
282 _changed_size_hints, obj);
\r
283 text = va_arg(args, char*);
\r
284 if (text == NULL) break;
\r
285 response = va_arg(args, int);
\r
290 _elm_popup_timeout(void *data, Evas_Object *obj, void *event_info)
\r
292 evas_object_hide((Evas_Object*)data);
\r
293 evas_object_smart_callback_call((Evas_Object *)data, "response", (void *)ELM_POPUP_RESPONSE_TIMEOUT);
\r
297 _elm_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
\r
299 int res_id = ELM_POPUP_RESPONSE_NONE;
\r
300 int *id = (int *)data;
\r
302 ecore_main_loop_quit();
\r
307 response_cb(void *data, Evas_Object *obj, void *event_info)
\r
309 int res_id = (int) event_info;
\r
310 int *id = (int *)data;
\r
312 ecore_main_loop_quit();
\r
316 * Add a new Popup object.
\r
318 * @param[in] parent_app The parent object
\r
319 * @return The new object or NULL if it cannot be created
\r
324 elm_popup_add(Evas_Object *parent_app)
\r
329 Evas_Object *parent;
\r
330 Evas_Coord x,y,w,h;
\r
333 unsigned char *prop_data = NULL;
\r
335 Ecore_X_Window_Type type;
\r
338 //FIXME: Keep this window always on top
\r
339 parent = elm_win_add(parent_app, "popup", ELM_WIN_DIALOG_BASIC);
\r
340 elm_win_borderless_set(parent, EINA_TRUE);
\r
341 elm_win_alpha_set(parent, EINA_TRUE);
\r
342 elm_win_raise(parent);
\r
343 ecore_x_window_geometry_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &x, &y, &w, &h);
\r
344 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
345 ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
\r
346 if (ret && prop_data) memcpy(&rotation, prop_data, sizeof(int));
\r
347 if (prop_data) free(prop_data);
\r
348 evas_object_resize(parent, w, h);
\r
349 evas_object_move(parent, x, y);
\r
350 if (rotation != -1)
\r
351 elm_win_rotation_with_resize_set(parent, rotation);
\r
355 parent = parent_app;
\r
357 wd = ELM_NEW(Widget_Data);
\r
358 e = evas_object_evas_get(parent);
\r
359 obj = elm_widget_add(e);
\r
360 ELM_SET_WIDTYPE(widtype, "popup");
\r
361 elm_widget_type_set(obj, "popup");
\r
362 elm_widget_sub_object_add(parent, obj);
\r
363 elm_widget_data_set(obj, wd);
\r
364 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
\r
365 elm_widget_del_hook_set(obj, _del_hook);
\r
366 elm_widget_theme_hook_set(obj, _theme_hook);
\r
368 wd->notify = elm_notify_add(parent);
\r
369 elm_widget_resize_object_set(obj, wd->notify);
\r
370 elm_notify_orient_set(wd->notify, ELM_NOTIFY_ORIENT_CENTER);
\r
371 wd->notify_orient = ELM_NOTIFY_ORIENT_CENTER;
\r
372 elm_notify_repeat_events_set(wd->notify, EINA_FALSE);
\r
373 evas_object_size_hint_weight_set(wd->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
374 evas_object_size_hint_align_set(wd->notify, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
376 wd->layout = elm_layout_add(parent);
\r
377 evas_object_size_hint_weight_set(wd->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
378 evas_object_size_hint_align_set(wd->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
380 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
381 elm_notify_content_set(wd->notify, wd->layout);
\r
383 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _show, NULL);
\r
384 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _hide, NULL);
\r
385 wd->rot_angle = rotation;
\r
388 wd->parent = parent;
\r
389 elm_object_style_set(wd->notify, "popup");
\r
390 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, _del_parent, obj);
\r
393 ecore_x_netwm_window_type_get(elm_win_xwindow_get(parent), &type);
\r
394 if (type == ECORE_X_WINDOW_TYPE_DIALOG)
\r
396 elm_object_style_set(wd->notify, "popup");
\r
404 * Add a new Popup object.
\r
406 * @param[in] parent The parent object
\r
407 * @param[in] title text to be displayed in title area.
\r
408 * @param[in] desc_text text to be displayed in description area.
\r
409 * @param[in] no_of_buttons Number of buttons to be packed in action area.
\r
410 * @param[in] first_button_text button text
\r
411 * @param[in] Varargs response ID for first button, then additional buttons followed by response id's ending with NULL
\r
412 * @return The new object or NULL if it cannot be created
\r
417 elm_popup_with_buttons_add(Evas_Object *parent, char *title, char *desc_text,int no_of_buttons, char *first_button_text, ...)
\r
419 Evas_Object *popup;
\r
420 popup = elm_popup_add(parent);
\r
421 Widget_Data *wd = elm_widget_data_get(popup);
\r
426 elm_popup_desc_set(popup, desc_text);
\r
430 elm_popup_title_label_set(popup, title);
\r
432 if (first_button_text)
\r
435 va_start(args, first_button_text);
\r
436 wd->action_area = elm_layout_add(popup);
\r
437 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
438 snprintf(buf,sizeof(buf), "buttons%d", no_of_buttons);
\r
439 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(popup));
\r
440 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,visible", "elm");
\r
441 if (wd->title_area)
\r
443 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
445 _elm_popup_buttons_add_valist (popup, first_button_text, args);
\r
448 edje_object_message_signal_process(wd->layout);
\r
449 _sizing_eval(popup);
\r
456 * This Set's the description text in content area of Popup widget.
\r
458 * @param[in] obj The Popup object
\r
459 * @param[in] text description text.
\r
464 elm_popup_desc_set(Evas_Object *obj, const char *text)
\r
466 ELM_CHECK_WIDTYPE(obj, widtype);
\r
467 Widget_Data *wd = elm_widget_data_get(obj);
\r
471 if (wd->content_area)
\r
473 evas_object_del(wd->content_area);
\r
474 wd->content_area = NULL;
\r
476 wd->content_area = elm_layout_add(obj);
\r
477 elm_layout_theme_set(wd->content_area, "popup", "content", elm_widget_style_get(obj));
\r
478 wd->desc_label = elm_label_add(obj);
\r
479 snprintf(buf, sizeof(buf), "popup_description/%s", elm_widget_style_get(obj));
\r
480 elm_object_style_set(wd->desc_label, buf);
\r
481 elm_label_line_wrap_set(wd->desc_label, EINA_TRUE);
\r
482 elm_label_label_set(wd->desc_label, text);
\r
483 evas_object_size_hint_weight_set(wd->desc_label, EVAS_HINT_EXPAND, 0.0);
\r
484 evas_object_size_hint_align_set(wd->desc_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
485 evas_object_show(wd->desc_label);
\r
486 elm_layout_content_set(wd->content_area, "elm.swallow.content", wd->desc_label);
\r
487 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
488 evas_object_event_callback_add(wd->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
489 _changed_size_hints, obj);
\r
494 * This Get's the description text packed in content area of popup object.
\r
496 * @param[in] obj The Popup object
\r
497 * @return description text.
\r
502 elm_popup_desc_get(Evas_Object *obj)
\r
504 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
505 Widget_Data *wd = elm_widget_data_get(obj);
\r
507 if (!wd) return NULL;
\r
508 return elm_label_label_get(wd->desc_label);
\r
512 * This Set's the title text in title area of popup object.
\r
514 * @param[in] obj The popup object
\r
515 * @param[in] text The title text
\r
520 elm_popup_title_label_set(Evas_Object *obj, const char *text)
\r
522 ELM_CHECK_WIDTYPE(obj, widtype);
\r
523 Widget_Data *wd = elm_widget_data_get(obj);
\r
526 eina_stringshare_replace(&wd->title_area, text);
\r
527 edje_object_part_text_set(elm_layout_edje_get(wd->layout), "elm.swallow.title", text);
\r
528 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,visible", "elm");
\r
529 if (wd->action_area)
\r
530 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
531 if (wd->title_icon)
\r
532 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,icon,visible", "elm");
\r
533 edje_object_message_signal_process(wd->layout);
\r
538 * This Get's the title text packed in title area of popup object.
\r
540 * @param[in] obj The Popup object
\r
541 * @return title text
\r
546 elm_popup_title_label_get(Evas_Object *obj)
\r
548 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
549 Widget_Data *wd = elm_widget_data_get(obj);
\r
551 if (!wd) return NULL;
\r
552 return wd->title_area;
\r
556 * This Set's the icon in the title area of Popup object.
\r
558 * @param[in] obj The popup object
\r
559 * @param[in] icon The title icon
\r
564 elm_popup_title_icon_set(Evas_Object *obj, Evas_Object *icon)
\r
566 ELM_CHECK_WIDTYPE(obj, widtype);
\r
567 Widget_Data *wd = elm_widget_data_get(obj);
\r
570 if (wd->title_icon)
\r
572 evas_object_del(wd->title_icon);
\r
573 wd->title_icon = NULL;
\r
575 wd->title_icon = icon;
\r
576 elm_layout_content_set(wd->layout, "elm.swallow.title.icon", wd->title_icon);
\r
577 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,icon,visible", "elm");
\r
578 edje_object_message_signal_process(wd->layout);
\r
583 * This Get's the icon packed in title area of Popup object.
\r
585 * @param[in] obj The Popup object
\r
586 * @return title icon
\r
591 elm_popup_title_icon_get(Evas_Object *obj)
\r
593 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
594 Widget_Data *wd = elm_widget_data_get(obj);
\r
596 if (!wd) return NULL;
\r
597 return wd->title_icon;
\r
601 * This Set's the content widget in content area of Popup object.
\r
603 * @param[in] obj The popup object
\r
604 * @param[in] content The content widget
\r
609 elm_popup_content_set(Evas_Object *obj, Evas_Object *content)
\r
611 ELM_CHECK_WIDTYPE(obj, widtype);
\r
612 Widget_Data *wd = elm_widget_data_get(obj);
\r
615 if (wd->content_area)
\r
617 evas_object_del(wd->content_area);
\r
618 wd->content_area = NULL;
\r
620 wd->content_area = elm_layout_add(obj);
\r
621 elm_layout_theme_set(wd->content_area, "popup","content", elm_widget_style_get(obj));
\r
622 elm_layout_content_set(wd->content_area, "elm.swallow.content", content);
\r
623 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
624 evas_object_event_callback_add(wd->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
625 _changed_size_hints, obj);
\r
630 * This Get's the content widget packed in content area of Popup object.
\r
632 * @param[in] obj The Popup object
\r
633 * @return content packed in popup widget
\r
638 elm_popup_content_get(Evas_Object *obj)
\r
640 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
641 Widget_Data *wd = elm_widget_data_get(obj);
\r
643 if (!wd) return NULL;
\r
644 return wd->content_area;
\r
648 * Adds the buttons in to the action area of popup object.
\r
650 * @param[in] obj The popup object
\r
651 * @param[in] no_of_buttons Number of buttons that has to be packed in action area.
\r
652 * @param[in] first_button_text Label of first button
\r
653 * @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
657 elm_popup_buttons_add(Evas_Object *obj,int no_of_buttons, char *first_button_text, ...)
\r
660 ELM_CHECK_WIDTYPE(obj, widtype);
\r
661 Widget_Data *wd = elm_widget_data_get(obj);
\r
666 va_start(args, first_button_text);
\r
667 if (wd->action_area)
\r
669 evas_object_del(wd->action_area);
\r
670 wd->action_area = NULL;
\r
672 wd->action_area = elm_layout_add(obj);
\r
673 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
674 evas_object_size_hint_weight_set(wd->action_area, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
675 evas_object_size_hint_align_set(wd->action_area, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
676 snprintf(buf, sizeof(buf), "buttons%d", no_of_buttons);
\r
677 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(obj));
\r
678 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,visible", "elm");
\r
679 if (wd->title_area)
\r
680 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
681 _elm_popup_buttons_add_valist (obj, first_button_text, args);
\r
683 edje_object_message_signal_process(wd->layout);
\r
688 * This Set's the time before the popup window is hidden,
\r
689 * and ELM_POPUP_RESPONSE_TIMEOUT is sent along with response signal.
\r
691 * @param[in] obj The popup object
\r
692 * @param[in] timeout The timeout value in seconds.
\r
697 elm_popup_timeout_set(Evas_Object *obj, int timeout)
\r
699 ELM_CHECK_WIDTYPE(obj, widtype);
\r
700 Widget_Data *wd = elm_widget_data_get(obj);
\r
703 elm_notify_timeout_set(wd->notify, timeout);
\r
704 evas_object_smart_callback_add(wd->notify, "notify,timeout", _elm_popup_timeout, obj);
\r
708 * This Set's the mode of popup, by default ELM_POPUP_TYPE_NONE is set i.e, popup
\r
709 * will not close when clicked outside. if ELM_POPUP_TYPE_ALERT is set, popup will close
\r
710 * when clicked outside, and ELM_POPUP_RESPONSE_NONE is sent along with response signal.
\r
712 * @param[in] obj The popup object
\r
713 * @param[in] mode Elm_Popup_Mode
\r
718 elm_popup_mode_set(Evas_Object *obj, Elm_Popup_Mode mode)
\r
720 ELM_CHECK_WIDTYPE(obj, widtype);
\r
721 Widget_Data *wd = elm_widget_data_get(obj);
\r
724 if (mode == ELM_POPUP_TYPE_ALERT)
\r
725 evas_object_smart_callback_add(wd->notify, "block,clicked", _block_clicked_cb, obj);
\r
727 evas_object_smart_callback_del(wd->notify, "block,clicked", _block_clicked_cb);
\r
731 * This Hides the popup by emitting response signal.
\r
733 * @param[in] obj The popup object
\r
734 * @param[in] response_id response ID of the signal to be emitted along with response signal
\r
739 elm_popup_response(Evas_Object *obj, int response_id)
\r
741 ELM_CHECK_WIDTYPE(obj, widtype);
\r
742 Widget_Data *wd = elm_widget_data_get(obj);
\r
745 evas_object_hide(obj);
\r
746 evas_object_smart_callback_call((Evas_Object *)obj, "response", (void *)response_id);
\r
750 * This API controls the direction from which popup will appear and location of popup.
\r
751 * @param[in] obj The popup object
\r
752 * @param[in] orient the orientation of the popup
\r
757 elm_popup_orient_set(Evas_Object *obj, Elm_Popup_Orient orient)
\r
759 ELM_CHECK_WIDTYPE(obj, widtype);
\r
760 Widget_Data *wd = elm_widget_data_get(obj);
\r
761 Elm_Notify_Orient notify_orient = -1;
\r
766 case ELM_POPUP_ORIENT_TOP:
\r
767 notify_orient = ELM_NOTIFY_ORIENT_TOP;
\r
769 case ELM_POPUP_ORIENT_CENTER:
\r
770 notify_orient = ELM_NOTIFY_ORIENT_CENTER;
\r
772 case ELM_POPUP_ORIENT_BOTTOM:
\r
773 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM;
\r
775 case ELM_POPUP_ORIENT_LEFT:
\r
776 notify_orient = ELM_NOTIFY_ORIENT_LEFT;
\r
778 case ELM_POPUP_ORIENT_RIGHT:
\r
779 notify_orient = ELM_NOTIFY_ORIENT_RIGHT;
\r
781 case ELM_POPUP_ORIENT_TOP_LEFT:
\r
782 notify_orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
\r
784 case ELM_POPUP_ORIENT_TOP_RIGHT:
\r
785 notify_orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
\r
787 case ELM_POPUP_ORIENT_BOTTOM_LEFT:
\r
788 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
\r
790 case ELM_POPUP_ORIENT_BOTTOM_RIGHT:
\r
791 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
\r
794 wd->notify_orient = notify_orient;
\r
795 elm_notify_orient_set(wd->notify, notify_orient);
\r
799 * Applications which do not pass any window to popup need to take care of rotation, only when popup is already shown.
\r
800 * @param obj The popup object
\r
801 * @param rot_angle the angle to which popup has to be rotated.
\r
806 elm_popup_rotation_set(Evas_Object *obj, int rot_angle)
\r
808 ELM_CHECK_WIDTYPE(obj, widtype);
\r
809 Widget_Data *wd = elm_widget_data_get(obj);
\r
814 if (wd->rot_angle != rot_angle)
\r
816 elm_win_rotation_with_resize_set(wd->parent,rot_angle);
\r
817 wd->rot_angle = rot_angle;
\r
823 * Blocks in a main loop until popup either emits response signal or is exited due
\r
824 * to exit signal, when exit signal is received dialog responds with ELM_POPUP_RESPONSE_NONE
\r
825 * response ID else returns the response ID from response signal emission.
\r
826 * before entering the main loop popup calls evas_object_show on the popup for you.
\r
827 * you can force popup to return at any time by calling elm_popup_responsec to emit the
\r
828 * response signal. destroying the popup during elm_popup_run is a very bad idea.
\r
829 * typical usage of this function may be
\r
830 * int result = elm_popup_run(popup);
\r
833 * case ELM_POPUP_RESPONSE_OK:
\r
834 * do_something_specific_to_app();
\r
835 * evas_object_del(popup);
\r
837 * case ELM_POPUP_RESPONSE_CANCEL:
\r
838 * do_nothing_popup_was_cancelled();
\r
839 * evas_object_del(popup);
\r
841 * case ELM_POPUP_RESPONSE_NONE:
\r
843 * evas_object_del(popup);
\r
846 * do not run elm_popup_run in a timer/idler callback.
\r
847 * when popup returns with signal ELM_POPUP_RESPONSE_NONE, then exit the application using elm_exit
\r
848 * by calling any post exit application code.
\r
850 * @param[in] obj The popup object
\r
854 elm_popup_run(Evas_Object *obj)
\r
857 Ecore_Event_Handler *_elm_exit_handler = NULL;
\r
858 /*Finger waggle warning*/
\r
859 _elm_dangerous_call_check(__FUNCTION__);
\r
860 evas_object_show(obj);
\r
861 evas_object_smart_callback_add(obj, "response", response_cb, &response_id);
\r
862 _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, &response_id);
\r
863 ecore_main_loop_begin();
\r
864 if (_elm_exit_handler)
\r
866 ecore_event_handler_del(_elm_exit_handler);
\r
867 _elm_exit_handler = NULL;
\r
869 return response_id;
\r