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;
112 Evas_Coord downx, downy;
113 Evas_Coord cx, cy, cw, ch;
115 Eina_List *item_providers;
116 Mod_Api *api; // module api if supplied
118 Eina_Bool changed : 1;
119 Eina_Bool linewrap : 1;
120 Eina_Bool char_linewrap : 1;
121 Eina_Bool single_line : 1;
122 Eina_Bool password : 1;
123 Eina_Bool show_last_character : 1;
124 Eina_Bool editable : 1;
125 Eina_Bool selection_asked : 1;
126 Eina_Bool have_selection : 1;
127 Eina_Bool selmode : 1;
128 Eina_Bool deferred_cur : 1;
129 Eina_Bool disabled : 1;
130 Eina_Bool context_menu : 1;
131 Eina_Bool bgcolor : 1;
132 Eina_Bool ellipsis : 1;
133 Eina_Bool autoreturnkey : 1;
134 Eina_Bool input_panel_enable : 1;
137 struct _Elm_Entry_Item_Provider
139 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
143 static const char *widtype = NULL;
144 static void _del_hook(Evas_Object *obj);
145 static void _theme_hook(Evas_Object *obj);
146 static void _disable_hook(Evas_Object *obj);
147 static void _sizing_eval(Evas_Object *obj);
148 static void _on_focus_hook(void *data, Evas_Object *obj);
149 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
150 static const char *_getbase(Evas_Object *obj);
151 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
152 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
153 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
154 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
155 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
156 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
157 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
158 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
159 static int _get_value_in_key_string(char *oldstring, char *key, char *value);
160 static int _string_key_value_replace(char *oldstring, char *key, char *value, char *tagstring);
161 static int _is_width_over(Evas_Object *obj);
162 static void _ellipsis_entry_to_width(Evas_Object *obj);
163 static int _textinput_control_function(void *data,void *input_data);
164 static int _entry_length_get(Evas_Object *obj);
166 #define MIN_ENTRY_FONT_SIZE 8
167 #define MAX_ENTRY_FONT_SIZE 60
169 static const char SIG_CHANGED[] = "changed";
170 static const char SIG_ACTIVATED[] = "activated";
171 static const char SIG_PRESS[] = "press";
172 static const char SIG_LONGPRESSED[] = "longpressed";
173 static const char SIG_CLICKED[] = "clicked";
174 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
175 static const char SIG_FOCUSED[] = "focused";
176 static const char SIG_UNFOCUSED[] = "unfocused";
177 static const char SIG_SELECTION_PASTE[] = "selection,paste";
178 static const char SIG_SELECTION_COPY[] = "selection,copy";
179 static const char SIG_SELECTION_CUT[] = "selection,cut";
180 static const char SIG_SELECTION_START[] = "selection,start";
181 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
182 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
183 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
184 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
185 static const Evas_Smart_Cb_Description _signals[] = {
189 {SIG_LONGPRESSED, ""},
191 {SIG_CLICKED_DOUBLE, ""},
194 {SIG_SELECTION_PASTE, ""},
195 {SIG_SELECTION_COPY, ""},
196 {SIG_SELECTION_CUT, ""},
197 {SIG_SELECTION_START, ""},
198 {SIG_SELECTION_CHANGED, ""},
199 {SIG_SELECTION_CLEARED, ""},
200 {SIG_CURSOR_CHANGED, ""},
201 {SIG_ANCHOR_CLICKED, ""},
205 static Eina_List *entries = NULL;
209 void (*obj_hook) (Evas_Object *obj);
210 void (*obj_unhook) (Evas_Object *obj);
211 void (*obj_longpress) (Evas_Object *obj);
212 void (*obj_mouseup) (Evas_Object *obj);
216 _module(Evas_Object *obj __UNUSED__)
218 static Elm_Module *m = NULL;
219 if (m) goto ok; // already found - just use
220 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
222 m->api = malloc(sizeof(Mod_Api));
223 if (!m->api) return NULL;
224 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
225 _elm_module_symbol_get(m, "obj_hook");
226 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
227 _elm_module_symbol_get(m, "obj_unhook");
228 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
229 _elm_module_symbol_get(m, "obj_longpress");
230 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
231 _elm_module_symbol_get(m, "obj_mouseup");
232 ok: // ok - return api
237 _del_hook(Evas_Object *obj)
239 Widget_Data *wd = elm_widget_data_get(obj);
240 Elm_Entry_Context_Menu_Item *it;
241 Elm_Entry_Item_Provider *ip;
243 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
245 entries = eina_list_remove(entries, obj);
246 #ifdef HAVE_ELEMENTARY_X
247 ecore_event_handler_del(wd->sel_notify_handler);
248 ecore_event_handler_del(wd->sel_clear_handler);
250 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
251 if (wd->text) eina_stringshare_del(wd->text);
252 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
253 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
254 EINA_LIST_FREE(wd->items, it)
256 eina_stringshare_del(it->label);
257 eina_stringshare_del(it->icon_file);
258 eina_stringshare_del(it->icon_group);
261 EINA_LIST_FREE(wd->item_providers, ip)
269 _theme_hook(Evas_Object *obj)
271 Widget_Data *wd = elm_widget_data_get(obj);
274 t = eina_stringshare_add(elm_entry_entry_get(obj));
275 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
276 elm_entry_entry_set(obj, t);
277 eina_stringshare_del(t);
278 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
279 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
285 _disable_hook(Evas_Object *obj)
287 Widget_Data *wd = elm_widget_data_get(obj);
289 if (elm_widget_disabled_get(obj))
291 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
292 wd->disabled = EINA_TRUE;
296 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
297 wd->disabled = EINA_FALSE;
302 _elm_win_recalc_job(void *data)
304 Widget_Data *wd = elm_widget_data_get(data);
305 Evas_Coord minw = -1, minh = -1, maxh = -1;
306 Evas_Coord resw, resh, minminw;
308 wd->deferred_recalc_job = NULL;
309 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
312 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
313 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
315 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
316 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
317 evas_object_size_hint_min_set(data, minminw, minh);
318 if (wd->single_line) maxh = minh;
319 evas_object_size_hint_max_set(data, -1, maxh);
320 if (wd->deferred_cur)
321 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
325 _sizing_eval(Evas_Object *obj)
327 Widget_Data *wd = elm_widget_data_get(obj);
328 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
329 Evas_Coord resw, resh;
331 if (wd->linewrap || wd->char_linewrap)
333 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
334 if ((resw == wd->lastw) && (!wd->changed)) return;
335 wd->changed = EINA_FALSE;
337 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
338 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
342 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
343 edje_object_size_min_calc(wd->ent, &minw, &minh);
344 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
345 evas_object_size_hint_min_set(obj, minw, minh);
346 if (wd->single_line) maxh = minh;
347 evas_object_size_hint_max_set(obj, maxw, maxh);
349 if (wd->ellipsis && wd->single_line)
351 if (_is_width_over(obj) == 1)
353 _ellipsis_entry_to_width(obj);
360 _check_enable_returnkey(Evas_Object *obj)
362 Widget_Data *wd = elm_widget_data_get(obj);
365 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
368 if (!wd->autoreturnkey) return;
370 if (_entry_length_get(obj) == 0)
372 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
376 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
381 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
383 Widget_Data *wd = elm_widget_data_get(obj);
384 Evas_Object *top = elm_widget_top_get(obj);
386 if (!wd->editable) return;
387 if (elm_widget_focus_get(obj))
389 evas_object_focus_set(wd->ent, 1);
390 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
391 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
392 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
393 _check_enable_returnkey(obj);
397 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
398 edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
399 evas_object_focus_set(wd->ent, 0);
400 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
401 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
406 _hoversel_position(Evas_Object *obj)
408 Widget_Data *wd = elm_widget_data_get(obj);
409 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
411 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
412 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
414 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
425 evas_object_move(wd->hoversel, x + cx, y + cy);
426 evas_object_resize(wd->hoversel, cw, ch);
430 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
432 Widget_Data *wd = elm_widget_data_get(data);
434 if (wd->hoversel) _hoversel_position(data);
438 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
440 Widget_Data *wd = elm_widget_data_get(data);
442 if (wd->linewrap || wd->char_linewrap)
446 if (wd->hoversel) _hoversel_position(data);
447 // Evas_Coord ww, hh;
448 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
452 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
454 Widget_Data *wd = elm_widget_data_get(data);
456 if (wd->hoversel) evas_object_hide(wd->hoversel);
460 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
462 elm_widget_scroll_freeze_pop(data);
466 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
468 Widget_Data *wd = elm_widget_data_get(data);
470 wd->selmode = EINA_TRUE;
471 edje_object_part_text_select_none(wd->ent, "elm.text");
473 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
474 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
475 elm_widget_scroll_hold_push(data);
479 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
481 Widget_Data *wd = elm_widget_data_get(data);
483 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
484 if (wd->sel_notify_handler)
486 #ifdef HAVE_ELEMENTARY_X
489 top = elm_widget_top_get(data);
490 if ((top) && (elm_win_xwindow_get(top)))
492 ecore_x_selection_primary_request
493 (elm_win_xwindow_get(top),
494 ECORE_X_SELECTION_TARGET_UTF8_STRING);
495 wd->selection_asked = EINA_TRUE;
502 _store_selection(Evas_Object *obj)
504 Widget_Data *wd = elm_widget_data_get(obj);
508 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
509 eina_stringshare_replace(&wd->cut_sel, sel);
513 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
515 Widget_Data *wd = elm_widget_data_get(data);
517 wd->selmode = EINA_FALSE;
518 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
519 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
520 elm_widget_scroll_hold_pop(data);
521 _store_selection(data);
522 edje_object_part_text_insert(wd->ent, "elm.text", "");
523 edje_object_part_text_select_none(wd->ent, "elm.text");
527 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
529 Widget_Data *wd = elm_widget_data_get(data);
531 wd->selmode = EINA_FALSE;
532 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
533 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
534 elm_widget_scroll_hold_pop(data);
535 _store_selection(data);
536 edje_object_part_text_select_none(wd->ent, "elm.text");
540 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
542 Widget_Data *wd = elm_widget_data_get(data);
544 wd->selmode = EINA_FALSE;
545 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
546 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
547 elm_widget_scroll_hold_pop(data);
548 edje_object_part_text_select_none(wd->ent, "elm.text");
552 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
554 Elm_Entry_Context_Menu_Item *it = data;
555 Evas_Object *obj2 = it->obj;
556 if (it->func) it->func(it->data, obj2, NULL);
560 _long_press(void *data)
562 Widget_Data *wd = elm_widget_data_get(data);
565 const Elm_Entry_Context_Menu_Item *it;
567 if ((wd->api) && (wd->api->obj_longpress))
569 wd->api->obj_longpress(data);
571 else if (wd->context_menu)
573 const char *context_menu_orientation;
575 if (wd->hoversel) evas_object_del(wd->hoversel);
576 else elm_widget_scroll_freeze_push(data);
577 wd->hoversel = elm_hoversel_add(data);
578 context_menu_orientation = edje_object_data_get
579 (wd->ent, "context_menu_orientation");
580 if ((context_menu_orientation) &&
581 (!strcmp(context_menu_orientation, "horizontal")))
582 elm_hoversel_horizontal_set(wd->hoversel, 1);
583 elm_object_style_set(wd->hoversel, "entry");
584 elm_widget_sub_object_add(data, wd->hoversel);
585 elm_hoversel_label_set(wd->hoversel, "Text");
586 top = elm_widget_top_get(data);
587 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
588 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
592 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
594 if (1) // need way to detect if someone has a selection
597 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
605 if (wd->have_selection)
607 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
610 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
613 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
617 EINA_LIST_FOREACH(wd->items, l, it)
619 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
620 it->icon_type, _item_clicked, it);
624 _hoversel_position(data);
625 evas_object_show(wd->hoversel);
626 elm_hoversel_hover_begin(wd->hoversel);
628 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
629 edje_object_part_text_select_abort(wd->ent, "elm.text");
631 wd->longpress_timer = NULL;
632 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
637 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
639 Widget_Data *wd = elm_widget_data_get(data);
640 Evas_Event_Mouse_Down *ev = event_info;
642 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
643 if (ev->button != 1) return;
644 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
645 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
646 wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
647 wd->downx = ev->canvas.x;
648 wd->downy = ev->canvas.y;
652 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
654 Widget_Data *wd = elm_widget_data_get(data);
655 Evas_Event_Mouse_Up *ev = event_info;
657 if (ev->button != 1) return;
658 if ((wd->api) && (wd->api->obj_mouseup))
660 wd->api->obj_mouseup(data);
662 if (wd->longpress_timer)
664 ecore_timer_del(wd->longpress_timer);
665 wd->longpress_timer = NULL;
670 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
672 Widget_Data *wd = elm_widget_data_get(data);
673 Evas_Event_Mouse_Move *ev = event_info;
677 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
679 if (wd->longpress_timer)
681 ecore_timer_del(wd->longpress_timer);
682 wd->longpress_timer = NULL;
685 else if (wd->longpress_timer)
689 dx = wd->downx - ev->cur.canvas.x;
691 dy = wd->downy - ev->cur.canvas.y;
694 ((_elm_config->finger_size / 2) *
695 (_elm_config->finger_size / 2)))
697 ecore_timer_del(wd->longpress_timer);
698 wd->longpress_timer = NULL;
702 else if (wd->longpress_timer)
706 dx = wd->downx - ev->cur.canvas.x;
708 dy = wd->downy - ev->cur.canvas.y;
711 ((_elm_config->finger_size / 2) *
712 (_elm_config->finger_size / 2)))
714 ecore_timer_del(wd->longpress_timer);
715 wd->longpress_timer = NULL;
721 _getbase(Evas_Object *obj)
723 Widget_Data *wd = elm_widget_data_get(obj);
724 if (!wd) return "base";
727 if((wd->password)&&(wd->show_last_character)) return "custom-password";
728 else if(wd->password) return "base-password";
731 if (wd->single_line) return "base-single";
734 if (wd->linewrap) return "base";
735 else if (wd->char_linewrap) return "base-charwrap";
736 else return "base-nowrap";
742 if((wd->password)&&(wd->show_last_character)) return "custom-password";
743 else if(wd->password) return "base-password";
746 if (wd->single_line) return "base-single-noedit";
749 if (wd->linewrap) return "base-noedit";
750 else if (wd->char_linewrap) return "base-noedit-charwrap";
751 else return "base-nowrap-noedit";
759 _str_append(char *str, const char *txt, int *len, int *alloc)
761 int txt_len = strlen(txt);
763 if (txt_len <= 0) return str;
764 if ((*len + txt_len) >= *alloc)
769 alloc2 = *alloc + txt_len + 128;
770 str2 = realloc(str, alloc2);
771 if (!str2) return str;
775 strcpy(str + *len, txt);
781 _strncpy(char* dest, const char* src, size_t count)
785 ERR( "dest is NULL" );
790 ERR( "src is NULL" );
795 ERR( "count is smaller than 0" );
799 return strncpy( dest, src, count );
803 _mkup_to_text(const char *mkup)
806 int str_len = 0, str_alloc = 0;
808 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
810 if (!mkup) return NULL;
812 tag_start = tag_end = esc_start = esc_end = NULL;
817 if (((p!=NULL)&&(*p == 0)) ||
818 (tag_end) || (esc_end) ||
819 (tag_start) || (esc_start))
825 ttag = malloc(tag_end - tag_start);
828 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
829 ttag[tag_end - tag_start - 1] = 0;
830 if (!strcmp(ttag, "br"))
831 str = _str_append(str, "\n", &str_len, &str_alloc);
832 else if (!strcmp(ttag, "\n"))
833 str = _str_append(str, "\n", &str_len, &str_alloc);
834 else if (!strcmp(ttag, "\\n"))
835 str = _str_append(str, "\n", &str_len, &str_alloc);
836 else if (!strcmp(ttag, "\t"))
837 str = _str_append(str, "\t", &str_len, &str_alloc);
838 else if (!strcmp(ttag, "\\t"))
839 str = _str_append(str, "\t", &str_len, &str_alloc);
842 tag_start = tag_end = NULL;
846 ts = malloc(esc_end - esc_start + 1);
850 _strncpy(ts, esc_start, esc_end - esc_start);
851 ts[esc_end - esc_start] = 0;
852 esc = evas_textblock_escape_string_get(ts);
854 str = _str_append(str, esc, &str_len, &str_alloc);
857 esc_start = esc_end = NULL;
859 else if ((p!=NULL)&&(*p == 0))
861 ts = malloc(p - s + 1);
864 _strncpy(ts, s, p - s);
866 str = _str_append(str, ts, &str_len, &str_alloc);
872 if ((p!=NULL)&&(*p == '<'))
878 ts = malloc(p - s + 1);
881 _strncpy(ts, s, p - s);
883 str = _str_append(str, ts, &str_len, &str_alloc);
889 else if ((p!=NULL)&&(*p == '>'))
897 else if ((p!=NULL)&&(*p == '&'))
903 ts = malloc(p - s + 1);
906 _strncpy(ts, s, p - s);
908 str = _str_append(str, ts, &str_len, &str_alloc);
914 else if ((p!=NULL)&&(*p == ';'))
928 _entry_length_get(Evas_Object *obj)
931 char *str = elm_entry_entry_get(obj);
934 char *plain_str = _mkup_to_text(str);
935 if (!plain_str) return 0;
937 len = strlen(plain_str);
944 _text_to_mkup(const char *text)
947 int str_len = 0, str_alloc = 0;
948 int ch, pos = 0, pos2 = 0;
950 if (!text) return NULL;
954 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
955 if ((ch <= 0) || (pos2 <= 0)) break;
957 str = _str_append(str, "<br>", &str_len, &str_alloc);
959 str = _str_append(str, "<\t>", &str_len, &str_alloc);
961 str = _str_append(str, "<", &str_len, &str_alloc);
963 str = _str_append(str, ">", &str_len, &str_alloc);
965 str = _str_append(str, "&", &str_len, &str_alloc);
970 _strncpy(tstr, text + pos, pos2 - pos);
971 tstr[pos2 - pos] = 0;
972 str = _str_append(str, tstr, &str_len, &str_alloc);
979 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
981 Widget_Data *wd = elm_widget_data_get(data);
983 wd->changed = EINA_TRUE;
985 if (wd->text) eina_stringshare_del(wd->text);
987 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
989 _check_enable_returnkey(data);
993 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
995 Widget_Data *wd = elm_widget_data_get(data);
999 EINA_LIST_FOREACH(entries, l, entry)
1001 if (entry != data) elm_entry_select_none(entry);
1003 wd->have_selection = EINA_TRUE;
1004 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1005 if (wd->sel_notify_handler)
1007 char *txt = _mkup_to_text(elm_entry_selection_get(data));
1011 #ifdef HAVE_ELEMENTARY_X
1014 top = elm_widget_top_get(data);
1015 if ((top) && (elm_win_xwindow_get(top)))
1016 ecore_x_selection_primary_set(elm_win_xwindow_get(top), txt,
1025 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1027 Widget_Data *wd = elm_widget_data_get(data);
1029 wd->have_selection = EINA_TRUE;
1030 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1031 if (wd->sel_notify_handler)
1033 char *txt = _mkup_to_text(elm_entry_selection_get(data));
1037 #ifdef HAVE_ELEMENTARY_X
1040 top = elm_widget_top_get(data);
1041 if ((top) && (elm_win_xwindow_get(top)))
1042 ecore_x_selection_primary_set(elm_win_xwindow_get(top), txt,
1051 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1053 Widget_Data *wd = elm_widget_data_get(data);
1055 if (!wd->have_selection) return;
1056 wd->have_selection = EINA_FALSE;
1057 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1058 if (wd->sel_notify_handler)
1062 #ifdef HAVE_ELEMENTARY_X
1065 top = elm_widget_top_get(data);
1066 if ((top) && (elm_win_xwindow_get(top)))
1070 t = _mkup_to_text(wd->cut_sel);
1073 ecore_x_selection_primary_set(elm_win_xwindow_get(top),
1079 eina_stringshare_del(wd->cut_sel);
1084 #ifdef HAVE_ELEMENTARY_X
1087 top = elm_widget_top_get(data);
1088 if ((top) && (elm_win_xwindow_get(top)))
1089 ecore_x_selection_primary_clear();
1096 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1098 Widget_Data *wd = elm_widget_data_get(data);
1100 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1101 if (wd->sel_notify_handler)
1103 #ifdef HAVE_ELEMENTARY_X
1106 top = elm_widget_top_get(data);
1107 if ((top) && (elm_win_xwindow_get(top)))
1109 ecore_x_selection_primary_request(elm_win_xwindow_get(top),
1110 ECORE_X_SELECTION_TARGET_UTF8_STRING);
1111 wd->selection_asked = EINA_TRUE;
1118 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1120 Widget_Data *wd = elm_widget_data_get(data);
1122 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1126 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1128 Widget_Data *wd = elm_widget_data_get(data);
1131 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1132 txt = _mkup_to_text(elm_entry_selection_get(data));
1133 eina_stringshare_replace(&wd->cut_sel, txt);
1135 edje_object_part_text_insert(wd->ent, "elm.text", "");
1136 wd->changed = EINA_TRUE;
1141 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1143 Widget_Data *wd = elm_widget_data_get(data);
1144 Evas_Coord cx, cy, cw, ch;
1146 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1147 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1148 &cx, &cy, &cw, &ch);
1149 if (!wd->deferred_recalc_job)
1150 elm_widget_show_region_set(data, cx, cy, cw, ch);
1153 wd->deferred_cur = EINA_TRUE;
1162 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1164 Widget_Data *wd = elm_widget_data_get(data);
1169 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1171 Widget_Data *wd = elm_widget_data_get(data);
1172 Elm_Entry_Anchor_Info ei;
1173 char *buf2, *p, *p2, *n;
1175 p = strrchr(emission, ',');
1178 const Eina_List *geoms;
1182 while (p2 >= emission)
1184 if (*p2 == ',') break;
1188 buf2 = alloca(5 + p - p2);
1189 strncpy(buf2, p2, p - p2);
1192 ei.button = atoi(buf2);
1193 ei.x = ei.y = ei.w = ei.h = 0;
1195 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1198 Evas_Textblock_Rectangle *r;
1200 Evas_Coord px, py, x, y;
1202 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1203 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1204 EINA_LIST_FOREACH(geoms, l, r)
1206 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1207 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1218 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1223 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1225 Widget_Data *wd = elm_widget_data_get(data);
1230 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1232 Widget_Data *wd = elm_widget_data_get(data);
1237 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1239 Widget_Data *wd = elm_widget_data_get(data);
1244 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1246 Widget_Data *wd = elm_widget_data_get(data);
1248 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1252 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1254 Widget_Data *wd = elm_widget_data_get(data);
1256 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1260 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1262 Widget_Data *wd = elm_widget_data_get(data);
1264 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1268 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1270 Widget_Data *wd = elm_widget_data_get(data);
1272 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1275 #ifdef HAVE_ELEMENTARY_X
1277 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1279 Widget_Data *wd = elm_widget_data_get(data);
1280 Ecore_X_Event_Selection_Notify *ev = event;
1282 if (!wd->selection_asked) return 1;
1283 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1284 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1286 Ecore_X_Selection_Data_Text *text_data;
1288 text_data = ev->data;
1289 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1291 if (text_data->text)
1293 char *txt = _text_to_mkup(text_data->text);
1297 elm_entry_entry_insert(data, txt);
1302 wd->selection_asked = EINA_FALSE;
1308 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1310 Widget_Data *wd = elm_widget_data_get(data);
1311 Ecore_X_Event_Selection_Clear *ev = event;
1313 if (!wd->have_selection) return 1;
1314 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1315 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1317 elm_entry_select_none(data);
1323 static Evas_Object *
1324 _get_item(void *data, Evas_Object *edje, const char *part, const char *item)
1326 Widget_Data *wd = elm_widget_data_get(data);
1329 Elm_Entry_Item_Provider *ip;
1332 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1334 o = ip->func(ip->data, data, item);
1337 o = edje_object_add(evas_object_evas_get(data));
1338 if (!strncmp(item, "emoticon/", 9))
1339 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1341 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1347 _get_value_in_key_string(char *oldstring, char *key, char *value)
1349 char *curlocater, *starttag, *endtag;
1350 int firstindex = 0, foundflag = -1;
1352 curlocater = strstr(oldstring, key);
1353 if (curlocater == NULL)
1359 starttag = curlocater;
1360 endtag = curlocater + strlen(key);
1364 firstindex = abs(oldstring - curlocater);
1365 firstindex += strlen(key)+1; // strlen("font_size") + strlen("=")
1366 value = oldstring + firstindex;
1368 while (oldstring != starttag)
1370 if (*starttag == '>')
1375 if (*starttag == '<')
1379 if (starttag == NULL)
1383 while (NULL != *endtag)
1398 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1412 _string_key_value_replace(char *oldstring, char *key, char *value, char *tagstring)
1414 char *curlocater, *starttag, *endtag;
1415 int firstindex = 0, insertflag = 0;
1417 curlocater = strstr(oldstring, key);
1418 if (curlocater == NULL)
1424 starttag = curlocater - 1;
1425 endtag = curlocater + strlen(key);
1429 firstindex = abs(oldstring - curlocater);
1430 firstindex += strlen(key)+1; // strlen("font_size") + strlen("=")
1431 strncpy(tagstring, oldstring, firstindex);
1432 tagstring[firstindex] = '\0';
1433 sprintf(&tagstring[firstindex], "%s", value);
1435 while (curlocater != NULL)
1437 if (*curlocater == ' ' || *curlocater == '>')
1441 strcat(tagstring, curlocater);
1443 while (oldstring != starttag)
1445 if (*starttag == '>')
1450 if (*starttag == '<')
1454 if (starttag == NULL)
1458 while (NULL != *endtag)
1473 if (insertflag == 0 && *starttag == '<' && *endtag == '>')
1480 if (insertflag == 1)
1482 sprintf(tagstring, "<%s=%s>", key, value);
1483 strcat(tagstring, oldstring);
1491 _is_width_over(Evas_Object *obj)
1493 Evas_Coord x, y, w, h;
1494 Evas_Coord vx, vy, vw, vh;
1495 Widget_Data *wd = elm_widget_data_get(obj);
1499 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1501 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1503 if (x >= 0 && y >= 0)
1506 if (4 < wd->wrap_w && w > wd->wrap_w)
1513 _ellipsis_entry_to_width(Evas_Object *obj)
1515 Widget_Data *wd = elm_widget_data_get(obj);
1516 int cur_fontsize = 0, len, jumpcount, i, tagend;
1517 char *oldstring, *value, *textlocater, *entrystring;
1518 char *string, fontbuf[16];
1522 entrystring = edje_object_part_text_get(wd->ent, "elm.text");
1524 len = strlen(entrystring);
1525 oldstring = malloc(sizeof(char)*(len+32));
1526 strcpy(oldstring, entrystring);
1528 if (_get_value_in_key_string(oldstring, "font_size", value) == 0
1531 cur_fontsize = atoi(value);
1534 cur_fontsize = 24; /* default size in aqua.edc */
1539 while (_is_width_over(obj) == 1)
1541 if (cur_fontsize > MIN_ENTRY_FONT_SIZE)
1544 entrystring = edje_object_part_text_get(wd->ent, "elm.text");
1545 len = strlen(entrystring);
1546 if (len <= 0) return;
1547 string = malloc(sizeof(char)*(len+32));
1548 oldstring = malloc(sizeof(char)*(len+32));
1549 sprintf(fontbuf, "%d", cur_fontsize);
1551 strcpy(oldstring, entrystring);
1552 _string_key_value_replace(oldstring, "font_size", fontbuf, string);
1554 edje_object_part_text_set(wd->ent, "elm.text", string);
1555 if (wd->text) eina_stringshare_del(wd->text);
1557 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1564 entrystring = edje_object_part_text_get(wd->ent, "elm.text");
1565 len = strlen(entrystring) - 1;
1567 for (i = 0; i <= len; i++)
1569 if (entrystring[i] == '>' && entrystring[i+1] != NULL &&
1570 entrystring[i+1] != '<')
1576 oldstring = elm_entry_markup_to_utf8(entrystring);
1578 string = malloc(sizeof(char)*(len+32));
1579 while (jumpcount < len-3)
1581 strncpy(string, entrystring, tagend+1);
1582 string[tagend+1] = '\0';
1583 strcat(string, "...");
1584 strcat(string, &oldstring[jumpcount]);
1586 edje_object_part_text_set(wd->ent, "elm.text", string);
1587 if (wd->text) eina_stringshare_del(wd->text);
1589 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1591 if (_is_width_over(obj) == 1)
1596 entrystring = edje_object_part_text_get(wd->ent, "elm.text");
1606 static int _textinput_control_function(void *data,void *input_data)
1608 /*calculate character count*/
1609 Widget_Data *wd = elm_widget_data_get(data);
1612 size_t len=0, bytes_per_char=0,insert_text_len=0;
1613 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1615 size_t remain_bytes;
1618 byte_len = strlen(text);/*no of bytes*/
1619 remain_bytes = wd->max_no_of_bytes-byte_len;
1620 sprintf(buf,"%d",remain_bytes);
1621 edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1624 insert_text = (char *)input_data;
1625 insert_text_len = strlen(insert_text);
1626 if(remain_bytes<insert_text_len)
1628 evas_object_smart_callback_call(input_data, "maxlength,reached", NULL);
1631 if(byte_len>=wd->max_no_of_bytes)
1633 evas_object_smart_callback_call(input_data, "maxlength,reached", NULL);
1642 * This adds an entry to @p parent object.
1644 * @param parent The parent object
1645 * @return The new object or NULL if it cannot be created
1650 elm_entry_add(Evas_Object *parent)
1652 Evas_Object *obj, *top;
1656 wd = ELM_NEW(Widget_Data);
1657 e = evas_object_evas_get(parent);
1658 wd->bgcolor = EINA_FALSE;
1659 wd->bg = evas_object_rectangle_add(e);
1660 evas_object_color_set(wd->bg, 0, 0, 0, 0);
1661 obj = elm_widget_add(e);
1662 ELM_SET_WIDTYPE(widtype, "entry");
1663 elm_widget_type_set(obj, "entry");
1664 elm_widget_sub_object_add(parent, obj);
1665 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1666 elm_widget_data_set(obj, wd);
1667 elm_widget_del_hook_set(obj, _del_hook);
1668 elm_widget_theme_hook_set(obj, _theme_hook);
1669 elm_widget_disable_hook_set(obj, _disable_hook);
1670 elm_widget_can_focus_set(obj, 1);
1672 wd->linewrap = EINA_TRUE;
1673 wd->ellipsis = EINA_FALSE;
1674 wd->char_linewrap= EINA_FALSE;
1675 wd->editable = EINA_TRUE;
1676 wd->disabled = EINA_FALSE;
1677 wd->context_menu = EINA_TRUE;
1679 wd->ent = edje_object_add(e);
1680 edje_object_item_provider_set(wd->ent, _get_item, obj);
1681 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
1682 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
1683 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
1685 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
1687 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
1690 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
1691 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
1692 _signal_entry_changed, obj);
1693 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
1694 _signal_selection_start, obj);
1695 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
1696 _signal_selection_changed, obj);
1697 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
1698 _signal_selection_cleared, obj);
1699 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
1700 _signal_entry_paste_request, obj);
1701 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
1702 _signal_entry_copy_notify, obj);
1703 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
1704 _signal_entry_cut_notify, obj);
1705 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
1706 _signal_cursor_changed, obj);
1707 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
1708 _signal_anchor_down, obj);
1709 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
1710 _signal_anchor_up, obj);
1711 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
1712 _signal_anchor_move, obj);
1713 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
1714 _signal_anchor_in, obj);
1715 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
1716 _signal_anchor_out, obj);
1717 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
1718 _signal_key_enter, obj);
1719 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
1720 _signal_mouse_down, obj);
1721 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
1722 _signal_mouse_up, obj);
1723 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
1724 _signal_mouse_double, obj);
1725 edje_object_part_text_set(wd->ent, "elm.text", "");
1726 elm_widget_resize_object_set(obj, wd->ent);
1729 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
1731 #ifdef HAVE_ELEMENTARY_X
1732 top = elm_widget_top_get(obj);
1733 if ((top) && (elm_win_xwindow_get(top)))
1735 wd->sel_notify_handler =
1736 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
1737 _event_selection_notify, obj);
1738 wd->sel_clear_handler =
1739 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
1740 _event_selection_clear, obj);
1744 entries = eina_list_prepend(entries, obj);
1746 // module - find module for entry
1747 wd->api = _module(obj);
1748 // if found - hook in
1749 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
1751 // TODO: convert Elementary to subclassing of Evas_Smart_Class
1752 // TODO: and save some bytes, making descriptions per-class and not instance!
1753 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1757 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
1759 ELM_CHECK_WIDTYPE(obj, widtype);
1760 Widget_Data *wd = elm_widget_data_get(obj);
1762 ext_mod->cancel = _cancel;
1763 ext_mod->copy = _copy;
1764 ext_mod->cut = _cut;
1765 ext_mod->paste = _paste;
1766 ext_mod->select = _select;
1767 ext_mod->selectall = NULL; /* to be implemented*/
1768 ext_mod->ent = wd->ent;
1769 ext_mod->items = wd->items;
1770 ext_mod->longpress_timer = wd->longpress_timer;
1771 ext_mod->editable = wd->editable;
1772 ext_mod->have_selection = wd->have_selection;
1773 ext_mod->password = wd->password;
1774 ext_mod->selmode = wd->selmode;
1778 * This sets the entry object not to line wrap. All input will
1779 * be on a single line, and the entry box will extend with user input.
1781 * @param obj The entry object
1782 * @param single_line If true, the text in the entry
1783 * will be on a single line.
1788 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
1790 ELM_CHECK_WIDTYPE(obj, widtype);
1791 Widget_Data *wd = elm_widget_data_get(obj);
1794 if (wd->single_line == single_line) return;
1795 wd->single_line = single_line;
1796 wd->linewrap = EINA_FALSE;
1797 wd->char_linewrap = EINA_FALSE;
1798 t = eina_stringshare_add(elm_entry_entry_get(obj));
1799 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
1800 elm_entry_entry_set(obj, t);
1801 eina_stringshare_del(t);
1806 * This returns true if the entry has been set to single line mode.
1807 * See also elm_entry_single_line_set().
1809 * @param obj The entry object
1810 * @return single_line If true, the text in the entry is set to display
1816 elm_entry_single_line_get(const Evas_Object *obj)
1818 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1819 Widget_Data *wd = elm_widget_data_get(obj);
1820 if (!wd) return EINA_FALSE;
1821 return wd->single_line;
1825 * This set's the maximum bytes that can be added in entry.
1827 * @param obj The entry object
1828 * @param max_no_of_bytes Maximum number of bytes entry can have.
1833 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
1835 Widget_Data *wd = elm_widget_data_get(obj);
1837 wd->max_no_of_bytes = max_no_of_bytes;
1838 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
1839 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
1844 * This sets the entry object to password mode. All text entered
1845 * and/or displayed within the widget will be replaced with asterisks (*).
1847 * @param obj The entry object
1848 * @param password If true, password mode is enabled.
1853 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
1855 ELM_CHECK_WIDTYPE(obj, widtype);
1856 Widget_Data *wd = elm_widget_data_get(obj);
1859 if (wd->password == password) return;
1860 wd->password = password;
1861 wd->show_last_character = EINA_FALSE;
1862 wd->single_line = EINA_TRUE;
1863 wd->linewrap = EINA_FALSE;
1864 wd->char_linewrap = EINA_FALSE;
1865 t = eina_stringshare_add(elm_entry_entry_get(obj));
1866 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
1867 elm_entry_entry_set(obj, t);
1868 eina_stringshare_del(t);
1873 * This set's the entry in password mode with out masking the last character entered by user,
1874 * and later masking the character after 2 seconds.
1876 * @param obj The entry object
1877 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
1883 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
1885 Widget_Data *wd = elm_widget_data_get(obj);
1888 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
1889 wd->show_last_character = show_last_character;
1890 wd->password = show_last_character;
1891 wd->single_line = EINA_TRUE;
1892 wd->linewrap = EINA_FALSE;
1893 wd->char_linewrap = EINA_FALSE;
1894 t = eina_stringshare_add(elm_entry_entry_get(obj));
1895 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
1896 elm_entry_entry_set(obj, t);
1897 eina_stringshare_del(t);
1902 * This returns whether password mode is enabled.
1903 * See also elm_entry_password_set().
1905 * @param obj The entry object
1906 * @return If true, the entry is set to display all characters
1912 elm_entry_password_get(const Evas_Object *obj)
1914 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1915 Widget_Data *wd = elm_widget_data_get(obj);
1916 if (!wd) return EINA_FALSE;
1917 return wd->password;
1921 * This sets the text displayed within the entry to @p entry.
1923 * @param obj The entry object
1924 * @param entry The text to be displayed
1929 elm_entry_entry_set(Evas_Object *obj, const char *entry)
1931 ELM_CHECK_WIDTYPE(obj, widtype);
1932 Widget_Data *wd = elm_widget_data_get(obj);
1934 if (!entry) entry = "";
1935 if(wd->max_no_of_bytes)
1937 int len = strlen(entry);
1938 if(len > wd->max_no_of_bytes)
1940 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
1944 edje_object_part_text_set(wd->ent, "elm.text", entry);
1945 if (wd->text) eina_stringshare_del(wd->text);
1947 wd->changed = EINA_TRUE;
1952 * This returns the text currently shown in object @p entry.
1953 * See also elm_entry_entry_set().
1955 * @param obj The entry object
1956 * @return The currently displayed text or NULL on failure
1961 elm_entry_entry_get(const Evas_Object *obj)
1963 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1964 Widget_Data *wd = elm_widget_data_get(obj);
1966 if (!wd) return NULL;
1967 if (wd->text) return wd->text;
1968 text = edje_object_part_text_get(wd->ent, "elm.text");
1971 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
1974 eina_stringshare_replace(&wd->text, text);
1979 * This returns all selected text within the entry.
1981 * @param obj The entry object
1982 * @return The selected text within the entry or NULL on failure
1987 elm_entry_selection_get(const Evas_Object *obj)
1989 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1990 Widget_Data *wd = elm_widget_data_get(obj);
1991 if (!wd) return NULL;
1992 return edje_object_part_text_selection_get(wd->ent, "elm.text");
1996 * This inserts text in @p entry at the beginning of the entry
1999 * @param obj The entry object
2000 * @param entry The text to insert
2005 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2007 ELM_CHECK_WIDTYPE(obj, widtype);
2008 Widget_Data *wd = elm_widget_data_get(obj);
2010 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2011 wd->changed = EINA_TRUE;
2016 * This enables word line wrapping in the entry object. It is the opposite
2017 * of elm_entry_single_line_set(). Additionally, setting this disables
2018 * character line wrapping.
2019 * See also elm_entry_line_char_wrap_set().
2021 * @param obj The entry object
2022 * @param wrap If true, the entry will be wrapped once it reaches the end
2023 * of the object. Wrapping will occur at the end of the word before the end of the
2029 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2031 ELM_CHECK_WIDTYPE(obj, widtype);
2032 Widget_Data *wd = elm_widget_data_get(obj);
2035 if (wd->linewrap == wrap) return;
2036 wd->linewrap = wrap;
2038 wd->char_linewrap = EINA_FALSE;
2039 t = eina_stringshare_add(elm_entry_entry_get(obj));
2040 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2041 elm_entry_entry_set(obj, t);
2042 eina_stringshare_del(t);
2047 * Set wrap width of the entry
2049 * @param obj The entry object
2050 * @param w The wrap width in pixels at a minimum where words need to wrap
2054 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2056 Widget_Data *wd = elm_widget_data_get(obj);
2057 if (wd->wrap_w == w) return;
2063 * get wrap width of the entry
2065 * @param obj The entry object
2066 * @return The wrap width in pixels at a minimum where words need to wrap
2070 elm_entry_wrap_width_get(const Evas_Object *obj)
2072 Widget_Data *wd = elm_widget_data_get(obj);
2077 * This enables character line wrapping in the entry object. It is the opposite
2078 * of elm_entry_single_line_set(). Additionally, setting this disables
2079 * word line wrapping.
2080 * See also elm_entry_line_wrap_set().
2082 * @param obj The entry object
2083 * @param wrap If true, the entry will be wrapped once it reaches the end
2084 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2089 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2091 ELM_CHECK_WIDTYPE(obj, widtype);
2092 Widget_Data *wd = elm_widget_data_get(obj);
2095 if (wd->char_linewrap == wrap) return;
2096 wd->char_linewrap = wrap;
2097 if(wd->char_linewrap)
2098 wd->linewrap = EINA_FALSE;
2099 t = eina_stringshare_add(elm_entry_entry_get(obj));
2100 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2101 elm_entry_entry_set(obj, t);
2102 eina_stringshare_del(t);
2107 * This sets the editable attribute of the entry.
2109 * @param obj The entry object
2110 * @param editable If true, the entry will be editable by the user.
2111 * If false, it will be set to the disabled state.
2116 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2118 ELM_CHECK_WIDTYPE(obj, widtype);
2119 Widget_Data *wd = elm_widget_data_get(obj);
2122 if (wd->editable == editable) return;
2123 wd->editable = editable;
2124 t = eina_stringshare_add(elm_entry_entry_get(obj));
2125 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2126 elm_entry_entry_set(obj, t);
2127 eina_stringshare_del(t);
2132 * This gets the editable attribute of the entry.
2133 * See also elm_entry_editable_set().
2135 * @param obj The entry object
2136 * @return If true, the entry is editable by the user.
2137 * If false, it is not editable by the user
2142 elm_entry_editable_get(const Evas_Object *obj)
2144 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2145 Widget_Data *wd = elm_widget_data_get(obj);
2146 if (!wd) return EINA_FALSE;
2147 return wd->editable;
2151 * This drops any existing text selection within the entry.
2153 * @param obj The entry object
2158 elm_entry_select_none(Evas_Object *obj)
2160 ELM_CHECK_WIDTYPE(obj, widtype);
2161 Widget_Data *wd = elm_widget_data_get(obj);
2165 wd->selmode = EINA_FALSE;
2166 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
2167 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2169 wd->have_selection = EINA_FALSE;
2170 edje_object_part_text_select_none(wd->ent, "elm.text");
2174 * This selects all text within the entry.
2176 * @param obj The entry object
2181 elm_entry_select_all(Evas_Object *obj)
2183 ELM_CHECK_WIDTYPE(obj, widtype);
2184 Widget_Data *wd = elm_widget_data_get(obj);
2188 wd->selmode = EINA_FALSE;
2189 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
2190 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2192 wd->have_selection = EINA_TRUE;
2193 edje_object_part_text_select_all(wd->ent, "elm.text");
2197 * This moves the cursor one place to the right within the entry.
2199 * @param obj The entry object
2200 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2205 elm_entry_cursor_next(Evas_Object *obj)
2207 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2208 Widget_Data *wd = elm_widget_data_get(obj);
2209 if (!wd) return EINA_FALSE;
2210 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2214 * This moves the cursor one place to the left within the entry.
2216 * @param obj The entry object
2217 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2222 elm_entry_cursor_prev(Evas_Object *obj)
2224 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2225 Widget_Data *wd = elm_widget_data_get(obj);
2226 if (!wd) return EINA_FALSE;
2227 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2231 * This moves the cursor one line up within the entry.
2233 * @param obj The entry object
2234 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2239 elm_entry_cursor_up(Evas_Object *obj)
2241 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2242 Widget_Data *wd = elm_widget_data_get(obj);
2243 if (!wd) return EINA_FALSE;
2244 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2248 * This moves the cursor one line down within the entry.
2250 * @param obj The entry object
2251 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2256 elm_entry_cursor_down(Evas_Object *obj)
2258 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2259 Widget_Data *wd = elm_widget_data_get(obj);
2260 if (!wd) return EINA_FALSE;
2261 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2265 * This moves the cursor to the beginning of the entry.
2267 * @param obj The entry object
2272 elm_entry_cursor_begin_set(Evas_Object *obj)
2274 ELM_CHECK_WIDTYPE(obj, widtype);
2275 Widget_Data *wd = elm_widget_data_get(obj);
2277 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2281 * This moves the cursor to the end of the entry.
2283 * @param obj The entry object
2288 elm_entry_cursor_end_set(Evas_Object *obj)
2290 ELM_CHECK_WIDTYPE(obj, widtype);
2291 Widget_Data *wd = elm_widget_data_get(obj);
2293 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2297 * This moves the cursor to the beginning of the current line.
2299 * @param obj The entry object
2304 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2306 ELM_CHECK_WIDTYPE(obj, widtype);
2307 Widget_Data *wd = elm_widget_data_get(obj);
2309 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2313 * This moves the cursor to the end of the current line.
2315 * @param obj The entry object
2320 elm_entry_cursor_line_end_set(Evas_Object *obj)
2322 ELM_CHECK_WIDTYPE(obj, widtype);
2323 Widget_Data *wd = elm_widget_data_get(obj);
2325 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2329 * This begins a selection within the entry as though
2330 * the user were holding down the mouse button to make a selection.
2332 * @param obj The entry object
2337 elm_entry_cursor_selection_begin(Evas_Object *obj)
2339 ELM_CHECK_WIDTYPE(obj, widtype);
2340 Widget_Data *wd = elm_widget_data_get(obj);
2342 edje_object_part_text_select_begin(wd->ent, "elm.text");
2346 * This ends a selection within the entry as though
2347 * the user had just released the mouse button while making a selection.
2349 * @param obj The entry object
2354 elm_entry_cursor_selection_end(Evas_Object *obj)
2356 ELM_CHECK_WIDTYPE(obj, widtype);
2357 Widget_Data *wd = elm_widget_data_get(obj);
2359 edje_object_part_text_select_extend(wd->ent, "elm.text");
2363 * TODO: fill this in
2365 * @param obj The entry object
2366 * @return TODO: fill this in
2371 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2373 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2374 Widget_Data *wd = elm_widget_data_get(obj);
2375 if (!wd) return EINA_FALSE;
2376 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2380 * This returns whether the cursor is visible.
2382 * @param obj The entry object
2383 * @return If true, the cursor is visible.
2388 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2390 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2391 Widget_Data *wd = elm_widget_data_get(obj);
2392 if (!wd) return EINA_FALSE;
2393 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2397 * TODO: fill this in
2399 * @param obj The entry object
2400 * @return TODO: fill this in
2405 elm_entry_cursor_content_get(const Evas_Object *obj)
2407 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2408 Widget_Data *wd = elm_widget_data_get(obj);
2409 if (!wd) return NULL;
2410 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2414 * This executes a "cut" action on the selected text in the entry.
2416 * @param obj The entry object
2421 elm_entry_selection_cut(Evas_Object *obj)
2423 ELM_CHECK_WIDTYPE(obj, widtype);
2424 Widget_Data *wd = elm_widget_data_get(obj);
2426 _cut(obj, NULL, NULL);
2430 * This executes a "copy" action on the selected text in the entry.
2432 * @param obj The entry object
2437 elm_entry_selection_copy(Evas_Object *obj)
2439 ELM_CHECK_WIDTYPE(obj, widtype);
2440 Widget_Data *wd = elm_widget_data_get(obj);
2442 _copy(obj, NULL, NULL);
2446 * This executes a "paste" action in the entry.
2448 * @param obj The entry object
2453 elm_entry_selection_paste(Evas_Object *obj)
2455 ELM_CHECK_WIDTYPE(obj, widtype);
2456 Widget_Data *wd = elm_widget_data_get(obj);
2458 _paste(obj, NULL, NULL);
2462 * This clears and frees the items in a entry's contextual (right click) menu.
2464 * @param obj The entry object
2469 elm_entry_context_menu_clear(Evas_Object *obj)
2471 ELM_CHECK_WIDTYPE(obj, widtype);
2472 Widget_Data *wd = elm_widget_data_get(obj);
2473 Elm_Entry_Context_Menu_Item *it;
2475 EINA_LIST_FREE(wd->items, it)
2477 eina_stringshare_del(it->label);
2478 eina_stringshare_del(it->icon_file);
2479 eina_stringshare_del(it->icon_group);
2485 * This adds an item to the entry's contextual menu.
2487 * @param obj The entry object
2488 * @param label The item's text label
2489 * @param icon_file The item's icon file
2490 * @param icon_type The item's icon type
2491 * @param func The callback to execute when the item is clicked
2492 * @param data The data to associate with the item for related functions
2497 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)
2499 ELM_CHECK_WIDTYPE(obj, widtype);
2500 Widget_Data *wd = elm_widget_data_get(obj);
2501 Elm_Entry_Context_Menu_Item *it;
2503 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2505 wd->items = eina_list_append(wd->items, it);
2507 it->label = eina_stringshare_add(label);
2508 it->icon_file = eina_stringshare_add(icon_file);
2509 it->icon_type = icon_type;
2511 it->data = (void *)data;
2515 * This disables the entry's contextual (right click) menu.
2517 * @param obj The entry object
2518 * @param disabled If true, the menu is disabled
2523 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2525 ELM_CHECK_WIDTYPE(obj, widtype);
2526 Widget_Data *wd = elm_widget_data_get(obj);
2528 if (wd->context_menu == !disabled) return;
2529 wd->context_menu = !disabled;
2533 * This returns whether the entry's contextual (right click) menu is disabled.
2535 * @param obj The entry object
2536 * @return If true, the menu is disabled
2541 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2543 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2544 Widget_Data *wd = elm_widget_data_get(obj);
2545 if (!wd) return EINA_FALSE;
2546 return !wd->context_menu;
2550 * This appends a custom item provider to the list for that entry
2552 * This appends the given callback. The list is walked from beginning to end
2553 * with each function called given the item href string in the text. If the
2554 * function returns an object handle other than NULL (it should create an
2555 * and object to do this), then this object is used to replace that item. If
2556 * not the next provider is called until one provides an item object, or the
2557 * default provider in entry does.
2559 * @param obj The entry object
2560 * @param func The function called to provide the item object
2561 * @param data The data passed to @p func
2566 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2568 ELM_CHECK_WIDTYPE(obj, widtype);
2569 Widget_Data *wd = elm_widget_data_get(obj);
2572 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2576 wd->item_providers = eina_list_append(wd->item_providers, ip);
2580 * This prepends a custom item provider to the list for that entry
2582 * This prepends the given callback. See elm_entry_item_provider_append() for
2585 * @param obj The entry object
2586 * @param func The function called to provide the item object
2587 * @param data The data passed to @p func
2592 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2594 ELM_CHECK_WIDTYPE(obj, widtype);
2595 Widget_Data *wd = elm_widget_data_get(obj);
2598 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2602 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2606 * This removes a custom item provider to the list for that entry
2608 * This removes the given callback. See elm_entry_item_provider_append() for
2611 * @param obj The entry object
2612 * @param func The function called to provide the item object
2613 * @param data The data passed to @p func
2618 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2620 ELM_CHECK_WIDTYPE(obj, widtype);
2621 Widget_Data *wd = elm_widget_data_get(obj);
2623 Elm_Entry_Item_Provider *ip;
2626 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2628 if ((ip->func == func) && (ip->data == data))
2630 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2638 * This converts a markup (HTML-like) string into UTF-8.
2640 * @param s The string (in markup) to be converted
2641 * @return The converted string (in UTF-8)
2646 elm_entry_markup_to_utf8(const char *s)
2648 char *ss = _mkup_to_text(s);
2649 if (!ss) ss = strdup("");
2654 * This converts a UTF-8 string into markup (HTML-like).
2656 * @param s The string (in UTF-8) to be converted
2657 * @return The converted string (in markup)
2662 elm_entry_utf8_to_markup(const char *s)
2664 char *ss = _text_to_mkup(s);
2665 if (!ss) ss = strdup("");
2670 * Get the input method context in the entry widget
2672 * @param obj The entry object
2673 * @return The input method context
2677 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
2679 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2680 Widget_Data *wd = elm_widget_data_get(obj);
2681 if (!wd || !wd->ent) return NULL;
2683 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
2687 * Set whether entry should enable the return key on soft keyboard automatically
2689 * @param obj The entry object
2690 * @param on If true, entry enables the return key on soft keyboard automatically.
2695 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
2697 ELM_CHECK_WIDTYPE(obj, widtype);
2698 Widget_Data *wd = elm_widget_data_get(obj);
2701 wd->autoreturnkey = on;
2702 _check_enable_returnkey(obj);
2706 * Set whether entry should support auto capitalization
2708 * @param obj The entry object
2709 * @param on If true, entry suports auto capitalization.
2714 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on)
2716 ELM_CHECK_WIDTYPE(obj, widtype);
2717 Eina_Bool autocap = on;
2718 Widget_Data *wd = elm_widget_data_get(obj);
2722 autocap = EINA_FALSE;
2726 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", autocap);
2730 * Set the font size on the entry object
2732 * @param obj The entry object
2733 * @param size font size
2738 elm_entry_fontsize_set(Evas_Object *obj, const int fontsize)
2740 ELM_CHECK_WIDTYPE(obj, widtype);
2741 Widget_Data *wd = elm_widget_data_get(obj);
2742 char *string, fontvalue[16], *entrystring;
2746 entrystring = elm_entry_entry_get(obj);
2747 if (entrystring == NULL) return;
2748 len = strlen(entrystring);
2749 if (len <= 0) return;
2750 string = alloca(sizeof(char)*(len+32));
2751 sprintf(fontvalue, "%d", fontsize);
2753 if (_string_key_value_replace(entrystring, "font_size", fontvalue, string) == 0)
2755 elm_entry_entry_set(obj, string);
2760 * Set the text align on the entry object
2762 * @param obj The entry object
2763 * @param align align mode
2768 elm_entry_text_align_set(Evas_Object *obj, char *alignmode)
2770 ELM_CHECK_WIDTYPE(obj, widtype);
2771 Widget_Data *wd = elm_widget_data_get(obj);
2772 char *string, *entrystring;
2776 entrystring = elm_entry_entry_get(obj);
2777 if (entrystring == NULL) return;
2778 len = strlen(entrystring);
2779 if (len <= 0) return;
2780 string = alloca(sizeof(char)*(len+32));
2782 if (_string_key_value_replace(entrystring, "align", alignmode, string) == 0)
2784 elm_entry_entry_set(obj, string);
2789 * Set the text color on the entry object
2791 * @param obj The entry object
2792 * @param r Red property background color of The entry object
2793 * @param g Green property background color of The entry object
2794 * @param b Blue property background color of The entry object
2795 * @param a Alpha property background alpha of The entry object
2800 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
2802 ELM_CHECK_WIDTYPE(obj, widtype);
2803 Widget_Data *wd = elm_widget_data_get(obj);
2804 char *string, *entrystring, colorstring[16];
2808 entrystring = elm_entry_entry_get(obj);
2809 if (entrystring == NULL) return;
2810 len = strlen(entrystring);
2811 if (len <= 0) return;
2812 string = alloca(sizeof(char)*(len+32));
2814 sprintf(colorstring, "#%02X%02X%02X%02X", r, g, b, a);
2815 if (_string_key_value_replace(entrystring, "color", colorstring, string) == 0)
2817 elm_entry_entry_set(obj, string);
2823 * Set background color of the entry
2825 * @param obj The entry object
2826 * @param r Red property background color of The entry object
2827 * @param g Green property background color of The entry object
2828 * @param b Blue property background color of The entry object
2829 * @param a Alpha property background alpha of The entry object
2833 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
2835 ELM_CHECK_WIDTYPE(obj, widtype);
2836 Widget_Data *wd = elm_widget_data_get(obj);
2837 evas_object_color_set(wd->bg, r, g, b, a);
2839 if (wd->bgcolor == EINA_FALSE)
2842 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
2847 * Set the ellipsis behavior of the entry
2849 * @param obj The entry object
2850 * @param ellipsis To ellipsis text or not
2854 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
2856 ELM_CHECK_WIDTYPE(obj, widtype);
2857 Widget_Data *wd = elm_widget_data_get(obj);
2859 if (wd->ellipsis == ellipsis) return;
2860 wd->ellipsis = ellipsis;
2866 * enable to show the input panel automatically.
2868 * @param obj The entry object
2869 * @param enabled If true, the input panel is enabled
2874 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2876 ELM_CHECK_WIDTYPE(obj, widtype);
2877 Widget_Data *wd = elm_widget_data_get(obj);
2880 wd->input_panel_enable = enabled;
2881 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
2885 * Set the input panel layout of the entry
2887 * @param obj The entry object
2888 * @param layout the layout to set
2893 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
2895 ELM_CHECK_WIDTYPE(obj, widtype);
2896 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
2899 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);