2015-07-18 08:21:49 -07:00
|
|
|
~~Title: Popup Tutorial~~
|
|
|
|
==== Popup Tutorial ====
|
|
|
|
|
|
|
|
This tutorial explains how to use Popup in the application.
|
|
|
|
|
|
|
|
=== Table of Contents ===
|
|
|
|
|
|
|
|
* [[#Initializing_the_Application|Initializing the Application]]
|
|
|
|
* [[#Creating_a_Popup_Widget|Creating a Popup Widget]]
|
|
|
|
|
2015-07-18 08:40:42 -07:00
|
|
|
A popup example : {{ :popup.png?direct |list}}
|
2015-07-18 08:21:49 -07:00
|
|
|
|
|
|
|
//**__The whole code__ : **//{{/code_c/tutorial/popup/popup.c}}
|
|
|
|
--------
|
|
|
|
|
|
|
|
=== Initializing the Application ===
|
|
|
|
|
|
|
|
The code below shows a typical elementary application that creates a window
|
|
|
|
entitled "Popup Tutorial" and a button which opens up popup on click.
|
|
|
|
<code c>
|
|
|
|
#include <Elementary.h>
|
|
|
|
|
2015-07-18 08:40:42 -07:00
|
|
|
static void
|
2015-07-18 08:45:36 -07:00
|
|
|
_btn_click_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
2015-07-18 08:40:42 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
//popup code here
|
|
|
|
}
|
|
|
|
|
2015-07-18 08:21:49 -07:00
|
|
|
EAPI_MAIN int
|
|
|
|
elm_main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *btn;
|
|
|
|
|
|
|
|
win = elm_win_util_standard_add("Popup", "Popup Tutorial");
|
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
|
|
|
//win 400x400 px
|
|
|
|
evas_object_resize(win, 400, 400);
|
|
|
|
|
|
|
|
btn = elm_button_add(win);
|
|
|
|
elm_object_text_set(btn, "popup");
|
|
|
|
evas_object_resize(btn, 100, 50);
|
|
|
|
evas_object_move(btn, 150, 150);
|
|
|
|
evas_object_show(btn);
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", _btn_click_cb, win);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
elm_run();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ELM_MAIN()
|
|
|
|
</code>
|
|
|
|
|
2015-07-18 08:49:20 -07:00
|
|
|
=== Creating a Popup Widget ===
|
2015-07-18 08:40:42 -07:00
|
|
|
This widget is an enhancement of Notify. In addition to content area, there are two optional sections, namely title area and action area.
|
2015-07-18 08:21:49 -07:00
|
|
|
|
|
|
|
<code c>
|
2015-07-18 08:45:36 -07:00
|
|
|
static void
|
|
|
|
_popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *popup = data;
|
|
|
|
//delete popup
|
|
|
|
evas_object_del(popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_btn_click_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
2015-07-18 08:40:42 -07:00
|
|
|
Evas_Object *popup;
|
|
|
|
Evas_Object *btn;
|
2015-07-18 21:23:19 -07:00
|
|
|
|
|
|
|
// Add an elm popup
|
2015-07-18 08:40:42 -07:00
|
|
|
popup = elm_popup_add(data);
|
|
|
|
elm_object_text_set(popup, "This Popup has content area and "
|
|
|
|
"action area set, action area has one button Close");
|
2015-07-18 08:21:49 -07:00
|
|
|
|
2015-07-18 08:40:42 -07:00
|
|
|
// popup buttons
|
|
|
|
btn = elm_button_add(popup);
|
|
|
|
elm_object_text_set(btn, "Close");
|
|
|
|
elm_object_part_content_set(popup, "button1", btn);
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", _popup_close_cb, popup);
|
2015-07-18 08:21:49 -07:00
|
|
|
|
2015-07-18 08:40:42 -07:00
|
|
|
// popup show should be called after adding all the contents and the buttons
|
|
|
|
// of popup to set the focus into popup's contents correctly.
|
|
|
|
evas_object_show(popup);
|
2015-07-18 08:21:49 -07:00
|
|
|
}
|
2015-08-20 08:16:55 -07:00
|
|
|
</code>
|