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 Evas_Object *parent_app;
\r
21 Evas_Object *title_area;
\r
22 Evas_Object *title_icon;
\r
23 Evas_Object *content_area;
\r
24 Evas_Object *desc_label;
\r
25 Evas_Object *action_area;
\r
26 Eina_List *button_list;
\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
49 static void _resize_parent(void *data, Evas *e, Evas_Object *obj, void *event_info);
\r
52 _del_parent(void *data, Evas *e, Evas_Object *obj, void *evet_info)
\r
54 Evas_Object *pop = data;
\r
55 Widget_Data *wd = elm_widget_data_get(pop);
\r
58 if (wd->parent == obj)
\r
60 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _del_parent, pop);
\r
66 _del_job(void *data)
\r
68 Evas_Object *obj = data;
\r
69 evas_object_del(obj);
\r
73 _del_hook(Evas_Object *obj)
\r
75 Widget_Data *wd = elm_widget_data_get(obj);
\r
82 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _del_parent, obj);
\r
83 wd->del_job = ecore_job_add(_del_job, wd->parent);
\r
91 _del_pre_hook(Evas_Object *obj)
\r
93 Widget_Data *wd = elm_widget_data_get(obj);
\r
94 Action_Area_Data *action_data = NULL;
\r
95 Eina_List *list = NULL;
\r
98 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_SHOW, _show, NULL);
\r
99 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_HIDE, _hide, NULL);
\r
100 if (wd->parent_app)
\r
101 evas_object_event_callback_del_full(wd->parent_app, EVAS_CALLBACK_RESIZE, _resize_parent, obj);
\r
102 EINA_LIST_FOREACH(wd->button_list, list, action_data)
\r
105 action_data = NULL;
\r
107 eina_list_free(wd->button_list);
\r
111 _theme_hook(Evas_Object *obj)
\r
113 Widget_Data *wd = elm_widget_data_get(obj);
\r
115 Eina_List *list = NULL;
\r
116 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, ELM_NOTIFY_ORIENT_CENTER);
\r
121 edje_object_message_signal_process(elm_layout_edje_get(wd->layout));
\r
122 if (wd->title_area)
\r
124 snprintf(buf, sizeof(buf), "popup_title/%s", elm_widget_style_get(obj));
\r
125 elm_object_style_set(wd->title_area, buf);
\r
127 if (wd->action_area)
\r
129 EINA_LIST_FOREACH(wd->button_list, list, action_data)
\r
131 snprintf(buf, sizeof(buf), "popup_button/%s", elm_widget_style_get(obj));
\r
132 elm_object_style_set(action_data->btn, buf);
\r
135 if (wd->content_area)
\r
137 elm_layout_theme_set(wd->content_area, "popup", "content", elm_widget_style_get(obj));
\r
138 if (wd->desc_label)
\r
140 snprintf(buf, sizeof(buf), "popup_description/%s", elm_widget_style_get(obj));
\r
141 elm_object_style_set(wd->desc_label, buf);
\r
148 _sizing_eval(Evas_Object *obj)
\r
150 Widget_Data *wd = elm_widget_data_get(obj);
\r
151 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
\r
154 edje_object_size_min_calc(elm_layout_edje_get(wd->layout), &minw, &minh);
\r
155 evas_object_size_hint_min_set(obj, minw, minh);
\r
156 evas_object_size_hint_max_set(obj, maxw, maxh);
\r
160 _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
162 _sizing_eval(data);
\r
166 _block_clicked_cb( void *data, Evas_Object *obj, void *event_info )
\r
168 evas_object_hide((Evas_Object*)data);
\r
169 evas_object_smart_callback_call((Evas_Object *)data, "response", (void *)ELM_POPUP_RESPONSE_NONE);
\r
172 static Ecore_Event_Handler* _elm_wnd_map_handler = NULL;
\r
175 _wnd_map_notify(void *data, int type, void *event)
\r
178 Evas_Object* obj = (Evas_Object*)data;
\r
180 if (obj && _elm_wnd_map_handler)
\r
182 e = evas_object_evas_get(obj);
\r
186 /* Render given object again, previous frame was discarded. */
\r
188 ecore_event_handler_del(_elm_wnd_map_handler);
\r
189 _elm_wnd_map_handler = NULL;
\r
198 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
200 Widget_Data *wd = elm_widget_data_get(obj);
\r
203 if (wd->parent) evas_object_show(wd->parent);
\r
204 elm_layout_theme_set(wd->layout, "popup", "base", elm_widget_style_get(obj));
\r
206 evas_object_show(obj);
\r
207 if (e && !_elm_wnd_map_handler)
\r
209 int curr_rmethod = 0;
\r
210 int gl_rmethod = 0;
\r
212 curr_rmethod = evas_output_method_get(e);
\r
213 gl_rmethod = evas_render_method_lookup("gl_x11");
\r
215 if (!curr_rmethod) return;
\r
216 if (!gl_rmethod) return;
\r
217 if (curr_rmethod == gl_rmethod)
\r
218 _elm_wnd_map_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, _wnd_map_notify, obj);
\r
223 _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
225 Widget_Data *wd = elm_widget_data_get(obj);
\r
228 if (wd->parent) evas_object_hide(wd->parent);
\r
229 evas_object_hide(obj);
\r
233 _resize_parent(void *data, Evas *e, Evas_Object *obj, void *event_info)
\r
235 Widget_Data *wd = elm_widget_data_get(data);
\r
241 rot_angle = elm_win_rotation_get(obj);
\r
242 if (wd->rot_angle != rot_angle)
\r
244 elm_win_rotation_with_resize_set(wd->parent, rot_angle);
\r
245 wd->rot_angle = rot_angle;
\r
251 _action_area_clicked( void *data, Evas_Object *obj, void *event_info )
\r
253 Action_Area_Data *adata = NULL;
\r
254 adata = (Action_Area_Data *)data;
\r
256 if (!adata) return;
\r
257 evas_object_smart_callback_call(adata->obj, "response", (void *)adata->response_id);
\r
258 evas_object_hide(adata->obj);
\r
261 static Evas_Object*
\r
262 _elm_popup_add_button(Evas_Object *obj, const char *text, int response_id)
\r
265 Widget_Data *wd = elm_widget_data_get(obj);
\r
268 if (!wd) return NULL;
\r
269 Action_Area_Data *adata = ELM_NEW(sizeof(Action_Area_Data));
\r
270 btn = elm_button_add(obj);
\r
271 snprintf(buf, sizeof(buf), "popup_button/%s", elm_widget_style_get(obj));
\r
272 elm_object_style_set(btn, buf);
\r
273 elm_button_label_set(btn, text);
\r
274 adata->response_id = response_id;
\r
277 wd->button_list = eina_list_append(wd->button_list, adata);
\r
278 evas_object_smart_callback_add(btn, "clicked", _action_area_clicked, adata);
\r
283 _elm_popup_buttons_add_valist(Evas_Object *obj, const char *first_button_text, va_list args)
\r
285 const char *text = NULL;
\r
291 if (first_button_text == NULL) return;
\r
292 Widget_Data *wd = elm_widget_data_get(obj);
\r
294 text = first_button_text;
\r
295 response = va_arg(args, int);
\r
296 while (text != NULL)
\r
298 btn = _elm_popup_add_button(obj, text, response);
\r
300 snprintf(buf, sizeof(buf), "actionbtn%d", index);
\r
301 elm_layout_content_set(wd->action_area, buf, btn);
\r
302 evas_object_event_callback_add(wd->action_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
303 _changed_size_hints, obj);
\r
304 text = va_arg(args, char*);
\r
305 if (text == NULL) break;
\r
306 response = va_arg(args, int);
\r
311 _elm_popup_timeout( void *data, Evas_Object *obj, void *event_info )
\r
313 evas_object_hide((Evas_Object*)data);
\r
314 evas_object_smart_callback_call((Evas_Object *)data, "response", (void *)ELM_POPUP_RESPONSE_TIMEOUT);
\r
318 _elm_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
\r
320 int res_id = ELM_POPUP_RESPONSE_NONE;
\r
321 int *id = (int *)data;
\r
323 ecore_main_loop_quit();
\r
328 response_cb( void *data, Evas_Object *obj, void *event_info )
\r
330 int res_id = (int) event_info;
\r
331 int *id = (int *)data;
\r
333 ecore_main_loop_quit();
\r
337 * Add a new Popup object.
\r
339 * @param parent The parent object
\r
340 * @return The new object or NULL if it cannot be created
\r
345 elm_popup_add(Evas_Object *parent_app)
\r
350 Evas_Object *parent;
\r
351 Evas_Coord x,y,w,h;
\r
354 unsigned char *prop_data = NULL;
\r
357 //FIXME: Keep this window always on top
\r
358 parent = elm_win_add(parent_app, "popup", ELM_WIN_DIALOG_BASIC);
\r
359 elm_win_borderless_set(parent, EINA_TRUE);
\r
360 elm_win_alpha_set(parent, EINA_TRUE);
\r
361 elm_win_raise(parent);
\r
364 evas_object_geometry_get(parent_app, &x, &y, &w, &h);
\r
365 rotation = elm_win_rotation_get(parent_app);
\r
366 evas_object_resize(parent, w, h);
\r
367 evas_object_move(parent, x, y);
\r
368 if (rotation != -1)
\r
369 elm_win_rotation_set(parent, rotation);
\r
373 ecore_x_window_geometry_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &x, &y, &w, &h);
\r
374 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
375 ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
\r
376 if (ret && prop_data) memcpy(&rotation, prop_data, sizeof(int));
\r
377 if (prop_data) free(prop_data);
\r
378 evas_object_resize(parent, w, h);
\r
379 evas_object_move(parent, x, y);
\r
380 if (rotation != -1)
\r
381 elm_win_rotation_with_resize_set(parent, rotation);
\r
384 wd = ELM_NEW(Widget_Data);
\r
385 e = evas_object_evas_get(parent);
\r
386 obj = elm_widget_add(e);
\r
387 ELM_SET_WIDTYPE(widtype, "popup");
\r
388 elm_widget_type_set(obj, "popup");
\r
389 elm_widget_sub_object_add(parent, obj);
\r
390 elm_widget_data_set(obj, wd);
\r
391 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
\r
392 elm_widget_del_hook_set(obj, _del_hook);
\r
393 elm_widget_theme_hook_set(obj, _theme_hook);
\r
394 wd->parent = parent;
\r
395 wd->rot_angle = rotation;
\r
397 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, _del_parent, obj);
\r
399 evas_object_event_callback_add(parent_app, EVAS_CALLBACK_RESIZE, _resize_parent, obj);
\r
400 wd->parent_app = parent_app;
\r
402 wd->notify = elm_notify_add(parent);
\r
403 elm_widget_resize_object_set(obj, wd->notify);
\r
404 elm_notify_orient_set(wd->notify, ELM_NOTIFY_ORIENT_CENTER);
\r
405 elm_notify_repeat_events_set(wd->notify, EINA_FALSE);
\r
406 evas_object_size_hint_weight_set(wd->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
407 evas_object_size_hint_align_set(wd->notify, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
409 wd->layout = elm_layout_add(parent);
\r
410 evas_object_size_hint_weight_set(wd->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
411 evas_object_size_hint_align_set(wd->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
413 elm_layout_theme_set(wd->layout, "popup", "base", "default");
\r
414 elm_notify_content_set(wd->notify, wd->layout);
\r
416 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _show, NULL);
\r
417 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _hide, NULL);
\r
425 * Add a new Popup object.
\r
427 * @param parent The parent object
\r
428 * @param title text to be displayed in title area.
\r
429 * @param desc_text text to be displayed in description area.
\r
430 * @param no_of_buttons Number of buttons to be packed in action area.
\r
431 * @param first_button_text button text
\r
432 * @param Varargs response ID for first button, then additional buttons followed by response id's ending with NULL
\r
433 * @return The new object or NULL if it cannot be created
\r
438 elm_popup_add_with_buttons(Evas_Object *parent, char *title, char *desc_text,int no_of_buttons, char *first_button_text, ... )
\r
440 Evas_Object *popup;
\r
441 popup = elm_popup_add(parent);
\r
442 Widget_Data *wd = elm_widget_data_get(popup);
\r
447 elm_popup_desc_set(popup, desc_text);
\r
451 elm_popup_title_label_set(popup, title);
\r
453 if (first_button_text)
\r
456 va_start(args, first_button_text);
\r
457 wd->action_area = elm_layout_add(popup);
\r
458 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
459 snprintf(buf,sizeof(buf), "buttons%d", no_of_buttons);
\r
460 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(popup));
\r
461 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,visible", "elm");
\r
462 if (wd->title_area)
\r
464 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
466 _elm_popup_buttons_add_valist (popup, first_button_text, args);
\r
470 _sizing_eval(popup);
\r
476 * This Set's the description text in content area of Popup widget.
\r
478 * @param text description text.
\r
483 elm_popup_desc_set(Evas_Object *obj, const char *text)
\r
485 ELM_CHECK_WIDTYPE(obj, widtype);
\r
486 Widget_Data *wd = elm_widget_data_get(obj);
\r
490 if (wd->content_area)
\r
492 evas_object_del(wd->content_area);
\r
493 wd->content_area = NULL;
\r
495 wd->content_area = elm_layout_add(obj);
\r
496 elm_layout_theme_set(wd->content_area, "popup", "content", elm_widget_style_get(obj));
\r
497 wd->desc_label = elm_label_add(obj);
\r
498 snprintf(buf, sizeof(buf), "popup_description/%s", elm_widget_style_get(obj));
\r
499 elm_object_style_set(wd->desc_label, buf);
\r
500 elm_label_line_wrap_set(wd->desc_label, EINA_TRUE);
\r
501 elm_label_label_set(wd->desc_label, text);
\r
502 evas_object_size_hint_weight_set(wd->desc_label, EVAS_HINT_EXPAND, 0.0);
\r
503 evas_object_size_hint_align_set(wd->desc_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
504 evas_object_show(wd->desc_label);
\r
505 elm_layout_content_set(wd->content_area, "elm.swallow.content", wd->desc_label);
\r
506 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
507 evas_object_event_callback_add(wd->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
508 _changed_size_hints, obj);
\r
513 * This Get's the description text packed in content area of popup object.
\r
515 * @param obj The Popup object
\r
516 * @return description text.
\r
521 elm_popup_desc_get(Evas_Object *obj)
\r
523 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
524 Widget_Data *wd = elm_widget_data_get(obj);
\r
526 if (!wd) return NULL;
\r
527 return elm_label_label_get(wd->desc_label);
\r
531 * This Set's the title text in title area of popup object.
\r
533 * @param obj The popup object
\r
534 * @param text The title text
\r
539 elm_popup_title_label_set(Evas_Object *obj, const char *text)
\r
541 ELM_CHECK_WIDTYPE(obj, widtype);
\r
542 Widget_Data *wd = elm_widget_data_get(obj);
\r
546 if (wd->title_area)
\r
548 evas_object_del(wd->title_area);
\r
549 wd->title_area = NULL;
\r
551 wd->title_area = elm_label_add(obj);
\r
552 snprintf(buf, sizeof(buf), "popup_title/%s", elm_widget_style_get(obj));
\r
553 elm_object_style_set(wd->title_area, buf);
\r
554 elm_label_label_set(wd->title_area, text);
\r
555 evas_object_size_hint_weight_set(wd->title_area, EVAS_HINT_EXPAND, 0.0);
\r
556 evas_object_size_hint_align_set(wd->title_area, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
557 elm_layout_content_set(wd->layout, "elm.swallow.title", wd->title_area);
\r
558 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,visible", "elm");
\r
559 if (wd->action_area)
\r
561 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
563 if (wd->title_icon)
\r
565 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,icon,visible", "elm");
\r
571 * This Get's the title text packed in title area of popup object.
\r
573 * @param obj The Popup object
\r
574 * @return title text
\r
579 elm_popup_title_label_get(Evas_Object *obj)
\r
581 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
582 Widget_Data *wd = elm_widget_data_get(obj);
\r
584 if (!wd) return NULL;
\r
585 return elm_label_label_get(wd->title_area);
\r
589 * This Set's the icon in the title area of Popup object.
\r
591 * @param obj The popup object
\r
592 * @param icon The title icon
\r
597 elm_popup_title_icon_set(Evas_Object *obj, Evas_Object *icon)
\r
599 ELM_CHECK_WIDTYPE(obj, widtype);
\r
600 Widget_Data *wd = elm_widget_data_get(obj);
\r
603 if (wd->title_icon)
\r
605 evas_object_del(wd->title_icon);
\r
606 wd->title_icon = NULL;
\r
608 wd->title_icon = icon;
\r
609 elm_layout_content_set(wd->layout, "elm.swallow.title.icon", wd->title_icon);
\r
610 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,title,icon,visible", "elm");
\r
615 * This Get's the icon packed in title area of Popup object.
\r
617 * @param obj The Popup object
\r
618 * @return title icon
\r
623 elm_popup_title_icon_get(Evas_Object *obj)
\r
625 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
626 Widget_Data *wd = elm_widget_data_get(obj);
\r
628 if (!wd) return NULL;
\r
629 return wd->title_icon;
\r
633 * This Set's the content widget in content area of Popup object.
\r
635 * @param obj The popup object
\r
636 * @param content The content widget
\r
641 elm_popup_content_set(Evas_Object *obj, Evas_Object *content)
\r
643 ELM_CHECK_WIDTYPE(obj, widtype);
\r
644 Widget_Data *wd = elm_widget_data_get(obj);
\r
647 if (wd->content_area)
\r
649 evas_object_del(wd->content_area);
\r
650 wd->content_area = NULL;
\r
652 wd->content_area = elm_layout_add(obj);
\r
653 elm_layout_theme_set(wd->content_area, "popup","content", elm_widget_style_get(obj));
\r
654 elm_layout_content_set(wd->content_area, "elm.swallow.content", content);
\r
655 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->content_area);
\r
656 evas_object_event_callback_add(wd->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
\r
657 _changed_size_hints, obj);
\r
662 * This Get's the content widget packed in content area of Popup object.
\r
664 * @param obj The Popup object
\r
665 * @return content packed in popup widget
\r
670 elm_popup_content_get(Evas_Object *obj)
\r
672 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
673 Widget_Data *wd = elm_widget_data_get(obj);
\r
675 if (!wd) return NULL;
\r
676 return wd->content_area;
\r
680 * Adds the buttons in to the action area of popup object.
\r
682 * @param obj The popup object
\r
683 * @param no_of_buttons Number of buttons that has to be packed in action area.
\r
684 * @param first_button_text Label of first button
\r
685 * @param Varargs Response ID(Elm_Popup_Response/ any integer value) for first button, then additional buttons along with their response id ending with NULL.
\r
689 elm_popup_buttons_add(Evas_Object *obj,int no_of_buttons, char *first_button_text, ...)
\r
692 ELM_CHECK_WIDTYPE(obj, widtype);
\r
693 Widget_Data *wd = elm_widget_data_get(obj);
\r
698 va_start(args, first_button_text);
\r
699 if (wd->action_area)
\r
701 evas_object_del(wd->action_area);
\r
702 wd->action_area = NULL;
\r
704 wd->action_area = elm_layout_add(obj);
\r
705 elm_layout_content_set(wd->layout, "elm.swallow.buttonArea", wd->action_area);
\r
706 evas_object_size_hint_weight_set(wd->action_area, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
707 evas_object_size_hint_align_set(wd->action_area, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
708 snprintf(buf, sizeof(buf), "buttons%d", no_of_buttons);
\r
709 elm_layout_theme_set(wd->action_area, "popup", buf, elm_widget_style_get(obj));
\r
710 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,visible", "elm");
\r
711 if (wd->title_area)
\r
713 edje_object_signal_emit(elm_layout_edje_get(wd->layout), "elm,state,button,title,visible", "elm");
\r
715 _elm_popup_buttons_add_valist (obj, first_button_text, args);
\r
721 * This Set's the time before the popup window is hidden,
\r
722 * and ELM_POPUP_RESPONSE_TIMEOUT is sent along with response signal.
\r
724 * @param obj The popup object
\r
725 * @param timeout The timeout value in seconds.
\r
730 elm_popup_timeout_set(Evas_Object *obj, int timeout)
\r
732 ELM_CHECK_WIDTYPE(obj, widtype);
\r
733 Widget_Data *wd = elm_widget_data_get(obj);
\r
736 elm_notify_timeout_set(wd->notify, timeout);
\r
737 evas_object_smart_callback_add(wd->notify, "notify,timeout", _elm_popup_timeout, obj);
\r
741 * This Set's the mode of popup, by default ELM_POPUP_TYPE_NONE is set i.e, popup
\r
742 * will not close when clicked outside. if ELM_POPUP_TYPE_ALERT is set, popup will close
\r
743 * when clicked outside, and ELM_POPUP_RESPONSE_NONE is sent along with response signal.
\r
745 * @param obj The popup object
\r
746 * @param mode Elm_Popup_Mode
\r
751 elm_popup_mode_set(Evas_Object *obj, Elm_Popup_Mode mode)
\r
753 ELM_CHECK_WIDTYPE(obj, widtype);
\r
754 Widget_Data *wd = elm_widget_data_get(obj);
\r
757 if(mode == ELM_POPUP_TYPE_ALERT)
\r
758 evas_object_smart_callback_add(wd->notify, "block,clicked", _block_clicked_cb, obj);
\r
760 evas_object_smart_callback_del(wd->notify, "block,clicked", _block_clicked_cb);
\r
764 * This Hides the popup by emitting response signal.
\r
766 * @param obj The popup object
\r
767 * @param response_id response ID of the signal to be emitted along with response signal
\r
772 elm_popup_response(Evas_Object *obj, int response_id)
\r
774 ELM_CHECK_WIDTYPE(obj, widtype);
\r
775 Widget_Data *wd = elm_widget_data_get(obj);
\r
778 evas_object_hide(obj);
\r
779 evas_object_smart_callback_call((Evas_Object *)obj, "response", (void *)response_id);
\r
783 * This API controls the direction from which popup will appear and location of popup.
\r
784 * @param obj The popup object
\r
785 * @param orient the orientation of the popup
\r
790 elm_popup_orient_set(Evas_Object *obj, Elm_Popup_Orient orient)
\r
792 ELM_CHECK_WIDTYPE(obj, widtype);
\r
793 Widget_Data *wd = elm_widget_data_get(obj);
\r
794 Elm_Notify_Orient notify_orient = -1;
\r
799 case ELM_POPUP_ORIENT_TOP:
\r
800 notify_orient = ELM_NOTIFY_ORIENT_TOP;
\r
802 case ELM_POPUP_ORIENT_CENTER:
\r
803 notify_orient = ELM_NOTIFY_ORIENT_CENTER;
\r
805 case ELM_POPUP_ORIENT_BOTTOM:
\r
806 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM;
\r
808 case ELM_POPUP_ORIENT_LEFT:
\r
809 notify_orient = ELM_NOTIFY_ORIENT_LEFT;
\r
811 case ELM_POPUP_ORIENT_RIGHT:
\r
812 notify_orient = ELM_NOTIFY_ORIENT_RIGHT;
\r
814 case ELM_POPUP_ORIENT_TOP_LEFT:
\r
815 notify_orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
\r
817 case ELM_POPUP_ORIENT_TOP_RIGHT:
\r
818 notify_orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
\r
820 case ELM_POPUP_ORIENT_BOTTOM_LEFT:
\r
821 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
\r
823 case ELM_POPUP_ORIENT_BOTTOM_RIGHT:
\r
824 notify_orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
\r
827 elm_notify_orient_set(wd->notify, notify_orient);
\r
831 * Applications which do not pass any window to popup need to take care of rotation, only when popup is already shown.
\r
832 * @param obj The popup object
\r
833 * @param rot_angle the angle to which popup has to be rotated.
\r
838 elm_popup_rotation_set(Evas_Object *obj, int rot_angle)
\r
840 ELM_CHECK_WIDTYPE(obj, widtype);
\r
841 Widget_Data *wd = elm_widget_data_get(obj);
\r
846 if (wd->rot_angle != rot_angle)
\r
848 elm_win_rotation_with_resize_set(wd->parent, rot_angle);
\r
849 wd->rot_angle = rot_angle;
\r
855 * Blocks in a main loop until popup either emits response signal or is exited due
\r
856 * to exit signal, when exit signal is received dialog responds with ELM_POPUP_RESPONSE_NONE
\r
857 * response ID else returns the response ID from response signal emission.
\r
858 * before entering the main loop popup calls evas_object_show on the popup for you.
\r
859 * you can force popup to return at any time by calling elm_popup_responsec to emit the
\r
860 * response signal. destroying the popup during elm_popup_run is a very bad idea.
\r
861 * typical usage of this function may be
\r
862 * int result = elm_popup_run(popup);
\r
865 * case ELM_POPUP_RESPONSE_OK:
\r
866 * do_something_specific_to_app();
\r
867 * evas_object_del(popup);
\r
869 * case ELM_POPUP_RESPONSE_CANCEL:
\r
870 * do_nothing_popup_was_cancelled();
\r
871 * evas_object_del(popup);
\r
873 * case ELM_POPUP_RESPONSE_NONE:
\r
875 * evas_object_del(popup);
\r
878 * do not run elm_popup_run in a timer/idler callback.
\r
879 * when popup returns with signal ELM_POPUP_RESPONSE_NONE, then exit the application using elm_exit
\r
880 * by calling any post exit application code.
\r
882 * @param obj The popup object
\r
886 elm_popup_run(Evas_Object *obj)
\r
889 Ecore_Event_Handler *_elm_exit_handler = NULL;
\r
890 /*Finger waggle warning*/
\r
891 /*_elm_dangerous_call_check(__FUNCTION__);*/
\r
892 WRN("WARNING!! Dont use this function use response signal instead, this function is only for applications using java script engine");
\r
893 evas_object_show(obj);
\r
894 evas_object_smart_callback_add(obj, "response", response_cb, &response_id);
\r
895 _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, &response_id);
\r
896 ecore_main_loop_begin();
\r
897 if(_elm_exit_handler)
\r
899 ecore_event_handler_del(_elm_exit_handler);
\r
900 _elm_exit_handler = NULL;
\r
902 return response_id;
\r