tizen 2.3 release
[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_ACCESS_CHANGED[] = "access,changed";
24 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
25 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
26 static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened";
27 static const char SIG_ANCHOR_IN[] = "anchor,in";
28 static const char SIG_ANCHOR_OUT[] = "anchor,out";
29 static const char SIG_ANCHOR_UP[] = "anchor,up";
30 static const char SIG_CHANGED[] = "changed";
31 static const char SIG_CHANGED_USER[] = "changed,user";
32 static const char SIG_CLICKED[] = "clicked";
33 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
34 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
35 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
36 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
37 static const char SIG_FOCUSED[] = "focused";
38 static const char SIG_LANG_CHANGED[] = "language,changed";
39 static const char SIG_LONGPRESSED[] = "longpressed";
40 static const char SIG_MAX_LENGTH[] = "maxlength,reached";
41 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
42 static const char SIG_PRESS[] = "press";
43 static const char SIG_REDO_REQUEST[] = "redo,request";
44 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
45 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
46 static const char SIG_SELECTION_COPY[] = "selection,copy";
47 static const char SIG_SELECTION_CUT[] = "selection,cut";
48 static const char SIG_SELECTION_PASTE[] = "selection,paste";
49 static const char SIG_SELECTION_START[] = "selection,start";
50 static const char SIG_TEXT_SET_DONE[] = "text,set,done";
51 static const char SIG_THEME_CHANGED[] = "theme,changed";
52 static const char SIG_UNDO_REQUEST[] = "undo,request";
53 static const char SIG_UNFOCUSED[] = "unfocused";
54 static const char SIG_REJECTED[] = "rejected";
55 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
56    {SIG_ABORTED, ""},
57    {SIG_ACTIVATED, ""},
58    {SIG_ACCESS_CHANGED, ""},
59    {SIG_ANCHOR_CLICKED, ""},
60    {SIG_ANCHOR_DOWN, ""},
61    {SIG_ANCHOR_HOVER_OPENED, ""},
62    {SIG_ANCHOR_IN, ""},
63    {SIG_ANCHOR_OUT, ""},
64    {SIG_ANCHOR_UP, ""},
65    {SIG_CHANGED, ""},
66    {SIG_CHANGED_USER, ""},
67    {SIG_CLICKED, ""},
68    {SIG_CLICKED_DOUBLE, ""},
69    {SIG_CLICKED_TRIPLE, ""},
70    {SIG_CURSOR_CHANGED, ""},
71    {SIG_CURSOR_CHANGED_MANUAL, ""},
72    {SIG_FOCUSED, ""},
73    {SIG_LANG_CHANGED, ""},
74    {SIG_LONGPRESSED, ""},
75    {SIG_MAX_LENGTH, ""},
76    {SIG_PREEDIT_CHANGED, ""},
77    {SIG_PRESS, ""},
78    {SIG_REDO_REQUEST, ""},
79    {SIG_SELECTION_CHANGED, ""},
80    {SIG_SELECTION_CLEARED, ""},
81    {SIG_SELECTION_COPY, ""},
82    {SIG_SELECTION_CUT, ""},
83    {SIG_SELECTION_PASTE, ""},
84    {SIG_SELECTION_START, ""},
85    {SIG_TEXT_SET_DONE, ""},
86    {SIG_THEME_CHANGED, ""},
87    {SIG_UNDO_REQUEST, ""},
88    {SIG_UNFOCUSED, ""},
89    {NULL, NULL}
90 };
91
92 static const Elm_Layout_Part_Alias_Description _content_aliases[] =
93 {
94    {"icon", "elm.swallow.icon"},
95    {"end", "elm.swallow.end"},
96    {NULL, NULL}
97 };
98
99 static const Evas_Smart_Interface *_smart_interfaces[] =
100 {
101    (Evas_Smart_Interface *)&ELM_SCROLLABLE_IFACE, NULL
102 };
103
104 EVAS_SMART_SUBCLASS_IFACE_NEW
105   (ELM_ENTRY_SMART_NAME, _elm_entry, Elm_Entry_Smart_Class,
106   Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks,
107   _smart_interfaces);
108
109 static Eina_List *entries = NULL;
110
111 struct _Mod_Api
112 {
113    void (*obj_hook)(Evas_Object *obj);
114    void (*obj_unhook)(Evas_Object *obj);
115    void (*obj_longpress)(Evas_Object *obj);
116    // TIZEN
117    void (*obj_hidemenu) (Evas_Object *obj);
118    void (*obj_mouseup) (Evas_Object *obj);
119    //
120 };
121
122 ////////////////////////// TIZEN ONLY - START
123 static void _hover_cancel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
124 static void _hover_selected_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
125 static void _copy_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
126 static void _cut_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
127 static void _paste_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
128 #ifndef ELM_FEATURE_WEARABLE
129 static void _menu_call(Evas_Object *obj);
130 #endif
131 static void _dnd_enter_cb(void *data, Evas_Object *obj);
132 static void _dnd_leave_cb(void *data, Evas_Object *obj);
133 static void _dnd_pos_cb(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action);
134
135 static void
136 _select_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
137 {
138    ELM_ENTRY_DATA_GET(data, sd);
139
140    if (!sd->sel_allow) return;
141    sd->sel_mode = EINA_TRUE;
142
143    if (edje_object_part_text_selection_get(sd->entry_edje, "elm.text") == NULL)
144      {
145         edje_object_part_text_select_none(sd->entry_edje, "elm.text");
146         edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
147         edje_object_part_text_select_all(sd->entry_edje, "elm.text");
148      }
149    else
150      {
151         edje_object_part_text_cursor_begin_set(sd->entry_edje, "elm.text",
152                                                EDJE_CURSOR_SELECTION_BEGIN);
153         edje_object_part_text_cursor_begin_set(sd->entry_edje, "elm.text",
154                                                EDJE_CURSOR_SELECTION_END);
155         edje_object_part_text_cursor_end_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
156         edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
157 #ifndef ELM_FEATURE_WEARABLE
158         _menu_call(data);
159 #endif
160      }
161 }
162
163 static void
164 _select_word(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
165 {
166    ELM_ENTRY_DATA_GET(data, sd);
167
168    if (!sd->sel_allow) return;
169    sd->sel_mode = EINA_TRUE;
170
171    if (!_elm_config->desktop_entry)
172      {
173         if (!sd->password)
174           edje_object_part_text_select_allow_set
175             (sd->entry_edje, "elm.text", EINA_TRUE);
176      }
177    edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
178    edje_object_part_text_select_word(sd->entry_edje, "elm.text");
179 }
180
181 #ifdef HAVE_ELEMENTARY_X
182 static Ecore_X_Window
183 _cbhm_window_get()
184 {
185    Ecore_X_Atom x_atom_cbhm = ecore_x_atom_get("CBHM_XWIN");
186    Ecore_X_Window x_cbhm_win = 0;
187    unsigned char *buf = NULL;
188    int num = 0;
189    int ret = ecore_x_window_prop_property_get(0, x_atom_cbhm, XA_WINDOW, 0, &buf, &num);
190    if (ret && num)
191      memcpy(&x_cbhm_win, buf, sizeof(Ecore_X_Window));
192    if (buf)
193      free(buf);
194    return x_cbhm_win;
195 }
196 #endif
197
198 static Eina_Bool
199 _cbhm_msg_send(Evas_Object *obj, char *msg)
200 {
201 #ifdef HAVE_ELEMENTARY_X
202    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
203    Ecore_X_Atom x_atom_cbhm_msg = ecore_x_atom_get("CBHM_MSG");
204    Ecore_X_Window xwin = elm_win_xwindow_get(obj);
205
206    if (!x_cbhm_win || !x_atom_cbhm_msg)
207      return EINA_FALSE;
208
209    XClientMessageEvent m;
210    memset(&m, 0, sizeof(m));
211    m.type = ClientMessage;
212    m.display = ecore_x_display_get();
213    m.window = xwin;
214    m.message_type = x_atom_cbhm_msg;
215    m.format = 8;
216    snprintf(m.data.b, 20, "%s", msg);
217
218    XSendEvent(ecore_x_display_get(), x_cbhm_win, False, NoEventMask, (XEvent*)&m);
219
220    ecore_x_sync();
221    return EINA_TRUE;
222 #else
223    return EINA_FALSE;
224 #endif
225 }
226
227 static Eina_Bool
228 _xclient_msg_cb(void *data, int type __UNUSED__, void *event)
229 {
230 #ifdef HAVE_ELEMENTARY_X
231    Evas_Object *obj = (Evas_Object *)data;
232    ELM_ENTRY_DATA_GET(data, sd);
233    Ecore_X_Event_Client_Message *ev = event;
234
235    if (ev->message_type != ecore_x_atom_get("CBHM_MSG"))
236      return ECORE_CALLBACK_PASS_ON;
237
238    if (!strcmp("SET_OWNER", ev->data.b))
239      {
240         if (elm_object_focus_get(obj) == EINA_TRUE)
241           {
242              ecore_x_selection_secondary_set(elm_win_xwindow_get(data), NULL, 0);
243
244              if (sd->cnp_mode != ELM_CNP_MODE_MARKUP)
245                _cbhm_msg_send(data, "show0");
246              else
247                _cbhm_msg_send(data, "show1");
248           }
249      }
250 #endif
251    return ECORE_CALLBACK_PASS_ON;
252 }
253
254 static void
255 _magnifier_hide(void *data)
256 {
257    ELM_ENTRY_DATA_GET(data, sd);
258
259    if (!sd->magnifier_showing) return;
260    evas_object_hide(sd->mgf_bg);
261    elm_object_scroll_freeze_pop(data);
262    sd->magnifier_showing = EINA_FALSE;
263 }
264
265 static void
266 _magnifier_show(void *data)
267 {
268    ELM_ENTRY_DATA_GET(data, sd);
269
270    if (sd->magnifier_showing) return;
271    evas_object_show(sd->mgf_bg);
272    elm_object_scroll_freeze_push(data);
273    sd->magnifier_showing = EINA_TRUE;
274 }
275
276 static Evas_Object *
277 _entry_createicon(void *data,
278       Evas_Object *parent, Evas_Coord *xoff, Evas_Coord *yoff)
279 {
280    int xm, ym;
281    Evas_Object *icon;
282    const char *text;
283    Evas_Coord sel_x = 0, sel_y = 0, sel_h = 0, sel_w = 0, margin_w = 0, margin_h = 0;
284    ELM_ENTRY_DATA_GET(data, sd);
285
286    icon = evas_object_textblock_add(evas_object_evas_get(parent));
287    text = edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
288
289    int r, g, b, a;
290    evas_object_color_get(data, &r, &g, &b, &a);
291    evas_object_color_set(icon, r, g, b, a);
292
293    // Copy style
294    Evas_Textblock_Style *tb_style =
295       (Evas_Textblock_Style *)evas_object_textblock_style_get(elm_entry_textblock_get(data));
296    evas_object_textblock_style_set(icon, tb_style);
297    evas_object_textblock_size_formatted_get(icon, &margin_w, &margin_h);
298
299    evas_object_textblock_text_markup_set(icon, text);
300
301    edje_object_part_text_selection_geometry_get
302       (sd->entry_edje, "elm.text", &sel_x, &sel_y, &sel_w, &sel_h);
303
304    evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
305    evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
306    evas_object_move(icon, sel_x, sel_y);
307    evas_object_resize(icon, sel_w + margin_w, sel_h + margin_h);
308    evas_object_show(icon);
309
310    evas_pointer_canvas_xy_get(evas_object_evas_get(data), &xm, &ym);
311    if (xoff) *xoff = xm - (sel_w / 2);
312    if (yoff) *yoff = ym - (sel_h / 2);
313
314    return icon;
315 }
316
317 static void
318 _magnifier_proxy_update(Evas_Object *obj, double scale)
319 {
320    ELM_ENTRY_DATA_GET(obj, sd);
321
322    Evas_Coord x, y, w, h;
323    Evas_Coord bx, bw;
324    Evas_Coord cx, cy, cw, ch;
325    Evas_Coord mh, ox, oy;
326    Evas_Coord ctnx = 0, ctny = 0;
327    Evas_Coord swx, sww;
328    double px, py, pw, ph;
329
330    evas_object_geometry_get(sd->mgf_bg, &bx, NULL, &bw, NULL);
331    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text",
332                                              &cx, &cy, &cw, &ch);
333    cy += (ch / 2);
334    evas_object_geometry_get(obj, &x, &y, &w, &h);
335
336    if (sd->scroll)
337      {
338         sd->s_iface->content_pos_get(obj, &ox, &oy);
339         cx -= ox;
340         cy -= oy;
341         edje_object_part_geometry_get(sd->scr_edje, "elm.swallow.content",
342                                       &ctnx, &ctny, NULL, NULL);
343      }
344
345    evas_object_geometry_get(sd->mgf_proxy, NULL, NULL, NULL, &mh);
346    edje_object_part_geometry_get(sd->mgf_bg, "swallow", &swx, NULL, &sww, NULL);
347    /* px, py are the scaled offsets that indicates the start
348       position of the magnifier viewport area. */
349    px = -(cx * scale) + (cx + x + ctnx - bx) - swx - ctnx * scale;
350    if (cx + x + ctnx <= bx + swx)
351      {
352         //show cursor at first pos
353         px = -(cx * scale) - ctnx * scale;
354      }
355    else if (x + ctnx + cx + cw * scale >= bx + swx + sww)
356      {
357         //show cursor at last pos
358         double right_off;
359         const char *type = NULL;
360         Evas_Object *top = elm_widget_top_get(obj);
361         Evas_Coord tx = 0, tw = 0;
362         if (top)
363           {
364              type = evas_object_type_get(top);
365              if (type && !strcmp(type, "elm_win"))
366                evas_object_geometry_get(top, &tx, NULL, &tw, NULL);
367           }
368         right_off = tx + tw - (bx + swx + sww);
369         px = px - (cw * scale + right_off);
370      }
371    py = -(cy * scale) + mh * 0.5 - ctny * scale;
372    pw = w * scale;
373    ph = h * scale;
374    evas_object_image_fill_set(sd->mgf_proxy, px, py, pw, ph);
375 }
376
377 static void
378 _magnifier_move(void *data)
379 {
380    ELM_ENTRY_DATA_GET(data, sd);
381
382    Evas_Coord x, y, w, h;
383    Evas_Coord cx, cy, ch, ox = 0, oy = 0;
384    Evas_Coord mw, mh;
385    Evas_Coord sww, swh, adjh;
386    Evas_Coord bdh;
387    Evas_Coord ctnx = 0, ctny = 0;
388    double adj_scale;
389    Evas_Coord mx, my;
390    Evas_Object *top;
391    const char *type = NULL;
392
393    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text",
394                                              &cx, &cy, NULL, &ch);
395    if (sd->scroll)
396      {
397         evas_object_geometry_get(sd->scr_edje, &x, &y, &w, &h);
398         sd->s_iface->content_pos_get(data, &ox, &oy);
399         cx -= ox;
400         cy -= oy;
401      }
402    else
403      evas_object_geometry_get(data, &x, &y, &w, &h);
404
405    edje_object_part_geometry_get(sd->mgf_bg, "bg", NULL, NULL, &mw, &mh);
406    edje_object_part_geometry_get(sd->mgf_bg, "swallow", NULL, NULL, &sww, &swh);
407    bdh = mh - swh;
408    if (sd->scroll)
409      edje_object_part_geometry_get(sd->scr_edje, "elm.swallow.content",
410                                    &ctnx, &ctny, NULL, NULL);
411
412    adjh = ch * sd->mgf_scale + mh - swh;
413    if (adjh < sd->mgf_height)
414      adjh = sd->mgf_height;
415
416    /* move to fully show magnifier */
417    if (cy + y - adjh < 0)
418      oy = adjh - (cy + y);
419
420    //adjusting scale and size
421    adj_scale = sd->mgf_scale;
422    if (cy + y - adjh + oy < 0)
423      {
424         Evas_Coord edj_content_h;
425         adjh = cy + y + ch;
426         if (adjh < sd->mgf_height)
427           adjh = sd->mgf_height;
428         edj_content_h = adjh - bdh;
429         adj_scale = (double)edj_content_h / ch;
430         if (adj_scale > sd->mgf_scale)
431           adj_scale = sd->mgf_scale;
432      }
433    evas_object_resize(sd->mgf_bg, mw, adjh);
434
435    mx = cx + x - (mw / 2) + ctnx;
436    my = cy + y - adjh + oy + ctny;
437    evas_object_move(sd->mgf_bg, mx, my);
438
439    // keep magnifier inside window
440    top = elm_widget_top_get(data);
441    if (top)
442      {
443         type = evas_object_type_get(top);
444         if (type && !strcmp(type, "elm_win"))
445           {
446              Evas_Coord wx, wy, wh, ww;
447              evas_object_geometry_get(top, &wx, &wy, &ww, &wh);
448              if (mx < wx)
449                evas_object_move(sd->mgf_bg, wx, my);
450              else if (mx + mw > wx + ww)
451                evas_object_move(sd->mgf_bg, wx + ww - mw, my);
452           }
453      }
454
455    _magnifier_proxy_update(data, adj_scale);
456 }
457
458 static void
459 _magnifier_create(void *data)
460 {
461    ELM_ENTRY_DATA_GET(data, sd);
462
463    Evas_Coord x, y, w, h, mw, mh;
464    Evas *e;
465    const char* key_data;
466    double elm_scale;
467
468    if (sd->mgf_proxy) evas_object_del(sd->mgf_proxy);
469    if (sd->mgf_bg) evas_object_del(sd->mgf_bg);
470
471    if (sd->scroll)
472      evas_object_geometry_get(sd->scr_edje, &x, &y, &w, &h);
473    else
474      evas_object_geometry_get(data, &x, &y, &w, &h);
475
476    if ((w <= 0) || (h <= 0)) return;
477
478    sd->mgf_bg = edje_object_add(evas_object_evas_get(data));
479
480    _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier",
481                          "fixed-size");
482
483    e = evas_object_evas_get(data);
484
485    key_data = edje_object_data_get(sd->mgf_bg, "height");
486    if (key_data) sd->mgf_height = atoi(key_data);
487    key_data = edje_object_data_get(sd->mgf_bg, "scale");
488    if (key_data)
489      {
490         struct lconv *lc;
491         lc = localeconv();
492         if (lc && lc->decimal_point && strcmp(lc->decimal_point, "."))
493           {
494              char local[128];
495              strncpy(local, key_data, sizeof(local));
496              local[127] = '\0';
497              /* change '.' to local decimal point (ex: ',') */
498              int j = 0;
499              while(local[j] != 0)
500                {
501                   if (local[j] == '.')
502                     {
503                        local[j] = lc->decimal_point[0];
504                        break;
505                     }
506                   j++;
507                }
508              sd->mgf_scale = atof(local);
509           }
510         else
511           sd->mgf_scale = atof(key_data);
512      }
513    else
514      sd->mgf_scale = 1.0;
515
516    key_data = edje_object_data_get(sd->mgf_bg, "arrow");
517    if (key_data)
518      sd->mgf_arrow_height = atoi(key_data);
519    else
520      sd->mgf_arrow_height = 0;
521
522    elm_scale = elm_config_scale_get();
523    sd->mgf_height = (int)((float)sd->mgf_height * elm_scale);
524
525    sd->mgf_proxy = evas_object_image_add(e);
526    edje_object_part_swallow(sd->mgf_bg, "swallow", sd->mgf_proxy);
527    evas_object_image_source_set(sd->mgf_proxy, data);
528
529    /* Tizen Only: Since Proxy has the texture size limitation problem,
530       we set a key value for evas works in some hackish way to avoid this
531       problem. This hackish code should be removed once evas supports
532       a mechanism like a virtual texture. */
533    evas_object_data_set(sd->mgf_proxy, "tizenonly", (void *) 1);
534
535    // REDWOOD ONLY (20140617): support setting mgf color from app
536    if (sd->mgf_bg_color_set)
537    {
538       Edje_Message_Int_Set *msg;
539       msg = malloc(sizeof(Edje_Message_Int_Set) + 3 * sizeof(int));
540       if (!msg) return;
541       msg->count = 4;
542       msg->val[0] = sd->mgf_r;
543       msg->val[1] = sd->mgf_g;
544       msg->val[2] = sd->mgf_b;
545       msg->val[3] = sd->mgf_a;
546       edje_object_message_send(sd->mgf_bg, EDJE_MESSAGE_INT_SET, 1, msg);
547       free(msg);
548    }
549    //
550
551    mw = (Evas_Coord)((float)w * sd->mgf_scale);
552    mh = (Evas_Coord)((float)h * sd->mgf_scale);
553    if ((mw <= 0) || (mh <= 0))
554      return;
555
556    evas_object_layer_set(sd->mgf_bg, EVAS_LAYER_MAX);
557    evas_object_layer_set(sd->mgf_proxy, EVAS_LAYER_MAX);
558 }
559
560 static void
561 _signal_long_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
562 {
563    ELM_ENTRY_DATA_GET(data, sd);
564    if (sd->disabled) return;
565
566    sd->long_pressed = EINA_TRUE;
567    sd->hit_selection = (sd->have_selection) ? /* For text DND */
568       edje_object_part_text_xy_in_selection_get(sd->entry_edje,
569                                                 "elm.text", sd->downx, sd->downy) : EINA_FALSE;
570    if (!sd->hit_selection)
571      sd->drag_started = EINA_FALSE;
572    else if (sd->drag_enabled)
573      {
574         const char *sel =
575            edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
576
577         if ((sel) && (sel[0]))
578           {
579              sd->drag_started = EINA_TRUE;
580              elm_drag_start(data, ELM_SEL_FORMAT_TEXT,
581                             sel,
582                             ELM_XDND_ACTION_COPY,
583                             _entry_createicon, data,
584                             NULL /*Elm_Drag_Pos dragpos*/,
585                             NULL /*void *dragdata*/,
586                             NULL /*Elm_Drag_Accept acceptcb*/,
587                             NULL /*void *acceptdata*/,
588                             NULL /*Elm_Drag_Done dragdone*/,
589                             NULL /*void *donecbdata*/);
590              edje_object_part_text_cursor_handler_disabled_set
591                 (sd->entry_edje, "elm.text", EINA_TRUE);
592              _hover_cancel_cb(data, NULL, NULL);
593           }
594      }
595    if (!sd->drag_started)
596      {
597         _hover_cancel_cb(data, NULL, NULL);
598         if (sd->magnifier_enabled)
599           {
600              if ((sd->api) && (sd->api->obj_hidemenu))
601                sd->api->obj_hidemenu(data);
602              if (sd->has_text)
603                {
604                   _magnifier_create(data);
605                   _magnifier_move(data);
606                   _magnifier_show(data);
607                }
608           }
609      }
610 }
611
612 static void
613 _signal_handler_move_start_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
614 {
615    ELM_ENTRY_DATA_GET(data, sd);
616
617    elm_object_scroll_freeze_push(data);
618
619    if ((sd->api) && (sd->api->obj_hidemenu))
620      sd->api->obj_hidemenu(data);
621
622    if (sd->magnifier_enabled)
623      {
624         if (sd->has_text)
625           {
626              _magnifier_create(data);
627              _magnifier_move(data);
628              _magnifier_show(data);
629           }
630      }
631 }
632
633 static void
634 _signal_handler_move_end_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
635 {
636    elm_object_scroll_freeze_pop(data);
637
638    _magnifier_hide(data);
639 #ifndef ELM_FEATURE_WEARABLE
640    _menu_call(data);
641 #endif
642 }
643
644 static void
645 _signal_handler_moving_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
646 {
647    ELM_ENTRY_DATA_GET(data, sd);
648
649    if ((sd->magnifier_enabled) && (sd->has_text))
650      {
651         _magnifier_move(data);
652         _magnifier_show(data);
653      }
654 }
655
656 static void
657 _signal_handler_click_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
658 {
659    _magnifier_hide(data);
660 #ifndef ELM_FEATURE_WEARABLE
661    _menu_call(data);
662 #endif
663    elm_widget_scroll_freeze_pop(data);
664 }
665
666 static Evas_Coord_Rectangle
667 _intersection_region_get(Evas_Coord_Rectangle rect1, Evas_Coord_Rectangle rect2)
668 {
669    Evas_Coord_Rectangle ret_rect;
670    Evas_Coord_Point l1, l2, r1, r2, p1, p2;
671
672    l1.x = rect1.x;
673    l1.y = rect1.y;
674    r1.x = rect1.x + rect1.w;
675    r1.y = rect1.y + rect1.h;
676
677    l2.x = rect2.x;
678    l2.y = rect2.y;
679    r2.x = rect2.x + rect2.w;
680    r2.y = rect2.y + rect2.h;
681
682    p1.x = (l1.x > l2.x) ? l1.x : l2.x;
683    p1.y = (l1.y > l2.y) ? l1.y : l2.y;
684    p2.x = (r1.x < r2.x) ? r1.x : r2.x;
685    p2.y = (r1.y < r2.y) ? r1.y : r2.y;
686
687    ret_rect.x = p1.x;
688    ret_rect.y = p1.y;
689    ret_rect.w = (p2.x > p1.x) ? p2.x - p1.x : -1;
690    ret_rect.h = (p2.y > p1.y) ? p2.y - p1.y : -1;
691
692    return ret_rect;
693 }
694
695 static Evas_Coord_Rectangle
696 _viewport_region_get(Evas_Object *data)
697 {
698    Evas_Object *parent_obj;
699    Evas_Coord_Rectangle geometry, ret_rect;
700    geometry.x = geometry.y = geometry.w = geometry.h = -1;
701    ret_rect = geometry;
702
703    ELM_ENTRY_DATA_GET(data, sd);
704    if (!data || !strlen(elm_widget_type_get(data))) return geometry;
705
706    if (sd->scroll)
707      {
708         sd->s_iface->content_viewport_size_get(data, &geometry.w, &geometry.h);
709         sd->s_iface->content_viewport_pos_get(data, &geometry.x, &geometry.y);
710      }
711    else
712      {
713         evas_object_geometry_get(data,
714                                  &geometry.x,
715                                  &geometry.y,
716                                  &geometry.w,
717                                  &geometry.h);
718      }
719    ret_rect = geometry;
720
721    parent_obj = data;
722
723    while ((parent_obj = elm_widget_parent_get(parent_obj)))
724      {
725         if (!strcmp(elm_widget_type_get(parent_obj), "elm_scroller") ||
726             !strcmp(elm_widget_type_get(parent_obj), "elm_genlist"))
727           {
728              evas_object_geometry_get(parent_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
729              if ((ret_rect.w == -1) && (ret_rect.h == -1)) ret_rect = geometry;
730              ret_rect = _intersection_region_get(geometry, ret_rect);
731           }
732      }
733
734    return ret_rect;
735 }
736
737 static Evas_Coord_Rectangle
738 _layout_region_get(Evas_Object *data)
739 {
740    Evas_Coord_Rectangle geometry;
741    geometry.x = geometry.y = geometry.w = geometry.h = -1;
742
743    if (!data || !strlen(elm_widget_type_get(data))) return geometry;
744
745    Evas_Object *child_obj = data;
746    Evas_Object *parent_obj;
747
748    while ((parent_obj = elm_widget_parent_get(child_obj)))
749      {
750         if (!strcmp(elm_widget_type_get(parent_obj), "elm_conformant"))
751           {
752              evas_object_geometry_get(child_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
753              return geometry;
754           }
755         child_obj = parent_obj;
756      }
757
758    return geometry;
759 }
760
761 static void
762 _region_recalc_job(void *data)
763 {
764    ELM_ENTRY_DATA_GET(data, sd);
765    Evas_Coord_Rectangle ret_rect;
766
767    sd->region_recalc_job = NULL;
768
769    if (!_elm_config->desktop_entry)
770      {
771         ret_rect = _viewport_region_get(data);
772         edje_object_part_text_viewport_region_set(sd->entry_edje, "elm.text",
773                                                   ret_rect.x, ret_rect.y,
774                                                   ret_rect.w, ret_rect.h);
775         ret_rect = _layout_region_get(data);
776         edje_object_part_text_layout_region_set(sd->entry_edje, "elm.text",
777                                                 ret_rect.x, ret_rect.y,
778                                                 ret_rect.w, ret_rect.h);
779      }
780 }
781
782 static void
783 _region_get_job(void *data)
784 {
785    ELM_ENTRY_DATA_GET(data, sd);
786
787    sd->region_get_job = NULL;
788
789    if (!_elm_config->desktop_entry)
790      {
791         if (sd->region_recalc_job) ecore_job_del(sd->region_recalc_job);
792         sd->region_recalc_job = ecore_job_add(_region_recalc_job, data);
793
794         //evas_smart_objects_calculate(evas_object_evas_get(data)); //remove: too many calculation
795      }
796 }
797
798 static void
799 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
800 {
801    ELM_ENTRY_DATA_GET(data, sd);
802    if (sd->disabled) return;
803
804    if (sd->magnifier_enabled)
805      _magnifier_hide(data);
806 #ifndef ELM_FEATURE_WEARABLE
807    _menu_call(data);
808 #endif
809 }
810
811 static void
812 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
813 {
814    ELM_ENTRY_DATA_GET(data, sd);
815    Evas_Coord cx, cy, cw, ch;
816
817    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
818    if (!sd->deferred_recalc_job)
819      elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
820    else
821      {
822         sd->deferred_cur = EINA_TRUE;
823         sd->cx = cx;
824         sd->cy = cy;
825         sd->cw = cw;
826         sd->ch = ch;
827      }
828 }
829
830 static void
831 _elm_entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
832 {
833    Evas_Event_Key_Down *ev = event_info;
834    if (!ev->keyname) return;
835
836    ELM_ENTRY_DATA_GET(data, sd);
837    if ((sd->api) && (sd->api->obj_hidemenu))
838      sd->api->obj_hidemenu(data);
839 }
840
841 static void
842 _keep_selection(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
843 {
844    ELM_ENTRY_DATA_GET(obj, sd);
845
846    sd->start_sel_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
847                                                             EDJE_CURSOR_SELECTION_BEGIN);
848    sd->end_sel_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
849                                                           EDJE_CURSOR_SELECTION_END);
850 }
851
852 static void
853 _paste_translation(void *data, Evas_Object *obj, void *event_info)
854 {
855    ELM_ENTRY_DATA_GET(obj, sd);
856
857    elm_entry_cursor_pos_set(obj, sd->start_sel_pos);
858    elm_entry_cursor_selection_begin(obj);
859    elm_entry_cursor_pos_set(obj, sd->end_sel_pos);
860    elm_entry_cursor_selection_end(obj);
861    if (data)
862      _elm_entry_entry_paste(obj, data);
863    if ((data) && (event_info))
864      _elm_entry_entry_paste(obj, " ");
865    if (event_info)
866      _elm_entry_entry_paste(obj, event_info);
867 }
868
869 static void
870 _is_selected_all(void *data, Evas_Object *obj, void *event_info __UNUSED__)
871 {
872    if ((!data) || (!obj)) return;
873    ELM_ENTRY_DATA_GET(obj, sd);
874    int pos;
875    Eina_Bool *ret = (Eina_Bool *)data;
876
877    pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
878                                               EDJE_CURSOR_SELECTION_BEGIN);
879    edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
880                                         EDJE_CURSOR_USER, pos);
881    if (edje_object_part_text_cursor_prev(sd->entry_edje, "elm.text", EDJE_CURSOR_USER))
882      {
883         *ret = EINA_FALSE;
884         return;
885      }
886    else
887      {
888         pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
889                                                    EDJE_CURSOR_SELECTION_END);
890         edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
891                                              EDJE_CURSOR_USER, pos);
892         if (edje_object_part_text_cursor_next(sd->entry_edje, "elm.text", EDJE_CURSOR_USER))
893           {
894              *ret = EINA_FALSE;
895              return;
896           }
897      }
898    *ret = EINA_TRUE;
899 }
900
901 void elm_entry_extension_module_data_get(Evas_Object *obj, Elm_Entry_Extension_data *ext_mod)
902 {
903    ELM_ENTRY_DATA_GET(obj, sd);
904
905    ext_mod->cancel = _hover_cancel_cb;
906    ext_mod->copy = _copy_cb;
907    ext_mod->cut = _cut_cb;
908    ext_mod->paste = _paste_cb;
909    ext_mod->select = _select_word;
910    ext_mod->selectall = _select_all;
911    ext_mod->ent = sd->entry_edje;
912    ext_mod->items = sd->items;
913    ext_mod->editable = sd->editable;
914    ext_mod->have_selection = sd->have_selection;
915    ext_mod->password = sd->password;
916    ext_mod->selmode = sd->sel_mode;
917    ext_mod->context_menu = sd->context_menu;
918    ext_mod->cnp_mode = sd->cnp_mode;
919    ext_mod->viewport_rect = _viewport_region_get(obj);
920    ext_mod->keep_selection = _keep_selection;
921    ext_mod->paste_translation = _paste_translation;
922    ext_mod->is_selected_all = _is_selected_all;
923 }
924
925 #ifdef HAVE_ELEMENTARY_X
926 /* Example of env vars:
927  * ILLUME_KBD="0, 0, 800, 301"
928  * ILLUME_IND="0, 0, 800, 32"
929  * ILLUME_STK="0, 568, 800, 32"
930  */
931 static Eina_Bool
932 _sip_part_geometry_get_from_env(const char *part,
933                                 int *sx,
934                                 int *sy,
935                                 int *sw,
936                                 int *sh)
937 {
938    const char delimiters[] = " ,;";
939    char *env_val, *token;
940    char buf[PATH_MAX];
941    int tsx, tsy, tsw;
942
943    if (!(env_val = getenv(part))) return EINA_FALSE;
944
945    /* strtok would modify env var if not copied to a buffer */
946    strncpy(buf, env_val, sizeof(buf));
947    buf[PATH_MAX - 1] = '\0';
948
949    token = strtok(buf, delimiters);
950    if (!token) return EINA_FALSE;
951    tsx = atoi(token);
952
953    token = strtok(NULL, delimiters);
954    if (!token) return EINA_FALSE;
955    tsy = atoi(token);
956
957    token = strtok(NULL, delimiters);
958    if (!token) return EINA_FALSE;
959    tsw = atoi(token);
960
961    token = strtok(NULL, delimiters);
962    if (!token) return EINA_FALSE;
963    *sh = atoi(token);
964
965    *sx = tsx;
966    *sy = tsy;
967    *sw = tsw;
968
969    return EINA_TRUE;
970 }
971
972 static void
973 _sip_geometry_get(Evas_Object *obj)
974 {
975    Ecore_X_Window zone = 0;
976    Evas_Object *top;
977    Ecore_X_Window xwin;
978    Eina_Rectangle unirect, srect, vrect, crect;
979    Evas_Coord tx, ty, tw, th;
980    Evas_Coord ww = 0, wh = 0;
981
982    ELM_ENTRY_DATA_GET(obj, sd);
983
984    unirect.x = unirect.y = unirect.w = unirect.h = -1;
985    vrect.x = vrect.y = vrect.w = vrect.h = -1;
986    srect.x = srect.y = srect.w = srect.h = -1;
987    crect.x = crect.y = crect.w = crect.h = -1;
988    top = elm_widget_top_get(obj);
989    xwin = elm_win_xwindow_get(top);
990
991    if (xwin)
992      zone = ecore_x_e_illume_zone_get(xwin);
993
994    //Virtual Keypad
995    if ((!_sip_part_geometry_get_from_env
996         ("ILLUME_KBD", &vrect.x, &vrect.y, &vrect.w, &vrect.h)) && (xwin))
997      {
998         if (!ecore_x_e_illume_keyboard_geometry_get
999             (xwin, &vrect.x, &vrect.y, &vrect.w, &vrect.h))
1000           {
1001              if (!ecore_x_e_illume_keyboard_geometry_get
1002                  (zone, &vrect.x, &vrect.y, &vrect.w, &vrect.h))
1003                vrect.x = vrect.y = vrect.w = vrect.h = 0;
1004           }
1005      }
1006
1007    //Softkey
1008    if ((!_sip_part_geometry_get_from_env
1009         ("ILLUME_STK", &srect.x, &srect.y, &srect.w, &srect.h)) && (xwin))
1010      {
1011         if (!ecore_x_e_illume_softkey_geometry_get
1012             (zone, &srect.x, &srect.y, &srect.w, &srect.h))
1013           srect.x = srect.y = srect.w = srect.h = 0;
1014      }
1015
1016    //Clipboard
1017    if ((!_sip_part_geometry_get_from_env
1018         ("ILLUME_CB", &crect.x, &crect.y, &crect.w, &crect.h)) && (xwin))
1019      {
1020         if (!ecore_x_e_illume_clipboard_geometry_get
1021             (zone, &crect.x, &crect.y, &crect.w, &crect.h))
1022           crect.x = crect.y = crect.w = crect.h = 0;
1023      }
1024
1025    if (!eina_rectangle_is_empty(&vrect))
1026      {
1027         unirect.x = vrect.x;
1028         unirect.y = vrect.y;
1029         unirect.w = vrect.w;
1030         unirect.h = vrect.h;
1031      }
1032    if (!eina_rectangle_is_empty(&srect))
1033      {
1034         if (eina_rectangle_is_empty(&unirect))
1035           {
1036              unirect.x = srect.x;
1037              unirect.y = srect.y;
1038              unirect.w = srect.w;
1039              unirect.h = srect.h;
1040           }
1041         else
1042           {
1043              eina_rectangle_union(&unirect, &srect);
1044           }
1045      }
1046    if (!eina_rectangle_is_empty(&crect))
1047      {
1048         if (eina_rectangle_is_empty(&unirect))
1049           {
1050              unirect.x = crect.x;
1051              unirect.y = crect.y;
1052              unirect.w = crect.w;
1053              unirect.h = crect.h;
1054           }
1055         else
1056           {
1057              eina_rectangle_union(&unirect, &crect);
1058           }
1059      }
1060
1061    tx = ty = tw = th = -1;
1062    evas_object_geometry_get(top, &tx, &ty, &tw, &th);
1063    if (xwin)
1064      ecore_x_window_geometry_get(xwin, NULL, NULL, &ww, &wh);
1065    if (eina_rectangle_is_empty(&unirect))
1066      {
1067         edje_object_part_text_layout_region_set(sd->entry_edje, "elm.text", tx, ty, tw, th);
1068      }
1069    else
1070      {
1071         Evas_Coord lx, ly, lw, lh;
1072         if (unirect.y > 0)
1073           {
1074              lx = tx;
1075              ly = ty;
1076              lw = tw;
1077              lh = unirect.y - ly;
1078           }
1079         else
1080           {
1081              lx = tx;
1082              ly = ty > unirect.y + unirect.h ? ty : unirect.y + unirect.h;
1083              lw = tw;
1084              lh = ty - ly;
1085           }
1086         if ((lw > ww) && (ww > 0)) lw = ww;
1087         if ((lh > wh) && (wh > 0)) lh = wh;
1088         edje_object_part_text_layout_region_set(sd->entry_edje, "elm.text", lx, ly, lw, lh);
1089      }
1090 }
1091
1092 static Eina_Bool
1093 _on_prop_change(void *data,
1094                 int type __UNUSED__,
1095                 void *event __UNUSED__)
1096 {
1097    Ecore_X_Event_Window_Property *ev = event;
1098
1099    if ((ev->atom == ECORE_X_ATOM_E_ILLUME_ZONE) ||
1100        (ev->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE) ||
1101        (ev->atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE) ||
1102        (ev->atom == ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY) ||
1103        (ev->atom == ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY) ||
1104        (ev->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_GEOMETRY))
1105      {
1106         if (elm_widget_focus_get(data))
1107           _sip_geometry_get(data);
1108      }
1109
1110    return ECORE_CALLBACK_PASS_ON;
1111 }
1112 #endif
1113 ////////////////////////// TIZEN ONLY - END
1114
1115 static Mod_Api *
1116 _module_find(Evas_Object *obj __UNUSED__)
1117 {
1118    static Elm_Module *m = NULL;
1119
1120    if (m) goto ok;  // already found - just use
1121    if (!(m = _elm_module_find_as("entry/api"))) return NULL;
1122    // get module api
1123    m->api = malloc(sizeof(Mod_Api));
1124    if (!m->api) return NULL;
1125
1126    ((Mod_Api *)(m->api))->obj_hook = // called on creation
1127      _elm_module_symbol_get(m, "obj_hook");
1128    ((Mod_Api *)(m->api))->obj_unhook = // called on deletion
1129      _elm_module_symbol_get(m, "obj_unhook");
1130    ((Mod_Api *)(m->api))->obj_longpress = // called on long press menu
1131      _elm_module_symbol_get(m, "obj_longpress");
1132    //TIZEN ONLY
1133    ((Mod_Api *)(m->api))->obj_hidemenu = // called on hide menu
1134      _elm_module_symbol_get(m, "obj_hidemenu");
1135    ((Mod_Api *)(m->api))->obj_mouseup = // called on mouseup
1136      _elm_module_symbol_get(m, "obj_mouseup");
1137    //
1138 ok: // ok - return api
1139    return m->api;
1140 }
1141
1142 static char *
1143 _file_load(const char *file)
1144 {
1145    Eina_File *f;
1146    char *text = NULL;
1147    void *tmp = NULL;
1148
1149    f = eina_file_open(file, EINA_FALSE);
1150    if (!f) return NULL;
1151
1152    tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
1153    if (!tmp) goto on_error;
1154
1155    text = malloc(eina_file_size_get(f) + 1);
1156    if (!text) goto on_error;
1157
1158    memcpy(text, tmp, eina_file_size_get(f));
1159    text[eina_file_size_get(f)] = 0;
1160
1161    if (eina_file_map_faulted(f, tmp))
1162      {
1163         free(text);
1164         text = NULL;
1165      }
1166
1167  on_error:
1168    if (tmp) eina_file_map_free(f, tmp);
1169    eina_file_close(f);
1170
1171    return text;
1172 }
1173
1174 static char *
1175 _plain_load(const char *file)
1176 {
1177    char *text;
1178
1179    text = _file_load(file);
1180    if (text)
1181      {
1182         char *text2;
1183
1184         text2 = elm_entry_utf8_to_markup(text);
1185         free(text);
1186         return text2;
1187      }
1188
1189    return NULL;
1190 }
1191
1192 static Eina_Bool
1193 _load_do(Evas_Object *obj)
1194 {
1195    char *text;
1196
1197    ELM_ENTRY_DATA_GET(obj, sd);
1198
1199    if (!sd->file)
1200      {
1201         elm_object_text_set(obj, "");
1202         return EINA_TRUE;
1203      }
1204
1205    switch (sd->format)
1206      {
1207       case ELM_TEXT_FORMAT_PLAIN_UTF8:
1208         text = _plain_load(sd->file);
1209         break;
1210
1211       case ELM_TEXT_FORMAT_MARKUP_UTF8:
1212         text = _file_load(sd->file);
1213         break;
1214
1215       default:
1216         text = NULL;
1217         break;
1218      }
1219
1220    if (text)
1221      {
1222         elm_object_text_set(obj, text);
1223         free(text);
1224
1225         return EINA_TRUE;
1226      }
1227    else
1228      {
1229         elm_object_text_set(obj, "");
1230
1231         return EINA_FALSE;
1232      }
1233 }
1234
1235 static void
1236 _utf8_markup_save(const char *file,
1237                   const char *text)
1238 {
1239    FILE *f;
1240
1241    if ((!text) || (!text[0]))
1242      {
1243         ecore_file_unlink(file);
1244
1245         return;
1246      }
1247
1248    f = fopen(file, "wb");
1249    if (!f)
1250      {
1251         // FIXME: report a write error
1252         return;
1253      }
1254
1255    fputs(text, f); // FIXME: catch error
1256    fclose(f);
1257 }
1258
1259 static void
1260 _utf8_plain_save(const char *file,
1261                  const char *text)
1262 {
1263    char *text2;
1264
1265    text2 = elm_entry_markup_to_utf8(text);
1266    if (!text2)
1267      return;
1268
1269    _utf8_markup_save(file, text2);
1270    free(text2);
1271 }
1272
1273 static void
1274 _save_do(Evas_Object *obj)
1275 {
1276    ELM_ENTRY_DATA_GET(obj, sd);
1277
1278    if (!sd->file) return;
1279    switch (sd->format)
1280      {
1281       case ELM_TEXT_FORMAT_PLAIN_UTF8:
1282         _utf8_plain_save(sd->file, elm_object_text_get(obj));
1283         break;
1284
1285       case ELM_TEXT_FORMAT_MARKUP_UTF8:
1286         _utf8_markup_save(sd->file, elm_object_text_get(obj));
1287         break;
1288
1289       default:
1290         break;
1291      }
1292 }
1293
1294 static Eina_Bool
1295 _delay_write(void *data)
1296 {
1297    ELM_ENTRY_DATA_GET(data, sd);
1298
1299    _save_do(data);
1300    sd->delay_write = NULL;
1301
1302    return ECORE_CALLBACK_CANCEL;
1303 }
1304
1305 static void
1306 _elm_entry_guide_update(Evas_Object *obj,
1307                         Eina_Bool has_text)
1308 {
1309    ELM_ENTRY_DATA_GET(obj, sd);
1310
1311    if ((has_text) && (!sd->has_text))
1312      edje_object_signal_emit(sd->entry_edje, "elm,guide,disabled", "elm");
1313    else if ((!has_text) && (sd->has_text))
1314      edje_object_signal_emit(sd->entry_edje, "elm,guide,enabled", "elm");
1315
1316    sd->has_text = has_text;
1317 }
1318
1319 static Elm_Entry_Markup_Filter *
1320 _filter_new(Elm_Entry_Filter_Cb func,
1321             void *data)
1322 {
1323    Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
1324
1325    if (!tf) return NULL;
1326
1327    tf->func = func;
1328    tf->orig_data = data;
1329    if (func == elm_entry_filter_limit_size)
1330      {
1331         Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
1332
1333         if (!data)
1334           {
1335              free(tf);
1336
1337              return NULL;
1338           }
1339
1340         lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
1341         if (!lim2)
1342           {
1343              free(tf);
1344
1345              return NULL;
1346           }
1347         memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
1348         tf->data = lim2;
1349      }
1350    else if (func == elm_entry_filter_accept_set)
1351      {
1352         Elm_Entry_Filter_Accept_Set *as = data, *as2;
1353
1354         if (!data)
1355           {
1356              free(tf);
1357
1358              return NULL;
1359           }
1360         as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
1361         if (!as2)
1362           {
1363              free(tf);
1364
1365              return NULL;
1366           }
1367         if (as->accepted)
1368           as2->accepted = eina_stringshare_add(as->accepted);
1369         else
1370           as2->accepted = NULL;
1371         if (as->rejected)
1372           as2->rejected = eina_stringshare_add(as->rejected);
1373         else
1374           as2->rejected = NULL;
1375         tf->data = as2;
1376      }
1377    else
1378      tf->data = data;
1379    return tf;
1380 }
1381
1382 static void
1383 _filter_free(Elm_Entry_Markup_Filter *tf)
1384 {
1385    if (tf->func == elm_entry_filter_limit_size)
1386      {
1387         Elm_Entry_Filter_Limit_Size *lim = tf->data;
1388
1389         if (lim) free(lim);
1390      }
1391    else if (tf->func == elm_entry_filter_accept_set)
1392      {
1393         Elm_Entry_Filter_Accept_Set *as = tf->data;
1394
1395         if (as)
1396           {
1397              if (as->accepted) eina_stringshare_del(as->accepted);
1398              if (as->rejected) eina_stringshare_del(as->rejected);
1399
1400              free(as);
1401           }
1402      }
1403    free(tf);
1404 }
1405
1406 static void
1407 _mirrored_set(Evas_Object *obj,
1408               Eina_Bool rtl)
1409 {
1410    ELM_ENTRY_DATA_GET(obj, sd);
1411
1412    edje_object_mirrored_set(sd->entry_edje, rtl);
1413
1414    if (sd->anchor_hover.hover)
1415      elm_widget_mirrored_set(sd->anchor_hover.hover, rtl);
1416 }
1417
1418 static const char *
1419 _elm_entry_theme_group_get(Evas_Object *obj)
1420 {
1421    ELM_ENTRY_DATA_GET(obj, sd);
1422
1423    if (sd->editable)
1424      {
1425         if (sd->password) return "base-password";
1426         else
1427           {
1428              if (sd->single_line) return "base-single";
1429              else
1430                {
1431                   switch (sd->line_wrap)
1432                     {
1433                      case ELM_WRAP_CHAR:
1434                        return "base-charwrap";
1435
1436                      case ELM_WRAP_WORD:
1437                        return "base";
1438
1439                      case ELM_WRAP_MIXED:
1440                        return "base-mixedwrap";
1441
1442                      case ELM_WRAP_NONE:
1443                      default:
1444                        return "base-nowrap";
1445                     }
1446                }
1447           }
1448      }
1449    else
1450      {
1451         if (sd->password) return "base-password";
1452         else
1453           {
1454              if (sd->single_line) return "base-single-noedit";
1455              else
1456                {
1457                   switch (sd->line_wrap)
1458                     {
1459                      case ELM_WRAP_CHAR:
1460                        return "base-noedit-charwrap";
1461
1462                      case ELM_WRAP_WORD:
1463                        return "base-noedit";
1464
1465                      case ELM_WRAP_MIXED:
1466                        return "base-noedit-mixedwrap";
1467
1468                      case ELM_WRAP_NONE:
1469                      default:
1470                        return "base-nowrap-noedit";
1471                     }
1472                }
1473           }
1474      }
1475 }
1476
1477 #ifdef HAVE_ELEMENTARY_X
1478 static Eina_Bool
1479 _drag_drop_cb(void *data __UNUSED__,
1480               Evas_Object *obj,
1481               Elm_Selection_Data *drop)
1482 {
1483    Eina_Bool rv;
1484
1485    ELM_ENTRY_DATA_GET(obj, sd);
1486
1487    edje_object_part_text_cursor_copy
1488      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, /*->*/ EDJE_CURSOR_USER);
1489    rv = edje_object_part_text_cursor_coord_set
1490        (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, drop->x, drop->y);
1491
1492    if (!rv) WRN("Warning: Failed to position cursor: paste anyway");
1493
1494    elm_entry_entry_insert(obj, drop->data);
1495    edje_object_part_text_cursor_copy
1496      (sd->entry_edje, "elm.text", EDJE_CURSOR_USER, /*->*/ EDJE_CURSOR_MAIN);
1497
1498    return EINA_TRUE;
1499 }
1500
1501 static Elm_Sel_Format
1502 _get_drop_format(Evas_Object *obj)
1503 {
1504    ELM_ENTRY_DATA_GET(obj, sd);
1505
1506    if ((sd->editable) && (!sd->single_line) && (!sd->password) && (!sd->disabled))
1507      return ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
1508    return ELM_SEL_FORMAT_MARKUP;
1509 }
1510 #endif
1511
1512 /* we can't reuse layout's here, because it's on entry_edje only */
1513 static Eina_Bool
1514 _elm_entry_smart_disable(Evas_Object *obj)
1515 {
1516    ELM_ENTRY_DATA_GET(obj, sd);
1517
1518 #ifdef HAVE_ELEMENTARY_X
1519    elm_drop_target_del(obj, sd->drop_format,
1520                        _dnd_enter_cb, obj,
1521                        _dnd_leave_cb, obj,
1522                        _dnd_pos_cb, obj,
1523                        _drag_drop_cb, NULL);
1524    sd->drop_added = EINA_FALSE;
1525 #endif
1526    if (elm_object_disabled_get(obj))
1527      {
1528         if (sd->sel_allow)
1529           edje_object_part_text_select_disabled_set(sd->entry_edje, "elm.text", EINA_TRUE);
1530         edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
1531         if (sd->scroll)
1532           {
1533              edje_object_signal_emit(sd->scr_edje, "elm,state,disabled", "elm");
1534              sd->s_iface->freeze_set(obj, EINA_TRUE);
1535           }
1536         sd->disabled = EINA_TRUE;
1537      }
1538    else
1539      {
1540         if (sd->sel_allow)
1541           edje_object_part_text_select_disabled_set(sd->entry_edje, "elm.text", EINA_FALSE);
1542         edje_object_signal_emit(sd->entry_edje, "elm,state,enabled", "elm");
1543         if (sd->scroll)
1544           {
1545              edje_object_signal_emit(sd->scr_edje, "elm,state,enabled", "elm");
1546              sd->s_iface->freeze_set(obj, EINA_FALSE);
1547           }
1548         sd->disabled = EINA_FALSE;
1549 #ifdef HAVE_ELEMENTARY_X
1550         if (sd->drop_enabled)
1551           {
1552              sd->drop_format = _get_drop_format(obj);
1553              elm_drop_target_add(obj, sd->drop_format,
1554                                  _dnd_enter_cb, obj,
1555                                  _dnd_leave_cb, obj,
1556                                  _dnd_pos_cb, obj,
1557                                  _drag_drop_cb, NULL);
1558              sd->drop_added = EINA_TRUE;
1559           }
1560 #endif
1561      }
1562
1563    return EINA_TRUE;
1564 }
1565
1566 // TIZEN ONLY(130911)
1567 // When cursor geometry is changed by theme or tag, show region geometry needs to be updated.
1568 static void
1569 _cursor_geometry_update(Evas_Object *obj)
1570 {
1571    Evas_Coord cx, cy, cw, ch, rx, ry, rw, rh;
1572
1573    ELM_ENTRY_DATA_GET(obj, sd);
1574    Elm_Widget_Smart_Data *wsd = evas_object_smart_data_get(obj);
1575
1576    edje_object_part_text_cursor_geometry_get
1577       (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1578    elm_widget_show_region_get(obj, &rx, &ry, &rw, &rh);
1579
1580    if (cw != rw && cw != 0)
1581      wsd->rw = cw;
1582    if (ch != rh && ch != 0)
1583      wsd->rh = ch;
1584 }
1585 //
1586
1587 // TIZEN ONLY(131106): Add rectangle for processing mouse up event on paddings inside of entry.
1588 static void
1589 _event_rect_cursor_changed_signal_cb(void *data,
1590                                      Evas_Object *obj __UNUSED__,
1591                                      const char *emission __UNUSED__,
1592                                      const char *source __UNUSED__)
1593 {
1594    ELM_ENTRY_DATA_GET(data, sd);
1595
1596    edje_object_signal_callback_del
1597      (sd->entry_edje, "cursor,changed", "elm.text",
1598      _event_rect_cursor_changed_signal_cb);
1599
1600    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
1601 }
1602
1603 static void
1604 _event_rect_mouse_up_cb(void *data,
1605                         Evas *e __UNUSED__,
1606                         Evas_Object *obj __UNUSED__,
1607                         void *event_info)
1608 {
1609    Evas_Event_Mouse_Up *ev;
1610    Evas_Object *tb;
1611    Evas_Coord ox, oy, ow, oh;
1612    Evas_Coord tx, ty, tw, th;
1613    Evas_Coord cx, cy;
1614    Evas_Coord ex, ey, ew, eh;
1615    Evas_Textblock_Cursor *tc;
1616    int pos;
1617
1618    ELM_ENTRY_DATA_GET(data, sd);
1619
1620    ev = (Evas_Event_Mouse_Up *)event_info;
1621    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1622      return;
1623
1624    tb = elm_entry_textblock_get(data);
1625    evas_object_geometry_get(data, &ox, &oy, &ow, &oh);
1626    if ((ev->canvas.x <= ox) || (ev->canvas.x >= ox + ow) ||
1627        (ev->canvas.y <= oy) || (ev->canvas.y >= oy + oh))
1628      return;
1629    edje_object_part_geometry_get(sd->entry_edje, "elm.text", &ex, &ey, &ew, &eh);
1630    evas_object_geometry_get(tb, &tx, &ty, &tw, &th);
1631
1632    cx = ev->canvas.x - tx;
1633    cy = ev->canvas.y - ty;
1634    if (cy >= eh) cy = eh - 1;
1635    if (cy < ey) cy = 0;
1636    if (cx >= ew) cx = ew - 1;
1637    if (cx < 0) cx = 0;
1638
1639    tc = evas_object_textblock_cursor_new(tb);
1640    evas_textblock_cursor_char_coord_set(tc, cx, cy);
1641    pos = evas_textblock_cursor_pos_get(tc);
1642
1643    if (pos != elm_entry_cursor_pos_get(data))
1644      {
1645         edje_object_signal_callback_add
1646            (sd->entry_edje, "cursor,changed", "elm.text",
1647             _event_rect_cursor_changed_signal_cb, data);
1648      }
1649    elm_entry_cursor_pos_set(data, pos);
1650    evas_textblock_cursor_free(tc);
1651
1652    elm_entry_select_none(data);
1653    evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1654
1655    if (!elm_widget_disabled_get(data) &&
1656        !evas_object_freeze_events_get(data))
1657      {
1658         if (sd->editable && sd->input_panel_enable)
1659           edje_object_part_text_input_panel_show(sd->entry_edje, "elm.text");
1660      }
1661 }
1662 ////////////////////////////////
1663
1664 ////////////////////////////////////////////////
1665 // TIZEN_ONLY(131221): Customize accessiblity for editfield
1666 ////////////////////////////////////////////////
1667
1668 static char *
1669 _access_info_cb(void *data, Evas_Object *obj __UNUSED__)
1670 {
1671    const char *txt;
1672
1673    ELM_ENTRY_DATA_GET(data, sd);
1674
1675    if ((sd->password && _elm_config->access_password_read_enable) ||
1676        (!sd->password))
1677      {
1678         txt = elm_widget_access_info_get(data);
1679
1680         if (!txt) txt = _elm_util_mkup_to_text(elm_entry_entry_get(data));
1681         if (txt && (strlen(txt) > 0)) return strdup(txt);
1682      }
1683    else if (sd->password && !(_elm_config->access_password_read_enable))
1684      {
1685         Eina_Strbuf *buf = eina_strbuf_new();
1686         char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(data));
1687         char *ret;
1688
1689         eina_strbuf_append_printf(buf, E_("%d characters"), evas_string_char_len_get(text));
1690         ret = eina_strbuf_string_steal(buf);
1691
1692         free(text);
1693         eina_strbuf_free(buf);
1694         return ret;
1695      }
1696
1697    /* to take care guide text */
1698    txt = edje_object_part_text_get(sd->entry_edje, "elm.guide");
1699    txt = _elm_util_mkup_to_text(txt);
1700    if (txt && (strlen(txt) > 0)) return strdup(txt);
1701
1702    return NULL;
1703 }
1704
1705 static char *
1706 _access_state_cb(void *data, Evas_Object *obj __UNUSED__)
1707 {
1708    Evas_Object *top;
1709    Eina_Strbuf *buf;
1710    char *ret;
1711
1712    ELM_ENTRY_DATA_GET(data, sd);
1713
1714    top = elm_widget_top_get(data);
1715    ret = NULL;
1716    buf = eina_strbuf_new();
1717
1718    if (elm_widget_disabled_get(data))
1719      eina_strbuf_append(buf, E_("Disabled"));
1720
1721    if (!sd->editable)
1722      {
1723         if (!eina_strbuf_length_get(buf))
1724           eina_strbuf_append(buf, E_("State: Not Editable"));
1725         else eina_strbuf_append(buf, E_(", Not Editable"));
1726      }
1727    else if (!elm_widget_disabled_get(data))
1728      {
1729         if ((elm_object_focus_get(data) && (elm_win_keyboard_mode_get(top) == ELM_WIN_KEYBOARD_OFF) && !sd->on_activate) ||
1730             (!elm_object_focus_get(data)))
1731           eina_strbuf_append(buf, E_("double tap to edit"));
1732         else
1733           eina_strbuf_append(buf, E_("Editing"));
1734      }
1735
1736    if (!eina_strbuf_length_get(buf)) goto buf_free;
1737
1738    ret = eina_strbuf_string_steal(buf);
1739
1740 buf_free:
1741    eina_strbuf_free(buf);
1742    return ret;
1743 }
1744
1745 static char *
1746 _access_context_info_cb(void *data, Evas_Object *obj __UNUSED__)
1747 {
1748    Evas_Object *top;
1749    Eina_Strbuf *buf;
1750    char *ret;
1751
1752    ELM_ENTRY_DATA_GET(data, sd);
1753
1754    top = elm_widget_top_get(data);
1755    ret = NULL;
1756    buf = eina_strbuf_new();
1757
1758    if (sd->editable && !elm_widget_disabled_get(data))
1759      {
1760         if (!((elm_object_focus_get(data) && (elm_win_keyboard_mode_get(top) == ELM_WIN_KEYBOARD_OFF) && !sd->on_activate) ||
1761             (!elm_object_focus_get(data))))
1762           {
1763              if (sd->on_activate)
1764                sd->on_activate = EINA_FALSE;
1765              if (!elm_entry_is_empty(data))
1766                eina_strbuf_append(buf, E_("Flick up and down to adjust the position"));
1767           }
1768      }
1769
1770    if (!eina_strbuf_length_get(buf)) goto buf_free;
1771
1772    ret = eina_strbuf_string_steal(buf);
1773
1774 buf_free:
1775    eina_strbuf_free(buf);
1776    return ret;
1777 }
1778
1779 // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
1780 static const char *
1781 _elm_entry_anchor_access_string_get(Evas_Object *obj,
1782                                     const char *name,
1783                                     const char *text)
1784 {
1785    Eina_List *l;
1786    char *ret;
1787    Elm_Entry_Anchor_Access_Provider *ap;
1788
1789    ELM_ENTRY_DATA_GET(obj, sd);
1790
1791    EINA_LIST_FOREACH(sd->anchor_access_providers, l, ap)
1792      {
1793         ret = ap->func(ap->data, obj, name, text);
1794         if (ret) return ret;
1795      }
1796    return text;
1797 }
1798 //
1799
1800 // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
1801 static void
1802 _elm_entry_anchors_highlight_clear(Evas_Object *obj)
1803 {
1804    char *data;
1805
1806    ELM_ENTRY_DATA_GET(obj, sd);
1807
1808    if (sd->anchor_highlight_rect)
1809      {
1810         data = (char *)evas_object_data_del(sd->anchor_highlight_rect, "anchor_name");
1811         if (data) free(data);
1812         data = (char *)evas_object_data_del(sd->anchor_highlight_rect, "anchor_text");
1813         if (data) free(data);
1814         evas_object_del(sd->anchor_highlight_rect);
1815         sd->anchor_highlight_rect = NULL;
1816      }
1817    sd->anchor_highlight_pos = -1;
1818 }
1819 //
1820
1821 // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
1822 static void
1823 _elm_entry_hide_cb(void *data __UNUSED__,
1824                    Evas *e __UNUSED__,
1825                    Evas_Object *obj,
1826                    void *event_info __UNUSED__)
1827 {
1828    _elm_entry_anchors_highlight_clear(obj);
1829 }
1830 //
1831
1832 // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
1833 static Eina_Bool
1834 _elm_entry_anchors_highlight_set(Evas_Object *obj, int pos)
1835 {
1836    Evas_Textblock_Rectangle *r;
1837    Evas_Object *tb = elm_entry_textblock_get(obj);
1838    Evas *e = evas_object_evas_get(obj);
1839    const Eina_List *anchors_a, *l;
1840    Eina_List *ll, *ll_next, *range = NULL;
1841    Evas_Coord x, y, w, h;
1842    int count = 0;
1843
1844    ELM_ENTRY_DATA_GET(obj, sd);
1845
1846    if (pos < 0)
1847      {
1848         sd->anchor_highlight_pos = -1;
1849         return EINA_FALSE;
1850      }
1851    sd->anchor_highlight_pos = pos;
1852    evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
1853    anchors_a = evas_textblock_node_format_list_get(tb, "a");
1854
1855    if (anchors_a)
1856      {
1857         const Evas_Object_Textblock_Node_Format *node;
1858         Evas_Textblock_Cursor *start, *end;
1859
1860         EINA_LIST_FOREACH(anchors_a, l, node)
1861           {
1862              if (count != pos)
1863                {
1864                   count++;
1865                   continue;
1866                }
1867
1868              const char *s = evas_textblock_node_format_text_get(node);
1869              char *p, *name = NULL;
1870
1871              p = strstr(s, "href=");
1872              if (p)
1873                {
1874                   name = strdup(p + 5);
1875                }
1876
1877              start = evas_object_textblock_cursor_new(tb);
1878              end = evas_object_textblock_cursor_new(tb);
1879              evas_textblock_cursor_at_format_set(start, node);
1880              evas_textblock_cursor_copy(start, end);
1881
1882              node = evas_textblock_node_format_next_get(node);
1883              for (; node; node = evas_textblock_node_format_next_get(node))
1884                {
1885                   s = evas_textblock_node_format_text_get(node);
1886                   if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
1887                     break;
1888                }
1889
1890              if (node)
1891                {
1892                   Evas_Coord sx, sy, ex, ey;
1893                   Evas_Object *rect = NULL;
1894                   char *text, *last_name, *last_text;
1895                   // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
1896                   const char *access_string;
1897                   //
1898
1899                   sx = w;
1900                   sy = h;
1901                   ex = 0;
1902                   ey = 0;
1903
1904                   evas_textblock_cursor_at_format_set(end, node);
1905                   text = (char *)evas_textblock_cursor_range_text_get(
1906                      start, end, EVAS_TEXTBLOCK_TEXT_PLAIN);
1907
1908                   if (!(sd->anchor_highlight_rect))
1909                     {
1910                        rect = edje_object_add(e);
1911                        _elm_theme_object_set(obj, rect, "access", "base", "default");
1912                        evas_object_smart_member_add(rect, obj);
1913                        evas_object_repeat_events_set(rect, EINA_TRUE);
1914                        sd->anchor_highlight_rect = rect;
1915                     }
1916                   else
1917                     {
1918                        last_name = evas_object_data_del(sd->anchor_highlight_rect, "anchor_name");
1919                        last_text = evas_object_data_del(sd->anchor_highlight_rect, "anchor_text");
1920                        if (last_name) free(last_name);
1921                        if (last_text) free(last_text);
1922                     }
1923
1924                   range = evas_textblock_cursor_range_geometry_get(start, end);
1925                   EINA_LIST_FOREACH_SAFE(range, ll, ll_next, r)
1926                     {
1927                        if (sx > r->x) sx = r->x;
1928                        if (sy > r->y) sy = r->y;
1929                        if (ex < r->x + r->w) ex = r->x + r->w;
1930                        if (ey < r->y + r->h) ey = r->y + r->h;
1931
1932                        free(r);
1933                        range = eina_list_remove_list(range, ll);
1934                     }
1935                   elm_widget_show_region_set(obj, sx, sy, ex - sx, ey - sy, EINA_FALSE);
1936
1937                   evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
1938                   evas_object_resize(sd->anchor_highlight_rect, ex - sx, ey - sy);
1939                   evas_object_move(sd->anchor_highlight_rect, sx + x, sy + y);
1940                   evas_object_show(sd->anchor_highlight_rect);
1941                   evas_object_data_set(sd->anchor_highlight_rect, "anchor_name", name);
1942                   evas_object_data_set(sd->anchor_highlight_rect, "anchor_text", text);
1943
1944                   // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
1945                   access_string = _elm_entry_anchor_access_string_get(obj, name, text);
1946                   _elm_access_say(obj, access_string, EINA_FALSE);
1947                   //
1948                   return EINA_TRUE;
1949                }
1950              else
1951                {
1952                   if (name)
1953                     free(name);
1954                   evas_textblock_cursor_free(start);
1955                   evas_textblock_cursor_free(end);
1956                   return EINA_TRUE;
1957                }
1958           }
1959      }
1960    sd->anchor_highlight_pos = -1;
1961    return EINA_FALSE;
1962 }
1963 //
1964
1965 // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
1966 static void
1967 _elm_entry_anchor_highlight_activate(Evas_Object *obj, int pos)
1968 {
1969    Elm_Entry_Anchor_Info ei;
1970
1971    ELM_ENTRY_DATA_GET(obj, sd);
1972
1973    if (pos != sd->anchor_highlight_pos)
1974      _elm_entry_anchors_highlight_set(obj, pos);
1975
1976    ei.button = 1;
1977    ei.name = evas_object_data_get(sd->anchor_highlight_rect, "anchor_name");
1978    ei.x = ei.y = ei.w = ei.h = 0;
1979
1980    if (!sd->disabled)
1981      evas_object_smart_callback_call(obj, SIG_ANCHOR_CLICKED, &ei);
1982 }
1983 //
1984
1985 static Eina_Bool
1986 _access_action_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
1987 {
1988    if (!action_info) return EINA_FALSE;
1989    char *cp = NULL;
1990    int pos = -1;
1991    ELM_ENTRY_DATA_GET(data, sd);
1992
1993    switch (action_info->action_type)
1994      {
1995       case ELM_ACCESS_ACTION_UP:
1996         if (sd->sel_allow && sd->sel_mode)
1997           elm_entry_select_none(data);
1998         elm_entry_cursor_prev(data);
1999         cp = elm_entry_cursor_content_get(data);
2000         _elm_access_say(data, cp, EINA_FALSE);
2001         break;
2002
2003       case ELM_ACCESS_ACTION_DOWN:
2004         if (sd->sel_allow && sd->sel_mode)
2005           elm_entry_select_none(data);
2006         elm_entry_cursor_next(data);
2007         cp = elm_entry_cursor_content_get(data);
2008         _elm_access_say(data, cp, EINA_FALSE);
2009         break;
2010
2011       case ELM_ACCESS_ACTION_ACTIVATE:
2012         if (!elm_widget_disabled_get(data) &&
2013             !evas_object_freeze_events_get(data))
2014           {
2015              if (!elm_widget_focus_get(data))
2016                elm_object_focus_set(data, EINA_TRUE);
2017              else if (sd->editable)
2018                {
2019                   pos = elm_entry_cursor_pos_get(data);
2020                   if (pos > 0)
2021                     {
2022                        elm_entry_cursor_begin_set(data);
2023                        _elm_access_say(data, E_("Cursor at beginning of text"), EINA_FALSE);
2024                     }
2025                   else
2026                     {
2027                        elm_entry_cursor_end_set(data);
2028                        _elm_access_say(data, E_("Cursor at end of text"), EINA_FALSE);
2029                     }
2030                }
2031
2032              // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
2033              if (!(sd->editable) && (sd->anchor_highlight_pos > -1))
2034                _elm_entry_anchor_highlight_activate(data, sd->anchor_highlight_pos);
2035              //
2036
2037              evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2038              if (sd->editable && sd->input_panel_enable)
2039                {
2040                   edje_object_part_text_input_panel_show(sd->entry_edje, "elm.text");
2041                   sd->on_activate = EINA_TRUE;
2042                }
2043           }
2044         break;
2045
2046       // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
2047       case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
2048         if (!elm_widget_disabled_get(data) &&
2049             !evas_object_freeze_events_get(data))
2050           {
2051              if (sd->editable)
2052                return EINA_FALSE;
2053              if (_elm_entry_anchors_highlight_set(data, sd->anchor_highlight_pos + 1))
2054                {
2055                   _elm_access_sound_play(ELM_ACCESS_SOUND_HIGHLIGHT);
2056                   return EINA_TRUE;
2057                }
2058              _elm_entry_anchors_highlight_clear(data);
2059              return EINA_FALSE;
2060           }
2061         break;
2062
2063       case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
2064         if (!elm_widget_disabled_get(data) &&
2065             !evas_object_freeze_events_get(data))
2066           {
2067              if (elm_entry_editable_get(data) || (sd->anchor_highlight_pos == -1))
2068                return EINA_FALSE;
2069              if (_elm_entry_anchors_highlight_set(data, sd->anchor_highlight_pos - 1))
2070                {
2071                   _elm_access_sound_play(ELM_ACCESS_SOUND_HIGHLIGHT);
2072                   return EINA_TRUE;
2073                }
2074              _elm_entry_anchors_highlight_clear(data);
2075              elm_access_highlight_set(obj);
2076              return EINA_TRUE;
2077           }
2078         break;
2079
2080       case ELM_ACCESS_ACTION_UNHIGHLIGHT:
2081         _elm_entry_anchors_highlight_clear(data);
2082         return EINA_FALSE;
2083       //
2084
2085       default:
2086         return EINA_FALSE;
2087         break;
2088      }
2089    return EINA_TRUE;
2090 }
2091
2092 static void
2093 _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
2094 {
2095    Evas_Object *ao;
2096
2097    ELM_ENTRY_DATA_GET(obj, sd);
2098
2099    if (is_access)
2100      {
2101         ao = elm_access_object_get(elm_entry_textblock_get(obj));
2102
2103         if (!ao)
2104           {
2105              ao = _elm_access_edje_object_part_object_register
2106                 (obj, sd->entry_edje, "elm.text");
2107              _elm_access_text_set(_elm_access_object_get(ao),
2108                                   ELM_ACCESS_TYPE, E_("Edit Field"));
2109              _elm_access_callback_set(_elm_access_object_get(ao),
2110                                       ELM_ACCESS_INFO, _access_info_cb, obj);
2111              _elm_access_callback_set(_elm_access_object_get(ao),
2112                                       ELM_ACCESS_STATE, _access_state_cb, obj);
2113              _elm_access_callback_set(_elm_access_object_get(ao),
2114                                       ELM_ACCESS_CONTEXT_INFO, _access_context_info_cb, obj);
2115              elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_ACTIVATE,
2116                                       _access_action_cb, obj);
2117              elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_UP,
2118                                       _access_action_cb, obj);
2119              elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_DOWN,
2120                                       _access_action_cb, obj);
2121              elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_HIGHLIGHT_NEXT,
2122                                       _access_action_cb, obj);
2123              elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_HIGHLIGHT_PREV,
2124                                       _access_action_cb, obj);
2125              elm_access_action_cb_set(ao, ELM_ACCESS_ACTION_UNHIGHLIGHT,
2126                                       _access_action_cb, obj);
2127           }
2128      }
2129    else
2130      {
2131         ao = elm_access_object_get(elm_entry_textblock_get(obj));
2132         if (!ao) return;
2133
2134         _elm_access_edje_object_part_object_unregister
2135            (obj, sd->entry_edje, "elm.text");
2136      }
2137 }
2138
2139 static Eina_Bool
2140 _elm_entry_smart_focus_next(const Evas_Object *obj,
2141                             Elm_Focus_Direction dir,
2142                             Evas_Object **next)
2143 {
2144    Eina_List *items = NULL;
2145    Evas_Object *clear;
2146
2147    if (!_elm_access_auto_highlight_get())
2148      {
2149         *next = (Evas_Object *)obj;
2150         return !elm_widget_focus_get(obj);
2151      }
2152    items = eina_list_append(items,
2153             elm_access_object_get(elm_entry_textblock_get((Evas_Object *)obj)));
2154
2155    clear = elm_object_part_content_get(obj, "elm.swallow.clear");
2156    if (clear && evas_object_visible_get(clear))
2157      items = eina_list_append(items, clear);
2158
2159    return elm_widget_focus_list_next_get(obj, items, eina_list_data_get, dir, next);
2160 }
2161
2162 static void
2163 _elm_entry_smart_access(Evas_Object *obj, Eina_Bool is_access)
2164 {
2165    ELM_ENTRY_CHECK(obj);
2166
2167    _access_obj_process(obj, is_access);
2168
2169    evas_object_smart_callback_call(obj, SIG_ACCESS_CHANGED, NULL);
2170 }
2171 /////////////////////////////////////
2172
2173 /* we can't issue the layout's theming code here, cause it assumes an
2174  * unique edje object, always */
2175 static Eina_Bool
2176 _elm_entry_smart_theme(Evas_Object *obj)
2177 {
2178    Evas_Object *ao;
2179    const char *str;
2180    const char *t;
2181    Elm_Widget_Smart_Class *parent_parent =
2182      (Elm_Widget_Smart_Class *)((Evas_Smart_Class *)
2183                                 _elm_entry_parent_sc)->parent;
2184
2185    ELM_ENTRY_DATA_GET(obj, sd);
2186
2187    if (!parent_parent->theme(obj))
2188      return EINA_FALSE;
2189
2190    evas_event_freeze(evas_object_evas_get(obj));
2191
2192    // TIZEN ONLY(130129) : Currently, for freezing cursor movement only.
2193    edje_object_part_text_freeze(sd->entry_edje, "elm.text");
2194    //
2195
2196    // TIZEN_ONLY(131221) : Customize accessiblity for editfield
2197    // do not delete access object, application could refer
2198    ao = elm_access_object_get(elm_entry_textblock_get(obj));
2199    _elm_access_object_hover_unregister(ao);
2200
2201    edje_object_mirrored_set
2202      (ELM_WIDGET_DATA(sd)->resize_obj, elm_widget_mirrored_get(obj));
2203
2204    edje_object_scale_set
2205      (ELM_WIDGET_DATA(sd)->resize_obj,
2206      elm_widget_scale_get(obj) * elm_config_scale_get());
2207
2208    _mirrored_set(obj, elm_widget_mirrored_get(obj));
2209
2210    // TIZEN ONLY(130225) : when password mode, elm_object_text_get returns utf8 string.
2211    elm_entry_imf_context_reset(obj);
2212    if (sd->password)
2213      {
2214         char *tmp = elm_entry_utf8_to_markup(elm_object_text_get(obj));
2215         t = eina_stringshare_add(tmp);
2216         if (tmp) free(tmp);
2217      }
2218    else
2219      t = eina_stringshare_add(elm_object_text_get(obj));
2220
2221    // TIZEN ONLY(131106): Add rectangle for processing mouse up event on paddings inside of entry.
2222    if (sd->event_rect)
2223      {
2224         if (sd->scroll)
2225           elm_object_part_content_unset(obj, "scroller_event_rect");
2226         else
2227           elm_object_part_content_unset(obj, "event_rect");
2228         evas_object_hide(sd->event_rect);
2229      }
2230    //
2231
2232    elm_widget_theme_object_set
2233      (obj, sd->entry_edje, "entry", _elm_entry_theme_group_get(obj),
2234      elm_widget_style_get(obj));
2235
2236    if (_elm_config->desktop_entry)
2237      edje_object_part_text_select_allow_set
2238        (sd->entry_edje, "elm.text", EINA_TRUE);
2239
2240    // TIZEN_ONLY(20130830): For cursor movement when mouse up.
2241    edje_object_part_text_select_disabled_set(sd->entry_edje, "elm.text",
2242                                              !elm_entry_select_allow_get(obj));
2243    ////
2244
2245    elm_object_text_set(obj, t);
2246    eina_stringshare_del(t);
2247
2248    if (elm_widget_disabled_get(obj))
2249      edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
2250
2251    edje_object_part_text_input_panel_layout_set
2252      (sd->entry_edje, "elm.text", sd->input_panel_layout);
2253    edje_object_part_text_input_panel_layout_variation_set
2254      (sd->entry_edje, "elm.text", sd->input_panel_layout_variation);
2255    edje_object_part_text_autocapital_type_set
2256      (sd->entry_edje, "elm.text", sd->autocapital_type);
2257    edje_object_part_text_prediction_allow_set
2258      (sd->entry_edje, "elm.text", sd->prediction_allow);
2259    edje_object_part_text_input_hint_set
2260      (sd->entry_edje, "elm.text", sd->input_hints);
2261    edje_object_part_text_input_panel_enabled_set
2262      (sd->entry_edje, "elm.text", sd->input_panel_enable);
2263    edje_object_part_text_input_panel_imdata_set
2264      (sd->entry_edje, "elm.text", sd->input_panel_imdata,
2265      sd->input_panel_imdata_len);
2266    edje_object_part_text_input_panel_return_key_type_set
2267      (sd->entry_edje, "elm.text", sd->input_panel_return_key_type);
2268    edje_object_part_text_input_panel_return_key_disabled_set
2269      (sd->entry_edje, "elm.text", sd->input_panel_return_key_disabled);
2270    edje_object_part_text_input_panel_show_on_demand_set
2271      (sd->entry_edje, "elm.text", sd->input_panel_show_on_demand);
2272    edje_object_part_text_cursor_handler_disabled_set
2273      (sd->entry_edje, "elm.text", sd->cursor_handler_disabled);
2274
2275    // elm_entry_cursor_pos_set -> cursor,changed -> widget_show_region_set
2276    // -> smart_objects_calculate will call all smart calculate functions,
2277    // and one of them can delete elm_entry.
2278    evas_object_ref(obj);
2279
2280    if (sd->cursor_pos != 0)
2281      elm_entry_cursor_pos_set(obj, sd->cursor_pos);
2282
2283    if (elm_widget_focus_get(obj))
2284      edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
2285
2286    edje_object_message_signal_process(sd->entry_edje);
2287
2288    if (sd->scroll)
2289      {
2290         sd->s_iface->mirrored_set(obj, elm_widget_mirrored_get(obj));
2291
2292         elm_widget_theme_object_set
2293           (obj, sd->scr_edje, "scroller", "entry", elm_widget_style_get(obj));
2294
2295         str = edje_object_data_get(sd->scr_edje, "focus_highlight");
2296      }
2297    else
2298      {
2299         str = edje_object_data_get(sd->entry_edje, "focus_highlight");
2300      }
2301
2302    // TIZEN ONLY(131106): Add rectangle for processing mouse up event on paddings inside of entry.
2303    if ((sd->scroll && edje_object_part_exists(sd->scr_edje, "scroller_event_rect")) ||
2304        (!sd->scroll && edje_object_part_exists(sd->entry_edje, "event_rect")))
2305      {
2306         if (!sd->event_rect)
2307           {
2308              sd->event_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
2309              evas_object_color_set(sd->event_rect, 0, 0, 0, 0);
2310              evas_object_size_hint_align_set(sd->event_rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
2311              evas_object_event_callback_add(sd->event_rect, EVAS_CALLBACK_MOUSE_UP,
2312                                             _event_rect_mouse_up_cb, obj);
2313           }
2314
2315         if (sd->scroll)
2316           elm_object_part_content_set(obj, "scroller_event_rect", sd->event_rect);
2317         else
2318           elm_object_part_content_set(obj, "event_rect", sd->event_rect);
2319      }
2320    //
2321
2322    if ((str) && (!strcmp(str, "on")))
2323      elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
2324    else
2325      elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
2326
2327    elm_layout_sizing_eval(obj);
2328
2329    sd->has_text = !sd->has_text;
2330    _elm_entry_guide_update(obj, !sd->has_text);
2331    // TIZEN_ONLY(131221) : Customize accessiblity for editfield
2332    if (_elm_config->access_mode)
2333      _elm_access_object_hover_register(ao, elm_entry_textblock_get(obj));
2334    //
2335    evas_event_thaw(evas_object_evas_get(obj));
2336    evas_event_thaw_eval(evas_object_evas_get(obj));
2337
2338    // TIZEN ONLY
2339    edje_object_part_text_thaw(sd->entry_edje, "elm.text"); //(130129) : Currently, for freezing cursor movement only.
2340    if (!_elm_config->desktop_entry)
2341      {
2342         if (sd->region_get_job) ecore_job_del(sd->region_get_job);
2343         sd->region_get_job = ecore_job_add(_region_get_job, obj);
2344      }
2345    //
2346
2347    // TIZEN ONLY(130911)
2348    _cursor_geometry_update(obj);
2349    //
2350
2351    evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
2352
2353    evas_object_unref(obj);
2354
2355    return EINA_TRUE;
2356 }
2357
2358 static void
2359 _cursor_geometry_recalc(Evas_Object *obj)
2360 {
2361    ELM_ENTRY_DATA_GET(obj, sd);
2362
2363    if (sd->cur_changed)
2364      evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
2365
2366    if (!sd->deferred_recalc_job)
2367      {
2368         Evas_Coord cx, cy, cw, ch;
2369
2370         edje_object_part_text_cursor_geometry_get
2371           (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
2372         if (sd->cur_changed)
2373           {
2374              sd->cur_changed = EINA_FALSE;
2375              elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
2376           }
2377      }
2378    else
2379      sd->deferred_cur = EINA_TRUE;
2380 }
2381
2382 static void
2383 _deferred_recalc_job(void *data)
2384 {
2385    Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
2386
2387    ELM_ENTRY_DATA_GET(data, sd);
2388
2389    if (!sd) return;
2390
2391    sd->deferred_recalc_job = NULL;
2392
2393    evas_object_geometry_get(sd->entry_edje, NULL, NULL, &resw, NULL);
2394    edje_object_size_min_restricted_calc(sd->entry_edje, &minw, &minh, resw, 0);
2395    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
2396
2397    /* This is a hack to workaround the way min size hints are treated.
2398     * If the minimum width is smaller than the restricted width, it
2399     * means the minimum doesn't matter. */
2400    if (minw <= resw)
2401      {
2402         Evas_Coord ominw = -1;
2403
2404         evas_object_size_hint_min_get(data, &ominw, NULL);
2405         minw = ominw;
2406      }
2407
2408    sd->ent_mw = minw;
2409    sd->ent_mh = minh;
2410
2411    elm_coords_finger_size_adjust(1, &fw, 1, &fh);
2412    if (sd->scroll)
2413      {
2414         Evas_Coord vmw = 0, vmh = 0;
2415
2416         edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
2417         if (sd->single_line)
2418           {
2419              evas_object_size_hint_min_set(data, vmw, minh + vmh);
2420              evas_object_size_hint_max_set(data, -1, minh + vmh);
2421           }
2422         else
2423           {
2424              evas_object_size_hint_min_set(data, vmw, vmh);
2425              evas_object_size_hint_max_set(data, -1, -1);
2426           }
2427      }
2428    else
2429      {
2430         if (sd->single_line)
2431           {
2432              evas_object_size_hint_min_set(data, minw, minh);
2433              evas_object_size_hint_max_set(data, -1, minh);
2434           }
2435         else
2436           {
2437              evas_object_size_hint_min_set(data, fw, minh);
2438              evas_object_size_hint_max_set(data, -1, -1);
2439           }
2440      }
2441
2442    if (sd->deferred_cur)
2443      {
2444         Evas_Coord cx, cy, cw, ch;
2445
2446         edje_object_part_text_cursor_geometry_get
2447           (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
2448         if (sd->cur_changed)
2449           {
2450              sd->cur_changed = EINA_FALSE;
2451              elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2452           }
2453      }
2454 }
2455
2456 static void
2457 _elm_entry_smart_sizing_eval(Evas_Object *obj)
2458 {
2459    Evas_Coord minw = -1, minh = -1;
2460    Evas_Coord resw, resh;
2461
2462    ELM_ENTRY_DATA_GET(obj, sd);
2463
2464    evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
2465
2466    if (sd->line_wrap)
2467      {
2468         if ((resw == sd->last_w) && (!sd->changed))
2469           {
2470              if (sd->scroll)
2471                {
2472                   Evas_Coord vw = 0, vh = 0, w = 0, h = 0;
2473
2474                   sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
2475
2476                   w = sd->ent_mw;
2477                   h = sd->ent_mh;
2478                   if (vw > sd->ent_mw) w = vw;
2479                   if (vh > sd->ent_mh) h = vh;
2480                   evas_object_resize(sd->entry_edje, w, h);
2481
2482                   return;
2483                }
2484
2485              return;
2486           }
2487
2488         evas_event_freeze(evas_object_evas_get(obj));
2489         sd->changed = EINA_FALSE;
2490         sd->last_w = resw;
2491         if (sd->scroll)
2492           {
2493              Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
2494
2495              evas_object_resize(sd->scr_edje, resw, resh);
2496              edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
2497              sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
2498              edje_object_size_min_restricted_calc
2499                (sd->entry_edje, &minw, &minh, vw, 0);
2500              elm_coords_finger_size_adjust(1, &minw, 1, &minh);
2501
2502              /* This is a hack to workaround the way min size hints
2503               * are treated.  If the minimum width is smaller than the
2504               * restricted width, it means the minimum doesn't
2505               * matter. */
2506              if (minw <= vw)
2507                {
2508                   Evas_Coord ominw = -1;
2509
2510                   evas_object_size_hint_min_get(sd->entry_edje, &ominw, NULL);
2511                   minw = ominw;
2512                }
2513              sd->ent_mw = minw;
2514              sd->ent_mh = minh;
2515
2516              if ((minw > 0) && (vw < minw)) vw = minw;
2517              if (minh > vh) vh = minh;
2518
2519              if (sd->single_line) h = vmh + minh;
2520              else h = vmh;
2521
2522              evas_object_resize(sd->entry_edje, vw, vh);
2523              evas_object_size_hint_min_set(obj, w, h);
2524
2525              if (sd->single_line)
2526                evas_object_size_hint_max_set(obj, -1, h);
2527              else
2528                evas_object_size_hint_max_set(obj, -1, -1);
2529           }
2530         else
2531           {
2532              if (sd->deferred_recalc_job)
2533                ecore_job_del(sd->deferred_recalc_job);
2534              sd->deferred_recalc_job =
2535                ecore_job_add(_deferred_recalc_job, obj);
2536           }
2537
2538         evas_event_thaw(evas_object_evas_get(obj));
2539         evas_event_thaw_eval(evas_object_evas_get(obj));
2540      }
2541    else
2542      {
2543         if (!sd->changed) return;
2544         evas_event_freeze(evas_object_evas_get(obj));
2545         sd->changed = EINA_FALSE;
2546         sd->last_w = resw;
2547         if (sd->scroll)
2548           {
2549              Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
2550
2551              edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
2552              sd->ent_mw = minw;
2553              sd->ent_mh = minh;
2554              elm_coords_finger_size_adjust(1, &minw, 1, &minh);
2555
2556              sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
2557
2558              if (minw > vw) vw = minw;
2559              if (minh > vh) vh = minh;
2560
2561              evas_object_resize(sd->entry_edje, vw, vh);
2562              edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
2563              if (sd->single_line) h = vmh + minh;
2564              else h = vmh;
2565
2566              evas_object_size_hint_min_set(obj, w, h);
2567              if (sd->single_line)
2568                evas_object_size_hint_max_set(obj, -1, h);
2569              else
2570                evas_object_size_hint_max_set(obj, -1, -1);
2571           }
2572         else
2573           {
2574              edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
2575              sd->ent_mw = minw;
2576              sd->ent_mh = minh;
2577              elm_coords_finger_size_adjust(1, &minw, 1, &minh);
2578              evas_object_size_hint_min_set(obj, minw, minh);
2579
2580              if (sd->single_line)
2581                evas_object_size_hint_max_set(obj, -1, minh);
2582              else
2583                evas_object_size_hint_max_set(obj, -1, -1);
2584           }
2585         evas_event_thaw(evas_object_evas_get(obj));
2586         evas_event_thaw_eval(evas_object_evas_get(obj));
2587      }
2588
2589    _cursor_geometry_recalc(obj);
2590 }
2591
2592 static void
2593 _return_key_enabled_check(Evas_Object *obj)
2594 {
2595    Eina_Bool return_key_disabled = EINA_FALSE;
2596
2597    ELM_ENTRY_DATA_GET(obj, sd);
2598
2599    if (!sd->auto_return_key) return;
2600
2601    if (elm_entry_is_empty(obj) == EINA_TRUE)
2602      return_key_disabled = EINA_TRUE;
2603
2604    elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
2605 }
2606
2607 static Eina_Bool
2608 _elm_entry_smart_on_focus(Evas_Object *obj, Elm_Focus_Info *info)
2609 {
2610    Evas_Object *top;
2611    Eina_Bool top_is_win = EINA_FALSE;
2612    Evas_Object *ao;
2613
2614    ELM_ENTRY_DATA_GET(obj, sd);
2615
2616    top = elm_widget_top_get(obj);
2617    if (!strcmp(evas_object_type_get(top), "elm_win"))
2618      top_is_win = EINA_TRUE;
2619
2620    // if (!sd->editable) return EINA_FALSE;   // TIZEN ONLY
2621    if (elm_widget_focus_get(obj))
2622      {
2623         printf("[Elm_entry::Focused] obj : %p\n", obj); // TIZEN ONLY
2624         evas_object_focus_set(sd->entry_edje, EINA_TRUE);
2625         edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
2626         sd->needs_focus_region = EINA_TRUE; // TIZEN_ONLY(20130830): For cursor movement when mouse up.
2627         if (sd->editable) // TIZEN ONLY
2628           {
2629              if (top && top_is_win && sd->input_panel_enable &&
2630                !edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text"))
2631                elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
2632              evas_object_smart_callback_call(obj, SIG_FOCUSED, info);
2633              _return_key_enabled_check(obj);
2634           }
2635         // TIZEN_ONLY(20140418): Call _elm_access_highlight_set manually in smart on focus of entry.
2636         if (_elm_config->access_mode)
2637           {
2638              Evas_Object *tb = elm_entry_textblock_get(obj);
2639              ao = elm_access_object_get(tb);
2640              _elm_access_highlight_set(ao, EINA_TRUE);
2641           }
2642         //
2643      }
2644    else
2645      {
2646         printf("[Elm_entry::Unfocused] obj : %p\n", obj); // TIZEN ONLY
2647         _cbhm_msg_send(obj, "cbhm_hide"); // TIZEN ONLY : Hide clipboard
2648         edje_object_signal_emit(sd->entry_edje, "elm,action,unfocus", "elm");
2649         evas_object_focus_set(sd->entry_edje, EINA_FALSE);
2650         // TIZEN ONLY
2651         if ((sd->api) && (sd->api->obj_hidemenu))
2652           sd->api->obj_hidemenu(obj);
2653         //
2654         if (sd->editable) // TIZEN ONLY
2655           {
2656              if (top && top_is_win && sd->input_panel_enable &&
2657                !edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text"))
2658                elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
2659              evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
2660           }
2661
2662         if (_elm_config->selection_clear_enable)
2663           {
2664              if ((sd->have_selection) && (!sd->hoversel))
2665                {
2666                   sd->sel_mode = EINA_FALSE;
2667                   elm_widget_scroll_hold_pop(obj);
2668                   edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", EINA_FALSE);
2669                   edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
2670                   edje_object_part_text_select_none(sd->entry_edje, "elm.text");
2671                }
2672           }
2673      }
2674
2675    return EINA_TRUE;
2676 }
2677
2678 static Eina_Bool
2679 _elm_entry_smart_translate(Evas_Object *obj)
2680 {
2681    evas_object_smart_callback_call(obj, SIG_LANG_CHANGED, NULL);
2682
2683    return EINA_TRUE;
2684 }
2685
2686 // TIZEN_ONLY(20130830): For cursor movement when mouse up.
2687 static void
2688 _entry_cursor_changed_for_focus_region_cb(void *data,
2689                                           Evas_Object *obj __UNUSED__,
2690                                           const char *emission __UNUSED__,
2691                                           const char *source __UNUSED__)
2692 {
2693    ELM_ENTRY_DATA_GET(data, sd);
2694    if (elm_widget_focus_get(data))
2695      elm_widget_focus_region_show(data);
2696    edje_object_signal_callback_del
2697       (sd->entry_edje, "cursor,updated", "elm.text",
2698        _entry_cursor_changed_for_focus_region_cb);
2699 }
2700 ////
2701
2702 static Eina_Bool
2703 _elm_entry_smart_on_focus_region(const Evas_Object *obj,
2704                                  Evas_Coord *x,
2705                                  Evas_Coord *y,
2706                                  Evas_Coord *w,
2707                                  Evas_Coord *h)
2708 {
2709    ELM_ENTRY_DATA_GET(obj, sd);
2710
2711    // TIZEN_ONLY(20130830): For cursor movement when mouse up.
2712    //if (sd->needs_focus_region)
2713    //  {
2714    //     edje_object_signal_callback_add
2715    //        (sd->entry_edje, "cursor,updated", "elm.text",
2716    //         _entry_cursor_changed_for_focus_region_cb, (void *)obj);
2717    //     sd->needs_focus_region = EINA_FALSE;
2718    //     return EINA_FALSE;
2719    //  }
2720    //else
2721      {
2722         edje_object_part_text_cursor_geometry_get
2723            (sd->entry_edje, "elm.text", x, y, w, h);
2724         return EINA_TRUE;
2725      }
2726    //edje_object_part_text_cursor_geometry_get
2727    //   (sd->entry_edje, "elm.text", x, y, w, h);
2728    //return EINA_TRUE;
2729    //////////////////////////////////////////////////////
2730 }
2731
2732 static void
2733 _show_region_hook(void *data,
2734                   Evas_Object *obj)
2735 {
2736    Evas_Coord x, y, w, h;
2737
2738    ELM_ENTRY_DATA_GET(data, sd);
2739
2740    elm_widget_show_region_get(obj, &x, &y, &w, &h);
2741
2742    sd->s_iface->content_region_show(obj, x, y, w, h);
2743 }
2744
2745 static Eina_Bool
2746 _elm_entry_smart_sub_object_del(Evas_Object *obj,
2747                                 Evas_Object *sobj)
2748 {
2749    /* unfortunately entry doesn't follow the signal pattern
2750     * elm,state,icon,{visible,hidden}, so we have to replicate this
2751     * smart function */
2752    if (sobj == elm_layout_content_get(obj, "elm.swallow.icon"))
2753      {
2754         elm_layout_signal_emit(obj, "elm,action,hide,icon", "elm");
2755      }
2756    else if (sobj == elm_layout_content_get(obj, "elm.swallow.end"))
2757      {
2758         elm_layout_signal_emit(obj, "elm,action,hide,end", "elm");
2759      }
2760
2761    if (!ELM_WIDGET_CLASS(_elm_entry_parent_sc)->sub_object_del(obj, sobj))
2762      return EINA_FALSE;
2763
2764    return EINA_TRUE;
2765 }
2766
2767 static void
2768 _hoversel_position(Evas_Object *obj)
2769 {
2770    Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
2771
2772    ELM_ENTRY_DATA_GET(obj, sd);
2773
2774    cx = cy = 0;
2775    cw = ch = 1;
2776    evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
2777    if (sd->use_down)
2778      {
2779         cx = sd->downx - x;
2780         cy = sd->downy - y;
2781         cw = 1;
2782         ch = 1;
2783      }
2784    else
2785      edje_object_part_text_cursor_geometry_get
2786        (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
2787
2788    evas_object_size_hint_min_get(sd->hoversel, &mw, &mh);
2789    if (cw < mw)
2790      {
2791         cx += (cw - mw) / 2;
2792         cw = mw;
2793      }
2794    if (ch < mh)
2795      {
2796         cy += (ch - mh) / 2;
2797         ch = mh;
2798      }
2799    evas_object_move(sd->hoversel, x + cx, y + cy);
2800    evas_object_resize(sd->hoversel, cw, ch);
2801 }
2802
2803 static void
2804 _hover_del_job(void *data)
2805 {
2806    ELM_ENTRY_DATA_GET(data, sd);
2807
2808    if (sd->hoversel)
2809      {
2810         evas_object_del(sd->hoversel);
2811         sd->hoversel = NULL;
2812      }
2813    sd->hov_deljob = NULL;
2814 }
2815
2816 static void
2817 _hover_dismissed_cb(void *data,
2818                     Evas_Object *obj __UNUSED__,
2819                     void *event_info __UNUSED__)
2820 {
2821    ELM_ENTRY_DATA_GET(data, sd);
2822
2823    sd->use_down = 0;
2824    if (sd->hoversel) evas_object_hide(sd->hoversel);
2825    if (sd->sel_mode)
2826      {
2827         if (!_elm_config->desktop_entry)
2828           {
2829              if (!sd->password)
2830                edje_object_part_text_select_allow_set
2831                  (sd->entry_edje, "elm.text", EINA_TRUE);
2832           }
2833      }
2834    elm_widget_scroll_freeze_pop(data);
2835    if (sd->hov_deljob) ecore_job_del(sd->hov_deljob);
2836    sd->hov_deljob = ecore_job_add(_hover_del_job, data);
2837 }
2838
2839 static void
2840 _hover_selected_cb(void *data,
2841                    Evas_Object *obj __UNUSED__,
2842                    void *event_info __UNUSED__)
2843 {
2844    ELM_ENTRY_DATA_GET(data, sd);
2845
2846    sd->sel_mode = EINA_TRUE;
2847    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
2848
2849    if (!_elm_config->desktop_entry)
2850      {
2851         if (!sd->password)
2852           edje_object_part_text_select_allow_set
2853             (sd->entry_edje, "elm.text", EINA_TRUE);
2854      }
2855    edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
2856
2857    if (!_elm_config->desktop_entry)
2858      {
2859         elm_widget_scroll_hold_push(data);
2860         sd->scroll_holding = EINA_TRUE;
2861      }
2862 }
2863
2864 static char *
2865 _item_tags_remove(const char *str)
2866 {
2867    char *ret;
2868    Eina_Strbuf *buf;
2869
2870    if (!str)
2871      return NULL;
2872
2873    buf = eina_strbuf_new();
2874    if (!buf)
2875      return NULL;
2876
2877    if (!eina_strbuf_append(buf, str))
2878      {
2879         eina_strbuf_free(buf);
2880         return NULL;
2881      }
2882
2883    while (EINA_TRUE)
2884      {
2885         const char *temp = eina_strbuf_string_get(buf);
2886         char *start_tag = NULL;
2887         char *end_tag = NULL;
2888         size_t sindex;
2889         size_t eindex;
2890
2891         start_tag = strstr(temp, "<item");
2892         if (!start_tag)
2893           start_tag = strstr(temp, "</item");
2894         if (start_tag)
2895           end_tag = strstr(start_tag, ">");
2896         else
2897           break;
2898         if (!end_tag || start_tag > end_tag)
2899           break;
2900
2901         sindex = start_tag - temp;
2902         eindex = end_tag - temp + 1;
2903         if (!eina_strbuf_remove(buf, sindex, eindex))
2904           break;
2905      }
2906
2907    ret = eina_strbuf_string_steal(buf);
2908    eina_strbuf_free(buf);
2909
2910    return ret;
2911 }
2912
2913 void
2914 _elm_entry_entry_paste(Evas_Object *obj,
2915                        const char *entry)
2916 {
2917    char *str = NULL;
2918
2919    ELM_ENTRY_CHECK(obj);
2920    ELM_ENTRY_DATA_GET(obj, sd);
2921
2922    if (sd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
2923      {
2924         str = _item_tags_remove(entry);
2925         if (!str) str = strdup(entry);
2926      }
2927    else
2928      str = strdup(entry);
2929    if (!str) str = (char *)entry;
2930
2931    edje_object_part_text_user_insert(sd->entry_edje, "elm.text", str);
2932
2933    if (str != entry) free(str);
2934
2935    // TIZEN ONLY
2936 #ifdef HAVE_ELEMENTARY_X
2937    if (elm_widget_focus_get(obj))
2938      ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), NULL,0);
2939 #endif
2940    //
2941 }
2942
2943 static void
2944 _paste_cb(void *data,
2945           Evas_Object *obj __UNUSED__,
2946           void *event_info __UNUSED__)
2947 {
2948    ELM_ENTRY_DATA_GET(data, sd);
2949
2950    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2951    if (sd->sel_notify_handler)
2952      {
2953 #ifdef HAVE_ELEMENTARY_X
2954         Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2955
2956         sd->selection_asked = EINA_TRUE;
2957
2958         if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2959           formats = ELM_SEL_FORMAT_TEXT;
2960         else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2961           formats |= ELM_SEL_FORMAT_IMAGE;
2962
2963         elm_cnp_selection_get
2964           (data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
2965 #endif
2966      }
2967    else
2968      {
2969 #ifdef HAVE_ELEMENTARY_WAYLAND
2970         Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2971         sd->selection_asked = EINA_TRUE;
2972         if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2973            formats = ELM_SEL_FORMAT_TEXT;
2974         else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2975            formats |= ELM_SEL_FORMAT_IMAGE;
2976         elm_cnp_selection_get(data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
2977 #endif
2978      }
2979 }
2980
2981 static void
2982 _selection_store(Elm_Sel_Type seltype,
2983                  Evas_Object *obj)
2984 {
2985    const char *sel;
2986
2987    ELM_ENTRY_DATA_GET(obj, sd);
2988
2989    sel = edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
2990    if ((!sel) || (!sel[0])) return;  /* avoid deleting our own selection */
2991
2992    elm_cnp_selection_set
2993      (obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
2994    if (seltype == ELM_SEL_TYPE_CLIPBOARD)
2995      eina_stringshare_replace(&sd->cut_sel, sel);
2996 }
2997
2998 static void
2999 _cut_cb(void *data,
3000         Evas_Object *obj __UNUSED__,
3001         void *event_info __UNUSED__)
3002 {
3003    ELM_ENTRY_DATA_GET(data, sd);
3004
3005    evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
3006    /* Store it */
3007    sd->sel_mode = EINA_FALSE;
3008    if (!_elm_config->desktop_entry)
3009      edje_object_part_text_select_allow_set
3010        (sd->entry_edje, "elm.text", EINA_FALSE);
3011    edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
3012
3013    if ((!_elm_config->desktop_entry) && (sd->scroll_holding))
3014      {
3015         elm_widget_scroll_hold_pop(data);
3016         sd->scroll_holding = EINA_FALSE;
3017      }
3018
3019    _selection_store(ELM_SEL_TYPE_CLIPBOARD, data);
3020    edje_object_part_text_user_insert(sd->entry_edje, "elm.text", "");
3021    elm_layout_sizing_eval(data);
3022 }
3023
3024 static void
3025 _copy_cb(void *data,
3026          Evas_Object *obj __UNUSED__,
3027          void *event_info __UNUSED__)
3028 {
3029    ELM_ENTRY_DATA_GET(data, sd);
3030
3031    evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
3032
3033    sd->sel_mode = EINA_FALSE;
3034    if (!_elm_config->desktop_entry)
3035      {
3036         edje_object_part_text_select_allow_set
3037           (sd->entry_edje, "elm.text", EINA_FALSE);
3038         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
3039         if (sd->scroll_holding)
3040           {
3041              elm_widget_scroll_hold_pop(data);
3042              sd->scroll_holding = EINA_FALSE;
3043           }
3044      }
3045    _selection_store(ELM_SEL_TYPE_CLIPBOARD, data);
3046 }
3047
3048 static void
3049 _hover_cancel_cb(void *data,
3050                  Evas_Object *obj __UNUSED__,
3051                  void *event_info __UNUSED__)
3052 {
3053    ELM_ENTRY_DATA_GET(data, sd);
3054
3055    sd->sel_mode = EINA_FALSE;
3056    if (!_elm_config->desktop_entry)
3057      edje_object_part_text_select_allow_set
3058        (sd->entry_edje, "elm.text", EINA_FALSE);
3059    edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
3060    if ((!_elm_config->desktop_entry) && (sd->scroll_holding))
3061      {
3062         elm_widget_scroll_hold_pop(data);
3063         sd->scroll_holding = EINA_FALSE;
3064      }
3065    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
3066 }
3067
3068 static void
3069 _hover_item_clicked_cb(void *data,
3070                        Evas_Object *obj __UNUSED__,
3071                        void *event_info __UNUSED__)
3072 {
3073    Elm_Entry_Context_Menu_Item *it = data;
3074    Evas_Object *obj2 = it->obj;
3075
3076    if (it->func) it->func(it->data, obj2, NULL);
3077 }
3078
3079 #ifndef ELM_FEATURE_WEARABLE
3080 static void
3081 _menu_call(Evas_Object *obj)
3082 {
3083    Evas_Object *top;
3084    const Eina_List *l;
3085    const Elm_Entry_Context_Menu_Item *it;
3086
3087    ELM_ENTRY_DATA_GET(obj, sd);
3088
3089    if ((sd->api) && (sd->api->obj_longpress))
3090      {
3091         sd->api->obj_longpress(obj);
3092      }
3093    else if (sd->context_menu)
3094      {
3095         const char *context_menu_orientation;
3096
3097         if (sd->hoversel) evas_object_del(sd->hoversel);
3098         else elm_widget_scroll_freeze_push(obj);
3099
3100         sd->hoversel = elm_hoversel_add(obj);
3101         context_menu_orientation = edje_object_data_get
3102             (sd->entry_edje, "context_menu_orientation");
3103
3104         if ((context_menu_orientation) &&
3105             (!strcmp(context_menu_orientation, "horizontal")))
3106           elm_hoversel_horizontal_set(sd->hoversel, EINA_TRUE);
3107
3108         elm_object_style_set(sd->hoversel, "entry");
3109         elm_widget_sub_object_add(obj, sd->hoversel);
3110         elm_object_text_set(sd->hoversel, "Text");
3111         top = elm_widget_top_get(obj);
3112
3113         if (top) elm_hoversel_hover_parent_set(sd->hoversel, top);
3114
3115         evas_object_smart_callback_add
3116           (sd->hoversel, "dismissed", _hover_dismissed_cb, obj);
3117         if (sd->have_selection)
3118           {
3119              if (!sd->password)
3120                {
3121                   elm_hoversel_item_add
3122                      (sd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
3123                       _copy_cb, obj);
3124                   if (sd->editable)
3125                     elm_hoversel_item_add
3126                        (sd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
3127                         _cut_cb, obj);
3128                   elm_hoversel_item_add
3129                     (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
3130                     _hover_cancel_cb, obj);
3131                }
3132           }
3133         else
3134           {
3135              if (!sd->sel_mode)
3136                {
3137                   if (!_elm_config->desktop_entry)
3138                     {
3139                        if (!sd->password)
3140                          elm_hoversel_item_add
3141                            (sd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
3142                            _hover_selected_cb, obj);
3143                     }
3144                   if (elm_selection_selection_has_owner(obj))
3145                     {
3146                        if (sd->editable)
3147                          elm_hoversel_item_add
3148                            (sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
3149                            _paste_cb, obj);
3150                     }
3151                }
3152              else
3153                elm_hoversel_item_add
3154                   (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
3155                    _hover_cancel_cb, obj);
3156           }
3157
3158         EINA_LIST_FOREACH(sd->items, l, it)
3159           {
3160              elm_hoversel_item_add(sd->hoversel, it->label, it->icon_file,
3161                                    it->icon_type, _hover_item_clicked_cb, it);
3162           }
3163
3164         if (sd->hoversel)
3165           {
3166              _hoversel_position(obj);
3167              evas_object_show(sd->hoversel);
3168              elm_hoversel_hover_begin(sd->hoversel);
3169           }
3170
3171         if (!_elm_config->desktop_entry)
3172           {
3173              edje_object_part_text_select_allow_set
3174                (sd->entry_edje, "elm.text", EINA_FALSE);
3175              edje_object_part_text_select_abort(sd->entry_edje, "elm.text");
3176           }
3177      }
3178 }
3179 #endif
3180
3181 static Eina_Bool
3182 _long_press_cb(void *data)
3183 {
3184    ELM_ENTRY_DATA_GET(data, sd);
3185
3186 #ifndef ELM_FEATURE_WEARABLE
3187    if (!_elm_config->desktop_entry && !sd->magnifier_enabled) // TIZEN ONLY
3188      _menu_call(data);
3189 #endif
3190
3191    sd->longpress_timer = NULL;
3192    evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
3193
3194    return ECORE_CALLBACK_CANCEL;
3195 }
3196
3197 static void
3198 _mouse_down_cb(void *data,
3199                Evas *evas __UNUSED__,
3200                Evas_Object *obj __UNUSED__,
3201                void *event_info)
3202 {
3203    Evas_Event_Mouse_Down *ev = event_info;
3204
3205    ELM_ENTRY_DATA_GET(data, sd);
3206
3207    if (sd->disabled) return;
3208    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
3209    sd->downx = ev->canvas.x;
3210    sd->downy = ev->canvas.y;
3211    sd->long_pressed = EINA_FALSE;
3212    if (ev->button == 1)
3213      {
3214         if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer);
3215         sd->longpress_timer = ecore_timer_add
3216             (_elm_config->longpress_timeout, _long_press_cb, data);
3217      }
3218 #ifndef ELM_FEATURE_WEARABLE
3219    else if (ev->button == 3)
3220      {
3221         if (_elm_config->desktop_entry)
3222           _menu_call(data);
3223      }
3224 #endif
3225    if (!sd->editable)
3226      {
3227          edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", EINA_TRUE);
3228      }
3229    else if (!sd->cursor_handler_disabled)
3230      {
3231          edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", EINA_FALSE);
3232      }
3233 }
3234
3235 static void
3236 _mouse_up_cb(void *data,
3237              Evas *evas __UNUSED__,
3238              Evas_Object *obj __UNUSED__,
3239              void *event_info)
3240 {
3241    Evas_Event_Mouse_Up *ev = event_info;
3242
3243    ELM_ENTRY_DATA_GET(data, sd);
3244
3245    if (sd->disabled) return;
3246    if (ev->button == 1)
3247      {
3248         if ((sd->editable) && (sd->drag_started))
3249           {
3250              edje_object_part_text_cursor_handler_disabled_set
3251                 (sd->entry_edje, "elm.text", sd->cursor_handler_disabled);
3252           }
3253         // TIZEN ONLY
3254         if (!sd->double_clicked)
3255           {
3256              if ((sd->api) && (sd->api->obj_mouseup))
3257                sd->api->obj_mouseup(data);
3258           }
3259         if (sd->magnifier_enabled)
3260           {
3261              _magnifier_hide(data);
3262 #ifndef ELM_FEATURE_WEARABLE
3263              if ((sd->long_pressed) && (!sd->drag_started))
3264                _menu_call(data);
3265 #endif
3266           }
3267         sd->mouse_upped = EINA_TRUE;
3268         /////
3269         if (sd->longpress_timer)
3270           {
3271              ecore_timer_del(sd->longpress_timer);
3272              sd->longpress_timer = NULL;
3273           }
3274      }
3275    else if ((ev->button == 3) && (!_elm_config->desktop_entry))
3276      {
3277         sd->use_down = 1;
3278 #ifndef ELM_FEATURE_WEARABLE
3279         _menu_call(data);
3280 #endif
3281      }
3282 }
3283
3284 static void
3285 _mouse_move_cb(void *data,
3286                Evas *evas __UNUSED__,
3287                Evas_Object *obj __UNUSED__,
3288                void *event_info)
3289 {
3290    Evas_Event_Mouse_Move *ev = event_info;
3291
3292    ELM_ENTRY_DATA_GET(data, sd);
3293
3294    if (sd->disabled) return;
3295
3296    // TIZEN ONLY
3297    if (ev->buttons == 1)
3298      {
3299         if (sd->long_pressed)
3300           {
3301              if ((!sd->drag_started) && (sd->magnifier_enabled))
3302                {
3303                   if (sd->has_text)
3304                     {
3305                        _magnifier_show(data);
3306                        _magnifier_move(data);
3307                     }
3308                }
3309           }
3310      }
3311    //////////
3312
3313    if (!sd->sel_mode)
3314      {
3315         if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
3316           {
3317              if (sd->longpress_timer)
3318                {
3319                   ecore_timer_del(sd->longpress_timer);
3320                   sd->longpress_timer = NULL;
3321                }
3322           }
3323         else if (sd->longpress_timer)
3324           {
3325              Evas_Coord dx, dy;
3326
3327              dx = sd->downx - ev->cur.canvas.x;
3328              dx *= dx;
3329              dy = sd->downy - ev->cur.canvas.y;
3330              dy *= dy;
3331              if ((dx + dy) >
3332                  ((_elm_config->finger_size / 2) *
3333                   (_elm_config->finger_size / 2)))
3334                {
3335                   ecore_timer_del(sd->longpress_timer);
3336                   sd->longpress_timer = NULL;
3337                }
3338           }
3339      }
3340    else if (sd->longpress_timer)
3341      {
3342         Evas_Coord dx, dy;
3343
3344         dx = sd->downx - ev->cur.canvas.x;
3345         dx *= dx;
3346         dy = sd->downy - ev->cur.canvas.y;
3347         dy *= dy;
3348         if ((dx + dy) >
3349             ((_elm_config->finger_size / 2) *
3350              (_elm_config->finger_size / 2)))
3351           {
3352              ecore_timer_del(sd->longpress_timer);
3353              sd->longpress_timer = NULL;
3354           }
3355      }
3356 }
3357
3358 static void
3359 _entry_changed_handle(void *data,
3360                       const char *event)
3361 {
3362    Evas_Coord minh;
3363    const char *text;
3364
3365    ELM_ENTRY_DATA_GET(data, sd);
3366
3367    evas_event_freeze(evas_object_evas_get(data));
3368    sd->changed = EINA_TRUE;
3369    /* Reset the size hints which are no more relevant. Keep the
3370     * height, this is a hack, but doesn't really matter cause we'll
3371     * re-eval in a moment. */
3372    evas_object_size_hint_min_get(data, NULL, &minh);
3373    evas_object_size_hint_min_set(data, -1, minh);
3374
3375    elm_layout_sizing_eval(data);
3376    if (sd->text) eina_stringshare_del(sd->text);
3377    sd->text = NULL;
3378
3379    // TIZEN ONLY
3380    if (sd->password_text)
3381      eina_stringshare_del(sd->password_text);
3382    sd->password_text = NULL;
3383
3384    if ((sd->api) && (sd->api->obj_hidemenu))
3385      sd->api->obj_hidemenu(data);
3386    /////
3387
3388    if (sd->delay_write)
3389      {
3390         ecore_timer_del(sd->delay_write);
3391         sd->delay_write = NULL;
3392      }
3393    evas_event_thaw(evas_object_evas_get(data));
3394    evas_event_thaw_eval(evas_object_evas_get(data));
3395    if ((sd->auto_save) && (sd->file))
3396      sd->delay_write = ecore_timer_add(2.0, _delay_write, data);
3397
3398    _return_key_enabled_check(data);
3399    text = edje_object_part_text_get(sd->entry_edje, "elm.text");
3400    if (text)
3401      {
3402         if (text[0])
3403           _elm_entry_guide_update(data, EINA_TRUE);
3404         else
3405           _elm_entry_guide_update(data, EINA_FALSE);
3406      }
3407    /* callback - this could call callbacks that delete the
3408     * entry... thus... any access to sd after this could be
3409     * invalid */
3410
3411    // TIZEN ONLY(130911)
3412    _cursor_geometry_update(data);
3413    //
3414
3415    evas_object_smart_callback_call(data, event, NULL);
3416 }
3417
3418 static void
3419 _entry_changed_signal_cb(void *data,
3420                          Evas_Object *obj __UNUSED__,
3421                          const char *emission __UNUSED__,
3422                          const char *source __UNUSED__)
3423 {
3424    _entry_changed_handle(data, SIG_CHANGED);
3425 }
3426
3427 static void
3428 _entry_changed_user_signal_cb(void *data,
3429                               Evas_Object *obj __UNUSED__,
3430                               const char *emission __UNUSED__,
3431                               const char *source __UNUSED__)
3432 {
3433    Elm_Entry_Change_Info info;
3434    Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
3435      edje_object_signal_callback_extra_data_get();
3436
3437    if (edje_info)
3438      {
3439         memcpy(&info, edje_info, sizeof(info));
3440         evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
3441      }
3442    else
3443      {
3444         evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
3445      }
3446 }
3447
3448 static void
3449 _entry_preedit_changed_signal_cb(void *data,
3450                                  Evas_Object *obj __UNUSED__,
3451                                  const char *emission __UNUSED__,
3452                                  const char *source __UNUSED__)
3453 {
3454    _entry_changed_handle(data, SIG_PREEDIT_CHANGED);
3455 }
3456
3457 static void
3458 _entry_undo_request_signal_cb(void *data,
3459                               Evas_Object *obj __UNUSED__,
3460                               const char *emission __UNUSED__,
3461                               const char *source __UNUSED__)
3462 {
3463    evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
3464 }
3465
3466 static void
3467 _entry_redo_request_signal_cb(void *data,
3468                               Evas_Object *obj __UNUSED__,
3469                               const char *emission __UNUSED__,
3470                               const char *source __UNUSED__)
3471 {
3472    evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
3473 }
3474
3475 static void
3476 _entry_selection_start_signal_cb(void *data,
3477                                  Evas_Object *obj __UNUSED__,
3478                                  const char *emission __UNUSED__,
3479                                  const char *source __UNUSED__)
3480 {
3481    const Eina_List *l;
3482    Evas_Object *entry;
3483
3484    ELM_ENTRY_DATA_GET(data, sd);
3485
3486    if (!elm_object_focus_get(data)) elm_object_focus_set(data, EINA_TRUE);
3487    EINA_LIST_FOREACH(entries, l, entry)
3488      {
3489         if (entry != data) elm_entry_select_none(entry);
3490      }
3491
3492    // TIZEN ONLY
3493    sd->sel_mode = EINA_TRUE;
3494    ///
3495
3496    evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
3497 #ifdef HAVE_ELEMENTARY_X
3498    if (sd->sel_notify_handler)
3499      {
3500         const char *txt = elm_entry_selection_get(data);
3501         Evas_Object *top;
3502
3503         top = elm_widget_top_get(data);
3504         if (txt && top && (elm_win_xwindow_get(top)))
3505           elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
3506                                 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
3507      }
3508 #endif
3509 }
3510
3511 static void
3512 _entry_selection_all_signal_cb(void *data,
3513                                Evas_Object *obj __UNUSED__,
3514                                const char *emission __UNUSED__,
3515                                const char *source __UNUSED__)
3516 {
3517    elm_entry_select_all(data);
3518 }
3519
3520 static void
3521 _entry_selection_none_signal_cb(void *data,
3522                                 Evas_Object *obj __UNUSED__,
3523                                 const char *emission __UNUSED__,
3524                                 const char *source __UNUSED__)
3525 {
3526    ELM_ENTRY_DATA_GET(data, sd); // TIZEN ONLY
3527
3528    elm_entry_select_none(data);
3529
3530    // TIZEN ONLY
3531    if ((sd->api) && (sd->api->obj_hidemenu))
3532      sd->api->obj_hidemenu(data);
3533    /////
3534
3535 }
3536
3537 static void
3538 _entry_selection_changed_signal_cb(void *data,
3539                                    Evas_Object *obj __UNUSED__,
3540                                    const char *emission __UNUSED__,
3541                                    const char *source __UNUSED__)
3542 {
3543    ELM_ENTRY_DATA_GET(data, sd);
3544    Evas_Coord cx, cy, cw, ch; // TIZEN ONLY
3545
3546    sd->have_selection = EINA_TRUE;
3547    sd->sel_mode = EINA_TRUE; // TIZEN ONLY
3548    evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
3549    _selection_store(ELM_SEL_TYPE_PRIMARY, data);
3550
3551    // TIZEN ONLY
3552    edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
3553    if (!sd->deferred_recalc_job)
3554      elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
3555    else
3556      {
3557         sd->deferred_cur = EINA_TRUE;
3558         sd->cx = cx;
3559         sd->cy = cy;
3560         sd->cw = cw;
3561         sd->ch = ch;
3562      }
3563    ///////
3564 }
3565
3566 static void
3567 _entry_selection_cleared_signal_cb(void *data,
3568                                    Evas_Object *obj __UNUSED__,
3569                                    const char *emission __UNUSED__,
3570                                    const char *source __UNUSED__)
3571 {
3572    ELM_ENTRY_DATA_GET(data, sd);
3573
3574    if (!sd->have_selection) return;
3575
3576    sd->have_selection = EINA_FALSE;
3577
3578    // TIZEN ONLY
3579    sd->sel_mode = EINA_FALSE;
3580    ///
3581
3582    // TIZEN_ONLY(20130830): For cursor movement when mouse up.
3583    edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", EINA_FALSE);
3584    //
3585    evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
3586    if (sd->sel_notify_handler)
3587      {
3588         if (sd->cut_sel)
3589           {
3590 #ifdef HAVE_ELEMENTARY_X
3591              Evas_Object *top;
3592
3593              top = elm_widget_top_get(data);
3594              if ((top) && (elm_win_xwindow_get(top)))
3595                elm_cnp_selection_set
3596                  (data, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_MARKUP,
3597                  sd->cut_sel, strlen(sd->cut_sel));
3598 #endif
3599              eina_stringshare_del(sd->cut_sel);
3600              sd->cut_sel = NULL;
3601           }
3602         else if (!sd->drag_started)
3603           {
3604 #ifdef HAVE_ELEMENTARY_X
3605              Evas_Object *top;
3606
3607              top = elm_widget_top_get(data);
3608              if ((top) && (elm_win_xwindow_get(top)))
3609                elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
3610 #endif
3611           }
3612      }
3613
3614    // TIZEN ONLY
3615    if ((sd->api) && (sd->api->obj_hidemenu))
3616      {
3617         sd->api->obj_hidemenu(data);
3618      }
3619    /////
3620 }
3621
3622 static void
3623 _entry_paste_request_signal_cb(void *data,
3624                                Evas_Object *obj __UNUSED__,
3625                                const char *emission,
3626                                const char *source __UNUSED__)
3627 {
3628    ELM_ENTRY_DATA_GET(data, sd);
3629
3630 #ifdef HAVE_ELEMENTARY_X
3631    Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
3632      ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
3633 #endif
3634
3635    if (!sd->editable) return;
3636    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
3637    if (sd->sel_notify_handler)
3638      {
3639 #ifdef HAVE_ELEMENTARY_X
3640         Evas_Object *top;
3641
3642         top = elm_widget_top_get(data);
3643         if ((top) && (elm_win_xwindow_get(top)))
3644           {
3645              Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
3646
3647              sd->selection_asked = EINA_TRUE;
3648
3649              if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
3650                formats = ELM_SEL_FORMAT_TEXT;
3651              else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
3652                formats |= ELM_SEL_FORMAT_IMAGE;
3653
3654              elm_cnp_selection_get(data, type, formats, NULL, NULL);
3655           }
3656 #endif
3657      }
3658 }
3659
3660 static void
3661 _entry_copy_notify_signal_cb(void *data,
3662                              Evas_Object *obj __UNUSED__,
3663                              const char *emission __UNUSED__,
3664                              const char *source __UNUSED__)
3665 {
3666    _copy_cb(data, NULL, NULL);
3667 }
3668
3669 static void
3670 _entry_cut_notify_signal_cb(void *data,
3671                             Evas_Object *obj __UNUSED__,
3672                             const char *emission __UNUSED__,
3673                             const char *source __UNUSED__)
3674 {
3675    _cut_cb(data, NULL, NULL);
3676 }
3677
3678 static void
3679 _entry_cursor_changed_signal_cb(void *data,
3680                                 Evas_Object *obj __UNUSED__,
3681                                 const char *emission __UNUSED__,
3682                                 const char *source __UNUSED__)
3683 {
3684    ELM_ENTRY_DATA_GET(data, sd);
3685    int new_pos = edje_object_part_text_cursor_pos_get
3686       (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
3687    if (sd->cursor_pos != new_pos)
3688      {
3689         sd->cursor_pos = new_pos;
3690         sd->cur_changed = EINA_TRUE;
3691      }
3692    _cursor_geometry_recalc(data);
3693    // TIZEN ONY - START
3694    if (elm_widget_focus_get(data))
3695      edje_object_signal_emit(sd->entry_edje, "elm,action,show,cursor", "elm");
3696    // TIZEN ONLY - END
3697 }
3698
3699 static void
3700 _entry_cursor_changed_manual_signal_cb(void *data,
3701                                        Evas_Object *obj __UNUSED__,
3702                                        const char *emission __UNUSED__,
3703                                        const char *source __UNUSED__)
3704 {
3705    ELM_ENTRY_DATA_GET(data, sd);
3706    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
3707    // TIZEN ONY - START
3708    if (elm_widget_focus_get(data))
3709      edje_object_signal_emit(sd->entry_edje, "elm,action,show,cursor", "elm");
3710    // TIZEN ONLY - END
3711 }
3712
3713 static void
3714 _signal_anchor_geoms_do_things_with_lol(Elm_Entry_Smart_Data *sd,
3715                                         Elm_Entry_Anchor_Info *ei)
3716 {
3717    Evas_Textblock_Rectangle *r;
3718    const Eina_List *geoms, *l;
3719    Evas_Coord px, py, x, y;
3720
3721    geoms = edje_object_part_text_anchor_geometry_get
3722        (sd->entry_edje, "elm.text", ei->name);
3723
3724    if (!geoms) return;
3725
3726    evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
3727    evas_pointer_canvas_xy_get
3728      (evas_object_evas_get(sd->entry_edje), &px, &py);
3729
3730    EINA_LIST_FOREACH(geoms, l, r)
3731      {
3732         if (((r->x + x) <= px) && ((r->y + y) <= py) &&
3733             ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
3734           {
3735              ei->x = r->x + x;
3736              ei->y = r->y + y;
3737              ei->w = r->w;
3738              ei->h = r->h;
3739              break;
3740           }
3741      }
3742 }
3743
3744 static void
3745 _entry_anchor_down_signal_cb(void *data,
3746                              Evas_Object *obj __UNUSED__,
3747                              const char *emission __UNUSED__,
3748                              const char *source __UNUSED__)
3749 {
3750    Elm_Entry_Anchor_Info ei;
3751    const char *p;
3752    char *p2;
3753
3754    ELM_ENTRY_DATA_GET(data, sd);
3755
3756    p = emission + sizeof("nchor,mouse,down,");
3757    ei.button = strtol(p, &p2, 10);
3758    ei.name = p2 + 1;
3759    ei.x = ei.y = ei.w = ei.h = 0;
3760
3761    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
3762
3763    if (!sd->disabled)
3764      evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
3765 }
3766
3767 static void
3768 _entry_anchor_up_signal_cb(void *data,
3769                            Evas_Object *obj __UNUSED__,
3770                            const char *emission __UNUSED__,
3771                            const char *source __UNUSED__)
3772 {
3773    Elm_Entry_Anchor_Info ei;
3774    const char *p;
3775    char *p2;
3776
3777    ELM_ENTRY_DATA_GET(data, sd);
3778
3779    p = emission + sizeof("nchor,mouse,up,");
3780    ei.button = strtol(p, &p2, 10);
3781    ei.name = p2 + 1;
3782    ei.x = ei.y = ei.w = ei.h = 0;
3783
3784    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
3785
3786    if (!sd->disabled)
3787      evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
3788 }
3789
3790 static void
3791 _anchor_hover_del_cb(void *data,
3792                      Evas *e __UNUSED__,
3793                      Evas_Object *obj __UNUSED__,
3794                      void *event_info __UNUSED__)
3795 {
3796    ELM_ENTRY_DATA_GET(data, sd);
3797
3798    if (sd->anchor_hover.pop) evas_object_del(sd->anchor_hover.pop);
3799    sd->anchor_hover.pop = NULL;
3800    evas_object_event_callback_del_full
3801      (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
3802 }
3803
3804 static void
3805 _anchor_hover_clicked_cb(void *data,
3806                          Evas_Object *obj __UNUSED__,
3807                          void *event_info __UNUSED__)
3808 {
3809    elm_entry_anchor_hover_end(data);
3810 }
3811
3812 static void
3813 _entry_hover_anchor_clicked_do(Evas_Object *obj,
3814                                Elm_Entry_Anchor_Info *info)
3815 {
3816    Evas_Object *hover_parent;
3817    Evas_Coord x, w, y, h, px, py;
3818    Elm_Entry_Anchor_Hover_Info ei;
3819
3820    ELM_ENTRY_DATA_GET(obj, sd);
3821
3822    ei.anchor_info = info;
3823
3824    sd->anchor_hover.pop = elm_icon_add(obj);
3825    evas_object_move(sd->anchor_hover.pop, info->x, info->y);
3826    evas_object_resize(sd->anchor_hover.pop, info->w, info->h);
3827
3828    sd->anchor_hover.hover = elm_hover_add(obj);
3829    evas_object_event_callback_add
3830      (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
3831    elm_widget_mirrored_set
3832      (sd->anchor_hover.hover, elm_widget_mirrored_get(obj));
3833    if (sd->anchor_hover.hover_style)
3834      elm_object_style_set
3835        (sd->anchor_hover.hover, sd->anchor_hover.hover_style);
3836
3837    hover_parent = sd->anchor_hover.hover_parent;
3838    if (!hover_parent) hover_parent = obj;
3839    elm_hover_parent_set(sd->anchor_hover.hover, hover_parent);
3840    elm_hover_target_set(sd->anchor_hover.hover, sd->anchor_hover.pop);
3841    ei.hover = sd->anchor_hover.hover;
3842
3843    evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
3844    ei.hover_parent.x = x;
3845    ei.hover_parent.y = y;
3846    ei.hover_parent.w = w;
3847    ei.hover_parent.h = h;
3848    px = info->x + (info->w / 2);
3849    py = info->y + (info->h / 2);
3850    ei.hover_left = 1;
3851    if (px < (x + (w / 3))) ei.hover_left = 0;
3852    ei.hover_right = 1;
3853    if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
3854    ei.hover_top = 1;
3855    if (py < (y + (h / 3))) ei.hover_top = 0;
3856    ei.hover_bottom = 1;
3857    if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
3858
3859    /* Swap right and left because they switch sides in RTL */
3860    if (elm_widget_mirrored_get(sd->anchor_hover.hover))
3861      {
3862         Eina_Bool tmp = ei.hover_left;
3863
3864         ei.hover_left = ei.hover_right;
3865         ei.hover_right = tmp;
3866      }
3867
3868    evas_object_smart_callback_call(obj, SIG_ANCHOR_HOVER_OPENED, &ei);
3869    evas_object_smart_callback_add
3870      (sd->anchor_hover.hover, "clicked", _anchor_hover_clicked_cb, obj);
3871
3872    /* FIXME: Should just check if there's any callback registered to
3873     * the smart events instead.  This is used to determine if anyone
3874     * cares about the hover or not. */
3875    if (!elm_layout_content_get(sd->anchor_hover.hover, "middle") &&
3876        !elm_layout_content_get(sd->anchor_hover.hover, "left") &&
3877        !elm_layout_content_get(sd->anchor_hover.hover, "right") &&
3878        !elm_layout_content_get(sd->anchor_hover.hover, "top") &&
3879        !elm_layout_content_get(sd->anchor_hover.hover, "bottom"))
3880      {
3881         evas_object_del(sd->anchor_hover.hover);
3882         sd->anchor_hover.hover = NULL;
3883      }
3884    else
3885      evas_object_show(sd->anchor_hover.hover);
3886 }
3887
3888 static void
3889 _entry_anchor_clicked_signal_cb(void *data,
3890                                 Evas_Object *obj __UNUSED__,
3891                                 const char *emission,
3892                                 const char *source __UNUSED__)
3893 {
3894    Elm_Entry_Anchor_Info ei;
3895    const char *p;
3896    char *p2;
3897
3898    ELM_ENTRY_DATA_GET(data, sd);
3899
3900    p = emission + sizeof("nchor,mouse,clicked,");
3901    ei.button = strtol(p, &p2, 10);
3902    ei.name = p2 + 1;
3903    ei.x = ei.y = ei.w = ei.h = 0;
3904
3905    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
3906
3907    if (!sd->disabled)
3908      {
3909         evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
3910
3911         _entry_hover_anchor_clicked_do(data, &ei);
3912      }
3913 }
3914
3915 static void
3916 _entry_anchor_move_signal_cb(void *data __UNUSED__,
3917                              Evas_Object *obj __UNUSED__,
3918                              const char *emission __UNUSED__,
3919                              const char *source __UNUSED__)
3920 {
3921 }
3922
3923 static void
3924 _entry_anchor_in_signal_cb(void *data,
3925                            Evas_Object *obj __UNUSED__,
3926                            const char *emission __UNUSED__,
3927                            const char *source __UNUSED__)
3928 {
3929    Elm_Entry_Anchor_Info ei;
3930
3931    ELM_ENTRY_DATA_GET(data, sd);
3932
3933    ei.name = emission + sizeof("nchor,mouse,in,");
3934    ei.button = 0;
3935    ei.x = ei.y = ei.w = ei.h = 0;
3936
3937    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
3938
3939    if (!sd->disabled)
3940      evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
3941 }
3942
3943 static void
3944 _entry_anchor_out_signal_cb(void *data,
3945                             Evas_Object *obj __UNUSED__,
3946                             const char *emission __UNUSED__,
3947                             const char *source __UNUSED__)
3948 {
3949    Elm_Entry_Anchor_Info ei;
3950
3951    ELM_ENTRY_DATA_GET(data, sd);
3952
3953    ei.name = emission + sizeof("nchor,mouse,out,");
3954    ei.button = 0;
3955    ei.x = ei.y = ei.w = ei.h = 0;
3956
3957    _signal_anchor_geoms_do_things_with_lol(sd, &ei);
3958
3959    if (!sd->disabled)
3960      evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
3961 }
3962
3963 static void
3964 _entry_key_enter_signal_cb(void *data,
3965                            Evas_Object *obj __UNUSED__,
3966                            const char *emission __UNUSED__,
3967                            const char *source __UNUSED__)
3968 {
3969    evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
3970 }
3971
3972 static void
3973 _entry_key_escape_signal_cb(void *data,
3974                             Evas_Object *obj __UNUSED__,
3975                             const char *emission __UNUSED__,
3976                             const char *source __UNUSED__)
3977 {
3978    evas_object_smart_callback_call(data, SIG_ABORTED, NULL);
3979 }
3980
3981 static void
3982 _entry_mouse_down_signal_cb(void *data,
3983                             Evas_Object *obj __UNUSED__,
3984                             const char *emission __UNUSED__,
3985                             const char *source __UNUSED__)
3986 {
3987    // TIZEN ONLY
3988    ELM_ENTRY_DATA_GET(data, sd);
3989    sd->double_clicked = EINA_FALSE;
3990    /////////
3991    evas_object_smart_callback_call(data, SIG_PRESS, NULL);
3992 }
3993
3994 static void
3995 _entry_mouse_clicked_signal_cb(void *data,
3996                                Evas_Object *obj __UNUSED__,
3997                                const char *emission __UNUSED__,
3998                                const char *source __UNUSED__)
3999 {
4000    evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
4001 }
4002
4003 static void
4004 _entry_mouse_double_signal_cb(void *data,
4005                               Evas_Object *obj __UNUSED__,
4006                               const char *emission __UNUSED__,
4007                               const char *source __UNUSED__)
4008 {
4009    // TIZEN ONLY
4010    ELM_ENTRY_DATA_GET(data, sd);
4011    if (sd->disabled) return;
4012    sd->double_clicked = EINA_TRUE;
4013    if (!sd->sel_allow) return;
4014
4015    if (!_elm_config->desktop_entry)
4016      edje_object_part_text_select_allow_set
4017         (sd->entry_edje, "elm.text", EINA_TRUE);
4018    _magnifier_hide(data);
4019 #ifndef ELM_FEATURE_WEARABLE
4020    _menu_call(data);
4021 #endif
4022    /////
4023    evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
4024 }
4025
4026 static void
4027 _entry_mouse_triple_signal_cb(void *data,
4028                               Evas_Object *obj __UNUSED__,
4029                               const char *emission __UNUSED__,
4030                               const char *source __UNUSED__)
4031 {
4032    // TIZEN ONLY
4033    ELM_ENTRY_DATA_GET(data, sd);
4034    if (sd->disabled) return;
4035    sd->double_clicked = EINA_TRUE;
4036    if (!sd->sel_allow) return;
4037
4038    if (!_elm_config->desktop_entry)
4039      edje_object_part_text_select_allow_set
4040         (sd->entry_edje, "elm.text", EINA_TRUE);
4041    _magnifier_hide(data);
4042 #ifndef ELM_FEATURE_WEARABLE
4043    _menu_call(data);
4044 #endif
4045    /////
4046    evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
4047 }
4048
4049 #ifdef HAVE_ELEMENTARY_X
4050 static Eina_Bool
4051 _event_selection_notify(void *data,
4052                         int type __UNUSED__,
4053                         void *event)
4054 {
4055    Ecore_X_Event_Selection_Notify *ev = event;
4056
4057    ELM_ENTRY_DATA_GET(data, sd);
4058
4059    if ((!sd->selection_asked) && (!sd->drag_selection_asked))
4060      return ECORE_CALLBACK_PASS_ON;
4061
4062    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
4063        (ev->selection == ECORE_X_SELECTION_PRIMARY))
4064      {
4065         Ecore_X_Selection_Data_Text *text_data;
4066
4067         text_data = ev->data;
4068         if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
4069           {
4070              if (text_data->text)
4071                {
4072                   char *txt = _elm_util_text_to_mkup(text_data->text);
4073
4074                   if (txt)
4075                     {
4076                        elm_entry_entry_insert(data, txt);
4077                        free(txt);
4078                     }
4079                }
4080           }
4081         sd->selection_asked = EINA_FALSE;
4082      }
4083    else if (ev->selection == ECORE_X_SELECTION_XDND)
4084      {
4085         Ecore_X_Selection_Data_Text *text_data;
4086
4087         text_data = ev->data;
4088         if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
4089           {
4090              if (text_data->text)
4091                {
4092                   char *txt = _elm_util_text_to_mkup(text_data->text);
4093
4094                   if (txt)
4095                     {
4096                        /* Massive FIXME: this should be at the drag point */
4097                        elm_entry_entry_insert(data, txt);
4098                        free(txt);
4099                     }
4100                }
4101           }
4102         sd->drag_selection_asked = EINA_FALSE;
4103
4104         ecore_x_dnd_send_finished();
4105      }
4106
4107    return ECORE_CALLBACK_PASS_ON;
4108 }
4109
4110 static Eina_Bool
4111 _event_selection_clear(void *data __UNUSED__,
4112                        int type __UNUSED__,
4113                        void *event __UNUSED__)
4114 {
4115 #if 0
4116    Ecore_X_Event_Selection_Clear *ev = event;
4117
4118    ELM_ENTRY_DATA_GET(data, sd);
4119
4120    if (!sd->have_selection) return ECORE_CALLBACK_PASS_ON;
4121    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
4122        (ev->selection == ECORE_X_SELECTION_PRIMARY))
4123      {
4124         elm_entry_select_none(data);
4125      }
4126 #else
4127    /// TIZEN ONLY
4128    Evas_Object *top = elm_widget_top_get(data);
4129    Ecore_X_Event_Selection_Clear *ev = event;
4130
4131    if (!top)
4132       return ECORE_CALLBACK_PASS_ON;
4133
4134    if (ev->selection != ECORE_X_SELECTION_SECONDARY)
4135      {
4136         return ECORE_CALLBACK_PASS_ON;
4137      }
4138
4139    if (elm_widget_focus_get(data))
4140      {
4141         ELM_ENTRY_DATA_GET(data, sd);
4142         Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
4143         evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
4144         if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
4145           formats = ELM_SEL_FORMAT_TEXT;
4146         else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
4147           formats |= ELM_SEL_FORMAT_IMAGE;
4148         elm_cnp_selection_get(data, ELM_SEL_TYPE_SECONDARY, formats, NULL, NULL);
4149
4150         return ECORE_CALLBACK_DONE;
4151      }
4152    ///////////
4153 #endif
4154    return ECORE_CALLBACK_PASS_ON;
4155 }
4156
4157 static void
4158 _dnd_enter_cb(void *data,
4159               Evas_Object *obj __UNUSED__)
4160 {
4161    elm_object_focus_set(data, EINA_TRUE);
4162 }
4163
4164 static void
4165 _dnd_leave_cb(void *data,
4166               Evas_Object *obji __UNUSED__)
4167 {
4168    elm_object_focus_set(data, EINA_FALSE);
4169 }
4170
4171 static void
4172 _dnd_pos_cb(void *data, Evas_Object *obj __UNUSED__, Evas_Coord x, Evas_Coord y,
4173             Elm_Xdnd_Action action EINA_UNUSED)
4174 {
4175    elm_object_focus_set(data, EINA_TRUE);
4176
4177    ELM_ENTRY_DATA_GET(data, sd);
4178
4179    edje_object_part_text_cursor_coord_set
4180       (sd->entry_edje, "elm.text", EDJE_CURSOR_USER, x, y);
4181    int pos = edje_object_part_text_cursor_pos_get
4182       (sd->entry_edje, "elm.text", EDJE_CURSOR_USER);
4183    elm_entry_cursor_pos_set(data, pos);
4184 }
4185
4186 #endif
4187
4188 static Evas_Object *
4189 _item_get(void *data,
4190           Evas_Object *edje __UNUSED__,
4191           const char *part __UNUSED__,
4192           const char *item)
4193 {
4194    Eina_List *l;
4195    Evas_Object *o;
4196    Elm_Entry_Item_Provider *ip;
4197
4198    ELM_ENTRY_DATA_GET(data, sd);
4199
4200    EINA_LIST_FOREACH(sd->item_providers, l, ip)
4201      {
4202         o = ip->func(ip->data, data, item);
4203         if (o) return o;
4204      }
4205    if (!strncmp(item, "file://", 7))
4206      {
4207         const char *fname = item + 7;
4208
4209         o = evas_object_image_filled_add(evas_object_evas_get(data));
4210         evas_object_image_file_set(o, fname, NULL);
4211         if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
4212           {
4213              evas_object_show(o);
4214           }
4215         else
4216           {
4217              evas_object_del(o);
4218              o = evas_object_rectangle_add(evas_object_evas_get(data));
4219              evas_object_color_set(o, 0, 0, 0, 0);
4220           }
4221         return o;
4222      }
4223
4224    o = edje_object_add(evas_object_evas_get(data));
4225    if (!elm_widget_theme_object_set
4226          (data, o, "entry", item, elm_widget_style_get(data)))
4227      {
4228         evas_object_del(o);
4229         o = evas_object_rectangle_add(evas_object_evas_get(data));
4230         evas_object_color_set(o, 0, 0, 0, 0);
4231      }
4232    return o;
4233 }
4234
4235 static void
4236 _text_filter_cb(void *data,
4237                 Evas_Object *edje __UNUSED__,
4238                 const char *part __UNUSED__,
4239                 Edje_Text_Filter_Type type,
4240                 char **text)
4241 {
4242    Eina_List *l;
4243    Elm_Entry_Markup_Filter *tf;
4244
4245    ELM_ENTRY_DATA_GET(data, sd);
4246
4247    if (type == EDJE_TEXT_FILTER_FORMAT)
4248      return;
4249
4250    EINA_LIST_FOREACH(sd->text_filters, l, tf)
4251      {
4252         tf->func(tf->data, data, text);
4253         if (!*text)
4254           break;
4255      }
4256 }
4257
4258 static void
4259 _markup_filter_cb(void *data,
4260                   Evas_Object *edje __UNUSED__,
4261                   const char *part __UNUSED__,
4262                   char **text)
4263 {
4264    Eina_List *l;
4265    Elm_Entry_Markup_Filter *tf;
4266
4267    ELM_ENTRY_DATA_GET(data, sd);
4268
4269    EINA_LIST_FOREACH(sd->markup_filters, l, tf)
4270      {
4271         tf->func(tf->data, data, text);
4272         if (!*text)
4273           break;
4274      }
4275 }
4276
4277 /* This function is used to insert text by chunks in jobs */
4278 static Eina_Bool
4279 _text_append_idler(void *data)
4280 {
4281    int start;
4282    char backup;
4283    Evas_Object *obj = (Evas_Object *)data;
4284
4285    ELM_ENTRY_DATA_GET(obj, sd);
4286
4287    evas_event_freeze(evas_object_evas_get(obj));
4288    if (sd->text) eina_stringshare_del(sd->text);
4289    sd->text = NULL;
4290    // TIZEN ONLY
4291    if (sd->password_text) eina_stringshare_del(sd->password_text);
4292    sd->password_text = NULL;
4293    //////
4294    sd->changed = EINA_TRUE;
4295
4296    start = sd->append_text_position;
4297    if ((start + _CHUNK_SIZE) < sd->append_text_len)
4298      {
4299         int pos = start;
4300         int tag_start, esc_start;
4301
4302         tag_start = esc_start = -1;
4303         /* Find proper markup cut place */
4304         while (pos - start < _CHUNK_SIZE)
4305           {
4306              int prev_pos = pos;
4307              Eina_Unicode tmp =
4308                eina_unicode_utf8_get_next(sd->append_text_left, &pos);
4309
4310              if (esc_start == -1)
4311                {
4312                   if (tmp == '<')
4313                     tag_start = prev_pos;
4314                   else if (tmp == '>')
4315                     tag_start = -1;
4316                }
4317              if (tag_start == -1)
4318                {
4319                   if (tmp == '&')
4320                     esc_start = prev_pos;
4321                   else if (tmp == ';')
4322                     esc_start = -1;
4323                }
4324           }
4325
4326         if (tag_start >= 0)
4327           {
4328              sd->append_text_position = tag_start;
4329           }
4330         else if (esc_start >= 0)
4331           {
4332              sd->append_text_position = esc_start;
4333           }
4334         else
4335           {
4336              sd->append_text_position = pos;
4337           }
4338      }
4339    else
4340      {
4341         sd->append_text_position = sd->append_text_len;
4342      }
4343
4344    backup = sd->append_text_left[sd->append_text_position];
4345    sd->append_text_left[sd->append_text_position] = '\0';
4346
4347    edje_object_part_text_append
4348      (sd->entry_edje, "elm.text", sd->append_text_left + start);
4349
4350    sd->append_text_left[sd->append_text_position] = backup;
4351
4352    evas_event_thaw(evas_object_evas_get(obj));
4353    evas_event_thaw_eval(evas_object_evas_get(obj));
4354
4355    _elm_entry_guide_update(obj, EINA_TRUE);
4356
4357    /* If there's still more to go, renew the idler, else, cleanup */
4358    if (sd->append_text_position < sd->append_text_len)
4359      {
4360         return ECORE_CALLBACK_RENEW;
4361      }
4362    else
4363      {
4364         free(sd->append_text_left);
4365         sd->append_text_left = NULL;
4366         sd->append_text_idler = NULL;
4367         evas_object_smart_callback_call(obj, SIG_TEXT_SET_DONE, NULL);
4368         return ECORE_CALLBACK_CANCEL;
4369      }
4370 }
4371
4372 static void
4373 _chars_add_till_limit(Evas_Object *obj,
4374                       char **text,
4375                       int can_add,
4376                       Length_Unit unit)
4377 {
4378    Eina_List *tag_list = NULL;
4379    int i = 0, current_len = 0;
4380    char *new_text;
4381
4382    if (!*text) return;
4383    if (unit >= LENGTH_UNIT_LAST) return;
4384    // TIZEN_ONLY (20131111) : Preediting text is not allowed, either.
4385    // if (strstr(*text, "<preedit")) return;
4386
4387    new_text = *text;
4388    current_len = strlen(*text);
4389    while (*new_text)
4390      {
4391         int idx = 0, unit_size = 0;
4392         char *markup, *utfstr;
4393
4394         if (*new_text == '<')
4395           {
4396              while (*(new_text + idx) != '>')
4397                {
4398                   idx++;
4399                   if (!*(new_text + idx)) break;
4400                }
4401              if ((*(new_text + idx - 1) == '/') && (idx == 2))
4402                {
4403                   // </> case
4404                   if (tag_list && eina_list_data_get(tag_list))
4405                     {
4406                        char *tag = eina_list_data_get(tag_list);
4407                        tag_list = eina_list_remove_list(tag_list, tag_list);
4408                        free(tag);
4409                     }
4410                }
4411              else if (*(new_text + 1) == '/')
4412                {
4413                   // closer case
4414                   Eina_List *l, *l_next;
4415                   char *tag;
4416                   EINA_LIST_FOREACH_SAFE(tag_list, l, l_next, tag)
4417                     {
4418                        if (!strncmp(new_text + 1, tag, idx))
4419                          {
4420                             tag_list = eina_list_remove_list(tag_list, l);
4421                             free(tag);
4422                             break;
4423                          }
4424                     }
4425                }
4426              else if (*(new_text + idx - 1) != '/')
4427                {
4428                   // opener case
4429                   int len = 0;
4430                   while (*(new_text + 1 + len))
4431                     {
4432                        if ((*(new_text + 1 + len) == ' ') ||
4433                            (*(new_text + 1 + len) == '=') ||
4434                            (*(new_text + 1 + len) == '>'))
4435                          break;
4436                        len++;
4437                     }
4438                   char *opener = malloc(len + 1);
4439                   strncpy(opener, new_text + 1, len);
4440                   opener[len] = 0;
4441                   if (!strcmp(opener, "br") || !strcmp(opener, "ps") ||
4442                       !strcmp(opener, "tab"))
4443                     free(opener);
4444                   else
4445                     tag_list = eina_list_prepend(tag_list, opener);
4446                }
4447           }
4448         else if (*new_text == '&')
4449           {
4450              while (*(new_text + idx) != ';')
4451                {
4452                   idx++;
4453                   if (!*(new_text + idx)) break;
4454                }
4455           }
4456         idx = evas_string_char_next_get(new_text, idx, NULL);
4457         markup = malloc(idx + 1);
4458         if (markup)
4459           {
4460              strncpy(markup, new_text, idx);
4461              markup[idx] = 0;
4462              utfstr = elm_entry_markup_to_utf8(markup);
4463              if (utfstr)
4464                {
4465                   if (unit == LENGTH_UNIT_BYTE)
4466                     unit_size = strlen(utfstr);
4467                   else if (unit == LENGTH_UNIT_CHAR)
4468                     unit_size = evas_string_char_len_get(utfstr);
4469                   free(utfstr);
4470                   utfstr = NULL;
4471                }
4472              free(markup);
4473              markup = NULL;
4474           }
4475         if (can_add < unit_size)
4476           {
4477              if (!i)
4478                {
4479                   if (elm_object_focus_get(obj))
4480                     evas_object_smart_callback_call(obj, SIG_MAX_LENGTH, NULL);
4481                   free(*text);
4482                   *text = NULL;
4483                   return;
4484                }
4485              can_add = 0;
4486              current_len = new_text - *text;
4487              (*text)[current_len] = 0;
4488              if (tag_list)
4489                {
4490                   Eina_List *l, *l_next;
4491                   char *tag;
4492
4493                   Eina_Strbuf *str = eina_strbuf_new();
4494                   eina_strbuf_append(str, *text);
4495
4496                   EINA_LIST_FOREACH_SAFE(tag_list, l, l_next, tag)
4497                     {
4498                        eina_strbuf_append(str, "</");
4499                        eina_strbuf_append(str, tag);
4500                        eina_strbuf_append(str, ">");
4501                        tag_list = eina_list_remove_list(tag_list, l);
4502                        free(tag);
4503                     }
4504                   free(*text);
4505                   *text = eina_strbuf_string_steal(str);
4506                   eina_strbuf_free(str);
4507                }
4508              break;
4509           }
4510         else
4511           {
4512              new_text += idx;
4513              can_add -= unit_size;
4514           }
4515         i++;
4516      }
4517
4518    if (elm_object_focus_get(obj))
4519      evas_object_smart_callback_call(obj, SIG_MAX_LENGTH, NULL);
4520 }
4521
4522 static void
4523 _elm_entry_smart_signal(Evas_Object *obj,
4524                         const char *emission,
4525                         const char *source)
4526 {
4527    ELM_ENTRY_DATA_GET(obj, sd);
4528    evas_object_ref(obj);
4529    /* always pass to both edje objs */
4530    edje_object_signal_emit(sd->entry_edje, emission, source);
4531    edje_object_message_signal_process(sd->entry_edje);
4532
4533    if (sd->scr_edje)
4534      {
4535         edje_object_signal_emit(sd->scr_edje, emission, source);
4536         edje_object_message_signal_process(sd->scr_edje);
4537      }
4538
4539    // REDWOOD ONLY (140617): Support setting mgf bg from application
4540    if (!strcmp(emission, "elm,mgf,bg,color"))
4541      {
4542         char **arr = eina_str_split(source, ",", 0);
4543         int i;
4544         for (i = 0; arr[i]; i++)
4545           {
4546              switch (i)
4547                {
4548                 case 0:
4549                    sd->mgf_r = atoi(arr[i]);
4550                    break;
4551                 case 1:
4552                    sd->mgf_g = atoi(arr[i]);
4553                    break;
4554                 case 2:
4555                    sd->mgf_b = atoi(arr[i]);
4556                    break;
4557                 case 3:
4558                    sd->mgf_a = atoi(arr[i]);
4559                    break;
4560                }
4561           }
4562         if (i == 4)
4563           {
4564              sd->mgf_bg_color_set = EINA_TRUE;
4565           }
4566         else
4567           {
4568              sd->mgf_bg_color_set = EINA_FALSE;
4569           }
4570      }
4571    //
4572    evas_object_unref(obj);
4573 }
4574
4575 static void
4576 _elm_entry_smart_callback_add(Evas_Object *obj,
4577                               const char *emission,
4578                               const char *source,
4579                               Edje_Signal_Cb func_cb,
4580                               void *data)
4581 {
4582    Evas_Object *ro;
4583
4584    ELM_ENTRY_DATA_GET(obj, sd);
4585
4586    ro = ELM_WIDGET_DATA(sd)->resize_obj;
4587
4588    ELM_WIDGET_DATA(sd)->resize_obj = sd->entry_edje;
4589
4590    ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_add
4591      (obj, emission, source, func_cb, data);
4592
4593    if (sd->scr_edje)
4594      {
4595         ELM_WIDGET_DATA(sd)->resize_obj = sd->scr_edje;
4596
4597         ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_add
4598           (obj, emission, source, func_cb, data);
4599      }
4600
4601    ELM_WIDGET_DATA(sd)->resize_obj = ro;
4602 }
4603
4604 static void *
4605 _elm_entry_smart_callback_del(Evas_Object *obj,
4606                               const char *emission,
4607                               const char *source,
4608                               Edje_Signal_Cb func_cb)
4609 {
4610    Evas_Object *ro;
4611    void *data;
4612
4613    ELM_ENTRY_DATA_GET(obj, sd);
4614
4615    ro = ELM_WIDGET_DATA(sd)->resize_obj;
4616
4617    ELM_WIDGET_DATA(sd)->resize_obj = sd->entry_edje;
4618
4619    data = ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_del
4620        (obj, emission, source, func_cb);
4621
4622    if (sd->scr_edje)
4623      {
4624         ELM_WIDGET_DATA(sd)->resize_obj = sd->scr_edje;
4625
4626         ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_del
4627           (obj, emission, source, func_cb);
4628      }
4629
4630    ELM_WIDGET_DATA(sd)->resize_obj = ro;
4631
4632    return data;
4633 }
4634
4635 static Eina_Bool
4636 _elm_entry_smart_content_set(Evas_Object *obj,
4637                              const char *part,
4638                              Evas_Object *content)
4639 {
4640    if (!ELM_CONTAINER_CLASS(_elm_entry_parent_sc)->content_set
4641          (obj, part, content))
4642      return EINA_FALSE;
4643
4644    /* too bad entry does not follow the pattern
4645     * "elm,state,{icon,end},visible", we have to repeat ourselves */
4646    if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
4647      elm_entry_icon_visible_set(obj, EINA_TRUE);
4648
4649    if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
4650      elm_entry_end_visible_set(obj, EINA_TRUE);
4651
4652    return EINA_TRUE;
4653 }
4654
4655 static Evas_Object *
4656 _elm_entry_smart_content_unset(Evas_Object *obj,
4657                                const char *part)
4658 {
4659    Evas_Object *ret;
4660
4661    ret = ELM_CONTAINER_CLASS(_elm_entry_parent_sc)->content_unset(obj, part);
4662    if (!ret) return NULL;
4663
4664    /* too bad entry does not follow the pattern
4665     * "elm,state,{icon,end},hidden", we have to repeat ourselves */
4666    if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
4667      elm_entry_icon_visible_set(obj, EINA_FALSE);
4668
4669    if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
4670      elm_entry_end_visible_set(obj, EINA_FALSE);
4671
4672    return ret;
4673 }
4674
4675 static Eina_Bool
4676 _elm_entry_smart_text_set(Evas_Object *obj,
4677                           const char *item,
4678                           const char *entry)
4679 {
4680    int len = 0;
4681
4682    ELM_ENTRY_DATA_GET(obj, sd);
4683
4684    if (!entry) entry = "";
4685    if (item)
4686      {
4687         if (!strcmp(item, "guide"))
4688           edje_object_part_text_set(sd->entry_edje, "elm.guide", entry);
4689         else
4690           edje_object_part_text_set(sd->entry_edje, item, entry);
4691
4692         return EINA_TRUE;
4693      }
4694
4695    evas_event_freeze(evas_object_evas_get(obj));
4696    if (sd->text) eina_stringshare_del(sd->text);
4697    sd->text = NULL;
4698    // TIZEN ONLY
4699    if (sd->password_text) eina_stringshare_del(sd->password_text);
4700    sd->password_text = NULL;
4701    /////
4702    sd->changed = EINA_TRUE;
4703
4704    /* Clear currently pending job if there is one */
4705    if (sd->append_text_idler)
4706      {
4707         ecore_idler_del(sd->append_text_idler);
4708         sd->append_text_idler = NULL;
4709      }
4710
4711    if (sd->append_text_left)
4712      {
4713         free(sd->append_text_left);
4714         sd->append_text_left = NULL;
4715      }
4716
4717    len = strlen(entry);
4718    /* Split to ~_CHUNK_SIZE chunks */
4719    if (len > _CHUNK_SIZE)
4720      {
4721         sd->append_text_left = (char *)malloc(len + 1);
4722      }
4723
4724    /* If we decided to use the idler */
4725    if (sd->append_text_left)
4726      {
4727         /* Need to clear the entry first */
4728         edje_object_part_text_set(sd->entry_edje, "elm.text", "");
4729         memcpy(sd->append_text_left, entry, len);
4730         sd->append_text_left[len] = '\0';
4731         sd->append_text_position = 0;
4732         sd->append_text_len = len;
4733         sd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
4734      }
4735    else
4736      {
4737         edje_object_part_text_set(sd->entry_edje, "elm.text", entry);
4738         evas_object_smart_callback_call(obj, SIG_TEXT_SET_DONE, NULL);
4739      }
4740
4741    if (len > 0)
4742      _elm_entry_guide_update(obj, EINA_TRUE);
4743    else
4744      _elm_entry_guide_update(obj, EINA_FALSE);
4745
4746    // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
4747    _elm_entry_anchors_highlight_clear(obj);
4748    //
4749    evas_event_thaw(evas_object_evas_get(obj));
4750    evas_event_thaw_eval(evas_object_evas_get(obj));
4751
4752    return EINA_TRUE;
4753 }
4754
4755 static const char *
4756 _elm_entry_smart_text_get(const Evas_Object *obj,
4757                           const char *item)
4758 {
4759    const char *text;
4760
4761    ELM_ENTRY_DATA_GET(obj, sd);
4762
4763    if (item)
4764      {
4765         if (!strcmp(item, "default")) goto proceed;
4766         else if (!strcmp(item, "guide"))
4767           return edje_object_part_text_get(sd->entry_edje, "elm.guide");
4768         else
4769           return edje_object_part_text_get(sd->entry_edje, item);
4770      }
4771
4772 proceed:
4773
4774    text = edje_object_part_text_get(sd->entry_edje, "elm.text");
4775    if (!text)
4776      {
4777         ERR("text=NULL for edje %p, part 'elm.text'", sd->entry_edje);
4778
4779         return NULL;
4780      }
4781
4782    if (sd->append_text_len > 0)
4783      {
4784         char *tmpbuf;
4785         size_t len, tlen;
4786
4787         tlen = strlen(text);
4788         len = tlen +  sd->append_text_len - sd->append_text_position;
4789         tmpbuf = calloc(1, len + 1);
4790         if (!tmpbuf)
4791           {
4792              ERR("Failed to allocate memory for entry's text %p", obj);
4793              return NULL;
4794           }
4795         memcpy(tmpbuf, text, tlen);
4796
4797         if (sd->append_text_left)
4798           memcpy(tmpbuf + tlen, sd->append_text_left
4799                  + sd->append_text_position, sd->append_text_len
4800                  - sd->append_text_position);
4801         tmpbuf[len] = '\0';
4802         eina_stringshare_replace(&sd->text, tmpbuf);
4803         free(tmpbuf);
4804      }
4805    else
4806      {
4807         eina_stringshare_replace(&sd->text, text);
4808      }
4809
4810    // TIZEN ONLY
4811    if (sd->password)
4812      {
4813         char *pw_text;
4814         pw_text = elm_entry_markup_to_utf8(sd->text);
4815         if (pw_text)
4816           {
4817              eina_stringshare_replace(&sd->password_text, pw_text);
4818              free(pw_text);
4819              return sd->password_text;
4820           }
4821      }
4822    /////
4823
4824    return sd->text;
4825 }
4826
4827 // TIZEN_ONLY(131221) : Customize accessiblity for editfield
4828 /* Original Code */
4829 /*
4830 static char *
4831 _access_info_cb(void *data __UNUSED__, Evas_Object *obj)
4832 {
4833    const char *txt;
4834
4835    ELM_ENTRY_DATA_GET(obj, sd);
4836
4837    if ((sd->password && _elm_config->access_password_read_enable) ||
4838        (!sd->password))
4839      {
4840         txt = elm_widget_access_info_get(obj);
4841
4842         if (!txt) txt = _elm_util_mkup_to_text(elm_entry_entry_get(obj));
4843         if (txt && (strlen(txt) > 0)) return strdup(txt);
4844      }
4845
4846    // to take care guide text
4847    txt = edje_object_part_text_get(sd->entry_edje, "elm.guide");
4848    txt = _elm_util_mkup_to_text(txt);
4849    if (txt && (strlen(txt) > 0)) return strdup(txt);
4850
4851    return NULL;
4852 }
4853
4854 static char *
4855 _access_state_cb(void *data __UNUSED__, Evas_Object *obj)
4856 {
4857    Eina_Strbuf *buf;
4858    char *ret;
4859
4860    ELM_ENTRY_DATA_GET(obj, sd);
4861
4862    ret = NULL;
4863    buf = eina_strbuf_new();
4864
4865    if (elm_widget_disabled_get(obj))
4866      eina_strbuf_append(buf, E_("State: Disabled"));
4867
4868    if (!sd->editable)
4869      {
4870         if (!eina_strbuf_length_get(buf))
4871           eina_strbuf_append(buf, E_("State: Not Editable"));
4872         else eina_strbuf_append(buf, E_(", Not Editable"));
4873      }
4874
4875    if (!eina_strbuf_length_get(buf)) goto buf_free;
4876
4877    ret = eina_strbuf_string_steal(buf);
4878
4879 buf_free:
4880    eina_strbuf_free(buf);
4881    return ret;
4882 }
4883 */
4884 /////////////////////////////////
4885
4886 static void
4887 _entry_selection_callbacks_unregister(Evas_Object *obj)
4888 {
4889    ELM_ENTRY_DATA_GET(obj, sd);
4890
4891    edje_object_signal_callback_del_full
4892      (sd->entry_edje, "selection,start", "elm.text",
4893      _entry_selection_start_signal_cb, obj);
4894    edje_object_signal_callback_del_full
4895      (sd->entry_edje, "selection,changed", "elm.text",
4896      _entry_selection_changed_signal_cb, obj);
4897    edje_object_signal_callback_del_full
4898      (sd->entry_edje, "entry,selection,all,request",
4899      "elm.text", _entry_selection_all_signal_cb, obj);
4900    edje_object_signal_callback_del_full
4901      (sd->entry_edje, "entry,selection,none,request",
4902      "elm.text", _entry_selection_none_signal_cb, obj);
4903    edje_object_signal_callback_del_full
4904      (sd->entry_edje, "selection,cleared", "elm.text",
4905      _entry_selection_cleared_signal_cb, obj);
4906    edje_object_signal_callback_del_full
4907      (sd->entry_edje, "entry,paste,request,*", "elm.text",
4908      _entry_paste_request_signal_cb, obj);
4909    edje_object_signal_callback_del_full
4910      (sd->entry_edje, "entry,copy,notify", "elm.text",
4911      _entry_copy_notify_signal_cb, obj);
4912    edje_object_signal_callback_del_full
4913      (sd->entry_edje, "entry,cut,notify", "elm.text",
4914      _entry_cut_notify_signal_cb, obj);
4915 }
4916
4917 static void
4918 _entry_selection_callbacks_register(Evas_Object *obj)
4919 {
4920    ELM_ENTRY_DATA_GET(obj, sd);
4921
4922    edje_object_signal_callback_add
4923      (sd->entry_edje, "selection,start", "elm.text",
4924      _entry_selection_start_signal_cb, obj);
4925    edje_object_signal_callback_add
4926      (sd->entry_edje, "selection,changed", "elm.text",
4927      _entry_selection_changed_signal_cb, obj);
4928    edje_object_signal_callback_add
4929      (sd->entry_edje, "entry,selection,all,request",
4930      "elm.text", _entry_selection_all_signal_cb, obj);
4931    edje_object_signal_callback_add
4932      (sd->entry_edje, "entry,selection,none,request",
4933      "elm.text", _entry_selection_none_signal_cb, obj);
4934    edje_object_signal_callback_add
4935      (sd->entry_edje, "selection,cleared", "elm.text",
4936      _entry_selection_cleared_signal_cb, obj);
4937    edje_object_signal_callback_add
4938      (sd->entry_edje, "entry,paste,request,*", "elm.text",
4939      _entry_paste_request_signal_cb, obj);
4940    edje_object_signal_callback_add
4941      (sd->entry_edje, "entry,copy,notify", "elm.text",
4942      _entry_copy_notify_signal_cb, obj);
4943    edje_object_signal_callback_add
4944      (sd->entry_edje, "entry,cut,notify", "elm.text",
4945      _entry_cut_notify_signal_cb, obj);
4946 }
4947
4948 static void
4949 _resize_cb(void *data,
4950            Evas *e __UNUSED__,
4951            Evas_Object *obj __UNUSED__,
4952            void *event_info __UNUSED__)
4953 {
4954    ELM_ENTRY_DATA_GET(data, sd);
4955
4956    if (sd->line_wrap)
4957      {
4958         elm_layout_sizing_eval(data);
4959      }
4960    else if (sd->scroll)
4961      {
4962         Evas_Coord vw = 0, vh = 0;
4963
4964         sd->s_iface->content_viewport_size_get(data, &vw, &vh);
4965         if (vw < sd->ent_mw) vw = sd->ent_mw;
4966         if (vh < sd->ent_mh) vh = sd->ent_mh;
4967         evas_object_resize(sd->entry_edje, vw, vh);
4968      }
4969
4970    if (sd->hoversel) _hoversel_position(data);
4971
4972    // TIZEN ONLY
4973    if (!_elm_config->desktop_entry)
4974      {
4975         if (sd->region_get_job) ecore_job_del(sd->region_get_job);
4976         sd->region_get_job = ecore_job_add(_region_get_job, data);
4977
4978         if (sd->magnifier_showing)
4979           _magnifier_move(data);
4980      }
4981    //
4982 }
4983
4984 static void
4985 _elm_entry_smart_add(Evas_Object *obj)
4986 {
4987    EVAS_SMART_DATA_ALLOC(obj, Elm_Entry_Smart_Data);
4988
4989    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.add(obj);
4990 }
4991
4992 static void
4993 _elm_entry_smart_del(Evas_Object *obj)
4994 {
4995    Elm_Entry_Context_Menu_Item *it;
4996    Elm_Entry_Item_Provider *ip;
4997    Elm_Entry_Markup_Filter *tf;
4998    // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
4999    Elm_Entry_Anchor_Access_Provider *ap;
5000    //
5001
5002    ELM_ENTRY_DATA_GET(obj, sd);
5003
5004    if (sd->delay_write)
5005      {
5006         ecore_timer_del(sd->delay_write);
5007         sd->delay_write = NULL;
5008         if (sd->auto_save) _save_do(obj);
5009      }
5010
5011    // TIZEN ONLY(131106): Add rectangle for processing mouse up event on paddings inside of entry.
5012    if (sd->event_rect)
5013      {
5014         evas_object_del(sd->event_rect);
5015         sd->event_rect = NULL;
5016      }
5017    //
5018    if (sd->scroll)
5019      sd->s_iface->content_viewport_resize_cb_set(obj, NULL);
5020
5021    // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
5022    _elm_entry_anchors_highlight_clear(obj);
5023    //
5024
5025    elm_entry_anchor_hover_end(obj);
5026    elm_entry_anchor_hover_parent_set(obj, NULL);
5027
5028    evas_event_freeze(evas_object_evas_get(obj));
5029
5030    if (sd->file) eina_stringshare_del(sd->file);
5031
5032    if (sd->hov_deljob) ecore_job_del(sd->hov_deljob);
5033    if ((sd->api) && (sd->api->obj_unhook))
5034      sd->api->obj_unhook(obj);  // module - unhook
5035
5036    entries = eina_list_remove(entries, obj);
5037 #ifdef HAVE_ELEMENTARY_X
5038    if (sd->sel_notify_handler)
5039      ecore_event_handler_del(sd->sel_notify_handler);
5040    if (sd->sel_clear_handler)
5041      ecore_event_handler_del(sd->sel_clear_handler);
5042    if (sd->client_msg_handler)                        // TIZEN ONLY
5043      ecore_event_handler_del(sd->client_msg_handler); //
5044    if (sd->prop_hdl) ecore_event_handler_del(sd->prop_hdl); // TIZEN ONLY
5045 #endif
5046    if (sd->cut_sel) eina_stringshare_del(sd->cut_sel);
5047    if (sd->text) eina_stringshare_del(sd->text);
5048    if (sd->deferred_recalc_job)
5049      ecore_job_del(sd->deferred_recalc_job);
5050    if (sd->append_text_idler)
5051      {
5052         ecore_idler_del(sd->append_text_idler);
5053         free(sd->append_text_left);
5054         sd->append_text_left = NULL;
5055         sd->append_text_idler = NULL;
5056      }
5057    if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer);
5058    EINA_LIST_FREE (sd->items, it)
5059      {
5060         eina_stringshare_del(it->label);
5061         eina_stringshare_del(it->icon_file);
5062         eina_stringshare_del(it->icon_group);
5063         free(it);
5064      }
5065    EINA_LIST_FREE (sd->item_providers, ip)
5066      {
5067         free(ip);
5068      }
5069    EINA_LIST_FREE (sd->text_filters, tf)
5070      {
5071         _filter_free(tf);
5072      }
5073    EINA_LIST_FREE (sd->markup_filters, tf)
5074      {
5075         _filter_free(tf);
5076      }
5077    // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
5078    EINA_LIST_FREE (sd->anchor_access_providers, ap)
5079      {
5080         free(ap);
5081      }
5082    //
5083    if (sd->delay_write) ecore_timer_del(sd->delay_write);
5084    if (sd->input_panel_imdata) free(sd->input_panel_imdata);
5085
5086    if (sd->anchor_hover.hover_style)
5087      eina_stringshare_del(sd->anchor_hover.hover_style);
5088
5089    //TIZEN ONLY
5090    if (sd->password_text) eina_stringshare_del(sd->password_text);
5091    if (sd->region_get_job) ecore_job_del(sd->region_get_job);
5092    if (sd->region_recalc_job) ecore_job_del(sd->region_recalc_job);
5093    if (sd->mgf_proxy) evas_object_del(sd->mgf_proxy);
5094    if (sd->mgf_bg) evas_object_del(sd->mgf_bg);
5095    //
5096    evas_event_thaw(evas_object_evas_get(obj));
5097    evas_event_thaw_eval(evas_object_evas_get(obj));
5098
5099    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.del(obj);
5100 }
5101
5102 static void
5103 _elm_entry_smart_move(Evas_Object *obj,
5104                       Evas_Coord x,
5105                       Evas_Coord y)
5106 {
5107    ELM_ENTRY_DATA_GET(obj, sd);
5108
5109    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.move(obj, x, y);
5110
5111    evas_object_move(sd->hit_rect, x, y);
5112
5113    if (sd->hoversel) _hoversel_position(obj);
5114
5115    // TIZEN ONLY
5116    if (!_elm_config->desktop_entry)
5117      {
5118         if (sd->region_get_job) ecore_job_del(sd->region_get_job);
5119         sd->region_get_job = ecore_job_add(_region_get_job, obj);
5120      }
5121    //
5122 }
5123
5124 static void
5125 _elm_entry_smart_resize(Evas_Object *obj,
5126                         Evas_Coord w,
5127                         Evas_Coord h)
5128 {
5129    ELM_ENTRY_DATA_GET(obj, sd);
5130
5131    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.resize(obj, w, h);
5132
5133    evas_object_resize(sd->hit_rect, w, h);
5134 }
5135
5136 static void
5137 _elm_entry_smart_member_add(Evas_Object *obj,
5138                             Evas_Object *member)
5139 {
5140    ELM_ENTRY_DATA_GET(obj, sd);
5141
5142    ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.member_add(obj, member);
5143
5144    if (sd->hit_rect)
5145      evas_object_raise(sd->hit_rect);
5146 }
5147
5148 // TIZEN_ONLY(131221) : Customize accessiblity for editfield
5149 /* Original Code */
5150 /*
5151 static Eina_Bool
5152 _elm_entry_smart_activate(Evas_Object *obj, Elm_Activate act)
5153 {
5154    if (act != ELM_ACTIVATE_DEFAULT) return EINA_FALSE;
5155
5156    ELM_ENTRY_DATA_GET(obj, sd);
5157
5158    if (!elm_widget_disabled_get(obj) &&
5159        !evas_object_freeze_events_get(obj))
5160      {
5161         evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
5162         if (sd->editable && sd->input_panel_enable)
5163           edje_object_part_text_input_panel_show(sd->entry_edje, "elm.text");
5164      }
5165    return EINA_TRUE;
5166 }
5167 */
5168 ////////////////////
5169
5170 static void
5171 _elm_entry_smart_set_user(Elm_Entry_Smart_Class *sc)
5172 {
5173    ELM_WIDGET_CLASS(sc)->base.add = _elm_entry_smart_add;
5174    ELM_WIDGET_CLASS(sc)->base.del = _elm_entry_smart_del;
5175    ELM_WIDGET_CLASS(sc)->base.move = _elm_entry_smart_move;
5176    ELM_WIDGET_CLASS(sc)->base.resize = _elm_entry_smart_resize;
5177    ELM_WIDGET_CLASS(sc)->base.member_add = _elm_entry_smart_member_add;
5178
5179    ELM_WIDGET_CLASS(sc)->on_focus_region = _elm_entry_smart_on_focus_region;
5180    ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_entry_smart_sub_object_del;
5181    ELM_WIDGET_CLASS(sc)->on_focus = _elm_entry_smart_on_focus;
5182    ELM_WIDGET_CLASS(sc)->theme = _elm_entry_smart_theme;
5183    ELM_WIDGET_CLASS(sc)->disable = _elm_entry_smart_disable;
5184    ELM_WIDGET_CLASS(sc)->translate = _elm_entry_smart_translate;
5185    // TIZEN_ONLY(131221) : Customize accessiblity for editfield
5186    //ELM_WIDGET_CLASS(sc)->activate = _elm_entry_smart_activate;
5187    ELM_WIDGET_CLASS(sc)->activate = NULL;
5188    ELM_WIDGET_CLASS(sc)->access = _elm_entry_smart_access;
5189    //
5190
5191    /* not a 'focus chain manager' */
5192    // TIZEN_ONLY(131221) : Customize accessiblity for editfield
5193    //ELM_WIDGET_CLASS(sc)->focus_next = NULL;
5194    ELM_WIDGET_CLASS(sc)->focus_next = _elm_entry_smart_focus_next;
5195    //
5196    ELM_WIDGET_CLASS(sc)->focus_direction_manager_is = NULL;
5197    ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
5198
5199    ELM_CONTAINER_CLASS(sc)->content_set = _elm_entry_smart_content_set;
5200    ELM_CONTAINER_CLASS(sc)->content_unset = _elm_entry_smart_content_unset;
5201
5202    ELM_LAYOUT_CLASS(sc)->signal = _elm_entry_smart_signal;
5203    ELM_LAYOUT_CLASS(sc)->callback_add = _elm_entry_smart_callback_add;
5204    ELM_LAYOUT_CLASS(sc)->callback_del = _elm_entry_smart_callback_del;
5205    ELM_LAYOUT_CLASS(sc)->text_set = _elm_entry_smart_text_set;
5206    ELM_LAYOUT_CLASS(sc)->text_get = _elm_entry_smart_text_get;
5207    ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_entry_smart_sizing_eval;
5208    ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
5209 }
5210
5211 EAPI const Elm_Entry_Smart_Class *
5212 elm_entry_smart_class_get(void)
5213 {
5214    static Elm_Entry_Smart_Class _sc =
5215      ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION(ELM_ENTRY_SMART_NAME);
5216    static const Elm_Entry_Smart_Class *class = NULL;
5217    Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
5218
5219    if (class)
5220      return class;
5221
5222    _elm_entry_smart_set(&_sc);
5223    esc->callbacks = _smart_callbacks;
5224    class = &_sc;
5225
5226    return class;
5227 }
5228
5229 EAPI Evas_Object *
5230 elm_entry_add(Evas_Object *parent)
5231 {
5232    Evas_Object *obj;
5233
5234 #ifdef HAVE_ELEMENTARY_X
5235    Evas_Object *top;
5236 #endif
5237
5238    EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
5239
5240    obj = elm_widget_add(_elm_entry_smart_class_new(), parent);
5241    if (!obj) return NULL;
5242
5243    if (!elm_widget_sub_object_add(parent, obj))
5244      ERR("could not add %p as sub object of %p", obj, parent);
5245
5246    ELM_ENTRY_DATA_GET(obj, sd);
5247
5248    sd->entry_edje = ELM_WIDGET_DATA(sd)->resize_obj;
5249
5250    sd->cnp_mode = ELM_CNP_MODE_MARKUP;
5251    sd->line_wrap = ELM_WRAP_WORD;
5252    sd->context_menu = EINA_TRUE;
5253    sd->disabled = EINA_FALSE;
5254    sd->auto_save = EINA_TRUE;
5255    sd->editable = EINA_TRUE;
5256    sd->scroll = EINA_FALSE;
5257
5258    sd->input_panel_imdata = NULL;
5259    //TIZEN ONLY
5260    sd->magnifier_enabled = EINA_TRUE;
5261 #ifdef ELM_FEATURE_WEARABLE
5262    sd->drag_enabled = EINA_FALSE;
5263    sd->drop_enabled = EINA_FALSE;
5264 #else
5265    sd->drag_enabled = EINA_TRUE;
5266    sd->drop_enabled = EINA_TRUE;
5267 #endif
5268    sd->mouse_upped = EINA_FALSE;
5269    sd->append_text_idler = NULL;
5270    sd->append_text_left = NULL;
5271 #ifdef ELM_FEATURE_WEARABLE
5272    sd->sel_allow = EINA_FALSE;
5273 #else
5274    sd->sel_allow = EINA_TRUE;
5275 #endif
5276    sd->cursor_handler_disabled = EINA_FALSE;
5277    sd->scroll_holding = EINA_FALSE;
5278    //
5279    // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
5280    sd->anchor_highlight_rect = NULL;
5281    sd->anchor_highlight_pos = -1;
5282    //
5283    // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
5284    sd->anchor_access_providers = NULL;
5285    //
5286
5287 #ifdef HAVE_ELEMENTARY_X
5288    sd->drop_format = ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
5289    elm_drop_target_add(obj, sd->drop_format,
5290                        _dnd_enter_cb, obj,
5291                        _dnd_leave_cb, obj,
5292                        _dnd_pos_cb, obj,
5293                        _drag_drop_cb, NULL);
5294    sd->drop_added = EINA_TRUE;
5295 #endif
5296    elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj));
5297
5298    sd->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
5299    evas_object_data_set(sd->hit_rect, "_elm_leaveme", obj);
5300    //TODO: Need to check why clipping is not happening when adding hit_rect as smart member of obj
5301    //evas_object_smart_member_add(sd->hit_rect, obj);
5302    evas_object_smart_member_add(sd->hit_rect, sd->entry_edje);
5303    elm_widget_sub_object_add(obj, sd->hit_rect);
5304
5305    /* common scroller hit rectangle setup */
5306    evas_object_color_set(sd->hit_rect, 0, 0, 0, 0);
5307    evas_object_show(sd->hit_rect);
5308    evas_object_repeat_events_set(sd->hit_rect, EINA_TRUE);
5309
5310    sd->s_iface = evas_object_smart_interface_get
5311        (obj, ELM_SCROLLABLE_IFACE_NAME);
5312
5313    sd->s_iface->objects_set(obj, sd->entry_edje, sd->hit_rect);
5314
5315    edje_object_item_provider_set(sd->entry_edje, _item_get, obj);
5316
5317    edje_object_text_insert_filter_callback_add
5318      (sd->entry_edje, "elm.text", _text_filter_cb, obj);
5319    edje_object_text_markup_filter_callback_add
5320      (sd->entry_edje, "elm.text", _markup_filter_cb, obj);
5321
5322    evas_object_event_callback_add
5323      (sd->entry_edje, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
5324    evas_object_event_callback_add
5325      (sd->entry_edje, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
5326    evas_object_event_callback_add
5327      (sd->entry_edje, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, obj);
5328
5329    /* this code can't go in smart_resize. sizing gets wrong */
5330    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
5331
5332    // TIZEN_ONLY(20140625): Support accessibility for entry anchors.
5333    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_entry_hide_cb, obj);
5334    //
5335
5336    edje_object_signal_callback_add
5337      (sd->entry_edje, "entry,changed", "elm.text",
5338      _entry_changed_signal_cb, obj);
5339    edje_object_signal_callback_add
5340      (sd->entry_edje, "entry,changed,user", "elm.text",
5341      _entry_changed_user_signal_cb, obj);
5342    edje_object_signal_callback_add
5343      (sd->entry_edje, "preedit,changed", "elm.text",
5344      _entry_preedit_changed_signal_cb, obj);
5345
5346    _entry_selection_callbacks_register(obj);
5347
5348    edje_object_signal_callback_add
5349      (sd->entry_edje, "cursor,changed", "elm.text",
5350      _entry_cursor_changed_signal_cb, obj);
5351    edje_object_signal_callback_add
5352      (sd->entry_edje, "cursor,changed,manual", "elm.text",
5353      _entry_cursor_changed_manual_signal_cb, obj);
5354    edje_object_signal_callback_add
5355      (sd->entry_edje, "anchor,mouse,down,*", "elm.text",
5356      _entry_anchor_down_signal_cb, obj);
5357    edje_object_signal_callback_add
5358      (sd->entry_edje, "anchor,mouse,up,*", "elm.text",
5359      _entry_anchor_up_signal_cb, obj);
5360    edje_object_signal_callback_add
5361      (sd->entry_edje, "anchor,mouse,clicked,*", "elm.text",
5362      _entry_anchor_clicked_signal_cb, obj);
5363    edje_object_signal_callback_add
5364      (sd->entry_edje, "anchor,mouse,move,*", "elm.text",
5365      _entry_anchor_move_signal_cb, obj);
5366    edje_object_signal_callback_add
5367      (sd->entry_edje, "anchor,mouse,in,*", "elm.text",
5368      _entry_anchor_in_signal_cb, obj);
5369    edje_object_signal_callback_add
5370      (sd->entry_edje, "anchor,mouse,out,*", "elm.text",
5371      _entry_anchor_out_signal_cb, obj);
5372    edje_object_signal_callback_add
5373      (sd->entry_edje, "entry,key,enter", "elm.text",
5374      _entry_key_enter_signal_cb, obj);
5375    edje_object_signal_callback_add
5376      (sd->entry_edje, "entry,key,escape", "elm.text",
5377      _entry_key_escape_signal_cb, obj);
5378    edje_object_signal_callback_add
5379      (sd->entry_edje, "mouse,down,1", "elm.text",
5380      _entry_mouse_down_signal_cb, obj);
5381    edje_object_signal_callback_add
5382      (sd->entry_edje, "mouse,clicked,1", "elm.text",
5383      _entry_mouse_clicked_signal_cb, obj);
5384    edje_object_signal_callback_add
5385      (sd->entry_edje, "mouse,down,1,double", "elm.text",
5386      _entry_mouse_double_signal_cb, obj);
5387    edje_object_signal_callback_add
5388      (sd->entry_edje, "mouse,down,1,triple", "elm.text",
5389      _entry_mouse_triple_signal_cb, obj);
5390    edje_object_signal_callback_add
5391      (sd->entry_edje, "entry,undo,request", "elm.text",
5392      _entry_undo_request_signal_cb, obj);
5393    edje_object_signal_callback_add
5394      (sd->entry_edje, "entry,redo,request", "elm.text",
5395      _entry_redo_request_signal_cb, obj);
5396
5397    // TIZEN ONLY
5398    edje_object_signal_callback_add
5399       (sd->entry_edje, "handler,move,start", "elm.text",
5400        _signal_handler_move_start_cb, obj);
5401    edje_object_signal_callback_add
5402       (sd->entry_edje, "handler,move,end", "elm.text",
5403        _signal_handler_move_end_cb, obj);
5404    edje_object_signal_callback_add
5405       (sd->entry_edje, "handler,moving", "elm.text",
5406        _signal_handler_moving_cb, obj);
5407    edje_object_signal_callback_add
5408       (sd->entry_edje, "selection,end", "elm.text",
5409        _signal_selection_end, obj);
5410    edje_object_signal_callback_add
5411       (sd->entry_edje, "long,pressed", "elm.text",
5412        _signal_long_pressed, obj);
5413    edje_object_signal_callback_add
5414       (sd->entry_edje, "magnifier,changed", "elm.text",
5415        _signal_magnifier_changed, obj);
5416    edje_object_signal_callback_add
5417       (sd->entry_edje, "cursor,handler,move,start", "elm.text",
5418        _signal_handler_move_start_cb, obj);
5419    edje_object_signal_callback_add
5420       (sd->entry_edje, "cursor,handler,move,end", "elm.text",
5421        _signal_handler_move_end_cb, obj);
5422    edje_object_signal_callback_add
5423       (sd->entry_edje, "cursor,handler,moving", "elm.text",
5424        _signal_handler_moving_cb, obj);
5425    edje_object_signal_callback_add
5426       (sd->entry_edje, "cursor,handler,clicked", "elm.text",
5427        _signal_handler_click_cb, obj);
5428    evas_object_event_callback_add(sd->entry_edje, EVAS_CALLBACK_KEY_DOWN,
5429                                   _elm_entry_key_down_cb, obj);
5430    /////////
5431
5432    elm_layout_text_set(obj, "elm.text", "");
5433
5434    elm_object_sub_cursor_set
5435      (ELM_WIDGET_DATA(sd)->resize_obj, obj, ELM_CURSOR_XTERM);
5436    elm_widget_can_focus_set(obj, EINA_TRUE);
5437    if (_elm_config->desktop_entry)
5438      edje_object_part_text_select_allow_set
5439        (sd->entry_edje, "elm.text", EINA_TRUE);
5440    else
5441      {
5442         // TIZEN ONLY
5443         edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", EINA_FALSE);
5444         edje_object_part_text_viewport_region_set(sd->entry_edje, "elm.text", -1, -1, -1, -1);
5445         edje_object_part_text_layout_region_set(sd->entry_edje, "elm.text", -1, -1, -1, -1);
5446         ////////
5447      }
5448
5449    elm_layout_sizing_eval(obj);
5450
5451    elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
5452    elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
5453    elm_entry_prediction_allow_set(obj, EINA_TRUE);
5454    elm_entry_input_hint_set(obj, ELM_INPUT_HINT_AUTO_COMPLETE);
5455
5456    sd->autocapital_type = edje_object_part_text_autocapital_type_get
5457        (sd->entry_edje, "elm.text");
5458
5459 #ifdef HAVE_ELEMENTARY_X
5460    top = elm_widget_top_get(obj);
5461    if ((top) && (elm_win_xwindow_get(top)))
5462      {
5463         sd->sel_notify_handler =
5464           ecore_event_handler_add
5465             (ECORE_X_EVENT_SELECTION_NOTIFY, _event_selection_notify, obj);
5466         sd->sel_clear_handler =
5467           ecore_event_handler_add
5468             (ECORE_X_EVENT_SELECTION_CLEAR, _event_selection_clear, obj);
5469      }
5470
5471    sd->client_msg_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _xclient_msg_cb, obj);  // TIZEN ONLY
5472
5473    sd->prop_hdl = ecore_event_handler_add
5474       (ECORE_X_EVENT_WINDOW_PROPERTY, _on_prop_change, obj); // TIZEN ONLY
5475 #endif
5476
5477    entries = eina_list_prepend(entries, obj);
5478
5479 #ifndef ELM_FEATURE_WEARABLE
5480    // module - find module for entry
5481    sd->api = _module_find(obj);
5482    // if found - hook in
5483    if ((sd->api) && (sd->api->obj_hook)) sd->api->obj_hook(obj);
5484 #endif
5485
5486    _mirrored_set(obj, elm_widget_mirrored_get(obj));
5487
5488    // TIZEN_ONLY(131221): Customize accessiblity for editfield
5489    /* Original Code */
5490    /*
5491    // access
5492    _elm_access_object_register(obj, sd->entry_edje);
5493    _elm_access_text_set
5494      (_elm_access_object_get(obj), ELM_ACCESS_TYPE, E_("Edit Field")); // TIZEN ONLY
5495    _elm_access_callback_set
5496      (_elm_access_object_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
5497    _elm_access_callback_set
5498      (_elm_access_object_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL);
5499    */
5500    if (_elm_config->access_mode)
5501      _access_obj_process(obj, EINA_TRUE);
5502    //////////////////////////
5503
5504    //Tizen Only: This should be removed when eo is applied.
5505    ELM_WIDGET_DATA_GET(obj, wsd);
5506    wsd->on_create = EINA_FALSE;
5507
5508    return obj;
5509 }
5510
5511 EAPI void
5512 elm_entry_text_style_user_push(Evas_Object *obj,
5513                                const char *style)
5514 {
5515    ELM_ENTRY_CHECK(obj);
5516    ELM_ENTRY_DATA_GET(obj, sd);
5517
5518    edje_object_part_text_style_user_push(sd->entry_edje, "elm.text", style);
5519    _elm_entry_smart_theme(obj);
5520 }
5521
5522 EAPI void
5523 elm_entry_text_style_user_pop(Evas_Object *obj)
5524 {
5525    ELM_ENTRY_CHECK(obj);
5526    ELM_ENTRY_DATA_GET(obj, sd);
5527
5528    edje_object_part_text_style_user_pop(sd->entry_edje, "elm.text");
5529
5530    _elm_entry_smart_theme(obj);
5531 }
5532
5533 EAPI const char *
5534 elm_entry_text_style_user_peek(const Evas_Object *obj)
5535 {
5536    ELM_ENTRY_CHECK(obj) NULL;
5537    ELM_ENTRY_DATA_GET(obj, sd);
5538
5539    return edje_object_part_text_style_user_peek(sd->entry_edje, "elm.text");
5540 }
5541
5542 EAPI void
5543 elm_entry_single_line_set(Evas_Object *obj,
5544                           Eina_Bool single_line)
5545 {
5546    ELM_ENTRY_CHECK(obj);
5547    ELM_ENTRY_DATA_GET(obj, sd);
5548
5549    if (sd->single_line == single_line) return;
5550
5551    sd->single_line = single_line;
5552    sd->line_wrap = ELM_WRAP_NONE;
5553    if (elm_entry_cnp_mode_get(obj) == ELM_CNP_MODE_MARKUP)
5554      elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
5555    _elm_entry_smart_theme(obj);
5556
5557    if (sd->scroll)
5558      {
5559         if (sd->single_line)
5560           {
5561              sd->s_iface->policy_set
5562                 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
5563              //***************** TIZEN Only
5564              sd->s_iface->movement_block_set(obj, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL);
5565              //****************************
5566              // TIZEN ONLY
5567              sd->s_iface->bounce_allow_set(obj, EINA_FALSE, EINA_FALSE);
5568              ///
5569           }
5570         else
5571           {
5572              sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
5573              // TIZEN ONLY
5574              sd->s_iface->bounce_allow_set(obj, EINA_FALSE, EINA_FALSE);
5575              ///
5576           }
5577         elm_layout_sizing_eval(obj);
5578      }
5579 }
5580
5581 EAPI Eina_Bool
5582 elm_entry_single_line_get(const Evas_Object *obj)
5583 {
5584    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5585    ELM_ENTRY_DATA_GET(obj, sd);
5586
5587    return sd->single_line;
5588 }
5589
5590 EAPI void
5591 elm_entry_password_set(Evas_Object *obj,
5592                        Eina_Bool password)
5593 {
5594    ELM_ENTRY_CHECK(obj);
5595    ELM_ENTRY_DATA_GET(obj, sd);
5596
5597    password = !!password;
5598
5599    if (sd->password == password) return;
5600    sd->password = password;
5601
5602 #ifdef HAVE_ELEMENTARY_X
5603    elm_drop_target_del(obj, sd->drop_format,
5604                        _dnd_enter_cb, obj,
5605                        _dnd_leave_cb, obj,
5606                        _dnd_pos_cb, obj,
5607                        _drag_drop_cb, NULL);
5608    sd->drop_added = EINA_FALSE;
5609 #endif
5610    if (password)
5611      {
5612         sd->single_line = EINA_TRUE;
5613         sd->line_wrap = ELM_WRAP_NONE;
5614         elm_entry_input_hint_set(obj, ((sd->input_hints & ~ELM_INPUT_HINT_AUTO_COMPLETE) | ELM_INPUT_HINT_SENSITIVE_DATA));
5615         _entry_selection_callbacks_unregister(obj);
5616      }
5617    else
5618      {
5619 #ifdef HAVE_ELEMENTARY_X
5620         if (sd->drop_enabled)
5621           {
5622              sd->drop_format = _get_drop_format(obj);
5623              elm_drop_target_add(obj, sd->drop_format,
5624                                  _dnd_enter_cb, obj,
5625                                  _dnd_leave_cb, obj,
5626                                  _dnd_pos_cb, obj,
5627                                  _drag_drop_cb, NULL);
5628              sd->drop_added = EINA_TRUE;
5629           }
5630 #endif
5631         elm_entry_input_hint_set(obj, ((sd->input_hints | ELM_INPUT_HINT_AUTO_COMPLETE) & ~ELM_INPUT_HINT_SENSITIVE_DATA));
5632         _entry_selection_callbacks_register(obj);
5633      }
5634
5635    _elm_entry_smart_theme(obj);
5636 }
5637
5638 EAPI Eina_Bool
5639 elm_entry_password_get(const Evas_Object *obj)
5640 {
5641    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5642    ELM_ENTRY_DATA_GET(obj, sd);
5643
5644    return sd->password;
5645 }
5646
5647 EAPI void
5648 elm_entry_entry_set(Evas_Object *obj,
5649                     const char *entry)
5650 {
5651    ELM_ENTRY_CHECK(obj);
5652    _elm_entry_smart_text_set(obj, NULL, entry);
5653 }
5654
5655 EAPI const char *
5656 elm_entry_entry_get(const Evas_Object *obj)
5657 {
5658    ELM_ENTRY_CHECK(obj) NULL;
5659    return _elm_entry_smart_text_get(obj, NULL);
5660 }
5661
5662 EAPI void
5663 elm_entry_entry_append(Evas_Object *obj,
5664                        const char *entry)
5665 {
5666    int len = 0;
5667
5668    ELM_ENTRY_CHECK(obj);
5669    ELM_ENTRY_DATA_GET(obj, sd);
5670
5671    if (!entry) entry = "";
5672
5673    sd->changed = EINA_TRUE;
5674
5675    len = strlen(entry);
5676    if (sd->append_text_left)
5677      {
5678         char *tmpbuf;
5679
5680         tmpbuf = realloc(sd->append_text_left, sd->append_text_len + len + 1);
5681         if (!tmpbuf)
5682           {
5683              /* Do something */
5684              return;
5685           }
5686         sd->append_text_left = tmpbuf;
5687         memcpy(sd->append_text_left + sd->append_text_len, entry, len + 1);
5688         sd->append_text_len += len;
5689      }
5690    else
5691      {
5692         /* FIXME: Add chunked appending here (like in entry_set) */
5693         edje_object_part_text_append(sd->entry_edje, "elm.text", entry);
5694      }
5695 }
5696
5697 EAPI Eina_Bool
5698 elm_entry_is_empty(const Evas_Object *obj)
5699 {
5700    /* FIXME: until there's support for that in textblock, we just
5701     * check to see if the there is text or not. */
5702    const Evas_Object *tb;
5703    Evas_Textblock_Cursor *cur;
5704    Eina_Bool ret;
5705
5706    ELM_ENTRY_CHECK(obj) EINA_TRUE;
5707    ELM_ENTRY_DATA_GET(obj, sd);
5708
5709    /* It's a hack until we get the support suggested above.  We just
5710     * create a cursor, point it to the begining, and then try to
5711     * advance it, if it can advance, the tb is not empty, otherwise it
5712     * is. */
5713    tb = edje_object_part_object_get(sd->entry_edje, "elm.text");
5714
5715    /* This is actually, ok for the time being, these hackish stuff
5716       will be removed once evas 1.0 is out */
5717    cur = evas_object_textblock_cursor_new((Evas_Object *)tb);
5718    evas_textblock_cursor_pos_set(cur, 0);
5719    ret = evas_textblock_cursor_char_next(cur);
5720    evas_textblock_cursor_free(cur);
5721
5722    return !ret;
5723 #if 0  // TIZEN ONLY CODES : IF ABOVE CODES HAVE NO PROBLEM, THEN DELETE THESE CODES.
5724    char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
5725    if (!str) return EINA_TRUE;
5726
5727    ret = (strlen(str) == 0);
5728
5729    free(str);
5730    return ret;
5731 #endif
5732 }
5733
5734 EAPI Evas_Object *
5735 elm_entry_textblock_get(Evas_Object *obj)
5736 {
5737    ELM_ENTRY_CHECK(obj) NULL;
5738    ELM_ENTRY_DATA_GET(obj, sd);
5739
5740    return (Evas_Object *)edje_object_part_object_get
5741             (sd->entry_edje, "elm.text");
5742 }
5743
5744 EAPI void
5745 elm_entry_calc_force(Evas_Object *obj)
5746 {
5747    ELM_ENTRY_CHECK(obj);
5748    ELM_ENTRY_DATA_GET(obj, sd);
5749
5750    edje_object_calc_force(sd->entry_edje);
5751    sd->changed = EINA_TRUE;
5752    elm_layout_sizing_eval(obj);
5753 }
5754
5755 EAPI const char *
5756 elm_entry_selection_get(const Evas_Object *obj)
5757 {
5758    ELM_ENTRY_CHECK(obj) NULL;
5759    ELM_ENTRY_DATA_GET(obj, sd);
5760
5761    if ((sd->password)) return NULL;
5762    return edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
5763 }
5764
5765 EAPI void
5766 elm_entry_entry_insert(Evas_Object *obj,
5767                        const char *entry)
5768 {
5769    ELM_ENTRY_CHECK(obj);
5770    ELM_ENTRY_DATA_GET(obj, sd);
5771
5772    edje_object_part_text_insert(sd->entry_edje, "elm.text", entry);
5773    // TIZEN ONLY
5774 #ifdef HAVE_ELEMENTARY_X
5775    if (elm_widget_focus_get(obj))
5776       ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), NULL,0);
5777 #endif
5778    ///////////
5779    sd->changed = EINA_TRUE;
5780    elm_layout_sizing_eval(obj);
5781 }
5782
5783 EAPI void
5784 elm_entry_line_wrap_set(Evas_Object *obj,
5785                         Elm_Wrap_Type wrap)
5786 {
5787    ELM_ENTRY_CHECK(obj);
5788    ELM_ENTRY_DATA_GET(obj, sd);
5789
5790    if (sd->line_wrap == wrap) return;
5791    sd->last_w = -1;
5792    sd->line_wrap = wrap;
5793    _elm_entry_smart_theme(obj);
5794 }
5795
5796 EAPI Elm_Wrap_Type
5797 elm_entry_line_wrap_get(const Evas_Object *obj)
5798 {
5799    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5800    ELM_ENTRY_DATA_GET(obj, sd);
5801
5802    return sd->line_wrap;
5803 }
5804
5805 EAPI void
5806 elm_entry_editable_set(Evas_Object *obj,
5807                        Eina_Bool editable)
5808 {
5809    ELM_ENTRY_CHECK(obj);
5810    ELM_ENTRY_DATA_GET(obj, sd);
5811
5812    if (sd->editable == editable) return;
5813    sd->editable = editable;
5814    _elm_entry_smart_theme(obj);
5815
5816 #ifdef HAVE_ELEMENTARY_X
5817    elm_drop_target_del(obj, sd->drop_format,
5818                        _dnd_enter_cb, obj,
5819                        _dnd_leave_cb, obj,
5820                        _dnd_pos_cb, obj,
5821                        _drag_drop_cb, NULL);
5822    sd->drop_added = EINA_FALSE;
5823    if (editable)
5824      {
5825         if (sd->drop_enabled)
5826           {
5827              sd->drop_format = _get_drop_format(obj);
5828              elm_drop_target_add(obj, sd->drop_format,
5829                                  _dnd_enter_cb, obj,
5830                                  _dnd_leave_cb, obj,
5831                                  _dnd_pos_cb, obj,
5832                                  _drag_drop_cb, NULL);
5833              sd->drop_added = EINA_TRUE;
5834           }
5835      }
5836 #endif
5837 }
5838
5839 EAPI Eina_Bool
5840 elm_entry_editable_get(const Evas_Object *obj)
5841 {
5842    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5843    ELM_ENTRY_DATA_GET(obj, sd);
5844
5845    return sd->editable;
5846 }
5847
5848 EAPI void
5849 elm_entry_select_none(Evas_Object *obj)
5850 {
5851    ELM_ENTRY_CHECK(obj);
5852    ELM_ENTRY_DATA_GET(obj, sd);
5853
5854    if ((sd->password)) return;
5855    if (sd->sel_mode)
5856      {
5857         sd->sel_mode = EINA_FALSE;
5858         if (!_elm_config->desktop_entry)
5859           edje_object_part_text_select_allow_set
5860             (sd->entry_edje, "elm.text", EINA_FALSE);
5861         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
5862      }
5863    edje_object_part_text_select_none(sd->entry_edje, "elm.text");
5864 }
5865
5866 EAPI void
5867 elm_entry_select_all(Evas_Object *obj)
5868 {
5869    ELM_ENTRY_CHECK(obj);
5870    ELM_ENTRY_DATA_GET(obj, sd);
5871
5872    if ((sd->password)) return;
5873    if (sd->sel_mode)
5874      {
5875         sd->sel_mode = EINA_FALSE;
5876         if (!_elm_config->desktop_entry)
5877           edje_object_part_text_select_allow_set
5878             (sd->entry_edje, "elm.text", EINA_FALSE);
5879         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
5880      }
5881    edje_object_part_text_select_all(sd->entry_edje, "elm.text");
5882 }
5883
5884 EAPI Eina_Bool
5885 elm_entry_cursor_geometry_get(const Evas_Object *obj,
5886                               Evas_Coord *x,
5887                               Evas_Coord *y,
5888                               Evas_Coord *w,
5889                               Evas_Coord *h)
5890 {
5891    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5892    ELM_ENTRY_DATA_GET(obj, sd);
5893
5894    edje_object_part_text_cursor_geometry_get
5895      (sd->entry_edje, "elm.text", x, y, w, h);
5896    return EINA_TRUE;
5897 }
5898
5899 EAPI Eina_Bool
5900 elm_entry_cursor_next(Evas_Object *obj)
5901 {
5902    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5903    ELM_ENTRY_DATA_GET(obj, sd);
5904
5905    return edje_object_part_text_cursor_next
5906             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5907 }
5908
5909 EAPI Eina_Bool
5910 elm_entry_cursor_prev(Evas_Object *obj)
5911 {
5912    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5913    ELM_ENTRY_DATA_GET(obj, sd);
5914
5915    return edje_object_part_text_cursor_prev
5916             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5917 }
5918
5919 EAPI Eina_Bool
5920 elm_entry_cursor_up(Evas_Object *obj)
5921 {
5922    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5923    ELM_ENTRY_DATA_GET(obj, sd);
5924
5925    return edje_object_part_text_cursor_up
5926             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5927 }
5928
5929 EAPI Eina_Bool
5930 elm_entry_cursor_down(Evas_Object *obj)
5931 {
5932    ELM_ENTRY_CHECK(obj) EINA_FALSE;
5933    ELM_ENTRY_DATA_GET(obj, sd);
5934
5935    return edje_object_part_text_cursor_down
5936             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5937 }
5938
5939 EAPI void
5940 elm_entry_cursor_begin_set(Evas_Object *obj)
5941 {
5942    ELM_ENTRY_CHECK(obj);
5943    ELM_ENTRY_DATA_GET(obj, sd);
5944
5945    edje_object_part_text_cursor_begin_set
5946      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5947 }
5948
5949 EAPI void
5950 elm_entry_cursor_end_set(Evas_Object *obj)
5951 {
5952    ELM_ENTRY_CHECK(obj);
5953    ELM_ENTRY_DATA_GET(obj, sd);
5954
5955    edje_object_part_text_cursor_end_set
5956      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5957 }
5958
5959 EAPI void
5960 elm_entry_cursor_line_begin_set(Evas_Object *obj)
5961 {
5962    ELM_ENTRY_CHECK(obj);
5963    ELM_ENTRY_DATA_GET(obj, sd);
5964
5965    edje_object_part_text_cursor_line_begin_set
5966      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5967 }
5968
5969 EAPI void
5970 elm_entry_cursor_line_end_set(Evas_Object *obj)
5971 {
5972    ELM_ENTRY_CHECK(obj);
5973    ELM_ENTRY_DATA_GET(obj, sd);
5974
5975    edje_object_part_text_cursor_line_end_set
5976      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
5977 }
5978
5979 EAPI void
5980 elm_entry_cursor_selection_begin(Evas_Object *obj)
5981 {
5982    ELM_ENTRY_CHECK(obj);
5983    ELM_ENTRY_DATA_GET(obj, sd);
5984
5985    edje_object_part_text_select_begin(sd->entry_edje, "elm.text");
5986 }
5987
5988 EAPI void
5989 elm_entry_cursor_selection_end(Evas_Object *obj)
5990 {
5991    ELM_ENTRY_CHECK(obj);
5992    ELM_ENTRY_DATA_GET(obj, sd);
5993
5994    edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
5995 }
5996
5997 EAPI Eina_Bool
5998 elm_entry_cursor_is_format_get(const Evas_Object *obj)
5999 {
6000    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6001    ELM_ENTRY_DATA_GET(obj, sd);
6002
6003    return edje_object_part_text_cursor_is_format_get
6004             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
6005 }
6006
6007 EAPI Eina_Bool
6008 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
6009 {
6010    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6011    ELM_ENTRY_DATA_GET(obj, sd);
6012
6013    return edje_object_part_text_cursor_is_visible_format_get
6014             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
6015 }
6016
6017 EAPI char *
6018 elm_entry_cursor_content_get(const Evas_Object *obj)
6019 {
6020    ELM_ENTRY_CHECK(obj) NULL;
6021    ELM_ENTRY_DATA_GET(obj, sd);
6022
6023    return edje_object_part_text_cursor_content_get
6024             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
6025 }
6026
6027 EAPI void
6028 elm_entry_cursor_pos_set(Evas_Object *obj,
6029                          int pos)
6030 {
6031    ELM_ENTRY_CHECK(obj);
6032    ELM_ENTRY_DATA_GET(obj, sd);
6033
6034    edje_object_part_text_cursor_pos_set
6035      (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, pos);
6036    edje_object_message_signal_process(sd->entry_edje);
6037 }
6038
6039 EAPI int
6040 elm_entry_cursor_pos_get(const Evas_Object *obj)
6041 {
6042    ELM_ENTRY_CHECK(obj) 0;
6043    ELM_ENTRY_DATA_GET(obj, sd);
6044
6045    return edje_object_part_text_cursor_pos_get
6046             (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
6047 }
6048
6049 EAPI void
6050 elm_entry_selection_cut(Evas_Object *obj)
6051 {
6052    ELM_ENTRY_CHECK(obj);
6053    ELM_ENTRY_DATA_GET(obj, sd);
6054
6055    if ((sd->password)) return;
6056    _cut_cb(obj, NULL, NULL);
6057 }
6058
6059 EAPI void
6060 elm_entry_selection_copy(Evas_Object *obj)
6061 {
6062    ELM_ENTRY_CHECK(obj);
6063    ELM_ENTRY_DATA_GET(obj, sd);
6064
6065    if ((sd->password)) return;
6066    _copy_cb(obj, NULL, NULL);
6067 }
6068
6069 EAPI void
6070 elm_entry_selection_paste(Evas_Object *obj)
6071 {
6072    ELM_ENTRY_CHECK(obj);
6073    ELM_ENTRY_DATA_GET(obj, sd);
6074
6075    if ((sd->password)) return;
6076    _paste_cb(obj, NULL, NULL);
6077 }
6078
6079 EAPI void
6080 elm_entry_context_menu_clear(Evas_Object *obj)
6081 {
6082    Elm_Entry_Context_Menu_Item *it;
6083
6084    ELM_ENTRY_CHECK(obj);
6085    ELM_ENTRY_DATA_GET(obj, sd);
6086
6087    EINA_LIST_FREE (sd->items, it)
6088      {
6089         eina_stringshare_del(it->label);
6090         eina_stringshare_del(it->icon_file);
6091         eina_stringshare_del(it->icon_group);
6092         free(it);
6093      }
6094 }
6095
6096 EAPI void
6097 elm_entry_context_menu_item_add(Evas_Object *obj,
6098                                 const char *label,
6099                                 const char *icon_file,
6100                                 Elm_Icon_Type icon_type,
6101                                 Evas_Smart_Cb func,
6102                                 const void *data)
6103 {
6104    Elm_Entry_Context_Menu_Item *it;
6105
6106    ELM_ENTRY_CHECK(obj);
6107    ELM_ENTRY_DATA_GET(obj, sd);
6108
6109    it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
6110    if (!it) return;
6111
6112    sd->items = eina_list_append(sd->items, it);
6113    it->obj = obj;
6114    it->label = eina_stringshare_add(label);
6115    it->icon_file = eina_stringshare_add(icon_file);
6116    it->icon_type = icon_type;
6117    it->func = func;
6118    it->data = (void *)data;
6119 }
6120
6121 EAPI void
6122 elm_entry_context_menu_disabled_set(Evas_Object *obj,
6123                                     Eina_Bool disabled)
6124 {
6125    ELM_ENTRY_CHECK(obj);
6126    ELM_ENTRY_DATA_GET(obj, sd);
6127
6128    if (sd->context_menu == !disabled) return;
6129    sd->context_menu = !disabled;
6130 }
6131
6132 EAPI Eina_Bool
6133 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
6134 {
6135    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6136    ELM_ENTRY_DATA_GET(obj, sd);
6137
6138    return !sd->context_menu;
6139 }
6140
6141 // TIZEN ONLY - START
6142 EAPI void
6143 elm_entry_select_allow_set(Evas_Object *obj,
6144                            Eina_Bool allow)
6145 {
6146    ELM_ENTRY_CHECK(obj);
6147    ELM_ENTRY_DATA_GET(obj, sd);
6148
6149    if (sd->sel_allow == allow) return;
6150    sd->sel_allow = allow;
6151
6152    // TIZEN_ONLY(20130830): For cursor movement when mouse up.
6153    edje_object_part_text_select_disabled_set(sd->entry_edje, "elm.text", !allow);
6154    //
6155 }
6156
6157 EAPI Eina_Bool
6158 elm_entry_select_allow_get(const Evas_Object *obj)
6159 {
6160    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6161    ELM_ENTRY_DATA_GET(obj, sd);
6162
6163    return sd->sel_allow;
6164 }
6165
6166 EAPI void
6167 elm_entry_cursor_handler_disabled_set(Evas_Object *obj,
6168                                       Eina_Bool disabled)
6169 {
6170    ELM_ENTRY_CHECK(obj);
6171    ELM_ENTRY_DATA_GET(obj, sd);
6172
6173    if (sd->cursor_handler_disabled == disabled) return;
6174    sd->cursor_handler_disabled = disabled;
6175
6176    if (!_elm_config->desktop_entry)
6177      edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", disabled);
6178 }
6179
6180 EAPI Eina_Bool
6181 elm_entry_cursor_handler_disabled_get(const Evas_Object *obj)
6182 {
6183    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6184    ELM_ENTRY_DATA_GET(obj, sd);
6185    return sd->cursor_handler_disabled;
6186 }
6187 // TIZEN ONLY - END
6188
6189 EAPI void
6190 elm_entry_item_provider_append(Evas_Object *obj,
6191                                Elm_Entry_Item_Provider_Cb func,
6192                                void *data)
6193 {
6194    Elm_Entry_Item_Provider *ip;
6195
6196    ELM_ENTRY_CHECK(obj);
6197    ELM_ENTRY_DATA_GET(obj, sd);
6198    EINA_SAFETY_ON_NULL_RETURN(func);
6199
6200    ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
6201    if (!ip) return;
6202
6203    ip->func = func;
6204    ip->data = data;
6205    sd->item_providers = eina_list_append(sd->item_providers, ip);
6206 }
6207
6208 EAPI void
6209 elm_entry_item_provider_prepend(Evas_Object *obj,
6210                                 Elm_Entry_Item_Provider_Cb func,
6211                                 void *data)
6212 {
6213    Elm_Entry_Item_Provider *ip;
6214
6215    ELM_ENTRY_CHECK(obj);
6216    ELM_ENTRY_DATA_GET(obj, sd);
6217    EINA_SAFETY_ON_NULL_RETURN(func);
6218
6219    ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
6220    if (!ip) return;
6221
6222    ip->func = func;
6223    ip->data = data;
6224    sd->item_providers = eina_list_prepend(sd->item_providers, ip);
6225 }
6226
6227 EAPI void
6228 elm_entry_item_provider_remove(Evas_Object *obj,
6229                                Elm_Entry_Item_Provider_Cb func,
6230                                void *data)
6231 {
6232    Eina_List *l;
6233    Elm_Entry_Item_Provider *ip;
6234
6235    ELM_ENTRY_CHECK(obj);
6236    ELM_ENTRY_DATA_GET(obj, sd);
6237    EINA_SAFETY_ON_NULL_RETURN(func);
6238
6239    EINA_LIST_FOREACH(sd->item_providers, l, ip)
6240      {
6241         if ((ip->func == func) && ((!data) || (ip->data == data)))
6242           {
6243              sd->item_providers = eina_list_remove_list(sd->item_providers, l);
6244              free(ip);
6245              return;
6246           }
6247      }
6248 }
6249
6250 EAPI void
6251 elm_entry_markup_filter_append(Evas_Object *obj,
6252                                Elm_Entry_Filter_Cb func,
6253                                void *data)
6254 {
6255    Elm_Entry_Markup_Filter *tf;
6256
6257    ELM_ENTRY_CHECK(obj);
6258    ELM_ENTRY_DATA_GET(obj, sd);
6259    EINA_SAFETY_ON_NULL_RETURN(func);
6260
6261    tf = _filter_new(func, data);
6262    if (!tf) return;
6263
6264    sd->markup_filters = eina_list_append(sd->markup_filters, tf);
6265 }
6266
6267 EAPI void
6268 elm_entry_markup_filter_prepend(Evas_Object *obj,
6269                                 Elm_Entry_Filter_Cb func,
6270                                 void *data)
6271 {
6272    Elm_Entry_Markup_Filter *tf;
6273
6274    ELM_ENTRY_CHECK(obj);
6275    ELM_ENTRY_DATA_GET(obj, sd);
6276    EINA_SAFETY_ON_NULL_RETURN(func);
6277
6278    tf = _filter_new(func, data);
6279    if (!tf) return;
6280
6281    sd->markup_filters = eina_list_prepend(sd->markup_filters, tf);
6282 }
6283
6284 EAPI void
6285 elm_entry_markup_filter_remove(Evas_Object *obj,
6286                                Elm_Entry_Filter_Cb func,
6287                                void *data)
6288 {
6289    Eina_List *l;
6290    Elm_Entry_Markup_Filter *tf;
6291
6292    ELM_ENTRY_CHECK(obj);
6293    ELM_ENTRY_DATA_GET(obj, sd);
6294    EINA_SAFETY_ON_NULL_RETURN(func);
6295
6296    EINA_LIST_FOREACH(sd->markup_filters, l, tf)
6297      {
6298         if ((tf->func == func) && ((!data) || (tf->orig_data == data)))
6299           {
6300              sd->markup_filters = eina_list_remove_list(sd->markup_filters, l);
6301              _filter_free(tf);
6302              return;
6303           }
6304      }
6305 }
6306
6307 EAPI char *
6308 elm_entry_markup_to_utf8(const char *s)
6309 {
6310    char *ss = _elm_util_mkup_to_text(s);
6311    if (!ss) ss = strdup("");
6312    return ss;
6313 }
6314
6315 EAPI char *
6316 elm_entry_utf8_to_markup(const char *s)
6317 {
6318    char *ss = _elm_util_text_to_mkup(s);
6319    if (!ss) ss = strdup("");
6320    return ss;
6321 }
6322
6323 static const char *
6324 _text_get(const Evas_Object *obj)
6325 {
6326    return elm_object_text_get(obj);
6327 }
6328
6329 EAPI void
6330 elm_entry_filter_limit_size(void *data,
6331                             Evas_Object *entry,
6332                             char **text)
6333 {
6334    const char *(*text_get)(const Evas_Object *);
6335    Elm_Entry_Filter_Limit_Size *lim = data;
6336    char *current, *utfstr;
6337    int len, newlen;
6338
6339    EINA_SAFETY_ON_NULL_RETURN(data);
6340    EINA_SAFETY_ON_NULL_RETURN(entry);
6341    EINA_SAFETY_ON_NULL_RETURN(text);
6342
6343    /* hack. I don't want to copy the entire function to work with
6344     * scrolled_entry */
6345    text_get = _text_get;
6346
6347    current = elm_entry_markup_to_utf8(text_get(entry));
6348    utfstr = elm_entry_markup_to_utf8(*text);
6349
6350    if (lim->max_char_count > 0)
6351      {
6352         len = evas_string_char_len_get(current);
6353         newlen = evas_string_char_len_get(utfstr);
6354         if ((len >= lim->max_char_count) && (newlen > 0))
6355           {
6356              if (elm_object_focus_get(entry))
6357                evas_object_smart_callback_call(entry, SIG_MAX_LENGTH, NULL);
6358              free(*text);
6359              *text = NULL;
6360              free(current);
6361              free(utfstr);
6362              return;
6363           }
6364         if ((len + newlen) > lim->max_char_count)
6365           _chars_add_till_limit
6366             (entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
6367      }
6368    else if (lim->max_byte_count > 0)
6369      {
6370         len = strlen(current);
6371         newlen = strlen(utfstr);
6372         if ((len >= lim->max_byte_count) && (newlen > 0))
6373           {
6374              if (elm_object_focus_get(entry))
6375                evas_object_smart_callback_call(entry, SIG_MAX_LENGTH, NULL);
6376              free(*text);
6377              *text = NULL;
6378              free(current);
6379              free(utfstr);
6380              return;
6381           }
6382         if ((len + newlen) > lim->max_byte_count)
6383           _chars_add_till_limit
6384             (entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
6385      }
6386
6387    free(current);
6388    free(utfstr);
6389 }
6390
6391 EAPI void
6392 elm_entry_filter_accept_set(void *data,
6393                             Evas_Object *entry,
6394                             char **text)
6395 {
6396    int read_idx, last_read_idx = 0, read_char;
6397    Elm_Entry_Filter_Accept_Set *as = data;
6398    Eina_Bool goes_in;
6399    Eina_Bool rejected;
6400    const char *set;
6401    char *insert;
6402
6403    EINA_SAFETY_ON_NULL_RETURN(data);
6404    EINA_SAFETY_ON_NULL_RETURN(text);
6405
6406    if ((!as->accepted) && (!as->rejected))
6407      return;
6408
6409    if (as->accepted)
6410      {
6411         set = as->accepted;
6412         goes_in = EINA_TRUE;
6413      }
6414    else
6415      {
6416         set = as->rejected;
6417         goes_in = EINA_FALSE;
6418      }
6419
6420    insert = *text;
6421    read_idx = evas_string_char_next_get(*text, 0, &read_char);
6422    rejected = EINA_FALSE;
6423    while (read_char)
6424      {
6425         int cmp_idx, cmp_char;
6426         Eina_Bool in_set = EINA_FALSE;
6427
6428         if (read_char == '<')
6429           {
6430              while (read_char && (read_char != '>'))
6431                read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
6432
6433              if (goes_in) in_set = EINA_TRUE;
6434              else in_set = EINA_FALSE;
6435           }
6436         else
6437           {
6438              if (read_char == '&')
6439                {
6440                   while (read_char && (read_char != ';'))
6441                     read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
6442
6443                   if (!read_char)
6444                     {
6445                        if (goes_in) in_set = EINA_TRUE;
6446                        else in_set = EINA_FALSE;
6447                        goto inserting;
6448                     }
6449                   if (read_char == ';')
6450                     {
6451                        char *tag;
6452                        int utf8 = 0;
6453                        tag = malloc(read_idx - last_read_idx + 1);
6454                        if (tag)
6455                          {
6456                             char *markup;
6457                             strncpy(tag, (*text) + last_read_idx, read_idx - last_read_idx);
6458                             tag[read_idx - last_read_idx] = 0;
6459                             markup = elm_entry_markup_to_utf8(tag);
6460                             free(tag);
6461                             if (markup)
6462                               {
6463                                  utf8 = *markup;
6464                                  free(markup);
6465                               }
6466                             if (!utf8)
6467                               {
6468                                  in_set = EINA_FALSE;
6469                                  goto inserting;
6470                               }
6471                             read_char = utf8;
6472                          }
6473                     }
6474                }
6475
6476              cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
6477              while (cmp_char)
6478                {
6479                   if (read_char == cmp_char)
6480                     {
6481                        in_set = EINA_TRUE;
6482                        break;
6483                     }
6484                   cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
6485                }
6486           }
6487
6488 inserting:
6489
6490         if (in_set == goes_in)
6491           {
6492              int size = read_idx - last_read_idx;
6493              const char *src = (*text) + last_read_idx;
6494              if (src != insert)
6495                memcpy(insert, *text + last_read_idx, size);
6496              insert += size;
6497           }
6498         else
6499           {
6500              rejected = EINA_TRUE;
6501           }
6502
6503         if (read_char)
6504           {
6505              last_read_idx = read_idx;
6506              read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
6507           }
6508      }
6509    *insert = 0;
6510    if (rejected)
6511      evas_object_smart_callback_call(entry, SIG_REJECTED, NULL);
6512 }
6513
6514 EAPI Eina_Bool
6515 elm_entry_file_set(Evas_Object *obj,
6516                    const char *file,
6517                    Elm_Text_Format format)
6518 {
6519    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6520    ELM_ENTRY_DATA_GET(obj, sd);
6521
6522    if (sd->delay_write)
6523      {
6524         ecore_timer_del(sd->delay_write);
6525         sd->delay_write = NULL;
6526      }
6527
6528    if (sd->auto_save) _save_do(obj);
6529    eina_stringshare_replace(&sd->file, file);
6530    sd->format = format;
6531    return _load_do(obj);
6532 }
6533
6534 EAPI void
6535 elm_entry_file_get(const Evas_Object *obj,
6536                    const char **file,
6537                    Elm_Text_Format *format)
6538 {
6539    ELM_ENTRY_CHECK(obj);
6540    ELM_ENTRY_DATA_GET(obj, sd);
6541
6542    if (file) *file = sd->file;
6543    if (format) *format = sd->format;
6544 }
6545
6546 EAPI void
6547 elm_entry_file_save(Evas_Object *obj)
6548 {
6549    ELM_ENTRY_CHECK(obj);
6550    ELM_ENTRY_DATA_GET(obj, sd);
6551
6552    if (sd->delay_write)
6553      {
6554         ecore_timer_del(sd->delay_write);
6555         sd->delay_write = NULL;
6556      }
6557    _save_do(obj);
6558    sd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
6559 }
6560
6561 EAPI void
6562 elm_entry_autosave_set(Evas_Object *obj,
6563                        Eina_Bool auto_save)
6564 {
6565    ELM_ENTRY_CHECK(obj);
6566    ELM_ENTRY_DATA_GET(obj, sd);
6567
6568    sd->auto_save = !!auto_save;
6569 }
6570
6571 EAPI Eina_Bool
6572 elm_entry_autosave_get(const Evas_Object *obj)
6573 {
6574    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6575    ELM_ENTRY_DATA_GET(obj, sd);
6576
6577    return sd->auto_save;
6578 }
6579
6580 EINA_DEPRECATED EAPI void
6581 elm_entry_cnp_textonly_set(Evas_Object *obj,
6582                            Eina_Bool textonly)
6583 {
6584    Elm_Cnp_Mode cnp_mode = ELM_CNP_MODE_MARKUP;
6585
6586    ELM_ENTRY_CHECK(obj);
6587
6588    if (textonly)
6589      cnp_mode = ELM_CNP_MODE_NO_IMAGE;
6590    elm_entry_cnp_mode_set(obj, cnp_mode);
6591 }
6592
6593 EINA_DEPRECATED EAPI Eina_Bool
6594 elm_entry_cnp_textonly_get(const Evas_Object *obj)
6595 {
6596    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6597
6598    return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
6599 }
6600
6601 EAPI void
6602 elm_entry_cnp_mode_set(Evas_Object *obj,
6603                        Elm_Cnp_Mode cnp_mode)
6604 {
6605    Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
6606
6607    ELM_ENTRY_CHECK(obj);
6608    ELM_ENTRY_DATA_GET(obj, sd);
6609
6610    if (sd->cnp_mode == cnp_mode) return;
6611    sd->cnp_mode = cnp_mode;
6612    if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
6613      format = ELM_SEL_FORMAT_TEXT;
6614    else if (cnp_mode == ELM_CNP_MODE_MARKUP)
6615      format |= ELM_SEL_FORMAT_IMAGE;
6616 #ifdef HAVE_ELEMENTARY_X
6617    if (sd->drop_enabled)
6618      {
6619         elm_drop_target_del(obj, sd->drop_format,
6620                             _dnd_enter_cb, obj,
6621                             _dnd_leave_cb, obj,
6622                             _dnd_pos_cb, obj,
6623                             _drag_drop_cb, NULL);
6624         sd->drop_format = format;
6625         elm_drop_target_add(obj, format,
6626                             _dnd_enter_cb, obj,
6627                             _dnd_leave_cb, obj,
6628                             _dnd_pos_cb, obj,
6629                             _drag_drop_cb, NULL);
6630         sd->drop_added = EINA_TRUE;
6631      }
6632 #endif
6633 }
6634
6635 EAPI Elm_Cnp_Mode
6636 elm_entry_cnp_mode_get(const Evas_Object *obj)
6637 {
6638    ELM_ENTRY_CHECK(obj) ELM_CNP_MODE_MARKUP;
6639    ELM_ENTRY_DATA_GET(obj, sd);
6640
6641    return sd->cnp_mode;
6642 }
6643
6644 static void
6645 _elm_entry_content_viewport_resize_cb(Evas_Object *obj,
6646                                       Evas_Coord w __UNUSED__, Evas_Coord h __UNUSED__)
6647 {
6648    ELM_ENTRY_DATA_GET(obj, sd);
6649
6650    if (sd->line_wrap)
6651      {
6652         elm_layout_sizing_eval(obj);
6653      }
6654    else if (sd->scroll)
6655      {
6656         Evas_Coord vw = 0, vh = 0;
6657
6658         sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
6659         if (vw < sd->ent_mw) vw = sd->ent_mw;
6660         if (vh < sd->ent_mh) vh = sd->ent_mh;
6661         evas_object_resize(sd->entry_edje, vw, vh);
6662      }
6663
6664    if (sd->hoversel) _hoversel_position(obj);
6665
6666    // TIZEN ONLY
6667    if (!_elm_config->desktop_entry)
6668      {
6669         if (sd->region_get_job) ecore_job_del(sd->region_get_job);
6670         sd->region_get_job = ecore_job_add(_region_get_job, obj);
6671
6672         if (sd->magnifier_showing)
6673           _magnifier_move(obj);
6674      }
6675    //
6676 }
6677
6678 EAPI void
6679 elm_entry_scrollable_set(Evas_Object *obj,
6680                          Eina_Bool scroll)
6681 {
6682    ELM_ENTRY_CHECK(obj);
6683    ELM_ENTRY_DATA_GET(obj, sd);
6684
6685    scroll = !!scroll;
6686    if (sd->scroll == scroll) return;
6687    sd->scroll = scroll;
6688
6689    if (sd->scroll)
6690      {
6691         /* we now must re-theme ourselves to a scroller decoration
6692          * and move the entry looking object to be the content of the
6693          * scrollable view */
6694         elm_widget_resize_object_set(obj, NULL, EINA_TRUE);
6695         elm_widget_sub_object_add(obj, sd->entry_edje);
6696
6697         if (!sd->scr_edje)
6698           {
6699              sd->scr_edje = edje_object_add(evas_object_evas_get(obj));
6700
6701              elm_widget_theme_object_set
6702                (obj, sd->scr_edje, "scroller", "entry",
6703                elm_widget_style_get(obj));
6704
6705              evas_object_size_hint_weight_set
6706                (sd->scr_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
6707              evas_object_size_hint_align_set
6708                (sd->scr_edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
6709
6710              evas_object_propagate_events_set(sd->scr_edje, EINA_TRUE);
6711           }
6712
6713         elm_widget_resize_object_set(obj, sd->scr_edje, EINA_TRUE);
6714
6715         sd->s_iface->objects_set(obj, sd->scr_edje, sd->hit_rect);
6716
6717         sd->s_iface->bounce_allow_set(obj, sd->h_bounce, sd->v_bounce);
6718         if (sd->single_line)
6719           {
6720              sd->s_iface->policy_set
6721                 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
6722              //***************** TIZEN Only
6723              sd->s_iface->movement_block_set(obj, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL);
6724              //****************************
6725           }
6726         else
6727           sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
6728         sd->s_iface->content_set(obj, sd->entry_edje);
6729         sd->s_iface->content_viewport_resize_cb_set(obj, _elm_entry_content_viewport_resize_cb);
6730         elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
6731      }
6732    else
6733      {
6734         if (sd->scr_edje)
6735           {
6736              sd->s_iface->content_set(obj, NULL);
6737              evas_object_hide(sd->scr_edje);
6738           }
6739         elm_widget_resize_object_set(obj, sd->entry_edje, EINA_TRUE);
6740
6741         if (sd->scr_edje)
6742           elm_widget_sub_object_add(obj, sd->scr_edje);
6743
6744         sd->s_iface->objects_set(obj, sd->entry_edje, sd->hit_rect);
6745
6746         elm_widget_on_show_region_hook_set(obj, NULL, NULL);
6747      }
6748    sd->last_w = -1;
6749    _elm_entry_smart_theme(obj);
6750 }
6751
6752 EAPI Eina_Bool
6753 elm_entry_scrollable_get(const Evas_Object *obj)
6754 {
6755    ELM_ENTRY_CHECK(obj) EINA_FALSE;
6756    ELM_ENTRY_DATA_GET(obj, sd);
6757
6758    return sd->scroll;
6759 }
6760
6761 EAPI void
6762 elm_entry_icon_visible_set(Evas_Object *obj,
6763                            Eina_Bool setting)
6764 {
6765    ELM_ENTRY_CHECK(obj);
6766
6767    if (!elm_layout_content_get(obj, "elm.swallow.icon")) return;
6768
6769    if (setting)
6770      elm_layout_signal_emit(obj, "elm,action,show,icon", "elm");
6771    else
6772      elm_layout_signal_emit(obj, "elm,action,hide,icon", "elm");
6773
6774    elm_layout_sizing_eval(obj);
6775 }
6776
6777 EAPI void
6778 elm_entry_end_visible_set(Evas_Object *obj,
6779                           Eina_Bool setting)
6780 {
6781    ELM_ENTRY_CHECK(obj);
6782
6783    if (!elm_layout_content_get(obj, "elm.swallow.end")) return;
6784
6785    if (setting)
6786      elm_layout_signal_emit(obj, "elm,action,show,end", "elm");
6787    else
6788      elm_layout_signal_emit(obj, "elm,action,hide,end", "elm");
6789
6790    elm_layout_sizing_eval(obj);
6791 }
6792
6793 EAPI void
6794 elm_entry_scrollbar_policy_set(Evas_Object *obj,
6795                                Elm_Scroller_Policy h,
6796                                Elm_Scroller_Policy v)
6797 {
6798    ELM_ENTRY_CHECK(obj);
6799    ELM_ENTRY_DATA_GET(obj, sd);
6800
6801    sd->policy_h = h;
6802    sd->policy_v = v;
6803    sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
6804 }
6805
6806 EAPI void
6807 elm_entry_bounce_set(Evas_Object *obj,
6808                      Eina_Bool h_bounce,
6809                      Eina_Bool v_bounce)
6810 {
6811    ELM_ENTRY_CHECK(obj);
6812    ELM_ENTRY_DATA_GET(obj, sd);
6813
6814    sd->h_bounce = h_bounce;
6815    sd->v_bounce = v_bounce;
6816    sd->s_iface->bounce_allow_set(obj, h_bounce, v_bounce);
6817 }
6818
6819 EAPI void
6820 elm_entry_bounce_get(const Evas_Object *obj,
6821                      Eina_Bool *h_bounce,
6822                      Eina_Bool *v_bounce)
6823 {
6824    ELM_ENTRY_CHECK(obj);
6825    ELM_ENTRY_DATA_GET(obj, sd);
6826
6827    sd->s_iface->bounce_allow_get(obj, h_bounce, v_bounce);
6828 }
6829
6830 EAPI void
6831 elm_entry_input_panel_layout_set(Evas_Object *obj,
6832                                  Elm_Input_Panel_Layout layout)
6833 {
6834    ELM_ENTRY_CHECK(obj);
6835    ELM_ENTRY_DATA_GET(obj, sd);
6836
6837    sd->input_panel_layout = layout;
6838
6839    edje_object_part_text_input_panel_layout_set
6840      (sd->entry_edje, "elm.text", layout);
6841
6842    if (layout == ELM_INPUT_PANEL_LAYOUT_PASSWORD)
6843      elm_entry_input_hint_set(obj, ((sd->input_hints & ~ELM_INPUT_HINT_AUTO_COMPLETE) | ELM_INPUT_HINT_SENSITIVE_DATA));
6844    else if (layout == ELM_INPUT_PANEL_LAYOUT_TERMINAL)
6845      elm_entry_input_hint_set(obj, (sd->input_hints & ~ELM_INPUT_HINT_AUTO_COMPLETE));
6846 }
6847
6848 EAPI Elm_Input_Panel_Layout
6849 elm_entry_input_panel_layout_get(const Evas_Object *obj)
6850 {
6851    ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_LAYOUT_INVALID;
6852    ELM_ENTRY_DATA_GET(obj, sd);
6853
6854    return sd->input_panel_layout;
6855 }
6856
6857 EAPI void
6858 elm_entry_input_panel_layout_variation_set(Evas_Object *obj,
6859                                            int variation)
6860 {
6861    ELM_ENTRY_CHECK(obj);
6862    ELM_ENTRY_DATA_GET(obj, sd);
6863
6864    sd->input_panel_layout_variation = variation;
6865
6866    edje_object_part_text_input_panel_layout_variation_set
6867       (sd->entry_edje, "elm.text", variation);
6868 }
6869
6870 EAPI int
6871 elm_entry_input_panel_layout_variation_get(const Evas_Object *obj)
6872 {
6873    ELM_ENTRY_CHECK(obj) 0;
6874    ELM_ENTRY_DATA_GET(obj, sd);
6875
6876    return sd->input_panel_layout_variation;
6877 }
6878
6879 EAPI void
6880 elm_entry_autocapital_type_set(Evas_Object *obj,
6881                                Elm_Autocapital_Type autocapital_type)
6882 {
6883    ELM_ENTRY_CHECK(obj);
6884    ELM_ENTRY_DATA_GET(obj, sd);
6885
6886    sd->autocapital_type = autocapital_type;
6887    edje_object_part_text_autocapital_type_set
6888      (sd->entry_edje, "elm.text", autocapital_type);
6889 }
6890
6891 EAPI Elm_Autocapital_Type
6892 elm_entry_autocapital_type_get(const Evas_Object *obj)
6893 {
6894    ELM_ENTRY_CHECK(obj) ELM_AUTOCAPITAL_TYPE_NONE;
6895    ELM_ENTRY_DATA_GET(obj, sd);
6896
6897    return sd->autocapital_type;
6898 }
6899
6900 EAPI void
6901 elm_entry_prediction_allow_set(Evas_Object *obj,
6902                                Eina_Bool prediction)
6903 {
6904    ELM_ENTRY_CHECK(obj);
6905    ELM_ENTRY_DATA_GET(obj, sd);
6906
6907    sd->prediction_allow = prediction;
6908    edje_object_part_text_prediction_allow_set
6909      (sd->entry_edje, "elm.text", prediction);
6910 }
6911
6912 EAPI Eina_Bool
6913 elm_entry_prediction_allow_get(const Evas_Object *obj)
6914 {
6915    ELM_ENTRY_CHECK(obj) EINA_TRUE;
6916    ELM_ENTRY_DATA_GET(obj, sd);
6917
6918    return sd->prediction_allow;
6919 }
6920
6921 EAPI void
6922 elm_entry_input_hint_set(Evas_Object *obj,
6923                          Elm_Input_Hints hints)
6924 {
6925    ELM_ENTRY_CHECK(obj);
6926    ELM_ENTRY_DATA_GET(obj, sd);
6927
6928    sd->input_hints = hints;
6929    edje_object_part_text_input_hint_set
6930      (sd->entry_edje, "elm.text", hints);
6931 }
6932
6933 EAPI Elm_Input_Hints
6934 elm_entry_input_hint_get(const Evas_Object *obj)
6935 {
6936    ELM_ENTRY_CHECK(obj) EINA_TRUE;
6937    ELM_ENTRY_DATA_GET(obj, sd);
6938
6939    return sd->input_hints;
6940 }
6941
6942 EAPI void
6943 elm_entry_imf_context_reset(Evas_Object *obj)
6944 {
6945    ELM_ENTRY_CHECK(obj);
6946    ELM_ENTRY_DATA_GET(obj, sd);
6947
6948    edje_object_part_text_imf_context_reset(sd->entry_edje, "elm.text");
6949 }
6950
6951 EAPI void
6952 elm_entry_input_panel_enabled_set(Evas_Object *obj,
6953                                   Eina_Bool enabled)
6954 {
6955    ELM_ENTRY_CHECK(obj);
6956    ELM_ENTRY_DATA_GET(obj, sd);
6957
6958    sd->input_panel_enable = enabled;
6959    edje_object_part_text_input_panel_enabled_set
6960      (sd->entry_edje, "elm.text", enabled);
6961 }
6962
6963 EAPI Eina_Bool
6964 elm_entry_input_panel_enabled_get(const Evas_Object *obj)
6965 {
6966    ELM_ENTRY_CHECK(obj) EINA_TRUE;
6967    ELM_ENTRY_DATA_GET(obj, sd);
6968
6969    return sd->input_panel_enable;
6970 }
6971
6972 EAPI void
6973 elm_entry_input_panel_show(Evas_Object *obj)
6974 {
6975    ELM_ENTRY_CHECK(obj);
6976    ELM_ENTRY_DATA_GET(obj, sd);
6977
6978    edje_object_part_text_input_panel_show(sd->entry_edje, "elm.text");
6979 }
6980
6981 EAPI void
6982 elm_entry_input_panel_hide(Evas_Object *obj)
6983 {
6984    ELM_ENTRY_CHECK(obj);
6985    ELM_ENTRY_DATA_GET(obj, sd);
6986
6987    edje_object_part_text_input_panel_hide(sd->entry_edje, "elm.text");
6988 }
6989
6990 EAPI void
6991 elm_entry_input_panel_language_set(Evas_Object *obj,
6992                                    Elm_Input_Panel_Lang lang)
6993 {
6994    ELM_ENTRY_CHECK(obj);
6995    ELM_ENTRY_DATA_GET(obj, sd);
6996
6997    sd->input_panel_lang = lang;
6998    edje_object_part_text_input_panel_language_set
6999      (sd->entry_edje, "elm.text", lang);
7000 }
7001
7002 EAPI Elm_Input_Panel_Lang
7003 elm_entry_input_panel_language_get(const Evas_Object *obj)
7004 {
7005    ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_LANG_AUTOMATIC;
7006    ELM_ENTRY_DATA_GET(obj, sd);
7007
7008    return sd->input_panel_lang;
7009 }
7010
7011 EAPI void
7012 elm_entry_input_panel_imdata_set(Evas_Object *obj,
7013                                  const void *data,
7014                                  int len)
7015 {
7016    ELM_ENTRY_CHECK(obj);
7017    ELM_ENTRY_DATA_GET(obj, sd);
7018
7019    if (sd->input_panel_imdata)
7020      free(sd->input_panel_imdata);
7021
7022    sd->input_panel_imdata = calloc(1, len);
7023    sd->input_panel_imdata_len = len;
7024    memcpy(sd->input_panel_imdata, data, len);
7025
7026    edje_object_part_text_input_panel_imdata_set
7027      (sd->entry_edje, "elm.text", sd->input_panel_imdata,
7028      sd->input_panel_imdata_len);
7029 }
7030
7031 EAPI void
7032 elm_entry_input_panel_imdata_get(const Evas_Object *obj,
7033                                  void *data,
7034                                  int *len)
7035 {
7036    ELM_ENTRY_CHECK(obj);
7037    ELM_ENTRY_DATA_GET(obj, sd);
7038
7039    edje_object_part_text_input_panel_imdata_get
7040      (sd->entry_edje, "elm.text", data, len);
7041 }
7042
7043 EAPI void
7044 elm_entry_input_panel_return_key_type_set(Evas_Object *obj,
7045                                           Elm_Input_Panel_Return_Key_Type
7046                                           return_key_type)
7047 {
7048    ELM_ENTRY_CHECK(obj);
7049    ELM_ENTRY_DATA_GET(obj, sd);
7050
7051    sd->input_panel_return_key_type = return_key_type;
7052
7053    edje_object_part_text_input_panel_return_key_type_set
7054      (sd->entry_edje, "elm.text", return_key_type);
7055 }
7056
7057 EAPI Elm_Input_Panel_Return_Key_Type
7058 elm_entry_input_panel_return_key_type_get(const Evas_Object *obj)
7059 {
7060    ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
7061    ELM_ENTRY_DATA_GET(obj, sd);
7062
7063    return sd->input_panel_return_key_type;
7064 }
7065
7066 EAPI void
7067 elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj,
7068                                               Eina_Bool disabled)
7069 {
7070    ELM_ENTRY_CHECK(obj);
7071    ELM_ENTRY_DATA_GET(obj, sd);
7072
7073    sd->input_panel_return_key_disabled = disabled;
7074
7075    edje_object_part_text_input_panel_return_key_disabled_set
7076      (sd->entry_edje, "elm.text", disabled);
7077 }
7078
7079 EAPI Eina_Bool
7080 elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
7081 {
7082    ELM_ENTRY_CHECK(obj) EINA_FALSE;
7083    ELM_ENTRY_DATA_GET(obj, sd);
7084
7085    return sd->input_panel_return_key_disabled;
7086 }
7087
7088 EAPI void
7089 elm_entry_input_panel_return_key_autoenabled_set(Evas_Object *obj,
7090                                                  Eina_Bool enabled)
7091 {
7092    ELM_ENTRY_CHECK(obj);
7093    ELM_ENTRY_DATA_GET(obj, sd);
7094
7095    sd->auto_return_key = enabled;
7096    _return_key_enabled_check(obj);
7097 }
7098
7099 EAPI void
7100 elm_entry_input_panel_show_on_demand_set(Evas_Object *obj,
7101                                          Eina_Bool ondemand)
7102 {
7103    ELM_ENTRY_CHECK(obj);
7104    ELM_ENTRY_DATA_GET(obj, sd);
7105
7106    sd->input_panel_show_on_demand = ondemand;
7107
7108    edje_object_part_text_input_panel_show_on_demand_set
7109      (sd->entry_edje, "elm.text", ondemand);
7110 }
7111
7112 EAPI Eina_Bool
7113 elm_entry_input_panel_show_on_demand_get(const Evas_Object *obj)
7114 {
7115    ELM_ENTRY_CHECK(obj) EINA_FALSE;
7116    ELM_ENTRY_DATA_GET(obj, sd);
7117
7118    return sd->input_panel_show_on_demand;
7119 }
7120
7121 EAPI void *
7122 elm_entry_imf_context_get(Evas_Object *obj)
7123 {
7124    ELM_ENTRY_CHECK(obj) NULL;
7125    ELM_ENTRY_DATA_GET(obj, sd);
7126    if (!sd) return NULL;
7127
7128    return edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text");
7129 }
7130
7131 /* START - ANCHOR HOVER */
7132 static void
7133 _anchor_parent_del_cb(void *data,
7134                       Evas *e __UNUSED__,
7135                       Evas_Object *obj __UNUSED__,
7136                       void *event_info __UNUSED__)
7137 {
7138    ELM_ENTRY_DATA_GET(data, sd);
7139
7140    sd->anchor_hover.hover_parent = NULL;
7141 }
7142
7143 EAPI void
7144 elm_entry_anchor_hover_parent_set(Evas_Object *obj,
7145                                   Evas_Object *parent)
7146 {
7147    ELM_ENTRY_CHECK(obj);
7148    ELM_ENTRY_DATA_GET(obj, sd);
7149
7150    if (sd->anchor_hover.hover_parent)
7151      evas_object_event_callback_del_full
7152        (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
7153        _anchor_parent_del_cb, obj);
7154    sd->anchor_hover.hover_parent = parent;
7155    if (sd->anchor_hover.hover_parent)
7156      evas_object_event_callback_add
7157        (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
7158        _anchor_parent_del_cb, obj);
7159 }
7160
7161 EAPI Evas_Object *
7162 elm_entry_anchor_hover_parent_get(const Evas_Object *obj)
7163 {
7164    ELM_ENTRY_CHECK(obj) NULL;
7165    ELM_ENTRY_DATA_GET(obj, sd);
7166
7167    return sd->anchor_hover.hover_parent;
7168 }
7169
7170 EAPI void
7171 elm_entry_anchor_hover_style_set(Evas_Object *obj,
7172                                  const char *style)
7173 {
7174    ELM_ENTRY_CHECK(obj);
7175    ELM_ENTRY_DATA_GET(obj, sd);
7176
7177    eina_stringshare_replace(&sd->anchor_hover.hover_style, style);
7178 }
7179
7180 EAPI const char *
7181 elm_entry_anchor_hover_style_get(const Evas_Object *obj)
7182 {
7183    ELM_ENTRY_CHECK(obj) NULL;
7184    ELM_ENTRY_DATA_GET(obj, sd);
7185
7186    return sd->anchor_hover.hover_style;
7187 }
7188
7189 EAPI void
7190 elm_entry_anchor_hover_end(Evas_Object *obj)
7191 {
7192    ELM_ENTRY_CHECK(obj);
7193    ELM_ENTRY_DATA_GET(obj, sd);
7194
7195    if (sd->anchor_hover.hover) evas_object_del(sd->anchor_hover.hover);
7196    if (sd->anchor_hover.pop) evas_object_del(sd->anchor_hover.pop);
7197    sd->anchor_hover.hover = NULL;
7198    sd->anchor_hover.pop = NULL;
7199 }
7200
7201 /* END - ANCHOR HOVER */
7202
7203 ////////////// TIZEN ONLY APIs
7204 EAPI void
7205 elm_entry_magnifier_disabled_set(Evas_Object *obj, Eina_Bool disabled)
7206 {
7207    ELM_ENTRY_CHECK(obj);
7208    ELM_ENTRY_DATA_GET(obj, sd);
7209
7210    if (sd->magnifier_enabled == !disabled) return;
7211    sd->magnifier_enabled = !disabled;
7212 }
7213
7214 EAPI Eina_Bool
7215 elm_entry_magnifier_disabled_get(const Evas_Object *obj)
7216 {
7217    ELM_ENTRY_CHECK(obj) EINA_FALSE;
7218    ELM_ENTRY_DATA_GET(obj, sd);
7219
7220    return !sd->magnifier_enabled;
7221 }
7222 ////////////////////////////////
7223
7224 ////////////// REDWOOD ONLY APIs
7225 EAPI void
7226 elm_entry_drag_disabled_set(Evas_Object *obj, Eina_Bool disabled)
7227 {
7228    ELM_ENTRY_CHECK(obj);
7229    ELM_ENTRY_DATA_GET(obj, sd);
7230
7231    if (sd->drag_enabled == !disabled) return;
7232    sd->drag_enabled = !disabled;
7233 }
7234
7235 EAPI Eina_Bool
7236 elm_entry_drag_disabled_get(const Evas_Object *obj)
7237 {
7238    ELM_ENTRY_CHECK(obj) EINA_FALSE;
7239    ELM_ENTRY_DATA_GET(obj, sd);
7240
7241    return !sd->drag_enabled;
7242 }
7243
7244 EAPI void
7245 elm_entry_drop_disabled_set(Evas_Object *obj, Eina_Bool disabled)
7246 {
7247    ELM_ENTRY_CHECK(obj);
7248    ELM_ENTRY_DATA_GET(obj, sd);
7249
7250    if (sd->drop_enabled == !disabled) return;
7251    sd->drop_enabled = !disabled;
7252    elm_drop_target_del(obj, sd->drop_format,
7253                        _dnd_enter_cb, obj,
7254                        _dnd_leave_cb, obj,
7255                        _dnd_pos_cb, obj,
7256                        _drag_drop_cb, NULL);
7257    if (!disabled && sd->drop_added)
7258      {
7259         sd->drop_format = _get_drop_format(obj);
7260         elm_drop_target_add(obj, sd->drop_format,
7261                             _dnd_enter_cb, obj,
7262                             _dnd_leave_cb, obj,
7263                             _dnd_pos_cb, obj,
7264                             _drag_drop_cb, NULL);
7265      }
7266 }
7267
7268 EAPI Eina_Bool
7269 elm_entry_drop_disabled_get(Evas_Object *obj)
7270 {
7271    ELM_ENTRY_CHECK(obj) EINA_FALSE;
7272    ELM_ENTRY_DATA_GET(obj, sd);
7273
7274    return !sd->drop_enabled;
7275 }
7276 ////////////////////////////////
7277
7278 /////////////////////////////////////////////////////////////////////
7279 // TIZEN_ONLY(20140625): Add elm_entry_anchor_access_provider_* APIs.
7280 /////////////////////////////////////////////////////////////////////
7281 EAPI void
7282 elm_entry_anchor_access_provider_append(Evas_Object *obj,
7283                                         Elm_Entry_Anchor_Access_Provider_Cb func,
7284                                         void *data)
7285 {
7286    Elm_Entry_Anchor_Access_Provider *ap;
7287
7288    ELM_ENTRY_CHECK(obj);
7289    ELM_ENTRY_DATA_GET(obj, sd);
7290    EINA_SAFETY_ON_NULL_RETURN(func);
7291
7292    ap = calloc(1, sizeof(Elm_Entry_Anchor_Access_Provider));
7293    if (!ap) return;
7294
7295    ap->func = func;
7296    ap->data = data;
7297    sd->anchor_access_providers = eina_list_append(sd->anchor_access_providers, ap);
7298 }
7299
7300 EAPI void
7301 elm_entry_anchor_access_provider_prepend(Evas_Object *obj,
7302                                          Elm_Entry_Anchor_Access_Provider_Cb func,
7303                                          void *data)
7304 {
7305    Elm_Entry_Anchor_Access_Provider *ap;
7306
7307    ELM_ENTRY_CHECK(obj);
7308    ELM_ENTRY_DATA_GET(obj, sd);
7309    EINA_SAFETY_ON_NULL_RETURN(func);
7310
7311    ap = calloc(1, sizeof(Elm_Entry_Anchor_Access_Provider));
7312    if (!ap) return;
7313
7314    ap->func = func;
7315    ap->data = data;
7316    sd->anchor_access_providers = eina_list_prepend(sd->anchor_access_providers, ap);
7317 }
7318
7319 EAPI void
7320 elm_entry_anchor_access_provider_remove(Evas_Object *obj,
7321                                         Elm_Entry_Anchor_Access_Provider_Cb func,
7322                                         void *data)
7323 {
7324    Eina_List *l;
7325    Elm_Entry_Anchor_Access_Provider *ap;
7326
7327    ELM_ENTRY_CHECK(obj);
7328    ELM_ENTRY_DATA_GET(obj, sd);
7329    EINA_SAFETY_ON_NULL_RETURN(func);
7330
7331    EINA_LIST_FOREACH(sd->anchor_access_providers, l, ap)
7332      {
7333         if ((ap->func == func) && ((!data) || (ap->data == data)))
7334           {
7335              sd->anchor_access_providers = eina_list_remove_list(sd->anchor_access_providers, l);
7336              free(ap);
7337              return;
7338           }
7339      }
7340 }
7341
7342 EAPI void
7343 elm_entry_select_region_set(Evas_Object *obj, int start, int end)
7344 {
7345    ELM_ENTRY_CHECK(obj);
7346    ELM_ENTRY_DATA_GET(obj, sd);
7347
7348    if ((sd->password)) return;
7349    if (sd->sel_mode)
7350      {
7351         sd->sel_mode = EINA_FALSE;
7352         if (!_elm_config->desktop_entry)
7353           edje_object_part_text_select_allow_set
7354             (sd->entry_edje, "elm.text", EINA_FALSE);
7355         edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
7356      }
7357
7358    /* Set have selection false to not be cleared handler in
7359       selection_cleared_signal_cb() since that callback will be called while
7360       resetting edje text. */
7361    sd->have_selection = EINA_FALSE;
7362
7363    edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, start);
7364    edje_object_part_text_select_begin(sd->entry_edje, "elm.text");
7365    edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, end);
7366    edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
7367 }
7368
7369 /////////////////////////////////////////////////////////////////////