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