elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_entry.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4 #include "elm_widget_entry.h"
5 #include "elm_module_priv.h"   // TIZEN ONLY
6 // TIZEN ONLY
7 #ifdef HAVE_ELEMENTARY_X
8 #include <X11/Xlib.h>
9 #include <X11/Xatom.h>
10 #endif
11 //
12
13 EAPI const char ELM_ENTRY_SMART_NAME[] = "elm_entry";
14
15 /* Maximum chunk size to be inserted to the entry at once
16  * FIXME: This size is arbitrary, should probably choose a better size.
17  * Possibly also find a way to set it to a low value for weak computers,
18  * and to a big value for better computers. */
19 #define _CHUNK_SIZE 10000
20
21 static const char SIG_ABORTED[] = "aborted";
22 static const char SIG_ACTIVATED[] = "activated";
23 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
24 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
25 static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened";
26 static const char SIG_ANCHOR_IN[] = "anchor,in";
27 static const char SIG_ANCHOR_OUT[] = "anchor,out";
28 static const char SIG_ANCHOR_UP[] = "anchor,up";
29 static const char SIG_CHANGED[] = "changed";
30 static const char SIG_CHANGED_USER[] = "changed,user";
31 static const char SIG_CLICKED[] = "clicked";
32 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
33 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
34 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
35 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
36 static const char SIG_FOCUSED[] = "focused";
37 static const char SIG_LANG_CHANGED[] = "language,changed";
38 static const char SIG_LONGPRESSED[] = "longpressed";
39 static const char SIG_MAX_LENGHT[] = "maxlength,reached";
40 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
41 static const char SIG_PRESS[] = "press";
42 static const char SIG_REDO_REQUEST[] = "redo,request";
43 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
44 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
45 static const char SIG_SELECTION_COPY[] = "selection,copy";
46 static const char SIG_SELECTION_CUT[] = "selection,cut";
47 static const char SIG_SELECTION_PASTE[] = "selection,paste";
48 static const char SIG_SELECTION_START[] = "selection,start";
49 static const char SIG_THEME_CHANGED[] = "theme,changed";
50 static const char SIG_UNDO_REQUEST[] = "undo,request";
51 static const char SIG_UNFOCUSED[] = "unfocused";
52 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
53    {SIG_ABORTED, ""},
54    {SIG_ACTIVATED, ""},
55    {SIG_ANCHOR_CLICKED, ""},
56    {SIG_ANCHOR_DOWN, ""},
57    {SIG_ANCHOR_HOVER_OPENED, ""},
58    {SIG_ANCHOR_IN, ""},
59    {SIG_ANCHOR_OUT, ""},
60    {SIG_ANCHOR_UP, ""},
61    {SIG_CHANGED, ""},
62    {SIG_CHANGED_USER, ""},
63    {SIG_CLICKED, ""},
64    {SIG_CLICKED_DOUBLE, ""},
65    {SIG_CLICKED_TRIPLE, ""},
66    {SIG_CURSOR_CHANGED, ""},
67    {SIG_CURSOR_CHANGED_MANUAL, ""},
68    {SIG_FOCUSED, ""},
69    {SIG_LANG_CHANGED, ""},
70    {SIG_LONGPRESSED, ""},
71    {SIG_MAX_LENGHT, ""},
72    {SIG_PREEDIT_CHANGED, ""},
73    {SIG_PRESS, ""},
74    {SIG_REDO_REQUEST, ""},
75    {SIG_SELECTION_CHANGED, ""},
76    {SIG_SELECTION_CLEARED, ""},
77    {SIG_SELECTION_COPY, ""},
78    {SIG_SELECTION_CUT, ""},
79    {SIG_SELECTION_PASTE, ""},
80    {SIG_SELECTION_START, ""},
81    {SIG_THEME_CHANGED, ""},
82    {SIG_UNDO_REQUEST, ""},
83    {SIG_UNFOCUSED, ""},
84    {NULL, NULL}
85 };
86
87 static const Elm_Layout_Part_Alias_Description _content_aliases[] =
88 {
89    {"icon", "elm.swallow.icon"},
90    {"end", "elm.swallow.end"},
91    {NULL, NULL}
92 };
93
94 static const Evas_Smart_Interface *_smart_interfaces[] =
95 {
96    (Evas_Smart_Interface *)&ELM_SCROLLABLE_IFACE, NULL
97 };
98
99 EVAS_SMART_SUBCLASS_IFACE_NEW
100   (ELM_ENTRY_SMART_NAME, _elm_entry, Elm_Entry_Smart_Class,
101   Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks,
102   _smart_interfaces);
103
104 static Eina_List *entries = NULL;
105
106 struct _Mod_Api
107 {
108    void (*obj_hook)(Evas_Object *obj);
109    void (*obj_unhook)(Evas_Object *obj);
110    void (*obj_longpress)(Evas_Object *obj);
111    // TIZEN
112    void (*obj_hidemenu) (Evas_Object *obj);
113    void (*obj_mouseup) (Evas_Object *obj);
114    //
115 };
116
117 ////////////////////////// TIZEN ONLY - START
118 static void _hover_cancel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
119 static void _hover_selected_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
120 static void _copy_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
121 static void _cut_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
122 static void _paste_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
123 static void _menu_call(Evas_Object *obj);
124
125 static void
126 _select_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
127 {
128    ELM_ENTRY_DATA_GET(data, sd);
129
130    if (!sd->sel_allow) return;
131    sd->sel_mode = EINA_TRUE;
132    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
133    edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
134    edje_object_part_text_select_all(sd->entry_edje, "elm.text");
135 }
136
137 static void
138 _select_word(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
139 {
140    ELM_ENTRY_DATA_GET(data, sd);
141
142    if (!sd->sel_allow) return;
143    sd->sel_mode = EINA_TRUE;
144
145    if (!_elm_config->desktop_entry)
146      {
147         if (!sd->password)
148           edje_object_part_text_select_allow_set
149             (sd->entry_edje, "elm.text", EINA_TRUE);
150      }
151    edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
152    edje_object_part_text_select_word(sd->entry_edje, "elm.text");
153 }
154
155 #ifdef HAVE_ELEMENTARY_X
156 static Ecore_X_Window
157 _cbhm_window_get()
158 {
159    Ecore_X_Atom x_atom_cbhm = ecore_x_atom_get("CBHM_XWIN");
160    Ecore_X_Window x_cbhm_win = 0;
161    unsigned char *buf = NULL;
162    int num = 0;
163    int ret = ecore_x_window_prop_property_get(0, x_atom_cbhm, XA_WINDOW, 0, &buf, &num);
164    if (ret && num)
165      memcpy(&x_cbhm_win, buf, sizeof(Ecore_X_Window));
166    if (buf)
167      free(buf);
168    return x_cbhm_win;
169 }
170 #endif
171
172 static Eina_Bool
173 _cbhm_msg_send(Evas_Object *obj, char *msg)
174 {
175 #ifdef HAVE_ELEMENTARY_X
176    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
177    Ecore_X_Atom x_atom_cbhm_msg = ecore_x_atom_get("CBHM_MSG");
178    Ecore_X_Window xwin = elm_win_xwindow_get(obj);
179
180    if (!x_cbhm_win || !x_atom_cbhm_msg)
181      return EINA_FALSE;
182
183    XClientMessageEvent m;
184    memset(&m, 0, sizeof(m));
185    m.type = ClientMessage;
186    m.display = ecore_x_display_get();
187    m.window = xwin;
188    m.message_type = x_atom_cbhm_msg;
189    m.format = 8;
190    snprintf(m.data.b, 20, "%s", msg);
191
192    XSendEvent(ecore_x_display_get(), x_cbhm_win, False, NoEventMask, (XEvent*)&m);
193
194    ecore_x_sync();
195    return EINA_TRUE;
196 #else
197    return EINA_FALSE;
198 #endif
199 }
200
201 static Eina_Bool
202 _xclient_msg_cb(void *data, int type __UNUSED__, void *event)
203 {
204 #ifdef HAVE_ELEMENTARY_X
205    Evas_Object *obj = (Evas_Object *)data;
206    ELM_ENTRY_DATA_GET(data, sd);
207    Ecore_X_Event_Client_Message *ev = event;
208
209    if (ev->message_type != ecore_x_atom_get("CBHM_MSG"))
210      return ECORE_CALLBACK_PASS_ON;
211
212    if (!strcmp("SET_OWNER", ev->data.b))
213      {
214         if (elm_object_focus_get(obj) == EINA_TRUE)
215           {
216              ecore_x_selection_secondary_set(elm_win_xwindow_get(data), "", 1);
217
218              if (sd->cnp_mode != ELM_CNP_MODE_MARKUP)
219                _cbhm_msg_send(data, "show0");
220              else
221                _cbhm_msg_send(data, "show1");
222           }
223      }
224 #endif
225    return ECORE_CALLBACK_PASS_ON;
226 }
227
228 static void
229 _magnifier_hide(void *data)
230 {
231    ELM_ENTRY_DATA_GET(data, sd);
232
233    if (sd->magnifier_showing)
234      {
235         evas_object_hide(sd->mgf_bg);
236         evas_object_hide(sd->mgf_clip);
237      }
238
239    if (sd->scroll)
240      sd->s_iface->freeze_set(data, EINA_FALSE);
241
242    sd->magnifier_showing = EINA_FALSE;
243 }
244
245 static void
246 _magnifier_show(void *data)
247 {
248    ELM_ENTRY_DATA_GET(data, sd);
249
250    if (!sd->magnifier_showing)
251    {
252       evas_object_show(sd->mgf_bg);
253       evas_object_show(sd->mgf_clip);
254    }
255
256    sd->magnifier_showing = EINA_TRUE;
257 }
258
259 static void
260 _magnifier_move(void *data)
261 {
262    ELM_ENTRY_DATA_GET(data, sd);
263
264    Evas_Coord x, y, w, h;
265    Evas_Coord cx, cy, cw, ch, ox, oy;
266
267    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
268
269    if (sd->scroll)
270      {
271         evas_object_geometry_get(sd->scr_edje, &x, &y, &w, &h);
272         sd->s_iface->content_pos_get(data, &ox, &oy);
273         cx -= ox;
274         cy -= oy;
275      }
276    else
277      evas_object_geometry_get(data, &x, &y, &w, &h);
278
279    ox = oy = 0;
280
281    if ((cy + y) - sd->mgf_height < 0)
282      oy = -1 * ((cy + y) - sd->mgf_height);
283
284    if (sd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
285      evas_object_move(sd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - sd->mgf_height + oy);
286    else if (sd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
287      evas_object_move(sd->mgf_bg, x, (cy + y) - sd->mgf_height + oy);
288    else
289      return;
290
291    evas_object_move(sd->mgf_proxy,
292                     (1 - sd->mgf_scale) * cx + x + ox,
293                     (1 - sd->mgf_scale) * cy + y - sd->mgf_height/2 - ch/2 - sd->mgf_arrow_height + sd->mgf_scale * oy);
294 }
295
296 static void
297 _magnifier_create(void *data)
298 {
299    ELM_ENTRY_DATA_GET(data, sd);
300
301    Evas_Coord x, y, w, h, mw, mh;
302    const char* key_data = NULL;
303    double elm_scale;
304
305    if (sd->mgf_proxy)
306      {
307         evas_object_image_source_unset(sd->mgf_proxy);
308         evas_object_color_set(sd->mgf_proxy, 255, 255, 255, 0);
309         evas_object_hide(sd->mgf_proxy);
310         evas_object_clip_unset(sd->mgf_proxy);
311         evas_object_del(sd->mgf_proxy);
312      }
313    if (sd->mgf_bg) evas_object_del(sd->mgf_bg);
314    if (sd->mgf_clip) evas_object_del(sd->mgf_clip);
315
316    if (sd->scroll)
317      evas_object_geometry_get(sd->scr_edje, &x, &y, &w, &h);
318    else
319      evas_object_geometry_get(data, &x, &y, &w, &h);
320
321    if ((w <= 0) || (h <= 0))
322      return;
323
324    sd->mgf_bg = edje_object_add(evas_object_evas_get(data));
325
326    if (sd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
327      _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier",
328                            "fixed-size");
329    else if (sd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
330      _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier",
331                            "fill-width");
332    else
333      return;
334
335    sd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
336    evas_object_color_set(sd->mgf_clip, 255, 255, 255, 255);
337    edje_object_part_swallow(sd->mgf_bg, "swallow", sd->mgf_clip);
338
339    key_data = edje_object_data_get(sd->mgf_bg, "height");
340    if (key_data) sd->mgf_height = atoi(key_data);
341    key_data = edje_object_data_get(sd->mgf_bg, "scale");
342    if (key_data) sd->mgf_scale = atof(key_data);
343    key_data = edje_object_data_get(sd->mgf_bg, "arrow");
344    if (key_data)
345      sd->mgf_arrow_height = atoi(key_data);
346    else
347      sd->mgf_arrow_height = 0;
348
349    elm_scale = elm_config_scale_get();
350    sd->mgf_height = (int)((float)sd->mgf_height * elm_scale);
351
352    if (sd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
353      evas_object_resize(sd->mgf_bg, w, sd->mgf_height);
354
355    if (sd->scroll)
356      {
357         sd->s_iface->freeze_set(data, EINA_TRUE);
358         sd->mgf_proxy = evas_object_image_add(evas_object_evas_get(sd->scr_edje));
359         evas_object_image_source_set(sd->mgf_proxy, sd->scr_edje);
360      }
361    else
362      {
363         sd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
364         evas_object_image_source_set(sd->mgf_proxy, data);
365      }
366
367    mw = (Evas_Coord)((float)w * sd->mgf_scale);
368    mh = (Evas_Coord)((float)h * sd->mgf_scale);
369    if ((mw <= 0) || (mh <= 0))
370      return;
371
372    evas_object_resize(sd->mgf_proxy, mw, mh);
373    evas_object_image_fill_set(sd->mgf_proxy, 0, 0, mw, mh);
374    evas_object_color_set(sd->mgf_proxy, 255, 255, 255, 255);
375    evas_object_pass_events_set(sd->mgf_proxy, EINA_TRUE);
376    evas_object_show(sd->mgf_proxy);
377    evas_object_clip_set(sd->mgf_proxy, sd->mgf_clip);
378
379    evas_object_layer_set(sd->mgf_bg, EVAS_LAYER_MAX);
380    evas_object_layer_set(sd->mgf_proxy, EVAS_LAYER_MAX);
381 }
382
383 static void
384 _magnifier_content_resize(void *data)
385 {
386    ELM_ENTRY_DATA_GET(data, sd);
387    Evas_Coord w, h, mw, mh;
388
389    if (sd->scroll)
390      evas_object_geometry_get(sd->scr_edje, NULL, NULL, &w, &h);
391    else
392      evas_object_geometry_get(data, NULL, NULL, &w, &h);
393
394    if ((w <= 0) || (h <= 0))
395      return;
396
397    mw = (Evas_Coord)((float)w * sd->mgf_scale);
398    mh = (Evas_Coord)((float)h * sd->mgf_scale);
399
400    if ((mw <= 0) || (mh <= 0))
401      return;
402
403    evas_object_resize(sd->mgf_proxy, mw, mh);
404    evas_object_image_fill_set(sd->mgf_proxy, 0, 0, mw, mh);
405 }
406
407 static void
408 _signal_long_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
409 {
410    ELM_ENTRY_DATA_GET(data, sd);
411    if (sd->disabled) return;
412
413    sd->long_pressed = EINA_TRUE;
414    _hover_cancel_cb(data, NULL, NULL);
415    if (sd->magnifier_enabled)
416      {
417         _magnifier_create(data);
418         _magnifier_move(data);
419         _magnifier_show(data);
420      }
421 }
422
423 static void
424 _signal_handler_move_start_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
425 {
426    ELM_ENTRY_DATA_GET(data, sd);
427
428    elm_object_scroll_freeze_push(data);
429
430    if ((sd->api) && (sd->api->obj_hidemenu))
431      sd->api->obj_hidemenu(data);
432
433    if (sd->magnifier_enabled)
434      {
435         _magnifier_create(data);
436         _magnifier_move(data);
437         _magnifier_show(data);
438      }
439 }
440
441 static void
442 _signal_handler_move_end_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
443 {
444    elm_object_scroll_freeze_pop(data);
445
446    _magnifier_hide(data);
447    _menu_call(data);
448 }
449
450 static void
451 _signal_handler_moving_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
452 {
453    ELM_ENTRY_DATA_GET(data, sd);
454
455    if (sd->magnifier_enabled)
456      {
457         _magnifier_move(data);
458         _magnifier_show(data);
459      }
460 }
461
462 static void
463 _signal_handler_click_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
464 {
465    _select_word(data, NULL, NULL);
466 }
467
468 static Evas_Coord_Rectangle
469 _intersection_region_get(Evas_Coord_Rectangle rect1, Evas_Coord_Rectangle rect2)
470 {
471    Evas_Coord_Rectangle ret_rect;
472    Evas_Coord_Point l1, l2, r1, r2, p1, p2;
473
474    l1.x = rect1.x;
475    l1.y = rect1.y;
476    r1.x = rect1.x + rect1.w;
477    r1.y = rect1.y + rect1.h;
478
479    l2.x = rect2.x;
480    l2.y = rect2.y;
481    r2.x = rect2.x + rect2.w;
482    r2.y = rect2.y + rect2.h;
483
484    p1.x = (l1.x > l2.x) ? l1.x : l2.x;
485    p1.y = (l1.y > l2.y) ? l1.y : l2.y;
486    p2.x = (r1.x < r2.x) ? r1.x : r2.x;
487    p2.y = (r1.y < r2.y) ? r1.y : r2.y;
488
489    ret_rect.x = p1.x;
490    ret_rect.y = p1.y;
491    ret_rect.w = (p2.x > p1.x) ? p2.x - p1.x : -1;
492    ret_rect.h = (p2.y > p1.y) ? p2.y - p1.y : -1;
493
494    return ret_rect;
495 }
496
497 static Evas_Coord_Rectangle
498 _viewport_region_get(Evas_Object *data)
499 {
500    Evas_Coord_Rectangle geometry, ret_rect;
501    geometry.x = geometry.y = geometry.w = geometry.h = -1;
502    ret_rect = geometry;
503
504    ELM_ENTRY_DATA_GET(data, sd);
505    if (!data || !strlen(elm_widget_type_get(data))) return geometry;
506
507    if (sd->scroll)
508      {
509         evas_object_geometry_get(sd->scr_edje,
510                                  &geometry.x,
511                                  &geometry.y,
512                                  &geometry.w,
513                                  &geometry.h);
514
515         ret_rect = geometry;
516      }
517
518    Evas_Object *parent_obj = data;
519
520    while ((parent_obj = elm_widget_parent_get(parent_obj)))
521      {
522         if (!strcmp(elm_widget_type_get(parent_obj), "elm_scroller") ||
523             !strcmp(elm_widget_type_get(parent_obj), "elm_genlist"))
524           {
525              evas_object_geometry_get(parent_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
526              if ((ret_rect.w == -1) && (ret_rect.h == -1)) ret_rect = geometry;
527              ret_rect = _intersection_region_get(geometry, ret_rect);
528           }
529      }
530
531    return ret_rect;
532 }
533
534 static Evas_Coord_Rectangle
535 _layout_region_get(Evas_Object *data)
536 {
537    Evas_Coord_Rectangle geometry;
538    geometry.x = geometry.y = geometry.w = geometry.h = -1;
539
540    if (!data || !strlen(elm_widget_type_get(data))) return geometry;
541
542    Evas_Object *child_obj = data;
543    Evas_Object *parent_obj;
544
545    while ((parent_obj = elm_widget_parent_get(child_obj)))
546      {
547         if (!strcmp(elm_widget_type_get(parent_obj), "elm_conformant"))
548           {
549              evas_object_geometry_get(child_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
550              return geometry;
551           }
552         child_obj = parent_obj;
553      }
554
555    return geometry;
556 }
557
558 static void
559 _region_recalc_job(void *data)
560 {
561    ELM_ENTRY_DATA_GET(data, sd);
562    Evas_Coord_Rectangle ret_rect;
563
564    sd->region_recalc_job = NULL;
565
566    if (!_elm_config->desktop_entry)
567      {
568         ret_rect = _viewport_region_get(data);
569         edje_object_part_text_viewport_region_set(sd->entry_edje, "elm.text",
570                                                   ret_rect.x, ret_rect.y,
571                                                   ret_rect.w, ret_rect.h);
572         ret_rect = _layout_region_get(data);
573         edje_object_part_text_layout_region_set(sd->entry_edje, "elm.text",
574                                                 ret_rect.x, ret_rect.y,
575                                                 ret_rect.w, ret_rect.h);
576      }
577 }
578
579 static void
580 _region_get_job(void *data)
581 {
582    ELM_ENTRY_DATA_GET(data, sd);
583
584    sd->region_get_job = NULL;
585
586    if (!_elm_config->desktop_entry)
587      {
588         if (sd->region_recalc_job) ecore_job_del(sd->region_recalc_job);
589         sd->region_recalc_job = ecore_job_add(_region_recalc_job, data);
590
591         evas_smart_objects_calculate(evas_object_evas_get(data));
592      }
593 }
594
595 static void
596 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
597 {
598    ELM_ENTRY_DATA_GET(data, sd);
599    if (sd->disabled) return;
600
601    if (sd->magnifier_enabled)
602      _magnifier_hide(data);
603    _menu_call(data);
604 }
605
606 static void
607 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
608 {
609    ELM_ENTRY_DATA_GET(data, sd);
610    Evas_Coord cx, cy, cw, ch;
611
612    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
613    if (!sd->deferred_recalc_job)
614      elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
615    else
616      {
617         sd->deferred_cur = EINA_TRUE;
618         sd->cx = cx;
619         sd->cy = cy;
620         sd->cw = cw;
621         sd->ch = ch;
622      }
623 }
624
625 static void
626 _elm_entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
627 {
628    Evas_Event_Key_Down *ev = event_info;
629    if (!ev->keyname) return;
630
631    ELM_ENTRY_DATA_GET(data, sd);
632    if (sd->sel_allow)
633      {
634         if (!_elm_config->desktop_entry)
635           edje_object_part_text_select_allow_set
636              (sd->entry_edje, "elm.text", EINA_TRUE);
637      }
638    if ((sd->api) && (sd->api->obj_hidemenu))
639      sd->api->obj_hidemenu(data);
640 }
641
642 void elm_entry_extension_module_data_get(Evas_Object *obj, Elm_Entry_Extension_data *ext_mod)
643 {
644    ELM_ENTRY_DATA_GET(obj, sd);
645
646    ext_mod->cancel = _hover_cancel_cb;
647    ext_mod->copy = _copy_cb;
648    ext_mod->cut = _cut_cb;
649    ext_mod->paste = _paste_cb;
650    ext_mod->select = _select_word;
651    ext_mod->selectall = _select_all;
652    ext_mod->ent = sd->entry_edje;
653    ext_mod->items = sd->items;
654    ext_mod->editable = sd->editable;
655    ext_mod->have_selection = sd->have_selection;
656    ext_mod->password = sd->password;
657    ext_mod->selmode = sd->sel_mode;
658    ext_mod->context_menu = sd->context_menu;
659    ext_mod->cnp_mode = sd->cnp_mode;
660    ext_mod->viewport_rect = _viewport_region_get(obj);
661 }
662 ////////////////////////// TIZEN ONLY - END
663
664 static Mod_Api *
665 _module_find(Evas_Object *obj __UNUSED__)
666 {
667    static Elm_Module *m = NULL;
668
669    if (m) goto ok;  // already found - just use
670    if (!(m = _elm_module_find_as("entry/api"))) return NULL;
671    // get module api
672    m->api = malloc(sizeof(Mod_Api));
673    if (!m->api) return NULL;
674
675    ((Mod_Api *)(m->api))->obj_hook = // called on creation
676      _elm_module_symbol_get(m, "obj_hook");
677    ((Mod_Api *)(m->api))->obj_unhook = // called on deletion
678      _elm_module_symbol_get(m, "obj_unhook");
679    ((Mod_Api *)(m->api))->obj_longpress = // called on long press menu
680      _elm_module_symbol_get(m, "obj_longpress");
681    //TIZEN ONLY
682    ((Mod_Api *)(m->api))->obj_hidemenu = // called on hide menu
683      _elm_module_symbol_get(m, "obj_hidemenu");
684    ((Mod_Api *)(m->api))->obj_mouseup = // called on mouseup
685      _elm_module_symbol_get(m, "obj_mouseup");
686    //
687 ok: // ok - return api
688    return m->api;
689 }
690
691 static char *
692 _file_load(const char *file)
693 {
694    Eina_File *f;
695    char *text = NULL;
696    void *tmp = NULL;
697
698    f = eina_file_open(file, EINA_FALSE);
699    if (!f) return NULL;
700
701    tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
702    if (!tmp) goto on_error;
703
704    text = malloc(eina_file_size_get(f) + 1);
705    if (!text) goto on_error;
706
707    memcpy(text, tmp, eina_file_size_get(f));
708    text[eina_file_size_get(f)] = 0;
709
710    if (eina_file_map_faulted(f, tmp))
711      {
712         free(text);
713         text = NULL;
714      }
715
716  on_error:
717    if (tmp) eina_file_map_free(f, tmp);
718    eina_file_close(f);
719
720    return text;
721 }
722
723 static char *
724 _plain_load(const char *file)
725 {
726    char *text;
727
728    text = _file_load(file);
729    if (text)
730      {
731         char *text2;
732
733         text2 = elm_entry_utf8_to_markup(text);
734         free(text);
735         return text2;
736      }
737
738    return NULL;
739 }
740
741 static Eina_Bool
742 _load_do(Evas_Object *obj)
743 {
744    char *text;
745
746    ELM_ENTRY_DATA_GET(obj, sd);
747
748    if (!sd->file)
749      {
750         elm_object_text_set(obj, "");
751         return EINA_TRUE;
752      }
753
754    switch (sd->format)
755      {
756       case ELM_TEXT_FORMAT_PLAIN_UTF8:
757         text = _plain_load(sd->file);
758         break;
759
760       case ELM_TEXT_FORMAT_MARKUP_UTF8:
761         text = _file_load(sd->file);
762         break;
763
764       default:
765         text = NULL;
766         break;
767      }
768
769    if (text)
770      {
771         elm_object_text_set(obj, text);
772         free(text);
773
774         return EINA_TRUE;
775      }
776    else
777      {
778         elm_object_text_set(obj, "");
779
780         return EINA_FALSE;
781      }
782 }
783
784 static void
785 _utf8_markup_save(const char *file,
786                   const char *text)
787 {
788    FILE *f;
789
790    if ((!text) || (!text[0]))
791      {
792         ecore_file_unlink(file);
793
794         return;
795      }
796
797    f = fopen(file, "wb");
798    if (!f)
799      {
800         // FIXME: report a write error
801         return;
802      }
803
804    fputs(text, f); // FIXME: catch error
805    fclose(f);
806 }
807
808 static void
809 _utf8_plain_save(const char *file,
810                  const char *text)
811 {
812    char *text2;
813
814    text2 = elm_entry_markup_to_utf8(text);
815    if (!text2)
816      return;
817
818    _utf8_markup_save(file, text2);
819    free(text2);
820 }
821
822 static void
823 _save_do(Evas_Object *obj)
824 {
825    ELM_ENTRY_DATA_GET(obj, sd);
826
827    if (!sd->file) return;
828    switch (sd->format)
829      {
830       case ELM_TEXT_FORMAT_PLAIN_UTF8:
831         _utf8_plain_save(sd->file, elm_object_text_get(obj));
832         break;
833
834       case ELM_TEXT_FORMAT_MARKUP_UTF8:
835         _utf8_markup_save(sd->file, elm_object_text_get(obj));
836         break;
837
838       default:
839         break;
840      }
841 }
842
843 static Eina_Bool
844 _delay_write(void *data)
845 {
846    ELM_ENTRY_DATA_GET(data, sd);
847
848    _save_do(data);
849    sd->delay_write = NULL;
850
851    return ECORE_CALLBACK_CANCEL;
852 }
853
854 static void
855 _elm_entry_guide_update(Evas_Object *obj,
856                         Eina_Bool has_text)
857 {
858    ELM_ENTRY_DATA_GET(obj, sd);
859
860    if ((has_text) && (!sd->has_text))
861      edje_object_signal_emit(sd->entry_edje, "elm,guide,disabled", "elm");
862    else if ((!has_text) && (sd->has_text))
863      edje_object_signal_emit(sd->entry_edje, "elm,guide,enabled", "elm");
864
865    sd->has_text = has_text;
866 }
867
868 static Elm_Entry_Markup_Filter *
869 _filter_new(Elm_Entry_Filter_Cb func,
870             void *data)
871 {
872    Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
873
874    if (!tf) return NULL;
875
876    tf->func = func;
877    if (func == elm_entry_filter_limit_size)
878      {
879         Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
880
881         if (!data)
882           {
883              free(tf);
884
885              return NULL;
886           }
887
888         lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
889         if (!lim2)
890           {
891              free(tf);
892
893              return NULL;
894           }
895         memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
896         tf->data = lim2;
897      }
898    else if (func == elm_entry_filter_accept_set)
899      {
900         Elm_Entry_Filter_Accept_Set *as = data, *as2;
901
902         if (!data)
903           {
904              free(tf);
905
906              return NULL;
907           }
908         as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
909         if (!as2)
910           {
911              free(tf);
912
913              return NULL;
914           }
915         if (as->accepted)
916           as2->accepted = eina_stringshare_add(as->accepted);
917         else
918           as2->accepted = NULL;
919         if (as->rejected)
920           as2->rejected = eina_stringshare_add(as->rejected);
921         else
922           as2->rejected = NULL;
923         tf->data = as2;
924      }
925    else
926      tf->data = data;
927    return tf;
928 }
929
930 static void
931 _filter_free(Elm_Entry_Markup_Filter *tf)
932 {
933    if (tf->func == elm_entry_filter_limit_size)
934      {
935         Elm_Entry_Filter_Limit_Size *lim = tf->data;
936
937         if (lim) free(lim);
938      }
939    else if (tf->func == elm_entry_filter_accept_set)
940      {
941         Elm_Entry_Filter_Accept_Set *as = tf->data;
942
943         if (as)
944           {
945              if (as->accepted) eina_stringshare_del(as->accepted);
946              if (as->rejected) eina_stringshare_del(as->rejected);
947
948              free(as);
949           }
950      }
951    free(tf);
952 }
953
954 static void
955 _mirrored_set(Evas_Object *obj,
956               Eina_Bool rtl)
957 {
958    ELM_ENTRY_DATA_GET(obj, sd);
959
960    edje_object_mirrored_set(sd->entry_edje, rtl);
961
962    if (sd->anchor_hover.hover)
963      elm_widget_mirrored_set(sd->anchor_hover.hover, rtl);
964 }
965
966 static const char *
967 _elm_entry_theme_group_get(Evas_Object *obj)
968 {
969    ELM_ENTRY_DATA_GET(obj, sd);
970
971    if (sd->editable)
972      {
973         if (sd->password) return "base-password";
974         else
975           {
976              if (sd->single_line) return "base-single";
977              else
978                {
979                   switch (sd->line_wrap)
980                     {
981                      case ELM_WRAP_CHAR:
982                        return "base-charwrap";
983
984                      case ELM_WRAP_WORD:
985                        return "base";
986
987                      case ELM_WRAP_MIXED:
988                        return "base-mixedwrap";
989
990                      case ELM_WRAP_NONE:
991                      default:
992                        return "base-nowrap";
993                     }
994                }
995           }
996      }
997    else
998      {
999         if (sd->password) return "base-password";
1000         else
1001           {
1002              if (sd->single_line) return "base-single-noedit";
1003              else
1004                {
1005                   switch (sd->line_wrap)
1006                     {
1007                      case ELM_WRAP_CHAR:
1008                        return "base-noedit-charwrap";
1009
1010                      case ELM_WRAP_WORD:
1011                        return "base-noedit";
1012
1013                      case ELM_WRAP_MIXED:
1014                        return "base-noedit-mixedwrap";
1015
1016                      case ELM_WRAP_NONE:
1017                      default:
1018                        return "base-nowrap-noedit";
1019                     }
1020                }
1021           }
1022      }
1023 }
1024
1025 /* we can't reuse layout's here, because it's on entry_edje only */
1026 static Eina_Bool
1027 _elm_entry_smart_disable(Evas_Object *obj)
1028 {
1029    ELM_ENTRY_DATA_GET(obj, sd);
1030
1031    if (elm_object_disabled_get(obj))
1032      {
1033         edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
1034         sd->disabled = EINA_TRUE;
1035      }
1036    else
1037      {
1038         edje_object_signal_emit(sd->entry_edje, "elm,state,enabled", "elm");
1039         sd->disabled = EINA_FALSE;
1040      }
1041
1042    return EINA_TRUE;
1043 }
1044
1045 /* we can't issue the layout's theming code here, cause it assumes an
1046  * unique edje object, always */
1047 static Eina_Bool
1048 _elm_entry_smart_theme(Evas_Object *obj)
1049 {
1050    const char *t;
1051    Elm_Widget_Smart_Class *parent_parent =
1052      (Elm_Widget_Smart_Class *)((Evas_Smart_Class *)
1053                                 _elm_entry_parent_sc)->parent;
1054
1055    ELM_ENTRY_DATA_GET(obj, sd);
1056
1057    if (!parent_parent->theme(obj))
1058      return EINA_FALSE;
1059
1060    evas_event_freeze(evas_object_evas_get(obj));
1061
1062    // TIZEN ONLY(130129) : Currently, for freezing cursor movement only.
1063    edje_object_part_text_freeze(sd->entry_edje, "elm.text");
1064    //
1065
1066    edje_object_mirrored_set
1067      (ELM_WIDGET_DATA(sd)->resize_obj, elm_widget_mirrored_get(obj));
1068
1069    edje_object_scale_set
1070      (ELM_WIDGET_DATA(sd)->resize_obj,
1071      elm_widget_scale_get(obj) * elm_config_scale_get());
1072
1073    _mirrored_set(obj, elm_widget_mirrored_get(obj));
1074
1075    // TIZEN ONLY(130225) : when password mode, elm_object_text_get returns utf8 string.
1076    if (sd->password)
1077      t = eina_stringshare_add(elm_entry_utf8_to_markup(elm_object_text_get(obj)));
1078    else
1079      t = eina_stringshare_add(elm_object_text_get(obj));
1080
1081    elm_widget_theme_object_set
1082      (obj, sd->entry_edje, "entry", _elm_entry_theme_group_get(obj),
1083      elm_widget_style_get(obj));
1084
1085    if (_elm_config->desktop_entry)
1086      edje_object_part_text_select_allow_set
1087        (sd->entry_edje, "elm.text", EINA_TRUE);
1088
1089    elm_object_text_set(obj, t);
1090    eina_stringshare_del(t);
1091
1092    if (elm_widget_disabled_get(obj))
1093      edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
1094
1095    edje_object_part_text_input_panel_layout_set
1096      (sd->entry_edje, "elm.text", sd->input_panel_layout);
1097    edje_object_part_text_input_panel_layout_variation_set
1098      (sd->entry_edje, "elm.text", sd->input_panel_layout_variation);
1099    edje_object_part_text_autocapital_type_set
1100      (sd->entry_edje, "elm.text", sd->autocapital_type);
1101    edje_object_part_text_prediction_allow_set
1102      (sd->entry_edje, "elm.text", sd->prediction_allow);
1103    edje_object_part_text_input_panel_enabled_set
1104      (sd->entry_edje, "elm.text", sd->input_panel_enable);
1105    edje_object_part_text_input_panel_imdata_set
1106      (sd->entry_edje, "elm.text", sd->input_panel_imdata,
1107      sd->input_panel_imdata_len);
1108    edje_object_part_text_input_panel_return_key_type_set
1109      (sd->entry_edje, "elm.text", sd->input_panel_return_key_type);
1110    edje_object_part_text_input_panel_return_key_disabled_set
1111      (sd->entry_edje, "elm.text", sd->input_panel_return_key_disabled);
1112
1113    if (sd->cursor_pos != 0)
1114      elm_entry_cursor_pos_set(obj, sd->cursor_pos);
1115
1116    if (elm_widget_focus_get(obj))
1117      edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
1118
1119    edje_object_message_signal_process(sd->entry_edje);
1120
1121    if (sd->scroll)
1122      {
1123         const char *str;
1124
1125         sd->s_iface->mirrored_set(obj, elm_widget_mirrored_get(obj));
1126
1127         elm_widget_theme_object_set
1128           (obj, sd->scr_edje, "scroller", "entry", elm_widget_style_get(obj));
1129
1130         str = edje_object_data_get(sd->scr_edje, "focus_highlight");
1131         if ((str) && (!strcmp(str, "on")))
1132           elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
1133         else
1134           elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
1135      }
1136
1137    elm_layout_sizing_eval(obj);
1138
1139    sd->has_text = !sd->has_text;
1140    _elm_entry_guide_update(obj, !sd->has_text);
1141    evas_event_thaw(evas_object_evas_get(obj));
1142    evas_event_thaw_eval(evas_object_evas_get(obj));
1143
1144    // TIZEN ONLY(130129) : Currently, for freezing cursor movement only.
1145    edje_object_part_text_thaw(sd->entry_edje, "elm.text");
1146    //
1147
1148    evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
1149
1150    return EINA_TRUE;
1151 }
1152
1153 static void
1154 _cursor_geometry_recalc(Evas_Object *obj)
1155 {
1156    ELM_ENTRY_DATA_GET(obj, sd);
1157
1158    evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
1159
1160    if (!sd->deferred_recalc_job)
1161      {
1162         Evas_Coord cx, cy, cw, ch;
1163
1164         edje_object_part_text_cursor_geometry_get
1165           (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1166         if (sd->cur_changed)
1167           {
1168              elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
1169              sd->cur_changed = EINA_FALSE;
1170           }
1171      }
1172    else
1173      sd->deferred_cur = EINA_TRUE;
1174 }
1175
1176 static void
1177 _deferred_recalc_job(void *data)
1178 {
1179    Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
1180
1181    ELM_ENTRY_DATA_GET(data, sd);
1182
1183    sd->deferred_recalc_job = NULL;
1184
1185    evas_object_geometry_get(sd->entry_edje, NULL, NULL, &resw, NULL);
1186    edje_object_size_min_restricted_calc(sd->entry_edje, &minw, &minh, resw, 0);
1187    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1188
1189    /* This is a hack to workaround the way min size hints are treated.
1190     * If the minimum width is smaller than the restricted width, it
1191     * means the minimum doesn't matter. */
1192    if (minw <= resw)
1193      {
1194         Evas_Coord ominw = -1;
1195
1196         evas_object_size_hint_min_get(data, &ominw, NULL);
1197         minw = ominw;
1198      }
1199
1200    sd->ent_mw = minw;
1201    sd->ent_mh = minh;
1202
1203    elm_coords_finger_size_adjust(1, &fw, 1, &fh);
1204    if (sd->scroll)
1205      {
1206         Evas_Coord vmw = 0, vmh = 0;
1207
1208         edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
1209         if (sd->single_line)
1210           {
1211              evas_object_size_hint_min_set(data, vmw, minh + vmh);
1212              evas_object_size_hint_max_set(data, -1, minh + vmh);
1213           }
1214         else
1215           {
1216              evas_object_size_hint_min_set(data, vmw, vmh);
1217              evas_object_size_hint_max_set(data, -1, -1);
1218           }
1219      }
1220    else
1221      {
1222         if (sd->single_line)
1223           {
1224              evas_object_size_hint_min_set(data, minw, minh);
1225              evas_object_size_hint_max_set(data, -1, minh);
1226           }
1227         else
1228           {
1229              evas_object_size_hint_min_set(data, fw, minh);
1230              evas_object_size_hint_max_set(data, -1, -1);
1231           }
1232      }
1233
1234    if (sd->deferred_cur)
1235      {
1236         Evas_Coord cx, cy, cw, ch;
1237
1238         edje_object_part_text_cursor_geometry_get
1239           (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1240         if (sd->cur_changed)
1241           {
1242              elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1243              sd->cur_changed = EINA_FALSE;
1244           }
1245      }
1246 }
1247
1248 static void
1249 _elm_entry_smart_sizing_eval(Evas_Object *obj)
1250 {
1251    Evas_Coord minw = -1, minh = -1;
1252    Evas_Coord resw, resh;
1253
1254    ELM_ENTRY_DATA_GET(obj, sd);
1255
1256    evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
1257
1258    if (sd->line_wrap)
1259      {
1260         if ((resw == sd->last_w) && (!sd->changed))
1261           {
1262              if (sd->scroll)
1263                {
1264                   Evas_Coord vw = 0, vh = 0, w = 0, h = 0;
1265
1266                   sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
1267
1268                   w = sd->ent_mw;
1269                   h = sd->ent_mh;
1270                   if (vw > sd->ent_mw) w = vw;
1271                   if (vh > sd->ent_mh) h = vh;
1272                   evas_object_resize(sd->entry_edje, w, h);
1273
1274                   return;
1275                }
1276
1277              return;
1278           }
1279
1280         evas_event_freeze(evas_object_evas_get(obj));
1281         sd->changed = EINA_FALSE;
1282         sd->last_w = resw;
1283         if (sd->scroll)
1284           {
1285              Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
1286
1287              evas_object_resize(sd->scr_edje, resw, resh);
1288              edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
1289              sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
1290              edje_object_size_min_restricted_calc
1291                (sd->entry_edje, &minw, &minh, vw, 0);
1292              elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1293
1294              /* This is a hack to workaround the way min size hints
1295               * are treated.  If the minimum width is smaller than the
1296               * restricted width, it means the minimum doesn't
1297               * matter. */
1298              if (minw <= vw)
1299                {
1300                   Evas_Coord ominw = -1;
1301
1302                   evas_object_size_hint_min_get(sd->entry_edje, &ominw, NULL);
1303                   minw = ominw;
1304                }
1305              sd->ent_mw = minw;
1306              sd->ent_mh = minh;
1307
1308              if ((minw > 0) && (vw < minw)) vw = minw;
1309              if (minh > vh) vh = minh;
1310
1311              if (sd->single_line) h = vmh + minh;
1312              else h = vmh;
1313
1314              evas_object_resize(sd->entry_edje, vw, vh);
1315              evas_object_size_hint_min_set(obj, w, h);
1316
1317              if (sd->single_line)
1318                evas_object_size_hint_max_set(obj, -1, h);
1319              else
1320                evas_object_size_hint_max_set(obj, -1, -1);
1321           }
1322         else
1323           {
1324              if (sd->deferred_recalc_job)
1325                ecore_job_del(sd->deferred_recalc_job);
1326              sd->deferred_recalc_job =
1327                ecore_job_add(_deferred_recalc_job, obj);
1328           }
1329
1330         evas_event_thaw(evas_object_evas_get(obj));
1331         evas_event_thaw_eval(evas_object_evas_get(obj));
1332      }
1333    else
1334      {
1335         if (!sd->changed) return;
1336         evas_event_freeze(evas_object_evas_get(obj));
1337         sd->changed = EINA_FALSE;
1338         sd->last_w = resw;
1339         if (sd->scroll)
1340           {
1341              Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
1342
1343              edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
1344              sd->ent_mw = minw;
1345              sd->ent_mh = minh;
1346              elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1347
1348              sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
1349
1350              if (minw > vw) vw = minw;
1351              if (minh > vh) vh = minh;
1352
1353              evas_object_resize(sd->entry_edje, vw, vh);
1354              edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
1355              if (sd->single_line) h = vmh + minh;
1356              else h = vmh;
1357
1358              evas_object_size_hint_min_set(obj, w, h);
1359              if (sd->single_line)
1360                evas_object_size_hint_max_set(obj, -1, h);
1361              else
1362                evas_object_size_hint_max_set(obj, -1, -1);
1363           }
1364         else
1365           {
1366              edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
1367              sd->ent_mw = minw;
1368              sd->ent_mh = minh;
1369              elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1370              evas_object_size_hint_min_set(obj, minw, minh);
1371
1372              if (sd->single_line)
1373                evas_object_size_hint_max_set(obj, -1, minh);
1374              else
1375                evas_object_size_hint_max_set(obj, -1, -1);
1376           }
1377         evas_event_thaw(evas_object_evas_get(obj));
1378         evas_event_thaw_eval(evas_object_evas_get(obj));
1379      }
1380
1381    _cursor_geometry_recalc(obj);
1382 }
1383
1384 static void
1385 _return_key_enabled_check(Evas_Object *obj)
1386 {
1387    Eina_Bool return_key_disabled = EINA_FALSE;
1388
1389    ELM_ENTRY_DATA_GET(obj, sd);
1390
1391    if (!sd->auto_return_key) return;
1392
1393    if (elm_entry_is_empty(obj) == EINA_TRUE)
1394      return_key_disabled = EINA_TRUE;
1395
1396    elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
1397 }
1398
1399 static Eina_Bool
1400 _elm_entry_smart_on_focus(Evas_Object *obj)
1401 {
1402    Evas_Object *top;
1403    Eina_Bool top_is_win;
1404
1405    ELM_ENTRY_DATA_GET(obj, sd);
1406
1407    top = elm_widget_top_get(obj);
1408    if (!strcmp(evas_object_type_get(top), "elm_win"))
1409      top_is_win = EINA_TRUE;
1410
1411    // if (!sd->editable) return EINA_FALSE;   // TIZEN ONLY
1412    if (elm_widget_focus_get(obj))
1413      {
1414         printf("[Elm_entry::Focused] obj : %p\n", obj); // TIZEN ONLY
1415         evas_object_focus_set(sd->entry_edje, EINA_TRUE);
1416         edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
1417         sd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE; // TIZEN ONLY
1418         if (sd->editable) // TIZEN ONLY
1419           {
1420              if (top && top_is_win && sd->input_panel_enable)
1421                elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
1422              evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
1423              _return_key_enabled_check(obj);
1424           }
1425      }
1426    else
1427      {
1428         printf("[Elm_entry::Unfocused] obj : %p\n", obj); // TIZEN ONLY
1429         _cbhm_msg_send(obj, "cbhm_hide"); // TIZEN ONLY : Hide clipboard
1430         edje_object_signal_emit(sd->entry_edje, "elm,action,unfocus", "elm");
1431         evas_object_focus_set(sd->entry_edje, EINA_FALSE);
1432         // TIZEN ONLY
1433         if ((sd->api) && (sd->api->obj_hidemenu))
1434           sd->api->obj_hidemenu(obj);
1435         //
1436         if (sd->editable) // TIZEN ONLY
1437           {
1438              if (top && top_is_win && sd->input_panel_enable)
1439                elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
1440              evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
1441           }
1442
1443         if (_elm_config->selection_clear_enable)
1444           {
1445              if ((sd->have_selection) && (!sd->hoversel))
1446                {
1447                   sd->sel_mode = EINA_FALSE;
1448                   elm_widget_scroll_hold_pop(obj);
1449                   edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", EINA_FALSE);
1450                   edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1451                   edje_object_part_text_select_none(sd->entry_edje, "elm.text");
1452                }
1453           }
1454      }
1455
1456    return EINA_TRUE;
1457 }
1458
1459 static Eina_Bool
1460 _elm_entry_smart_translate(Evas_Object *obj)
1461 {
1462    evas_object_smart_callback_call(obj, SIG_LANG_CHANGED, NULL);
1463
1464    return EINA_TRUE;
1465 }
1466
1467 static Eina_Bool
1468 _elm_entry_smart_on_focus_region(const Evas_Object *obj,
1469                                  Evas_Coord *x,
1470                                  Evas_Coord *y,
1471                                  Evas_Coord *w,
1472                                  Evas_Coord *h)
1473 {
1474    ELM_ENTRY_DATA_GET(obj, sd);
1475
1476    edje_object_part_text_cursor_geometry_get
1477      (sd->entry_edje, "elm.text", x, y, w, h);
1478    return EINA_TRUE;
1479 }
1480
1481 // TIZEN ONLY
1482 static Eina_Bool
1483 _elm_entry_smart_event(Evas_Object *obj,
1484                        Evas_Object *src __UNUSED__,
1485                        Evas_Callback_Type type,
1486                        void *event_info)
1487 {
1488    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
1489    Evas_Event_Key_Down *ev = event_info;
1490    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
1491    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
1492    return EINA_TRUE;
1493 }
1494 //
1495
1496 static void
1497 _show_region_hook(void *data,
1498                   Evas_Object *obj)
1499 {
1500    Evas_Coord x, y, w, h;
1501
1502    ELM_ENTRY_DATA_GET(data, sd);
1503
1504    elm_widget_show_region_get(obj, &x, &y, &w, &h);
1505
1506    sd->s_iface->content_region_show(obj, x, y, w, h);
1507 }
1508
1509 static Eina_Bool
1510 _elm_entry_smart_sub_object_del(Evas_Object *obj,
1511                                 Evas_Object *sobj)
1512 {
1513    /* unfortunately entry doesn't follow the signal pattern
1514     * elm,state,icon,{visible,hidden}, so we have to replicate this
1515     * smart function */
1516    if (sobj == elm_layout_content_get(obj, "elm.swallow.icon"))
1517      {
1518         elm_layout_signal_emit(obj, "elm,action,hide,icon", "elm");
1519      }
1520    else if (sobj == elm_layout_content_get(obj, "elm.swallow.end"))
1521      {
1522         elm_layout_signal_emit(obj, "elm,action,hide,end", "elm");
1523      }
1524
1525    if (!ELM_WIDGET_CLASS(_elm_entry_parent_sc)->sub_object_del(obj, sobj))
1526      return EINA_FALSE;
1527
1528    return EINA_TRUE;
1529 }
1530
1531 static void
1532 _hoversel_position(Evas_Object *obj)
1533 {
1534    Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1535
1536    ELM_ENTRY_DATA_GET(obj, sd);
1537
1538    cx = cy = 0;
1539    cw = ch = 1;
1540    evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
1541    if (sd->use_down)
1542      {
1543         cx = sd->downx - x;
1544         cy = sd->downy - y;
1545         cw = 1;
1546         ch = 1;
1547      }
1548    else
1549      edje_object_part_text_cursor_geometry_get
1550        (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1551
1552    evas_object_size_hint_min_get(sd->hoversel, &mw, &mh);
1553    if (cw < mw)
1554      {
1555         cx += (cw - mw) / 2;
1556         cw = mw;
1557      }
1558    if (ch < mh)
1559      {
1560         cy += (ch - mh) / 2;
1561         ch = mh;
1562      }
1563    evas_object_move(sd->hoversel, x + cx, y + cy);
1564    evas_object_resize(sd->hoversel, cw, ch);
1565 }
1566
1567 static void
1568 _hover_del_job(void *data)
1569 {
1570    ELM_ENTRY_DATA_GET(data, sd);
1571
1572    if (sd->hoversel)
1573      {
1574         evas_object_del(sd->hoversel);
1575         sd->hoversel = NULL;
1576      }
1577    sd->hov_deljob = NULL;
1578 }
1579
1580 static void
1581 _hover_dismissed_cb(void *data,
1582                     Evas_Object *obj __UNUSED__,
1583                     void *event_info __UNUSED__)
1584 {
1585    ELM_ENTRY_DATA_GET(data, sd);
1586
1587    sd->use_down = 0;
1588    if (sd->hoversel) evas_object_hide(sd->hoversel);
1589    if (sd->sel_mode)
1590      {
1591         if (!_elm_config->desktop_entry)
1592           {
1593              if (!sd->password)
1594                edje_object_part_text_select_allow_set
1595                  (sd->entry_edje, "elm.text", EINA_TRUE);
1596           }
1597      }
1598    elm_widget_scroll_freeze_pop(data);
1599    if (sd->hov_deljob) ecore_job_del(sd->hov_deljob);
1600    sd->hov_deljob = ecore_job_add(_hover_del_job, data);
1601 }
1602
1603 static void
1604 _hover_selected_cb(void *data,
1605                    Evas_Object *obj __UNUSED__,
1606                    void *event_info __UNUSED__)
1607 {
1608    ELM_ENTRY_DATA_GET(data, sd);
1609
1610    sd->sel_mode = EINA_TRUE;
1611    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
1612
1613    if (!_elm_config->desktop_entry)
1614      {
1615         if (!sd->password)
1616           edje_object_part_text_select_allow_set
1617             (sd->entry_edje, "elm.text", EINA_TRUE);
1618      }
1619    edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
1620
1621    if (!_elm_config->desktop_entry)
1622      {
1623         elm_widget_scroll_hold_push(data);
1624         sd->scroll_holding = EINA_TRUE;
1625      }
1626 }
1627
1628 static char *
1629 _item_tags_remove(const char *str)
1630 {
1631    char *ret;
1632    Eina_Strbuf *buf;
1633
1634    if (!str)
1635      return NULL;
1636
1637    buf = eina_strbuf_new();
1638    if (!buf)
1639      return NULL;
1640
1641    if (!eina_strbuf_append(buf, str))
1642      {
1643         eina_strbuf_free(buf);
1644         return NULL;
1645      }
1646
1647    while (EINA_TRUE)
1648      {
1649         const char *temp = eina_strbuf_string_get(buf);
1650         char *start_tag = NULL;
1651         char *end_tag = NULL;
1652         size_t sindex;
1653         size_t eindex;
1654
1655         start_tag = strstr(temp, "<item");
1656         if (!start_tag)
1657           start_tag = strstr(temp, "</item");
1658         if (start_tag)
1659           end_tag = strstr(start_tag, ">");
1660         else
1661           break;
1662         if (!end_tag || start_tag > end_tag)
1663           break;
1664
1665         sindex = start_tag - temp;
1666         eindex = end_tag - temp + 1;
1667         if (!eina_strbuf_remove(buf, sindex, eindex))
1668           break;
1669      }
1670
1671    ret = eina_strbuf_string_steal(buf);
1672    eina_strbuf_free(buf);
1673
1674    return ret;
1675 }
1676
1677 void
1678 _elm_entry_entry_paste(Evas_Object *obj,
1679                        const char *entry)
1680 {
1681    char *str = NULL;
1682
1683    ELM_ENTRY_CHECK(obj);
1684    ELM_ENTRY_DATA_GET(obj, sd);
1685
1686    if (sd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
1687      {
1688         str = _item_tags_remove(entry);
1689         if (!str) str = strdup(entry);
1690      }
1691    else
1692      str = strdup(entry);
1693    if (!str) str = (char *)entry;
1694
1695    edje_object_part_text_user_insert(sd->entry_edje, "elm.text", str);
1696
1697    if (str != entry) free(str);
1698
1699    // TIZEN ONLY
1700 #ifdef HAVE_ELEMENTARY_X
1701    if (elm_widget_focus_get(obj))
1702      ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1703 #endif
1704    //
1705 }
1706
1707 static void
1708 _paste_cb(void *data,
1709           Evas_Object *obj __UNUSED__,
1710           void *event_info __UNUSED__)
1711 {
1712    ELM_ENTRY_DATA_GET(data, sd);
1713
1714    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1715    if (sd->sel_notify_handler)
1716      {
1717 #ifdef HAVE_ELEMENTARY_X
1718         Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1719
1720         sd->selection_asked = EINA_TRUE;
1721
1722         if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1723           formats = ELM_SEL_FORMAT_TEXT;
1724         else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1725           formats |= ELM_SEL_FORMAT_IMAGE;
1726
1727         elm_cnp_selection_get
1728           (data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1729 #endif
1730      }
1731    else
1732      {
1733 #ifdef HAVE_ELEMENTARY_WAYLAND
1734         Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1735         sd->selection_asked = EINA_TRUE;
1736         if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1737            formats = ELM_SEL_FORMAT_TEXT;
1738         else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1739            formats |= ELM_SEL_FORMAT_IMAGE;
1740         elm_cnp_selection_get(data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1741 #endif
1742      }
1743 }
1744
1745 static void
1746 _selection_store(Elm_Sel_Type seltype,
1747                  Evas_Object *obj)
1748 {
1749    const char *sel;
1750
1751    ELM_ENTRY_DATA_GET(obj, sd);
1752
1753    sel = edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
1754    if ((!sel) || (!sel[0])) return;  /* avoid deleting our own selection */
1755
1756    elm_cnp_selection_set
1757      (obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1758    if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1759      eina_stringshare_replace(&sd->cut_sel, sel);
1760 }
1761
1762 static void
1763 _cut_cb(void *data,
1764         Evas_Object *obj __UNUSED__,
1765         void *event_info __UNUSED__)
1766 {
1767    ELM_ENTRY_DATA_GET(data, sd);
1768
1769    /* Store it */
1770    sd->sel_mode = EINA_FALSE;
1771    if (!_elm_config->desktop_entry)
1772      edje_object_part_text_select_allow_set
1773        (sd->entry_edje, "elm.text", EINA_FALSE);
1774    edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1775
1776    if ((!_elm_config->desktop_entry) && (sd->scroll_holding))
1777      {
1778         elm_widget_scroll_hold_pop(data);
1779         sd->scroll_holding = EINA_FALSE;
1780      }
1781
1782    _selection_store(ELM_SEL_TYPE_CLIPBOARD, data);
1783    edje_object_part_text_user_insert(sd->entry_edje, "elm.text", "");
1784    elm_layout_sizing_eval(data);
1785 }
1786
1787 static void
1788 _copy_cb(void *data,
1789          Evas_Object *obj __UNUSED__,
1790          void *event_info __UNUSED__)
1791 {
1792    ELM_ENTRY_DATA_GET(data, sd);
1793
1794    // TIZEN ONLY
1795    //sd->sel_mode = EINA_FALSE;
1796    sd->sel_mode = EINA_TRUE;
1797    //
1798
1799    if (!_elm_config->desktop_entry)
1800      {
1801         //edje_object_part_text_select_allow_set      // TIZEN ONLY
1802         //  (sd->entry_edje, "elm.text", EINA_FALSE);
1803         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1804         if (sd->scroll_holding)
1805           {
1806              elm_widget_scroll_hold_pop(data);
1807              sd->scroll_holding = EINA_FALSE;
1808           }
1809      }
1810    _selection_store(ELM_SEL_TYPE_CLIPBOARD, data);
1811 }
1812
1813 static void
1814 _hover_cancel_cb(void *data,
1815                  Evas_Object *obj __UNUSED__,
1816                  void *event_info __UNUSED__)
1817 {
1818    ELM_ENTRY_DATA_GET(data, sd);
1819
1820    sd->sel_mode = EINA_FALSE;
1821    if (!_elm_config->desktop_entry)
1822      edje_object_part_text_select_allow_set
1823        (sd->entry_edje, "elm.text", EINA_FALSE);
1824    edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1825    if ((!_elm_config->desktop_entry) && (sd->scroll_holding))
1826      {
1827         elm_widget_scroll_hold_pop(data);
1828         sd->scroll_holding = EINA_FALSE;
1829      }
1830    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
1831 }
1832
1833 static void
1834 _hover_item_clicked_cb(void *data,
1835                        Evas_Object *obj __UNUSED__,
1836                        void *event_info __UNUSED__)
1837 {
1838    Elm_Entry_Context_Menu_Item *it = data;
1839    Evas_Object *obj2 = it->obj;
1840
1841    if (it->func) it->func(it->data, obj2, NULL);
1842 }
1843
1844 static void
1845 _menu_call(Evas_Object *obj)
1846 {
1847    Evas_Object *top;
1848    const Eina_List *l;
1849    const Elm_Entry_Context_Menu_Item *it;
1850
1851    ELM_ENTRY_DATA_GET(obj, sd);
1852
1853    if ((sd->api) && (sd->api->obj_longpress))
1854      {
1855         sd->api->obj_longpress(obj);
1856      }
1857    else if (sd->context_menu)
1858      {
1859         const char *context_menu_orientation;
1860
1861         if (sd->hoversel) evas_object_del(sd->hoversel);
1862         else elm_widget_scroll_freeze_push(obj);
1863
1864         sd->hoversel = elm_hoversel_add(obj);
1865         context_menu_orientation = edje_object_data_get
1866             (sd->entry_edje, "context_menu_orientation");
1867
1868         if ((context_menu_orientation) &&
1869             (!strcmp(context_menu_orientation, "horizontal")))
1870           elm_hoversel_horizontal_set(sd->hoversel, EINA_TRUE);
1871
1872         elm_object_style_set(sd->hoversel, "entry");
1873         elm_widget_sub_object_add(obj, sd->hoversel);
1874         elm_object_text_set(sd->hoversel, "Text");
1875         top = elm_widget_top_get(obj);
1876
1877         if (top) elm_hoversel_hover_parent_set(sd->hoversel, top);
1878
1879         evas_object_smart_callback_add
1880           (sd->hoversel, "dismissed", _hover_dismissed_cb, obj);
1881         if (sd->have_selection)
1882           {
1883              if (!sd->password)
1884                {
1885                   elm_hoversel_item_add
1886                      (sd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1887                       _copy_cb, obj);
1888                   if (sd->editable)
1889                     elm_hoversel_item_add
1890                        (sd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1891                         _cut_cb, obj);
1892                   elm_hoversel_item_add
1893                     (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1894                     _hover_cancel_cb, obj);
1895                }
1896           }
1897         else
1898           {
1899              if (!sd->sel_mode)
1900                {
1901                   if (!_elm_config->desktop_entry)
1902                     {
1903                        if (!sd->password)
1904                          elm_hoversel_item_add
1905                            (sd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1906                            _hover_selected_cb, obj);
1907                     }
1908                   if (elm_selection_selection_has_owner(obj))
1909                     {
1910                        if (sd->editable)
1911                          elm_hoversel_item_add
1912                            (sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1913                            _paste_cb, obj);
1914                     }
1915                }
1916              else
1917                elm_hoversel_item_add
1918                   (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1919                    _hover_cancel_cb, obj);
1920           }
1921
1922         EINA_LIST_FOREACH(sd->items, l, it)
1923           {
1924              elm_hoversel_item_add(sd->hoversel, it->label, it->icon_file,
1925                                    it->icon_type, _hover_item_clicked_cb, it);
1926           }
1927
1928         if (sd->hoversel)
1929           {
1930              _hoversel_position(obj);
1931              evas_object_show(sd->hoversel);
1932              elm_hoversel_hover_begin(sd->hoversel);
1933           }
1934
1935         if (!_elm_config->desktop_entry)
1936           {
1937              edje_object_part_text_select_allow_set
1938                (sd->entry_edje, "elm.text", EINA_FALSE);
1939              edje_object_part_text_select_abort(sd->entry_edje, "elm.text");
1940           }
1941      }
1942 }
1943
1944 static Eina_Bool
1945 _long_press_cb(void *data)
1946 {
1947    ELM_ENTRY_DATA_GET(data, sd);
1948
1949    if (!_elm_config->desktop_entry && !sd->magnifier_enabled) // TIZEN ONLY
1950      _menu_call(data);
1951
1952    sd->longpress_timer = NULL;
1953    evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1954
1955    return ECORE_CALLBACK_CANCEL;
1956 }
1957
1958 // TIZEN ONLY - START
1959 static Eina_Bool
1960 _click_cb(void *data)
1961 {
1962    ELM_ENTRY_DATA_GET(data, sd);
1963
1964    sd->click_timer = NULL;
1965    if ((!_elm_config->desktop_entry) && sd->mouse_upped && sd->editable)
1966      {
1967         _menu_call(data);
1968      }
1969    return ECORE_CALLBACK_CANCEL;
1970 }
1971 // TIZEN ONLY - END
1972
1973 static void
1974 _mouse_down_cb(void *data,
1975                Evas *evas __UNUSED__,
1976                Evas_Object *obj __UNUSED__,
1977                void *event_info)
1978 {
1979    Evas_Event_Mouse_Down *ev = event_info;
1980
1981    ELM_ENTRY_DATA_GET(data, sd);
1982
1983    if (sd->disabled) return;
1984    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1985    sd->downx = ev->canvas.x;
1986    sd->downy = ev->canvas.y;
1987    sd->long_pressed = EINA_FALSE;
1988    if (ev->button == 1)
1989      {
1990         if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer);
1991         sd->longpress_timer = ecore_timer_add
1992             (_elm_config->longpress_timeout, _long_press_cb, data);
1993
1994         // TIZEN ONLY - START
1995         if (sd->click_timer)
1996           {
1997              ecore_timer_del(sd->click_timer); // avoid double click
1998              sd->click_timer = NULL;
1999           }
2000         else
2001           {
2002              if (!sd->have_selection)
2003                sd->click_timer = ecore_timer_add (0.2, _click_cb, data); //FIXME: time out
2004           }
2005         sd->mouse_upped = EINA_FALSE;
2006         // TIZEN ONLY - END
2007      }
2008    else if (ev->button == 3)
2009      {
2010         if (_elm_config->desktop_entry)
2011           _menu_call(data);
2012      }
2013    if (!sd->editable)
2014      {
2015          edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", EINA_TRUE);
2016      }
2017    else if (!sd->cursor_handler_disabled)
2018      {
2019          edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", EINA_FALSE);
2020      }
2021 }
2022
2023 static void
2024 _mouse_up_cb(void *data,
2025              Evas *evas __UNUSED__,
2026              Evas_Object *obj __UNUSED__,
2027              void *event_info)
2028 {
2029    Evas_Event_Mouse_Up *ev = event_info;
2030
2031    ELM_ENTRY_DATA_GET(data, sd);
2032
2033    if (sd->disabled) return;
2034    if (ev->button == 1)
2035      {
2036         // TIZEN ONLY
2037         if (!sd->double_clicked)
2038           {
2039              if ((sd->api) && (sd->api->obj_mouseup))
2040                sd->api->obj_mouseup(data);
2041           }
2042         if (sd->magnifier_enabled)
2043           {
2044              _magnifier_hide(data);
2045              if (sd->long_pressed) _menu_call(data);
2046           }
2047         if (sd->click_timer)
2048           {
2049              if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2050                {
2051                   ecore_timer_del(sd->click_timer);
2052                   sd->click_timer = NULL;
2053                }
2054           }
2055         sd->mouse_upped = EINA_TRUE;
2056         /////
2057         if (sd->longpress_timer)
2058           {
2059              ecore_timer_del(sd->longpress_timer);
2060              sd->longpress_timer = NULL;
2061           }
2062      }
2063    else if ((ev->button == 3) && (!_elm_config->desktop_entry))
2064      {
2065         sd->use_down = 1;
2066         _menu_call(data);
2067      }
2068 }
2069
2070 static void
2071 _mouse_move_cb(void *data,
2072                Evas *evas __UNUSED__,
2073                Evas_Object *obj __UNUSED__,
2074                void *event_info)
2075 {
2076    Evas_Event_Mouse_Move *ev = event_info;
2077
2078    ELM_ENTRY_DATA_GET(data, sd);
2079
2080    if (sd->disabled) return;
2081
2082    // TIZEN ONLY
2083    if (ev->buttons == 1)
2084      {
2085         if ((sd->long_pressed) && (sd->magnifier_enabled))
2086           {
2087              _magnifier_show(data);
2088              _magnifier_move(data);
2089           }
2090      }
2091    //////////
2092
2093    if (!sd->sel_mode)
2094      {
2095         if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2096           {
2097              if (sd->longpress_timer)
2098                {
2099                   ecore_timer_del(sd->longpress_timer);
2100                   sd->longpress_timer = NULL;
2101                }
2102           }
2103         else if (sd->longpress_timer)
2104           {
2105              Evas_Coord dx, dy;
2106
2107              dx = sd->downx - ev->cur.canvas.x;
2108              dx *= dx;
2109              dy = sd->downy - ev->cur.canvas.y;
2110              dy *= dy;
2111              if ((dx + dy) >
2112                  ((_elm_config->finger_size / 2) *
2113                   (_elm_config->finger_size / 2)))
2114                {
2115                   ecore_timer_del(sd->longpress_timer);
2116                   sd->longpress_timer = NULL;
2117                }
2118           }
2119      }
2120    else if (sd->longpress_timer)
2121      {
2122         Evas_Coord dx, dy;
2123
2124         dx = sd->downx - ev->cur.canvas.x;
2125         dx *= dx;
2126         dy = sd->downy - ev->cur.canvas.y;
2127         dy *= dy;
2128         if ((dx + dy) >
2129             ((_elm_config->finger_size / 2) *
2130              (_elm_config->finger_size / 2)))
2131           {
2132              ecore_timer_del(sd->longpress_timer);
2133              sd->longpress_timer = NULL;
2134           }
2135      }
2136 }
2137
2138 static void
2139 _entry_changed_handle(void *data,
2140                       const char *event)
2141 {
2142    Evas_Coord minh;
2143    const char *text;
2144
2145    ELM_ENTRY_DATA_GET(data, sd);
2146
2147    evas_event_freeze(evas_object_evas_get(data));
2148    sd->changed = EINA_TRUE;
2149    /* Reset the size hints which are no more relevant. Keep the
2150     * height, this is a hack, but doesn't really matter cause we'll
2151     * re-eval in a moment. */
2152    evas_object_size_hint_min_get(data, NULL, &minh);
2153    evas_object_size_hint_min_set(data, -1, minh);
2154
2155    elm_layout_sizing_eval(data);
2156    if (sd->text) eina_stringshare_del(sd->text);
2157    sd->text = NULL;
2158
2159    // TIZEN ONLY
2160    if (sd->password_text)
2161      eina_stringshare_del(sd->password_text);
2162    sd->password_text = NULL;
2163
2164    if ((sd->api) && (sd->api->obj_hidemenu))
2165      sd->api->obj_hidemenu(data);
2166    /////
2167
2168    if (sd->delay_write)
2169      {
2170         ecore_timer_del(sd->delay_write);
2171         sd->delay_write = NULL;
2172      }
2173    evas_event_thaw(evas_object_evas_get(data));
2174    evas_event_thaw_eval(evas_object_evas_get(data));
2175    if ((sd->auto_save) && (sd->file))
2176      sd->delay_write = ecore_timer_add(2.0, _delay_write, data);
2177
2178    _return_key_enabled_check(data);
2179    text = edje_object_part_text_get(sd->entry_edje, "elm.text");
2180    if (text)
2181      {
2182         if (text[0])
2183           _elm_entry_guide_update(data, EINA_TRUE);
2184         else
2185           _elm_entry_guide_update(data, EINA_FALSE);
2186      }
2187    /* callback - this could call callbacks that delete the
2188     * entry... thus... any access to sd after this could be
2189     * invalid */
2190    evas_object_smart_callback_call(data, event, NULL);
2191 }
2192
2193 static void
2194 _entry_changed_signal_cb(void *data,
2195                          Evas_Object *obj __UNUSED__,
2196                          const char *emission __UNUSED__,
2197                          const char *source __UNUSED__)
2198 {
2199    _entry_changed_handle(data, SIG_CHANGED);
2200 }
2201
2202 static void
2203 _entry_changed_user_signal_cb(void *data,
2204                               Evas_Object *obj __UNUSED__,
2205                               const char *emission __UNUSED__,
2206                               const char *source __UNUSED__)
2207 {
2208    Elm_Entry_Change_Info info;
2209    Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
2210      edje_object_signal_callback_extra_data_get();
2211
2212    if (edje_info)
2213      {
2214         memcpy(&info, edje_info, sizeof(info));
2215         evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
2216      }
2217    else
2218      {
2219         evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
2220      }
2221 }
2222
2223 static void
2224 _entry_preedit_changed_signal_cb(void *data,
2225                                  Evas_Object *obj __UNUSED__,
2226                                  const char *emission __UNUSED__,
2227                                  const char *source __UNUSED__)
2228 {
2229    _entry_changed_handle(data, SIG_PREEDIT_CHANGED);
2230 }
2231
2232 static void
2233 _entry_undo_request_signal_cb(void *data,
2234                               Evas_Object *obj __UNUSED__,
2235                               const char *emission __UNUSED__,
2236                               const char *source __UNUSED__)
2237 {
2238    evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
2239 }
2240
2241 static void
2242 _entry_redo_request_signal_cb(void *data,
2243                               Evas_Object *obj __UNUSED__,
2244                               const char *emission __UNUSED__,
2245                               const char *source __UNUSED__)
2246 {
2247    evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
2248 }
2249
2250 static void
2251 _entry_selection_start_signal_cb(void *data,
2252                                  Evas_Object *obj __UNUSED__,
2253                                  const char *emission __UNUSED__,
2254                                  const char *source __UNUSED__)
2255 {
2256    const Eina_List *l;
2257    Evas_Object *entry;
2258
2259    ELM_ENTRY_DATA_GET(data, sd);
2260
2261    if (!elm_object_focus_get(data)) elm_object_focus_set(data, EINA_TRUE);
2262    EINA_LIST_FOREACH(entries, l, entry)
2263      {
2264         if (entry != data) elm_entry_select_none(entry);
2265      }
2266
2267    // TIZEN ONLY
2268    sd->sel_mode = EINA_TRUE;
2269    ///
2270
2271    evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2272 #ifdef HAVE_ELEMENTARY_X
2273    if (sd->sel_notify_handler)
2274      {
2275         const char *txt = elm_entry_selection_get(data);
2276         Evas_Object *top;
2277
2278         top = elm_widget_top_get(data);
2279         if (txt && top && (elm_win_xwindow_get(top)))
2280           elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2281                                 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
2282      }
2283 #endif
2284 }
2285
2286 static void
2287 _entry_selection_all_signal_cb(void *data,
2288                                Evas_Object *obj __UNUSED__,
2289                                const char *emission __UNUSED__,
2290                                const char *source __UNUSED__)
2291 {
2292    elm_entry_select_all(data);
2293 }
2294
2295 static void
2296 _entry_selection_none_signal_cb(void *data,
2297                                 Evas_Object *obj __UNUSED__,
2298                                 const char *emission __UNUSED__,
2299                                 const char *source __UNUSED__)
2300 {
2301    ELM_ENTRY_DATA_GET(data, sd); // TIZEN ONLY
2302
2303    elm_entry_select_none(data);
2304
2305    // TIZEN ONLY
2306    if ((sd->api) && (sd->api->obj_hidemenu))
2307      sd->api->obj_hidemenu(data);
2308    /////
2309
2310 }
2311
2312 static void
2313 _entry_selection_changed_signal_cb(void *data,
2314                                    Evas_Object *obj __UNUSED__,
2315                                    const char *emission __UNUSED__,
2316                                    const char *source __UNUSED__)
2317 {
2318    ELM_ENTRY_DATA_GET(data, sd);
2319    Evas_Coord cx, cy, cw, ch; // TIZEN ONLY
2320
2321    sd->have_selection = EINA_TRUE;
2322    sd->sel_mode = EINA_TRUE; // TIZEN ONLY
2323    evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2324    _selection_store(ELM_SEL_TYPE_PRIMARY, data);
2325
2326    // TIZEN ONLY
2327    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
2328    if (!sd->deferred_recalc_job)
2329      elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2330    else
2331      {
2332         sd->deferred_cur = EINA_TRUE;
2333         sd->cx = cx;
2334         sd->cy = cy;
2335         sd->cw = cw;
2336         sd->ch = ch;
2337      }
2338    ///////
2339 }
2340
2341 static void
2342 _entry_selection_cleared_signal_cb(void *data,
2343                                    Evas_Object *obj __UNUSED__,
2344                                    const char *emission __UNUSED__,
2345                                    const char *source __UNUSED__)
2346 {
2347    ELM_ENTRY_DATA_GET(data, sd);
2348
2349    if (!sd->have_selection) return;
2350
2351    sd->have_selection = EINA_FALSE;
2352
2353    // TIZEN ONLY
2354    sd->sel_mode = EINA_FALSE;
2355    ///
2356
2357    evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2358    if (sd->sel_notify_handler)
2359      {
2360         if (sd->cut_sel)
2361           {
2362 #ifdef HAVE_ELEMENTARY_X
2363              Evas_Object *top;
2364
2365              top = elm_widget_top_get(data);
2366              if ((top) && (elm_win_xwindow_get(top)))
2367                elm_cnp_selection_set
2368                  (data, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_MARKUP,
2369                  sd->cut_sel, strlen(sd->cut_sel));
2370 #endif
2371              eina_stringshare_del(sd->cut_sel);
2372              sd->cut_sel = NULL;
2373           }
2374         else
2375           {
2376 #ifdef HAVE_ELEMENTARY_X
2377              Evas_Object *top;
2378
2379              top = elm_widget_top_get(data);
2380              if ((top) && (elm_win_xwindow_get(top)))
2381                elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
2382 #endif
2383           }
2384      }
2385
2386    // TIZEN ONLY
2387    if ((sd->api) && (sd->api->obj_hidemenu))
2388      {
2389         sd->api->obj_hidemenu(data);
2390      }
2391    /////
2392 }
2393
2394 static void
2395 _entry_paste_request_signal_cb(void *data,
2396                                Evas_Object *obj __UNUSED__,
2397                                const char *emission,
2398                                const char *source __UNUSED__)
2399 {
2400    ELM_ENTRY_DATA_GET(data, sd);
2401
2402 #ifdef HAVE_ELEMENTARY_X
2403    Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
2404      ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
2405 #endif
2406
2407    if (!sd->editable) return;
2408    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2409    if (sd->sel_notify_handler)
2410      {
2411 #ifdef HAVE_ELEMENTARY_X
2412         Evas_Object *top;
2413
2414         top = elm_widget_top_get(data);
2415         if ((top) && (elm_win_xwindow_get(top)))
2416           {
2417              Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2418
2419              sd->selection_asked = EINA_TRUE;
2420
2421              if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2422                formats = ELM_SEL_FORMAT_TEXT;
2423              else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2424                formats |= ELM_SEL_FORMAT_IMAGE;
2425
2426              elm_cnp_selection_get(data, type, formats, NULL, NULL);
2427           }
2428 #endif
2429      }
2430 }
2431
2432 static void
2433 _entry_copy_notify_signal_cb(void *data,
2434                              Evas_Object *obj __UNUSED__,
2435                              const char *emission __UNUSED__,
2436                              const char *source __UNUSED__)
2437 {
2438    evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2439    _copy_cb(data, NULL, NULL);
2440 }
2441
2442 static void
2443 _entry_cut_notify_signal_cb(void *data,
2444                             Evas_Object *obj __UNUSED__,
2445                             const char *emission __UNUSED__,
2446                             const char *source __UNUSED__)
2447 {
2448    evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2449    _cut_cb(data, NULL, NULL);
2450 }
2451
2452 static void
2453 _entry_cursor_changed_signal_cb(void *data,
2454                                 Evas_Object *obj __UNUSED__,
2455                                 const char *emission __UNUSED__,
2456                                 const char *source __UNUSED__)
2457 {
2458    ELM_ENTRY_DATA_GET(data, sd);
2459    sd->cursor_pos = edje_object_part_text_cursor_pos_get
2460        (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
2461    sd->cur_changed = EINA_TRUE;
2462    _cursor_geometry_recalc(data);
2463 }
2464
2465 static void
2466 _entry_cursor_changed_manual_signal_cb(void *data,
2467                                        Evas_Object *obj __UNUSED__,
2468                                        const char *emission __UNUSED__,
2469                                        const char *source __UNUSED__)
2470 {
2471    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
2472 }
2473
2474 static void
2475 _signal_anchor_geoms_do_things_with_lol(Elm_Entry_Smart_Data *sd,
2476                                         Elm_Entry_Anchor_Info *ei)
2477 {
2478    Evas_Textblock_Rectangle *r;
2479    const Eina_List *geoms, *l;
2480    Evas_Coord px, py, x, y;
2481
2482    geoms = edje_object_part_text_anchor_geometry_get
2483        (sd->entry_edje, "elm.text", ei->name);
2484
2485    if (!geoms) return;
2486
2487    evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
2488    evas_pointer_canvas_xy_get
2489      (evas_object_evas_get(sd->entry_edje), &px, &py);
2490
2491    EINA_LIST_FOREACH(geoms, l, r)
2492      {
2493         if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2494             ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2495           {
2496              ei->x = r->x + x;
2497              ei->y = r->y + y;
2498              ei->w = r->w;
2499              ei->h = r->h;
2500              break;
2501           }
2502      }
2503 }
2504
2505 static void
2506 _entry_anchor_down_signal_cb(void *data,
2507                              Evas_Object *obj __UNUSED__,
2508                              const char *emission __UNUSED__,
2509                              const char *source __UNUSED__)
2510 {
2511    Elm_Entry_Anchor_Info ei;
2512    const char *p;
2513    char *p2;
2514
2515    ELM_ENTRY_DATA_GET(data, sd);
2516
2517    p = emission + sizeof("nchor,mouse,down,");
2518    ei.button = strtol(p, &p2, 10);
2519    ei.name = p2 + 1;
2520    ei.x = ei.y = ei.w = ei.h = 0;
2521
2522    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2523
2524    if (!sd->disabled)
2525      evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
2526 }
2527
2528 static void
2529 _entry_anchor_up_signal_cb(void *data,
2530                            Evas_Object *obj __UNUSED__,
2531                            const char *emission __UNUSED__,
2532                            const char *source __UNUSED__)
2533 {
2534    Elm_Entry_Anchor_Info ei;
2535    const char *p;
2536    char *p2;
2537
2538    ELM_ENTRY_DATA_GET(data, sd);
2539
2540    p = emission + sizeof("nchor,mouse,up,");
2541    ei.button = strtol(p, &p2, 10);
2542    ei.name = p2 + 1;
2543    ei.x = ei.y = ei.w = ei.h = 0;
2544
2545    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2546
2547    if (!sd->disabled)
2548      evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
2549 }
2550
2551 static void
2552 _anchor_hover_del_cb(void *data,
2553                      Evas *e __UNUSED__,
2554                      Evas_Object *obj __UNUSED__,
2555                      void *event_info __UNUSED__)
2556 {
2557    ELM_ENTRY_DATA_GET(data, sd);
2558
2559    if (sd->anchor_hover.pop) evas_object_del(sd->anchor_hover.pop);
2560    sd->anchor_hover.pop = NULL;
2561    evas_object_event_callback_del_full
2562      (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
2563 }
2564
2565 static void
2566 _anchor_hover_clicked_cb(void *data,
2567                          Evas_Object *obj __UNUSED__,
2568                          void *event_info __UNUSED__)
2569 {
2570    elm_entry_anchor_hover_end(data);
2571 }
2572
2573 static void
2574 _entry_hover_anchor_clicked_do(Evas_Object *obj,
2575                                Elm_Entry_Anchor_Info *info)
2576 {
2577    Evas_Object *hover_parent;
2578    Evas_Coord x, w, y, h, px, py;
2579    Elm_Entry_Anchor_Hover_Info ei;
2580
2581    ELM_ENTRY_DATA_GET(obj, sd);
2582
2583    ei.anchor_info = info;
2584
2585    sd->anchor_hover.pop = elm_icon_add(obj);
2586    evas_object_move(sd->anchor_hover.pop, info->x, info->y);
2587    evas_object_resize(sd->anchor_hover.pop, info->w, info->h);
2588
2589    sd->anchor_hover.hover = elm_hover_add(obj);
2590    evas_object_event_callback_add
2591      (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
2592    elm_widget_mirrored_set
2593      (sd->anchor_hover.hover, elm_widget_mirrored_get(obj));
2594    if (sd->anchor_hover.hover_style)
2595      elm_object_style_set
2596        (sd->anchor_hover.hover, sd->anchor_hover.hover_style);
2597
2598    hover_parent = sd->anchor_hover.hover_parent;
2599    if (!hover_parent) hover_parent = obj;
2600    elm_hover_parent_set(sd->anchor_hover.hover, hover_parent);
2601    elm_hover_target_set(sd->anchor_hover.hover, sd->anchor_hover.pop);
2602    ei.hover = sd->anchor_hover.hover;
2603
2604    evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
2605    ei.hover_parent.x = x;
2606    ei.hover_parent.y = y;
2607    ei.hover_parent.w = w;
2608    ei.hover_parent.h = h;
2609    px = info->x + (info->w / 2);
2610    py = info->y + (info->h / 2);
2611    ei.hover_left = 1;
2612    if (px < (x + (w / 3))) ei.hover_left = 0;
2613    ei.hover_right = 1;
2614    if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
2615    ei.hover_top = 1;
2616    if (py < (y + (h / 3))) ei.hover_top = 0;
2617    ei.hover_bottom = 1;
2618    if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
2619
2620    /* Swap right and left because they switch sides in RTL */
2621    if (elm_widget_mirrored_get(sd->anchor_hover.hover))
2622      {
2623         Eina_Bool tmp = ei.hover_left;
2624
2625         ei.hover_left = ei.hover_right;
2626         ei.hover_right = tmp;
2627      }
2628
2629    evas_object_smart_callback_call(obj, SIG_ANCHOR_HOVER_OPENED, &ei);
2630    evas_object_smart_callback_add
2631      (sd->anchor_hover.hover, "clicked", _anchor_hover_clicked_cb, obj);
2632
2633    /* FIXME: Should just check if there's any callback registered to
2634     * the smart events instead.  This is used to determine if anyone
2635     * cares about the hover or not. */
2636    if (!elm_layout_content_get(sd->anchor_hover.hover, "middle") &&
2637        !elm_layout_content_get(sd->anchor_hover.hover, "left") &&
2638        !elm_layout_content_get(sd->anchor_hover.hover, "right") &&
2639        !elm_layout_content_get(sd->anchor_hover.hover, "top") &&
2640        !elm_layout_content_get(sd->anchor_hover.hover, "bottom"))
2641      {
2642         evas_object_del(sd->anchor_hover.hover);
2643         sd->anchor_hover.hover = NULL;
2644      }
2645    else
2646      evas_object_show(sd->anchor_hover.hover);
2647 }
2648
2649 static void
2650 _entry_anchor_clicked_signal_cb(void *data,
2651                                 Evas_Object *obj __UNUSED__,
2652                                 const char *emission,
2653                                 const char *source __UNUSED__)
2654 {
2655    Elm_Entry_Anchor_Info ei;
2656    const char *p;
2657    char *p2;
2658
2659    ELM_ENTRY_DATA_GET(data, sd);
2660
2661    p = emission + sizeof("nchor,mouse,clicked,");
2662    ei.button = strtol(p, &p2, 10);
2663    ei.name = p2 + 1;
2664    ei.x = ei.y = ei.w = ei.h = 0;
2665
2666    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2667
2668    if (!sd->disabled)
2669      {
2670         evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2671
2672         _entry_hover_anchor_clicked_do(data, &ei);
2673      }
2674 }
2675
2676 static void
2677 _entry_anchor_move_signal_cb(void *data __UNUSED__,
2678                              Evas_Object *obj __UNUSED__,
2679                              const char *emission __UNUSED__,
2680                              const char *source __UNUSED__)
2681 {
2682 }
2683
2684 static void
2685 _entry_anchor_in_signal_cb(void *data,
2686                            Evas_Object *obj __UNUSED__,
2687                            const char *emission __UNUSED__,
2688                            const char *source __UNUSED__)
2689 {
2690    Elm_Entry_Anchor_Info ei;
2691
2692    ELM_ENTRY_DATA_GET(data, sd);
2693
2694    ei.name = emission + sizeof("nchor,mouse,in,");
2695    ei.button = 0;
2696    ei.x = ei.y = ei.w = ei.h = 0;
2697
2698    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2699
2700    if (!sd->disabled)
2701      evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
2702 }
2703
2704 static void
2705 _entry_anchor_out_signal_cb(void *data,
2706                             Evas_Object *obj __UNUSED__,
2707                             const char *emission __UNUSED__,
2708                             const char *source __UNUSED__)
2709 {
2710    Elm_Entry_Anchor_Info ei;
2711
2712    ELM_ENTRY_DATA_GET(data, sd);
2713
2714    ei.name = emission + sizeof("nchor,mouse,out,");
2715    ei.button = 0;
2716    ei.x = ei.y = ei.w = ei.h = 0;
2717
2718    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2719
2720    if (!sd->disabled)
2721      evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
2722 }
2723
2724 static void
2725 _entry_key_enter_signal_cb(void *data,
2726                            Evas_Object *obj __UNUSED__,
2727                            const char *emission __UNUSED__,
2728                            const char *source __UNUSED__)
2729 {
2730    evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2731 }
2732
2733 static void
2734 _entry_key_escape_signal_cb(void *data,
2735                             Evas_Object *obj __UNUSED__,
2736                             const char *emission __UNUSED__,
2737                             const char *source __UNUSED__)
2738 {
2739    evas_object_smart_callback_call(data, SIG_ABORTED, NULL);
2740 }
2741
2742 static void
2743 _entry_mouse_down_signal_cb(void *data,
2744                             Evas_Object *obj __UNUSED__,
2745                             const char *emission __UNUSED__,
2746                             const char *source __UNUSED__)
2747 {
2748    // TIZEN ONLY
2749    ELM_ENTRY_DATA_GET(data, sd);
2750    sd->double_clicked = EINA_FALSE;
2751    if ((sd->api) && (sd->api->obj_hidemenu))
2752      sd->api->obj_hidemenu(data);
2753    /////////
2754    evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2755 }
2756
2757 static void
2758 _entry_mouse_clicked_signal_cb(void *data,
2759                                Evas_Object *obj __UNUSED__,
2760                                const char *emission __UNUSED__,
2761                                const char *source __UNUSED__)
2762 {
2763    evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2764 }
2765
2766 static void
2767 _entry_mouse_double_signal_cb(void *data,
2768                               Evas_Object *obj __UNUSED__,
2769                               const char *emission __UNUSED__,
2770                               const char *source __UNUSED__)
2771 {
2772    // TIZEN ONLY
2773    ELM_ENTRY_DATA_GET(data, sd);
2774    if (sd->disabled) return;
2775    sd->double_clicked = EINA_TRUE;
2776    if (!sd->sel_allow) return;
2777
2778    if (sd->click_timer)
2779      {
2780         ecore_timer_del(sd->click_timer);
2781         sd->click_timer = NULL;
2782      }
2783
2784    edje_object_part_text_select_word(sd->entry_edje, "elm.text");
2785    if (!_elm_config->desktop_entry)
2786      edje_object_part_text_select_allow_set
2787         (sd->entry_edje, "elm.text", EINA_TRUE);
2788    /////
2789    evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2790 }
2791
2792 static void
2793 _entry_mouse_triple_signal_cb(void *data,
2794                               Evas_Object *obj __UNUSED__,
2795                               const char *emission __UNUSED__,
2796                               const char *source __UNUSED__)
2797 {
2798    evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
2799 }
2800
2801 #ifdef HAVE_ELEMENTARY_X
2802 static Eina_Bool
2803 _event_selection_notify(void *data,
2804                         int type __UNUSED__,
2805                         void *event)
2806 {
2807    Ecore_X_Event_Selection_Notify *ev = event;
2808
2809    ELM_ENTRY_DATA_GET(data, sd);
2810
2811    if ((!sd->selection_asked) && (!sd->drag_selection_asked))
2812      return ECORE_CALLBACK_PASS_ON;
2813
2814    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2815        (ev->selection == ECORE_X_SELECTION_PRIMARY))
2816      {
2817         Ecore_X_Selection_Data_Text *text_data;
2818
2819         text_data = ev->data;
2820         if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2821           {
2822              if (text_data->text)
2823                {
2824                   char *txt = _elm_util_text_to_mkup(text_data->text);
2825
2826                   if (txt)
2827                     {
2828                        elm_entry_entry_insert(data, txt);
2829                        free(txt);
2830                     }
2831                }
2832           }
2833         sd->selection_asked = EINA_FALSE;
2834      }
2835    else if (ev->selection == ECORE_X_SELECTION_XDND)
2836      {
2837         Ecore_X_Selection_Data_Text *text_data;
2838
2839         text_data = ev->data;
2840         if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2841           {
2842              if (text_data->text)
2843                {
2844                   char *txt = _elm_util_text_to_mkup(text_data->text);
2845
2846                   if (txt)
2847                     {
2848                        /* Massive FIXME: this should be at the drag point */
2849                        elm_entry_entry_insert(data, txt);
2850                        free(txt);
2851                     }
2852                }
2853           }
2854         sd->drag_selection_asked = EINA_FALSE;
2855
2856         ecore_x_dnd_send_finished();
2857      }
2858
2859    return ECORE_CALLBACK_PASS_ON;
2860 }
2861
2862 static Eina_Bool
2863 _event_selection_clear(void *data __UNUSED__,
2864                        int type __UNUSED__,
2865                        void *event __UNUSED__)
2866 {
2867 #if 0
2868    Ecore_X_Event_Selection_Clear *ev = event;
2869
2870    ELM_ENTRY_DATA_GET(data, sd);
2871
2872    if (!sd->have_selection) return ECORE_CALLBACK_PASS_ON;
2873    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2874        (ev->selection == ECORE_X_SELECTION_PRIMARY))
2875      {
2876         elm_entry_select_none(data);
2877      }
2878 #else
2879    /// TIZEN ONLY
2880    Evas_Object *top = elm_widget_top_get(data);
2881    Ecore_X_Event_Selection_Clear *ev = event;
2882
2883    if (!top)
2884       return ECORE_CALLBACK_PASS_ON;
2885
2886    if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2887      {
2888         return ECORE_CALLBACK_PASS_ON;
2889      }
2890
2891    if (elm_widget_focus_get(data))
2892      {
2893         ELM_ENTRY_DATA_GET(data, sd);
2894         Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2895         evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2896         if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2897           formats = ELM_SEL_FORMAT_TEXT;
2898         else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2899           formats |= ELM_SEL_FORMAT_IMAGE;
2900         elm_cnp_selection_get(data, ELM_SEL_TYPE_SECONDARY, formats, NULL, NULL);
2901
2902         return ECORE_CALLBACK_DONE;
2903      }
2904    ///////////
2905 #endif
2906    return ECORE_CALLBACK_PASS_ON;
2907 }
2908
2909 static Eina_Bool
2910 _drag_drop_cb(void *data __UNUSED__,
2911               Evas_Object *obj,
2912               Elm_Selection_Data *drop)
2913 {
2914    Eina_Bool rv;
2915
2916    ELM_ENTRY_DATA_GET(obj, sd);
2917
2918    edje_object_part_text_cursor_copy
2919      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, /*->*/ EDJE_CURSOR_USER);
2920    rv = edje_object_part_text_cursor_coord_set
2921        (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, drop->x, drop->y);
2922
2923    if (!rv) WRN("Warning: Failed to position cursor: paste anyway");
2924
2925    elm_entry_entry_insert(obj, drop->data);
2926    edje_object_part_text_cursor_copy
2927      (sd->entry_edje, "elm.text", EDJE_CURSOR_USER, /*->*/ EDJE_CURSOR_MAIN);
2928
2929    return EINA_TRUE;
2930 }
2931
2932 #endif
2933
2934 static Evas_Object *
2935 _item_get(void *data,
2936           Evas_Object *edje __UNUSED__,
2937           const char *part __UNUSED__,
2938           const char *item)
2939 {
2940    Eina_List *l;
2941    Evas_Object *o;
2942    Elm_Entry_Item_Provider *ip;
2943
2944    ELM_ENTRY_DATA_GET(data, sd);
2945
2946    EINA_LIST_FOREACH(sd->item_providers, l, ip)
2947      {
2948         o = ip->func(ip->data, data, item);
2949         if (o) return o;
2950      }
2951    if (!strncmp(item, "file://", 7))
2952      {
2953         const char *fname = item + 7;
2954
2955         o = evas_object_image_filled_add(evas_object_evas_get(data));
2956         evas_object_image_file_set(o, fname, NULL);
2957         if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2958           {
2959              evas_object_show(o);
2960           }
2961         else
2962           {
2963              evas_object_del(o);
2964              o = edje_object_add(evas_object_evas_get(data));
2965              elm_widget_theme_object_set
2966                (data, o, "entry/emoticon", "wtf",
2967                elm_widget_style_get(data));
2968           }
2969         return o;
2970      }
2971
2972    o = edje_object_add(evas_object_evas_get(data));
2973    if (!elm_widget_theme_object_set
2974          (data, o, "entry", item, elm_widget_style_get(data)))
2975      elm_widget_theme_object_set
2976        (data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2977    return o;
2978 }
2979
2980 static void
2981 _text_filter_cb(void *data,
2982                 Evas_Object *edje __UNUSED__,
2983                 const char *part __UNUSED__,
2984                 Edje_Text_Filter_Type type,
2985                 char **text)
2986 {
2987    Eina_List *l;
2988    Elm_Entry_Markup_Filter *tf;
2989
2990    ELM_ENTRY_DATA_GET(data, sd);
2991
2992    if (type == EDJE_TEXT_FILTER_FORMAT)
2993      return;
2994
2995    EINA_LIST_FOREACH(sd->text_filters, l, tf)
2996      {
2997         tf->func(tf->data, data, text);
2998         if (!*text)
2999           break;
3000      }
3001 }
3002
3003 static void
3004 _markup_filter_cb(void *data,
3005                   Evas_Object *edje __UNUSED__,
3006                   const char *part __UNUSED__,
3007                   char **text)
3008 {
3009    Eina_List *l;
3010    Elm_Entry_Markup_Filter *tf;
3011
3012    ELM_ENTRY_DATA_GET(data, sd);
3013
3014    EINA_LIST_FOREACH(sd->markup_filters, l, tf)
3015      {
3016         tf->func(tf->data, data, text);
3017         if (!*text)
3018           break;
3019      }
3020 }
3021
3022 /* This function is used to insert text by chunks in jobs */
3023 static Eina_Bool
3024 _text_append_idler(void *data)
3025 {
3026    int start;
3027    char backup;
3028    Evas_Object *obj = (Evas_Object *)data;
3029
3030    ELM_ENTRY_DATA_GET(obj, sd);
3031
3032    evas_event_freeze(evas_object_evas_get(obj));
3033    if (sd->text) eina_stringshare_del(sd->text);
3034    sd->text = NULL;
3035    // TIZEN ONLY
3036    if (sd->password_text) eina_stringshare_del(sd->password_text);
3037    sd->password_text = NULL;
3038    //////
3039    sd->changed = EINA_TRUE;
3040
3041    start = sd->append_text_position;
3042    if ((start + _CHUNK_SIZE) < sd->append_text_len)
3043      {
3044         int pos = start;
3045         int tag_start, esc_start;
3046
3047         tag_start = esc_start = -1;
3048         /* Find proper markup cut place */
3049         while (pos - start < _CHUNK_SIZE)
3050           {
3051              int prev_pos = pos;
3052              Eina_Unicode tmp =
3053                eina_unicode_utf8_get_next(sd->append_text_left, &pos);
3054
3055              if (esc_start == -1)
3056                {
3057                   if (tmp == '<')
3058                     tag_start = prev_pos;
3059                   else if (tmp == '>')
3060                     tag_start = -1;
3061                }
3062              if (tag_start == -1)
3063                {
3064                   if (tmp == '&')
3065                     esc_start = prev_pos;
3066                   else if (tmp == ';')
3067                     esc_start = -1;
3068                }
3069           }
3070
3071         if (tag_start >= 0)
3072           {
3073              sd->append_text_position = tag_start;
3074           }
3075         else if (esc_start >= 0)
3076           {
3077              sd->append_text_position = esc_start;
3078           }
3079         else
3080           {
3081              sd->append_text_position = pos;
3082           }
3083      }
3084    else
3085      {
3086         sd->append_text_position = sd->append_text_len;
3087      }
3088
3089    backup = sd->append_text_left[sd->append_text_position];
3090    sd->append_text_left[sd->append_text_position] = '\0';
3091
3092    edje_object_part_text_append
3093      (sd->entry_edje, "elm.text", sd->append_text_left + start);
3094
3095    sd->append_text_left[sd->append_text_position] = backup;
3096
3097    evas_event_thaw(evas_object_evas_get(obj));
3098    evas_event_thaw_eval(evas_object_evas_get(obj));
3099
3100    _elm_entry_guide_update(obj, EINA_TRUE);
3101
3102    /* If there's still more to go, renew the idler, else, cleanup */
3103    if (sd->append_text_position < sd->append_text_len)
3104      {
3105         return ECORE_CALLBACK_RENEW;
3106      }
3107    else
3108      {
3109         free(sd->append_text_left);
3110         sd->append_text_left = NULL;
3111         sd->append_text_idler = NULL;
3112         return ECORE_CALLBACK_CANCEL;
3113      }
3114 }
3115
3116 static void
3117 _chars_add_till_limit(Evas_Object *obj,
3118                       char **text,
3119                       int can_add,
3120                       Length_Unit unit)
3121 {
3122    int i = 0, current_len = 0;
3123    char *new_text;
3124
3125    if (!*text) return;
3126    if (unit >= LENGTH_UNIT_LAST) return;
3127    if (strstr(*text, "<preedit")) return;
3128
3129    new_text = *text;
3130    current_len = strlen(*text);
3131    while (*new_text)
3132      {
3133         int idx = 0, unit_size = 0;
3134         char *markup, *utfstr;
3135
3136         if (*new_text == '<')
3137           {
3138              while (*(new_text + idx) != '>')
3139                {
3140                   idx++;
3141                   if (!*(new_text + idx)) break;
3142                }
3143           }
3144         else if (*new_text == '&')
3145           {
3146              while (*(new_text + idx) != ';')
3147                {
3148                   idx++;
3149                   if (!*(new_text + idx)) break;
3150                }
3151           }
3152         idx = evas_string_char_next_get(new_text, idx, NULL);
3153         markup = malloc(idx + 1);
3154         if (markup)
3155           {
3156              strncpy(markup, new_text, idx);
3157              markup[idx] = 0;
3158              utfstr = elm_entry_markup_to_utf8(markup);
3159              if (utfstr)
3160                {
3161                   if (unit == LENGTH_UNIT_BYTE)
3162                     unit_size = strlen(utfstr);
3163                   else if (unit == LENGTH_UNIT_CHAR)
3164                     unit_size = evas_string_char_len_get(utfstr);
3165                   free(utfstr);
3166                   utfstr = NULL;
3167                }
3168              free(markup);
3169              markup = NULL;
3170           }
3171         if (can_add < unit_size)
3172           {
3173              if (!i)
3174                {
3175                   evas_object_smart_callback_call(obj, SIG_MAX_LENGHT, NULL);
3176                   free(*text);
3177                   *text = NULL;
3178                   return;
3179                }
3180              can_add = 0;
3181              strncpy(new_text, new_text + idx,
3182                      current_len - ((new_text + idx) - *text));
3183              current_len -= idx;
3184              (*text)[current_len] = 0;
3185           }
3186         else
3187           {
3188              new_text += idx;
3189              can_add -= unit_size;
3190           }
3191         i++;
3192      }
3193
3194    evas_object_smart_callback_call(obj, SIG_MAX_LENGHT, NULL);
3195 }
3196
3197 static void
3198 _elm_entry_smart_signal(Evas_Object *obj,
3199                         const char *emission,
3200                         const char *source)
3201 {
3202    ELM_ENTRY_DATA_GET(obj, sd);
3203
3204    /* always pass to both edje objs */
3205    edje_object_signal_emit(sd->entry_edje, emission, source);
3206
3207    if (sd->scr_edje)
3208      edje_object_signal_emit(sd->scr_edje, emission, source);
3209 }
3210
3211 static void
3212 _elm_entry_smart_callback_add(Evas_Object *obj,
3213                               const char *emission,
3214                               const char *source,
3215                               Edje_Signal_Cb func_cb,
3216                               void *data)
3217 {
3218    Evas_Object *ro;
3219
3220    ELM_ENTRY_DATA_GET(obj, sd);
3221
3222    ro = ELM_WIDGET_DATA(sd)->resize_obj;
3223
3224    ELM_WIDGET_DATA(sd)->resize_obj = sd->entry_edje;
3225
3226    ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_add
3227      (obj, emission, source, func_cb, data);
3228
3229    if (sd->scr_edje)
3230      {
3231         ELM_WIDGET_DATA(sd)->resize_obj = sd->scr_edje;
3232
3233         ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_add
3234           (obj, emission, source, func_cb, data);
3235      }
3236
3237    ELM_WIDGET_DATA(sd)->resize_obj = ro;
3238 }
3239
3240 static void *
3241 _elm_entry_smart_callback_del(Evas_Object *obj,
3242                               const char *emission,
3243                               const char *source,
3244                               Edje_Signal_Cb func_cb)
3245 {
3246    Evas_Object *ro;
3247    void *data;
3248
3249    ELM_ENTRY_DATA_GET(obj, sd);
3250
3251    ro = ELM_WIDGET_DATA(sd)->resize_obj;
3252
3253    ELM_WIDGET_DATA(sd)->resize_obj = sd->entry_edje;
3254
3255    data = ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_del
3256        (obj, emission, source, func_cb);
3257
3258    if (sd->scr_edje)
3259      {
3260         ELM_WIDGET_DATA(sd)->resize_obj = sd->scr_edje;
3261
3262         ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_del
3263           (obj, emission, source, func_cb);
3264      }
3265
3266    ELM_WIDGET_DATA(sd)->resize_obj = ro;
3267
3268    return data;
3269 }
3270
3271 static Eina_Bool
3272 _elm_entry_smart_content_set(Evas_Object *obj,
3273                              const char *part,
3274                              Evas_Object *content)
3275 {
3276    if (!ELM_CONTAINER_CLASS(_elm_entry_parent_sc)->content_set
3277          (obj, part, content))
3278      return EINA_FALSE;
3279
3280    /* too bad entry does not follow the pattern
3281     * "elm,state,{icon,end},visible", we have to repeat ourselves */
3282    if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
3283      elm_entry_icon_visible_set(obj, EINA_TRUE);
3284
3285    if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
3286      elm_entry_end_visible_set(obj, EINA_TRUE);
3287
3288    return EINA_TRUE;
3289 }
3290
3291 static Evas_Object *
3292 _elm_entry_smart_content_unset(Evas_Object *obj,
3293                                const char *part)
3294 {
3295    Evas_Object *ret;
3296
3297    ret = ELM_CONTAINER_CLASS(_elm_entry_parent_sc)->content_unset(obj, part);
3298    if (!ret) return NULL;
3299
3300    /* too bad entry does not follow the pattern
3301     * "elm,state,{icon,end},hidden", we have to repeat ourselves */
3302    if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
3303      elm_entry_icon_visible_set(obj, EINA_FALSE);
3304
3305    if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
3306      elm_entry_end_visible_set(obj, EINA_FALSE);
3307
3308    return ret;
3309 }
3310
3311 static Eina_Bool
3312 _elm_entry_smart_text_set(Evas_Object *obj,
3313                           const char *item,
3314                           const char *entry)
3315 {
3316    int len = 0;
3317
3318    ELM_ENTRY_DATA_GET(obj, sd);
3319
3320    if (!entry) entry = "";
3321    if (item)
3322      {
3323         if (!strcmp(item, "guide"))
3324           edje_object_part_text_set(sd->entry_edje, "elm.guide", entry);
3325         else
3326           edje_object_part_text_set(sd->entry_edje, item, entry);
3327
3328         return EINA_TRUE;
3329      }
3330
3331    evas_event_freeze(evas_object_evas_get(obj));
3332    if (sd->text) eina_stringshare_del(sd->text);
3333    sd->text = NULL;
3334    // TIZEN ONLY
3335    if (sd->password_text) eina_stringshare_del(sd->password_text);
3336    sd->password_text = NULL;
3337    /////
3338    sd->changed = EINA_TRUE;
3339
3340    /* Clear currently pending job if there is one */
3341    if (sd->append_text_idler)
3342      {
3343         ecore_idler_del(sd->append_text_idler);
3344         free(sd->append_text_left);
3345         sd->append_text_left = NULL;
3346         sd->append_text_idler = NULL;
3347      }
3348
3349    len = strlen(entry);
3350    /* Split to ~_CHUNK_SIZE chunks */
3351    if (len > _CHUNK_SIZE)
3352      {
3353         sd->append_text_left = (char *)malloc(len + 1);
3354      }
3355
3356    /* If we decided to use the idler */
3357    if (sd->append_text_left)
3358      {
3359         /* Need to clear the entry first */
3360         edje_object_part_text_set(sd->entry_edje, "elm.text", "");
3361         memcpy(sd->append_text_left, entry, len + 1);
3362         sd->append_text_position = 0;
3363         sd->append_text_len = len;
3364         sd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
3365      }
3366    else
3367      {
3368         edje_object_part_text_set(sd->entry_edje, "elm.text", entry);
3369      }
3370
3371    if (len > 0)
3372      _elm_entry_guide_update(obj, EINA_TRUE);
3373    else
3374      _elm_entry_guide_update(obj, EINA_FALSE);
3375
3376    evas_event_thaw(evas_object_evas_get(obj));
3377    evas_event_thaw_eval(evas_object_evas_get(obj));
3378
3379    return EINA_TRUE;
3380 }
3381
3382 static const char *
3383 _elm_entry_smart_text_get(const Evas_Object *obj,
3384                           const char *item)
3385 {
3386    const char *text;
3387
3388    ELM_ENTRY_DATA_GET(obj, sd);
3389
3390    if (item)
3391      {
3392         if (!strcmp(item, "default")) goto proceed;
3393         else if (!strcmp(item, "guide"))
3394           return edje_object_part_text_get(sd->entry_edje, "elm.guide");
3395         else
3396           return edje_object_part_text_get(sd->entry_edje, item);
3397      }
3398
3399 proceed:
3400
3401    text = edje_object_part_text_get(sd->entry_edje, "elm.text");
3402    if (!text)
3403      {
3404         ERR("text=NULL for edje %p, part 'elm.text'", sd->entry_edje);
3405
3406         return NULL;
3407      }
3408
3409    if (sd->append_text_len > 0)
3410      {
3411         char *tmpbuf;
3412         size_t tlen;
3413
3414         tlen = strlen(text);
3415         tmpbuf = malloc(sd->append_text_len + 1);
3416         if (!tmpbuf)
3417           {
3418              ERR("Failed to allocate memory for entry's text %p", obj);
3419              return NULL;
3420           }
3421         memcpy(tmpbuf, text, tlen);
3422
3423         if (sd->append_text_left)
3424           memcpy(tmpbuf + tlen, sd->append_text_left
3425                  + sd->append_text_position, sd->append_text_len
3426                  - sd->append_text_position);
3427         tmpbuf[sd->append_text_len] = '\0';
3428         eina_stringshare_replace(&sd->text, tmpbuf);
3429         free(tmpbuf);
3430      }
3431    else
3432      {
3433         eina_stringshare_replace(&sd->text, text);
3434      }
3435
3436    // TIZEN ONLY
3437    if (sd->password)
3438      {
3439         char *pw_text;
3440         pw_text = elm_entry_markup_to_utf8(sd->text);
3441         if (pw_text)
3442           {
3443              eina_stringshare_replace(&sd->password_text, pw_text);
3444              free(pw_text);
3445              return sd->password_text;
3446           }
3447      }
3448    /////
3449
3450    return sd->text;
3451 }
3452
3453 static char *
3454 _access_info_cb(void *data __UNUSED__, Evas_Object *obj)
3455 {
3456    const char *txt;
3457
3458    ELM_ENTRY_DATA_GET(obj, sd);
3459
3460    if (sd->password) return NULL;
3461
3462    txt = elm_widget_access_info_get(obj);
3463
3464    if (!txt) txt = _elm_util_mkup_to_text(elm_entry_entry_get(obj));
3465    if (txt) return strdup(txt);
3466
3467    return NULL;
3468 }
3469
3470 static char *
3471 _access_state_cb(void *data __UNUSED__, Evas_Object *obj)
3472 {
3473    Eina_Strbuf *buf;
3474    char *ret;
3475
3476    ELM_ENTRY_DATA_GET(obj, sd);
3477
3478    ret = NULL;
3479    buf = eina_strbuf_new();
3480
3481    if (elm_widget_disabled_get(obj))
3482      eina_strbuf_append(buf, "State: Disabled");
3483
3484    if (!sd->editable)
3485      {
3486         if (!eina_strbuf_length_get(buf))
3487           eina_strbuf_append(buf, "State: Not Editable");
3488         else eina_strbuf_append(buf, ", Not Editable");
3489      }
3490
3491    if (sd->password)
3492      {
3493         if (!eina_strbuf_length_get(buf))
3494           eina_strbuf_append(buf, "State: Password");
3495         else eina_strbuf_append(buf, ", Password");
3496      }
3497
3498    if (!eina_strbuf_length_get(buf)) goto buf_free;
3499
3500    ret = eina_strbuf_string_steal(buf);
3501
3502 buf_free:
3503    eina_strbuf_free(buf);
3504    return ret;
3505 }
3506
3507 static void
3508 _entry_selection_callbacks_unregister(Evas_Object *obj)
3509 {
3510    ELM_ENTRY_DATA_GET(obj, sd);
3511
3512    edje_object_signal_callback_del_full
3513      (sd->entry_edje, "selection,start", "elm.text",
3514      _entry_selection_start_signal_cb, obj);
3515    edje_object_signal_callback_del_full
3516      (sd->entry_edje, "selection,changed", "elm.text",
3517      _entry_selection_changed_signal_cb, obj);
3518    edje_object_signal_callback_del_full
3519      (sd->entry_edje, "entry,selection,all,request",
3520      "elm.text", _entry_selection_all_signal_cb, obj);
3521    edje_object_signal_callback_del_full
3522      (sd->entry_edje, "entry,selection,none,request",
3523      "elm.text", _entry_selection_none_signal_cb, obj);
3524    edje_object_signal_callback_del_full
3525      (sd->entry_edje, "selection,cleared", "elm.text",
3526      _entry_selection_cleared_signal_cb, obj);
3527    edje_object_signal_callback_del_full
3528      (sd->entry_edje, "entry,paste,request,*", "elm.text",
3529      _entry_paste_request_signal_cb, obj);
3530    edje_object_signal_callback_del_full
3531      (sd->entry_edje, "entry,copy,notify", "elm.text",
3532      _entry_copy_notify_signal_cb, obj);
3533    edje_object_signal_callback_del_full
3534      (sd->entry_edje, "entry,cut,notify", "elm.text",
3535      _entry_cut_notify_signal_cb, obj);
3536 }
3537
3538 static void
3539 _entry_selection_callbacks_register(Evas_Object *obj)
3540 {
3541    ELM_ENTRY_DATA_GET(obj, sd);
3542
3543    edje_object_signal_callback_add
3544      (sd->entry_edje, "selection,start", "elm.text",
3545      _entry_selection_start_signal_cb, obj);
3546    edje_object_signal_callback_add
3547      (sd->entry_edje, "selection,changed", "elm.text",
3548      _entry_selection_changed_signal_cb, obj);
3549    edje_object_signal_callback_add
3550      (sd->entry_edje, "entry,selection,all,request",
3551      "elm.text", _entry_selection_all_signal_cb, obj);
3552    edje_object_signal_callback_add
3553      (sd->entry_edje, "entry,selection,none,request",
3554      "elm.text", _entry_selection_none_signal_cb, obj);
3555    edje_object_signal_callback_add
3556      (sd->entry_edje, "selection,cleared", "elm.text",
3557      _entry_selection_cleared_signal_cb, obj);
3558    edje_object_signal_callback_add
3559      (sd->entry_edje, "entry,paste,request,*", "elm.text",
3560      _entry_paste_request_signal_cb, obj);
3561    edje_object_signal_callback_add
3562      (sd->entry_edje, "entry,copy,notify", "elm.text",
3563      _entry_copy_notify_signal_cb, obj);
3564    edje_object_signal_callback_add
3565      (sd->entry_edje, "entry,cut,notify", "elm.text",
3566      _entry_cut_notify_signal_cb, obj);
3567 }
3568
3569 static void
3570 _resize_cb(void *data,
3571            Evas *e __UNUSED__,
3572            Evas_Object *obj __UNUSED__,
3573            void *event_info __UNUSED__)
3574 {
3575    ELM_ENTRY_DATA_GET(data, sd);
3576
3577    if (sd->line_wrap)
3578      {
3579         elm_layout_sizing_eval(data);
3580      }
3581    else if (sd->scroll)
3582      {
3583         Evas_Coord vw = 0, vh = 0;
3584
3585         sd->s_iface->content_viewport_size_get(data, &vw, &vh);
3586         if (vw < sd->ent_mw) vw = sd->ent_mw;
3587         if (vh < sd->ent_mh) vh = sd->ent_mh;
3588         evas_object_resize(sd->entry_edje, vw, vh);
3589      }
3590
3591    if (sd->hoversel) _hoversel_position(data);
3592
3593    // TIZEN ONLY
3594    if (!_elm_config->desktop_entry)
3595      {
3596         if (sd->region_get_job) ecore_job_del(sd->region_get_job);
3597         sd->region_get_job = ecore_job_add(_region_get_job, data);
3598
3599         if (sd->magnifier_showing)
3600           _magnifier_content_resize(data);
3601      }
3602    //
3603 }
3604
3605 static void
3606 _elm_entry_smart_add(Evas_Object *obj)
3607 {
3608 #ifdef HAVE_ELEMENTARY_X
3609    Evas_Object *top;
3610 #endif
3611
3612    EVAS_SMART_DATA_ALLOC(obj, Elm_Entry_Smart_Data);
3613
3614    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.add(obj);
3615
3616    priv->entry_edje = ELM_WIDGET_DATA(priv)->resize_obj;
3617
3618    priv->cnp_mode = ELM_CNP_MODE_MARKUP;
3619    priv->line_wrap = ELM_WRAP_WORD;
3620    priv->context_menu = EINA_TRUE;
3621    priv->disabled = EINA_FALSE;
3622    priv->auto_save = EINA_TRUE;
3623    priv->editable = EINA_TRUE;
3624    priv->scroll = EINA_FALSE;
3625
3626    priv->input_panel_imdata = NULL;
3627    //TIZEN ONLY
3628    priv->magnifier_enabled = EINA_TRUE;
3629    priv->mouse_upped = EINA_FALSE;
3630    priv->sel_allow = EINA_TRUE;
3631    priv->cursor_handler_disabled = EINA_FALSE;
3632    priv->scroll_holding = EINA_FALSE;
3633    //
3634
3635    elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj));
3636
3637    priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
3638    evas_object_data_set(priv->hit_rect, "_elm_leaveme", obj);
3639    evas_object_smart_member_add(priv->hit_rect, obj);
3640    elm_widget_sub_object_add(obj, priv->hit_rect);
3641
3642    /* common scroller hit rectangle setup */
3643    evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
3644    evas_object_show(priv->hit_rect);
3645    evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
3646
3647    priv->s_iface = evas_object_smart_interface_get
3648        (obj, ELM_SCROLLABLE_IFACE_NAME);
3649
3650    priv->s_iface->objects_set(obj, priv->entry_edje, priv->hit_rect);
3651
3652    edje_object_item_provider_set(priv->entry_edje, _item_get, obj);
3653
3654    edje_object_text_insert_filter_callback_add
3655      (priv->entry_edje, "elm.text", _text_filter_cb, obj);
3656    edje_object_text_markup_filter_callback_add
3657      (priv->entry_edje, "elm.text", _markup_filter_cb, obj);
3658
3659    evas_object_event_callback_add
3660      (priv->entry_edje, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
3661    evas_object_event_callback_add
3662      (priv->entry_edje, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
3663    evas_object_event_callback_add
3664      (priv->entry_edje, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, obj);
3665
3666    /* this code can't go in smart_resize. sizing gets wrong */
3667    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
3668
3669    edje_object_signal_callback_add
3670      (priv->entry_edje, "entry,changed", "elm.text",
3671      _entry_changed_signal_cb, obj);
3672    edje_object_signal_callback_add
3673      (priv->entry_edje, "entry,changed,user", "elm.text",
3674      _entry_changed_user_signal_cb, obj);
3675    edje_object_signal_callback_add
3676      (priv->entry_edje, "preedit,changed", "elm.text",
3677      _entry_preedit_changed_signal_cb, obj);
3678
3679    _entry_selection_callbacks_register(obj);
3680
3681    edje_object_signal_callback_add
3682      (priv->entry_edje, "cursor,changed", "elm.text",
3683      _entry_cursor_changed_signal_cb, obj);
3684    edje_object_signal_callback_add
3685      (priv->entry_edje, "cursor,changed,manual", "elm.text",
3686      _entry_cursor_changed_manual_signal_cb, obj);
3687    edje_object_signal_callback_add
3688      (priv->entry_edje, "anchor,mouse,down,*", "elm.text",
3689      _entry_anchor_down_signal_cb, obj);
3690    edje_object_signal_callback_add
3691      (priv->entry_edje, "anchor,mouse,up,*", "elm.text",
3692      _entry_anchor_up_signal_cb, obj);
3693    edje_object_signal_callback_add
3694      (priv->entry_edje, "anchor,mouse,clicked,*", "elm.text",
3695      _entry_anchor_clicked_signal_cb, obj);
3696    edje_object_signal_callback_add
3697      (priv->entry_edje, "anchor,mouse,move,*", "elm.text",
3698      _entry_anchor_move_signal_cb, obj);
3699    edje_object_signal_callback_add
3700      (priv->entry_edje, "anchor,mouse,in,*", "elm.text",
3701      _entry_anchor_in_signal_cb, obj);
3702    edje_object_signal_callback_add
3703      (priv->entry_edje, "anchor,mouse,out,*", "elm.text",
3704      _entry_anchor_out_signal_cb, obj);
3705    edje_object_signal_callback_add
3706      (priv->entry_edje, "entry,key,enter", "elm.text",
3707      _entry_key_enter_signal_cb, obj);
3708    edje_object_signal_callback_add
3709      (priv->entry_edje, "entry,key,escape", "elm.text",
3710      _entry_key_escape_signal_cb, obj);
3711    edje_object_signal_callback_add
3712      (priv->entry_edje, "mouse,down,1", "elm.text",
3713      _entry_mouse_down_signal_cb, obj);
3714    edje_object_signal_callback_add
3715      (priv->entry_edje, "mouse,clicked,1", "elm.text",
3716      _entry_mouse_clicked_signal_cb, obj);
3717    edje_object_signal_callback_add
3718      (priv->entry_edje, "mouse,down,1,double", "elm.text",
3719      _entry_mouse_double_signal_cb, obj);
3720    edje_object_signal_callback_add
3721      (priv->entry_edje, "mouse,down,1,triple", "elm.text",
3722      _entry_mouse_triple_signal_cb, obj);
3723    edje_object_signal_callback_add
3724      (priv->entry_edje, "entry,undo,request", "elm.text",
3725      _entry_undo_request_signal_cb, obj);
3726    edje_object_signal_callback_add
3727      (priv->entry_edje, "entry,redo,request", "elm.text",
3728      _entry_redo_request_signal_cb, obj);
3729
3730    // TIZEN ONLY
3731    edje_object_signal_callback_add
3732       (priv->entry_edje, "handler,move,start", "elm.text",
3733        _signal_handler_move_start_cb, obj);
3734    edje_object_signal_callback_add
3735       (priv->entry_edje, "handler,move,end", "elm.text",
3736        _signal_handler_move_end_cb, obj);
3737    edje_object_signal_callback_add
3738       (priv->entry_edje, "handler,moving", "elm.text",
3739        _signal_handler_moving_cb, obj);
3740    edje_object_signal_callback_add
3741       (priv->entry_edje, "selection,end", "elm.text",
3742        _signal_selection_end, obj);
3743    edje_object_signal_callback_add
3744       (priv->entry_edje, "long,pressed", "elm.text",
3745        _signal_long_pressed, obj);
3746    edje_object_signal_callback_add
3747       (priv->entry_edje, "magnifier,changed", "elm.text",
3748        _signal_magnifier_changed, obj);
3749    edje_object_signal_callback_add
3750       (priv->entry_edje, "cursor,handler,move,start", "elm.text",
3751        _signal_handler_move_start_cb, obj);
3752    edje_object_signal_callback_add
3753       (priv->entry_edje, "cursor,handler,move,end", "elm.text",
3754        _signal_handler_move_end_cb, obj);
3755    edje_object_signal_callback_add
3756       (priv->entry_edje, "cursor,handler,moving", "elm.text",
3757        _signal_handler_moving_cb, obj);
3758    edje_object_signal_callback_add
3759       (priv->entry_edje, "cursor,handler,clicked", "elm.text",
3760        _signal_handler_click_cb, obj);
3761    evas_object_event_callback_add(priv->entry_edje, EVAS_CALLBACK_KEY_DOWN,
3762                                   _elm_entry_key_down_cb, obj);
3763    /////////
3764
3765    elm_layout_text_set(obj, "elm.text", "");
3766
3767    elm_object_sub_cursor_set
3768      (ELM_WIDGET_DATA(priv)->resize_obj, obj, ELM_CURSOR_XTERM);
3769    elm_widget_can_focus_set(obj, EINA_TRUE);
3770    if (_elm_config->desktop_entry)
3771      edje_object_part_text_select_allow_set
3772        (priv->entry_edje, "elm.text", EINA_TRUE);
3773    else
3774      {
3775         // TIZEN ONLY
3776         edje_object_part_text_select_allow_set(priv->entry_edje, "elm.text", EINA_TRUE);
3777         edje_object_part_text_viewport_region_set(priv->entry_edje, "elm.text", -1, -1, -1, -1);
3778         edje_object_part_text_layout_region_set(priv->entry_edje, "elm.text", -1, -1, -1, -1);
3779         ////////
3780      }
3781
3782    elm_layout_sizing_eval(obj);
3783
3784    elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
3785    elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
3786    elm_entry_prediction_allow_set(obj, EINA_TRUE);
3787
3788    priv->autocapital_type = edje_object_part_text_autocapital_type_get
3789        (priv->entry_edje, "elm.text");
3790
3791 #ifdef HAVE_ELEMENTARY_X
3792    top = elm_widget_top_get(obj);
3793    if ((top) && (elm_win_xwindow_get(top)))
3794      {
3795         priv->sel_notify_handler =
3796           ecore_event_handler_add
3797             (ECORE_X_EVENT_SELECTION_NOTIFY, _event_selection_notify, obj);
3798         priv->sel_clear_handler =
3799           ecore_event_handler_add
3800             (ECORE_X_EVENT_SELECTION_CLEAR, _event_selection_clear, obj);
3801      }
3802
3803    priv->client_msg_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _xclient_msg_cb, obj);  // TIZEN ONLY
3804
3805    elm_drop_target_add
3806      (obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3807      _drag_drop_cb, NULL);
3808 #endif
3809
3810    entries = eina_list_prepend(entries, obj);
3811
3812    // module - find module for entry
3813    priv->api = _module_find(obj);
3814    // if found - hook in
3815    if ((priv->api) && (priv->api->obj_hook)) priv->api->obj_hook(obj);
3816
3817    _mirrored_set(obj, elm_widget_mirrored_get(obj));
3818
3819    // access
3820    _elm_access_object_register(obj, priv->entry_edje);
3821    _elm_access_text_set
3822      (_elm_access_object_get(obj), ELM_ACCESS_TYPE, E_("Entry"));
3823    _elm_access_callback_set
3824      (_elm_access_object_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
3825    _elm_access_callback_set
3826      (_elm_access_object_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL);
3827 }
3828
3829 static void
3830 _elm_entry_smart_del(Evas_Object *obj)
3831 {
3832    Elm_Entry_Context_Menu_Item *it;
3833    Elm_Entry_Item_Provider *ip;
3834    Elm_Entry_Markup_Filter *tf;
3835
3836    ELM_ENTRY_DATA_GET(obj, sd);
3837
3838    if (sd->delay_write)
3839      {
3840         ecore_timer_del(sd->delay_write);
3841         sd->delay_write = NULL;
3842         if (sd->auto_save) _save_do(obj);
3843      }
3844
3845    elm_entry_anchor_hover_end(obj);
3846    elm_entry_anchor_hover_parent_set(obj, NULL);
3847
3848    evas_event_freeze(evas_object_evas_get(obj));
3849
3850    if (sd->file) eina_stringshare_del(sd->file);
3851
3852    if (sd->hov_deljob) ecore_job_del(sd->hov_deljob);
3853    if ((sd->api) && (sd->api->obj_unhook))
3854      sd->api->obj_unhook(obj);  // module - unhook
3855
3856    entries = eina_list_remove(entries, obj);
3857 #ifdef HAVE_ELEMENTARY_X
3858    if (sd->sel_notify_handler)
3859      ecore_event_handler_del(sd->sel_notify_handler);
3860    if (sd->sel_clear_handler)
3861      ecore_event_handler_del(sd->sel_clear_handler);
3862    if (sd->client_msg_handler)                        // TIZEN ONLY
3863      ecore_event_handler_del(sd->client_msg_handler); //
3864 #endif
3865    if (sd->cut_sel) eina_stringshare_del(sd->cut_sel);
3866    if (sd->text) eina_stringshare_del(sd->text);
3867    if (sd->deferred_recalc_job)
3868      ecore_job_del(sd->deferred_recalc_job);
3869    if (sd->append_text_idler)
3870      {
3871         ecore_idler_del(sd->append_text_idler);
3872         free(sd->append_text_left);
3873         sd->append_text_left = NULL;
3874         sd->append_text_idler = NULL;
3875      }
3876    if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer);
3877    EINA_LIST_FREE (sd->items, it)
3878      {
3879         eina_stringshare_del(it->label);
3880         eina_stringshare_del(it->icon_file);
3881         eina_stringshare_del(it->icon_group);
3882         free(it);
3883      }
3884    EINA_LIST_FREE (sd->item_providers, ip)
3885      {
3886         free(ip);
3887      }
3888    EINA_LIST_FREE (sd->text_filters, tf)
3889      {
3890         _filter_free(tf);
3891      }
3892    EINA_LIST_FREE (sd->markup_filters, tf)
3893      {
3894         _filter_free(tf);
3895      }
3896    if (sd->delay_write) ecore_timer_del(sd->delay_write);
3897    if (sd->input_panel_imdata) free(sd->input_panel_imdata);
3898
3899    if (sd->anchor_hover.hover_style)
3900      eina_stringshare_del(sd->anchor_hover.hover_style);
3901
3902    //TIZEN ONLY
3903    if (sd->password_text) eina_stringshare_del(sd->password_text);
3904    if (sd->region_get_job) ecore_job_del(sd->region_get_job);
3905    if (sd->region_recalc_job) ecore_job_del(sd->region_recalc_job);
3906    if (sd->mgf_proxy) evas_object_del(sd->mgf_proxy);
3907    if (sd->mgf_bg) evas_object_del(sd->mgf_bg);
3908    if (sd->mgf_clip) evas_object_del(sd->mgf_clip);
3909    if (sd->click_timer) ecore_timer_del(sd->click_timer);
3910    //
3911    evas_event_thaw(evas_object_evas_get(obj));
3912    evas_event_thaw_eval(evas_object_evas_get(obj));
3913
3914    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.del(obj);
3915 }
3916
3917 static void
3918 _elm_entry_smart_move(Evas_Object *obj,
3919                       Evas_Coord x,
3920                       Evas_Coord y)
3921 {
3922    ELM_ENTRY_DATA_GET(obj, sd);
3923
3924    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.move(obj, x, y);
3925
3926    evas_object_move(sd->hit_rect, x, y);
3927
3928    if (sd->hoversel) _hoversel_position(obj);
3929
3930    // TIZEN ONLY
3931    if (!_elm_config->desktop_entry)
3932      {
3933         if (sd->region_get_job) ecore_job_del(sd->region_get_job);
3934         sd->region_get_job = ecore_job_add(_region_get_job, obj);
3935      }
3936    //
3937 }
3938
3939 static void
3940 _elm_entry_smart_resize(Evas_Object *obj,
3941                         Evas_Coord w,
3942                         Evas_Coord h)
3943 {
3944    ELM_ENTRY_DATA_GET(obj, sd);
3945
3946    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.resize(obj, w, h);
3947
3948    evas_object_resize(sd->hit_rect, w, h);
3949 }
3950
3951 static void
3952 _elm_entry_smart_member_add(Evas_Object *obj,
3953                             Evas_Object *member)
3954 {
3955    ELM_ENTRY_DATA_GET(obj, sd);
3956
3957    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.member_add(obj, member);
3958
3959    if (sd->hit_rect)
3960      evas_object_raise(sd->hit_rect);
3961 }
3962
3963 static void
3964 _elm_entry_smart_set_user(Elm_Entry_Smart_Class *sc)
3965 {
3966    ELM_WIDGET_CLASS(sc)->base.add = _elm_entry_smart_add;
3967    ELM_WIDGET_CLASS(sc)->base.del = _elm_entry_smart_del;
3968    ELM_WIDGET_CLASS(sc)->base.move = _elm_entry_smart_move;
3969    ELM_WIDGET_CLASS(sc)->base.resize = _elm_entry_smart_resize;
3970    ELM_WIDGET_CLASS(sc)->base.member_add = _elm_entry_smart_member_add;
3971
3972    ELM_WIDGET_CLASS(sc)->on_focus_region = _elm_entry_smart_on_focus_region;
3973    ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_entry_smart_sub_object_del;
3974    ELM_WIDGET_CLASS(sc)->on_focus = _elm_entry_smart_on_focus;
3975    ELM_WIDGET_CLASS(sc)->theme = _elm_entry_smart_theme;
3976    ELM_WIDGET_CLASS(sc)->disable = _elm_entry_smart_disable;
3977    ELM_WIDGET_CLASS(sc)->translate = _elm_entry_smart_translate;
3978    //TIZEN ONLY
3979    ELM_WIDGET_CLASS(sc)->event = _elm_entry_smart_event;
3980    //
3981
3982    /* not a 'focus chain manager' */
3983    ELM_WIDGET_CLASS(sc)->focus_next = NULL;
3984    ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
3985
3986    ELM_CONTAINER_CLASS(sc)->content_set = _elm_entry_smart_content_set;
3987    ELM_CONTAINER_CLASS(sc)->content_unset = _elm_entry_smart_content_unset;
3988
3989    ELM_LAYOUT_CLASS(sc)->signal = _elm_entry_smart_signal;
3990    ELM_LAYOUT_CLASS(sc)->callback_add = _elm_entry_smart_callback_add;
3991    ELM_LAYOUT_CLASS(sc)->callback_del = _elm_entry_smart_callback_del;
3992    ELM_LAYOUT_CLASS(sc)->text_set = _elm_entry_smart_text_set;
3993    ELM_LAYOUT_CLASS(sc)->text_get = _elm_entry_smart_text_get;
3994    ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_entry_smart_sizing_eval;
3995    ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
3996 }
3997
3998 EAPI const Elm_Entry_Smart_Class *
3999 elm_entry_smart_class_get(void)
4000 {
4001    static Elm_Entry_Smart_Class _sc =
4002      ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION(ELM_ENTRY_SMART_NAME);
4003    static const Elm_Entry_Smart_Class *class = NULL;
4004    Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
4005
4006    if (class)
4007      return class;
4008
4009    _elm_entry_smart_set(&_sc);
4010    esc->callbacks = _smart_callbacks;
4011    class = &_sc;
4012
4013    return class;
4014 }
4015
4016 EAPI Evas_Object *
4017 elm_entry_add(Evas_Object *parent)
4018 {
4019    Evas_Object *obj;
4020
4021    EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
4022
4023    obj = elm_widget_add(_elm_entry_smart_class_new(), parent);
4024    if (!obj) return NULL;
4025
4026    if (!elm_widget_sub_object_add(parent, obj))
4027      ERR("could not add %p as sub object of %p", obj, parent);
4028
4029    return obj;
4030 }
4031
4032 EAPI void
4033 elm_entry_text_style_user_push(Evas_Object *obj,
4034                                const char *style)
4035 {
4036    ELM_ENTRY_CHECK(obj);
4037    ELM_ENTRY_DATA_GET(obj, sd);
4038
4039    edje_object_part_text_style_user_push(sd->entry_edje, "elm.text", style);
4040    _elm_entry_smart_theme(obj);
4041 }
4042
4043 EAPI void
4044 elm_entry_text_style_user_pop(Evas_Object *obj)
4045 {
4046    ELM_ENTRY_CHECK(obj);
4047    ELM_ENTRY_DATA_GET(obj, sd);
4048
4049    edje_object_part_text_style_user_pop(sd->entry_edje, "elm.text");
4050
4051    _elm_entry_smart_theme(obj);
4052 }
4053
4054 EAPI const char *
4055 elm_entry_text_style_user_peek(const Evas_Object *obj)
4056 {
4057    ELM_ENTRY_CHECK(obj) NULL;
4058    ELM_ENTRY_DATA_GET(obj, sd);
4059
4060    return edje_object_part_text_style_user_peek(sd->entry_edje, "elm.text");
4061 }
4062
4063 EAPI void
4064 elm_entry_single_line_set(Evas_Object *obj,
4065                           Eina_Bool single_line)
4066 {
4067    ELM_ENTRY_CHECK(obj);
4068    ELM_ENTRY_DATA_GET(obj, sd);
4069
4070    if (sd->single_line == single_line) return;
4071
4072    sd->single_line = single_line;
4073    sd->line_wrap = ELM_WRAP_NONE;
4074    if (elm_entry_cnp_mode_get(obj) == ELM_CNP_MODE_MARKUP)
4075      elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
4076    _elm_entry_smart_theme(obj);
4077
4078    if (sd->scroll)
4079      {
4080         if (sd->single_line)
4081           {
4082              sd->s_iface->policy_set
4083                 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
4084              // TIZEN ONLY
4085              sd->s_iface->bounce_allow_set(obj, EINA_FALSE, EINA_FALSE);
4086              ///
4087           }
4088         else
4089           {
4090              sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
4091              // TIZEN ONLY
4092              sd->s_iface->bounce_allow_set(obj, EINA_FALSE, EINA_FALSE);
4093              ///
4094           }
4095         elm_layout_sizing_eval(obj);
4096      }
4097 }
4098
4099 EAPI Eina_Bool
4100 elm_entry_single_line_get(const Evas_Object *obj)
4101 {
4102    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4103    ELM_ENTRY_DATA_GET(obj, sd);
4104
4105    return sd->single_line;
4106 }
4107
4108 EAPI void
4109 elm_entry_password_set(Evas_Object *obj,
4110                        Eina_Bool password)
4111 {
4112    ELM_ENTRY_CHECK(obj);
4113    ELM_ENTRY_DATA_GET(obj, sd);
4114
4115    password = !!password;
4116
4117    if (sd->password == password) return;
4118    sd->password = password;
4119
4120    if (password)
4121      {
4122         sd->single_line = EINA_TRUE;
4123         sd->line_wrap = ELM_WRAP_NONE;
4124 #ifdef HAVE_ELEMENTARY_X
4125         elm_drop_target_del(obj);
4126 #endif
4127         _entry_selection_callbacks_unregister(obj);
4128      }
4129    else
4130      {
4131 #ifdef HAVE_ELEMENTARY_X
4132         elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
4133 #endif
4134         _entry_selection_callbacks_register(obj);
4135      }
4136
4137    _elm_entry_smart_theme(obj);
4138 }
4139
4140 EAPI Eina_Bool
4141 elm_entry_password_get(const Evas_Object *obj)
4142 {
4143    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4144    ELM_ENTRY_DATA_GET(obj, sd);
4145
4146    return sd->password;
4147 }
4148
4149 EAPI void
4150 elm_entry_entry_set(Evas_Object *obj,
4151                     const char *entry)
4152 {
4153    ELM_ENTRY_CHECK(obj);
4154    _elm_entry_smart_text_set(obj, NULL, entry);
4155 }
4156
4157 EAPI const char *
4158 elm_entry_entry_get(const Evas_Object *obj)
4159 {
4160    ELM_ENTRY_CHECK(obj) NULL;
4161    return _elm_entry_smart_text_get(obj, NULL);
4162 }
4163
4164 EAPI void
4165 elm_entry_entry_append(Evas_Object *obj,
4166                        const char *entry)
4167 {
4168    int len = 0;
4169
4170    ELM_ENTRY_CHECK(obj);
4171    ELM_ENTRY_DATA_GET(obj, sd);
4172
4173    if (!entry) entry = "";
4174
4175    sd->changed = EINA_TRUE;
4176
4177    len = strlen(entry);
4178    if (sd->append_text_left)
4179      {
4180         char *tmpbuf;
4181
4182         tmpbuf = realloc(sd->append_text_left, sd->append_text_len + len + 1);
4183         if (!tmpbuf)
4184           {
4185              /* Do something */
4186              return;
4187           }
4188         sd->append_text_left = tmpbuf;
4189         memcpy(sd->append_text_left + sd->append_text_len, entry, len + 1);
4190         sd->append_text_len += len;
4191      }
4192    else
4193      {
4194         /* FIXME: Add chunked appending here (like in entry_set) */
4195         edje_object_part_text_append(sd->entry_edje, "elm.text", entry);
4196      }
4197 }
4198
4199 EAPI Eina_Bool
4200 elm_entry_is_empty(const Evas_Object *obj)
4201 {
4202    /* FIXME: until there's support for that in textblock, we just
4203     * check to see if the there is text or not. */
4204    const Evas_Object *tb;
4205    Evas_Textblock_Cursor *cur;
4206    Eina_Bool ret;
4207
4208    ELM_ENTRY_CHECK(obj) EINA_TRUE;
4209    ELM_ENTRY_DATA_GET(obj, sd);
4210
4211    /* It's a hack until we get the support suggested above.  We just
4212     * create a cursor, point it to the begining, and then try to
4213     * advance it, if it can advance, the tb is not empty, otherwise it
4214     * is. */
4215    tb = edje_object_part_object_get(sd->entry_edje, "elm.text");
4216
4217    /* This is actually, ok for the time being, these hackish stuff
4218       will be removed once evas 1.0 is out */
4219    cur = evas_object_textblock_cursor_new((Evas_Object *)tb);
4220    evas_textblock_cursor_pos_set(cur, 0);
4221    ret = evas_textblock_cursor_char_next(cur);
4222    evas_textblock_cursor_free(cur);
4223
4224    return !ret;
4225 #if 0  // TIZEN ONLY CODES : IF ABOVE CODES HAVE NO PROBLEM, THEN DELETE THESE CODES.
4226    char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
4227    if (!str) return EINA_TRUE;
4228
4229    ret = (strlen(str) == 0);
4230
4231    free(str);
4232    return ret;
4233 #endif
4234 }
4235
4236 EAPI Evas_Object *
4237 elm_entry_textblock_get(Evas_Object *obj)
4238 {
4239    ELM_ENTRY_CHECK(obj) NULL;
4240    ELM_ENTRY_DATA_GET(obj, sd);
4241
4242    return (Evas_Object *)edje_object_part_object_get
4243             (sd->entry_edje, "elm.text");
4244 }
4245
4246 EAPI void
4247 elm_entry_calc_force(Evas_Object *obj)
4248 {
4249    ELM_ENTRY_CHECK(obj);
4250    ELM_ENTRY_DATA_GET(obj, sd);
4251
4252    edje_object_calc_force(sd->entry_edje);
4253    sd->changed = EINA_TRUE;
4254    elm_layout_sizing_eval(obj);
4255 }
4256
4257 EAPI const char *
4258 elm_entry_selection_get(const Evas_Object *obj)
4259 {
4260    ELM_ENTRY_CHECK(obj) NULL;
4261    ELM_ENTRY_DATA_GET(obj, sd);
4262
4263    if ((sd->password)) return NULL;
4264    return edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
4265 }
4266
4267 EAPI void
4268 elm_entry_entry_insert(Evas_Object *obj,
4269                        const char *entry)
4270 {
4271    ELM_ENTRY_CHECK(obj);
4272    ELM_ENTRY_DATA_GET(obj, sd);
4273
4274    edje_object_part_text_insert(sd->entry_edje, "elm.text", entry);
4275    // TIZEN ONLY
4276 #ifdef HAVE_ELEMENTARY_X
4277    if (elm_widget_focus_get(obj))
4278       ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
4279 #endif
4280    ///////////
4281    sd->changed = EINA_TRUE;
4282    elm_layout_sizing_eval(obj);
4283 }
4284
4285 EAPI void
4286 elm_entry_line_wrap_set(Evas_Object *obj,
4287                         Elm_Wrap_Type wrap)
4288 {
4289    ELM_ENTRY_CHECK(obj);
4290    ELM_ENTRY_DATA_GET(obj, sd);
4291
4292    if (sd->line_wrap == wrap) return;
4293    sd->last_w = -1;
4294    sd->line_wrap = wrap;
4295    _elm_entry_smart_theme(obj);
4296 }
4297
4298 EAPI Elm_Wrap_Type
4299 elm_entry_line_wrap_get(const Evas_Object *obj)
4300 {
4301    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4302    ELM_ENTRY_DATA_GET(obj, sd);
4303
4304    return sd->line_wrap;
4305 }
4306
4307 EAPI void
4308 elm_entry_editable_set(Evas_Object *obj,
4309                        Eina_Bool editable)
4310 {
4311    ELM_ENTRY_CHECK(obj);
4312    ELM_ENTRY_DATA_GET(obj, sd);
4313
4314    if (sd->editable == editable) return;
4315    sd->editable = editable;
4316    _elm_entry_smart_theme(obj);
4317
4318 #ifdef HAVE_ELEMENTARY_X
4319    if (editable)
4320      elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
4321    else
4322      elm_drop_target_del(obj);
4323 #endif
4324 }
4325
4326 EAPI Eina_Bool
4327 elm_entry_editable_get(const Evas_Object *obj)
4328 {
4329    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4330    ELM_ENTRY_DATA_GET(obj, sd);
4331
4332    return sd->editable;
4333 }
4334
4335 EAPI void
4336 elm_entry_select_none(Evas_Object *obj)
4337 {
4338    ELM_ENTRY_CHECK(obj);
4339    ELM_ENTRY_DATA_GET(obj, sd);
4340
4341    if ((sd->password)) return;
4342    if (sd->sel_mode)
4343      {
4344         sd->sel_mode = EINA_FALSE;
4345         if (!_elm_config->desktop_entry)
4346           edje_object_part_text_select_allow_set
4347             (sd->entry_edje, "elm.text", EINA_FALSE);
4348         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
4349      }
4350    sd->have_selection = EINA_FALSE;
4351    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
4352 }
4353
4354 EAPI void
4355 elm_entry_select_all(Evas_Object *obj)
4356 {
4357    ELM_ENTRY_CHECK(obj);
4358    ELM_ENTRY_DATA_GET(obj, sd);
4359
4360    if ((sd->password)) return;
4361    if (sd->sel_mode)
4362      {
4363         sd->sel_mode = EINA_FALSE;
4364         if (!_elm_config->desktop_entry)
4365           edje_object_part_text_select_allow_set
4366             (sd->entry_edje, "elm.text", EINA_FALSE);
4367         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
4368      }
4369    edje_object_part_text_select_all(sd->entry_edje, "elm.text");
4370 }
4371
4372 EAPI Eina_Bool
4373 elm_entry_cursor_geometry_get(const Evas_Object *obj,
4374                               Evas_Coord *x,
4375                               Evas_Coord *y,
4376                               Evas_Coord *w,
4377                               Evas_Coord *h)
4378 {
4379    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4380    ELM_ENTRY_DATA_GET(obj, sd);
4381
4382    edje_object_part_text_cursor_geometry_get
4383      (sd->entry_edje, "elm.text", x, y, w, h);
4384    return EINA_TRUE;
4385 }
4386
4387 EAPI Eina_Bool
4388 elm_entry_cursor_next(Evas_Object *obj)
4389 {
4390    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4391    ELM_ENTRY_DATA_GET(obj, sd);
4392
4393    return edje_object_part_text_cursor_next
4394             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4395 }
4396
4397 EAPI Eina_Bool
4398 elm_entry_cursor_prev(Evas_Object *obj)
4399 {
4400    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4401    ELM_ENTRY_DATA_GET(obj, sd);
4402
4403    return edje_object_part_text_cursor_prev
4404             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4405 }
4406
4407 EAPI Eina_Bool
4408 elm_entry_cursor_up(Evas_Object *obj)
4409 {
4410    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4411    ELM_ENTRY_DATA_GET(obj, sd);
4412
4413    return edje_object_part_text_cursor_up
4414             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4415 }
4416
4417 EAPI Eina_Bool
4418 elm_entry_cursor_down(Evas_Object *obj)
4419 {
4420    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4421    ELM_ENTRY_DATA_GET(obj, sd);
4422
4423    return edje_object_part_text_cursor_down
4424             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4425 }
4426
4427 EAPI void
4428 elm_entry_cursor_begin_set(Evas_Object *obj)
4429 {
4430    ELM_ENTRY_CHECK(obj);
4431    ELM_ENTRY_DATA_GET(obj, sd);
4432
4433    edje_object_part_text_cursor_begin_set
4434      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4435 }
4436
4437 EAPI void
4438 elm_entry_cursor_end_set(Evas_Object *obj)
4439 {
4440    ELM_ENTRY_CHECK(obj);
4441    ELM_ENTRY_DATA_GET(obj, sd);
4442
4443    edje_object_part_text_cursor_end_set
4444      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4445 }
4446
4447 EAPI void
4448 elm_entry_cursor_line_begin_set(Evas_Object *obj)
4449 {
4450    ELM_ENTRY_CHECK(obj);
4451    ELM_ENTRY_DATA_GET(obj, sd);
4452
4453    edje_object_part_text_cursor_line_begin_set
4454      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4455 }
4456
4457 EAPI void
4458 elm_entry_cursor_line_end_set(Evas_Object *obj)
4459 {
4460    ELM_ENTRY_CHECK(obj);
4461    ELM_ENTRY_DATA_GET(obj, sd);
4462
4463    edje_object_part_text_cursor_line_end_set
4464      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4465 }
4466
4467 EAPI void
4468 elm_entry_cursor_selection_begin(Evas_Object *obj)
4469 {
4470    ELM_ENTRY_CHECK(obj);
4471    ELM_ENTRY_DATA_GET(obj, sd);
4472
4473    edje_object_part_text_select_begin(sd->entry_edje, "elm.text");
4474 }
4475
4476 EAPI void
4477 elm_entry_cursor_selection_end(Evas_Object *obj)
4478 {
4479    ELM_ENTRY_CHECK(obj);
4480    ELM_ENTRY_DATA_GET(obj, sd);
4481
4482    edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
4483 }
4484
4485 EAPI Eina_Bool
4486 elm_entry_cursor_is_format_get(const Evas_Object *obj)
4487 {
4488    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4489    ELM_ENTRY_DATA_GET(obj, sd);
4490
4491    return edje_object_part_text_cursor_is_format_get
4492             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4493 }
4494
4495 EAPI Eina_Bool
4496 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
4497 {
4498    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4499    ELM_ENTRY_DATA_GET(obj, sd);
4500
4501    return edje_object_part_text_cursor_is_visible_format_get
4502             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4503 }
4504
4505 EAPI char *
4506 elm_entry_cursor_content_get(const Evas_Object *obj)
4507 {
4508    ELM_ENTRY_CHECK(obj) NULL;
4509    ELM_ENTRY_DATA_GET(obj, sd);
4510
4511    return edje_object_part_text_cursor_content_get
4512             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4513 }
4514
4515 EAPI void
4516 elm_entry_cursor_pos_set(Evas_Object *obj,
4517                          int pos)
4518 {
4519    ELM_ENTRY_CHECK(obj);
4520    ELM_ENTRY_DATA_GET(obj, sd);
4521
4522    edje_object_part_text_cursor_pos_set
4523      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, pos);
4524    edje_object_message_signal_process(sd->entry_edje);
4525 }
4526
4527 EAPI int
4528 elm_entry_cursor_pos_get(const Evas_Object *obj)
4529 {
4530    ELM_ENTRY_CHECK(obj) 0;
4531    ELM_ENTRY_DATA_GET(obj, sd);
4532
4533    return edje_object_part_text_cursor_pos_get
4534             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4535 }
4536
4537 EAPI void
4538 elm_entry_selection_cut(Evas_Object *obj)
4539 {
4540    ELM_ENTRY_CHECK(obj);
4541    ELM_ENTRY_DATA_GET(obj, sd);
4542
4543    if ((sd->password)) return;
4544    _cut_cb(obj, NULL, NULL);
4545 }
4546
4547 EAPI void
4548 elm_entry_selection_copy(Evas_Object *obj)
4549 {
4550    ELM_ENTRY_CHECK(obj);
4551    ELM_ENTRY_DATA_GET(obj, sd);
4552
4553    if ((sd->password)) return;
4554    _copy_cb(obj, NULL, NULL);
4555 }
4556
4557 EAPI void
4558 elm_entry_selection_paste(Evas_Object *obj)
4559 {
4560    ELM_ENTRY_CHECK(obj);
4561    ELM_ENTRY_DATA_GET(obj, sd);
4562
4563    if ((sd->password)) return;
4564    _paste_cb(obj, NULL, NULL);
4565 }
4566
4567 EAPI void
4568 elm_entry_context_menu_clear(Evas_Object *obj)
4569 {
4570    Elm_Entry_Context_Menu_Item *it;
4571
4572    ELM_ENTRY_CHECK(obj);
4573    ELM_ENTRY_DATA_GET(obj, sd);
4574
4575    EINA_LIST_FREE (sd->items, it)
4576      {
4577         eina_stringshare_del(it->label);
4578         eina_stringshare_del(it->icon_file);
4579         eina_stringshare_del(it->icon_group);
4580         free(it);
4581      }
4582 }
4583
4584 EAPI void
4585 elm_entry_context_menu_item_add(Evas_Object *obj,
4586                                 const char *label,
4587                                 const char *icon_file,
4588                                 Elm_Icon_Type icon_type,
4589                                 Evas_Smart_Cb func,
4590                                 const void *data)
4591 {
4592    Elm_Entry_Context_Menu_Item *it;
4593
4594    ELM_ENTRY_CHECK(obj);
4595    ELM_ENTRY_DATA_GET(obj, sd);
4596
4597    it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
4598    if (!it) return;
4599
4600    sd->items = eina_list_append(sd->items, it);
4601    it->obj = obj;
4602    it->label = eina_stringshare_add(label);
4603    it->icon_file = eina_stringshare_add(icon_file);
4604    it->icon_type = icon_type;
4605    it->func = func;
4606    it->data = (void *)data;
4607 }
4608
4609 EAPI void
4610 elm_entry_context_menu_disabled_set(Evas_Object *obj,
4611                                     Eina_Bool disabled)
4612 {
4613    ELM_ENTRY_CHECK(obj);
4614    ELM_ENTRY_DATA_GET(obj, sd);
4615
4616    if (sd->context_menu == !disabled) return;
4617    sd->context_menu = !disabled;
4618 }
4619
4620 EAPI Eina_Bool
4621 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
4622 {
4623    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4624    ELM_ENTRY_DATA_GET(obj, sd);
4625
4626    return !sd->context_menu;
4627 }
4628
4629 // TIZEN ONLY - START
4630 EAPI void
4631 elm_entry_select_allow_set(Evas_Object *obj,
4632                            Eina_Bool allow)
4633 {
4634    ELM_ENTRY_CHECK(obj);
4635    ELM_ENTRY_DATA_GET(obj, sd);
4636
4637    if (sd->sel_allow == allow) return;
4638    sd->sel_allow = allow;
4639
4640    edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", allow);
4641 }
4642
4643 EAPI Eina_Bool
4644 elm_entry_select_allow_get(const Evas_Object *obj)
4645 {
4646    ELM_ENTRY_CHECK(obj);
4647    ELM_ENTRY_DATA_GET(obj, sd);
4648
4649    return sd->sel_allow;
4650 }
4651
4652 EAPI void
4653 elm_entry_cursor_handler_disabled_set(Evas_Object *obj,
4654                                       Eina_Bool disabled)
4655 {
4656    ELM_ENTRY_CHECK(obj);
4657    ELM_ENTRY_DATA_GET(obj, sd);
4658
4659    if (sd->cursor_handler_disabled == disabled) return;
4660    sd->cursor_handler_disabled = disabled;
4661
4662    if (!_elm_config->desktop_entry)
4663      edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", disabled);
4664 }
4665
4666 EAPI Eina_Bool
4667 elm_entry_cursor_handler_disabled_get(const Evas_Object *obj)
4668 {
4669    ELM_ENTRY_CHECK(obj);
4670    ELM_ENTRY_DATA_GET(obj, sd);
4671    return sd->cursor_handler_disabled;
4672 }
4673 // TIZEN ONLY - END
4674
4675 EAPI void
4676 elm_entry_item_provider_append(Evas_Object *obj,
4677                                Elm_Entry_Item_Provider_Cb func,
4678                                void *data)
4679 {
4680    Elm_Entry_Item_Provider *ip;
4681
4682    ELM_ENTRY_CHECK(obj);
4683    ELM_ENTRY_DATA_GET(obj, sd);
4684    EINA_SAFETY_ON_NULL_RETURN(func);
4685
4686    ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
4687    if (!ip) return;
4688
4689    ip->func = func;
4690    ip->data = data;
4691    sd->item_providers = eina_list_append(sd->item_providers, ip);
4692 }
4693
4694 EAPI void
4695 elm_entry_item_provider_prepend(Evas_Object *obj,
4696                                 Elm_Entry_Item_Provider_Cb func,
4697                                 void *data)
4698 {
4699    Elm_Entry_Item_Provider *ip;
4700
4701    ELM_ENTRY_CHECK(obj);
4702    ELM_ENTRY_DATA_GET(obj, sd);
4703    EINA_SAFETY_ON_NULL_RETURN(func);
4704
4705    ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
4706    if (!ip) return;
4707
4708    ip->func = func;
4709    ip->data = data;
4710    sd->item_providers = eina_list_prepend(sd->item_providers, ip);
4711 }
4712
4713 EAPI void
4714 elm_entry_item_provider_remove(Evas_Object *obj,
4715                                Elm_Entry_Item_Provider_Cb func,
4716                                void *data)
4717 {
4718    Eina_List *l;
4719    Elm_Entry_Item_Provider *ip;
4720
4721    ELM_ENTRY_CHECK(obj);
4722    ELM_ENTRY_DATA_GET(obj, sd);
4723    EINA_SAFETY_ON_NULL_RETURN(func);
4724
4725    EINA_LIST_FOREACH(sd->item_providers, l, ip)
4726      {
4727         if ((ip->func == func) && ((!data) || (ip->data == data)))
4728           {
4729              sd->item_providers = eina_list_remove_list(sd->item_providers, l);
4730              free(ip);
4731              return;
4732           }
4733      }
4734 }
4735
4736 EAPI void
4737 elm_entry_markup_filter_append(Evas_Object *obj,
4738                                Elm_Entry_Filter_Cb func,
4739                                void *data)
4740 {
4741    Elm_Entry_Markup_Filter *tf;
4742
4743    ELM_ENTRY_CHECK(obj);
4744    ELM_ENTRY_DATA_GET(obj, sd);
4745    EINA_SAFETY_ON_NULL_RETURN(func);
4746
4747    tf = _filter_new(func, data);
4748    if (!tf) return;
4749
4750    sd->markup_filters = eina_list_append(sd->markup_filters, tf);
4751 }
4752
4753 EAPI void
4754 elm_entry_markup_filter_prepend(Evas_Object *obj,
4755                                 Elm_Entry_Filter_Cb func,
4756                                 void *data)
4757 {
4758    Elm_Entry_Markup_Filter *tf;
4759
4760    ELM_ENTRY_CHECK(obj);
4761    ELM_ENTRY_DATA_GET(obj, sd);
4762    EINA_SAFETY_ON_NULL_RETURN(func);
4763
4764    tf = _filter_new(func, data);
4765    if (!tf) return;
4766
4767    sd->markup_filters = eina_list_prepend(sd->markup_filters, tf);
4768 }
4769
4770 EAPI void
4771 elm_entry_markup_filter_remove(Evas_Object *obj,
4772                                Elm_Entry_Filter_Cb func,
4773                                void *data)
4774 {
4775    Eina_List *l;
4776    Elm_Entry_Markup_Filter *tf;
4777
4778    ELM_ENTRY_CHECK(obj);
4779    ELM_ENTRY_DATA_GET(obj, sd);
4780    EINA_SAFETY_ON_NULL_RETURN(func);
4781
4782    EINA_LIST_FOREACH(sd->markup_filters, l, tf)
4783      {
4784         if ((tf->func == func) && ((!data) || (tf->data == data)))
4785           {
4786              sd->markup_filters = eina_list_remove_list(sd->markup_filters, l);
4787              _filter_free(tf);
4788              return;
4789           }
4790      }
4791 }
4792
4793 EAPI char *
4794 elm_entry_markup_to_utf8(const char *s)
4795 {
4796    char *ss = _elm_util_mkup_to_text(s);
4797    if (!ss) ss = strdup("");
4798    return ss;
4799 }
4800
4801 EAPI char *
4802 elm_entry_utf8_to_markup(const char *s)
4803 {
4804    char *ss = _elm_util_text_to_mkup(s);
4805    if (!ss) ss = strdup("");
4806    return ss;
4807 }
4808
4809 static const char *
4810 _text_get(const Evas_Object *obj)
4811 {
4812    return elm_object_text_get(obj);
4813 }
4814
4815 EAPI void
4816 elm_entry_filter_limit_size(void *data,
4817                             Evas_Object *entry,
4818                             char **text)
4819 {
4820    const char *(*text_get)(const Evas_Object *);
4821    Elm_Entry_Filter_Limit_Size *lim = data;
4822    char *current, *utfstr;
4823    int len, newlen;
4824
4825    EINA_SAFETY_ON_NULL_RETURN(data);
4826    EINA_SAFETY_ON_NULL_RETURN(entry);
4827    EINA_SAFETY_ON_NULL_RETURN(text);
4828
4829    /* hack. I don't want to copy the entire function to work with
4830     * scrolled_entry */
4831    text_get = _text_get;
4832
4833    current = elm_entry_markup_to_utf8(text_get(entry));
4834    utfstr = elm_entry_markup_to_utf8(*text);
4835
4836    if (lim->max_char_count > 0)
4837      {
4838         len = evas_string_char_len_get(current);
4839         newlen = evas_string_char_len_get(utfstr);
4840         if ((len >= lim->max_char_count) && (newlen > 0))
4841           {
4842              evas_object_smart_callback_call(entry, SIG_MAX_LENGHT, NULL);
4843              free(*text);
4844              *text = NULL;
4845              free(current);
4846              free(utfstr);
4847              return;
4848           }
4849         if ((len + newlen) > lim->max_char_count)
4850           _chars_add_till_limit
4851             (entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4852      }
4853    else if (lim->max_byte_count > 0)
4854      {
4855         len = strlen(current);
4856         newlen = strlen(utfstr);
4857         if ((len >= lim->max_byte_count) && (newlen > 0))
4858           {
4859              evas_object_smart_callback_call(entry, SIG_MAX_LENGHT, NULL);
4860              free(*text);
4861              *text = NULL;
4862              free(current);
4863              free(utfstr);
4864              return;
4865           }
4866         if ((len + newlen) > lim->max_byte_count)
4867           _chars_add_till_limit
4868             (entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4869      }
4870
4871    free(current);
4872    free(utfstr);
4873 }
4874
4875 EAPI void
4876 elm_entry_filter_accept_set(void *data,
4877                             Evas_Object *entry __UNUSED__,
4878                             char **text)
4879 {
4880    int read_idx, last_read_idx = 0, read_char;
4881    Elm_Entry_Filter_Accept_Set *as = data;
4882    Eina_Bool goes_in;
4883    const char *set;
4884    char *insert;
4885
4886    EINA_SAFETY_ON_NULL_RETURN(data);
4887    EINA_SAFETY_ON_NULL_RETURN(text);
4888
4889    if ((!as->accepted) && (!as->rejected))
4890      return;
4891
4892    if (as->accepted)
4893      {
4894         set = as->accepted;
4895         goes_in = EINA_TRUE;
4896      }
4897    else
4898      {
4899         set = as->rejected;
4900         goes_in = EINA_FALSE;
4901      }
4902
4903    insert = *text;
4904    read_idx = evas_string_char_next_get(*text, 0, &read_char);
4905    while (read_char)
4906      {
4907         int cmp_idx, cmp_char;
4908         Eina_Bool in_set = EINA_FALSE;
4909
4910         cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4911         while (cmp_char)
4912           {
4913              if (read_char == cmp_char)
4914                {
4915                   in_set = EINA_TRUE;
4916                   break;
4917                }
4918              cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4919           }
4920         if (in_set == goes_in)
4921           {
4922              int size = read_idx - last_read_idx;
4923              const char *src = (*text) + last_read_idx;
4924              if (src != insert)
4925                memcpy(insert, *text + last_read_idx, size);
4926              insert += size;
4927           }
4928         last_read_idx = read_idx;
4929         read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4930      }
4931    *insert = 0;
4932 }
4933
4934 EAPI Eina_Bool
4935 elm_entry_file_set(Evas_Object *obj,
4936                    const char *file,
4937                    Elm_Text_Format format)
4938 {
4939    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4940    ELM_ENTRY_DATA_GET(obj, sd);
4941
4942    if (sd->delay_write)
4943      {
4944         ecore_timer_del(sd->delay_write);
4945         sd->delay_write = NULL;
4946      }
4947
4948    if (sd->auto_save) _save_do(obj);
4949    eina_stringshare_replace(&sd->file, file);
4950    sd->format = format;
4951    return _load_do(obj);
4952 }
4953
4954 EAPI void
4955 elm_entry_file_get(const Evas_Object *obj,
4956                    const char **file,
4957                    Elm_Text_Format *format)
4958 {
4959    ELM_ENTRY_CHECK(obj);
4960    ELM_ENTRY_DATA_GET(obj, sd);
4961
4962    if (file) *file = sd->file;
4963    if (format) *format = sd->format;
4964 }
4965
4966 EAPI void
4967 elm_entry_file_save(Evas_Object *obj)
4968 {
4969    ELM_ENTRY_CHECK(obj);
4970    ELM_ENTRY_DATA_GET(obj, sd);
4971
4972    if (sd->delay_write)
4973      {
4974         ecore_timer_del(sd->delay_write);
4975         sd->delay_write = NULL;
4976      }
4977    _save_do(obj);
4978    sd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4979 }
4980
4981 EAPI void
4982 elm_entry_autosave_set(Evas_Object *obj,
4983                        Eina_Bool auto_save)
4984 {
4985    ELM_ENTRY_CHECK(obj);
4986    ELM_ENTRY_DATA_GET(obj, sd);
4987
4988    sd->auto_save = !!auto_save;
4989 }
4990
4991 EAPI Eina_Bool
4992 elm_entry_autosave_get(const Evas_Object *obj)
4993 {
4994    ELM_ENTRY_CHECK(obj) EINA_FALSE;
4995    ELM_ENTRY_DATA_GET(obj, sd);
4996
4997    return sd->auto_save;
4998 }
4999
5000 EINA_DEPRECATED EAPI void
5001 elm_entry_cnp_textonly_set(Evas_Object *obj,
5002                            Eina_Bool textonly)
5003 {
5004    Elm_Cnp_Mode cnp_mode = ELM_CNP_MODE_MARKUP;
5005
5006    ELM_ENTRY_CHECK(obj);
5007
5008    if (textonly)
5009      cnp_mode = ELM_CNP_MODE_NO_IMAGE;
5010    elm_entry_cnp_mode_set(obj, cnp_mode);
5011 }
5012
5013 EINA_DEPRECATED EAPI Eina_Bool
5014 elm_entry_cnp_textonly_get(const Evas_Object *obj)
5015 {
5016    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5017
5018    return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
5019 }
5020
5021 EAPI void
5022 elm_entry_cnp_mode_set(Evas_Object *obj,
5023                        Elm_Cnp_Mode cnp_mode)
5024 {
5025    Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
5026
5027    ELM_ENTRY_CHECK(obj);
5028    ELM_ENTRY_DATA_GET(obj, sd);
5029
5030    if (sd->cnp_mode == cnp_mode) return;
5031    sd->cnp_mode = cnp_mode;
5032    if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
5033      format = ELM_SEL_FORMAT_TEXT;
5034    else if (cnp_mode == ELM_CNP_MODE_MARKUP)
5035      format |= ELM_SEL_FORMAT_IMAGE;
5036 #ifdef HAVE_ELEMENTARY_X
5037    elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
5038 #endif
5039 }
5040
5041 EAPI Elm_Cnp_Mode
5042 elm_entry_cnp_mode_get(const Evas_Object *obj)
5043 {
5044    ELM_ENTRY_CHECK(obj) ELM_CNP_MODE_MARKUP;
5045    ELM_ENTRY_DATA_GET(obj, sd);
5046
5047    return sd->cnp_mode;
5048 }
5049
5050 EAPI void
5051 elm_entry_scrollable_set(Evas_Object *obj,
5052                          Eina_Bool scroll)
5053 {
5054    ELM_ENTRY_CHECK(obj);
5055    ELM_ENTRY_DATA_GET(obj, sd);
5056
5057    scroll = !!scroll;
5058    if (sd->scroll == scroll) return;
5059    sd->scroll = scroll;
5060
5061    if (sd->scroll)
5062      {
5063         /* we now must re-theme ourselves to a scroller decoration
5064          * and move the entry looking object to be the content of the
5065          * scrollable view */
5066         elm_widget_resize_object_set(obj, NULL);
5067         elm_widget_sub_object_add(obj, sd->entry_edje);
5068
5069         if (!sd->scr_edje)
5070           {
5071              sd->scr_edje = edje_object_add(evas_object_evas_get(obj));
5072
5073              elm_widget_theme_object_set
5074                (obj, sd->scr_edje, "scroller", "entry",
5075                elm_widget_style_get(obj));
5076
5077              evas_object_size_hint_weight_set
5078                (sd->scr_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5079              evas_object_size_hint_align_set
5080                (sd->scr_edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
5081
5082              evas_object_propagate_events_set(sd->scr_edje, EINA_TRUE);
5083           }
5084
5085         elm_widget_resize_object_set(obj, sd->scr_edje);
5086
5087         sd->s_iface->objects_set(obj, sd->scr_edje, sd->hit_rect);
5088
5089         sd->s_iface->bounce_allow_set(obj, sd->h_bounce, sd->v_bounce);
5090         if (sd->single_line)
5091           sd->s_iface->policy_set
5092             (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
5093         else
5094           sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
5095         sd->s_iface->content_set(obj, sd->entry_edje);
5096         elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
5097      }
5098    else
5099      {
5100         if (sd->scr_edje)
5101           {
5102              sd->s_iface->content_set(obj, NULL);
5103              evas_object_hide(sd->scr_edje);
5104           }
5105         elm_widget_resize_object_set(obj, sd->entry_edje);
5106
5107         if (sd->scr_edje)
5108           elm_widget_sub_object_add(obj, sd->scr_edje);
5109
5110         sd->s_iface->objects_set(obj, sd->entry_edje, sd->hit_rect);
5111
5112         elm_widget_on_show_region_hook_set(obj, NULL, NULL);
5113      }
5114    sd->last_w = -1;
5115    _elm_entry_smart_theme(obj);
5116 }
5117
5118 EAPI Eina_Bool
5119 elm_entry_scrollable_get(const Evas_Object *obj)
5120 {
5121    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5122    ELM_ENTRY_DATA_GET(obj, sd);
5123
5124    return sd->scroll;
5125 }
5126
5127 EAPI void
5128 elm_entry_icon_visible_set(Evas_Object *obj,
5129                            Eina_Bool setting)
5130 {
5131    ELM_ENTRY_CHECK(obj);
5132
5133    if (!elm_layout_content_get(obj, "elm.swallow.icon")) return;
5134
5135    if (setting)
5136      elm_layout_signal_emit(obj, "elm,action,show,icon", "elm");
5137    else
5138      elm_layout_signal_emit(obj, "elm,action,hide,icon", "elm");
5139
5140    elm_layout_sizing_eval(obj);
5141 }
5142
5143 EAPI void
5144 elm_entry_end_visible_set(Evas_Object *obj,
5145                           Eina_Bool setting)
5146 {
5147    ELM_ENTRY_CHECK(obj);
5148
5149    if (!elm_layout_content_get(obj, "elm.swallow.icon")) return;
5150
5151    if (setting)
5152      elm_layout_signal_emit(obj, "elm,action,show,end", "elm");
5153    else
5154      elm_layout_signal_emit(obj, "elm,action,hide,end", "elm");
5155
5156    elm_layout_sizing_eval(obj);
5157 }
5158
5159 EAPI void
5160 elm_entry_scrollbar_policy_set(Evas_Object *obj,
5161                                Elm_Scroller_Policy h,
5162                                Elm_Scroller_Policy v)
5163 {
5164    ELM_ENTRY_CHECK(obj);
5165    ELM_ENTRY_DATA_GET(obj, sd);
5166
5167    sd->policy_h = h;
5168    sd->policy_v = v;
5169    sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
5170 }
5171
5172 EAPI void
5173 elm_entry_bounce_set(Evas_Object *obj,
5174                      Eina_Bool h_bounce,
5175                      Eina_Bool v_bounce)
5176 {
5177    ELM_ENTRY_CHECK(obj);
5178    ELM_ENTRY_DATA_GET(obj, sd);
5179
5180    sd->h_bounce = h_bounce;
5181    sd->v_bounce = v_bounce;
5182    sd->s_iface->bounce_allow_set(obj, h_bounce, v_bounce);
5183 }
5184
5185 EAPI void
5186 elm_entry_bounce_get(const Evas_Object *obj,
5187                      Eina_Bool *h_bounce,
5188                      Eina_Bool *v_bounce)
5189 {
5190    ELM_ENTRY_CHECK(obj);
5191    ELM_ENTRY_DATA_GET(obj, sd);
5192
5193    sd->s_iface->bounce_allow_get(obj, h_bounce, v_bounce);
5194 }
5195
5196 EAPI void
5197 elm_entry_input_panel_layout_set(Evas_Object *obj,
5198                                  Elm_Input_Panel_Layout layout)
5199 {
5200    ELM_ENTRY_CHECK(obj);
5201    ELM_ENTRY_DATA_GET(obj, sd);
5202
5203    sd->input_panel_layout = layout;
5204
5205    edje_object_part_text_input_panel_layout_set
5206      (sd->entry_edje, "elm.text", layout);
5207 }
5208
5209 EAPI Elm_Input_Panel_Layout
5210 elm_entry_input_panel_layout_get(const Evas_Object *obj)
5211 {
5212    ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_LAYOUT_INVALID;
5213    ELM_ENTRY_DATA_GET(obj, sd);
5214
5215    return sd->input_panel_layout;
5216 }
5217
5218 EAPI void
5219 elm_entry_input_panel_layout_variation_set(Evas_Object *obj,
5220                                            int variation)
5221 {
5222    ELM_ENTRY_CHECK(obj);
5223    ELM_ENTRY_DATA_GET(obj, sd);
5224
5225    sd->input_panel_layout_variation = variation;
5226
5227    edje_object_part_text_input_panel_layout_variation_set
5228       (sd->entry_edje, "elm.text", variation);
5229 }
5230
5231 EAPI int
5232 elm_entry_input_panel_layout_variation_get(const Evas_Object *obj)
5233 {
5234    ELM_ENTRY_CHECK(obj) 0;
5235    ELM_ENTRY_DATA_GET(obj, sd);
5236
5237    return sd->input_panel_layout_variation;
5238 }
5239
5240 EAPI void
5241 elm_entry_autocapital_type_set(Evas_Object *obj,
5242                                Elm_Autocapital_Type autocapital_type)
5243 {
5244    ELM_ENTRY_CHECK(obj);
5245    ELM_ENTRY_DATA_GET(obj, sd);
5246
5247    sd->autocapital_type = autocapital_type;
5248    edje_object_part_text_autocapital_type_set
5249      (sd->entry_edje, "elm.text", autocapital_type);
5250 }
5251
5252 EAPI Elm_Autocapital_Type
5253 elm_entry_autocapital_type_get(const Evas_Object *obj)
5254 {
5255    ELM_ENTRY_CHECK(obj) ELM_AUTOCAPITAL_TYPE_NONE;
5256    ELM_ENTRY_DATA_GET(obj, sd);
5257
5258    return sd->autocapital_type;
5259 }
5260
5261 EAPI void
5262 elm_entry_prediction_allow_set(Evas_Object *obj,
5263                                Eina_Bool prediction)
5264 {
5265    ELM_ENTRY_CHECK(obj);
5266    ELM_ENTRY_DATA_GET(obj, sd);
5267
5268    sd->prediction_allow = prediction;
5269    edje_object_part_text_prediction_allow_set
5270      (sd->entry_edje, "elm.text", prediction);
5271 }
5272
5273 EAPI Eina_Bool
5274 elm_entry_prediction_allow_get(const Evas_Object *obj)
5275 {
5276    ELM_ENTRY_CHECK(obj) EINA_TRUE;
5277    ELM_ENTRY_DATA_GET(obj, sd);
5278
5279    return sd->prediction_allow;
5280 }
5281
5282 EAPI void
5283 elm_entry_imf_context_reset(Evas_Object *obj)
5284 {
5285    ELM_ENTRY_CHECK(obj);
5286    ELM_ENTRY_DATA_GET(obj, sd);
5287
5288    edje_object_part_text_imf_context_reset(sd->entry_edje, "elm.text");
5289 }
5290
5291 EAPI void
5292 elm_entry_input_panel_enabled_set(Evas_Object *obj,
5293                                   Eina_Bool enabled)
5294 {
5295    ELM_ENTRY_CHECK(obj);
5296    ELM_ENTRY_DATA_GET(obj, sd);
5297
5298    sd->input_panel_enable = enabled;
5299    edje_object_part_text_input_panel_enabled_set
5300      (sd->entry_edje, "elm.text", enabled);
5301 }
5302
5303 EAPI Eina_Bool
5304 elm_entry_input_panel_enabled_get(const Evas_Object *obj)
5305 {
5306    ELM_ENTRY_CHECK(obj) EINA_TRUE;
5307    ELM_ENTRY_DATA_GET(obj, sd);
5308
5309    return sd->input_panel_enable;
5310 }
5311
5312 EAPI void
5313 elm_entry_input_panel_show(Evas_Object *obj)
5314 {
5315    ELM_ENTRY_CHECK(obj);
5316    ELM_ENTRY_DATA_GET(obj, sd);
5317
5318    edje_object_part_text_input_panel_show(sd->entry_edje, "elm.text");
5319 }
5320
5321 EAPI void
5322 elm_entry_input_panel_hide(Evas_Object *obj)
5323 {
5324    ELM_ENTRY_CHECK(obj);
5325    ELM_ENTRY_DATA_GET(obj, sd);
5326
5327    edje_object_part_text_input_panel_hide(sd->entry_edje, "elm.text");
5328 }
5329
5330 EAPI void
5331 elm_entry_input_panel_language_set(Evas_Object *obj,
5332                                    Elm_Input_Panel_Lang lang)
5333 {
5334    ELM_ENTRY_CHECK(obj);
5335    ELM_ENTRY_DATA_GET(obj, sd);
5336
5337    sd->input_panel_lang = lang;
5338    edje_object_part_text_input_panel_language_set
5339      (sd->entry_edje, "elm.text", lang);
5340 }
5341
5342 EAPI Elm_Input_Panel_Lang
5343 elm_entry_input_panel_language_get(const Evas_Object *obj)
5344 {
5345    ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_LANG_AUTOMATIC;
5346    ELM_ENTRY_DATA_GET(obj, sd);
5347
5348    return sd->input_panel_lang;
5349 }
5350
5351 EAPI void
5352 elm_entry_input_panel_imdata_set(Evas_Object *obj,
5353                                  const void *data,
5354                                  int len)
5355 {
5356    ELM_ENTRY_CHECK(obj);
5357    ELM_ENTRY_DATA_GET(obj, sd);
5358
5359    if (sd->input_panel_imdata)
5360      free(sd->input_panel_imdata);
5361
5362    sd->input_panel_imdata = calloc(1, len);
5363    sd->input_panel_imdata_len = len;
5364    memcpy(sd->input_panel_imdata, data, len);
5365
5366    edje_object_part_text_input_panel_imdata_set
5367      (sd->entry_edje, "elm.text", sd->input_panel_imdata,
5368      sd->input_panel_imdata_len);
5369 }
5370
5371 EAPI void
5372 elm_entry_input_panel_imdata_get(const Evas_Object *obj,
5373                                  void *data,
5374                                  int *len)
5375 {
5376    ELM_ENTRY_CHECK(obj);
5377    ELM_ENTRY_DATA_GET(obj, sd);
5378
5379    edje_object_part_text_input_panel_imdata_get
5380      (sd->entry_edje, "elm.text", data, len);
5381 }
5382
5383 EAPI void
5384 elm_entry_input_panel_return_key_type_set(Evas_Object *obj,
5385                                           Elm_Input_Panel_Return_Key_Type
5386                                           return_key_type)
5387 {
5388    ELM_ENTRY_CHECK(obj);
5389    ELM_ENTRY_DATA_GET(obj, sd);
5390
5391    sd->input_panel_return_key_type = return_key_type;
5392
5393    edje_object_part_text_input_panel_return_key_type_set
5394      (sd->entry_edje, "elm.text", return_key_type);
5395 }
5396
5397 EAPI Elm_Input_Panel_Return_Key_Type
5398 elm_entry_input_panel_return_key_type_get(const Evas_Object *obj)
5399 {
5400    ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
5401    ELM_ENTRY_DATA_GET(obj, sd);
5402
5403    return sd->input_panel_return_key_type;
5404 }
5405
5406 EAPI void
5407 elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj,
5408                                               Eina_Bool disabled)
5409 {
5410    ELM_ENTRY_CHECK(obj);
5411    ELM_ENTRY_DATA_GET(obj, sd);
5412
5413    sd->input_panel_return_key_disabled = disabled;
5414
5415    edje_object_part_text_input_panel_return_key_disabled_set
5416      (sd->entry_edje, "elm.text", disabled);
5417 }
5418
5419 EAPI Eina_Bool
5420 elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
5421 {
5422    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5423    ELM_ENTRY_DATA_GET(obj, sd);
5424
5425    return sd->input_panel_return_key_disabled;
5426 }
5427
5428 EAPI void
5429 elm_entry_input_panel_return_key_autoenabled_set(Evas_Object *obj,
5430                                                  Eina_Bool enabled)
5431 {
5432    ELM_ENTRY_CHECK(obj);
5433    ELM_ENTRY_DATA_GET(obj, sd);
5434
5435    sd->auto_return_key = enabled;
5436    _return_key_enabled_check(obj);
5437 }
5438
5439 EAPI void *
5440 elm_entry_imf_context_get(Evas_Object *obj)
5441 {
5442    ELM_ENTRY_CHECK(obj) NULL;
5443    ELM_ENTRY_DATA_GET(obj, sd);
5444    if (!sd) return NULL;
5445
5446    return edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text");
5447 }
5448
5449 /* START - ANCHOR HOVER */
5450 static void
5451 _anchor_parent_del_cb(void *data,
5452                       Evas *e __UNUSED__,
5453                       Evas_Object *obj __UNUSED__,
5454                       void *event_info __UNUSED__)
5455 {
5456    ELM_ENTRY_DATA_GET(data, sd);
5457
5458    sd->anchor_hover.hover_parent = NULL;
5459 }
5460
5461 EAPI void
5462 elm_entry_anchor_hover_parent_set(Evas_Object *obj,
5463                                   Evas_Object *parent)
5464 {
5465    ELM_ENTRY_CHECK(obj);
5466    ELM_ENTRY_DATA_GET(obj, sd);
5467
5468    if (sd->anchor_hover.hover_parent)
5469      evas_object_event_callback_del_full
5470        (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
5471        _anchor_parent_del_cb, obj);
5472    sd->anchor_hover.hover_parent = parent;
5473    if (sd->anchor_hover.hover_parent)
5474      evas_object_event_callback_add
5475        (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
5476        _anchor_parent_del_cb, obj);
5477 }
5478
5479 EAPI Evas_Object *
5480 elm_entry_anchor_hover_parent_get(const Evas_Object *obj)
5481 {
5482    ELM_ENTRY_CHECK(obj) NULL;
5483    ELM_ENTRY_DATA_GET(obj, sd);
5484
5485    return sd->anchor_hover.hover_parent;
5486 }
5487
5488 EAPI void
5489 elm_entry_anchor_hover_style_set(Evas_Object *obj,
5490                                  const char *style)
5491 {
5492    ELM_ENTRY_CHECK(obj);
5493    ELM_ENTRY_DATA_GET(obj, sd);
5494
5495    eina_stringshare_replace(&sd->anchor_hover.hover_style, style);
5496 }
5497
5498 EAPI const char *
5499 elm_entry_anchor_hover_style_get(const Evas_Object *obj)
5500 {
5501    ELM_ENTRY_CHECK(obj) NULL;
5502    ELM_ENTRY_DATA_GET(obj, sd);
5503
5504    return sd->anchor_hover.hover_style;
5505 }
5506
5507 EAPI void
5508 elm_entry_anchor_hover_end(Evas_Object *obj)
5509 {
5510    ELM_ENTRY_CHECK(obj);
5511    ELM_ENTRY_DATA_GET(obj, sd);
5512
5513    if (sd->anchor_hover.hover) evas_object_del(sd->anchor_hover.hover);
5514    if (sd->anchor_hover.pop) evas_object_del(sd->anchor_hover.pop);
5515    sd->anchor_hover.hover = NULL;
5516    sd->anchor_hover.pop = NULL;
5517 }
5518
5519 /* END - ANCHOR HOVER */
5520
5521 ////////////// TIZEN ONLY APIs
5522 EAPI void
5523 elm_entry_magnifier_disabled_set(Evas_Object *obj, Eina_Bool disabled)
5524 {
5525    ELM_ENTRY_CHECK(obj);
5526    ELM_ENTRY_DATA_GET(obj, sd);
5527
5528    if (sd->magnifier_enabled == !disabled) return;
5529    sd->magnifier_enabled = !disabled;
5530 }
5531
5532 EAPI Eina_Bool
5533 elm_entry_magnifier_disabled_get(const Evas_Object *obj)
5534 {
5535    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5536    ELM_ENTRY_DATA_GET(obj, sd);
5537
5538    return !sd->magnifier_enabled;
5539 }
5540
5541 EAPI void
5542 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
5543 {
5544    ELM_ENTRY_CHECK(obj);
5545    ELM_ENTRY_DATA_GET(obj, sd);
5546
5547    sd->mgf_type = type;
5548    _magnifier_create(obj);
5549 }
5550 ////////////////////////////////