tizen 2.3 release
[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    // TIZEN ONLY(131106): Add rectangle for processing mouse up event on paddings inside of entry.
133    Evas_Object                          *event_rect;
134    //
135    const Elm_Scrollable_Smart_Interface *s_iface;
136
137    Evas_Object                          *hoversel;
138    Ecore_Job                            *deferred_recalc_job;
139    Ecore_Event_Handler                  *sel_notify_handler;
140    Ecore_Event_Handler                  *sel_clear_handler;
141    Ecore_Event_Handler                  *client_msg_handler;  // TIZEN ONLY
142    Ecore_Timer                          *longpress_timer;
143    Ecore_Timer                          *delay_write;
144    /* for deferred appending */
145    Ecore_Idler                          *append_text_idler;
146    char                                 *append_text_left;
147    int                                   append_text_position;
148    int                                   append_text_len;
149    /* Only for clipboard */
150    const char                           *cut_sel;
151    const char                           *text;
152    const char                           *file;
153    Elm_Text_Format                       format;
154    Evas_Coord                            last_w, ent_mw, ent_mh;
155    Evas_Coord                            downx, downy;
156    Eina_List                            *items;
157    Eina_List                            *item_providers;
158    Eina_List                            *text_filters;
159    Eina_List                            *markup_filters;
160    Ecore_Job                            *hov_deljob;
161    Mod_Api                              *api; // module api if supplied
162    int                                   cursor_pos;
163    Elm_Scroller_Policy                   policy_h, policy_v;
164    Elm_Wrap_Type                         line_wrap;
165    Elm_Input_Panel_Layout                input_panel_layout;
166    Elm_Autocapital_Type                  autocapital_type;
167    Elm_Input_Panel_Lang                  input_panel_lang;
168    Elm_Input_Panel_Return_Key_Type       input_panel_return_key_type;
169    Elm_Input_Hints                       input_hints;
170    void                                 *input_panel_imdata;
171    int                                   input_panel_imdata_len;
172    int                                   input_panel_layout_variation;
173    struct
174    {
175       Evas_Object *hover_parent;
176       Evas_Object *pop, *hover;
177       const char  *hover_style;
178    } anchor_hover;
179    // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
180    int                                   anchor_highlight_pos;
181    Evas_Object                          *anchor_highlight_rect;
182    //
183    // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
184    Eina_List                            *anchor_access_providers;
185    //
186
187    Elm_Cnp_Mode                          cnp_mode;
188    Elm_Sel_Format                        drop_format;
189    //// TIZEN ONLY
190    Evas_Object *mgf_proxy;
191    Evas_Object *mgf_bg;
192    Evas_Coord mgf_height;
193 #ifdef HAVE_ELEMENTARY_X
194    Ecore_Event_Handler           *prop_hdl;
195 #endif
196    float mgf_scale;
197    int mgf_arrow_height;
198    int mgf_r, mgf_g, mgf_b, mgf_a; // REDWOOD ONLY (20140617): support setting mgf bg color from app
199    int start_sel_pos, end_sel_pos;
200    Ecore_Job *region_get_job;
201    Ecore_Job *region_recalc_job;
202    const char *password_text;
203    Evas_Coord cx, cy, cw, ch;
204
205    Eina_Bool double_clicked : 1;
206    Eina_Bool long_pressed : 1;
207    Eina_Bool hit_selection : 1;
208    Eina_Bool magnifier_enabled : 1;
209    Eina_Bool magnifier_showing : 1;
210    Eina_Bool mouse_upped : 1;
211    Eina_Bool sel_allow : 1;
212    Eina_Bool cursor_handler_disabled : 1;
213    Eina_Bool scroll_holding : 1;
214    Eina_Bool needs_focus_region : 1; // TIZEN_ONLY (20130830) : Focus cursor movement when mouse up.
215    Eina_Bool drag_started : 1; // REDWOOD ONLY
216    Eina_Bool drag_enabled : 1; // REDWOOD ONLY
217    Eina_Bool drop_enabled : 1; // REDWOOD ONLY
218    Eina_Bool drop_added : 1; // REDWOOD ONLY
219    Eina_Bool on_activate : 1; // TIZEN_ONLY (20140527): Add TTS strings to entry.
220    Eina_Bool mgf_bg_color_set : 1; // REDWOOD ONLY (20140617): support setting mgf bg color from app
221    //////////////////////
222    Eina_Bool                             input_panel_return_key_disabled : 1;
223    Eina_Bool                             drag_selection_asked : 1;
224    Eina_Bool                             input_panel_enable : 1;
225    Eina_Bool                             prediction_allow : 1;
226    Eina_Bool                             selection_asked : 1;
227    Eina_Bool                             auto_return_key : 1;
228    Eina_Bool                             have_selection : 1;
229    Eina_Bool                             deferred_cur : 1;
230    Eina_Bool                             context_menu : 1;
231    Eina_Bool                             cur_changed : 1;
232    Eina_Bool                             single_line : 1;
233    Eina_Bool                             can_write : 1;
234    Eina_Bool                             auto_save : 1;
235    Eina_Bool                             password : 1;
236    Eina_Bool                             editable : 1;
237    Eina_Bool                             disabled : 1;
238    Eina_Bool                             h_bounce : 1;
239    Eina_Bool                             v_bounce : 1;
240    Eina_Bool                             has_text : 1;
241    Eina_Bool                             use_down : 1;
242    Eina_Bool                             sel_mode : 1;
243    Eina_Bool                             changed : 1;
244    Eina_Bool                             scroll : 1;
245    Eina_Bool                             input_panel_show_on_demand : 1;
246 };
247
248 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
249 typedef struct _Elm_Entry_Item_Provider     Elm_Entry_Item_Provider;
250 typedef struct _Elm_Entry_Markup_Filter     Elm_Entry_Markup_Filter;
251 // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
252 typedef struct _Elm_Entry_Anchor_Access_Provider Elm_Entry_Anchor_Access_Provider;
253 //
254
255 struct _Elm_Entry_Context_Menu_Item
256 {
257    Evas_Object  *obj;
258    const char   *label;
259    const char   *icon_file;
260    const char   *icon_group;
261    Elm_Icon_Type icon_type;
262    Evas_Smart_Cb func;
263    void         *data;
264 };
265
266 struct _Elm_Entry_Item_Provider
267 {
268    Evas_Object *(*func)(void *data, Evas_Object * entry, const char *item);
269    void        *data;
270 };
271
272 struct _Elm_Entry_Markup_Filter
273 {
274    Elm_Entry_Filter_Cb func;
275    void               *data;
276    void               *orig_data;
277 };
278
279 // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
280 struct _Elm_Entry_Anchor_Access_Provider
281 {
282    char        *(*func)(void *data, Evas_Object * entry, const char *name, const char *text);
283    void        *data;
284 };
285 //
286
287 typedef enum _Length_Unit
288 {
289    LENGTH_UNIT_CHAR,
290    LENGTH_UNIT_BYTE,
291    LENGTH_UNIT_LAST
292 } Length_Unit;
293
294 /**
295  * @}
296  */
297
298 EAPI extern const char ELM_ENTRY_SMART_NAME[];
299 EAPI const Elm_Entry_Smart_Class *elm_entry_smart_class_get(void);
300
301 #define ELM_ENTRY_DATA_GET(o, sd) \
302   Elm_Entry_Smart_Data * sd = evas_object_smart_data_get(o)
303
304 #define ELM_ENTRY_DATA_GET_OR_RETURN(o, ptr)         \
305   ELM_ENTRY_DATA_GET(o, ptr);                        \
306   if (!ptr)                                          \
307     {                                                \
308        CRITICAL("No widget data for object %p (%s)", \
309                 o, evas_object_type_get(o));         \
310        return;                                       \
311     }
312
313 #define ELM_ENTRY_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
314   ELM_ENTRY_DATA_GET(o, ptr);                         \
315   if (!ptr)                                           \
316     {                                                 \
317        CRITICAL("No widget data for object %p (%s)",  \
318                 o, evas_object_type_get(o));          \
319        return val;                                    \
320     }
321
322 #define ELM_ENTRY_CHECK(obj)                     \
323   if (!obj || !elm_widget_type_check             \
324         ((obj), ELM_ENTRY_SMART_NAME, __func__)) \
325     return
326
327 #endif