elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_widget_index.h
1 #ifndef ELM_WIDGET_INDEX_H
2 #define ELM_WIDGET_INDEX_H
3
4 #include "elm_widget_layout.h"
5
6 /**
7  * @addtogroup Widget
8  * @{
9  *
10  * @section elm-index-class The Elementary Index Class
11  *
12  * Elementary, besides having the @ref Index widget, exposes its
13  * foundation -- the Elementary Index Class -- in order to create other
14  * widgets which are a index with some more logic on top.
15  */
16
17 /**
18  * @def ELM_INDEX_CLASS
19  *
20  * Use this macro to cast whichever subclass of
21  * #Elm_Index_Smart_Class into it, so to access its fields.
22  *
23  * @ingroup Widget
24  */
25 #define ELM_INDEX_CLASS(x) ((Elm_Index_Smart_Class *)x)
26
27 /**
28  * @def ELM_INDEX_DATA
29  *
30  * Use this macro to cast whichever subdata of
31  * #Elm_Index_Smart_Data into it, so to access its fields.
32  *
33  * @ingroup Widget
34  */
35 #define ELM_INDEX_DATA(x)  ((Elm_Index_Smart_Data *)x)
36
37 /**
38  * @def ELM_INDEX_SMART_CLASS_VERSION
39  *
40  * Current version for Elementary index @b base smart class, a value
41  * which goes to _Elm_Index_Smart_Class::version.
42  *
43  * @ingroup Widget
44  */
45 #define ELM_INDEX_SMART_CLASS_VERSION 1
46
47 /**
48  * @def ELM_INDEX_SMART_CLASS_INIT
49  *
50  * Initializer for a whole #Elm_Index_Smart_Class structure, with
51  * @c NULL values on its specific fields.
52  *
53  * @param smart_class_init initializer to use for the "base" field
54  * (#Evas_Smart_Class).
55  *
56  * @see EVAS_SMART_CLASS_INIT_NULL
57  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
58  * @see ELM_INDEX_SMART_CLASS_INIT_NULL
59  * @see ELM_INDEX_SMART_CLASS_INIT_NAME_VERSION
60  *
61  * @ingroup Widget
62  */
63 #define ELM_INDEX_SMART_CLASS_INIT(smart_class_init) \
64   {smart_class_init, ELM_INDEX_SMART_CLASS_VERSION}
65
66 /**
67  * @def ELM_INDEX_SMART_CLASS_INIT_NULL
68  *
69  * Initializer to zero out a whole #Elm_Index_Smart_Class structure.
70  *
71  * @see ELM_INDEX_SMART_CLASS_INIT_NAME_VERSION
72  * @see ELM_INDEX_SMART_CLASS_INIT
73  *
74  * @ingroup Widget
75  */
76 #define ELM_INDEX_SMART_CLASS_INIT_NULL \
77   ELM_INDEX_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
78
79 /**
80  * @def ELM_INDEX_SMART_CLASS_INIT_NAME_VERSION
81  *
82  * Initializer to zero out a whole #Elm_Index_Smart_Class structure and
83  * set its name and version.
84  *
85  * This is similar to #ELM_INDEX_SMART_CLASS_INIT_NULL, but it will
86  * also set the version field of #Elm_Index_Smart_Class (base field)
87  * to the latest #ELM_INDEX_SMART_CLASS_VERSION and name it to the
88  * specific value.
89  *
90  * It will keep a reference to the name field as a <c>"const char *"</c>,
91  * i.e., the name must be available while the structure is
92  * used (hint: static or global variable!) and must not be modified.
93  *
94  * @see ELM_INDEX_SMART_CLASS_INIT_NULL
95  * @see ELM_INDEX_SMART_CLASS_INIT
96  *
97  * @ingroup Widget
98  */
99 #define ELM_INDEX_SMART_CLASS_INIT_NAME_VERSION(name) \
100   ELM_INDEX_SMART_CLASS_INIT                          \
101     (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
102
103 /**
104  * Elementary index base smart class. This inherits directly from
105  * #Elm_Layout_Smart_Class and is meant to build widgets extending the
106  * behavior of a index.
107  *
108  * All of the functions listed on @ref Index namespace will work for
109  * objects deriving from #Elm_Index_Smart_Class.
110  */
111 typedef struct _Elm_Index_Smart_Class
112 {
113    Elm_Layout_Smart_Class base;
114
115    int                    version;    /**< Version of this smart class definition */
116 } Elm_Index_Smart_Class;
117
118 /**
119  * Base layout smart data extended with index instance data.
120  */
121 typedef struct _Elm_Index_Smart_Data Elm_Index_Smart_Data;
122 struct _Elm_Index_Smart_Data
123 {
124    Elm_Layout_Smart_Data base;
125
126    Evas_Object          *event[2];
127    Evas_Object          *bx[2]; // 2 - for now all that's supported
128    Eina_List            *items;  /* 1 list. N levels, but only 2
129                                   * for now and # of items will be
130                                   * small */
131    Eina_List            *omit;
132
133    int                   level;
134    Evas_Coord            dx, dy;
135    Ecore_Timer          *delay;
136    double                delay_change_time;
137    Eina_Bool             level_active[2];
138
139    Eina_Bool             down : 1;
140    Eina_Bool             horizontal : 1;
141    Eina_Bool             autohide_disabled : 1;
142    Eina_Bool             indicator_disabled : 1;
143    Eina_Bool             omit_enabled : 1;
144    Eina_Bool             index_focus : 1;
145 };
146
147 typedef struct _Elm_Index_Item       Elm_Index_Item;
148 struct _Elm_Index_Item
149 {
150    ELM_WIDGET_ITEM;
151
152    const char   *letter;
153    int           level;
154    Evas_Smart_Cb func;
155
156    Eina_List    *omitted;
157    Elm_Index_Item       *head;
158
159    Eina_Bool     selected : 1;
160 };
161
162 typedef struct _Elm_Index_Omit Elm_Index_Omit;
163 struct _Elm_Index_Omit
164 {
165    int offset;
166    int count;
167 };
168
169 /**
170  * @}
171  */
172
173 EAPI extern const char ELM_INDEX_SMART_NAME[];
174 EAPI const Elm_Index_Smart_Class *elm_index_smart_class_get(void);
175
176 #define ELM_INDEX_DATA_GET(o, sd) \
177   Elm_Index_Smart_Data * sd = evas_object_smart_data_get(o)
178
179 #define ELM_INDEX_DATA_GET_OR_RETURN(o, ptr)         \
180   ELM_INDEX_DATA_GET(o, ptr);                        \
181   if (!ptr)                                          \
182     {                                                \
183        CRITICAL("No widget data for object %p (%s)", \
184                 o, evas_object_type_get(o));         \
185        return;                                       \
186     }
187
188 #define ELM_INDEX_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
189   ELM_INDEX_DATA_GET(o, ptr);                         \
190   if (!ptr)                                           \
191     {                                                 \
192        CRITICAL("No widget data for object %p (%s)",  \
193                 o, evas_object_type_get(o));          \
194        return val;                                    \
195     }
196
197 #define ELM_INDEX_CHECK(obj)                                                 \
198   if (!obj || !elm_widget_type_check((obj), ELM_INDEX_SMART_NAME, __func__)) \
199     return
200
201 #define ELM_INDEX_ITEM_CHECK(it)                            \
202   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
203   ELM_INDEX_CHECK(it->base.widget);
204
205 #define ELM_INDEX_ITEM_CHECK_OR_RETURN(it, ...)                        \
206   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
207   ELM_INDEX_CHECK(it->base.widget) __VA_ARGS__;
208
209 #endif