[access] call a callback function with information
[framework/uifw/elementary.git] / src / lib / elc_popup.h
1 /**
2  * @defgroup Popup Popup
3  * @ingroup Elementary
4  *
5  * @image html popup_inheritance_tree.png
6  * @image latex popup_inheritance_tree.eps
7  *
8  * This widget is an enhancement of @ref Notify. In addition to
9  * content area, there are two optional sections, namely title area and
10  * action area.
11  *
12  * The popup widget displays its content with a particular orientation in
13  * the parent area. This orientation can be one among top, center,
14  * bottom, left, top-left, top-right, bottom-left and bottom-right.
15  * Content part of Popup can be an Evas Object set by application or
16  * it can be Text set by application or set of items containing an
17  * icon and/or text.  The content/item-list can be removed using
18  * elm_object_content_set with second parameter passed as NULL.
19  *
20  * The following figures show the textual layouts of popup in which Title
21  * Area and Action area area are optional ones.  Action area can have
22  * up to 3 buttons handled using elm_object common APIs mentioned
23  * below. If user wants to have more than 3 buttons then these buttons
24  * can be put inside the items of a list as content.  User needs to
25  * handle the clicked signal of these action buttons if required.  No
26  * event is processed by the widget automatically when clicked on
27  * these action buttons.
28  *
29  * <pre>
30  *
31  *|---------------------|    |---------------------|    |---------------------|
32  *|     Title Area      |    |     Title Area      |    |     Title Area      |
33  *|Icon|    Text        |    |Icon|    Text        |    |Icon|    Text        |
34  *|---------------------|    |---------------------|    |---------------------|
35  *|       Item 1        |    |                     |    |                     |
36  *|---------------------|    |                     |    |                     |
37  *|       Item 2        |    |                     |    |    Description      |
38  *|---------------------|    |       Content       |    |                     |
39  *|       Item 3        |    |                     |    |                     |
40  *|---------------------|    |                     |    |                     |
41  *|         .           |    |---------------------|    |---------------------|
42  *|         .           |    |     Action Area     |    |     Action Area     |
43  *|         .           |    | Btn1  |Btn2|. |Btn3 |    | Btn1  |Btn2|  |Btn3 |
44  *|---------------------|    |---------------------|    |---------------------|
45  *|       Item N        |     Content Based Layout     Description based Layout
46  *|---------------------|
47  *|     Action Area     |
48  *| Btn1  |Btn2|. |Btn3 |
49  *|---------------------|
50  *   Item Based Layout
51  *
52  * </pre>
53  *
54  * Timeout can be set on expiry of which popup instance hides and
55  * sends a smart signal "timeout" to the user.  The visible region of
56  * popup is surrounded by a translucent region called Blocked Event
57  * area.  By clicking on Blocked Event area, the signal
58  * "block,clicked" is sent to the application. This block event area
59  * can be avoided by using API elm_popup_allow_events_set.  When gets
60  * hidden, popup does not get destroyed automatically, application
61  * should destroy the popup instance after use.  To control the
62  * maximum height of the internal scroller for item, we use the height
63  * of the action area which is passed by theme based on the number of
64  * buttons currently set to popup.
65  *
66  * This widget inherits from the @ref Layout one, so that all the
67  * functions acting on it also work for popup objects (@since 1.8).
68  *
69  * This widget emits the following signals, besides the ones sent from
70  * @ref Layout:
71  * @li @c "timeout" - whenever popup is closed as a result of timeout.
72  * @li @c "block,clicked" - whenever user taps on Blocked Event area.
73  *
74  * Styles available for Popup
75  * @li "default"
76  *
77  * Default contents parts of the popup widget that you can use are:
78  * @li "default" - The content of the popup
79  * @li "title,icon" - Title area's icon
80  * @li "button1" - 1st button of the action area
81  * @li "button2" - 2nd button of the action area
82  * @li "button3" - 3rd button of the action area
83  *
84  * Default text parts of the popup widget that you can use are:
85  * @li "title,text" - This operates on Title area's label
86  * @li "default" - content-text set in the content area of the widget
87  *
88  * Default contents parts of the popup items that you can use are:
89  * @li "default" -Item's icon
90  *
91  * Default text parts of the popup items that you can use are:
92  * @li "default" - Item's label
93  *
94  * Supported elm_object_item common APIs.
95  * @li @ref elm_object_item_disabled_set
96  * @li @ref elm_object_item_disabled_get
97  * @li @ref elm_object_item_part_text_set
98  * @li @ref elm_object_item_part_text_get
99  * @li @ref elm_object_item_part_content_set
100  * @li @ref elm_object_item_part_content_get
101  * @li @ref elm_object_item_signal_emit
102  * @li @ref elm_object_item_del
103  *
104  * Here are some sample code to illustrate Popup usage:
105  * @li @ref popup_example_01_c
106  * @li @ref popup_example_02_c
107  * @li @ref popup_example_03_c
108  */
109
110 /**
111  * @brief Possible orient values for popup.
112  *
113  * These values should be used in conjunction to elm_popup_orient_set() to
114  * set the position in which the popup should appear(relative to its parent)
115  * and in conjunction with elm_popup_orient_get() to know where the popup
116  * is appearing.
117  *
118  * @ingroup Popup
119  */
120 typedef enum
121 {
122    ELM_POPUP_ORIENT_TOP = 0, /**< Popup should appear in the top of parent, default */
123    ELM_POPUP_ORIENT_CENTER, /**< Popup should appear in the center of parent */
124    ELM_POPUP_ORIENT_BOTTOM, /**< Popup should appear in the bottom of parent */
125    ELM_POPUP_ORIENT_LEFT, /**< Popup should appear in the left of parent */
126    ELM_POPUP_ORIENT_RIGHT, /**< Popup should appear in the right of parent */
127    ELM_POPUP_ORIENT_TOP_LEFT, /**< Popup should appear in the top left of parent */
128    ELM_POPUP_ORIENT_TOP_RIGHT, /**< Popup should appear in the top right of parent */
129    ELM_POPUP_ORIENT_BOTTOM_LEFT, /**< Popup should appear in the bottom left of parent */
130    ELM_POPUP_ORIENT_BOTTOM_RIGHT, /**< Notify should appear in the bottom right of parent */
131    ELM_POPUP_ORIENT_LAST /**< Sentinel value, @b don't use */
132  } Elm_Popup_Orient;
133
134 /**
135  * @brief Adds a new Popup to the parent
136  *
137  * @param parent The parent object
138  * @return The new object or NULL if it cannot be created
139  *
140  * @ingroup Popup
141  */
142 EAPI Evas_Object *elm_popup_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
143
144 /**
145  * @brief Add a new item to a Popup object
146  *
147  * Both an item list and a content could not be set at the same time!
148  * once you add an item, the previous content will be removed.
149  *
150  * @param obj popup object
151  * @param icon Icon to be set on new item
152  * @param label The Label of the new item
153  * @param func Convenience function called when item selected
154  * @param data Data passed to @p func above
155  * @return A handle to the item added or @c NULL, on errors
156  *
157  * @ingroup Popup
158  * @warning When the first item is appended to popup object, any previous content
159  * of the content area is deleted. At a time, only one of content, content-text
160  * and item(s) can be there in a popup content area.
161  */
162 EAPI Elm_Object_Item *elm_popup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1);
163
164 /**
165  * @brief Sets the wrapping type of content text packed in content
166  * area of popup object.
167  *
168  * @param obj The Popup object
169  * @param wrap wrapping type of type Elm_Wrap_Type
170  *
171  * @ingroup Popup
172  * @see elm_popup_content_text_wrap_type_get()
173  */
174 EAPI void elm_popup_content_text_wrap_type_set(Evas_Object *obj, Elm_Wrap_Type wrap) EINA_ARG_NONNULL(1);
175
176 /**
177  * @brief Returns the wrapping type of content text packed in content area of
178  * popup object.
179  *
180  * @param obj The Popup object
181  * @return wrap type of the content text
182  *
183  * @ingroup Popup
184  * @see elm_popup_content_text_wrap_type_set
185  */
186 EAPI Elm_Wrap_Type elm_popup_content_text_wrap_type_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
187
188 /**
189  * @brief Sets the orientation of the popup in the parent region
190  *
191  * @param obj The popup object
192  * @param orient  the orientation of the popup
193  *
194  * Sets the position in which popup will appear in its parent
195  *
196  * @ingroup Popup
197  * @see @ref Elm_Popup_Orient for possible values.
198  */
199 EAPI void elm_popup_orient_set(Evas_Object *obj, Elm_Popup_Orient orient) EINA_ARG_NONNULL(1);
200
201 /**
202  * @brief Returns the orientation of Popup
203  *
204  * @param obj The popup object
205  * @return the orientation of the popup
206  *
207  * @ingroup Popup
208  * @see elm_popup_orient_set()
209  * @see Elm_Popup_Orient
210  */
211 EAPI Elm_Popup_Orient elm_popup_orient_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
212
213 /**
214  * @brief Sets a timeout to hide popup automatically
215  *
216  * @param obj The popup object
217  * @param timeout The timeout in seconds
218  *
219  * This function sets a timeout and starts the timer controlling when the
220  * popup is hidden. Since calling evas_object_show() on a popup restarts
221  * the timer controlling when it is hidden, setting this before the
222  * popup is shown will in effect mean starting the timer when the popup is
223  * shown. Smart signal "timeout" is called afterwards which can be handled
224  * if needed.
225  *
226  * @note Set a value <= 0.0 to disable a running timer.
227  *
228  * @note If the value > 0.0 and the popup is previously visible, the
229  * timer will be started with this value, canceling any running timer.
230  * @ingroup Popup
231  */
232 EAPI void elm_popup_timeout_set(Evas_Object *obj, double timeout) EINA_ARG_NONNULL(1);
233
234 /**
235  * @brief Returns the timeout value set to the popup (in seconds)
236  *
237  * @param obj The popup object
238  * @return the timeout value
239  *
240  * @ingroup Popup
241  * @see elm_popup_timeout_set()
242  */
243 EAPI double elm_popup_timeout_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
244
245 /**
246  * @brief Sets whether events should be passed to by a click outside.
247  *
248  * @param obj The popup object
249  * @param allow EINA_TRUE Events are passed to lower objects, else not
250  *
251  * Enabling allow event will remove the Blocked event area and events will
252  * pass to the lower layer objects otherwise they are blocked.
253  *
254  * @ingroup Popup
255  * @see elm_popup_allow_events_get()
256  * @note The default value is EINA_FALSE.
257  */
258 EAPI void elm_popup_allow_events_set(Evas_Object *obj, Eina_Bool allow);
259
260 /**
261  * @brief Returns value indicating whether allow event is enabled or not
262  *
263  * @param obj The popup object
264  * @return EINA_FALSE if Blocked event area is present else EINA_TRUE
265  *
266  * @ingroup Popup
267  * @see elm_popup_allow_events_set()
268  * @note By default the Blocked event area is present
269  */
270 EAPI Eina_Bool elm_popup_allow_events_get(const Evas_Object *obj);