2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
4 #include <Elementary.h>
6 #include "elm_module_priv.h"
8 * @defgroup Entry Entry
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
18 * You can also insert "items" in the entry with:
20 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
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:
27 * - emoticon/angry-shout
28 * - emoticon/crazy-laugh
29 * - emoticon/evil-laugh
31 * - emoticon/goggle-smile
33 * - emoticon/grumpy-smile
35 * - emoticon/guilty-smile
37 * - emoticon/half-smile
38 * - emoticon/happy-panting
40 * - emoticon/indifferent
42 * - emoticon/knowing-grin
44 * - emoticon/little-bit-sorry
45 * - emoticon/love-lots
47 * - emoticon/minimal-smile
48 * - emoticon/not-happy
49 * - emoticon/not-impressed
51 * - emoticon/opensmile
54 * - emoticon/squint-laugh
55 * - emoticon/surprised
56 * - emoticon/suspicious
57 * - emoticon/tongue-dangling
58 * - emoticon/tongue-poke
61 * - emoticon/very-sorry
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.
71 * See the entry test for some more examples of use of this.
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
92 typedef struct _Mod_Api Mod_Api;
94 typedef struct _Widget_Data Widget_Data;
95 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
100 Evas_Object *popup;/*copy paste UI - elm_popup*/
101 Evas_Object *ctxpopup;/*copy paste UI - elm_ctxpopup*/
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 */
112 int ellipsis_threshold;
114 Evas_Coord downx, downy;
115 Evas_Coord cx, cy, cw, ch;
117 Eina_List *item_providers;
118 Mod_Api *api; // module api if supplied
120 Eina_Bool changed : 1;
121 Eina_Bool linewrap : 1;
122 Eina_Bool char_linewrap : 1;
123 Eina_Bool single_line : 1;
124 Eina_Bool password : 1;
125 Eina_Bool show_last_character : 1;
126 Eina_Bool editable : 1;
127 Eina_Bool selection_asked : 1;
128 Eina_Bool have_selection : 1;
129 Eina_Bool selmode : 1;
130 Eina_Bool deferred_cur : 1;
131 Eina_Bool disabled : 1;
132 Eina_Bool context_menu : 1;
133 Eina_Bool bgcolor : 1;
134 Eina_Bool ellipsis : 1;
135 Eina_Bool autoreturnkey : 1;
136 Eina_Bool input_panel_enable : 1;
137 Eina_Bool autocapitalize : 1;
138 Elm_Input_Panel_Layout input_panel_layout;
141 struct _Elm_Entry_Item_Provider
143 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
147 static const char *widtype = NULL;
148 static void _del_hook(Evas_Object *obj);
149 static void _theme_hook(Evas_Object *obj);
150 static void _disable_hook(Evas_Object *obj);
151 static void _sizing_eval(Evas_Object *obj);
152 static void _on_focus_hook(void *data, Evas_Object *obj);
153 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
154 static const char *_getbase(Evas_Object *obj);
155 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
156 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
157 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
158 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
159 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
160 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
161 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
162 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
163 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
164 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
165 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
166 static int _is_width_over(Evas_Object *obj);
167 static void _ellipsis_entry_to_width(Evas_Object *obj);
168 static void _reverse_ellipsis_entry(Evas_Object *obj);
169 static int _textinput_control_function(void *data,void *input_data);
170 static int _entry_length_get(Evas_Object *obj);
172 static const char SIG_CHANGED[] = "changed";
173 static const char SIG_ACTIVATED[] = "activated";
174 static const char SIG_PRESS[] = "press";
175 static const char SIG_LONGPRESSED[] = "longpressed";
176 static const char SIG_CLICKED[] = "clicked";
177 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
178 static const char SIG_FOCUSED[] = "focused";
179 static const char SIG_UNFOCUSED[] = "unfocused";
180 static const char SIG_SELECTION_PASTE[] = "selection,paste";
181 static const char SIG_SELECTION_COPY[] = "selection,copy";
182 static const char SIG_SELECTION_CUT[] = "selection,cut";
183 static const char SIG_SELECTION_START[] = "selection,start";
184 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
185 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
186 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
187 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
188 static const Evas_Smart_Cb_Description _signals[] = {
192 {SIG_LONGPRESSED, ""},
194 {SIG_CLICKED_DOUBLE, ""},
197 {SIG_SELECTION_PASTE, ""},
198 {SIG_SELECTION_COPY, ""},
199 {SIG_SELECTION_CUT, ""},
200 {SIG_SELECTION_START, ""},
201 {SIG_SELECTION_CHANGED, ""},
202 {SIG_SELECTION_CLEARED, ""},
203 {SIG_CURSOR_CHANGED, ""},
204 {SIG_ANCHOR_CLICKED, ""},
208 static Eina_List *entries = NULL;
212 void (*obj_hook) (Evas_Object *obj);
213 void (*obj_unhook) (Evas_Object *obj);
214 void (*obj_longpress) (Evas_Object *obj);
215 void (*obj_mouseup) (Evas_Object *obj);
219 _module(Evas_Object *obj __UNUSED__)
221 static Elm_Module *m = NULL;
222 if (m) goto ok; // already found - just use
223 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
225 m->api = malloc(sizeof(Mod_Api));
226 if (!m->api) return NULL;
227 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
228 _elm_module_symbol_get(m, "obj_hook");
229 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
230 _elm_module_symbol_get(m, "obj_unhook");
231 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
232 _elm_module_symbol_get(m, "obj_longpress");
233 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
234 _elm_module_symbol_get(m, "obj_mouseup");
235 ok: // ok - return api
240 _del_hook(Evas_Object *obj)
242 Widget_Data *wd = elm_widget_data_get(obj);
243 Elm_Entry_Context_Menu_Item *it;
244 Elm_Entry_Item_Provider *ip;
246 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
248 entries = eina_list_remove(entries, obj);
249 #ifdef HAVE_ELEMENTARY_X
250 ecore_event_handler_del(wd->sel_notify_handler);
251 ecore_event_handler_del(wd->sel_clear_handler);
253 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
254 if (wd->text) eina_stringshare_del(wd->text);
255 if (wd->bg) evas_object_del(wd->bg);
256 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
257 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
258 EINA_LIST_FREE(wd->items, it)
260 eina_stringshare_del(it->label);
261 eina_stringshare_del(it->icon_file);
262 eina_stringshare_del(it->icon_group);
265 EINA_LIST_FREE(wd->item_providers, ip)
273 _theme_hook(Evas_Object *obj)
275 Widget_Data *wd = elm_widget_data_get(obj);
277 Ecore_IMF_Context *ic;
279 t = eina_stringshare_add(elm_entry_entry_get(obj));
280 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
281 elm_entry_entry_set(obj, t);
282 eina_stringshare_del(t);
283 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
284 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
285 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
287 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
290 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
297 _disable_hook(Evas_Object *obj)
299 Widget_Data *wd = elm_widget_data_get(obj);
301 if (elm_widget_disabled_get(obj))
303 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
304 wd->disabled = EINA_TRUE;
308 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
309 wd->disabled = EINA_FALSE;
314 _elm_win_recalc_job(void *data)
316 Widget_Data *wd = elm_widget_data_get(data);
317 Evas_Coord minw = -1, minh = -1, maxh = -1;
318 Evas_Coord resw, resh, minminw;
320 wd->deferred_recalc_job = NULL;
321 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
324 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
325 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
327 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
328 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
329 evas_object_size_hint_min_set(data, minminw, minh);
330 if (wd->single_line) maxh = minh;
331 evas_object_size_hint_max_set(data, -1, maxh);
332 if (wd->deferred_cur)
333 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
337 _sizing_eval(Evas_Object *obj)
339 Widget_Data *wd = elm_widget_data_get(obj);
340 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
341 Evas_Coord resw, resh;
343 if (wd->linewrap || wd->char_linewrap)
345 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
346 if ((resw == wd->lastw) && (!wd->changed)) return;
347 wd->changed = EINA_FALSE;
349 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
350 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
354 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
355 edje_object_size_min_calc(wd->ent, &minw, &minh);
356 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
357 evas_object_size_hint_min_set(obj, minw, minh);
358 if (wd->single_line) maxh = minh;
359 evas_object_size_hint_max_set(obj, maxw, maxh);
361 if (wd->ellipsis && wd->single_line)
363 if (_is_width_over(obj))
364 _ellipsis_entry_to_width(obj);
365 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
366 _reverse_ellipsis_entry(obj);
372 _check_enable_returnkey(Evas_Object *obj)
374 Widget_Data *wd = elm_widget_data_get(obj);
377 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
380 if (!wd->autoreturnkey) return;
382 if (_entry_length_get(obj) == 0)
384 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
388 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
393 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
395 Widget_Data *wd = elm_widget_data_get(obj);
396 Evas_Object *top = elm_widget_top_get(obj);
398 if (!wd->editable) return;
399 if (elm_widget_focus_get(obj))
401 evas_object_focus_set(wd->ent, 1);
402 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
403 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
404 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
405 _check_enable_returnkey(obj);
409 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
410 edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
411 evas_object_focus_set(wd->ent, 0);
412 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
413 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
418 _hoversel_position(Evas_Object *obj)
420 Widget_Data *wd = elm_widget_data_get(obj);
421 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
423 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
424 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
426 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
437 evas_object_move(wd->hoversel, x + cx, y + cy);
438 evas_object_resize(wd->hoversel, cw, ch);
442 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
444 Widget_Data *wd = elm_widget_data_get(data);
446 if (wd->hoversel) _hoversel_position(data);
450 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
452 Widget_Data *wd = elm_widget_data_get(data);
454 if (wd->linewrap || wd->char_linewrap)
458 if (wd->hoversel) _hoversel_position(data);
459 // Evas_Coord ww, hh;
460 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
464 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
466 Widget_Data *wd = elm_widget_data_get(data);
468 if (wd->hoversel) evas_object_hide(wd->hoversel);
472 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
474 elm_widget_scroll_freeze_pop(data);
478 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
480 Widget_Data *wd = elm_widget_data_get(data);
482 wd->selmode = EINA_TRUE;
483 edje_object_part_text_select_none(wd->ent, "elm.text");
485 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
486 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
487 elm_widget_scroll_hold_push(data);
491 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
493 Widget_Data *wd = elm_widget_data_get(data);
495 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
496 if (wd->sel_notify_handler)
498 #ifdef HAVE_ELEMENTARY_X
499 wd->selection_asked = EINA_TRUE;
500 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_MARKUP, data);
506 _store_selection(enum _elm_sel_type seltype, Evas_Object *obj)
508 Widget_Data *wd = elm_widget_data_get(obj);
512 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
513 elm_selection_set(seltype, obj, ELM_SEL_MARKUP, sel);
514 if (seltype == ELM_SEL_CLIPBOARD)
515 eina_stringshare_replace(&wd->cut_sel, sel);
519 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
521 Widget_Data *wd = elm_widget_data_get(data);
524 wd->selmode = EINA_FALSE;
525 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
526 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
527 elm_widget_scroll_hold_pop(data);
528 _store_selection(ELM_SEL_CLIPBOARD, data);
529 edje_object_part_text_insert(wd->ent, "elm.text", "");
530 edje_object_part_text_select_none(wd->ent, "elm.text");
534 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
536 Widget_Data *wd = elm_widget_data_get(data);
538 wd->selmode = EINA_FALSE;
539 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
540 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
541 elm_widget_scroll_hold_pop(data);
542 _store_selection(ELM_SEL_CLIPBOARD, data);
543 // edje_object_part_text_select_none(wd->ent, "elm.text");
547 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
549 Widget_Data *wd = elm_widget_data_get(data);
551 wd->selmode = EINA_FALSE;
552 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
553 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
554 elm_widget_scroll_hold_pop(data);
555 edje_object_part_text_select_none(wd->ent, "elm.text");
559 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
561 Elm_Entry_Context_Menu_Item *it = data;
562 Evas_Object *obj2 = it->obj;
563 if (it->func) it->func(it->data, obj2, NULL);
567 _long_press(void *data)
569 Widget_Data *wd = elm_widget_data_get(data);
572 const Elm_Entry_Context_Menu_Item *it;
574 if ((wd->api) && (wd->api->obj_longpress))
576 wd->api->obj_longpress(data);
578 else if (wd->context_menu)
580 const char *context_menu_orientation;
582 if (wd->hoversel) evas_object_del(wd->hoversel);
583 else elm_widget_scroll_freeze_push(data);
584 wd->hoversel = elm_hoversel_add(data);
585 context_menu_orientation = edje_object_data_get
586 (wd->ent, "context_menu_orientation");
587 if ((context_menu_orientation) &&
588 (!strcmp(context_menu_orientation, "horizontal")))
589 elm_hoversel_horizontal_set(wd->hoversel, 1);
590 elm_object_style_set(wd->hoversel, "entry");
591 elm_widget_sub_object_add(data, wd->hoversel);
592 elm_hoversel_label_set(wd->hoversel, "Text");
593 top = elm_widget_top_get(data);
594 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
595 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
599 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
601 if (1) // need way to detect if someone has a selection
604 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
612 if (wd->have_selection)
614 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
617 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
620 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
624 EINA_LIST_FOREACH(wd->items, l, it)
626 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
627 it->icon_type, _item_clicked, it);
631 _hoversel_position(data);
632 evas_object_show(wd->hoversel);
633 elm_hoversel_hover_begin(wd->hoversel);
635 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
636 edje_object_part_text_select_abort(wd->ent, "elm.text");
638 wd->longpress_timer = NULL;
639 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
644 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
646 Widget_Data *wd = elm_widget_data_get(data);
647 Evas_Event_Mouse_Down *ev = event_info;
649 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
650 if (ev->button != 1) return;
651 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
652 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
653 wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
654 wd->downx = ev->canvas.x;
655 wd->downy = ev->canvas.y;
659 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
661 Widget_Data *wd = elm_widget_data_get(data);
662 Evas_Event_Mouse_Up *ev = event_info;
664 if (ev->button != 1) return;
665 if ((wd->api) && (wd->api->obj_mouseup))
667 wd->api->obj_mouseup(data);
669 if (wd->longpress_timer)
671 ecore_timer_del(wd->longpress_timer);
672 wd->longpress_timer = NULL;
677 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
679 Widget_Data *wd = elm_widget_data_get(data);
680 Evas_Event_Mouse_Move *ev = event_info;
684 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
686 if (wd->longpress_timer)
688 ecore_timer_del(wd->longpress_timer);
689 wd->longpress_timer = NULL;
692 else if (wd->longpress_timer)
696 dx = wd->downx - ev->cur.canvas.x;
698 dy = wd->downy - ev->cur.canvas.y;
701 ((_elm_config->finger_size / 2) *
702 (_elm_config->finger_size / 2)))
704 ecore_timer_del(wd->longpress_timer);
705 wd->longpress_timer = NULL;
709 else if (wd->longpress_timer)
713 dx = wd->downx - ev->cur.canvas.x;
715 dy = wd->downy - ev->cur.canvas.y;
718 ((_elm_config->finger_size / 2) *
719 (_elm_config->finger_size / 2)))
721 ecore_timer_del(wd->longpress_timer);
722 wd->longpress_timer = NULL;
728 _getbase(Evas_Object *obj)
730 Widget_Data *wd = elm_widget_data_get(obj);
731 if (!wd) return "base";
734 if((wd->password)&&(wd->show_last_character)) return "custom-password";
735 else if(wd->password) return "base-password";
738 if (wd->single_line) return "base-single";
741 if (wd->linewrap) return "base";
742 else if (wd->char_linewrap) return "base-charwrap";
743 else return "base-nowrap";
749 if((wd->password)&&(wd->show_last_character)) return "custom-password";
750 else if(wd->password) return "base-password";
753 if (wd->single_line) return "base-single-noedit";
756 if (wd->linewrap) return "base-noedit";
757 else if (wd->char_linewrap) return "base-noedit-charwrap";
758 else return "base-nowrap-noedit";
766 _str_append(char *str, const char *txt, int *len, int *alloc)
768 int txt_len = strlen(txt);
770 if (txt_len <= 0) return str;
771 if ((*len + txt_len) >= *alloc)
776 alloc2 = *alloc + txt_len + 128;
777 str2 = realloc(str, alloc2);
778 if (!str2) return str;
782 strcpy(str + *len, txt);
788 _strncpy(char* dest, const char* src, size_t count)
792 ERR( "dest is NULL" );
797 ERR( "src is NULL" );
802 ERR( "count is smaller than 0" );
806 return strncpy( dest, src, count );
810 _mkup_to_text(const char *mkup)
813 int str_len = 0, str_alloc = 0;
815 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
817 if (!mkup) return NULL;
819 tag_start = tag_end = esc_start = esc_end = NULL;
824 if (((p!=NULL)&&(*p == 0)) ||
825 (tag_end) || (esc_end) ||
826 (tag_start) || (esc_start))
832 ttag = malloc(tag_end - tag_start);
835 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
836 ttag[tag_end - tag_start - 1] = 0;
837 if (!strcmp(ttag, "br"))
838 str = _str_append(str, "\n", &str_len, &str_alloc);
839 else if (!strcmp(ttag, "\n"))
840 str = _str_append(str, "\n", &str_len, &str_alloc);
841 else if (!strcmp(ttag, "\\n"))
842 str = _str_append(str, "\n", &str_len, &str_alloc);
843 else if (!strcmp(ttag, "\t"))
844 str = _str_append(str, "\t", &str_len, &str_alloc);
845 else if (!strcmp(ttag, "\\t"))
846 str = _str_append(str, "\t", &str_len, &str_alloc);
849 tag_start = tag_end = NULL;
853 ts = malloc(esc_end - esc_start + 1);
857 _strncpy(ts, esc_start, esc_end - esc_start);
858 ts[esc_end - esc_start] = 0;
859 esc = evas_textblock_escape_string_get(ts);
861 str = _str_append(str, esc, &str_len, &str_alloc);
864 esc_start = esc_end = NULL;
866 else if ((p!=NULL)&&(*p == 0))
868 ts = malloc(p - s + 1);
871 _strncpy(ts, s, p - s);
873 str = _str_append(str, ts, &str_len, &str_alloc);
879 if ((p!=NULL)&&(*p == '<'))
885 ts = malloc(p - s + 1);
888 _strncpy(ts, s, p - s);
890 str = _str_append(str, ts, &str_len, &str_alloc);
896 else if ((p!=NULL)&&(*p == '>'))
904 else if ((p!=NULL)&&(*p == '&'))
910 ts = malloc(p - s + 1);
913 _strncpy(ts, s, p - s);
915 str = _str_append(str, ts, &str_len, &str_alloc);
921 else if ((p!=NULL)&&(*p == ';'))
935 _entry_length_get(Evas_Object *obj)
938 const char *str = elm_entry_entry_get(obj);
941 char *plain_str = _mkup_to_text(str);
942 if (!plain_str) return 0;
944 len = strlen(plain_str);
951 _text_to_mkup(const char *text)
954 int str_len = 0, str_alloc = 0;
955 int ch, pos = 0, pos2 = 0;
957 if (!text) return NULL;
961 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
962 if ((ch <= 0) || (pos2 <= 0)) break;
964 str = _str_append(str, "<br>", &str_len, &str_alloc);
966 str = _str_append(str, "<\t>", &str_len, &str_alloc);
968 str = _str_append(str, "<", &str_len, &str_alloc);
970 str = _str_append(str, ">", &str_len, &str_alloc);
972 str = _str_append(str, "&", &str_len, &str_alloc);
977 _strncpy(tstr, text + pos, pos2 - pos);
978 tstr[pos2 - pos] = 0;
979 str = _str_append(str, tstr, &str_len, &str_alloc);
986 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
988 Widget_Data *wd = elm_widget_data_get(data);
990 wd->changed = EINA_TRUE;
992 if (wd->text) eina_stringshare_del(wd->text);
994 _check_enable_returnkey(data);
995 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
999 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1001 Widget_Data *wd = elm_widget_data_get(data);
1005 EINA_LIST_FOREACH(entries, l, entry)
1007 if (entry != data) elm_entry_select_none(entry);
1009 wd->have_selection = EINA_TRUE;
1010 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1011 if (wd->sel_notify_handler)
1013 char *txt = _mkup_to_text(elm_entry_selection_get(data));
1017 #ifdef HAVE_ELEMENTARY_X
1020 top = elm_widget_top_get(data);
1021 if ((top) && (elm_win_xwindow_get(top)))
1022 ecore_x_selection_primary_set(elm_win_xwindow_get(top), txt,
1031 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1033 Widget_Data *wd = elm_widget_data_get(data);
1035 wd->have_selection = EINA_TRUE;
1036 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1037 if (wd->sel_notify_handler)
1039 char *txt = _mkup_to_text(elm_entry_selection_get(data));
1043 #ifdef HAVE_ELEMENTARY_X
1046 top = elm_widget_top_get(data);
1047 if ((top) && (elm_win_xwindow_get(top)))
1048 ecore_x_selection_primary_set(elm_win_xwindow_get(top), txt,
1057 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1059 Widget_Data *wd = elm_widget_data_get(data);
1061 if (!wd->have_selection) return;
1062 wd->have_selection = EINA_FALSE;
1063 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1064 if (wd->sel_notify_handler)
1068 #ifdef HAVE_ELEMENTARY_X
1071 top = elm_widget_top_get(data);
1072 if ((top) && (elm_win_xwindow_get(top)))
1076 t = _mkup_to_text(wd->cut_sel);
1079 ecore_x_selection_primary_set(elm_win_xwindow_get(top),
1085 eina_stringshare_del(wd->cut_sel);
1090 #ifdef HAVE_ELEMENTARY_X
1093 top = elm_widget_top_get(data);
1094 if ((top) && (elm_win_xwindow_get(top)))
1095 ecore_x_selection_primary_clear();
1102 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1104 Widget_Data *wd = elm_widget_data_get(data);
1106 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1107 if (wd->sel_notify_handler)
1109 #ifdef HAVE_ELEMENTARY_X
1112 top = elm_widget_top_get(data);
1113 if ((top) && (elm_win_xwindow_get(top)))
1115 wd->selection_asked = EINA_TRUE;
1116 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_MARKUP, data);
1123 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1125 Widget_Data *wd = elm_widget_data_get(data);
1127 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1128 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_MARKUP,
1129 elm_entry_selection_get(data));
1133 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1135 Widget_Data *wd = elm_widget_data_get(data);
1137 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1138 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_MARKUP,
1139 elm_entry_selection_get(data));
1140 edje_object_part_text_insert(wd->ent, "elm.text", "");
1141 wd->changed = EINA_TRUE;
1146 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1148 Widget_Data *wd = elm_widget_data_get(data);
1149 Evas_Coord cx, cy, cw, ch;
1151 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1152 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1153 &cx, &cy, &cw, &ch);
1154 if (!wd->deferred_recalc_job)
1155 elm_widget_show_region_set(data, cx, cy, cw, ch);
1158 wd->deferred_cur = EINA_TRUE;
1167 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1169 Widget_Data *wd = elm_widget_data_get(data);
1174 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1176 Widget_Data *wd = elm_widget_data_get(data);
1177 Elm_Entry_Anchor_Info ei;
1178 char *buf2, *p, *p2, *n;
1180 p = strrchr(emission, ',');
1183 const Eina_List *geoms;
1187 while (p2 >= emission)
1189 if (*p2 == ',') break;
1193 buf2 = alloca(5 + p - p2);
1194 strncpy(buf2, p2, p - p2);
1197 ei.button = atoi(buf2);
1198 ei.x = ei.y = ei.w = ei.h = 0;
1200 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1203 Evas_Textblock_Rectangle *r;
1205 Evas_Coord px, py, x, y;
1207 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1208 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1209 EINA_LIST_FOREACH(geoms, l, r)
1211 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1212 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1223 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1228 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1230 Widget_Data *wd = elm_widget_data_get(data);
1235 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1237 Widget_Data *wd = elm_widget_data_get(data);
1242 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1244 Widget_Data *wd = elm_widget_data_get(data);
1249 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1251 Widget_Data *wd = elm_widget_data_get(data);
1253 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1257 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1259 Widget_Data *wd = elm_widget_data_get(data);
1261 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1265 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1267 Widget_Data *wd = elm_widget_data_get(data);
1269 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1273 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1275 Widget_Data *wd = elm_widget_data_get(data);
1277 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1280 #ifdef HAVE_ELEMENTARY_X
1282 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1284 Widget_Data *wd = elm_widget_data_get(data);
1285 Ecore_X_Event_Selection_Notify *ev = event;
1287 if (!wd->selection_asked) return 1;
1288 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1289 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1291 Ecore_X_Selection_Data_Text *text_data;
1293 text_data = ev->data;
1294 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1296 if (text_data->text)
1298 char *txt = _text_to_mkup(text_data->text);
1302 elm_entry_entry_insert(data, txt);
1307 wd->selection_asked = EINA_FALSE;
1309 return ECORE_CALLBACK_PASS_ON;
1313 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1316 Widget_Data *wd = elm_widget_data_get(data);
1317 Ecore_X_Event_Selection_Clear *ev = event;
1319 if (!wd->have_selection) return 1;
1320 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1321 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1323 elm_entry_select_none(data);
1326 return ECORE_CALLBACK_PASS_ON;
1330 static Evas_Object *
1331 _get_item(void *data, Evas_Object *edje, const char *part, const char *item)
1333 Widget_Data *wd = elm_widget_data_get(data);
1336 Elm_Entry_Item_Provider *ip;
1339 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1341 o = ip->func(ip->data, data, item);
1344 o = edje_object_add(evas_object_evas_get(data));
1345 if (!strncmp(item, "emoticon/", 9))
1346 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1348 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1353 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1355 char *curlocater, *starttag, *endtag;
1356 int firstindex = 0, foundflag = -1;
1358 curlocater = strstr(oldstring, key);
1361 starttag = curlocater;
1362 endtag = curlocater + strlen(key);
1363 if (endtag == NULL || *endtag != '=')
1369 firstindex = abs(oldstring - curlocater);
1370 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1371 *value = (char*)oldstring + firstindex;
1373 while (oldstring != starttag)
1375 if (*starttag == '>')
1380 if (*starttag == '<')
1384 if (starttag == NULL) break;
1387 while (NULL != endtag)
1398 if (endtag == NULL) break;
1401 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1411 if (foundflag == 1) return 0;
1417 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1419 const char *srcstring = NULL;
1420 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1421 char *curlocater, *replocater;
1422 char *starttag, *endtag;
1423 int tagtxtlen = 0, insertflag = 0;
1425 srcstring = eina_strbuf_string_get(srcbuf);
1426 curlocater = strstr(srcstring, key);
1428 if (curlocater == NULL)
1436 starttag = strchr(srcstring, '<');
1437 endtag = strchr(srcstring, '>');
1438 tagtxtlen = endtag - starttag;
1439 if (tagtxtlen <= 0) tagtxtlen = 0;
1440 if (starttag < curlocater && curlocater < endtag) break;
1441 if (endtag != NULL && endtag+1 != NULL)
1442 srcstring = endtag+1;
1445 } while (strlen(srcstring) > 1);
1447 if (starttag && endtag && tagtxtlen > strlen(key))
1449 repbuf = eina_strbuf_new();
1450 diffbuf = eina_strbuf_new();
1451 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1452 srcstring = eina_strbuf_string_get(repbuf);
1453 curlocater = strstr(srcstring, key);
1455 if (curlocater != NULL)
1457 replocater = curlocater + strlen(key) + 1;
1459 while (*replocater == ' ' || *replocater == '=')
1464 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1467 if (replocater-curlocater > strlen(key)+1)
1470 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1479 eina_strbuf_reset(repbuf);
1487 if (repbuf == NULL) repbuf = eina_strbuf_new();
1488 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1492 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1493 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1499 eina_strbuf_prepend(diffbuf, "<");
1500 eina_strbuf_append(diffbuf, ">");
1501 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1505 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1506 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1510 if (repbuf) eina_strbuf_free(repbuf);
1511 if (diffbuf) eina_strbuf_free(diffbuf);
1517 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1519 Eina_Strbuf *sharebuf = NULL;
1521 sharebuf = eina_strbuf_new();
1522 eina_strbuf_append(sharebuf, *srcstring);
1523 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1524 eina_stringshare_del(*srcstring);
1525 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1526 eina_strbuf_free(sharebuf);
1532 _is_width_over(Evas_Object *obj)
1534 Evas_Coord x, y, w, h;
1535 Evas_Coord vx, vy, vw, vh;
1536 Widget_Data *wd = elm_widget_data_get(obj);
1540 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1542 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1544 if (x >= 0 && y >= 0)
1547 if (4 < wd->wrap_w && w > wd->wrap_w)
1554 _reverse_ellipsis_entry(Evas_Object *obj)
1556 Widget_Data *wd = elm_widget_data_get(obj);
1557 int cur_fontsize = 0;
1558 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1559 char **kvalue = NULL;
1560 const char *minfont, *deffont, *maxfont;
1561 const char *ellipsis_string = "...";
1562 int minfontsize, maxfontsize, minshowcount;
1564 minshowcount = strlen(ellipsis_string) + 1;
1565 minfont = edje_object_data_get(wd->ent, "min_font_size");
1566 if (minfont) minfontsize = atoi(minfont);
1567 else minfontsize = 1;
1568 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1569 if (maxfont) maxfontsize = atoi(maxfont);
1570 else maxfontsize = 1;
1571 deffont = edje_object_data_get(wd->ent, "default_font_size");
1572 if (deffont) cur_fontsize = atoi(deffont);
1573 else cur_fontsize = 1;
1574 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1575 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1577 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1579 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1582 txtbuf = eina_strbuf_new();
1583 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1585 if (cur_fontsize >= atoi(deffont))
1587 if (txtbuf) eina_strbuf_free(txtbuf);
1591 if (_is_width_over(obj) != 1)
1593 int rev_fontsize = cur_fontsize;
1597 if (rev_fontsize > atoi(deffont))
1600 if (fontbuf != NULL)
1602 eina_strbuf_free(fontbuf);
1605 fontbuf = eina_strbuf_new();
1606 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1607 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1608 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1610 eina_strbuf_free(fontbuf);
1612 } while (_is_width_over(obj) != 1);
1614 while (_is_width_over(obj))
1617 if (rev_fontsize < atoi(deffont))
1620 if (fontbuf != NULL)
1622 eina_strbuf_free(fontbuf);
1625 fontbuf = eina_strbuf_new();
1626 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1627 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1628 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1629 eina_strbuf_free(fontbuf);
1634 if (txtbuf) eina_strbuf_free(txtbuf);
1640 _ellipsis_entry_to_width(Evas_Object *obj)
1642 Widget_Data *wd = elm_widget_data_get(obj);
1643 int cur_fontsize = 0, len, jumpcount;
1644 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1645 char **kvalue = NULL;
1646 const char *minfont, *deffont, *maxfont;
1647 const char *ellipsis_string = "...";
1648 int minfontsize, maxfontsize, minshowcount;
1649 int i, tagend, cur_len;
1652 minshowcount = strlen(ellipsis_string) + 1;
1653 minfont = edje_object_data_get(wd->ent, "min_font_size");
1654 if (minfont) minfontsize = atoi(minfont);
1655 else minfontsize = 1;
1656 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1657 if (maxfont) maxfontsize = atoi(maxfont);
1658 else maxfontsize = 1;
1659 deffont = edje_object_data_get(wd->ent, "default_font_size");
1660 if (deffont) cur_fontsize = atoi(deffont);
1661 else cur_fontsize = 1;
1662 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1663 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1665 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1667 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1670 txtbuf = eina_strbuf_new();
1671 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1673 while (_is_width_over(obj))
1675 if (wd->ellipsis_threshold == 0)
1676 wd->ellipsis_threshold = _entry_length_get(obj);
1677 if (cur_fontsize > minfontsize)
1680 if (fontbuf != NULL)
1682 eina_strbuf_free(fontbuf);
1685 fontbuf = eina_strbuf_new();
1686 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1687 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1688 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1689 eina_strbuf_free(fontbuf);
1691 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1695 len = _entry_length_get(obj);
1696 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1697 cur_len = strlen(cur_str);
1699 for (i = 0; i < len; i++)
1701 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1702 cur_str[i+1] != '<')
1709 while (jumpcount < len-strlen(ellipsis_string))
1711 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1715 eina_strbuf_free(txtbuf);
1718 txtbuf = eina_strbuf_new();
1719 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1720 eina_strbuf_append(txtbuf, ellipsis_string);
1721 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1722 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1723 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1725 if (_is_width_over(obj))
1733 if (txtbuf) eina_strbuf_free(txtbuf);
1738 static int _textinput_control_function(void *data,void *input_data)
1740 /*calculate character count*/
1741 Widget_Data *wd = elm_widget_data_get(data);
1744 size_t insert_text_len=0;
1745 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1747 size_t remain_bytes;
1750 byte_len = strlen(text);/*no of bytes*/
1751 remain_bytes = wd->max_no_of_bytes-byte_len;
1752 sprintf(buf,"%d",remain_bytes);
1753 edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1756 insert_text = (char *)input_data;
1757 insert_text_len = strlen(insert_text);
1758 if(remain_bytes<insert_text_len)
1760 evas_object_smart_callback_call(input_data, "maxlength,reached", NULL);
1763 if(byte_len>=wd->max_no_of_bytes)
1765 evas_object_smart_callback_call(input_data, "maxlength,reached", NULL);
1774 * This adds an entry to @p parent object.
1776 * @param parent The parent object
1777 * @return The new object or NULL if it cannot be created
1782 elm_entry_add(Evas_Object *parent)
1784 Evas_Object *obj, *top;
1788 wd = ELM_NEW(Widget_Data);
1789 e = evas_object_evas_get(parent);
1790 wd->bgcolor = EINA_FALSE;
1791 wd->bg = evas_object_rectangle_add(e);
1792 evas_object_color_set(wd->bg, 0, 0, 0, 0);
1793 obj = elm_widget_add(e);
1794 ELM_SET_WIDTYPE(widtype, "entry");
1795 elm_widget_type_set(obj, "entry");
1796 elm_widget_sub_object_add(parent, obj);
1797 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1798 elm_widget_data_set(obj, wd);
1799 elm_widget_del_hook_set(obj, _del_hook);
1800 elm_widget_theme_hook_set(obj, _theme_hook);
1801 elm_widget_disable_hook_set(obj, _disable_hook);
1802 elm_widget_can_focus_set(obj, 1);
1804 wd->linewrap = EINA_TRUE;
1805 wd->ellipsis = EINA_FALSE;
1806 wd->char_linewrap= EINA_FALSE;
1807 wd->editable = EINA_TRUE;
1808 wd->disabled = EINA_FALSE;
1809 wd->context_menu = EINA_TRUE;
1811 wd->ellipsis_threshold = 0;
1813 wd->ent = edje_object_add(e);
1814 edje_object_item_provider_set(wd->ent, _get_item, obj);
1815 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
1816 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
1817 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
1819 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
1821 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
1824 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
1825 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
1826 _signal_entry_changed, obj);
1827 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
1828 _signal_selection_start, obj);
1829 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
1830 _signal_selection_changed, obj);
1831 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
1832 _signal_selection_cleared, obj);
1833 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
1834 _signal_entry_paste_request, obj);
1835 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
1836 _signal_entry_copy_notify, obj);
1837 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
1838 _signal_entry_cut_notify, obj);
1839 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
1840 _signal_cursor_changed, obj);
1841 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
1842 _signal_anchor_down, obj);
1843 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
1844 _signal_anchor_up, obj);
1845 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
1846 _signal_anchor_move, obj);
1847 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
1848 _signal_anchor_in, obj);
1849 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
1850 _signal_anchor_out, obj);
1851 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
1852 _signal_key_enter, obj);
1853 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
1854 _signal_mouse_down, obj);
1855 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
1856 _signal_mouse_up, obj);
1857 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
1858 _signal_mouse_double, obj);
1859 edje_object_part_text_set(wd->ent, "elm.text", "");
1860 elm_widget_resize_object_set(obj, wd->ent);
1863 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
1865 #ifdef HAVE_ELEMENTARY_X
1866 top = elm_widget_top_get(obj);
1867 if ((top) && (elm_win_xwindow_get(top)))
1869 wd->sel_notify_handler =
1870 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
1871 _event_selection_notify, obj);
1872 wd->sel_clear_handler =
1873 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
1874 _event_selection_clear, obj);
1878 entries = eina_list_prepend(entries, obj);
1880 // module - find module for entry
1881 wd->api = _module(obj);
1882 // if found - hook in
1883 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
1885 // TODO: convert Elementary to subclassing of Evas_Smart_Class
1886 // TODO: and save some bytes, making descriptions per-class and not instance!
1887 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1891 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
1893 ELM_CHECK_WIDTYPE(obj, widtype);
1894 Widget_Data *wd = elm_widget_data_get(obj);
1896 ext_mod->cancel = _cancel;
1897 ext_mod->copy = _copy;
1898 ext_mod->cut = _cut;
1899 ext_mod->paste = _paste;
1900 ext_mod->select = _select;
1901 ext_mod->selectall = NULL; /* to be implemented*/
1902 ext_mod->ent = wd->ent;
1903 ext_mod->items = wd->items;
1904 ext_mod->longpress_timer = wd->longpress_timer;
1905 ext_mod->editable = wd->editable;
1906 ext_mod->have_selection = wd->have_selection;
1907 ext_mod->password = wd->password;
1908 ext_mod->selmode = wd->selmode;
1912 * This sets the entry object not to line wrap. All input will
1913 * be on a single line, and the entry box will extend with user input.
1915 * @param obj The entry object
1916 * @param single_line If true, the text in the entry
1917 * will be on a single line.
1922 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
1924 ELM_CHECK_WIDTYPE(obj, widtype);
1925 Widget_Data *wd = elm_widget_data_get(obj);
1928 if (wd->single_line == single_line) return;
1929 wd->single_line = single_line;
1930 wd->linewrap = EINA_FALSE;
1931 wd->char_linewrap = EINA_FALSE;
1932 t = eina_stringshare_add(elm_entry_entry_get(obj));
1933 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
1934 elm_entry_entry_set(obj, t);
1935 eina_stringshare_del(t);
1940 * This returns true if the entry has been set to single line mode.
1941 * See also elm_entry_single_line_set().
1943 * @param obj The entry object
1944 * @return single_line If true, the text in the entry is set to display
1950 elm_entry_single_line_get(const Evas_Object *obj)
1952 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1953 Widget_Data *wd = elm_widget_data_get(obj);
1954 if (!wd) return EINA_FALSE;
1955 return wd->single_line;
1959 * This set's the maximum bytes that can be added in entry.
1961 * @param obj The entry object
1962 * @param max_no_of_bytes Maximum number of bytes entry can have.
1967 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
1969 Widget_Data *wd = elm_widget_data_get(obj);
1971 wd->max_no_of_bytes = max_no_of_bytes;
1972 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
1973 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
1978 * This sets the entry object to password mode. All text entered
1979 * and/or displayed within the widget will be replaced with asterisks (*).
1981 * @param obj The entry object
1982 * @param password If true, password mode is enabled.
1987 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
1989 ELM_CHECK_WIDTYPE(obj, widtype);
1990 Widget_Data *wd = elm_widget_data_get(obj);
1993 if (wd->password == password) return;
1994 wd->password = password;
1995 wd->show_last_character = EINA_FALSE;
1996 wd->single_line = EINA_TRUE;
1997 wd->linewrap = EINA_FALSE;
1998 wd->char_linewrap = EINA_FALSE;
1999 t = eina_stringshare_add(elm_entry_entry_get(obj));
2000 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2001 elm_entry_entry_set(obj, t);
2002 eina_stringshare_del(t);
2007 * This set's the entry in password mode with out masking the last character entered by user,
2008 * and later masking the character after 2 seconds.
2010 * @param obj The entry object
2011 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2017 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2019 Widget_Data *wd = elm_widget_data_get(obj);
2022 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2023 wd->show_last_character = show_last_character;
2024 wd->password = show_last_character;
2025 wd->single_line = EINA_TRUE;
2026 wd->linewrap = EINA_FALSE;
2027 wd->char_linewrap = EINA_FALSE;
2028 t = eina_stringshare_add(elm_entry_entry_get(obj));
2029 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2030 elm_entry_entry_set(obj, t);
2031 eina_stringshare_del(t);
2036 * This returns whether password mode is enabled.
2037 * See also elm_entry_password_set().
2039 * @param obj The entry object
2040 * @return If true, the entry is set to display all characters
2046 elm_entry_password_get(const Evas_Object *obj)
2048 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2049 Widget_Data *wd = elm_widget_data_get(obj);
2050 if (!wd) return EINA_FALSE;
2051 return wd->password;
2055 * This sets the text displayed within the entry to @p entry.
2057 * @param obj The entry object
2058 * @param entry The text to be displayed
2063 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2065 ELM_CHECK_WIDTYPE(obj, widtype);
2066 Widget_Data *wd = elm_widget_data_get(obj);
2068 if (!entry) entry = "";
2069 if(wd->max_no_of_bytes)
2071 int len = strlen(entry);
2072 if(len > wd->max_no_of_bytes)
2074 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2078 edje_object_part_text_set(wd->ent, "elm.text", entry);
2079 if (wd->text) eina_stringshare_del(wd->text);
2081 wd->changed = EINA_TRUE;
2086 * This returns the text currently shown in object @p entry.
2087 * See also elm_entry_entry_set().
2089 * @param obj The entry object
2090 * @return The currently displayed text or NULL on failure
2095 elm_entry_entry_get(const Evas_Object *obj)
2097 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2098 Widget_Data *wd = elm_widget_data_get(obj);
2100 if (!wd) return NULL;
2101 if (wd->text) return wd->text;
2102 text = edje_object_part_text_get(wd->ent, "elm.text");
2105 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2108 eina_stringshare_replace(&wd->text, text);
2113 * This returns all selected text within the entry.
2115 * @param obj The entry object
2116 * @return The selected text within the entry or NULL on failure
2121 elm_entry_selection_get(const Evas_Object *obj)
2123 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2124 Widget_Data *wd = elm_widget_data_get(obj);
2125 if (!wd) return NULL;
2126 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2130 * This inserts text in @p entry at the beginning of the entry
2133 * @param obj The entry object
2134 * @param entry The text to insert
2139 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2141 ELM_CHECK_WIDTYPE(obj, widtype);
2142 Widget_Data *wd = elm_widget_data_get(obj);
2144 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2145 wd->changed = EINA_TRUE;
2150 * This enables word line wrapping in the entry object. It is the opposite
2151 * of elm_entry_single_line_set(). Additionally, setting this disables
2152 * character line wrapping.
2153 * See also elm_entry_line_char_wrap_set().
2155 * @param obj The entry object
2156 * @param wrap If true, the entry will be wrapped once it reaches the end
2157 * of the object. Wrapping will occur at the end of the word before the end of the
2163 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2165 ELM_CHECK_WIDTYPE(obj, widtype);
2166 Widget_Data *wd = elm_widget_data_get(obj);
2169 if (wd->linewrap == wrap) return;
2170 wd->linewrap = wrap;
2172 wd->char_linewrap = EINA_FALSE;
2173 t = eina_stringshare_add(elm_entry_entry_get(obj));
2174 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2175 elm_entry_entry_set(obj, t);
2176 eina_stringshare_del(t);
2181 * Set wrap width of the entry
2183 * @param obj The entry object
2184 * @param w The wrap width in pixels at a minimum where words need to wrap
2188 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2190 Widget_Data *wd = elm_widget_data_get(obj);
2191 if (wd->wrap_w == w) return;
2197 * get wrap width of the entry
2199 * @param obj The entry object
2200 * @return The wrap width in pixels at a minimum where words need to wrap
2204 elm_entry_wrap_width_get(const Evas_Object *obj)
2206 Widget_Data *wd = elm_widget_data_get(obj);
2211 * This enables character line wrapping in the entry object. It is the opposite
2212 * of elm_entry_single_line_set(). Additionally, setting this disables
2213 * word line wrapping.
2214 * See also elm_entry_line_wrap_set().
2216 * @param obj The entry object
2217 * @param wrap If true, the entry will be wrapped once it reaches the end
2218 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2223 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2225 ELM_CHECK_WIDTYPE(obj, widtype);
2226 Widget_Data *wd = elm_widget_data_get(obj);
2229 if (wd->char_linewrap == wrap) return;
2230 wd->char_linewrap = wrap;
2231 if(wd->char_linewrap)
2232 wd->linewrap = EINA_FALSE;
2233 t = eina_stringshare_add(elm_entry_entry_get(obj));
2234 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2235 elm_entry_entry_set(obj, t);
2236 eina_stringshare_del(t);
2241 * This sets the editable attribute of the entry.
2243 * @param obj The entry object
2244 * @param editable If true, the entry will be editable by the user.
2245 * If false, it will be set to the disabled state.
2250 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2252 ELM_CHECK_WIDTYPE(obj, widtype);
2253 Widget_Data *wd = elm_widget_data_get(obj);
2256 if (wd->editable == editable) return;
2257 wd->editable = editable;
2258 t = eina_stringshare_add(elm_entry_entry_get(obj));
2259 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2260 elm_entry_entry_set(obj, t);
2261 eina_stringshare_del(t);
2266 * This gets the editable attribute of the entry.
2267 * See also elm_entry_editable_set().
2269 * @param obj The entry object
2270 * @return If true, the entry is editable by the user.
2271 * If false, it is not editable by the user
2276 elm_entry_editable_get(const Evas_Object *obj)
2278 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2279 Widget_Data *wd = elm_widget_data_get(obj);
2280 if (!wd) return EINA_FALSE;
2281 return wd->editable;
2285 * This drops any existing text selection within the entry.
2287 * @param obj The entry object
2292 elm_entry_select_none(Evas_Object *obj)
2294 ELM_CHECK_WIDTYPE(obj, widtype);
2295 Widget_Data *wd = elm_widget_data_get(obj);
2299 wd->selmode = EINA_FALSE;
2300 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
2301 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2303 wd->have_selection = EINA_FALSE;
2304 edje_object_part_text_select_none(wd->ent, "elm.text");
2308 * This selects all text within the entry.
2310 * @param obj The entry object
2315 elm_entry_select_all(Evas_Object *obj)
2317 ELM_CHECK_WIDTYPE(obj, widtype);
2318 Widget_Data *wd = elm_widget_data_get(obj);
2322 wd->selmode = EINA_FALSE;
2323 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
2324 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2326 wd->have_selection = EINA_TRUE;
2327 edje_object_part_text_select_all(wd->ent, "elm.text");
2331 * This moves the cursor one place to the right within the entry.
2333 * @param obj The entry object
2334 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2339 elm_entry_cursor_next(Evas_Object *obj)
2341 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2342 Widget_Data *wd = elm_widget_data_get(obj);
2343 if (!wd) return EINA_FALSE;
2344 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2348 * This moves the cursor one place to the left within the entry.
2350 * @param obj The entry object
2351 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2356 elm_entry_cursor_prev(Evas_Object *obj)
2358 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2359 Widget_Data *wd = elm_widget_data_get(obj);
2360 if (!wd) return EINA_FALSE;
2361 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2365 * This moves the cursor one line up within the entry.
2367 * @param obj The entry object
2368 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2373 elm_entry_cursor_up(Evas_Object *obj)
2375 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2376 Widget_Data *wd = elm_widget_data_get(obj);
2377 if (!wd) return EINA_FALSE;
2378 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2382 * This moves the cursor one line down within the entry.
2384 * @param obj The entry object
2385 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2390 elm_entry_cursor_down(Evas_Object *obj)
2392 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2393 Widget_Data *wd = elm_widget_data_get(obj);
2394 if (!wd) return EINA_FALSE;
2395 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2399 * This moves the cursor to the beginning of the entry.
2401 * @param obj The entry object
2406 elm_entry_cursor_begin_set(Evas_Object *obj)
2408 ELM_CHECK_WIDTYPE(obj, widtype);
2409 Widget_Data *wd = elm_widget_data_get(obj);
2411 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2415 * This moves the cursor to the end of the entry.
2417 * @param obj The entry object
2422 elm_entry_cursor_end_set(Evas_Object *obj)
2424 ELM_CHECK_WIDTYPE(obj, widtype);
2425 Widget_Data *wd = elm_widget_data_get(obj);
2427 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2431 * This moves the cursor to the beginning of the current line.
2433 * @param obj The entry object
2438 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2440 ELM_CHECK_WIDTYPE(obj, widtype);
2441 Widget_Data *wd = elm_widget_data_get(obj);
2443 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2447 * This moves the cursor to the end of the current line.
2449 * @param obj The entry object
2454 elm_entry_cursor_line_end_set(Evas_Object *obj)
2456 ELM_CHECK_WIDTYPE(obj, widtype);
2457 Widget_Data *wd = elm_widget_data_get(obj);
2459 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2463 * This begins a selection within the entry as though
2464 * the user were holding down the mouse button to make a selection.
2466 * @param obj The entry object
2471 elm_entry_cursor_selection_begin(Evas_Object *obj)
2473 ELM_CHECK_WIDTYPE(obj, widtype);
2474 Widget_Data *wd = elm_widget_data_get(obj);
2476 edje_object_part_text_select_begin(wd->ent, "elm.text");
2480 * This ends a selection within the entry as though
2481 * the user had just released the mouse button while making a selection.
2483 * @param obj The entry object
2488 elm_entry_cursor_selection_end(Evas_Object *obj)
2490 ELM_CHECK_WIDTYPE(obj, widtype);
2491 Widget_Data *wd = elm_widget_data_get(obj);
2493 edje_object_part_text_select_extend(wd->ent, "elm.text");
2497 * TODO: fill this in
2499 * @param obj The entry object
2500 * @return TODO: fill this in
2505 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2507 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2508 Widget_Data *wd = elm_widget_data_get(obj);
2509 if (!wd) return EINA_FALSE;
2510 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2514 * This returns whether the cursor is visible.
2516 * @param obj The entry object
2517 * @return If true, the cursor is visible.
2522 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2524 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2525 Widget_Data *wd = elm_widget_data_get(obj);
2526 if (!wd) return EINA_FALSE;
2527 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2531 * TODO: fill this in
2533 * @param obj The entry object
2534 * @return TODO: fill this in
2539 elm_entry_cursor_content_get(const Evas_Object *obj)
2541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2542 Widget_Data *wd = elm_widget_data_get(obj);
2543 if (!wd) return NULL;
2544 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2548 * This executes a "cut" action on the selected text in the entry.
2550 * @param obj The entry object
2555 elm_entry_selection_cut(Evas_Object *obj)
2557 ELM_CHECK_WIDTYPE(obj, widtype);
2558 Widget_Data *wd = elm_widget_data_get(obj);
2560 _cut(obj, NULL, NULL);
2564 * This executes a "copy" action on the selected text in the entry.
2566 * @param obj The entry object
2571 elm_entry_selection_copy(Evas_Object *obj)
2573 ELM_CHECK_WIDTYPE(obj, widtype);
2574 Widget_Data *wd = elm_widget_data_get(obj);
2576 _copy(obj, NULL, NULL);
2580 * This executes a "paste" action in the entry.
2582 * @param obj The entry object
2587 elm_entry_selection_paste(Evas_Object *obj)
2589 ELM_CHECK_WIDTYPE(obj, widtype);
2590 Widget_Data *wd = elm_widget_data_get(obj);
2592 _paste(obj, NULL, NULL);
2596 * This clears and frees the items in a entry's contextual (right click) menu.
2598 * @param obj The entry object
2603 elm_entry_context_menu_clear(Evas_Object *obj)
2605 ELM_CHECK_WIDTYPE(obj, widtype);
2606 Widget_Data *wd = elm_widget_data_get(obj);
2607 Elm_Entry_Context_Menu_Item *it;
2609 EINA_LIST_FREE(wd->items, it)
2611 eina_stringshare_del(it->label);
2612 eina_stringshare_del(it->icon_file);
2613 eina_stringshare_del(it->icon_group);
2619 * This adds an item to the entry's contextual menu.
2621 * @param obj The entry object
2622 * @param label The item's text label
2623 * @param icon_file The item's icon file
2624 * @param icon_type The item's icon type
2625 * @param func The callback to execute when the item is clicked
2626 * @param data The data to associate with the item for related functions
2631 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)
2633 ELM_CHECK_WIDTYPE(obj, widtype);
2634 Widget_Data *wd = elm_widget_data_get(obj);
2635 Elm_Entry_Context_Menu_Item *it;
2637 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2639 wd->items = eina_list_append(wd->items, it);
2641 it->label = eina_stringshare_add(label);
2642 it->icon_file = eina_stringshare_add(icon_file);
2643 it->icon_type = icon_type;
2645 it->data = (void *)data;
2649 * This disables the entry's contextual (right click) menu.
2651 * @param obj The entry object
2652 * @param disabled If true, the menu is disabled
2657 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2659 ELM_CHECK_WIDTYPE(obj, widtype);
2660 Widget_Data *wd = elm_widget_data_get(obj);
2662 if (wd->context_menu == !disabled) return;
2663 wd->context_menu = !disabled;
2667 * This returns whether the entry's contextual (right click) menu is disabled.
2669 * @param obj The entry object
2670 * @return If true, the menu is disabled
2675 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2677 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2678 Widget_Data *wd = elm_widget_data_get(obj);
2679 if (!wd) return EINA_FALSE;
2680 return !wd->context_menu;
2684 * This appends a custom item provider to the list for that entry
2686 * This appends the given callback. The list is walked from beginning to end
2687 * with each function called given the item href string in the text. If the
2688 * function returns an object handle other than NULL (it should create an
2689 * and object to do this), then this object is used to replace that item. If
2690 * not the next provider is called until one provides an item object, or the
2691 * default provider in entry does.
2693 * @param obj The entry object
2694 * @param func The function called to provide the item object
2695 * @param data The data passed to @p func
2700 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2702 ELM_CHECK_WIDTYPE(obj, widtype);
2703 Widget_Data *wd = elm_widget_data_get(obj);
2706 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2710 wd->item_providers = eina_list_append(wd->item_providers, ip);
2714 * This prepends a custom item provider to the list for that entry
2716 * This prepends the given callback. See elm_entry_item_provider_append() for
2719 * @param obj The entry object
2720 * @param func The function called to provide the item object
2721 * @param data The data passed to @p func
2726 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2728 ELM_CHECK_WIDTYPE(obj, widtype);
2729 Widget_Data *wd = elm_widget_data_get(obj);
2732 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2736 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2740 * This removes a custom item provider to the list for that entry
2742 * This removes the given callback. See elm_entry_item_provider_append() for
2745 * @param obj The entry object
2746 * @param func The function called to provide the item object
2747 * @param data The data passed to @p func
2752 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2754 ELM_CHECK_WIDTYPE(obj, widtype);
2755 Widget_Data *wd = elm_widget_data_get(obj);
2757 Elm_Entry_Item_Provider *ip;
2760 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2762 if ((ip->func == func) && (ip->data == data))
2764 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2772 * This converts a markup (HTML-like) string into UTF-8.
2774 * @param s The string (in markup) to be converted
2775 * @return The converted string (in UTF-8)
2780 elm_entry_markup_to_utf8(const char *s)
2782 char *ss = _mkup_to_text(s);
2783 if (!ss) ss = strdup("");
2788 * This converts a UTF-8 string into markup (HTML-like).
2790 * @param s The string (in UTF-8) to be converted
2791 * @return The converted string (in markup)
2796 elm_entry_utf8_to_markup(const char *s)
2798 char *ss = _text_to_mkup(s);
2799 if (!ss) ss = strdup("");
2804 * Get the input method context in the entry widget
2806 * @param obj The entry object
2807 * @return The input method context
2811 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
2813 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2814 Widget_Data *wd = elm_widget_data_get(obj);
2815 if (!wd || !wd->ent) return NULL;
2817 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
2821 * Set whether entry should enable the return key on soft keyboard automatically
2823 * @param obj The entry object
2824 * @param on If true, entry enables the return key on soft keyboard automatically.
2829 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
2831 ELM_CHECK_WIDTYPE(obj, widtype);
2832 Widget_Data *wd = elm_widget_data_get(obj);
2835 wd->autoreturnkey = on;
2836 _check_enable_returnkey(obj);
2840 * Set whether entry should support auto capitalization
2842 * @param obj The entry object
2843 * @param on If true, entry suports auto capitalization.
2848 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on)
2850 ELM_CHECK_WIDTYPE(obj, widtype);
2851 Widget_Data *wd = elm_widget_data_get(obj);
2855 wd->autocapitalize = EINA_FALSE;
2857 wd->autocapitalize = on;
2859 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
2863 * Set the font size on the entry object
2865 * @param obj The entry object
2866 * @param size font size
2871 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
2873 ELM_CHECK_WIDTYPE(obj, widtype);
2874 Widget_Data *wd = elm_widget_data_get(obj);
2875 Eina_Strbuf *fontbuf = NULL;
2880 t = eina_stringshare_add(elm_entry_entry_get(obj));
2881 fontbuf = eina_strbuf_new();
2882 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
2884 if (fontsize == 0) removeflag = 1; // remove fontsize tag
2886 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
2888 elm_entry_entry_set(obj, t);
2892 eina_strbuf_free(fontbuf);
2893 eina_stringshare_del(t);
2897 * Set the text align on the entry object
2899 * @param obj The entry object
2900 * @param align align mode
2905 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
2907 ELM_CHECK_WIDTYPE(obj, widtype);
2908 Widget_Data *wd = elm_widget_data_get(obj);
2913 t = eina_stringshare_add(elm_entry_entry_get(obj));
2915 if (len <= 0) return;
2917 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
2918 elm_entry_entry_set(obj, t);
2922 eina_stringshare_del(t);
2926 * Set the text color on the entry object
2928 * @param obj The entry object
2929 * @param r Red property background color of The entry object
2930 * @param g Green property background color of The entry object
2931 * @param b Blue property background color of The entry object
2932 * @param a Alpha property background alpha of The entry object
2937 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
2939 ELM_CHECK_WIDTYPE(obj, widtype);
2940 Widget_Data *wd = elm_widget_data_get(obj);
2941 Eina_Strbuf *colorbuf = NULL;
2946 t = eina_stringshare_add(elm_entry_entry_get(obj));
2948 if (len <= 0) return;
2949 colorbuf = eina_strbuf_new();
2950 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
2952 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
2954 elm_entry_entry_set(obj, t);
2958 eina_strbuf_free(colorbuf);
2959 eina_stringshare_del(t);
2964 * Set background color of the entry
2966 * @param obj The entry object
2967 * @param r Red property background color of The entry object
2968 * @param g Green property background color of The entry object
2969 * @param b Blue property background color of The entry object
2970 * @param a Alpha property background alpha of The entry object
2974 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
2976 ELM_CHECK_WIDTYPE(obj, widtype);
2977 Widget_Data *wd = elm_widget_data_get(obj);
2978 evas_object_color_set(wd->bg, r, g, b, a);
2980 if (wd->bgcolor == EINA_FALSE)
2983 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
2988 * Set the ellipsis behavior of the entry
2990 * @param obj The entry object
2991 * @param ellipsis To ellipsis text or not
2995 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
2997 ELM_CHECK_WIDTYPE(obj, widtype);
2998 Widget_Data *wd = elm_widget_data_get(obj);
2999 if (wd->ellipsis == ellipsis) return;
3000 wd->ellipsis = ellipsis;
3006 * This sets the attribute to show the input panel automatically.
3008 * @param obj The entry object
3009 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3014 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3016 ELM_CHECK_WIDTYPE(obj, widtype);
3017 Widget_Data *wd = elm_widget_data_get(obj);
3020 wd->input_panel_enable = enabled;
3021 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3025 * Set the input panel layout of the entry
3027 * @param obj The entry object
3028 * @param layout the layout to set
3033 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3035 ELM_CHECK_WIDTYPE(obj, widtype);
3036 Widget_Data *wd = elm_widget_data_get(obj);
3039 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3042 wd->input_panel_layout = layout;
3044 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);