elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_widget_entry.h
1 #ifndef ELM_WIDGET_ENTRY_H
2 #define ELM_WIDGET_ENTRY_H
3
4 #include "elm_interface_scrollable.h"
5 #include "elm_widget_layout.h"
6
7 /**
8  * @addtogroup Widget
9  * @{
10  *
11  * @section elm-entry-class The Elementary Entry Class
12  *
13  * Elementary, besides having the @ref Entry widget, exposes its
14  * foundation -- the Elementary Entry Class -- in order to create
15  * other widgets which are a entry with some more logic on top.
16  */
17
18 /**
19  * @def ELM_ENTRY_CLASS
20  *
21  * Use this macro to cast whichever subclass of
22  * #Elm_Entry_Smart_Class into it, so to access its fields.
23  *
24  * @ingroup Widget
25  */
26 #define ELM_ENTRY_CLASS(x) ((Elm_Entry_Smart_Class *)x)
27
28 /**
29  * @def ELM_ENTRY_DATA
30  *
31  * Use this macro to cast whichever subdata of
32  * #Elm_Entry_Smart_Data into it, so to access its fields.
33  *
34  * @ingroup Widget
35  */
36 #define ELM_ENTRY_DATA(x)  ((Elm_Entry_Smart_Data *)x)
37
38 /**
39  * @def ELM_ENTRY_SMART_CLASS_VERSION
40  *
41  * Current version for Elementary entry @b base smart class, a value
42  * which goes to _Elm_Entry_Smart_Class::version.
43  *
44  * @ingroup Widget
45  */
46 #define ELM_ENTRY_SMART_CLASS_VERSION 1
47
48 /**
49  * @def ELM_ENTRY_SMART_CLASS_INIT
50  *
51  * Initializer for a whole #Elm_Entry_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_ENTRY_SMART_CLASS_INIT_NULL
60  * @see ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION
61  *
62  * @ingroup Widget
63  */
64 #define ELM_ENTRY_SMART_CLASS_INIT(smart_class_init) \
65   {smart_class_init, ELM_ENTRY_SMART_CLASS_VERSION}
66
67 /**
68  * @def ELM_ENTRY_SMART_CLASS_INIT_NULL
69  *
70  * Initializer to zero out a whole #Elm_Entry_Smart_Class structure.
71  *
72  * @see ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION
73  * @see ELM_ENTRY_SMART_CLASS_INIT
74  *
75  * @ingroup Widget
76  */
77 #define ELM_ENTRY_SMART_CLASS_INIT_NULL \
78   ELM_ENTRY_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
79
80 /**
81  * @def ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION
82  *
83  * Initializer to zero out a whole #Elm_Entry_Smart_Class structure and
84  * set its name and version.
85  *
86  * This is similar to #ELM_ENTRY_SMART_CLASS_INIT_NULL, but it will
87  * also set the version field of #Elm_Entry_Smart_Class (base field)
88  * to the latest #ELM_ENTRY_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_ENTRY_SMART_CLASS_INIT_NULL
96  * @see ELM_ENTRY_SMART_CLASS_INIT
97  *
98  * @ingroup Widget
99  */
100 #define ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION(name) \
101   ELM_ENTRY_SMART_CLASS_INIT                          \
102     (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
103
104 /**
105  * Elementary entry base smart class. This inherits directly from
106  * #Elm_Layout_Smart_Class and is meant to build widgets extending the
107  * behavior of a entry.
108  *
109  * All of the functions listed on @ref Entry namespace will work for
110  * objects deriving from #Elm_Entry_Smart_Class.
111  */
112 typedef struct _Elm_Entry_Smart_Class
113 {
114    Elm_Layout_Smart_Class base;
115
116    int                    version;    /**< Version of this smart class definition */
117 } Elm_Entry_Smart_Class;
118
119 typedef struct _Mod_Api                     Mod_Api;
120
121 /**
122  * Base widget smart data extended with entry instance data.
123  */
124 typedef struct _Elm_Entry_Smart_Data        Elm_Entry_Smart_Data;
125 struct _Elm_Entry_Smart_Data
126 {
127    Elm_Layout_Smart_Data                 base; /* base widget smart data as
128                                                 * first member obligatory, as
129                                                 * we're inheriting from it */
130
131    Evas_Object                          *hit_rect, *entry_edje, *scr_edje;
132    const Elm_Scrollable_Smart_Interface *s_iface;
133
134    Evas_Object                          *hoversel;
135    Ecore_Job                            *deferred_recalc_job;
136    Ecore_Event_Handler                  *sel_notify_handler;
137    Ecore_Event_Handler                  *sel_clear_handler;
138    Ecore_Event_Handler                  *client_msg_handler;  // TIZEN ONLY
139    Ecore_Timer                          *longpress_timer;
140    Ecore_Timer                          *delay_write;
141    Ecore_Timer                          *click_timer; // TIZEN ONLY
142    /* for deferred appending */
143    Ecore_Idler                          *append_text_idler;
144    char                                 *append_text_left;
145    int                                   append_text_position;
146    int                                   append_text_len;
147    /* Only for clipboard */
148    const char                           *cut_sel;
149    const char                           *text;
150    const char                           *file;
151    Elm_Text_Format                       format;
152    Evas_Coord                            last_w, ent_mw, ent_mh;
153    Evas_Coord                            downx, downy;
154    Eina_List                            *items;
155    Eina_List                            *item_providers;
156    Eina_List                            *text_filters;
157    Eina_List                            *markup_filters;
158    Ecore_Job                            *hov_deljob;
159    Mod_Api                              *api; // module api if supplied
160    int                                   cursor_pos;
161    Elm_Scroller_Policy                   policy_h, policy_v;
162    Elm_Wrap_Type                         line_wrap;
163    Elm_Input_Panel_Layout                input_panel_layout;
164    Elm_Autocapital_Type                  autocapital_type;
165    Elm_Input_Panel_Lang                  input_panel_lang;
166    Elm_Input_Panel_Return_Key_Type       input_panel_return_key_type;
167    void                                 *input_panel_imdata;
168    int                                   input_panel_imdata_len;
169    int                                   input_panel_layout_variation;
170    struct
171    {
172       Evas_Object *hover_parent;
173       Evas_Object *pop, *hover;
174       const char  *hover_style;
175    } anchor_hover;
176
177    Elm_Cnp_Mode                          cnp_mode;
178    //// TIZEN ONLY
179    Evas_Object *mgf_proxy;
180    Evas_Object *mgf_clip;
181    Evas_Object *mgf_bg;
182    Evas_Coord mgf_height;
183    float mgf_scale;
184    int mgf_arrow_height;
185    int mgf_type;
186    Ecore_Job *region_get_job;
187    Ecore_Job *region_recalc_job;
188    const char *password_text;
189    Evas_Coord cx, cy, cw, ch;
190
191    Eina_Bool double_clicked : 1;
192    Eina_Bool long_pressed : 1;
193    Eina_Bool magnifier_enabled : 1;
194    Eina_Bool magnifier_showing : 1;
195    Eina_Bool mouse_upped : 1;
196    Eina_Bool sel_allow : 1;
197    Eina_Bool cursor_handler_disabled : 1;
198    Eina_Bool scroll_holding : 1;
199    //
200    Eina_Bool                             input_panel_return_key_disabled : 1;
201    Eina_Bool                             drag_selection_asked : 1;
202    Eina_Bool                             input_panel_enable : 1;
203    Eina_Bool                             prediction_allow : 1;
204    Eina_Bool                             selection_asked : 1;
205    Eina_Bool                             auto_return_key : 1;
206    Eina_Bool                             have_selection : 1;
207    Eina_Bool                             deferred_cur : 1;
208    Eina_Bool                             context_menu : 1;
209    Eina_Bool                             cur_changed : 1;
210    Eina_Bool                             single_line : 1;
211    Eina_Bool                             can_write : 1;
212    Eina_Bool                             auto_save : 1;
213    Eina_Bool                             password : 1;
214    Eina_Bool                             editable : 1;
215    Eina_Bool                             disabled : 1;
216    Eina_Bool                             h_bounce : 1;
217    Eina_Bool                             v_bounce : 1;
218    Eina_Bool                             has_text : 1;
219    Eina_Bool                             use_down : 1;
220    Eina_Bool                             sel_mode : 1;
221    Eina_Bool                             changed : 1;
222    Eina_Bool                             scroll : 1;
223 };
224
225 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
226 typedef struct _Elm_Entry_Item_Provider     Elm_Entry_Item_Provider;
227 typedef struct _Elm_Entry_Markup_Filter     Elm_Entry_Markup_Filter;
228
229 struct _Elm_Entry_Context_Menu_Item
230 {
231    Evas_Object  *obj;
232    const char   *label;
233    const char   *icon_file;
234    const char   *icon_group;
235    Elm_Icon_Type icon_type;
236    Evas_Smart_Cb func;
237    void         *data;
238 };
239
240 struct _Elm_Entry_Item_Provider
241 {
242    Evas_Object *(*func)(void *data, Evas_Object * entry, const char *item);
243    void        *data;
244 };
245
246 struct _Elm_Entry_Markup_Filter
247 {
248    Elm_Entry_Filter_Cb func;
249    void               *data;
250 };
251
252 typedef enum _Length_Unit
253 {
254    LENGTH_UNIT_CHAR,
255    LENGTH_UNIT_BYTE,
256    LENGTH_UNIT_LAST
257 } Length_Unit;
258
259 /**
260  * @}
261  */
262
263 EAPI extern const char ELM_ENTRY_SMART_NAME[];
264 EAPI const Elm_Entry_Smart_Class *elm_entry_smart_class_get(void);
265
266 #define ELM_ENTRY_DATA_GET(o, sd) \
267   Elm_Entry_Smart_Data * sd = evas_object_smart_data_get(o)
268
269 #define ELM_ENTRY_DATA_GET_OR_RETURN(o, ptr)         \
270   ELM_ENTRY_DATA_GET(o, ptr);                        \
271   if (!ptr)                                          \
272     {                                                \
273        CRITICAL("No widget data for object %p (%s)", \
274                 o, evas_object_type_get(o));         \
275        return;                                       \
276     }
277
278 #define ELM_ENTRY_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
279   ELM_ENTRY_DATA_GET(o, ptr);                         \
280   if (!ptr)                                           \
281     {                                                 \
282        CRITICAL("No widget data for object %p (%s)",  \
283                 o, evas_object_type_get(o));          \
284        return val;                                    \
285     }
286
287 #define ELM_ENTRY_CHECK(obj)                     \
288   if (!obj || !elm_widget_type_check             \
289         ((obj), ELM_ENTRY_SMART_NAME, __func__)) \
290     return
291
292 #endif
293
294 //TIZEN ONLY
295 typedef enum _Elm_Entry_Magnifier_Type
296 {
297    _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
298    _ENTRY_MAGNIFIER_FILLWIDTH,
299    _ENTRY_MAGNIFIER_CIRCULAR,
300 } Elm_Entry_Magnifier_Type;
301 //