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