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