[focus] When an object has focus_chain manager, it should return its own next object...
[framework/uifw/elementary.git] / src / lib / elm_widget_panel.h
1 #ifndef ELM_WIDGET_PANEL_H
2 #define ELM_WIDGET_PANEL_H
3
4 #include "elm_widget_layout.h"
5 #include "els_box.h"
6
7 /**
8  * @addtogroup Widget
9  * @{
10  *
11  * @section elm-panel-class The Elementary Panel Class
12  *
13  * Elementary, besides having the @ref Panel widget, exposes its
14  * foundation -- the Elementary Panel Class -- in order to create other
15  * widgets which are a panel with some more logic on top.
16  */
17
18 /**
19  * @def ELM_PANEL_CLASS
20  *
21  * Use this macro to cast whichever subclass of
22  * #Elm_Panel_Smart_Class into it, so to access its fields.
23  *
24  * @ingroup Widget
25  */
26 #define ELM_PANEL_CLASS(x) ((Elm_Panel_Smart_Class *)x)
27
28 /**
29  * @def ELM_PANEL_DATA
30  *
31  * Use this macro to cast whichever subdata of
32  * #Elm_Panel_Smart_Data into it, so to access its fields.
33  *
34  * @ingroup Widget
35  */
36 #define ELM_PANEL_DATA(x)  ((Elm_Panel_Smart_Data *)x)
37
38 /**
39  * @def ELM_PANEL_SMART_CLASS_VERSION
40  *
41  * Current version for Elementary panel @b base smart class, a value
42  * which goes to _Elm_Panel_Smart_Class::version.
43  *
44  * @ingroup Widget
45  */
46 #define ELM_PANEL_SMART_CLASS_VERSION 1
47
48 /**
49  * @def ELM_PANEL_SMART_CLASS_INIT
50  *
51  * Initializer for a whole #Elm_Panel_Smart_Class structure, with
52  * @c NULL values on its specific fields.
53  *
54  * @param smart_class_init initializer to use for the "base" field
55  * (#Evas_Smart_Class).
56  *
57  * @see EVAS_SMART_CLASS_INIT_NULL
58  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
59  * @see ELM_PANEL_SMART_CLASS_INIT_NULL
60  * @see ELM_PANEL_SMART_CLASS_INIT_NAME_VERSION
61  *
62  * @ingroup Widget
63  */
64 #define ELM_PANEL_SMART_CLASS_INIT(smart_class_init) \
65   {smart_class_init, ELM_PANEL_SMART_CLASS_VERSION}
66
67 /**
68  * @def ELM_PANEL_SMART_CLASS_INIT_NULL
69  *
70  * Initializer to zero out a whole #Elm_Panel_Smart_Class structure.
71  *
72  * @see ELM_PANEL_SMART_CLASS_INIT_NAME_VERSION
73  * @see ELM_PANEL_SMART_CLASS_INIT
74  *
75  * @ingroup Widget
76  */
77 #define ELM_PANEL_SMART_CLASS_INIT_NULL \
78   ELM_PANEL_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
79
80 /**
81  * @def ELM_PANEL_SMART_CLASS_INIT_NAME_VERSION
82  *
83  * Initializer to zero out a whole #Elm_Panel_Smart_Class structure and
84  * set its name and version.
85  *
86  * This is similar to #ELM_PANEL_SMART_CLASS_INIT_NULL, but it will
87  * also set the version field of #Elm_Panel_Smart_Class (base field)
88  * to the latest #ELM_PANEL_SMART_CLASS_VERSION and name it to the
89  * specific value.
90  *
91  * It will keep a reference to the name field as a <c>"const char *"</c>,
92  * i.e., the name must be available while the structure is
93  * used (hint: static or global variable!) and must not be modified.
94  *
95  * @see ELM_PANEL_SMART_CLASS_INIT_NULL
96  * @see ELM_PANEL_SMART_CLASS_INIT
97  *
98  * @ingroup Widget
99  */
100 #define ELM_PANEL_SMART_CLASS_INIT_NAME_VERSION(name) \
101   ELM_PANEL_SMART_CLASS_INIT                          \
102     (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
103
104 /**
105  * Elementary panel base smart class. This inherits directly from
106  * #Elm_Layout_Smart_Class and is meant to build widgets extending the
107  * behavior of a panel.
108  *
109  * All of the functions listed on @ref Panel namespace will work for
110  * objects deriving from #Elm_Panel_Smart_Class.
111  */
112 typedef struct _Elm_Panel_Smart_Class
113 {
114    Elm_Layout_Smart_Class base;
115
116    int                    version;    /**< Version of this smart class definition */
117 } Elm_Panel_Smart_Class;
118
119 /**
120  * Base layout smart data extended with panel instance data.
121  */
122 typedef struct _Elm_Panel_Smart_Data Elm_Panel_Smart_Data;
123 struct _Elm_Panel_Smart_Data
124 {
125    Elm_Layout_Smart_Data                 base; /* base widget smart data as
126                                                 * first member obligatory, as
127                                                 * we're inheriting from it */
128
129    Evas_Object                          *bx, *content;
130
131    Elm_Panel_Orient                      orient;
132
133    Eina_Bool                             hidden : 1;
134    Eina_Bool                             on_deletion : 1;
135 };
136
137 /**
138  * @}
139  */
140
141 EAPI extern const char ELM_PANEL_SMART_NAME[];
142 EAPI const Elm_Panel_Smart_Class *elm_panel_smart_class_get(void);
143
144 #define ELM_PANEL_DATA_GET(o, sd) \
145   Elm_Panel_Smart_Data * sd = evas_object_smart_data_get(o)
146
147 #define ELM_PANEL_DATA_GET_OR_RETURN(o, ptr)         \
148   ELM_PANEL_DATA_GET(o, ptr);                        \
149   if (!ptr)                                          \
150     {                                                \
151        CRITICAL("No widget data for object %p (%s)", \
152                 o, evas_object_type_get(o));         \
153        return;                                       \
154     }
155
156 #define ELM_PANEL_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
157   ELM_PANEL_DATA_GET(o, ptr);                         \
158   if (!ptr)                                           \
159     {                                                 \
160        CRITICAL("No widget data for object %p (%s)",  \
161                 o, evas_object_type_get(o));          \
162        return val;                                    \
163     }
164
165 #define ELM_PANEL_CHECK(obj)                                      \
166   if (!obj || !elm_widget_type_check((obj), ELM_PANEL_SMART_NAME, \
167                                      __func__))                   \
168     return
169
170 #endif