Autoscroll using conformant: By default it is enabled. To disable autoscroll changes...
[framework/uifw/elementary.git] / src / lib / elm_entry.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4 #include <Elementary.h>
5 #include "elm_priv.h"
6 #include "elm_module_priv.h"
7 /**
8  * @defgroup Entry Entry
9  * @ingroup Elementary
10  *
11  * An entry is a convenience widget which shows
12  * a box that the user can enter text into.  Unlike a
13  * @ref Scrolled_Entry widget, entries DO NOT scroll with user
14  * input.  Entry widgets are capable of expanding past the
15  * boundaries of the window, thus resizing the window to its
16  * own length.
17  * 
18  * You can also insert "items" in the entry with:
19  * 
20  * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
21  * 
22  * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
23  * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
24  * supports a list of emoticon names by default. These are:
25  * 
26  * - emoticon/angry
27  * - emoticon/angry-shout
28  * - emoticon/crazy-laugh
29  * - emoticon/evil-laugh
30  * - emoticon/evil
31  * - emoticon/goggle-smile
32  * - emoticon/grumpy
33  * - emoticon/grumpy-smile
34  * - emoticon/guilty
35  * - emoticon/guilty-smile
36  * - emoticon/haha
37  * - emoticon/half-smile
38  * - emoticon/happy-panting
39  * - emoticon/happy
40  * - emoticon/indifferent
41  * - emoticon/kiss
42  * - emoticon/knowing-grin
43  * - emoticon/laugh
44  * - emoticon/little-bit-sorry
45  * - emoticon/love-lots
46  * - emoticon/love
47  * - emoticon/minimal-smile
48  * - emoticon/not-happy
49  * - emoticon/not-impressed
50  * - emoticon/omg
51  * - emoticon/opensmile
52  * - emoticon/smile
53  * - emoticon/sorry
54  * - emoticon/squint-laugh
55  * - emoticon/surprised
56  * - emoticon/suspicious
57  * - emoticon/tongue-dangling
58  * - emoticon/tongue-poke
59  * - emoticon/uh
60  * - emoticon/unhappy
61  * - emoticon/very-sorry
62  * - emoticon/what
63  * - emoticon/wink
64  * - emoticon/worried
65  * - emoticon/wtf
66  *
67  * These are built-in currently, but you can add your own item provieer that
68  * can create inlined objects in the text and fill the space allocated to the
69  * item with a custom object of your own.
70  * 
71  * See the entry test for some more examples of use of this.
72  * 
73  * Signals that you can add callbacks for are:
74  * - "changed" - The text within the entry was changed
75  * - "activated" - The entry has received focus and the cursor
76  * - "press" - The entry has been clicked
77  * - "longpressed" - The entry has been clicked for a couple seconds
78  * - "clicked" - The entry has been clicked
79  * - "clicked,double" - The entry has been double clicked
80  * - "focused" - The entry has received focus
81  * - "unfocused" - The entry has lost focus
82  * - "selection,paste" - A paste action has occurred
83  * - "selection,copy" - A copy action has occurred
84  * - "selection,cut" - A cut action has occurred
85  * - "selection,start" - A selection has begun
86  * - "selection,changed" - The selection has changed
87  * - "selection,cleared" - The selection has been cleared
88  * - "cursor,changed" - The cursor has changed
89  * - "anchor,clicked" - The anchor has been clicked
90  */
91
92 typedef struct _Mod_Api Mod_Api;
93
94 typedef struct _Widget_Data Widget_Data;
95 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
96
97 struct _Widget_Data
98 {
99    Evas_Object *ent;
100    Evas_Object *popup;/*copy paste UI - elm_popup*/
101    Evas_Object *ctxpopup;/*copy paste UI - elm_ctxpopup*/
102    Evas_Object *bg;   
103    Evas_Object *hoversel;
104    Ecore_Job *deferred_recalc_job;
105    Ecore_Event_Handler *sel_notify_handler;
106    Ecore_Event_Handler *sel_clear_handler;
107    Ecore_Timer *longpress_timer;
108    /* Only for clipboard */
109    const char *cut_sel;
110    const char *text;
111    Evas_Coord wrap_w;
112    int ellipsis_threshold;
113    Evas_Coord lastw;
114    Evas_Coord downx, downy;
115    Evas_Coord cx, cy, cw, ch;
116    Eina_List *items;
117    Eina_List *item_providers;
118    Ecore_Job *hovdeljob;
119    Mod_Api *api; // module api if supplied
120    int max_no_of_bytes;
121    Eina_Bool changed : 1;
122    Eina_Bool linewrap : 1;
123    Eina_Bool char_linewrap : 1;
124    Eina_Bool single_line : 1;
125    Eina_Bool password : 1;
126    Eina_Bool show_last_character : 1;
127    Eina_Bool editable : 1;
128    Eina_Bool selection_asked : 1;
129    Eina_Bool have_selection : 1;
130    Eina_Bool selmode : 1;
131    Eina_Bool deferred_cur : 1;
132    Eina_Bool disabled : 1;
133    Eina_Bool context_menu : 1;
134    Eina_Bool drag_selection_asked : 1;
135    Eina_Bool bgcolor : 1;
136    Eina_Bool ellipsis : 1;
137    Eina_Bool autoreturnkey : 1;
138    Eina_Bool input_panel_enable : 1;
139    Eina_Bool autocapitalize : 1;
140    Elm_Input_Panel_Layout input_panel_layout;
141    Eina_Bool autoperiod : 1;
142 };
143
144 struct _Elm_Entry_Item_Provider
145 {
146    Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
147    void *data;
148 };
149
150 static const char *widtype = NULL;
151
152 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Drop_Data *);
153 static void _del_hook(Evas_Object *obj);
154 static void _theme_hook(Evas_Object *obj);
155 static void _disable_hook(Evas_Object *obj);
156 static void _sizing_eval(Evas_Object *obj);
157 static void _on_focus_hook(void *data, Evas_Object *obj);
158 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
159 static const char *_getbase(Evas_Object *obj);
160 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
161 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
162 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
163 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
164 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
165 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
166 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
167 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
168 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
169 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
170 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
171 static int _is_width_over(Evas_Object *obj);
172 static void _ellipsis_entry_to_width(Evas_Object *obj);
173 static void _reverse_ellipsis_entry(Evas_Object *obj);
174 static int _textinput_control_function(void *data,void *input_data);
175 static int _entry_length_get(Evas_Object *obj);
176
177 static const char SIG_CHANGED[] = "changed";
178 static const char SIG_ACTIVATED[] = "activated";
179 static const char SIG_PRESS[] = "press";
180 static const char SIG_LONGPRESSED[] = "longpressed";
181 static const char SIG_CLICKED[] = "clicked";
182 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
183 static const char SIG_FOCUSED[] = "focused";
184 static const char SIG_UNFOCUSED[] = "unfocused";
185 static const char SIG_SELECTION_PASTE[] = "selection,paste";
186 static const char SIG_SELECTION_COPY[] = "selection,copy";
187 static const char SIG_SELECTION_CUT[] = "selection,cut";
188 static const char SIG_SELECTION_START[] = "selection,start";
189 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
190 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
191 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
192 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
193 #ifdef HAVE_CONFORMANT_AUTOSCROLL
194 static const char SIG_IMPREGION_CHANGED[] = "impregion,changed";
195 #endif
196 static const Evas_Smart_Cb_Description _signals[] = {
197   {SIG_CHANGED, ""},
198   {SIG_ACTIVATED, ""},
199   {SIG_PRESS, ""},
200   {SIG_LONGPRESSED, ""},
201   {SIG_CLICKED, ""},
202   {SIG_CLICKED_DOUBLE, ""},
203   {SIG_FOCUSED, ""},
204   {SIG_UNFOCUSED, ""},
205   {SIG_SELECTION_PASTE, ""},
206   {SIG_SELECTION_COPY, ""},
207   {SIG_SELECTION_CUT, ""},
208   {SIG_SELECTION_START, ""},
209   {SIG_SELECTION_CHANGED, ""},
210   {SIG_SELECTION_CLEARED, ""},
211   {SIG_CURSOR_CHANGED, ""},
212   {SIG_ANCHOR_CLICKED, ""},
213   {NULL, NULL}
214 };
215
216 static Eina_List *entries = NULL;
217
218 struct _Mod_Api
219 {
220    void (*obj_hook) (Evas_Object *obj);
221    void (*obj_unhook) (Evas_Object *obj);
222    void (*obj_longpress) (Evas_Object *obj);
223    void (*obj_mouseup) (Evas_Object *obj);
224 };
225
226 static Mod_Api *
227 _module(Evas_Object *obj __UNUSED__)
228 {
229    static Elm_Module *m = NULL;
230    if (m) goto ok; // already found - just use
231    if (!(m = _elm_module_find_as("entry/api"))) return NULL;
232    // get module api
233    m->api = malloc(sizeof(Mod_Api));
234    if (!m->api) return NULL;
235    ((Mod_Api *)(m->api)      )->obj_hook = // called on creation
236      _elm_module_symbol_get(m, "obj_hook");
237    ((Mod_Api *)(m->api)      )->obj_unhook = // called on deletion
238      _elm_module_symbol_get(m, "obj_unhook");
239    ((Mod_Api *)(m->api)      )->obj_longpress = // called on long press menu
240      _elm_module_symbol_get(m, "obj_longpress");
241     ((Mod_Api *)(m->api)      )->obj_mouseup = // called on mouseup
242    _elm_module_symbol_get(m, "obj_mouseup");
243    ok: // ok - return api
244    return m->api;
245 }
246
247 static void
248 _del_hook(Evas_Object *obj)
249 {
250    Widget_Data *wd = elm_widget_data_get(obj);
251    Elm_Entry_Context_Menu_Item *it;
252    Elm_Entry_Item_Provider *ip;
253
254    if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
255    if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
256
257    entries = eina_list_remove(entries, obj);
258 #ifdef HAVE_ELEMENTARY_X
259    ecore_event_handler_del(wd->sel_notify_handler);
260    ecore_event_handler_del(wd->sel_clear_handler);
261 #endif
262    if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
263    if (wd->text) eina_stringshare_del(wd->text);
264    if (wd->bg) evas_object_del(wd->bg);
265    if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
266    if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
267    EINA_LIST_FREE(wd->items, it)
268      {
269         eina_stringshare_del(it->label);
270         eina_stringshare_del(it->icon_file);
271         eina_stringshare_del(it->icon_group);
272         free(it);
273      }
274    EINA_LIST_FREE(wd->item_providers, ip)
275      {
276         free(ip);
277      }
278    free(wd);
279 }
280
281 static void
282 _theme_hook(Evas_Object *obj)
283 {
284    Widget_Data *wd = elm_widget_data_get(obj);
285    const char *t;
286    Ecore_IMF_Context *ic;
287
288    t = eina_stringshare_add(elm_entry_entry_get(obj));
289    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
290    elm_entry_entry_set(obj, t);
291    eina_stringshare_del(t);
292    edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
293    edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
294    edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
295    edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
296
297    ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
298    if (ic)
299      {
300         ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
301      }
302
303    _sizing_eval(obj);
304 }
305
306 static void
307 _disable_hook(Evas_Object *obj)
308 {
309    Widget_Data *wd = elm_widget_data_get(obj);
310
311    if (elm_widget_disabled_get(obj))
312      {
313         edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
314         wd->disabled = EINA_TRUE;
315      }
316    else
317      {
318         edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
319         wd->disabled = EINA_FALSE;
320      }
321 }
322
323 static void
324 _elm_win_recalc_job(void *data)
325 {
326    Widget_Data *wd = elm_widget_data_get(data);
327    Evas_Coord minw = -1, minh = -1, maxh = -1;
328    Evas_Coord resw, resh, minminw;
329    if (!wd) return;
330    wd->deferred_recalc_job = NULL;
331    evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
332    resh = 0;
333    minminw = 0;
334    edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
335    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
336    minminw = minw;
337    edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
338    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
339    evas_object_size_hint_min_set(data, minminw, minh);
340    if (wd->single_line) maxh = minh;
341    evas_object_size_hint_max_set(data, -1, maxh);
342    if (wd->deferred_cur)
343      elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
344 }
345
346 static void
347 _sizing_eval(Evas_Object *obj)
348 {
349    Widget_Data *wd = elm_widget_data_get(obj);
350    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
351    Evas_Coord resw, resh;
352    if (!wd) return;
353    if (wd->linewrap || wd->char_linewrap)
354      {
355         evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
356         if ((resw == wd->lastw) && (!wd->changed)) return;
357         wd->changed = EINA_FALSE;
358         wd->lastw = resw;
359         if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
360         wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
361      }
362    else
363      {
364         evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
365         edje_object_size_min_calc(wd->ent, &minw, &minh);
366         elm_coords_finger_size_adjust(1, &minw, 1, &minh);
367         evas_object_size_hint_min_set(obj, minw, minh);
368         if (wd->single_line) maxh = minh;
369         evas_object_size_hint_max_set(obj, maxw, maxh);
370
371         if (wd->ellipsis && wd->single_line)
372           {
373             if (_is_width_over(obj))
374               _ellipsis_entry_to_width(obj);
375                         else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
376               _reverse_ellipsis_entry(obj);
377           }
378      }
379 }
380
381 static void
382 _check_enable_returnkey(Evas_Object *obj)
383 {
384     Widget_Data *wd = elm_widget_data_get(obj);
385     if (!wd) return;
386
387     Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
388     if (!ic) return;
389
390    if (!wd->autoreturnkey) return;
391
392    if (_entry_length_get(obj) == 0) 
393      {
394         ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
395      }
396    else 
397      {
398         ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
399      }
400 }
401
402 #ifdef HAVE_CONFORMANT_AUTOSCROLL
403 static Evas_Object *
404 _imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
405 {
406    Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
407    Widget_Data *wd = elm_widget_data_get(obj);
408    if (!wd) return NULL;
409    edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
410                                              &cx, &cy, &cw, &ch);
411    if (x) *x = cx;
412    if (y) *y = cy;
413    if (w) *w = cw;
414    if (h) *h = ch;
415    return NULL;
416 }
417 #endif
418
419 static void
420 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
421 {
422    Widget_Data *wd = elm_widget_data_get(obj);
423    Evas_Object *top = elm_widget_top_get(obj);
424    if (!wd) return;
425    if (!wd->editable) return;
426    if (elm_widget_focus_get(obj))
427      {
428         evas_object_focus_set(wd->ent, 1);
429         edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
430
431         if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
432         // start for cbhm
433         if (top) 
434         {
435                 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
436         }
437         // end for cbhm
438         evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
439         _check_enable_returnkey(obj);
440      }
441    else
442      {
443         edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
444         edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
445         evas_object_focus_set(wd->ent, 0);
446         if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
447         evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
448      }
449 }
450
451 static void
452 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
453 {
454    Widget_Data *wd = elm_widget_data_get(obj);
455    if (!wd) return;
456    edje_object_signal_emit(wd->ent, emission, source);
457 }
458
459 static void
460 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
461 {
462    Widget_Data *wd = elm_widget_data_get(obj);
463    if (!wd) return;
464    edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
465 }
466
467 static void *
468 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source))
469 {
470    Widget_Data *wd = elm_widget_data_get(obj);
471    if (!wd) return NULL;
472    return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
473 }
474
475 static void
476 _hoversel_position(Evas_Object *obj)
477 {
478    Widget_Data *wd = elm_widget_data_get(obj);
479    Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
480    if (!wd) return;
481    evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
482    edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
483                                              &cx, &cy, &cw, &ch);
484    evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
485    if (cw < mw)
486      {
487         cx += (cw - mw) / 2;
488         cw = mw;
489      }
490    if (ch < mh)
491      {
492         cy += (ch - mh) / 2;
493         ch = mh;
494      }
495    evas_object_move(wd->hoversel, x + cx, y + cy);
496    evas_object_resize(wd->hoversel, cw, ch);
497 }
498
499 static void
500 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
501 {
502    Widget_Data *wd = elm_widget_data_get(data);
503
504    if (wd->hoversel) _hoversel_position(data);
505 }
506
507 static void
508 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
509 {
510    Widget_Data *wd = elm_widget_data_get(data);
511    if (!wd) return;
512    if (wd->linewrap || wd->char_linewrap)
513      {
514         _sizing_eval(data);
515      }
516    if (wd->hoversel) _hoversel_position(data);
517 //   Evas_Coord ww, hh;
518 //   evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
519 }
520
521 static void
522 _hover_del(void *data)
523 {
524    Widget_Data *wd = elm_widget_data_get(data);
525    if (!wd) return;
526    
527    if (wd->hoversel)
528      {
529         evas_object_del(wd->hoversel);
530         wd->hoversel = NULL;
531      }
532    wd->hovdeljob = NULL;
533 }
534
535 static void
536 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
537 {
538    Widget_Data *wd = elm_widget_data_get(data);
539    if (!wd) return; 
540    if (wd->hoversel) evas_object_hide(wd->hoversel);
541    if (wd->selmode)
542      {
543         if (!wd->password)
544           edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
545      }
546    elm_widget_scroll_freeze_pop(data);
547    if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
548    wd->hovdeljob = ecore_job_add(_hover_del, data);
549 }
550
551 static void
552 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
553 {
554    Widget_Data *wd = elm_widget_data_get(data);
555    if (!wd) return;
556    wd->selmode = EINA_TRUE;
557    edje_object_part_text_select_none(wd->ent, "elm.text");
558    if (!wd->password)
559      edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
560    edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
561    elm_widget_scroll_hold_push(data);
562 }
563
564 static void
565 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
566 {
567    Widget_Data *wd = elm_widget_data_get(data);
568    if (!wd) return;
569    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
570    if (wd->sel_notify_handler)
571      {
572 #ifdef HAVE_ELEMENTARY_X
573         wd->selection_asked = EINA_TRUE;
574         elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data);
575 #endif
576      }
577 }
578
579 static void
580 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
581 {
582    Widget_Data *wd = elm_widget_data_get(obj);
583    const char *sel;
584
585    if (!wd) return;
586    sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
587    elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
588    if (seltype == ELM_SEL_CLIPBOARD)
589            eina_stringshare_replace(&wd->cut_sel, sel);
590 }
591
592 static void
593 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
594 {
595    Widget_Data *wd = elm_widget_data_get(data);
596
597    /* Store it */
598    wd->selmode = EINA_FALSE;
599    edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
600    edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
601    elm_widget_scroll_hold_pop(data);
602    _store_selection(ELM_SEL_CLIPBOARD, data);
603    edje_object_part_text_insert(wd->ent, "elm.text", "");
604    edje_object_part_text_select_none(wd->ent, "elm.text");
605 }
606
607 static void
608 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
609 {
610    Widget_Data *wd = elm_widget_data_get(data);
611    if (!wd) return;
612    wd->selmode = EINA_FALSE;
613    edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
614    edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
615    elm_widget_scroll_hold_pop(data);
616    _store_selection(ELM_SEL_CLIPBOARD, data);
617 //   edje_object_part_text_select_none(wd->ent, "elm.text");
618 }
619
620 static void
621 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
622 {
623    Widget_Data *wd = elm_widget_data_get(data);
624    if (!wd) return;
625    wd->selmode = EINA_FALSE;
626    edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
627    edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
628    elm_widget_scroll_hold_pop(data);
629    edje_object_part_text_select_none(wd->ent, "elm.text");
630 }
631
632 static void
633 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
634 {
635    Elm_Entry_Context_Menu_Item *it = data;
636    Evas_Object *obj2 = it->obj;
637
638         // start for cbhm
639         if (!strcmp(it->label, "Menu"))
640         {
641                 elm_cbhm_helper_init(obj);
642                 elm_cbhm_send_raw_data("show");
643         }
644         // end for cbhm
645
646    if (it->func) it->func(it->data, obj2, NULL);
647 }
648
649 static Eina_Bool
650 _long_press(void *data)
651 {
652    Widget_Data *wd = elm_widget_data_get(data);
653    Evas_Object *top;
654    const Eina_List *l;
655    const Elm_Entry_Context_Menu_Item *it;
656    if (!wd) return ECORE_CALLBACK_CANCEL;
657    if ((wd->api) && (wd->api->obj_longpress))
658      {
659         wd->api->obj_longpress(data);
660      }
661    else if (wd->context_menu)
662      {
663         const char *context_menu_orientation;
664
665         if (wd->hoversel) evas_object_del(wd->hoversel);
666         else elm_widget_scroll_freeze_push(data);
667         wd->hoversel = elm_hoversel_add(data);
668         context_menu_orientation = edje_object_data_get
669           (wd->ent, "context_menu_orientation");
670         if ((context_menu_orientation) &&
671             (!strcmp(context_menu_orientation, "horizontal")))
672           elm_hoversel_horizontal_set(wd->hoversel, 1);
673         elm_object_style_set(wd->hoversel, "entry");
674         elm_widget_sub_object_add(data, wd->hoversel);
675         elm_hoversel_label_set(wd->hoversel, "Text");
676         top = elm_widget_top_get(data);
677         if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
678         evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
679         if (!wd->selmode)
680           {
681              if (!wd->password)
682                elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
683                                      _select, data);
684              if (1) // need way to detect if someone has a selection
685                {
686                   if (wd->editable)
687                     elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
688                                           _paste, data);
689                }
690           }
691         else
692           {
693              if (!wd->password)
694                {
695                   if (wd->have_selection)
696                     {
697                        elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
698                                              _copy, data);
699                        if (wd->editable)
700                          elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
701                                                _cut, data);
702                     }
703                   elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
704                                         _cancel, data);
705                }
706           }
707         EINA_LIST_FOREACH(wd->items, l, it)
708           {
709              elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
710                                    it->icon_type, _item_clicked, it);
711           }
712         if (wd->hoversel)
713           {
714              _hoversel_position(data);
715              evas_object_show(wd->hoversel);
716              elm_hoversel_hover_begin(wd->hoversel);
717           }
718         edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
719         edje_object_part_text_select_abort(wd->ent, "elm.text");
720      }
721    wd->longpress_timer = NULL;
722    evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
723    return ECORE_CALLBACK_CANCEL;
724 }
725
726 static void
727 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
728 {
729    Widget_Data *wd = elm_widget_data_get(data);
730    Evas_Event_Mouse_Down *ev = event_info;
731    if (!wd) return;
732    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
733    if (ev->button != 1) return;
734    //   if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
735    if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
736    wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
737    wd->downx = ev->canvas.x;
738    wd->downy = ev->canvas.y;
739 }
740
741 static void
742 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
743 {
744    Widget_Data *wd = elm_widget_data_get(data);
745    Evas_Event_Mouse_Up *ev = event_info;
746    if (!wd) return;
747    if (ev->button != 1) return;
748    if ((wd->api) && (wd->api->obj_mouseup))
749      {
750         wd->api->obj_mouseup(data);
751      } 
752    if (wd->longpress_timer)
753      {
754         ecore_timer_del(wd->longpress_timer);
755         wd->longpress_timer = NULL;
756      }  
757 }
758
759 static void
760 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
761 {
762    Widget_Data *wd = elm_widget_data_get(data);
763    Evas_Event_Mouse_Move *ev = event_info;
764    if (!wd) return;
765    if (!wd->selmode)
766      {
767         if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
768           {
769              if (wd->longpress_timer)
770                {
771                   ecore_timer_del(wd->longpress_timer);
772                   wd->longpress_timer = NULL;
773                }
774           }
775         else if (wd->longpress_timer)
776           {
777              Evas_Coord dx, dy;
778
779              dx = wd->downx - ev->cur.canvas.x;
780              dx *= dx;
781              dy = wd->downy - ev->cur.canvas.y;
782              dy *= dy;
783              if ((dx + dy) >
784                  ((_elm_config->finger_size / 2) *
785                   (_elm_config->finger_size / 2)))
786                {
787                   ecore_timer_del(wd->longpress_timer);
788                   wd->longpress_timer = NULL;
789                }
790           }
791      }
792    else if (wd->longpress_timer)
793      {
794         Evas_Coord dx, dy;
795
796         dx = wd->downx - ev->cur.canvas.x;
797         dx *= dx;
798         dy = wd->downy - ev->cur.canvas.y;
799         dy *= dy;
800         if ((dx + dy) >
801             ((_elm_config->finger_size / 2) *
802              (_elm_config->finger_size / 2)))
803           {
804              ecore_timer_del(wd->longpress_timer);
805              wd->longpress_timer = NULL;
806           }
807      }
808 }
809
810 static const char *
811 _getbase(Evas_Object *obj)
812 {
813    Widget_Data *wd = elm_widget_data_get(obj);
814    if (!wd) return "base";
815    if (wd->editable)
816      {
817         if((wd->password)&&(wd->show_last_character)) return "custom-password"; 
818         else if(wd->password) return "base-password";
819         else
820           {
821              if (wd->single_line) return "base-single";
822              else
823                {
824                   if (wd->linewrap) return "base";
825                   else if (wd->char_linewrap) return "base-charwrap";
826                   else  return "base-nowrap";
827                }
828           }
829      }
830    else
831      {
832         if((wd->password)&&(wd->show_last_character)) return "custom-password"; 
833         else if(wd->password) return "base-password";
834         else
835           {
836              if (wd->single_line) return "base-single-noedit";
837              else
838                {
839                   if (wd->linewrap) return "base-noedit";
840                   else if (wd->char_linewrap) return "base-noedit-charwrap";
841                   else  return "base-nowrap-noedit";
842                }
843           }
844      }
845    return "base";
846 }
847
848 static char *
849 _str_append(char *str, const char *txt, int *len, int *alloc)
850 {
851    int txt_len = strlen(txt);
852
853    if (txt_len <= 0) return str;
854    if ((*len + txt_len) >= *alloc)
855      {
856         char *str2;
857         int alloc2;
858
859         alloc2 = *alloc + txt_len + 128;
860         str2 = realloc(str, alloc2);
861         if (!str2) return str;
862         *alloc = alloc2;
863         str = str2;
864      }
865    strcpy(str + *len, txt);
866    *len += txt_len;
867    return str;
868 }
869
870 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
871  * because some markups can be implemented otherwise according to style.
872  * probably doing it in textblock and making it translate according to it's
873  * style is correct. */
874 static char *
875 _strncpy(char* dest, const char* src, size_t count)
876 {
877    if (!dest) 
878      {
879         ERR( "dest is NULL" );
880         return NULL;
881      }
882    if (!src) 
883      {
884         ERR( "src is NULL" );
885         return NULL;
886      }
887    if (count < 0)
888      {
889         ERR( "count is smaller than 0" );
890         return NULL;
891      }
892
893    return strncpy( dest, src, count );
894 }
895
896 static char *
897 _mkup_to_text(const char *mkup)
898 {
899    char *str = NULL;
900    int str_len = 0, str_alloc = 0;
901    char *s, *p;
902    char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
903
904    if (!mkup) return NULL;
905    s=p=NULL;
906    tag_start = tag_end = esc_start = esc_end = NULL;
907    p = (char *)mkup;
908    s = p;
909    for (;;)
910      {
911         if (((p!=NULL)&&(*p == 0)) ||
912             (tag_end) || (esc_end) ||
913             (tag_start) || (esc_start))
914           {
915              if (tag_end)
916                {
917                   char *ttag;
918
919                   ttag = malloc(tag_end - tag_start);
920                   if (ttag)
921                     {
922                        _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
923                        ttag[tag_end - tag_start - 1] = 0;
924                        if (!strcmp(ttag, "br"))
925                          str = _str_append(str, "\n", &str_len, &str_alloc);
926                        else if (!strcmp(ttag, "\n"))
927                          str = _str_append(str, "\n", &str_len, &str_alloc);
928                        else if (!strcmp(ttag, "\\n"))
929                          str = _str_append(str, "\n", &str_len, &str_alloc);
930                        else if (!strcmp(ttag, "\t"))
931                          str = _str_append(str, "\t", &str_len, &str_alloc);
932                        else if (!strcmp(ttag, "\\t"))
933                          str = _str_append(str, "\t", &str_len, &str_alloc);
934                        else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
935                          str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
936                        free(ttag);
937                     }
938                   tag_start = tag_end = NULL;
939                }
940              else if (esc_end)
941                {
942                   ts = malloc(esc_end - esc_start + 1);
943                   if (ts)
944                     {
945                        const char *esc;
946                        _strncpy(ts, esc_start, esc_end - esc_start);
947                        ts[esc_end - esc_start] = 0;
948                        esc = evas_textblock_escape_string_get(ts);
949                        if (esc)
950                          str = _str_append(str, esc, &str_len, &str_alloc);
951                        free(ts);
952                     }
953                   esc_start = esc_end = NULL;
954                }
955              else if ((p!=NULL)&&(*p == 0))
956                {
957                   ts = malloc(p - s + 1);
958                   if (ts)
959                     {
960                        _strncpy(ts, s, p - s);
961                        ts[p - s] = 0;
962                        str = _str_append(str, ts, &str_len, &str_alloc);
963                        free(ts);
964                     }
965                   break;
966                }
967           }
968         if ((p!=NULL)&&(*p == '<'))
969           {
970              if (!esc_start)
971                {
972                   tag_start = p;
973                   tag_end = NULL;
974                   ts = malloc(p - s + 1);
975                   if (ts)
976                     {
977                        _strncpy(ts, s, p - s);
978                        ts[p - s] = 0;
979                        str = _str_append(str, ts, &str_len, &str_alloc);
980                        free(ts);
981                     }
982                   s = NULL;
983                }
984           }
985         else if ((p!=NULL)&&(*p == '>'))
986           {
987              if (tag_start)
988                {
989                   tag_end = p;
990                   s = p + 1;
991                }
992           }
993         else if ((p!=NULL)&&(*p == '&'))
994           {
995              if (!tag_start)
996                {
997                   esc_start = p;
998                   esc_end = NULL;
999                   ts = malloc(p - s + 1);
1000                   if (ts)
1001                     {
1002                        _strncpy(ts, s, p - s);
1003                        ts[p - s] = 0;
1004                        str = _str_append(str, ts, &str_len, &str_alloc);
1005                        free(ts);
1006                     }
1007                   s = NULL;
1008                }
1009           }
1010         else if ((p!=NULL)&&(*p == ';'))
1011           {
1012              if (esc_start)
1013                {
1014                   esc_end = p;
1015                   s = p + 1;
1016                }
1017           }
1018         p++;
1019      }
1020    return str;
1021 }
1022
1023 static int
1024 _entry_length_get(Evas_Object *obj)
1025 {
1026    int len;
1027    const char *str = elm_entry_entry_get(obj);
1028    if (!str) return 0;
1029
1030    char *plain_str = _mkup_to_text(str);
1031    if (!plain_str) return 0;
1032
1033    len = strlen(plain_str);
1034    free(plain_str);
1035
1036    return len;
1037 }
1038
1039 static char *
1040 _text_to_mkup(const char *text)
1041 {
1042    char *str = NULL;
1043    int str_len = 0, str_alloc = 0;
1044    int ch, pos = 0, pos2 = 0;
1045
1046    if (!text) return NULL;
1047    for (;;)
1048      {
1049         pos = pos2;
1050         pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1051         if ((ch <= 0) || (pos2 <= 0)) break;
1052         if (ch == '\n')
1053           str = _str_append(str, "<br>", &str_len, &str_alloc);
1054         else if (ch == '\t')
1055           str = _str_append(str, "<\t>", &str_len, &str_alloc);
1056         else if (ch == '<')
1057           str = _str_append(str, "&lt;", &str_len, &str_alloc);
1058         else if (ch == '>')
1059           str = _str_append(str, "&gt;", &str_len, &str_alloc);
1060         else if (ch == '&')
1061           str = _str_append(str, "&amp;", &str_len, &str_alloc);
1062         else
1063           {
1064              char tstr[16];
1065
1066              _strncpy(tstr, text + pos, pos2 - pos);
1067              tstr[pos2 - pos] = 0;
1068              str = _str_append(str, tstr, &str_len, &str_alloc);
1069           }
1070      }
1071    return str;
1072 }
1073
1074 static void
1075 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1076 {
1077    Widget_Data *wd = elm_widget_data_get(data);
1078    if (!wd) return;
1079    wd->changed = EINA_TRUE;
1080    _sizing_eval(data);
1081    if (wd->text) eina_stringshare_del(wd->text);
1082    wd->text = NULL;
1083    _check_enable_returnkey(data);   
1084    evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1085 }
1086
1087 static void
1088 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1089 {
1090    Widget_Data *wd = elm_widget_data_get(data);
1091    const Eina_List *l;
1092    Evas_Object *entry;
1093    if (!wd) return;
1094    EINA_LIST_FOREACH(entries, l, entry)
1095      {
1096         if (entry != data) elm_entry_select_none(entry);
1097      }
1098    wd->have_selection = EINA_TRUE;
1099    evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1100 #ifdef HAVE_ELEMENTARY_X
1101    if (wd->sel_notify_handler)
1102      {
1103         const char *txt = elm_entry_selection_get(data);
1104         Evas_Object *top;
1105
1106         top = elm_widget_top_get(data);
1107         if ((top) && (elm_win_xwindow_get(top)))
1108              elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1109      }
1110 #endif
1111 }
1112
1113 static void
1114 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1115 {
1116    Widget_Data *wd = elm_widget_data_get(data);
1117    if (!wd) return;
1118    wd->have_selection = EINA_TRUE;
1119    evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1120    elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1121                    elm_entry_selection_get(data));
1122 }
1123
1124 static void
1125 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1126 {
1127    Widget_Data *wd = elm_widget_data_get(data);
1128    if (!wd) return;
1129    if (!wd->have_selection) return;
1130    wd->have_selection = EINA_FALSE;
1131    evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1132    if (wd->sel_notify_handler)
1133      {
1134         if (wd->cut_sel)
1135           {
1136 #ifdef HAVE_ELEMENTARY_X
1137              Evas_Object *top;
1138
1139              top = elm_widget_top_get(data);
1140              if ((top) && (elm_win_xwindow_get(top)))
1141                  elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1142                                        wd->cut_sel);
1143 #endif
1144              eina_stringshare_del(wd->cut_sel);
1145              wd->cut_sel = NULL;
1146           }
1147         else
1148           {
1149 #ifdef HAVE_ELEMENTARY_X
1150              Evas_Object *top;
1151
1152              top = elm_widget_top_get(data);
1153              if ((top) && (elm_win_xwindow_get(top)))
1154                 elm_selection_clear(ELM_SEL_PRIMARY, data);
1155 #endif
1156           }
1157      }
1158 }
1159
1160 static void
1161 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1162 {
1163    Widget_Data *wd = elm_widget_data_get(data);
1164    if (!wd) return;
1165    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1166    if (wd->sel_notify_handler)
1167      {
1168 #ifdef HAVE_ELEMENTARY_X
1169         Evas_Object *top;
1170
1171         top = elm_widget_top_get(data);
1172         if ((top) && (elm_win_xwindow_get(top)))
1173           {
1174              wd->selection_asked = EINA_TRUE;
1175              elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data);
1176           }
1177 #endif
1178      }
1179 }
1180
1181 static void
1182 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1183 {
1184    Widget_Data *wd = elm_widget_data_get(data);
1185    if (!wd) return;
1186    evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1187    elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1188                         elm_entry_selection_get(data));
1189 }
1190
1191 static void
1192 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1193 {
1194    Widget_Data *wd = elm_widget_data_get(data);
1195    if (!wd) return;
1196    evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1197    elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1198                         elm_entry_selection_get(data));
1199    edje_object_part_text_insert(wd->ent, "elm.text", "");
1200    wd->changed = EINA_TRUE;
1201    _sizing_eval(data);
1202 }
1203
1204 static void
1205 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1206 {
1207    Widget_Data *wd = elm_widget_data_get(data);
1208    Evas_Coord cx, cy, cw, ch;
1209    if (!wd) return;
1210    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1211    edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1212                                              &cx, &cy, &cw, &ch);
1213    if (!wd->deferred_recalc_job)
1214      elm_widget_show_region_set(data, cx, cy, cw, ch);
1215    else
1216      {
1217         wd->deferred_cur = EINA_TRUE;
1218         wd->cx = cx;
1219         wd->cy = cy;
1220         wd->cw = cw;
1221         wd->ch = ch;
1222      }
1223 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1224    evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1225 #endif
1226 }
1227
1228 static void
1229 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1230 {
1231    Widget_Data *wd = elm_widget_data_get(data);
1232    if (!wd) return;
1233 }
1234
1235 static void
1236 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1237 {
1238    Widget_Data *wd = elm_widget_data_get(data);
1239    Elm_Entry_Anchor_Info ei;
1240    char *buf2, *p, *p2, *n;
1241    if (!wd) return;
1242    p = strrchr(emission, ',');
1243    if (p)
1244      {
1245         const Eina_List *geoms;
1246
1247         n = p + 1;
1248         p2 = p -1;
1249         while (p2 >= emission)
1250           {
1251              if (*p2 == ',') break;
1252              p2--;
1253           }
1254         p2++;
1255         buf2 = alloca(5 + p - p2);
1256         strncpy(buf2, p2, p - p2);
1257         buf2[p - p2] = 0;
1258         ei.name = n;
1259         ei.button = atoi(buf2);
1260         ei.x = ei.y = ei.w = ei.h = 0;
1261         geoms =
1262           edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1263         if (geoms)
1264           {
1265              Evas_Textblock_Rectangle *r;
1266              const Eina_List *l;
1267              Evas_Coord px, py, x, y;
1268
1269              evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1270              evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1271              EINA_LIST_FOREACH(geoms, l, r)
1272                {
1273                   if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1274                       ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1275                     {
1276                        ei.x = r->x + x;
1277                        ei.y = r->y + y;
1278                        ei.w = r->w;
1279                        ei.h = r->h;
1280                        break;
1281                     }
1282                }
1283           }
1284         if (!wd->disabled)
1285           evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1286      }
1287 }
1288
1289 static void
1290 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1291 {
1292    Widget_Data *wd = elm_widget_data_get(data);
1293    if (!wd) return;
1294 }
1295
1296 static void
1297 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1298 {
1299    Widget_Data *wd = elm_widget_data_get(data);
1300    if (!wd) return;
1301 }
1302
1303 static void
1304 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1305 {
1306    Widget_Data *wd = elm_widget_data_get(data);
1307    if (!wd) return;
1308 }
1309
1310 static void
1311 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1312 {
1313    Widget_Data *wd = elm_widget_data_get(data);
1314    if (!wd) return;
1315    evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1316 }
1317
1318 static void
1319 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1320 {
1321    Widget_Data *wd = elm_widget_data_get(data);
1322    if (!wd) return;
1323    evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1324 }
1325
1326 static void
1327 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1328 {
1329    Widget_Data *wd = elm_widget_data_get(data);
1330    if (!wd) return;
1331    evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1332 }
1333
1334 static void
1335 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1336 {
1337    Widget_Data *wd = elm_widget_data_get(data);
1338    if (!wd) return;
1339    evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1340 }
1341
1342 #ifdef HAVE_ELEMENTARY_X
1343 static Eina_Bool
1344 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1345 {
1346    Widget_Data *wd = elm_widget_data_get(data);
1347    Ecore_X_Event_Selection_Notify *ev = event;
1348    if (!wd) return ECORE_CALLBACK_PASS_ON;
1349    if (!wd->selection_asked && !wd->drag_selection_asked)
1350       return ECORE_CALLBACK_PASS_ON;
1351
1352    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1353        (ev->selection == ECORE_X_SELECTION_PRIMARY))
1354      {
1355         Ecore_X_Selection_Data_Text *text_data;
1356
1357         text_data = ev->data;
1358         if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1359           {
1360              if (text_data->text)
1361                {
1362                   char *txt = _text_to_mkup(text_data->text);
1363
1364                   if (txt)
1365                     {
1366                        elm_entry_entry_insert(data, txt);
1367                        free(txt);
1368                     }
1369                }
1370           }
1371         wd->selection_asked = EINA_FALSE;
1372      }
1373    else if (ev->selection == ECORE_X_SELECTION_XDND)
1374      {
1375         Ecore_X_Selection_Data_Text *text_data;
1376
1377         text_data = ev->data;
1378         if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1379           {
1380              if (text_data->text)
1381                {
1382                   char *txt = _text_to_mkup(text_data->text);
1383
1384                   if (txt)
1385                     {
1386                      /* Massive FIXME: this should be at the drag point */
1387                        elm_entry_entry_insert(data, txt);
1388                        free(txt);
1389                     }
1390                }
1391           }
1392         wd->drag_selection_asked = EINA_FALSE;
1393
1394         ecore_x_dnd_send_finished();
1395
1396      }
1397    return ECORE_CALLBACK_PASS_ON;
1398 }
1399
1400 static Eina_Bool
1401 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1402 {
1403 /*
1404    Widget_Data *wd = elm_widget_data_get(data);
1405    Ecore_X_Event_Selection_Clear *ev = event;
1406    if (!wd) return 1;
1407    if (!wd->have_selection) return 1;
1408    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1409        (ev->selection == ECORE_X_SELECTION_PRIMARY))
1410      {
1411         elm_entry_select_none(data);
1412      }
1413    return 1;*/
1414
1415         // start for cbhm
1416    Evas_Object *top = elm_widget_top_get(data);
1417    Ecore_X_Event_Selection_Clear *ev = event;
1418
1419    if (!top)
1420            return ECORE_CALLBACK_PASS_ON;
1421
1422         if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1423         {
1424                 return ECORE_CALLBACK_PASS_ON;
1425         }
1426
1427         elm_selection_get(1/*ELM_SEL_SECONDARY*/,0x1/*Markup */,data);
1428         // end for cbhm
1429    return ECORE_CALLBACK_PASS_ON;
1430 }
1431
1432
1433 static Eina_Bool
1434 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Drop_Data *drop)
1435 {
1436    Widget_Data *wd;
1437    Eina_Bool rv;
1438
1439    wd = elm_widget_data_get(obj);
1440
1441    if (!wd) return EINA_FALSE;
1442 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1443
1444    edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1445                                      EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1446    rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1447                                           EDJE_CURSOR_MAIN,drop->x,drop->y);
1448    if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1449    elm_entry_entry_insert(obj, drop->data);
1450    edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1451                                      EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1452
1453    return EINA_TRUE;
1454 }
1455 #endif
1456
1457 static Evas_Object *
1458 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1459 {
1460    Widget_Data *wd = elm_widget_data_get(data);
1461    Evas_Object *o;
1462    Eina_List *l;
1463    Elm_Entry_Item_Provider *ip;
1464    int ok = 0;
1465
1466    EINA_LIST_FOREACH(wd->item_providers, l, ip)
1467      {
1468         o = ip->func(ip->data, data, item);
1469         if (o) return o;
1470      }
1471    o = edje_object_add(evas_object_evas_get(data));
1472    if (!strncmp(item, "emoticon/", 9))
1473      ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1474    if (!ok)
1475      _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1476    return o;
1477 }
1478
1479 static int
1480 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1481 {
1482    char *curlocater, *starttag, *endtag;
1483    int firstindex = 0, foundflag = -1;
1484
1485    curlocater = strstr(oldstring, key);
1486    if (curlocater)
1487      {
1488         starttag = curlocater;
1489         endtag = curlocater + strlen(key);
1490         if (endtag == NULL || *endtag != '=') 
1491           {
1492             foundflag = 0;
1493             return -1;
1494           }
1495
1496         firstindex = abs(oldstring - curlocater);
1497         firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1498         *value = (char*)oldstring + firstindex;
1499
1500         while (oldstring != starttag)
1501           {
1502             if (*starttag == '>')
1503               {
1504                 foundflag = 0;
1505                 break;
1506               }
1507             if (*starttag == '<') 
1508               break;
1509             else 
1510               starttag--;
1511             if (starttag == NULL) break;
1512           }
1513
1514         while (NULL != endtag)
1515           {
1516             if (*endtag == '<')
1517               {
1518                 foundflag = 0;
1519                 break;
1520               }
1521             if (*endtag == '>') 
1522               break;
1523             else 
1524               endtag++;
1525             if (endtag == NULL) break;
1526           }
1527
1528         if (foundflag != 0 && *starttag == '<' && *endtag == '>') 
1529           foundflag = 1;
1530         else 
1531           foundflag = 0;
1532      }
1533    else
1534      {
1535        foundflag = 0;
1536      }
1537
1538    if (foundflag == 1) return 0;
1539
1540    return -1;
1541 }
1542
1543 static int
1544 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1545 {
1546    const char *srcstring = NULL;
1547    Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1548    char *curlocater, *replocater;
1549    char *starttag, *endtag;
1550    int tagtxtlen = 0, insertflag = 0;
1551
1552    srcstring = eina_strbuf_string_get(srcbuf);
1553    curlocater = strstr(srcstring, key);
1554
1555    if (curlocater == NULL)
1556      {
1557        insertflag = 1;
1558      }
1559    else
1560      {
1561        do 
1562          {
1563            starttag = strchr(srcstring, '<');
1564            endtag = strchr(srcstring, '>');
1565            tagtxtlen = endtag - starttag;
1566            if (tagtxtlen <= 0) tagtxtlen = 0;
1567            if (starttag < curlocater && curlocater < endtag) break;
1568            if (endtag != NULL && endtag+1 != NULL)
1569              srcstring = endtag+1;
1570            else
1571              break;
1572          } while (strlen(srcstring) > 1);
1573
1574        if (starttag && endtag && tagtxtlen > strlen(key))
1575          {
1576            repbuf = eina_strbuf_new();
1577            diffbuf = eina_strbuf_new();
1578            eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1579            srcstring = eina_strbuf_string_get(repbuf);
1580            curlocater = strstr(srcstring, key);
1581
1582            if (curlocater != NULL)
1583              {
1584                replocater = curlocater + strlen(key) + 1;
1585
1586                while (*replocater == ' ' || *replocater == '=')
1587                            {
1588                  replocater++;
1589                            }
1590
1591                 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1592                   replocater++;
1593
1594                if (replocater-curlocater > strlen(key)+1)
1595                  {
1596                    replocater--;
1597                    eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1598                  }
1599                else
1600                  insertflag = 1;
1601              }
1602            else
1603              {
1604                insertflag = 1;
1605              }
1606            eina_strbuf_reset(repbuf);
1607          }
1608        else
1609          {
1610            insertflag = 1; 
1611          }
1612      }
1613
1614    if (repbuf == NULL) repbuf = eina_strbuf_new();
1615    if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1616
1617    if (insertflag)
1618      {
1619        eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1620        eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1621      }
1622    else
1623      {
1624         if (deleteflag)
1625           {
1626             eina_strbuf_prepend(diffbuf, "<");
1627             eina_strbuf_append(diffbuf, ">");
1628             eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1629           }
1630         else
1631           {
1632             eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1633             eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1634           }
1635      }
1636
1637    if (repbuf) eina_strbuf_free(repbuf);
1638    if (diffbuf) eina_strbuf_free(diffbuf);
1639   
1640    return 0;           
1641 }
1642
1643 static int
1644 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1645 {
1646    Eina_Strbuf *sharebuf = NULL;   
1647    
1648    sharebuf = eina_strbuf_new();
1649    eina_strbuf_append(sharebuf, *srcstring);
1650    _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1651    eina_stringshare_del(*srcstring);
1652    *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1653    eina_strbuf_free(sharebuf);
1654
1655    return 0;
1656 }
1657
1658 static int
1659 _is_width_over(Evas_Object *obj)
1660 {
1661    Evas_Coord x, y, w, h;
1662    Evas_Coord vx, vy, vw, vh;
1663    Widget_Data *wd = elm_widget_data_get(obj);
1664
1665    if (!wd) return 0;
1666
1667    edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1668
1669    evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1670
1671    if (x >= 0 && y >= 0)
1672            return 0;
1673
1674    if (4 < wd->wrap_w && w > wd->wrap_w)
1675            return 1;
1676
1677    return 0;
1678 }
1679
1680 static void
1681 _reverse_ellipsis_entry(Evas_Object *obj)
1682 {
1683    Widget_Data *wd = elm_widget_data_get(obj);
1684    int cur_fontsize = 0;
1685    Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1686    char **kvalue = NULL;
1687    const char *minfont, *deffont, *maxfont;
1688    const char *ellipsis_string = "...";
1689    int minfontsize, maxfontsize, minshowcount;
1690
1691    minshowcount = strlen(ellipsis_string) + 1;
1692    minfont = edje_object_data_get(wd->ent, "min_font_size");
1693    if (minfont) minfontsize = atoi(minfont);
1694    else minfontsize = 1;
1695    maxfont = edje_object_data_get(wd->ent, "max_font_size");
1696    if (maxfont) maxfontsize = atoi(maxfont);
1697    else maxfontsize = 1;
1698    deffont = edje_object_data_get(wd->ent, "default_font_size");
1699    if (deffont) cur_fontsize = atoi(deffont);
1700    else cur_fontsize = 1;
1701    if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1702    if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1703
1704    if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1705      {
1706        if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1707      }
1708
1709    txtbuf = eina_strbuf_new();
1710    eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1711
1712    if (cur_fontsize >= atoi(deffont))
1713      {
1714        if (txtbuf) eina_strbuf_free(txtbuf);
1715        return;
1716      }
1717
1718    if (_is_width_over(obj) != 1)
1719      {
1720        int rev_fontsize = cur_fontsize;
1721   
1722        do {
1723            rev_fontsize++;
1724            if (rev_fontsize > atoi(deffont))
1725              break;
1726
1727            if (fontbuf != NULL)
1728              {
1729                eina_strbuf_free(fontbuf);
1730                fontbuf = NULL;
1731              }
1732            fontbuf = eina_strbuf_new();
1733            eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1734            _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1735            edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1736
1737            eina_strbuf_free(fontbuf);
1738            fontbuf = NULL;
1739          } while (_is_width_over(obj) != 1);
1740
1741        while (_is_width_over(obj))
1742          {
1743            rev_fontsize--;
1744            if (rev_fontsize < atoi(deffont))
1745              break;
1746
1747            if (fontbuf != NULL)
1748              {
1749                eina_strbuf_free(fontbuf);
1750                fontbuf = NULL;
1751              }
1752            fontbuf = eina_strbuf_new();
1753            eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1754            _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1755            edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1756            eina_strbuf_free(fontbuf);
1757            fontbuf = NULL;
1758          }
1759      }
1760
1761    if (txtbuf) eina_strbuf_free(txtbuf);
1762    wd->changed = 1;
1763    _sizing_eval(obj);
1764 }
1765
1766 static void
1767 _ellipsis_entry_to_width(Evas_Object *obj)
1768 {
1769    Widget_Data *wd = elm_widget_data_get(obj);
1770    int cur_fontsize = 0, len, jumpcount;
1771    Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1772    char **kvalue = NULL;
1773    const char *minfont, *deffont, *maxfont;
1774    const char *ellipsis_string = "...";
1775    int minfontsize, maxfontsize, minshowcount;
1776    int i, tagend, cur_len;
1777    char *cur_str;
1778
1779    minshowcount = strlen(ellipsis_string) + 1;
1780    minfont = edje_object_data_get(wd->ent, "min_font_size");
1781    if (minfont) minfontsize = atoi(minfont);
1782    else minfontsize = 1;
1783    maxfont = edje_object_data_get(wd->ent, "max_font_size");
1784    if (maxfont) maxfontsize = atoi(maxfont);
1785    else maxfontsize = 1;
1786    deffont = edje_object_data_get(wd->ent, "default_font_size");
1787    if (deffont) cur_fontsize = atoi(deffont);
1788    else cur_fontsize = 1;
1789    if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1790    if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1791
1792    if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1793      {
1794        if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1795      }
1796
1797    txtbuf = eina_strbuf_new();
1798    eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1799
1800    while (_is_width_over(obj))
1801      {
1802        if (wd->ellipsis_threshold == 0)
1803          wd->ellipsis_threshold = _entry_length_get(obj);
1804        if (cur_fontsize > minfontsize)
1805          {
1806            cur_fontsize--;
1807            if (fontbuf != NULL)
1808              {
1809                eina_strbuf_free(fontbuf);
1810                fontbuf = NULL;
1811              }
1812            fontbuf = eina_strbuf_new();
1813            eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1814            _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1815            edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1816            eina_strbuf_free(fontbuf);
1817            fontbuf = NULL;
1818                    edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1819          }
1820        else
1821          {
1822            len = _entry_length_get(obj);
1823            cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1824            cur_len = strlen(cur_str);
1825            tagend = 0;
1826            for (i = 0; i < len; i++)
1827              {
1828                if(cur_str[i] == '>' && cur_str[i+1] != NULL && 
1829                   cur_str[i+1] != '<')
1830                  {
1831                    tagend = i;
1832                    break;
1833                  }
1834              }
1835            jumpcount = 0;
1836            while (jumpcount < len-strlen(ellipsis_string))
1837              {
1838                cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1839
1840                if (txtbuf != NULL)
1841                  {
1842                    eina_strbuf_free(txtbuf);
1843                    txtbuf = NULL;
1844                  }
1845                txtbuf = eina_strbuf_new();
1846                eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1847                eina_strbuf_append(txtbuf, ellipsis_string);
1848                eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1849                edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1850                edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1851
1852                if (_is_width_over(obj)) 
1853                  jumpcount++;
1854                else 
1855                  break;
1856              }
1857          }
1858      }
1859
1860    if (txtbuf) eina_strbuf_free(txtbuf);
1861    wd->changed = 1;
1862    _sizing_eval(obj);
1863 }
1864
1865 static int _textinput_control_function(void *data,void *input_data)
1866 {
1867    /*calculate character count*/
1868    Evas_Object *entry = (Evas_Object *)data;
1869    Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
1870    char buf[10]="\0";
1871    size_t byte_len;
1872    size_t insert_text_len=0;
1873    char *text = edje_object_part_text_get(wd->ent, "elm.text");
1874    char *insert_text;  
1875    size_t remain_bytes;
1876    if(text!=NULL)
1877      {
1878        byte_len = strlen(text);/*no of bytes*/
1879        remain_bytes = wd->max_no_of_bytes-byte_len;
1880        sprintf(buf,"%d",remain_bytes);
1881        edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1882        if(input_data)
1883          {
1884            insert_text =  (char *)input_data;
1885            insert_text_len = strlen(insert_text);
1886            if(remain_bytes<insert_text_len)
1887              {
1888                evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1889                return EINA_TRUE;
1890              }
1891            if(byte_len>=wd->max_no_of_bytes)
1892              {
1893                evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1894                return EINA_TRUE;
1895              }
1896          }
1897      }
1898    return EINA_FALSE;  
1899 }
1900
1901 /**
1902  * This adds an entry to @p parent object.
1903  *
1904  * @param parent The parent object
1905  * @return The new object or NULL if it cannot be created
1906  *
1907  * @ingroup Entry
1908  */
1909 EAPI Evas_Object *
1910 elm_entry_add(Evas_Object *parent)
1911 {
1912    Evas_Object *obj, *top;
1913    Evas *e;
1914    Widget_Data *wd;
1915
1916    wd = ELM_NEW(Widget_Data);
1917    e = evas_object_evas_get(parent);
1918    wd->bgcolor = EINA_FALSE;
1919    wd->bg = evas_object_rectangle_add(e);
1920    evas_object_color_set(wd->bg, 0, 0, 0, 0);
1921    obj = elm_widget_add(e);
1922    ELM_SET_WIDTYPE(widtype, "entry");
1923    elm_widget_type_set(obj, "entry");
1924    elm_widget_sub_object_add(parent, obj);
1925    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1926    elm_widget_data_set(obj, wd);
1927    elm_widget_del_hook_set(obj, _del_hook);
1928    elm_widget_theme_hook_set(obj, _theme_hook);
1929    elm_widget_disable_hook_set(obj, _disable_hook);
1930    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1931    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1932    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1933    elm_widget_can_focus_set(obj, 1);
1934 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1935    elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
1936 #endif
1937
1938    wd->linewrap     = EINA_TRUE;
1939    wd->ellipsis     = EINA_FALSE;
1940    wd->char_linewrap= EINA_FALSE;
1941    wd->editable     = EINA_TRUE;
1942    wd->disabled     = EINA_FALSE;
1943    wd->context_menu = EINA_TRUE;
1944
1945    wd->ellipsis_threshold = 0;
1946
1947    wd->ent = edje_object_add(e);
1948    edje_object_item_provider_set(wd->ent, _get_item, obj);
1949    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
1950    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
1951    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
1952                                   _mouse_down, obj);
1953    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
1954                                   _mouse_up, obj);
1955    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
1956                                   _mouse_move, obj);
1957
1958    _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
1959    edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
1960                                    _signal_entry_changed, obj);
1961    edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
1962                                    _signal_selection_start, obj);
1963    edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
1964                                    _signal_selection_changed, obj);
1965    edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
1966                                    _signal_selection_cleared, obj);
1967    edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
1968                                    _signal_entry_paste_request, obj);
1969    edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
1970                                    _signal_entry_copy_notify, obj);
1971    edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
1972                                    _signal_entry_cut_notify, obj);
1973    edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
1974                                    _signal_cursor_changed, obj);
1975    edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
1976                                    _signal_anchor_down, obj);
1977    edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
1978                                    _signal_anchor_up, obj);
1979    edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
1980                                    _signal_anchor_move, obj);
1981    edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
1982                                    _signal_anchor_in, obj);
1983    edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
1984                                    _signal_anchor_out, obj);
1985    edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
1986                                    _signal_key_enter, obj);
1987    edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
1988                                    _signal_mouse_down, obj);
1989    edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
1990                                    _signal_mouse_up, obj);
1991    edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
1992                                    _signal_mouse_double, obj);
1993    edje_object_part_text_set(wd->ent, "elm.text", "");
1994    elm_widget_resize_object_set(obj, wd->ent);
1995    _sizing_eval(obj);
1996
1997    wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
1998
1999 #ifdef HAVE_ELEMENTARY_X
2000    top = elm_widget_top_get(obj);
2001    if ((top) && (elm_win_xwindow_get(top)))
2002      {
2003         wd->sel_notify_handler =
2004           ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2005                                   _event_selection_notify, obj);
2006         wd->sel_clear_handler =
2007           ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2008                                   _event_selection_clear, obj);
2009      }
2010
2011    elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2012 #endif
2013
2014    entries = eina_list_prepend(entries, obj);
2015
2016    // module - find module for entry
2017    wd->api = _module(obj);
2018    // if found - hook in
2019    if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2020
2021    // TODO: convert Elementary to subclassing of Evas_Smart_Class
2022    // TODO: and save some bytes, making descriptions per-class and not instance!
2023    evas_object_smart_callbacks_descriptions_set(obj, _signals);
2024    return obj;
2025 }
2026
2027 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2028 {
2029    ELM_CHECK_WIDTYPE(obj, widtype);
2030    Widget_Data *wd = elm_widget_data_get(obj);
2031    if (!wd) return;
2032    ext_mod->cancel = _cancel;
2033    ext_mod->copy = _copy;
2034    ext_mod->cut = _cut;
2035    ext_mod->paste = _paste;
2036    ext_mod->select = _select;
2037    ext_mod->selectall = NULL; /* to be implemented*/
2038    ext_mod->ent = wd->ent;
2039    ext_mod->items = wd->items;
2040    ext_mod->longpress_timer = wd->longpress_timer;
2041    ext_mod->editable = wd->editable;
2042    ext_mod->have_selection = wd->have_selection;
2043    ext_mod->password = wd->password;
2044    ext_mod->selmode = wd->selmode;
2045    ext_mod->context_menu = wd->context_menu;
2046 }
2047
2048 /**
2049  * This sets the entry object not to line wrap.  All input will
2050  * be on a single line, and the entry box will extend with user input.
2051  *
2052  * @param obj The entry object
2053  * @param single_line If true, the text in the entry
2054  * will be on a single line.
2055  *
2056  * @ingroup Entry
2057  */
2058 EAPI void
2059 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2060 {
2061    ELM_CHECK_WIDTYPE(obj, widtype);
2062    Widget_Data *wd = elm_widget_data_get(obj);
2063    const char *t;
2064    Ecore_IMF_Context *ic;
2065    if (!wd) return;
2066    if (wd->single_line == single_line) return;
2067    wd->single_line = single_line;
2068    wd->linewrap = EINA_FALSE;
2069    wd->char_linewrap = EINA_FALSE;
2070    t = eina_stringshare_add(elm_entry_entry_get(obj));
2071    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2072    elm_entry_entry_set(obj, t);
2073    edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
2074    edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2075    ic = elm_entry_imf_context_get(obj);
2076    if (ic)
2077      {
2078         ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2079      }
2080
2081    eina_stringshare_del(t);
2082    _sizing_eval(obj);
2083 }
2084
2085 /**
2086  * This returns true if the entry has been set to single line mode.
2087  * See also elm_entry_single_line_set().
2088  *
2089  * @param obj The entry object
2090  * @return single_line If true, the text in the entry is set to display
2091  * on a single line.
2092  *
2093  * @ingroup Entry
2094  */
2095 EAPI Eina_Bool
2096 elm_entry_single_line_get(const Evas_Object *obj)
2097 {
2098    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2099    Widget_Data *wd = elm_widget_data_get(obj);
2100    if (!wd) return EINA_FALSE;
2101    return wd->single_line;
2102 }
2103
2104 /**
2105  * This set's the maximum bytes that can be added in entry.
2106  *
2107  * @param obj The entry object
2108  * @param max_no_of_bytes Maximum number of bytes entry can have.
2109  * 
2110  * @ingroup Entry
2111  */
2112 EAPI void
2113 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2114 {
2115    Widget_Data *wd = elm_widget_data_get(obj);
2116
2117    wd->max_no_of_bytes = max_no_of_bytes;
2118    edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2119    edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2120  }
2121
2122
2123 /**
2124  * This sets the entry object to password mode.  All text entered
2125  * and/or displayed within the widget will be replaced with asterisks (*).
2126  *
2127  * @param obj The entry object
2128  * @param password If true, password mode is enabled.
2129  *
2130  * @ingroup Entry
2131  */
2132 EAPI void
2133 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2134 {
2135    ELM_CHECK_WIDTYPE(obj, widtype);
2136    Widget_Data *wd = elm_widget_data_get(obj);
2137    Ecore_IMF_Context *ic;
2138    const char *t;
2139    if (!wd) return;
2140    if (wd->password == password) return;
2141    wd->password = password;
2142    wd->show_last_character = EINA_FALSE;
2143    wd->single_line = EINA_TRUE;
2144    wd->linewrap = EINA_FALSE;
2145    wd->char_linewrap = EINA_FALSE;
2146    t = eina_stringshare_add(elm_entry_entry_get(obj));
2147    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2148    elm_entry_entry_set(obj, t);
2149
2150    ic = elm_entry_imf_context_get(obj);
2151    if (ic)
2152      {
2153         ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2154      }
2155
2156    eina_stringshare_del(t);
2157    _sizing_eval(obj);
2158 }
2159
2160 /**
2161  * This set's the entry in password mode with out masking the last character entered by user,
2162  * and later masking the character after 2 seconds.
2163  
2164  * @param obj The entry object
2165  * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character" 
2166  * 0 for default).
2167  *
2168  * @ingroup Entry
2169  */
2170 EAPI void         
2171 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2172 {
2173    Widget_Data *wd = elm_widget_data_get(obj);
2174    const char *t;
2175    if (!wd) return;
2176    if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character))  return;
2177    wd->show_last_character = show_last_character;
2178    wd->password = show_last_character;
2179    wd->single_line = EINA_TRUE;
2180    wd->linewrap = EINA_FALSE;
2181    wd->char_linewrap = EINA_FALSE;
2182    t = eina_stringshare_add(elm_entry_entry_get(obj));
2183     _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2184    elm_entry_entry_set(obj, t);
2185    eina_stringshare_del(t);
2186    _sizing_eval(obj);
2187 }
2188
2189 /**
2190  * This returns whether password mode is enabled.
2191  * See also elm_entry_password_set().
2192  *
2193  * @param obj The entry object
2194  * @return If true, the entry is set to display all characters
2195  * as asterisks (*).
2196  *
2197  * @ingroup Entry
2198  */
2199 EAPI Eina_Bool
2200 elm_entry_password_get(const Evas_Object *obj)
2201 {
2202    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2203    Widget_Data *wd = elm_widget_data_get(obj);
2204    if (!wd) return EINA_FALSE;
2205    return wd->password;
2206 }
2207
2208 /**
2209  * This sets the text displayed within the entry to @p entry.
2210  *
2211  * @param obj The entry object
2212  * @param entry The text to be displayed
2213  *
2214  * @ingroup Entry
2215  */
2216 EAPI void
2217 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2218 {
2219    ELM_CHECK_WIDTYPE(obj, widtype);
2220    Widget_Data *wd = elm_widget_data_get(obj);
2221    if (!wd) return;
2222    if (!entry) entry = "";
2223    if(wd->max_no_of_bytes)
2224      {
2225        int len = strlen(entry);
2226        if(len > wd->max_no_of_bytes)
2227        {
2228          ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2229          return;
2230        }
2231      }
2232    edje_object_part_text_set(wd->ent, "elm.text", entry);
2233    if (wd->text) eina_stringshare_del(wd->text);
2234    wd->text = NULL;
2235    wd->changed = EINA_TRUE;
2236    _sizing_eval(obj);
2237 }
2238
2239 /**
2240  * This returns the text currently shown in object @p entry.
2241  * See also elm_entry_entry_set().
2242  *
2243  * @param obj The entry object
2244  * @return The currently displayed text or NULL on failure
2245  *
2246  * @ingroup Entry
2247  */
2248 EAPI const char *
2249 elm_entry_entry_get(const Evas_Object *obj)
2250 {
2251    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2252    Widget_Data *wd = elm_widget_data_get(obj);
2253    const char *text;
2254    if (!wd) return NULL;
2255    if (wd->text) return wd->text;
2256    text = edje_object_part_text_get(wd->ent, "elm.text");
2257    if (!text)
2258      {
2259         ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2260         return NULL;
2261      }
2262    eina_stringshare_replace(&wd->text, text);
2263    return wd->text;
2264 }
2265
2266 /**
2267  * This returns all selected text within the entry.
2268  *
2269  * @param obj The entry object
2270  * @return The selected text within the entry or NULL on failure
2271  *
2272  * @ingroup Entry
2273  */
2274 EAPI const char *
2275 elm_entry_selection_get(const Evas_Object *obj)
2276 {
2277    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2278    Widget_Data *wd = elm_widget_data_get(obj);
2279    if (!wd) return NULL;
2280    return edje_object_part_text_selection_get(wd->ent, "elm.text");
2281 }
2282
2283 /**
2284  * This inserts text in @p entry at the beginning of the entry
2285  * object.
2286  *
2287  * @param obj The entry object
2288  * @param entry The text to insert
2289  *
2290  * @ingroup Entry
2291  */
2292 EAPI void
2293 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2294 {
2295    ELM_CHECK_WIDTYPE(obj, widtype);
2296    Widget_Data *wd = elm_widget_data_get(obj);
2297    if (!wd) return;
2298    edje_object_part_text_insert(wd->ent, "elm.text", entry);
2299    wd->changed = EINA_TRUE;
2300    _sizing_eval(obj);
2301 }
2302
2303 /**
2304  * This enables word line wrapping in the entry object.  It is the opposite
2305  * of elm_entry_single_line_set().  Additionally, setting this disables
2306  * character line wrapping.
2307  * See also elm_entry_line_char_wrap_set().
2308  *
2309  * @param obj The entry object
2310  * @param wrap If true, the entry will be wrapped once it reaches the end
2311  * of the object. Wrapping will occur at the end of the word before the end of the
2312  * object.
2313  *
2314  * @ingroup Entry
2315  */
2316 EAPI void
2317 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2318 {
2319    ELM_CHECK_WIDTYPE(obj, widtype);
2320    Widget_Data *wd = elm_widget_data_get(obj);
2321    const char *t;
2322    if (!wd) return;
2323    if (wd->linewrap == wrap) return;
2324    wd->linewrap = wrap;
2325    if(wd->linewrap)
2326        wd->char_linewrap = EINA_FALSE;
2327    t = eina_stringshare_add(elm_entry_entry_get(obj));
2328    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2329    elm_entry_entry_set(obj, t);
2330    eina_stringshare_del(t);
2331    _sizing_eval(obj);
2332 }
2333
2334 /**
2335  * Set wrap width of the entry
2336  *
2337  * @param obj The entry object
2338  * @param w The wrap width in pixels at a minimum where words need to wrap
2339  * @ingroup Entry
2340  */
2341 EAPI void
2342 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2343 {
2344    Widget_Data *wd = elm_widget_data_get(obj);
2345    if (wd->wrap_w == w) return;
2346    wd->wrap_w = w;
2347    _sizing_eval(obj);
2348 }
2349
2350 /**
2351  * get wrap width of the entry
2352  *
2353  * @param obj The entry object
2354  * @return The wrap width in pixels at a minimum where words need to wrap
2355  * @ingroup Entry
2356  */
2357 EAPI Evas_Coord
2358 elm_entry_wrap_width_get(const Evas_Object *obj)
2359 {
2360    Widget_Data *wd = elm_widget_data_get(obj);
2361    return wd->wrap_w;
2362 }
2363
2364 /**
2365  * This enables character line wrapping in the entry object.  It is the opposite
2366  * of elm_entry_single_line_set().  Additionally, setting this disables
2367  * word line wrapping.
2368  * See also elm_entry_line_wrap_set().
2369  *
2370  * @param obj The entry object
2371  * @param wrap If true, the entry will be wrapped once it reaches the end
2372  * of the object. Wrapping will occur immediately upon reaching the end of the object.
2373  *
2374  * @ingroup Entry
2375  */
2376 EAPI void
2377 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2378 {
2379    ELM_CHECK_WIDTYPE(obj, widtype);
2380    Widget_Data *wd = elm_widget_data_get(obj);
2381    const char *t;
2382    if (!wd) return;
2383    if (wd->char_linewrap == wrap) return;
2384    wd->char_linewrap = wrap;
2385    if(wd->char_linewrap)
2386        wd->linewrap = EINA_FALSE;
2387    t = eina_stringshare_add(elm_entry_entry_get(obj));
2388    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2389    elm_entry_entry_set(obj, t);
2390    eina_stringshare_del(t);
2391    _sizing_eval(obj);
2392 }
2393
2394 /**
2395  * This sets the editable attribute of the entry.
2396  *
2397  * @param obj The entry object
2398  * @param editable If true, the entry will be editable by the user.
2399  * If false, it will be set to the disabled state.
2400  *
2401  * @ingroup Entry
2402  */
2403 EAPI void
2404 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2405 {
2406    ELM_CHECK_WIDTYPE(obj, widtype);
2407    Widget_Data *wd = elm_widget_data_get(obj);
2408    const char *t;
2409    if (!wd) return;
2410    if (wd->editable == editable) return;
2411    wd->editable = editable;
2412    t = eina_stringshare_add(elm_entry_entry_get(obj));
2413    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2414    elm_entry_entry_set(obj, t);
2415    eina_stringshare_del(t);
2416    _sizing_eval(obj);
2417
2418 #ifdef HAVE_ELEMENTARY_X
2419    if (editable)
2420       elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2421    else
2422       elm_drop_target_del(obj);
2423 #endif
2424 }
2425
2426 /**
2427  * This gets the editable attribute of the entry.
2428  * See also elm_entry_editable_set().
2429  *
2430  * @param obj The entry object
2431  * @return If true, the entry is editable by the user.
2432  * If false, it is not editable by the user
2433  *
2434  * @ingroup Entry
2435  */
2436 EAPI Eina_Bool
2437 elm_entry_editable_get(const Evas_Object *obj)
2438 {
2439    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2440    Widget_Data *wd = elm_widget_data_get(obj);
2441    if (!wd) return EINA_FALSE;
2442    return wd->editable;
2443 }
2444
2445 /**
2446  * This drops any existing text selection within the entry.
2447  *
2448  * @param obj The entry object
2449  *
2450  * @ingroup Entry
2451  */
2452 EAPI void
2453 elm_entry_select_none(Evas_Object *obj)
2454 {
2455    ELM_CHECK_WIDTYPE(obj, widtype);
2456    Widget_Data *wd = elm_widget_data_get(obj);
2457    if (!wd) return;
2458    if (wd->selmode)
2459      {
2460         wd->selmode = EINA_FALSE;
2461         edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
2462         edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2463      }
2464    wd->have_selection = EINA_FALSE;
2465    edje_object_part_text_select_none(wd->ent, "elm.text");
2466 }
2467
2468 /**
2469  * This selects all text within the entry.
2470  *
2471  * @param obj The entry object
2472  *
2473  * @ingroup Entry
2474  */
2475 EAPI void
2476 elm_entry_select_all(Evas_Object *obj)
2477 {
2478    ELM_CHECK_WIDTYPE(obj, widtype);
2479    Widget_Data *wd = elm_widget_data_get(obj);
2480    if (!wd) return;
2481    if (wd->selmode)
2482      {
2483         wd->selmode = EINA_FALSE;
2484         edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
2485         edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2486      }
2487    wd->have_selection = EINA_TRUE;
2488    edje_object_part_text_select_all(wd->ent, "elm.text");
2489 }
2490
2491 /**
2492  * This moves the cursor one place to the right within the entry.
2493  *
2494  * @param obj The entry object
2495  * @return EINA_TRUE upon success, EINA_FALSE upon failure
2496  *
2497  * @ingroup Entry
2498  */
2499 EAPI Eina_Bool
2500 elm_entry_cursor_next(Evas_Object *obj)
2501 {
2502    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2503    Widget_Data *wd = elm_widget_data_get(obj);
2504    if (!wd) return EINA_FALSE;
2505    return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2506 }
2507
2508 /**
2509  * This moves the cursor one place to the left within the entry.
2510  *
2511  * @param obj The entry object
2512  * @return EINA_TRUE upon success, EINA_FALSE upon failure
2513  *
2514  * @ingroup Entry
2515  */
2516 EAPI Eina_Bool
2517 elm_entry_cursor_prev(Evas_Object *obj)
2518 {
2519    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2520    Widget_Data *wd = elm_widget_data_get(obj);
2521    if (!wd) return EINA_FALSE;
2522    return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2523 }
2524
2525 /**
2526  * This moves the cursor one line up within the entry.
2527  *
2528  * @param obj The entry object
2529  * @return EINA_TRUE upon success, EINA_FALSE upon failure
2530  *
2531  * @ingroup Entry
2532  */
2533 EAPI Eina_Bool
2534 elm_entry_cursor_up(Evas_Object *obj)
2535 {
2536    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2537    Widget_Data *wd = elm_widget_data_get(obj);
2538    if (!wd) return EINA_FALSE;
2539    return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2540 }
2541
2542 /**
2543  * This moves the cursor one line down within the entry.
2544  *
2545  * @param obj The entry object
2546  * @return EINA_TRUE upon success, EINA_FALSE upon failure
2547  *
2548  * @ingroup Entry
2549  */
2550 EAPI Eina_Bool
2551 elm_entry_cursor_down(Evas_Object *obj)
2552 {
2553    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2554    Widget_Data *wd = elm_widget_data_get(obj);
2555    if (!wd) return EINA_FALSE;
2556    return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2557 }
2558
2559 /**
2560  * This moves the cursor to the beginning of the entry.
2561  *
2562  * @param obj The entry object
2563  *
2564  * @ingroup Entry
2565  */
2566 EAPI void
2567 elm_entry_cursor_begin_set(Evas_Object *obj)
2568 {
2569    ELM_CHECK_WIDTYPE(obj, widtype);
2570    Widget_Data *wd = elm_widget_data_get(obj);
2571    if (!wd) return;
2572    edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2573 }
2574
2575 /**
2576  * This moves the cursor to the end of the entry.
2577  *
2578  * @param obj The entry object
2579  *
2580  * @ingroup Entry
2581  */
2582 EAPI void
2583 elm_entry_cursor_end_set(Evas_Object *obj)
2584 {
2585    ELM_CHECK_WIDTYPE(obj, widtype);
2586    Widget_Data *wd = elm_widget_data_get(obj);
2587    if (!wd) return;
2588    edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2589 }
2590
2591 /**
2592  * This moves the cursor to the beginning of the current line.
2593  *
2594  * @param obj The entry object
2595  *
2596  * @ingroup Entry
2597  */
2598 EAPI void
2599 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2600 {
2601    ELM_CHECK_WIDTYPE(obj, widtype);
2602    Widget_Data *wd = elm_widget_data_get(obj);
2603    if (!wd) return;
2604    edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2605 }
2606
2607 /**
2608  * This moves the cursor to the end of the current line.
2609  *
2610  * @param obj The entry object
2611  *
2612  * @ingroup Entry
2613  */
2614 EAPI void
2615 elm_entry_cursor_line_end_set(Evas_Object *obj)
2616 {
2617    ELM_CHECK_WIDTYPE(obj, widtype);
2618    Widget_Data *wd = elm_widget_data_get(obj);
2619    if (!wd) return;
2620    edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2621 }
2622
2623 /**
2624  * This begins a selection within the entry as though
2625  * the user were holding down the mouse button to make a selection.
2626  *
2627  * @param obj The entry object
2628  *
2629  * @ingroup Entry
2630  */
2631 EAPI void
2632 elm_entry_cursor_selection_begin(Evas_Object *obj)
2633 {
2634    ELM_CHECK_WIDTYPE(obj, widtype);
2635    Widget_Data *wd = elm_widget_data_get(obj);
2636    if (!wd) return;
2637    edje_object_part_text_select_begin(wd->ent, "elm.text");
2638 }
2639
2640 /**
2641  * This ends a selection within the entry as though
2642  * the user had just released the mouse button while making a selection.
2643  *
2644  * @param obj The entry object
2645  *
2646  * @ingroup Entry
2647  */
2648 EAPI void
2649 elm_entry_cursor_selection_end(Evas_Object *obj)
2650 {
2651    ELM_CHECK_WIDTYPE(obj, widtype);
2652    Widget_Data *wd = elm_widget_data_get(obj);
2653    if (!wd) return;
2654    edje_object_part_text_select_extend(wd->ent, "elm.text");
2655 }
2656
2657 /**
2658  * TODO: fill this in
2659  *
2660  * @param obj The entry object
2661  * @return TODO: fill this in
2662  *
2663  * @ingroup Entry
2664  */
2665 EAPI Eina_Bool
2666 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2667 {
2668    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2669    Widget_Data *wd = elm_widget_data_get(obj);
2670    if (!wd) return EINA_FALSE;
2671    return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2672 }
2673
2674 /**
2675  * This returns whether the cursor is visible.
2676  *
2677  * @param obj The entry object
2678  * @return If true, the cursor is visible.
2679  *
2680  * @ingroup Entry
2681  */
2682 EAPI Eina_Bool
2683 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2684 {
2685    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2686    Widget_Data *wd = elm_widget_data_get(obj);
2687    if (!wd) return EINA_FALSE;
2688    return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2689 }
2690
2691 /**
2692  * TODO: fill this in
2693  *
2694  * @param obj The entry object
2695  * @return TODO: fill this in
2696  *
2697  * @ingroup Entry
2698  */
2699 EAPI const char *
2700 elm_entry_cursor_content_get(const Evas_Object *obj)
2701 {
2702    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2703    Widget_Data *wd = elm_widget_data_get(obj);
2704    if (!wd) return NULL;
2705    return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2706 }
2707
2708 /**
2709  * This executes a "cut" action on the selected text in the entry.
2710  *
2711  * @param obj The entry object
2712  *
2713  * @ingroup Entry
2714  */
2715 EAPI void
2716 elm_entry_selection_cut(Evas_Object *obj)
2717 {
2718    ELM_CHECK_WIDTYPE(obj, widtype);
2719    Widget_Data *wd = elm_widget_data_get(obj);
2720    if (!wd) return;
2721    _cut(obj, NULL, NULL);
2722 }
2723
2724 /**
2725  * This executes a "copy" action on the selected text in the entry.
2726  *
2727  * @param obj The entry object
2728  *
2729  * @ingroup Entry
2730  */
2731 EAPI void
2732 elm_entry_selection_copy(Evas_Object *obj)
2733 {
2734    ELM_CHECK_WIDTYPE(obj, widtype);
2735    Widget_Data *wd = elm_widget_data_get(obj);
2736    if (!wd) return;
2737    _copy(obj, NULL, NULL);
2738 }
2739
2740 /**
2741  * This executes a "paste" action in the entry.
2742  *
2743  * @param obj The entry object
2744  *
2745  * @ingroup Entry
2746  */
2747 EAPI void
2748 elm_entry_selection_paste(Evas_Object *obj)
2749 {
2750    ELM_CHECK_WIDTYPE(obj, widtype);
2751    Widget_Data *wd = elm_widget_data_get(obj);
2752    if (!wd) return;
2753    _paste(obj, NULL, NULL);
2754 }
2755
2756 /**
2757  * This clears and frees the items in a entry's contextual (right click) menu.
2758  *
2759  * @param obj The entry object
2760  *
2761  * @ingroup Entry
2762  */
2763 EAPI void
2764 elm_entry_context_menu_clear(Evas_Object *obj)
2765 {
2766    ELM_CHECK_WIDTYPE(obj, widtype);
2767    Widget_Data *wd = elm_widget_data_get(obj);
2768    Elm_Entry_Context_Menu_Item *it;
2769    if (!wd) return;
2770    EINA_LIST_FREE(wd->items, it)
2771      {
2772         eina_stringshare_del(it->label);
2773         eina_stringshare_del(it->icon_file);
2774         eina_stringshare_del(it->icon_group);
2775         free(it);
2776      }
2777 }
2778
2779 /**
2780  * This adds an item to the entry's contextual menu.
2781  *
2782  * @param obj The entry object
2783  * @param label The item's text label
2784  * @param icon_file The item's icon file
2785  * @param icon_type The item's icon type
2786  * @param func The callback to execute when the item is clicked
2787  * @param data The data to associate with the item for related functions
2788  *
2789  * @ingroup Entry
2790  */
2791 EAPI void
2792 elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
2793 {
2794    ELM_CHECK_WIDTYPE(obj, widtype);
2795    Widget_Data *wd = elm_widget_data_get(obj);
2796    Elm_Entry_Context_Menu_Item *it;
2797    if (!wd) return;
2798    it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2799    if (!it) return;
2800    wd->items = eina_list_append(wd->items, it);
2801    it->obj = obj;
2802    it->label = eina_stringshare_add(label);
2803    it->icon_file = eina_stringshare_add(icon_file);
2804    it->icon_type = icon_type;
2805    it->func = func;
2806    it->data = (void *)data;
2807 }
2808
2809 /**
2810  * This disables the entry's contextual (right click) menu.
2811  *
2812  * @param obj The entry object
2813  * @param disabled If true, the menu is disabled
2814  *
2815  * @ingroup Entry
2816  */
2817 EAPI void
2818 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2819 {
2820    ELM_CHECK_WIDTYPE(obj, widtype);
2821    Widget_Data *wd = elm_widget_data_get(obj);
2822    if (!wd) return;
2823    if (wd->context_menu == !disabled) return;
2824    wd->context_menu = !disabled;
2825 }
2826
2827 /**
2828  * This returns whether the entry's contextual (right click) menu is disabled.
2829  *
2830  * @param obj The entry object
2831  * @return If true, the menu is disabled
2832  *
2833  * @ingroup Entry
2834  */
2835 EAPI Eina_Bool
2836 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2837 {
2838    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2839    Widget_Data *wd = elm_widget_data_get(obj);
2840    if (!wd) return EINA_FALSE;
2841    return !wd->context_menu;
2842 }
2843
2844 /**
2845  * This appends a custom item provider to the list for that entry
2846  *
2847  * This appends the given callback. The list is walked from beginning to end
2848  * with each function called given the item href string in the text. If the
2849  * function returns an object handle other than NULL (it should create an
2850  * and object to do this), then this object is used to replace that item. If
2851  * not the next provider is called until one provides an item object, or the
2852  * default provider in entry does.
2853  * 
2854  * @param obj The entry object
2855  * @param func The function called to provide the item object
2856  * @param data The data passed to @p func
2857  *
2858  * @ingroup Entry
2859  */
2860 EAPI void
2861 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2862 {
2863    ELM_CHECK_WIDTYPE(obj, widtype);
2864    Widget_Data *wd = elm_widget_data_get(obj);
2865    if (!wd) return;
2866    if (!func) return;
2867    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2868    if (!ip) return;
2869    ip->func = func;
2870    ip->data = data;
2871    wd->item_providers = eina_list_append(wd->item_providers, ip);
2872 }
2873
2874 /**
2875  * This prepends a custom item provider to the list for that entry
2876  *
2877  * This prepends the given callback. See elm_entry_item_provider_append() for
2878  * more information
2879  * 
2880  * @param obj The entry object
2881  * @param func The function called to provide the item object
2882  * @param data The data passed to @p func
2883  *
2884  * @ingroup Entry
2885  */
2886 EAPI void
2887 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2888 {
2889    ELM_CHECK_WIDTYPE(obj, widtype);
2890    Widget_Data *wd = elm_widget_data_get(obj);
2891    if (!wd) return;
2892    if (!func) return;
2893    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2894    if (!ip) return;
2895    ip->func = func;
2896    ip->data = data;
2897    wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2898 }
2899
2900 /**
2901  * This removes a custom item provider to the list for that entry
2902  *
2903  * This removes the given callback. See elm_entry_item_provider_append() for
2904  * more information
2905  * 
2906  * @param obj The entry object
2907  * @param func The function called to provide the item object
2908  * @param data The data passed to @p func
2909  *
2910  * @ingroup Entry
2911  */
2912 EAPI void
2913 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2914 {
2915    ELM_CHECK_WIDTYPE(obj, widtype);
2916    Widget_Data *wd = elm_widget_data_get(obj);
2917    Eina_List *l;
2918    Elm_Entry_Item_Provider *ip;
2919    if (!wd) return;
2920    if (!func) return;
2921    EINA_LIST_FOREACH(wd->item_providers, l, ip)
2922      {
2923         if ((ip->func == func) && (ip->data == data))
2924           {
2925              wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2926              free(ip);
2927              return;
2928           }
2929      }
2930 }
2931
2932 /**
2933  * This converts a markup (HTML-like) string into UTF-8.
2934  *
2935  * @param s The string (in markup) to be converted
2936  * @return The converted string (in UTF-8)
2937  *
2938  * @ingroup Entry
2939  */
2940 EAPI char *
2941 elm_entry_markup_to_utf8(const char *s)
2942 {
2943    char *ss = _mkup_to_text(s);
2944    if (!ss) ss = strdup("");
2945    return ss;
2946 }
2947
2948 /**
2949  * This converts a UTF-8 string into markup (HTML-like).
2950  *
2951  * @param s The string (in UTF-8) to be converted
2952  * @return The converted string (in markup)
2953  *
2954  * @ingroup Entry
2955  */
2956 EAPI char *
2957 elm_entry_utf8_to_markup(const char *s)
2958 {
2959    char *ss = _text_to_mkup(s);
2960    if (!ss) ss = strdup("");
2961    return ss;
2962 }
2963
2964 /**
2965  * Get the input method context in the entry widget
2966  *
2967  * @param obj The entry object
2968  * @return The input method context
2969  *
2970  * @ingroup Entry
2971  */
2972 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
2973 {
2974    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2975    Widget_Data *wd = elm_widget_data_get(obj);
2976    if (!wd || !wd->ent) return NULL;
2977   
2978    return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
2979 }
2980
2981 /**
2982  * Set whether entry should enable the return key on soft keyboard automatically
2983  *
2984  * @param obj The entry object
2985  * @param on If true, entry enables the return key on soft keyboard automatically.
2986  *
2987  * @ingroup Entry
2988  */
2989 EAPI void 
2990 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
2991 {
2992    ELM_CHECK_WIDTYPE(obj, widtype);
2993    Widget_Data *wd = elm_widget_data_get(obj);
2994    if (!wd) return;
2995
2996    wd->autoreturnkey = on;
2997    _check_enable_returnkey(obj);
2998 }
2999
3000 /**
3001  * Set whether entry should support auto capitalization
3002  *
3003  * @param obj The entry object
3004  * @param on If true, entry suports auto capitalization.
3005  *
3006  * @ingroup Entry
3007  */
3008 EAPI void 
3009 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3010 {
3011    ELM_CHECK_WIDTYPE(obj, widtype);
3012    Widget_Data *wd = elm_widget_data_get(obj);
3013    if (!wd) return;
3014
3015    if (wd->password)
3016        wd->autocapitalize = EINA_FALSE;
3017    else
3018        wd->autocapitalize = autocap;
3019
3020    edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
3021 }
3022
3023 /**
3024  * Set whether entry should support auto period
3025  *
3026  * @param obj The entry object
3027  * @param on If true, entry suports auto period.
3028  *
3029  * @ingroup Entry
3030  */
3031 EAPI void 
3032 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3033 {
3034    ELM_CHECK_WIDTYPE(obj, widtype);
3035    Widget_Data *wd = elm_widget_data_get(obj);
3036    if (!wd) return;
3037
3038    if (wd->password)
3039        wd->autoperiod = EINA_FALSE;
3040    else
3041        wd->autoperiod = autoperiod;
3042
3043    edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3044 }
3045
3046 /**
3047  * Set the font size on the entry object
3048  *
3049  * @param obj The entry object
3050  * @param size font size
3051  *
3052  * @ingroup Entry
3053  */
3054 EAPI void
3055 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3056 {
3057    ELM_CHECK_WIDTYPE(obj, widtype);
3058    Widget_Data *wd = elm_widget_data_get(obj);
3059    Eina_Strbuf *fontbuf = NULL;
3060    int removeflag = 0;
3061    const char *t;
3062
3063    if (!wd) return;
3064    t = eina_stringshare_add(elm_entry_entry_get(obj));
3065    fontbuf = eina_strbuf_new();
3066    eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3067
3068    if (fontsize == 0) removeflag = 1; // remove fontsize tag
3069
3070    if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3071      {
3072        elm_entry_entry_set(obj, t);
3073        wd->changed = 1;
3074        _sizing_eval(obj);
3075      }
3076    eina_strbuf_free(fontbuf);
3077    eina_stringshare_del(t);
3078 }
3079
3080 /**
3081  * Set the text align on the entry object
3082  *
3083  * @param obj The entry object
3084  * @param align align mode
3085  *
3086  * @ingroup Entry
3087  */
3088 EAPI void
3089 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3090 {
3091    ELM_CHECK_WIDTYPE(obj, widtype);
3092    Widget_Data *wd = elm_widget_data_get(obj);
3093    int len;
3094    const char *t;
3095
3096    if (!wd) return;
3097    t = eina_stringshare_add(elm_entry_entry_get(obj));
3098    len = strlen(t);
3099    if (len <= 0) return;
3100
3101    if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3102      elm_entry_entry_set(obj, t);
3103
3104    wd->changed = 1;
3105    _sizing_eval(obj);
3106    eina_stringshare_del(t);
3107 }
3108
3109 /**
3110  * Set the text color on the entry object
3111  *
3112  * @param obj The entry object
3113  * @param r Red property background color of The entry object 
3114  * @param g Green property background color of The entry object 
3115  * @param b Blue property background color of The entry object 
3116  * @param a Alpha property background alpha of The entry object 
3117  *
3118  * @ingroup Entry
3119  */
3120 EAPI void
3121 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3122 {
3123    ELM_CHECK_WIDTYPE(obj, widtype);
3124    Widget_Data *wd = elm_widget_data_get(obj);
3125    Eina_Strbuf *colorbuf = NULL;
3126    const char *t;
3127    int len;
3128
3129    if (!wd) return;
3130    t = eina_stringshare_add(elm_entry_entry_get(obj));
3131    len = strlen(t);
3132    if (len <= 0) return;
3133    colorbuf = eina_strbuf_new();
3134    eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3135
3136    if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3137      {
3138        elm_entry_entry_set(obj, t);
3139        wd->changed = 1;
3140        _sizing_eval(obj);
3141      }
3142    eina_strbuf_free(colorbuf);
3143    eina_stringshare_del(t);
3144 }
3145
3146
3147 /**
3148  * Set background color of the entry
3149  *
3150  * @param obj The entry object
3151  * @param r Red property background color of The entry object 
3152  * @param g Green property background color of The entry object 
3153  * @param b Blue property background color of The entry object 
3154  * @param a Alpha property background alpha of The entry object 
3155  * @ingroup Entry
3156  */
3157 EAPI void
3158 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3159 {
3160    ELM_CHECK_WIDTYPE(obj, widtype);
3161    Widget_Data *wd = elm_widget_data_get(obj);
3162    evas_object_color_set(wd->bg, r, g, b, a);
3163
3164    if (wd->bgcolor == EINA_FALSE)
3165      {
3166        wd->bgcolor = 1;
3167        edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3168      }
3169 }
3170
3171 /**
3172  * Set the ellipsis behavior of the entry
3173  *
3174  * @param obj The entry object
3175  * @param ellipsis To ellipsis text or not
3176  * @ingroup Entry
3177  */
3178 EAPI void
3179 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3180 {
3181    ELM_CHECK_WIDTYPE(obj, widtype);
3182    Widget_Data *wd = elm_widget_data_get(obj);
3183    if (wd->ellipsis == ellipsis) return;
3184    wd->ellipsis = ellipsis;
3185    wd->changed = 1;
3186    _sizing_eval(obj);
3187 }
3188
3189 /**
3190  * This sets the attribute to show the input panel automatically.
3191  *
3192  * @param obj The entry object
3193  * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3194  *
3195  * @ingroup Entry
3196  */
3197 EAPI void
3198 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3199 {
3200    ELM_CHECK_WIDTYPE(obj, widtype);
3201    Widget_Data *wd = elm_widget_data_get(obj);
3202    if (!wd) return;
3203
3204    wd->input_panel_enable = enabled;
3205    edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3206 }
3207
3208 /**
3209  * Set the input panel layout of the entry
3210  *
3211  * @param obj The entry object
3212  * @param layout the layout to set
3213  *
3214  * @ingroup Entry
3215  */
3216 EAPI void
3217 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3218 {
3219    ELM_CHECK_WIDTYPE(obj, widtype);
3220    Widget_Data *wd = elm_widget_data_get(obj);
3221    if (!wd) return;
3222    
3223    Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3224    if (!ic) return;
3225
3226    wd->input_panel_layout = layout;
3227    
3228    ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3229 }
3230
3231 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/