2 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * This file is part of the UI Gadget
5 * Written by Jayoun Lee <airjany@samsung.com>, Jinwoo Nam <jwoo.nam@samsung.com>
7 * PROPRIETARY/CONFIDENTIAL
9 * This software is the confidential and proprietary information of
10 * SAMSUNG ELECTRONICS (Confidential Information).
11 * You shall not disclose such Confidential Information and shall
12 * use it only in accordance with the terms of the license agreement
13 * you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no
14 * representations or warranties about the suitability
15 * of the software, either express or implied, including but not
16 * limited to the implied warranties of merchantability, fitness for a particular purpose, or non-
17 * infringement. SAMSUNG shall not be liable for any damages suffered by licensee as
18 * a result of using, modifying or distributing this software or its derivatives.
22 #ifndef __UI_GADGET_H__
23 #define __UI_GADGET_H__
27 * @author Wonguk Jeong <wonguk.jeong@samsung.com>
29 * @brief This file contains the public API of the UI gadget library
33 * @addtogroup APPLICATION_FRAMEWORK
36 * @defgroup UI_Gadget UI gadget library
37 * @author Wonguk Jeong <wonguk.jeong@samsung.com>
39 * @brief A library to develop/use a UI gadget
43 * @addtogroup UI_Gadget
46 * @defgroup UI_Gadget_For_User User API Reference Guide
47 * @brief A module to use a UI gadget. Caller uses this module and APIs.
49 * @section Header To Use Them:
51 * #include <ui-gadget.h>
56 * @addtogroup UI_Gadget_For_User
68 * struct ui_gadget is an opaque type representing a UI gadget
69 * @see ug_create(), ug_destroy()
70 * @see ug_get_layout(), ug_get_parent_layout(), ug_get_mode()
80 UG_MODE_FULLVIEW, /**< Fullview mode */
81 UG_MODE_FRAMEVIEW, /**< Frameview mode */
82 UG_MODE_INVALID, /**< Invalid mode */
88 * @see ug_send_event()
91 UG_EVENT_NONE = 0x00, /**< No event */
92 UG_EVENT_LOW_MEMORY, /**< Low memory event */
93 UG_EVENT_LOW_BATTERY, /**< Low battery event */
94 UG_EVENT_LANG_CHANGE, /**< Language change event */
95 UG_EVENT_ROTATE_PORTRAIT, /**< Rotate event: Portrait */
96 UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN, /**< Rotate event: Portrait upsidedown */
97 UG_EVENT_ROTATE_LANDSCAPE, /**< Rotate event: Landscape */
98 UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN,
99 /**< Rotate event: Landscape upsidedown */
100 UG_EVENT_REGION_CHANGE, /**< Region change event */
105 * UI gadget key event
106 * @see ug_send_key_event()
109 UG_KEY_EVENT_NONE = 0x00, /**< No event */
110 UG_KEY_EVENT_END, /**< End key event */
114 #define UG_OPT_INDICATOR_MASK (0x03)
115 #define UG_OPT_INDICATOR(opt) (opt & UG_OPT_INDICATOR_MASK)
119 * - Indicator option: [1, 0] bits
124 UG_OPT_INDICATOR_ENABLE = 0x00,
125 /**< Indicator option:
126 Enable with both portrait and landscape window */
127 UG_OPT_INDICATOR_PORTRAIT_ONLY = 0x01,
128 /**< Indicator option: Enable with portrait window */
129 UG_OPT_INDICATOR_LANDSCAPE_ONLY = 0x02,
130 /**< Indicator option: Enable with landscape window */
131 UG_OPT_INDICATOR_DISABLE = 0x03,
132 /**< Indicator option:
133 Disable with both portrait and landscape view window */
138 * UI gadget callback type
142 /** layout callback */
143 void (*layout_cb) (struct ui_gadget *ug, enum ug_mode mode,
145 /** result callback */
146 void (*result_cb) (struct ui_gadget *ug, bundle *result, void *priv);
147 /** destroy callback */
148 void (*destroy_cb) (struct ui_gadget *ug, void *priv);
154 * Easy-to-use macro of ug_init() for EFL
157 #define UG_INIT_EFL(win, opt) \
158 ug_init((Display *)ecore_x_display_get(), elm_win_xwindow_get(win), \
162 * Easy-to-use macro of ug_init() for GTK
165 #define UG_INIT_GTK(win, opt) \
166 win ? ug_init(gdk_display_get_default(), win, \
167 GDK_WINDOW_XWINDOW(GTK_WIDGET(win)->window), win, opt) : -1
171 * This function initializes default window, display, xwindow id, and indicator state.
174 * First of all, to use UI gadgets in an application, default window to draw the UI gadgets has to be registered. Besides, to change indicator state for the full-view UI gadget, display and xwindow id have to be registered, and to restore application's indicator state, default indicator option has to be registered. This function is used for registering them.
176 * \par Typical use case:
177 * Application developers who want to use UI gadget MUST register display, xwindow id, default window, and option with the function at first.
179 * \par Method of function operation:
180 * Register display, xwindow id, default window, and option.
182 * \par Context of function:
185 * \note If you are unfamiliar with display and xwindow id, please use following macros: UG_INIT_EFL, UG_INIT_GTK. The macros kindly generate proper functions to get display and xwindow id.
187 * @param[in] disp Default display
188 * @param[in] xid Default xwindow id of default window
189 * @param[in] win Default window object, it is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
190 * @param[in] opt Default indicator state to restore application's indicator state
191 * @return 0 on success, -1 on error
195 * \see UG_INIT_EFL(), UG_INIT_GTK()
200 * #include <ui-gadget.h>
206 * ug_init((Display *)ecore_x_display_get(), elm_win_xwindow_get(win), win, UG_OPT_INDICATOR_ENABLE);
207 * // for convenience you can use following macro: ELM_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE);
211 int ug_init(Display *disp, Window xid, void *win, enum ug_option opt);
215 * This function creates a UI gadget
218 * This function is used for creating a UI gadget instance. In addition, following callbacks could be registered with the function: layout callback, result callback, and destroy callback. (see struct ug_cbs)
220 * \par Typical use case:
221 * Anyone who want to create UI gadget could use the function.
223 * \par Method of function operation:
224 * First, the UI gadget with given name is dynamically loaded(dlopen). Next, state operations of loaded UI gadget are invoked according to its lifecycle. There are three callbacks which could be registered with the function: layout callback, result callback, and destroy callback. If the state is changed to "Create", the layout callback is invoked for layout arrangement. If ug_send_result() is invoked in the loaded UI gadget , the result callback is invoked. And, if ug_destroy_me() is invoked in the loaded UI gadget , the destroy callback is invoked.
226 * \par Context of function:
227 * This function supposed to be called after successful initialization with ug_init()
229 * @param[in] parent parent's UI gadget. If the UI gadget uses the function, the parent has to be the UI gadget. Otherwise, if an application uses the function, the parent has to be NULL
230 * @param[in] name name of UI gadget
231 * @param[in] mode mode of UI gadget (UG_MODE_FULLVIEW | UG_MODE_FRAMEVIEW)
232 * @param[in] data argument for the UI gadget (see \ref bundle_PG "bundle programming guide")
233 * @param[in] cbs callback functions (layout callback, result callback, destroy callback, see struct ug_cbs) and private data.
234 * @return The pointer of UI gadget, NULL on error
238 * \see struct ug_cbs, enum ug_mode
239 * \remarks If you passed "data" bundle, you MUST release it using bundle_free() after ug_create()
243 * #include <ui-gadget.h>
246 * struct ui_gadget *ug;
247 * struct ug_cbs cbs = {0, };
249 * // set callbacks: layout callback, result callback, destroy callback
250 * cbs.layout_cb = _layout_cb;
251 * cbs.result_cb = _result_cb;
252 * cbs.destroy_cb = _destroy_cb;
253 * cbs.priv = user_data;
255 * // create arguments
256 * b = bundle_create();
257 * bundle_add(b, "Content", "Hello");
259 * // create "helloUG-efl" UI gadget instance
260 * ug = ug_create(NULL, "helloUG-efl", UG_MODE_FULLVIEW, b, &cbs);
262 * // release arguments
267 struct ui_gadget *ug_create(struct ui_gadget *parent, const char *name,
268 enum ug_mode mode, bundle *data,
273 * This function pauses all UI gadgets
276 * This function is used for pausing UI gadgets with "Running" state. Eventually, state of the UI gadgets would be "Stopped."
278 * \par Typical use case:
279 * Application developers who want to pause loaded UI gadgets could use the function.
281 * \par Method of function operation:
282 * "Pause" state operations of UI gadgets with "Running" state in the UI gadget tree are invoked by post-order traversal.
284 * \par Context of function:
285 * This function supposed to be called after successful initialization with ug_init()
287 * @return 0 on success, -1 on error
296 * #include <ui-gadget.h>
298 * // pause all UI gadget instances
307 * This function resumes all UI gadgets
310 * This function is used for resuming UI gadgets with "Stopped" state. Eventually, state of all UI gadgets would be "Running."
312 * \par Typical use case:
313 * Application developers who want to resume loaded UI gadgets could use the function.
315 * \par Method of function operation:
316 * "Resume" state operations of UI gadgets with "Stopped" state in the UI gadget tree are invoked by post-order traversal.
318 * \par Context of function:
319 * This function supposed to be called after successful initialization with ug_init()
321 * @return 0 on success, -1 on error
330 * #include <ui-gadget.h>
332 * // resume all UI gadget instances
341 * This function destroys the given UI gadget instance
344 * This function is used for destroying given UI gadget instance and its children. Eventually, state of the instance would be "Destroyed."
346 * \par Typical use case:
347 * Anyone who want to destroy specific UI gadget could use the function.
349 * \par Method of function operation:
350 * "Destroy" state operations of the given UI gadget instance and its children are invoked.
352 * \par Context of function:
353 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
355 * @param[in] ug The UI gadget
356 * @return 0 on success, -1 on error
358 * \pre ug_init(), ug_create()
360 * \see ug_destroy_all()
365 * #include <ui-gadget.h>
367 * // destroy UI gadget instance
372 int ug_destroy(struct ui_gadget *ug);
376 * This function destroys all UI gadgets of an application
379 * This function is used for destroying all UI gadgets. Eventually, state of all UI gadgets would be "Destroyed."
381 * \par Typical use case:
382 * Application developers who want to destroy loaded UI gadgets could use the function.
384 * \par Method of function operation:
385 * "Destroy" state operations of all UI gadgets in the UI gadget tree are invoked by post-order traversal.
387 * \par Context of function:
388 * This function supposed to be called after successful initialization with ug_init()
390 * @return 0 on success, -1 on error
399 * #include <ui-gadget.h>
401 * // destroy all UI gadget instances
406 int ug_destroy_all(void);
410 * This function gets base layout of the given UI gadget instance
413 * This function is used for getting base layout pointer of given UI gadget instance.
415 * \par Typical use case:
416 * Anyone who want to get base layout of UI gadget could use the function.
418 * \par Method of function operation:
419 * This function returns base layout pointer which is created in "Create" operation of the given UI gadget instance.
421 * \par Context of function:
422 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
424 * @param[in] ug The UI gadget
425 * @return The pointer of base layout, NULL on error. The result value is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
427 * \pre ug_init(), ug_create()
429 * \see ug_get_parent_layout()
434 * #include <ui-gadget.h>
437 * // get a base layout
438 * ly = (Evas_Object *)ug_get_layout(ug);
442 void *ug_get_layout(struct ui_gadget *ug);
446 * This function gets base layout of parent of the given UI gadget instance
449 * This function is used for getting base layout pointer of parent of the given UI gadget instance.
451 * \par Typical use case:
452 * Anyone who want to get base layout of UI gadget's parent could use the function.
454 * \par Method of function operation:
455 * This function returns base layout pointer which is created in "Create" operation of parent of the given UI gadget instance.
457 * \par Context of function:
458 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
460 * @param[in] ug The UI gadget
461 * @return The pointer of base layout, NULL on error. The result value is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
463 * \pre ug_init(), ug_create()
465 * \see ug_get_layout()
470 * #include <ui-gadget.h>
473 * // get a base layout of parent of the given UI gadget instance
474 * ly = (Evas_Object *)ug_get_parent_layout(ug);
478 void *ug_get_parent_layout(struct ui_gadget *ug);
482 * This function gets default window
485 * This function is used for getting default window which is registered with ug_init()
487 * \par Typical use case:
488 * Anyone who want to get default window could use the function.
490 * \par Method of function operation:
491 * This function returns default window pointer which is registered with ug_init()
493 * \par Context of function:
494 * This function supposed to be called after successful initialization with ug_init()
496 * @return The pointer of default window, NULL on error. The result value is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
505 * #include <ui-gadget.h>
508 * // get default window
509 * win = (Evas_Object *)ug_get_window(ug);
513 void *ug_get_window(void);
517 * This function gets mode of the given UI gadget instance
520 * This function is used for getting mode of the given UI gadget instance. Mode could be UG_MODE_FULLVIEW or UG_MODE_FRAMEVIEW.
522 * \par Typical use case:
523 * Anyone who want to get mode of UI gadget could use the function.
525 * \par Method of function operation:
526 * This function returns mode which is registered with ug_create()
528 * \par Context of function:
529 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
531 * @param[in] ug The UI gadget
532 * @return UI gadget mode of the given UI gadget instance (UG_MODE_FULLVIEW | UG_MODE_FRAMEVIEW)
534 * \pre ug_init(), ug_create()
541 * #include <ui-gadget.h>
544 * // get mode (UG_MODE_FULLVIEW | UG_MODE_FRAMEVIEW)
545 * mode = ug_get_mode(ug);
549 enum ug_mode ug_get_mode(struct ui_gadget *ug);
553 * This function propagates the given system event to all UI gadgets
556 * This function is used for propagating the given system event. Available system events are low memory, low battery, language changed, and window rotate event.
558 * \par Typical use case:
559 * Application developers who want to propagate system event to all UI gadgets could use the function.
561 * \par Method of function operation:
562 * Event operations of all UI gadgets in the UI gadget tree are invoked by post-order traversal.
564 * \par Context of function:
565 * This function supposed to be called after successful initialization with ug_init()
567 * @param[in] event UI gadget event. (see enum ug_event)
568 * @return 0 on success, -1 on error
577 * #include <ui-gadget.h>
579 * // propagate low battery event to all UI gadget instances
580 * ug_send_event(UG_EVENT_LOW_BATTERY);
584 int ug_send_event(enum ug_event event);
588 * This function send key event to full view top UI gadget
591 * This function is used for sending key event to full view top UI gadget. Available key events are end event.
593 * \par Typical use case:
594 * Application developers who want to send key event to full view top UI gadget could use the function.
596 * \par Method of function operation:
597 * Key event operation of full view top UI gadget in the UI gadget tree are invoked.
599 * \par Context of function:
600 * This function supposed to be called after successful initialization with ug_init()
602 * @param[in] event UI gadget key event. (see enum ug_key_event)
603 * @return 0 on success, -1 on error
607 * \see enum ug_key_event
612 * #include <ui-gadget.h>
614 * // send key event callback to full view top UI gadget instances
615 * ug_send_key_event(UG_KEY_EVENT_END);
619 int ug_send_key_event(enum ug_key_event event);
623 * This function sends message to the given UI gadget instance
626 * This function is used for sending message to created UI gadget. The message have to be composed with bundle library.
628 * \par Typical use case:
629 * Anyone who want to send message to created UI gadget.
631 * \par Method of function operation:
632 * Message operation of given UI gadget instance is invoked.
634 * \par Context of function:
635 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
637 * @param[in] ug The UI gadget
638 * @param[in] msg message to send, which is bundle type (see \ref bundle_PG "bundle programming guide")
639 * @return 0 on success, -1 on error
641 * \pre ug_init(), ug_create()
644 * \remarks After send your message, you have to release it using bundle_free()
648 * #include <ui-gadget.h>
650 * // make a message with bundle
652 * b = bundle_create();
653 * bundle_add(b, "Content", "Hello");
655 * // send the message
656 * ug_send_message(ug, b);
658 * // release the message
663 int ug_send_message(struct ui_gadget *ug, bundle *msg);
667 * This function disable transition effect of the given UI gadget instance
670 * This function is used for disabling transition effect of created UI gadget.
672 * \par Typical use case:
673 * Anyone who want to disable transition effect of created UI gadget.
675 * \par Method of function operation:
676 * No transition effect of given UI gadget is invoked
678 * \par Context of function:
679 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
681 * @param[in] ug The UI gadget
682 * @return 0 on success, -1 on error
684 * \pre ug_init(), ug_create()
687 * \remarks Before show layout of given UI gadget, ug_disable_effect() should be called.
691 * #include <ui-gadget.h>
693 * static void layout_cb(struct ui_gadget *ug, enum ug_mode mode, void *priv)
696 * base = ug_get_layout(ug);
698 * case UG_MODE_FULLVIEW:
700 * ug_disable_effect(ug);
701 * evas_object_show(base);
705 int ug_disable_effect(struct ui_gadget *ug);
713 #endif /* __UI_GADGET_H__ */