4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Jinwoo Nam <jwoo.nam@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __UI_GADGET_H__
23 #define __UI_GADGET_H__
28 * @brief This file contains the public API of the UI gadget library
32 * @addtogroup APPLICATION_FRAMEWORK
35 * @defgroup UI_Gadget UI gadget library
37 * @brief A library to develop/use a UI gadget
41 * @addtogroup UI_Gadget
44 * @defgroup UI_Gadget_For_User User API Reference Guide
45 * @brief A module to use a UI gadget. Caller uses this module and APIs.
47 * @section Header To Use Them:
49 * #include <ui-gadget.h>
54 * @addtogroup UI_Gadget_For_User
59 #include <Ecore_Wayland.h>
67 * struct ui_gadget is an opaque type representing a UI gadget
68 * @see ug_create(), ug_destroy()
69 * @see ug_get_layout(), ug_get_parent_layout(), ug_get_mode()
71 typedef struct ui_gadget_s *ui_gadget_h;
79 UG_MODE_FULLVIEW, /**< Fullview mode */
80 UG_MODE_FRAMEVIEW, /**< Frameview mode */
81 UG_MODE_INVALID, /**< Invalid mode */
87 * @see ug_send_event()
90 UG_EVENT_NONE = 0x00, /**< No event */
91 UG_EVENT_LOW_MEMORY, /**< Low memory event */
92 UG_EVENT_LOW_BATTERY, /**< Low battery event */
93 UG_EVENT_LANG_CHANGE, /**< Language change event */
94 UG_EVENT_ROTATE_PORTRAIT, /**< Rotate event: Portrait */
95 UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN, /**< Rotate event: Portrait upsidedown */
96 UG_EVENT_ROTATE_LANDSCAPE, /**< Rotate event: Landscape */
97 UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN,
98 /**< Rotate event: Landscape upsidedown */
99 UG_EVENT_REGION_CHANGE, /**< Region change event */
104 * UI gadget key event
105 * @see ug_send_key_event()
108 UG_KEY_EVENT_NONE = 0x00, /**< No event */
109 UG_KEY_EVENT_END, /**< End key event */
113 #define UG_OPT_INDICATOR_MASK (0x03)
114 #define UG_OPT_INDICATOR(opt) (opt & UG_OPT_INDICATOR_MASK)
118 * - Indicator option: [1, 0] bits
123 UG_OPT_INDICATOR_ENABLE = 0x00,
124 /**< Indicator option:
125 Enable with both portrait and landscape window */
126 UG_OPT_INDICATOR_PORTRAIT_ONLY = 0x01,
127 /**< Indicator option: Enable with portrait window */
128 UG_OPT_INDICATOR_LANDSCAPE_ONLY = 0x02,
129 /**< Indicator option: Enable with landscape window */
130 UG_OPT_INDICATOR_DISABLE = 0x03,
131 /**< Indicator option:
132 Disable with both portrait and landscape view window */
137 * UI gadget callback type
141 /** layout callback */
142 void (*layout_cb) (ui_gadget_h ug, enum ug_mode mode,
144 /** result callback */
145 void (*result_cb) (ui_gadget_h ug, service_h result, void *priv);
146 /** destroy callback */
147 void (*destroy_cb) (ui_gadget_h ug, void *priv);
153 * Easy-to-use macro of ug_init() for EFL
156 #define UG_INIT_EFL(win, opt) \
157 ug_init((Display *)ecore_wl_display_get(), (elm_win_wl_window_get(win))->id, \
161 * Easy-to-use macro of ug_init() for GTK
164 #define UG_INIT_GTK(win, opt) \
165 win ? ug_init(gdk_display_get_default(), win, \
166 GDK_WINDOW_XWINDOW(GTK_WIDGET(win)->window), win, opt) : -1
170 * This function initializes default window, display, xwindow id, and indicator state.
173 * 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.
175 * \par Typical use case:
176 * Application developers who want to use UI gadget MUST register display, xwindow id, default window, and option with the function at first.
178 * \par Method of function operation:
179 * Register display, xwindow id, default window, and option.
181 * \par Context of function:
184 * \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.
186 * @param[in] disp Default display
187 * @param[in] xid Default xwindow id of default window
188 * @param[in] win Default window object, it is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
189 * @param[in] opt Default indicator state to restore application's indicator state
190 * @return 0 on success, -1 on error
194 * \see UG_INIT_EFL(), UG_INIT_GTK()
199 * #include <ui-gadget.h>
205 * ug_init((Display *)ecore_x_display_get(), elm_win_xwindow_get(win), win, UG_OPT_INDICATOR_ENABLE);
206 * // for convenience you can use following macro: ELM_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE);
210 int ug_init(Display *disp, Window xid, void *win, enum ug_option opt);
214 * This function creates a UI gadget
217 * 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)
219 * \par Typical use case:
220 * Anyone who want to create UI gadget could use the function.
222 * \par Method of function operation:
223 * 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.
225 * \par Context of function:
226 * This function supposed to be called after successful initialization with ug_init()
228 * @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
229 * @param[in] name name of UI gadget
230 * @param[in] mode mode of UI gadget (UG_MODE_FULLVIEW | UG_MODE_FRAMEVIEW)
231 * @param[in] service argument for the UI gadget (see \ref service_PG "Tizen managed api reference guide")
232 * @param[in] cbs callback functions (layout callback, result callback, destroy callback, see struct ug_cbs) and private data.
233 * @return The pointer of UI gadget, NULL on error
237 * \see struct ug_cbs, enum ug_mode
238 * \remarks If you passed "service", you MUST release it using service_destroy() after ug_create()
242 * #include <ui-gadget.h>
246 * struct ug_cbs cbs = {0, };
248 * // set callbacks: layout callback, result callback, destroy callback
249 * cbs.layout_cb = _layout_cb;
250 * cbs.result_cb = _result_cb;
251 * cbs.destroy_cb = _destroy_cb;
252 * cbs.priv = user_data;
254 * // create arguments
255 * service_create(&service);
256 * service_add_extra_data(service, "Content", "Hello");
258 * // create "helloUG-efl" UI gadget instance
259 * ug = ug_create(NULL, "helloUG-efl", UG_MODE_FULLVIEW, service, &cbs);
261 * // release arguments
262 * service_destroy(b);
266 ui_gadget_h ug_create(ui_gadget_h parent, const char *name,
267 enum ug_mode mode, service_h service,
272 * This function pauses all UI gadgets
275 * This function is used for pausing UI gadgets with "Running" state. Eventually, state of the UI gadgets would be "Stopped."
277 * \par Typical use case:
278 * Application developers who want to pause loaded UI gadgets could use the function.
280 * \par Method of function operation:
281 * "Pause" state operations of UI gadgets with "Running" state in the UI gadget tree are invoked by post-order traversal.
283 * \par Context of function:
284 * This function supposed to be called after successful initialization with ug_init()
286 * @return 0 on success, -1 on error
295 * #include <ui-gadget.h>
297 * // pause all UI gadget instances
306 * This function resumes all UI gadgets
309 * This function is used for resuming UI gadgets with "Stopped" state. Eventually, state of all UI gadgets would be "Running."
311 * \par Typical use case:
312 * Application developers who want to resume loaded UI gadgets could use the function.
314 * \par Method of function operation:
315 * "Resume" state operations of UI gadgets with "Stopped" state in the UI gadget tree are invoked by post-order traversal.
317 * \par Context of function:
318 * This function supposed to be called after successful initialization with ug_init()
320 * @return 0 on success, -1 on error
329 * #include <ui-gadget.h>
331 * // resume all UI gadget instances
340 * This function destroys the given UI gadget instance
343 * This function is used for destroying given UI gadget instance and its children. Eventually, state of the instance would be "Destroyed."
345 * \par Typical use case:
346 * Anyone who want to destroy specific UI gadget could use the function.
348 * \par Method of function operation:
349 * "Destroy" state operations of the given UI gadget instance and its children are invoked.
351 * \par Context of function:
352 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
354 * @param[in] ug The UI gadget
355 * @return 0 on success, -1 on error
357 * \pre ug_init(), ug_create()
359 * \see ug_destroy_all()
364 * #include <ui-gadget.h>
366 * // destroy UI gadget instance
371 int ug_destroy(ui_gadget_h ug);
375 * This function destroys all UI gadgets of an application
378 * This function is used for destroying all UI gadgets. Eventually, state of all UI gadgets would be "Destroyed."
380 * \par Typical use case:
381 * Application developers who want to destroy loaded UI gadgets could use the function.
383 * \par Method of function operation:
384 * "Destroy" state operations of all UI gadgets in the UI gadget tree are invoked by post-order traversal.
386 * \par Context of function:
387 * This function supposed to be called after successful initialization with ug_init()
389 * @return 0 on success, -1 on error
398 * #include <ui-gadget.h>
400 * // destroy all UI gadget instances
405 int ug_destroy_all(void);
409 * This function gets base layout of the given UI gadget instance
412 * This function is used for getting base layout pointer of given UI gadget instance.
414 * \par Typical use case:
415 * Anyone who want to get base layout of UI gadget could use the function.
417 * \par Method of function operation:
418 * This function returns base layout pointer which is created in "Create" operation of the given UI gadget instance.
420 * \par Context of function:
421 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
423 * @param[in] ug The UI gadget
424 * @return The pointer of base layout, NULL on error. The result value is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
426 * \pre ug_init(), ug_create()
428 * \see ug_get_parent_layout()
433 * #include <ui-gadget.h>
436 * // get a base layout
437 * ly = (Evas_Object *)ug_get_layout(ug);
441 void *ug_get_layout(ui_gadget_h ug);
445 * This function gets base layout of parent of the given UI gadget instance
448 * This function is used for getting base layout pointer of parent of the given UI gadget instance.
450 * \par Typical use case:
451 * Anyone who want to get base layout of UI gadget's parent could use the function.
453 * \par Method of function operation:
454 * This function returns base layout pointer which is created in "Create" operation of parent of the given UI gadget instance.
456 * \par Context of function:
457 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
459 * @param[in] ug The UI gadget
460 * @return The pointer of base layout, NULL on error. The result value is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
462 * \pre ug_init(), ug_create()
464 * \see ug_get_layout()
469 * #include <ui-gadget.h>
472 * // get a base layout of parent of the given UI gadget instance
473 * ly = (Evas_Object *)ug_get_parent_layout(ug);
477 void *ug_get_parent_layout(ui_gadget_h ug);
481 * This function gets default window
484 * This function is used for getting default window which is registered with ug_init()
486 * \par Typical use case:
487 * Anyone who want to get default window could use the function.
489 * \par Method of function operation:
490 * This function returns default window pointer which is registered with ug_init()
492 * \par Context of function:
493 * This function supposed to be called after successful initialization with ug_init()
495 * @return The pointer of default window, NULL on error. The result value is void pointer for supporting both GTK (GtkWidget *) and EFL (Evas_Object *)
504 * #include <ui-gadget.h>
507 * // get default window
508 * win = (Evas_Object *)ug_get_window(ug);
512 void *ug_get_window(void);
516 * This function gets mode of the given UI gadget instance
519 * This function is used for getting mode of the given UI gadget instance. Mode could be UG_MODE_FULLVIEW or UG_MODE_FRAMEVIEW.
521 * \par Typical use case:
522 * Anyone who want to get mode of UI gadget could use the function.
524 * \par Method of function operation:
525 * This function returns mode which is registered with ug_create()
527 * \par Context of function:
528 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
530 * @param[in] ug The UI gadget
531 * @return UI gadget mode of the given UI gadget instance (UG_MODE_FULLVIEW | UG_MODE_FRAMEVIEW)
533 * \pre ug_init(), ug_create()
540 * #include <ui-gadget.h>
543 * // get mode (UG_MODE_FULLVIEW | UG_MODE_FRAMEVIEW)
544 * mode = ug_get_mode(ug);
548 enum ug_mode ug_get_mode(ui_gadget_h ug);
552 * This function propagates the given system event to all UI gadgets
555 * This function is used for propagating the given system event. Available system events are low memory, low battery, language changed, and window rotate event.
557 * \par Typical use case:
558 * Application developers who want to propagate system event to all UI gadgets could use the function.
560 * \par Method of function operation:
561 * Event operations of all UI gadgets in the UI gadget tree are invoked by post-order traversal.
563 * \par Context of function:
564 * This function supposed to be called after successful initialization with ug_init()
566 * @param[in] event UI gadget event. (see enum ug_event)
567 * @return 0 on success, -1 on error
576 * #include <ui-gadget.h>
578 * // propagate low battery event to all UI gadget instances
579 * ug_send_event(UG_EVENT_LOW_BATTERY);
583 int ug_send_event(enum ug_event event);
587 * This function send key event to full view top UI gadget
590 * This function is used for sending key event to full view top UI gadget. Available key events are end event.
592 * \par Typical use case:
593 * Application developers who want to send key event to full view top UI gadget could use the function.
595 * \par Method of function operation:
596 * Key event operation of full view top UI gadget in the UI gadget tree are invoked.
598 * \par Context of function:
599 * This function supposed to be called after successful initialization with ug_init()
601 * @param[in] event UI gadget key event. (see enum ug_key_event)
602 * @return 0 on success, -1 on error
606 * \see enum ug_key_event
611 * #include <ui-gadget.h>
613 * // send key event callback to full view top UI gadget instances
614 * ug_send_key_event(UG_KEY_EVENT_END);
618 int ug_send_key_event(enum ug_key_event event);
622 * This function sends message to the given UI gadget instance
625 * This function is used for sending message to created UI gadget. The message have to be composed with service handle.
627 * \par Typical use case:
628 * Anyone who want to send message to created UI gadget.
630 * \par Method of function operation:
631 * Message operation of given UI gadget instance is invoked.
633 * \par Context of function:
634 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
636 * @param[in] ug The UI gadget
637 * @param[in] msg message to send, which is service type (see \ref service_PG "Tizen managed api reference guide")
638 * @return 0 on success, -1 on error
640 * \pre ug_init(), ug_create()
643 * \remarks After send your message, you have to release it using service_destroy()
647 * #include <ui-gadget.h>
649 * // make a message with service
651 * service_create(&msg)
652 * service_add_extra_data(msg, "Content", "Hello");
654 * // send the message
655 * ug_send_message(ug, msg);
657 * // release the message
658 * service_destroy(msg);
662 int ug_send_message(ui_gadget_h ug, service_h msg);
666 * This function disable transition effect of the given UI gadget instance
669 * This function is used for disabling transition effect of created UI gadget.
671 * \par Typical use case:
672 * Anyone who want to disable transition effect of created UI gadget.
674 * \par Method of function operation:
675 * No transition effect of given UI gadget is invoked
677 * \par Context of function:
678 * This function supposed to be called after successful initialization with ug_init() and creation UI gadget with ug_create()
680 * @param[in] ug The UI gadget
681 * @return 0 on success, -1 on error
683 * \pre ug_init(), ug_create()
686 * \remarks Before show layout of given UI gadget, ug_disable_effect() should be called.
690 * #include <ui-gadget.h>
692 * static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
695 * base = ug_get_layout(ug);
697 * case UG_MODE_FULLVIEW:
699 * ug_disable_effect(ug);
700 * evas_object_show(base);
704 int ug_disable_effect(ui_gadget_h ug);
712 #endif /* __UI_GADGET_H__ */