1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "elm_module_priv.h"
7 * @defgroup Entry Entry
9 * An entry is a convenience widget which shows
10 * a box that the user can enter text into. Unlike a
11 * @ref Scrolled_Entry widget, entries DO NOT scroll with user
12 * input. Entry widgets are capable of expanding past the
13 * boundaries of the window, thus resizing the window to its
16 * You can also insert "items" in the entry with:
18 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
20 * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
21 * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
22 * supports a list of emoticon names by default. These are:
25 * - emoticon/angry-shout
26 * - emoticon/crazy-laugh
27 * - emoticon/evil-laugh
29 * - emoticon/goggle-smile
31 * - emoticon/grumpy-smile
33 * - emoticon/guilty-smile
35 * - emoticon/half-smile
36 * - emoticon/happy-panting
38 * - emoticon/indifferent
40 * - emoticon/knowing-grin
42 * - emoticon/little-bit-sorry
43 * - emoticon/love-lots
45 * - emoticon/minimal-smile
46 * - emoticon/not-happy
47 * - emoticon/not-impressed
49 * - emoticon/opensmile
52 * - emoticon/squint-laugh
53 * - emoticon/surprised
54 * - emoticon/suspicious
55 * - emoticon/tongue-dangling
56 * - emoticon/tongue-poke
59 * - emoticon/very-sorry
65 * These are built-in currently, but you can add your own item provieer that
66 * can create inlined objects in the text and fill the space allocated to the
67 * item with a custom object of your own.
69 * See the entry test for some more examples of use of this.
71 * Entries have functions to load a text file, display it,
72 * allowing editing of it and saving of changes back to the file loaded.
73 * Changes are written back to the original file after a short delay.
74 * The file to load and save to is specified by elm_entry_file_set().
76 * Signals that you can add callbacks for are:
77 * - "changed" - The text within the entry was changed
78 * - "activated" - The entry has had editing finished and changes are to be committed (generally when enter key is pressed)
79 * - "press" - The entry has been clicked
80 * - "longpressed" - The entry has been clicked for a couple seconds
81 * - "clicked" - The entry has been clicked
82 * - "clicked,double" - The entry has been double clicked
83 * - "focused" - The entry has received focus
84 * - "unfocused" - The entry has lost focus
85 * - "selection,paste" - A paste action has occurred
86 * - "selection,copy" - A copy action has occurred
87 * - "selection,cut" - A cut action has occurred
88 * - "selection,start" - A selection has begun
89 * - "selection,changed" - The selection has changed
90 * - "selection,cleared" - The selection has been cleared
91 * - "cursor,changed" - The cursor has changed
92 * - "anchor,clicked" - The anchor has been clicked
95 typedef struct _Mod_Api Mod_Api;
97 typedef struct _Widget_Data Widget_Data;
98 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
99 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
100 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
106 Evas_Object *hoversel;
110 Evas_Object *mgf_proxy;
111 Evas_Object *mgf_clip;
113 Evas_Coord mgf_height;
116 Ecore_Job *deferred_recalc_job;
117 Ecore_Event_Handler *sel_notify_handler;
118 Ecore_Event_Handler *sel_clear_handler;
119 Ecore_Timer *longpress_timer;
120 Ecore_Timer *delay_write;
121 /* Only for clipboard */
125 int ellipsis_threshold;
127 Elm_Text_Format format;
129 Evas_Coord downx, downy;
130 Evas_Coord cx, cy, cw, ch;
132 Eina_List *item_providers;
133 Eina_List *text_filters;
134 Eina_List *match_list;
135 Ecore_Job *matchlist_job;
136 Ecore_Job *hovdeljob;
137 Mod_Api *api; // module api if supplied
139 Eina_Bool changed : 1;
140 Eina_Bool linewrap : 1;
141 Eina_Bool char_linewrap : 1;
142 Eina_Bool single_line : 1;
143 Eina_Bool password : 1;
144 Eina_Bool show_last_character : 1;
145 Eina_Bool editable : 1;
146 Eina_Bool selection_asked : 1;
147 Eina_Bool have_selection : 1;
148 Eina_Bool selmode : 1;
149 Eina_Bool deferred_cur : 1;
150 Eina_Bool disabled : 1;
151 Eina_Bool double_clicked : 1;
152 Eina_Bool long_pressed : 1;
153 Eina_Bool context_menu : 1;
154 Eina_Bool drag_selection_asked : 1;
155 Eina_Bool bgcolor : 1;
156 Eina_Bool ellipsis : 1;
157 Eina_Bool can_write : 1;
158 Eina_Bool autosave : 1;
159 Eina_Bool textonly : 1;
160 Eina_Bool autoreturnkey : 1;
161 Eina_Bool input_panel_enable : 1;
162 Eina_Bool autocapital : 1;
163 Elm_Input_Panel_Layout input_panel_layout;
164 Eina_Bool autoperiod : 1;
165 Eina_Bool matchlist_list_clicked : 1;
166 Eina_Bool matchlist_case_sensitive : 1;
167 int matchlist_threshold;
170 struct _Elm_Entry_Context_Menu_Item
174 const char *icon_file;
175 const char *icon_group;
176 Elm_Icon_Type icon_type;
181 struct _Elm_Entry_Item_Provider
183 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
187 struct _Elm_Entry_Text_Filter
189 void (*func) (void *data, Evas_Object *entry, char **text);
193 static const char *widtype = NULL;
195 static Evas_Object *cnpwidgetdata = NULL;
198 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
199 static void _del_hook(Evas_Object *obj);
200 static void _theme_hook(Evas_Object *obj);
201 static void _disable_hook(Evas_Object *obj);
202 static void _sizing_eval(Evas_Object *obj);
203 static void _on_focus_hook(void *data, Evas_Object *obj);
204 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
205 static const char *_getbase(Evas_Object *obj);
206 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
207 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
208 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
209 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
210 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
211 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
212 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
213 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
214 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
215 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
216 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
217 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
218 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
219 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
220 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
221 static int _is_width_over(Evas_Object *obj);
222 static void _ellipsis_entry_to_width(Evas_Object *obj);
223 static void _reverse_ellipsis_entry(Evas_Object *obj);
224 static int _entry_length_get(Evas_Object *obj);
225 static void _magnifier_create(void *data);
226 static void _magnifier_show(void *data);
227 static void _magnifier_hide(void *data);
228 static void _magnifier_move(void *data);
229 static void _long_pressed(void *data);
231 static const char SIG_CHANGED[] = "changed";
232 static const char SIG_ACTIVATED[] = "activated";
233 static const char SIG_PRESS[] = "press";
234 static const char SIG_LONGPRESSED[] = "longpressed";
235 static const char SIG_CLICKED[] = "clicked";
236 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
237 static const char SIG_FOCUSED[] = "focused";
238 static const char SIG_UNFOCUSED[] = "unfocused";
239 static const char SIG_SELECTION_PASTE[] = "selection,paste";
240 static const char SIG_SELECTION_COPY[] = "selection,copy";
241 static const char SIG_SELECTION_CUT[] = "selection,cut";
242 static const char SIG_SELECTION_START[] = "selection,start";
243 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
244 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
245 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
246 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
247 static const char SIG_MATCHLIST_CLICKED[] = "matchlist,clicked";
248 static const Evas_Smart_Cb_Description _signals[] = {
252 {SIG_LONGPRESSED, ""},
254 {SIG_CLICKED_DOUBLE, ""},
257 {SIG_SELECTION_PASTE, ""},
258 {SIG_SELECTION_COPY, ""},
259 {SIG_SELECTION_CUT, ""},
260 {SIG_SELECTION_START, ""},
261 {SIG_SELECTION_CHANGED, ""},
262 {SIG_SELECTION_CLEARED, ""},
263 {SIG_CURSOR_CHANGED, ""},
264 {SIG_ANCHOR_CLICKED, ""},
265 {SIG_MATCHLIST_CLICKED, ""},
269 typedef enum _Elm_Entry_Magnifier_Type
271 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
272 _ENTRY_MAGNIFIER_FILLWIDTH,
273 _ENTRY_MAGNIFIER_CIRCULAR,
274 } Elm_Entry_Magnifier_Type;
277 static Eina_List *entries = NULL;
281 void (*obj_hook) (Evas_Object *obj);
282 void (*obj_unhook) (Evas_Object *obj);
283 void (*obj_longpress) (Evas_Object *obj);
284 void (*obj_hidemenu) (Evas_Object *obj);
285 void (*obj_mouseup) (Evas_Object *obj);
289 _module(Evas_Object *obj __UNUSED__)
291 static Elm_Module *m = NULL;
292 if (m) goto ok; // already found - just use
293 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
295 m->api = malloc(sizeof(Mod_Api));
296 if (!m->api) return NULL;
297 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
298 _elm_module_symbol_get(m, "obj_hook");
299 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
300 _elm_module_symbol_get(m, "obj_unhook");
301 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
302 _elm_module_symbol_get(m, "obj_longpress");
303 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
304 _elm_module_symbol_get(m, "obj_hidemenu");
305 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
306 _elm_module_symbol_get(m, "obj_mouseup");
307 ok: // ok - return api
312 _buf_append(char *buf, const char *str, int *len, int *alloc)
314 int len2 = strlen(str);
315 if ((*len + len2) >= *alloc)
317 char *buf2 = realloc(buf, *alloc + len2 + 512);
318 if (!buf2) return NULL;
320 *alloc += (512 + len2);
322 strcpy(buf + *len, str);
328 _load_file(const char *file)
332 int alloc = 0, len = 0;
333 char *text = NULL, buf[PATH_MAX];
335 f = fopen(file, "rb");
337 while ((size = fread(buf, 1, sizeof(buf), f)))
341 tmp_text = _buf_append(text, buf, &len, &alloc);
342 if (!tmp_text) break;
350 _load_plain(const char *file)
354 text = _load_file(file);
359 text2 = elm_entry_utf8_to_markup(text);
367 _load(Evas_Object *obj)
369 Widget_Data *wd = elm_widget_data_get(obj);
374 elm_entry_entry_set(obj, "");
379 case ELM_TEXT_FORMAT_PLAIN_UTF8:
380 text = _load_plain(wd->file);
382 case ELM_TEXT_FORMAT_MARKUP_UTF8:
383 text = _load_file(wd->file);
391 elm_entry_entry_set(obj, text);
395 elm_entry_entry_set(obj, "");
399 _save_markup_utf8(const char *file, const char *text)
403 if ((!text) || (!text[0]))
405 ecore_file_unlink(file);
408 f = fopen(file, "wb");
411 // FIXME: report a write error
414 fputs(text, f); // FIXME: catch error
419 _save_plain_utf8(const char *file, const char *text)
423 text2 = elm_entry_markup_to_utf8(text);
426 _save_markup_utf8(file, text2);
431 _save(Evas_Object *obj)
433 Widget_Data *wd = elm_widget_data_get(obj);
435 if (!wd->file) return;
438 case ELM_TEXT_FORMAT_PLAIN_UTF8:
439 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
441 case ELM_TEXT_FORMAT_MARKUP_UTF8:
442 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
450 _delay_write(void *data)
452 Widget_Data *wd = elm_widget_data_get(data);
453 if (!wd) return ECORE_CALLBACK_CANCEL;
455 wd->delay_write = NULL;
456 return ECORE_CALLBACK_CANCEL;
460 _del_pre_hook(Evas_Object *obj)
462 Widget_Data *wd = elm_widget_data_get(obj);
466 ecore_timer_del(wd->delay_write);
467 wd->delay_write = NULL;
468 if (wd->autosave) _save(obj);
473 _del_hook(Evas_Object *obj)
475 Widget_Data *wd = elm_widget_data_get(obj);
476 Elm_Entry_Context_Menu_Item *it;
477 Elm_Entry_Item_Provider *ip;
478 Elm_Entry_Text_Filter *tf;
480 if (wd->file) eina_stringshare_del(wd->file);
482 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
483 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
485 entries = eina_list_remove(entries, obj);
486 #ifdef HAVE_ELEMENTARY_X
487 ecore_event_handler_del(wd->sel_notify_handler);
488 ecore_event_handler_del(wd->sel_clear_handler);
490 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
491 if (wd->text) eina_stringshare_del(wd->text);
492 if (wd->bg) evas_object_del(wd->bg);
493 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
494 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
495 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
496 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
497 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
498 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
500 EINA_LIST_FREE(wd->items, it)
502 eina_stringshare_del(it->label);
503 eina_stringshare_del(it->icon_file);
504 eina_stringshare_del(it->icon_group);
507 EINA_LIST_FREE(wd->item_providers, ip)
511 EINA_LIST_FREE(wd->text_filters, tf)
519 _theme_hook(Evas_Object *obj)
521 Widget_Data *wd = elm_widget_data_get(obj);
523 Ecore_IMF_Context *ic;
525 t = eina_stringshare_add(elm_entry_entry_get(obj));
526 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
527 elm_entry_entry_set(obj, t);
528 eina_stringshare_del(t);
529 if (elm_widget_disabled_get(obj))
530 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
531 edje_object_message_signal_process(wd->ent);
532 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
533 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
534 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
535 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
537 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
540 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
547 _disable_hook(Evas_Object *obj)
549 Widget_Data *wd = elm_widget_data_get(obj);
551 if (elm_widget_disabled_get(obj))
553 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
554 wd->disabled = EINA_TRUE;
558 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
559 wd->disabled = EINA_FALSE;
564 _elm_win_recalc_job(void *data)
566 Widget_Data *wd = elm_widget_data_get(data);
567 Evas_Coord minw = -1, minh = -1, maxh = -1;
568 Evas_Coord resw, resh, minminw;
570 wd->deferred_recalc_job = NULL;
571 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
573 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
574 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
576 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
577 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
578 evas_object_size_hint_min_set(data, minminw, minh);
579 if (wd->single_line) maxh = minh;
580 evas_object_size_hint_max_set(data, -1, maxh);
581 if (wd->deferred_cur)
582 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
586 _sizing_eval(Evas_Object *obj)
588 Widget_Data *wd = elm_widget_data_get(obj);
589 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
590 Evas_Coord resw, resh;
592 if ((wd->linewrap) || (wd->char_linewrap))
594 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
595 if ((resw == wd->lastw) && (!wd->changed)) return;
596 wd->changed = EINA_FALSE;
598 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
599 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
603 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
604 edje_object_size_min_calc(wd->ent, &minw, &minh);
605 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
606 evas_object_size_hint_min_set(obj, minw, minh);
607 if (wd->single_line) maxh = minh;
608 evas_object_size_hint_max_set(obj, maxw, maxh);
610 if (wd->ellipsis && wd->single_line)
612 if (_is_width_over(obj))
613 _ellipsis_entry_to_width(obj);
614 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
615 _reverse_ellipsis_entry(obj);
621 _check_enable_returnkey(Evas_Object *obj)
623 Widget_Data *wd = elm_widget_data_get(obj);
626 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
629 if (!wd->autoreturnkey) return;
631 if (_entry_length_get(obj) == 0)
633 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
637 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
642 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
644 Widget_Data *wd = elm_widget_data_get(obj);
645 Evas_Object *top = elm_widget_top_get(obj);
648 if (!wd->editable) return;
649 if (elm_widget_focus_get(obj))
651 evas_object_focus_set(wd->ent, EINA_TRUE);
652 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
653 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
654 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
655 _check_enable_returnkey(obj);
656 wd->mgf_type = _ENTRY_MAGNIFIER_FILLWIDTH;
657 _magnifier_create(obj);
661 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
662 evas_object_focus_set(wd->ent, EINA_FALSE);
663 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
664 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
666 if ((wd->api) && (wd->api->obj_hidemenu))
668 wd->api->obj_hidemenu(obj);
674 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
676 Widget_Data *wd = elm_widget_data_get(obj);
678 edje_object_signal_emit(wd->ent, emission, source);
682 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
684 Widget_Data *wd = elm_widget_data_get(obj);
686 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
690 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
692 Widget_Data *wd = elm_widget_data_get(obj);
693 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
698 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
700 Widget_Data *wd = elm_widget_data_get(obj);
701 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
705 _hoversel_position(Evas_Object *obj)
707 Widget_Data *wd = elm_widget_data_get(obj);
708 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
710 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
711 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
713 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
724 evas_object_move(wd->hoversel, x + cx, y + cy);
725 evas_object_resize(wd->hoversel, cw, ch);
729 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
731 Widget_Data *wd = elm_widget_data_get(data);
733 if (wd->hoversel) _hoversel_position(data);
737 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
739 Widget_Data *wd = elm_widget_data_get(data);
741 if ((wd->linewrap) || (wd->char_linewrap))
745 if (wd->hoversel) _hoversel_position(data);
746 // Evas_Coord ww, hh;
747 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
751 _hover_del(void *data)
753 Widget_Data *wd = elm_widget_data_get(data);
758 evas_object_del(wd->hoversel);
761 wd->hovdeljob = NULL;
765 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
767 Widget_Data *wd = elm_widget_data_get(data);
769 if (wd->hoversel) evas_object_hide(wd->hoversel);
773 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
775 elm_widget_scroll_freeze_pop(data);
776 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
777 wd->hovdeljob = ecore_job_add(_hover_del, data);
781 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
783 Widget_Data *wd = elm_widget_data_get(data);
785 wd->selmode = EINA_TRUE;
786 edje_object_part_text_select_none(wd->ent, "elm.text");
787 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
788 edje_object_part_text_select_all(wd->ent, "elm.text");
789 elm_object_scroll_freeze_pop(data);
793 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
795 Widget_Data *wd = elm_widget_data_get(data);
797 wd->selmode = EINA_TRUE;
798 edje_object_part_text_select_none(wd->ent, "elm.text");
800 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
801 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
802 elm_object_scroll_freeze_pop(data);
806 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
808 Widget_Data *wd = elm_widget_data_get(data);
810 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
811 if (wd->sel_notify_handler)
813 #ifdef HAVE_ELEMENTARY_X
814 wd->selection_asked = EINA_TRUE;
815 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
821 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
823 Widget_Data *wd = elm_widget_data_get(obj);
827 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
828 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
829 if (seltype == ELM_SEL_CLIPBOARD)
830 eina_stringshare_replace(&wd->cut_sel, sel);
834 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
836 Widget_Data *wd = elm_widget_data_get(data);
839 wd->selmode = EINA_FALSE;
840 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
841 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
842 elm_widget_scroll_hold_pop(data);
843 _store_selection(ELM_SEL_CLIPBOARD, data);
844 edje_object_part_text_insert(wd->ent, "elm.text", "");
845 edje_object_part_text_select_none(wd->ent, "elm.text");
849 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
851 Widget_Data *wd = elm_widget_data_get(data);
853 //wd->selmode = EINA_FALSE;
854 //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
855 //edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
856 elm_widget_scroll_hold_pop(data);
857 _store_selection(ELM_SEL_CLIPBOARD, data);
858 //edje_object_part_text_select_none(wd->ent, "elm.text");
862 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
864 Widget_Data *wd = elm_widget_data_get(data);
866 wd->selmode = EINA_FALSE;
867 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
868 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
869 elm_widget_scroll_hold_pop(data);
870 edje_object_part_text_select_none(wd->ent, "elm.text");
874 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
876 Widget_Data *wd = elm_widget_data_get(data);
880 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
881 cnpwidgetdata = data;
882 elm_cbhm_helper_init(obj);
883 if (elm_entry_cnp_textonly_get(obj))
884 elm_cbhm_send_raw_data("show0");
886 elm_cbhm_send_raw_data("show1");
892 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
894 Widget_Data *wd = elm_widget_data_get(data);
896 cnpwidgetdata = data;
902 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
904 Elm_Entry_Context_Menu_Item *it = data;
905 Evas_Object *obj2 = it->obj;
906 if (it->func) it->func(it->data, obj2, NULL);
910 _long_pressed(void *data)
912 Widget_Data *wd = elm_widget_data_get(data);
915 const Elm_Entry_Context_Menu_Item *it;
917 if ((wd->api) && (wd->api->obj_longpress))
919 wd->api->obj_longpress(data);
921 else if (wd->context_menu)
923 const char *context_menu_orientation;
925 if (wd->hoversel) evas_object_del(wd->hoversel);
926 else elm_widget_scroll_freeze_push(data);
927 wd->hoversel = elm_hoversel_add(data);
928 context_menu_orientation = edje_object_data_get
929 (wd->ent, "context_menu_orientation");
930 if ((context_menu_orientation) &&
931 (!strcmp(context_menu_orientation, "horizontal")))
932 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
933 elm_object_style_set(wd->hoversel, "entry");
934 elm_widget_sub_object_add(data, wd->hoversel);
935 elm_hoversel_label_set(wd->hoversel, "Text");
936 top = elm_widget_top_get(data);
937 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
938 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
942 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
944 if (1) // need way to detect if someone has a selection
947 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
951 if ((!wd->password) && (wd->editable))
952 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
953 _clipboard_menu, data);
960 if (wd->have_selection)
962 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
965 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
968 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
972 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
973 _clipboard_menu, data);
977 EINA_LIST_FOREACH(wd->items, l, it)
979 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
980 it->icon_type, _item_clicked, it);
984 _hoversel_position(data);
985 evas_object_show(wd->hoversel);
986 elm_hoversel_hover_begin(wd->hoversel);
988 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
989 edje_object_part_text_select_abort(wd->ent, "elm.text");
992 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
996 _magnifier_hide(void *data)
998 Widget_Data *wd = elm_widget_data_get(data);
1000 if (evas_version->major < 2 && evas_version->minor < 1) return;
1002 evas_object_hide(wd->mgf_bg);
1003 evas_object_hide(wd->mgf_clip);
1007 _magnifier_show(void *data)
1009 Widget_Data *wd = elm_widget_data_get(data);
1011 if (evas_version->major < 2 && evas_version->minor < 1) return;
1013 evas_object_show(wd->mgf_bg);
1014 evas_object_show(wd->mgf_clip);
1018 _magnifier_move(void *data)
1020 Widget_Data *wd = elm_widget_data_get(data);
1022 if (evas_version->major < 2 && evas_version->minor < 1) return;
1024 Evas_Coord x, y, w, h, fs;
1025 Evas_Coord cx, cy, cw, ch, ox, oy;
1027 evas_object_geometry_get(data, &x, &y, &w, &h);
1028 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1031 fs = elm_finger_size_get();
1033 if ((cy + y) - wd->mgf_height - fs < 0)
1034 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1036 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1037 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1038 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1039 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1043 evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 - fs + oy);
1047 _magnifier_create(void *data)
1049 Widget_Data *wd = elm_widget_data_get(data);
1050 Evas_Coord x, y, w, h;
1051 const char* key_data = NULL;
1054 if (evas_version->major < 2 && evas_version->minor < 1) return;
1058 evas_object_image_source_unset(wd->mgf_proxy);
1059 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1060 evas_object_hide(wd->mgf_proxy);
1061 evas_object_clip_unset(wd->mgf_proxy);
1062 evas_object_del(wd->mgf_proxy);
1064 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1065 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1067 evas_object_geometry_get(data, &x, &y, &w, &h);
1068 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1070 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1071 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1072 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1073 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1077 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1078 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1079 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1081 key_data = edje_object_data_get(wd->mgf_bg, "height");
1082 if (key_data) wd->mgf_height = atoi(key_data);
1083 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1084 if (key_data) wd->mgf_scale = atof(key_data);
1086 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1087 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1089 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1090 evas_object_image_source_set(wd->mgf_proxy, data);
1091 evas_object_resize(wd->mgf_proxy, w * wd->mgf_scale, h * wd->mgf_scale);
1092 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, w * wd->mgf_scale, h * wd->mgf_scale);
1093 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1094 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1095 evas_object_show(wd->mgf_proxy);
1096 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1098 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1099 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1103 _long_press(void *data)
1105 Widget_Data *wd = elm_widget_data_get(data);
1106 if (!wd) return ECORE_CALLBACK_CANCEL;
1108 wd->long_pressed = EINA_TRUE;
1110 if (wd->longpress_timer)
1112 ecore_timer_del(wd->longpress_timer);
1113 wd->longpress_timer = NULL;
1116 _cancel(data, NULL, NULL);
1118 _magnifier_create(data);
1119 _magnifier_move(data);
1120 _magnifier_show(data);
1121 elm_object_scroll_freeze_push(data);
1123 wd->longpress_timer = NULL;
1124 return ECORE_CALLBACK_CANCEL;
1128 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1130 Widget_Data *wd = elm_widget_data_get(data);
1131 Evas_Event_Mouse_Down *ev = event_info;
1133 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1134 if (ev->button != 1) return;
1135 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1136 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1137 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1138 wd->downx = ev->canvas.x;
1139 wd->downy = ev->canvas.y;
1141 wd->long_pressed = EINA_FALSE;
1145 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1147 Widget_Data *wd = elm_widget_data_get(data);
1148 Evas_Event_Mouse_Up *ev = event_info;
1150 if (ev->button != 1) return;
1152 if (!wd->double_clicked)
1154 if ((wd->api) && (wd->api->obj_mouseup))
1156 wd->api->obj_mouseup(data);
1159 if (wd->longpress_timer)
1161 ecore_timer_del(wd->longpress_timer);
1162 wd->longpress_timer = NULL;
1165 _magnifier_hide(data);
1166 elm_object_scroll_freeze_pop(data);
1168 if (wd->long_pressed)
1170 _long_pressed(data);
1175 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1177 Widget_Data *wd = elm_widget_data_get(data);
1178 Evas_Event_Mouse_Move *ev = event_info;
1182 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1184 if (wd->longpress_timer)
1186 ecore_timer_del(wd->longpress_timer);
1187 wd->longpress_timer = NULL;
1190 else if (wd->longpress_timer)
1194 dx = wd->downx - ev->cur.canvas.x;
1196 dy = wd->downy - ev->cur.canvas.y;
1199 ((_elm_config->finger_size / 2) *
1200 (_elm_config->finger_size / 2)))
1202 ecore_timer_del(wd->longpress_timer);
1203 wd->longpress_timer = NULL;
1207 else if (wd->longpress_timer)
1211 dx = wd->downx - ev->cur.canvas.x;
1213 dy = wd->downy - ev->cur.canvas.y;
1216 ((_elm_config->finger_size / 2) *
1217 (_elm_config->finger_size / 2)))
1219 ecore_timer_del(wd->longpress_timer);
1220 wd->longpress_timer = NULL;
1224 if (ev->buttons != 1) return;
1226 if (wd->long_pressed)
1228 _magnifier_show(data);
1229 _magnifier_move(data);
1234 _getbase(Evas_Object *obj)
1236 Widget_Data *wd = elm_widget_data_get(obj);
1237 if (!wd) return "base";
1242 if (wd->show_last_character) return "custom-password";
1243 else return "base-password";
1247 if (wd->single_line) return "base-single";
1250 if (wd->linewrap) return "base";
1251 else if (wd->char_linewrap) return "base-charwrap";
1252 else return "base-nowrap";
1260 if (wd->show_last_character) return "custom-password";
1261 else return "base-password";
1265 if (wd->single_line) return "base-single-noedit";
1268 if (wd->linewrap) return "base-noedit";
1269 else if (wd->char_linewrap) return "base-noedit-charwrap";
1270 else return "base-nowrap-noedit";
1278 _entry_length_get(Evas_Object *obj)
1281 const char *str = elm_entry_entry_get(obj);
1284 char *plain_str = _elm_util_mkup_to_text(str);
1285 if (!plain_str) return 0;
1287 len = strlen(plain_str);
1294 _matchlist_show(void *data)
1296 Widget_Data *wd = elm_widget_data_get(data);
1297 const char *text = NULL;
1299 char *str_list = NULL, *str_result = NULL;
1300 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1303 Eina_Bool textfound = EINA_FALSE;
1306 if (elm_widget_disabled_get(data)) return;
1308 wd->matchlist_job = NULL;
1310 if (wd->matchlist_list_clicked)
1312 evas_object_hide(wd->hover);
1313 wd->matchlist_list_clicked = EINA_FALSE;
1316 text = elm_entry_entry_get(data);
1319 textlen = strlen(text);
1321 if (textlen < wd->matchlist_threshold)
1323 evas_object_hide(wd->hover);
1327 evas_object_hide(wd->hover);
1331 elm_list_clear(wd->list);
1332 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1334 if (wd->matchlist_case_sensitive)
1335 str_result = strstr(str_list, text);
1337 str_result = strcasestr(str_list, text);
1341 str_mkup = malloc(strlen(str_list) + 16);
1343 textlen = strlen(str_list) - strlen(str_result);
1344 str_front = malloc(textlen + 1);
1345 memset(str_front, 0, textlen + 1);
1346 strncpy(str_front, str_list, textlen);
1348 textlen = strlen(text);
1349 str_mid = malloc(textlen + 1);
1350 memset(str_mid, 0, textlen + 1);
1351 strncpy(str_mid, str_list + strlen(str_front), textlen);
1353 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1355 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1357 if (str_mkup) free(str_mkup);
1358 if (str_front) free(str_front);
1359 if (str_mid) free(str_mid);
1361 textfound=EINA_TRUE;
1370 elm_list_go(wd->list);
1371 evas_object_show(wd->hover);
1372 evas_object_raise(wd->hover);
1376 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1378 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1379 Widget_Data *wd = elm_widget_data_get(data);
1380 if ((it == NULL) || (wd == NULL))
1383 const char *text = elm_list_item_label_get(it);
1384 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1389 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1390 elm_entry_cursor_end_set(data);
1391 wd->matchlist_list_clicked = EINA_TRUE;
1393 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1396 elm_widget_focus_set(data, EINA_TRUE);
1400 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
1402 Widget_Data *wd = elm_widget_data_get(obj);
1407 Evas_Coord max_w = 9999, max_h = 9999;
1408 const char* key_data = NULL;
1410 wd->matchlist_threshold = 1;
1411 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
1412 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
1413 elm_hover_target_set(wd->hover, obj);
1414 elm_object_style_set(wd->hover, "matchlist");
1416 wd->layout = elm_layout_add(wd->hover);
1417 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
1418 wd->list = elm_list_add(wd->layout);
1419 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
1420 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1421 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
1422 elm_object_style_set(wd->list, "matchlist");
1424 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
1425 if (key_data) max_w = atoi(key_data);
1426 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
1427 if (key_data) max_h = atoi(key_data);
1429 elm_list_go(wd->list);
1430 evas_object_size_hint_max_set(wd->list, max_w, max_h);
1431 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
1432 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
1433 elm_hover_content_set(wd->hover, "bottom", wd->layout);
1435 wd->match_list = match_list;
1440 evas_object_del(wd->hover);
1442 wd->match_list = NULL;
1445 wd->matchlist_case_sensitive = case_sensitive;
1450 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1452 Widget_Data *wd = elm_widget_data_get(data);
1454 wd->changed = EINA_TRUE;
1456 if (wd->text) eina_stringshare_del(wd->text);
1458 _check_enable_returnkey(data);
1459 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1460 if (wd->delay_write)
1462 ecore_timer_del(wd->delay_write);
1463 wd->delay_write = NULL;
1466 if ((wd->single_line) && (wd->match_list))
1468 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1469 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1471 if ((!wd->autosave) || (!wd->file)) return;
1472 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1476 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1478 Widget_Data *wd = elm_widget_data_get(data);
1479 elm_object_scroll_freeze_push(data);
1481 if ((wd->api) && (wd->api->obj_hidemenu))
1483 wd->api->obj_hidemenu(data);
1486 _magnifier_create(data);
1487 _magnifier_move(data);
1488 _magnifier_show(data);
1492 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1494 Widget_Data *wd = elm_widget_data_get(data);
1495 elm_object_scroll_freeze_pop(data);
1497 if (wd->have_selection)
1499 _magnifier_hide(data);
1500 _long_pressed(data);
1505 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1507 _magnifier_move(data);
1508 _magnifier_show(data);
1512 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1514 _magnifier_hide(data);
1515 _long_pressed(data);
1519 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1521 Widget_Data *wd = elm_widget_data_get(data);
1525 EINA_LIST_FOREACH(entries, l, entry)
1527 if (entry != data) elm_entry_select_none(entry);
1529 wd->have_selection = EINA_TRUE;
1530 wd->selmode = EINA_TRUE;
1531 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1532 #ifdef HAVE_ELEMENTARY_X
1533 if (wd->sel_notify_handler)
1535 const char *txt = elm_entry_selection_get(data);
1538 top = elm_widget_top_get(data);
1539 if ((top) && (elm_win_xwindow_get(top)))
1540 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1546 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1548 Evas_Coord cx, cy, cw, ch;
1549 Widget_Data *wd = elm_widget_data_get(data);
1552 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1553 if (!wd->deferred_recalc_job)
1554 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1557 wd->deferred_cur = EINA_TRUE;
1561 wd->ch = ch + elm_finger_size_get();
1566 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1568 Evas_Coord cx, cy, cw, ch;
1569 Widget_Data *wd = elm_widget_data_get(data);
1571 wd->have_selection = EINA_TRUE;
1572 wd->selmode = EINA_TRUE;
1573 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1574 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1575 elm_entry_selection_get(data));
1577 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1578 if (!wd->deferred_recalc_job)
1579 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1582 wd->deferred_cur = EINA_TRUE;
1586 wd->ch = ch + elm_finger_size_get();
1591 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1593 Widget_Data *wd = elm_widget_data_get(data);
1595 if (!wd->have_selection) return;
1596 wd->have_selection = EINA_FALSE;
1597 wd->selmode = EINA_FALSE;
1598 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1599 if (wd->sel_notify_handler)
1603 #ifdef HAVE_ELEMENTARY_X
1606 top = elm_widget_top_get(data);
1607 if ((top) && (elm_win_xwindow_get(top)))
1608 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1611 eina_stringshare_del(wd->cut_sel);
1616 #ifdef HAVE_ELEMENTARY_X
1619 top = elm_widget_top_get(data);
1620 if ((top) && (elm_win_xwindow_get(top)))
1621 elm_selection_clear(ELM_SEL_PRIMARY, data);
1626 if ((wd->api) && (wd->api->obj_hidemenu))
1628 wd->api->obj_hidemenu(data);
1633 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1635 Widget_Data *wd = elm_widget_data_get(data);
1637 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1638 if (wd->sel_notify_handler)
1640 #ifdef HAVE_ELEMENTARY_X
1643 top = elm_widget_top_get(data);
1644 if ((top) && (elm_win_xwindow_get(top)))
1646 wd->selection_asked = EINA_TRUE;
1647 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
1655 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1657 Widget_Data *wd = elm_widget_data_get(data);
1659 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1660 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1661 elm_entry_selection_get(data));
1665 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1667 Widget_Data *wd = elm_widget_data_get(data);
1669 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1670 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1671 elm_entry_selection_get(data));
1672 edje_object_part_text_insert(wd->ent, "elm.text", "");
1673 wd->changed = EINA_TRUE;
1678 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1680 Widget_Data *wd = elm_widget_data_get(data);
1681 Evas_Coord cx, cy, cw, ch;
1683 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1684 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1685 &cx, &cy, &cw, &ch);
1686 if (!wd->deferred_recalc_job)
1687 elm_widget_show_region_set(data, cx, cy, cw, ch);
1690 wd->deferred_cur = EINA_TRUE;
1699 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1701 Widget_Data *wd = elm_widget_data_get(data);
1706 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1708 Widget_Data *wd = elm_widget_data_get(data);
1709 Elm_Entry_Anchor_Info ei;
1710 char *buf2, *p, *p2, *n;
1712 p = strrchr(emission, ',');
1715 const Eina_List *geoms;
1719 while (p2 >= emission)
1721 if (*p2 == ',') break;
1725 buf2 = alloca(5 + p - p2);
1726 strncpy(buf2, p2, p - p2);
1729 ei.button = atoi(buf2);
1730 ei.x = ei.y = ei.w = ei.h = 0;
1732 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1735 Evas_Textblock_Rectangle *r;
1737 Evas_Coord px, py, x, y;
1739 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1740 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1741 EINA_LIST_FOREACH(geoms, l, r)
1743 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1744 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1755 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1760 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1762 Widget_Data *wd = elm_widget_data_get(data);
1767 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1769 Widget_Data *wd = elm_widget_data_get(data);
1774 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1776 Widget_Data *wd = elm_widget_data_get(data);
1781 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1783 Widget_Data *wd = elm_widget_data_get(data);
1785 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1789 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1791 Widget_Data *wd = elm_widget_data_get(data);
1793 wd->double_clicked = EINA_FALSE;
1794 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1796 if ((wd->api) && (wd->api->obj_hidemenu))
1798 wd->api->obj_hidemenu(data);
1803 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1805 Widget_Data *wd = elm_widget_data_get(data);
1807 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1811 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1813 Widget_Data *wd = elm_widget_data_get(data);
1815 wd->double_clicked = EINA_TRUE;
1816 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1819 #ifdef HAVE_ELEMENTARY_X
1821 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1823 Widget_Data *wd = elm_widget_data_get(data);
1824 Ecore_X_Event_Selection_Notify *ev = event;
1825 if (!wd) return ECORE_CALLBACK_PASS_ON;
1826 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1827 return ECORE_CALLBACK_PASS_ON;
1829 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1830 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1832 Ecore_X_Selection_Data_Text *text_data;
1834 text_data = ev->data;
1835 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1837 if (text_data->text)
1839 char *txt = _elm_util_text_to_mkup(text_data->text);
1843 elm_entry_entry_insert(data, txt);
1848 wd->selection_asked = EINA_FALSE;
1850 else if (ev->selection == ECORE_X_SELECTION_XDND)
1852 Ecore_X_Selection_Data_Text *text_data;
1854 text_data = ev->data;
1855 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1857 if (text_data->text)
1859 char *txt = _elm_util_text_to_mkup(text_data->text);
1863 /* Massive FIXME: this should be at the drag point */
1864 elm_entry_entry_insert(data, txt);
1869 wd->drag_selection_asked = EINA_FALSE;
1871 ecore_x_dnd_send_finished();
1874 return ECORE_CALLBACK_PASS_ON;
1878 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1881 Widget_Data *wd = elm_widget_data_get(data);
1882 Ecore_X_Event_Selection_Clear *ev = event;
1883 if (!wd) return ECORE_CALLBACK_PASS_ON;
1884 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1885 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1886 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1888 elm_entry_select_none(data);
1893 Evas_Object *top = elm_widget_top_get(data);
1894 Ecore_X_Event_Selection_Clear *ev = event;
1897 return ECORE_CALLBACK_PASS_ON;
1899 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1901 return ECORE_CALLBACK_PASS_ON;
1904 if (cnpwidgetdata == data)
1906 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1910 return ECORE_CALLBACK_PASS_ON;
1915 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1920 wd = elm_widget_data_get(obj);
1922 if (!wd) return EINA_FALSE;
1923 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1925 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1926 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1927 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1928 EDJE_CURSOR_MAIN,drop->x,drop->y);
1929 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1930 elm_entry_entry_insert(obj, drop->data);
1931 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1932 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1938 static Evas_Object *
1939 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1941 Widget_Data *wd = elm_widget_data_get(data);
1944 Elm_Entry_Item_Provider *ip;
1946 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1948 o = ip->func(ip->data, data, item);
1951 if (!strncmp(item, "file://", 7))
1953 const char *fname = item + 7;
1955 o = evas_object_image_filled_add(evas_object_evas_get(data));
1956 evas_object_image_file_set(o, fname, NULL);
1957 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1959 evas_object_show(o);
1964 o = edje_object_add(evas_object_evas_get(data));
1965 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1969 o = edje_object_add(evas_object_evas_get(data));
1970 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1971 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1976 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1978 char *curlocater, *starttag, *endtag;
1979 int firstindex = 0, foundflag = -1;
1981 curlocater = strstr(oldstring, key);
1984 starttag = curlocater;
1985 endtag = curlocater + strlen(key);
1986 if (endtag == NULL || *endtag != '=')
1992 firstindex = abs(oldstring - curlocater);
1993 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1994 *value = (char*)(oldstring + firstindex);
1996 while (oldstring != starttag)
1998 if (*starttag == '>')
2003 if (*starttag == '<')
2007 if (starttag == NULL) break;
2010 while (NULL != endtag)
2021 if (endtag == NULL) break;
2024 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
2034 if (foundflag == 1) return 0;
2040 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2042 const char *srcstring = NULL;
2043 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2044 char *curlocater, *replocater;
2045 char *starttag, *endtag;
2046 int tagtxtlen = 0, insertflag = 0;
2048 srcstring = eina_strbuf_string_get(srcbuf);
2049 curlocater = strstr(srcstring, key);
2051 if (!curlocater || !srcstring)
2059 starttag = strchr(srcstring, '<');
2060 endtag = strchr(srcstring, '>');
2061 tagtxtlen = endtag - starttag;
2062 if (tagtxtlen <= 0) tagtxtlen = 0;
2063 if (starttag < curlocater && curlocater < endtag) break;
2064 if (endtag != NULL && endtag+1 != NULL)
2065 srcstring = endtag+1;
2068 } while (strlen(srcstring) > 1);
2070 if (starttag && endtag && tagtxtlen > strlen(key))
2072 repbuf = eina_strbuf_new();
2073 diffbuf = eina_strbuf_new();
2074 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2075 srcstring = eina_strbuf_string_get(repbuf);
2076 curlocater = strstr(srcstring, key);
2078 if (curlocater != NULL)
2080 replocater = curlocater + strlen(key) + 1;
2082 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2085 if (replocater-curlocater > strlen(key)+1)
2087 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2096 eina_strbuf_reset(repbuf);
2104 if (repbuf == NULL) repbuf = eina_strbuf_new();
2105 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2109 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2110 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2116 eina_strbuf_prepend(diffbuf, "<");
2117 eina_strbuf_append(diffbuf, ">");
2118 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2122 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2123 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2127 if (repbuf) eina_strbuf_free(repbuf);
2128 if (diffbuf) eina_strbuf_free(diffbuf);
2134 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2136 Eina_Strbuf *sharebuf = NULL;
2138 sharebuf = eina_strbuf_new();
2139 eina_strbuf_append(sharebuf, *srcstring);
2140 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2141 eina_stringshare_del(*srcstring);
2142 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2143 eina_strbuf_free(sharebuf);
2149 _is_width_over(Evas_Object *obj)
2151 Evas_Coord x, y, w, h;
2152 Evas_Coord vx, vy, vw, vh;
2153 Widget_Data *wd = elm_widget_data_get(obj);
2157 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
2159 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
2161 if (x >= 0 && y >= 0)
2164 if (4 < wd->wrap_w && w > wd->wrap_w)
2171 _reverse_ellipsis_entry(Evas_Object *obj)
2173 Widget_Data *wd = elm_widget_data_get(obj);
2174 int cur_fontsize = 0;
2175 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
2176 char *kvalue = NULL;
2177 const char *minfont, *deffont, *maxfont;
2178 const char *ellipsis_string = "...";
2179 int minfontsize, maxfontsize, minshowcount;
2181 minshowcount = strlen(ellipsis_string) + 1;
2182 minfont = edje_object_data_get(wd->ent, "min_font_size");
2183 if (minfont) minfontsize = atoi(minfont);
2184 else minfontsize = 1;
2185 maxfont = edje_object_data_get(wd->ent, "max_font_size");
2186 if (maxfont) maxfontsize = atoi(maxfont);
2187 else maxfontsize = 1;
2188 deffont = edje_object_data_get(wd->ent, "default_font_size");
2189 if (deffont) cur_fontsize = atoi(deffont);
2190 else cur_fontsize = 1;
2191 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
2192 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
2194 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
2196 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
2199 txtbuf = eina_strbuf_new();
2200 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
2202 if (cur_fontsize >= atoi(deffont))
2204 if (txtbuf) eina_strbuf_free(txtbuf);
2208 if (_is_width_over(obj) != 1)
2210 int rev_fontsize = cur_fontsize;
2214 if (rev_fontsize > atoi(deffont))
2217 if (fontbuf != NULL)
2219 eina_strbuf_free(fontbuf);
2222 fontbuf = eina_strbuf_new();
2223 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
2224 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
2225 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2227 eina_strbuf_free(fontbuf);
2229 } while (_is_width_over(obj) != 1);
2231 while (_is_width_over(obj))
2234 if (rev_fontsize < atoi(deffont))
2237 if (fontbuf != NULL)
2239 eina_strbuf_free(fontbuf);
2242 fontbuf = eina_strbuf_new();
2243 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
2244 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
2245 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2246 eina_strbuf_free(fontbuf);
2251 if (txtbuf) eina_strbuf_free(txtbuf);
2257 _ellipsis_entry_to_width(Evas_Object *obj)
2259 Widget_Data *wd = elm_widget_data_get(obj);
2260 int cur_fontsize = 0, len, jumpcount;
2261 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
2262 char *kvalue = NULL;
2263 const char *minfont, *deffont, *maxfont;
2264 const char *ellipsis_string = "...";
2265 int minfontsize, maxfontsize, minshowcount;
2266 int i, tagend, cur_len;
2269 minshowcount = strlen(ellipsis_string) + 1;
2270 minfont = edje_object_data_get(wd->ent, "min_font_size");
2271 if (minfont) minfontsize = atoi(minfont);
2272 else minfontsize = 1;
2273 maxfont = edje_object_data_get(wd->ent, "max_font_size");
2274 if (maxfont) maxfontsize = atoi(maxfont);
2275 else maxfontsize = 1;
2276 deffont = edje_object_data_get(wd->ent, "default_font_size");
2277 if (deffont) cur_fontsize = atoi(deffont);
2278 else cur_fontsize = 1;
2279 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
2280 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
2282 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
2284 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
2287 txtbuf = eina_strbuf_new();
2288 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
2290 while (_is_width_over(obj))
2292 if (wd->ellipsis_threshold == 0)
2293 wd->ellipsis_threshold = _entry_length_get(obj);
2294 if (cur_fontsize > minfontsize)
2297 if (fontbuf != NULL)
2299 eina_strbuf_free(fontbuf);
2302 fontbuf = eina_strbuf_new();
2303 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
2304 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
2305 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2306 eina_strbuf_free(fontbuf);
2308 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2312 len = _entry_length_get(obj);
2313 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2314 cur_len = strlen(cur_str);
2316 for (i = 0; i < len; i++)
2318 if(cur_str[i] == '>' && cur_str[i+1] != '\0' &&
2319 cur_str[i+1] != '<')
2326 while (jumpcount < len-strlen(ellipsis_string))
2328 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2332 eina_strbuf_free(txtbuf);
2335 txtbuf = eina_strbuf_new();
2336 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
2337 eina_strbuf_append(txtbuf, ellipsis_string);
2338 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
2339 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2340 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2342 if (_is_width_over(obj))
2350 if (txtbuf) eina_strbuf_free(txtbuf);
2355 static Eina_Bool *_textinput_control_function(void *data,void *input_data)
2357 /* calculate character count */
2358 Evas_Object *entry = (Evas_Object *)data;
2359 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2362 size_t insert_text_len=0;
2363 char *text = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2365 size_t remain_bytes;
2368 byte_len = strlen(text); /* no of bytes */
2369 remain_bytes = wd->max_no_of_bytes - byte_len;
2370 sprintf(buf,"%d",remain_bytes);
2371 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2374 insert_text = (char *)input_data;
2375 insert_text_len = strlen(insert_text);
2376 if (remain_bytes < insert_text_len)
2378 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2381 if (byte_len >= wd->max_no_of_bytes)
2383 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2393 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2395 Widget_Data *wd = elm_widget_data_get(data);
2397 Elm_Entry_Text_Filter *tf;
2399 if (type == EDJE_TEXT_FILTER_FORMAT)
2402 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2404 tf->func(tf->data, data, text);
2411 * This adds an entry to @p parent object.
2413 * @param parent The parent object
2414 * @return The new object or NULL if it cannot be created
2419 elm_entry_add(Evas_Object *parent)
2421 Evas_Object *obj, *top;
2425 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
2427 wd = ELM_NEW(Widget_Data);
2428 e = evas_object_evas_get(parent);
2429 if (!e) return NULL;
2430 wd->bgcolor = EINA_FALSE;
2431 wd->bg = evas_object_rectangle_add(e);
2432 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2433 obj = elm_widget_add(e);
2434 ELM_SET_WIDTYPE(widtype, "entry");
2435 elm_widget_type_set(obj, "entry");
2436 elm_widget_sub_object_add(parent, obj);
2437 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2438 elm_widget_data_set(obj, wd);
2439 elm_widget_del_hook_set(obj, _del_hook);
2440 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2441 elm_widget_theme_hook_set(obj, _theme_hook);
2442 elm_widget_disable_hook_set(obj, _disable_hook);
2443 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2444 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2445 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2446 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2447 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2448 elm_widget_can_focus_set(obj, EINA_TRUE);
2449 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2451 wd->linewrap = EINA_TRUE;
2452 wd->ellipsis = EINA_FALSE;
2453 wd->char_linewrap= EINA_FALSE;
2454 wd->editable = EINA_TRUE;
2455 wd->disabled = EINA_FALSE;
2456 wd->context_menu = EINA_TRUE;
2457 wd->autosave = EINA_TRUE;
2458 wd->textonly = EINA_FALSE;
2459 wd->autoperiod = EINA_TRUE;
2461 wd->ellipsis_threshold = 0;
2463 wd->ent = edje_object_add(e);
2464 edje_object_item_provider_set(wd->ent, _get_item, obj);
2465 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2466 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2467 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2468 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2470 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2472 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2475 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2476 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2477 _signal_entry_changed, obj);
2478 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2479 _signal_handler_move_start, obj);
2480 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2481 _signal_handler_move_end, obj);
2482 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2483 _signal_handler_moving, obj);
2484 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2485 _signal_selection_start, obj);
2486 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2487 _signal_selection_end, obj);
2488 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2489 _signal_magnifier_changed, obj);
2490 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2491 _signal_selection_changed, obj);
2492 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2493 _signal_selection_cleared, obj);
2494 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2495 _signal_entry_paste_request, obj);
2496 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2497 _signal_entry_copy_notify, obj);
2498 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2499 _signal_entry_cut_notify, obj);
2500 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2501 _signal_cursor_changed, obj);
2502 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2503 _signal_anchor_down, obj);
2504 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2505 _signal_anchor_up, obj);
2506 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2507 _signal_anchor_move, obj);
2508 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2509 _signal_anchor_in, obj);
2510 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2511 _signal_anchor_out, obj);
2512 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2513 _signal_key_enter, obj);
2514 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2515 _signal_mouse_down, obj);
2516 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2517 _signal_mouse_clicked, obj);
2518 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2519 _signal_mouse_double, obj);
2520 edje_object_part_text_set(wd->ent, "elm.text", "");
2521 elm_widget_resize_object_set(obj, wd->ent);
2524 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2526 #ifdef HAVE_ELEMENTARY_X
2527 top = elm_widget_top_get(obj);
2528 if ((top) && (elm_win_xwindow_get(top)))
2530 wd->sel_notify_handler =
2531 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2532 _event_selection_notify, obj);
2533 wd->sel_clear_handler =
2534 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2535 _event_selection_clear, obj);
2538 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2541 entries = eina_list_prepend(entries, obj);
2543 // module - find module for entry
2544 wd->api = _module(obj);
2545 // if found - hook in
2546 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2548 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2549 // TODO: and save some bytes, making descriptions per-class and not instance!
2550 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2554 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2556 ELM_CHECK_WIDTYPE(obj, widtype);
2557 Widget_Data *wd = elm_widget_data_get(obj);
2559 ext_mod->cancel = _cancel;
2560 ext_mod->copy = _copy;
2561 ext_mod->cut = _cut;
2562 ext_mod->paste = _paste;
2563 ext_mod->select = _select;
2564 ext_mod->selectall = _selectall;
2565 ext_mod->ent = wd->ent;
2566 ext_mod->items = wd->items;
2567 ext_mod->longpress_timer = wd->longpress_timer;
2568 ext_mod->editable = wd->editable;
2569 ext_mod->have_selection = wd->have_selection;
2570 ext_mod->password = wd->password;
2571 ext_mod->selmode = wd->selmode;
2572 ext_mod->cnpinit = _cnpinit;
2573 ext_mod->context_menu = wd->context_menu;
2574 ext_mod->textonly = wd->textonly;
2578 * This sets the entry object not to line wrap. All input will
2579 * be on a single line, and the entry box will extend with user input.
2581 * @param obj The entry object
2582 * @param single_line If true, the text in the entry
2583 * will be on a single line.
2588 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2590 ELM_CHECK_WIDTYPE(obj, widtype);
2591 Widget_Data *wd = elm_widget_data_get(obj);
2593 Ecore_IMF_Context *ic;
2595 if (wd->single_line == single_line) return;
2596 wd->single_line = single_line;
2597 wd->linewrap = EINA_FALSE;
2598 wd->char_linewrap = EINA_FALSE;
2599 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2600 t = eina_stringshare_add(elm_entry_entry_get(obj));
2601 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2602 elm_entry_entry_set(obj, t);
2603 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2604 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2605 ic = elm_entry_imf_context_get(obj);
2608 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2611 eina_stringshare_del(t);
2616 * This returns true if the entry has been set to single line mode.
2617 * See also elm_entry_single_line_set().
2619 * @param obj The entry object
2620 * @return single_line If true, the text in the entry is set to display
2626 elm_entry_single_line_get(const Evas_Object *obj)
2628 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2629 Widget_Data *wd = elm_widget_data_get(obj);
2630 if (!wd) return EINA_FALSE;
2631 return wd->single_line;
2635 * This sets the entry object to password mode. All text entered
2636 * and/or displayed within the widget will be replaced with asterisks (*).
2638 * @param obj The entry object
2639 * @param password If true, password mode is enabled.
2644 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2646 ELM_CHECK_WIDTYPE(obj, widtype);
2647 Widget_Data *wd = elm_widget_data_get(obj);
2648 Ecore_IMF_Context *ic;
2651 if (wd->password == password) return;
2652 wd->password = password;
2653 wd->single_line = EINA_TRUE;
2654 wd->linewrap = EINA_FALSE;
2655 wd->char_linewrap = EINA_FALSE;
2656 if (_elm_config->password_show_last_character)
2657 wd->show_last_character = EINA_TRUE;
2658 t = eina_stringshare_add(elm_entry_entry_get(obj));
2659 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2660 elm_entry_entry_set(obj, t);
2665 elm_entry_autoperiod_set(obj, EINA_FALSE);
2667 if (wd->autocapital)
2668 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2671 ic = elm_entry_imf_context_get(obj);
2673 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2675 eina_stringshare_del(t);
2681 * This returns whether password mode is enabled.
2682 * See also elm_entry_password_set().
2684 * @param obj The entry object
2685 * @return If true, the entry is set to display all characters
2691 elm_entry_password_get(const Evas_Object *obj)
2693 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2694 Widget_Data *wd = elm_widget_data_get(obj);
2695 if (!wd) return EINA_FALSE;
2696 return wd->password;
2700 * This sets the text displayed within the entry to @p entry.
2702 * @param obj The entry object
2703 * @param entry The text to be displayed
2708 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2710 ELM_CHECK_WIDTYPE(obj, widtype);
2711 Widget_Data *wd = elm_widget_data_get(obj);
2713 if (!entry) entry = "";
2714 if(wd->max_no_of_bytes)
2716 int len = strlen(entry);
2717 if(len > wd->max_no_of_bytes)
2719 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2723 edje_object_part_text_set(wd->ent, "elm.text", entry);
2724 if (wd->text) eina_stringshare_del(wd->text);
2726 wd->changed = EINA_TRUE;
2731 * This returns the text currently shown in object @p entry.
2732 * See also elm_entry_entry_set().
2734 * @param obj The entry object
2735 * @return The currently displayed text or NULL on failure
2740 elm_entry_entry_get(const Evas_Object *obj)
2742 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2743 Widget_Data *wd = elm_widget_data_get(obj);
2745 if (!wd) return NULL;
2747 if ((wd->text)&&(wd->password))
2748 return elm_entry_markup_to_utf8(wd->text);
2750 if (wd->text) return wd->text;
2751 text = edje_object_part_text_get(wd->ent, "elm.text");
2754 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2757 eina_stringshare_replace(&wd->text, text);
2758 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2764 * This returns EINA_TRUE if the entry is empty/there was an error
2765 * and EINA_FALSE if it is not empty.
2767 * @param obj The entry object
2768 * @return If the entry is empty or not.
2773 elm_entry_is_empty(const Evas_Object *obj)
2775 /* FIXME: until there's support for that in textblock, we just check
2776 * to see if the there is text or not. */
2777 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2778 Widget_Data *wd = elm_widget_data_get(obj);
2779 const Evas_Object *tb;
2780 Evas_Textblock_Cursor *cur;
2782 if (!wd) return EINA_TRUE;
2785 /* It's a hack until we get the support suggested above.
2786 * We just create a cursor, point it to the begining, and then
2787 * try to advance it, if it can advance, the tb is not empty,
2788 * otherwise it is. */
2789 tb = edje_object_part_object_get(wd->ent, "elm.text");
2790 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2791 actually, ok for the time being, thsese hackish stuff will be removed
2792 once evas 1.0 is out*/
2793 evas_textblock_cursor_pos_set(cur, 0);
2794 ret = evas_textblock_cursor_char_next(cur);
2795 evas_textblock_cursor_free(cur);
2800 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
2801 if (!str) return EINA_TRUE;
2803 ret = (strlen(str) == 0);
2809 * This returns all selected text within the entry.
2811 * @param obj The entry object
2812 * @return The selected text within the entry or NULL on failure
2817 elm_entry_selection_get(const Evas_Object *obj)
2819 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2820 Widget_Data *wd = elm_widget_data_get(obj);
2821 if (!wd) return NULL;
2822 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2826 * This inserts text in @p entry where the current cursor position.
2828 * This inserts text at the cursor position is as if it was typed
2829 * by the user (note this also allows markup which a user
2830 * can't just "type" as it would be converted to escaped text, so this
2831 * call can be used to insert things like emoticon items or bold push/pop
2832 * tags, other font and color change tags etc.)
2834 * @param obj The entry object
2835 * @param entry The text to insert
2840 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2842 ELM_CHECK_WIDTYPE(obj, widtype);
2843 Widget_Data *wd = elm_widget_data_get(obj);
2845 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2847 if (cnpwidgetdata == obj)
2848 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2850 wd->changed = EINA_TRUE;
2855 * This enables word line wrapping in the entry object. It is the opposite
2856 * of elm_entry_single_line_set(). Additionally, setting this disables
2857 * character line wrapping.
2858 * See also elm_entry_line_char_wrap_set().
2860 * @param obj The entry object
2861 * @param wrap If true, the entry will be wrapped once it reaches the end
2862 * of the object. Wrapping will occur at the end of the word before the end of the
2868 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2870 ELM_CHECK_WIDTYPE(obj, widtype);
2871 Widget_Data *wd = elm_widget_data_get(obj);
2874 if (wd->linewrap == wrap) return;
2875 wd->linewrap = wrap;
2877 wd->char_linewrap = EINA_FALSE;
2878 t = eina_stringshare_add(elm_entry_entry_get(obj));
2879 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2880 elm_entry_entry_set(obj, t);
2881 eina_stringshare_del(t);
2886 * Set wrap width of the entry
2888 * @param obj The entry object
2889 * @param w The wrap width in pixels at a minimum where words need to wrap
2893 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2895 Widget_Data *wd = elm_widget_data_get(obj);
2896 if (wd->wrap_w == w) return;
2902 * get wrap width of the entry
2904 * @param obj The entry object
2905 * @return The wrap width in pixels at a minimum where words need to wrap
2909 elm_entry_wrap_width_get(const Evas_Object *obj)
2911 Widget_Data *wd = elm_widget_data_get(obj);
2916 * This enables character line wrapping in the entry object. It is the opposite
2917 * of elm_entry_single_line_set(). Additionally, setting this disables
2918 * word line wrapping.
2919 * See also elm_entry_line_wrap_set().
2921 * @param obj The entry object
2922 * @param wrap If true, the entry will be wrapped once it reaches the end
2923 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2928 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2930 ELM_CHECK_WIDTYPE(obj, widtype);
2931 Widget_Data *wd = elm_widget_data_get(obj);
2934 if (wd->char_linewrap == wrap) return;
2935 wd->char_linewrap = wrap;
2936 if(wd->char_linewrap)
2937 wd->linewrap = EINA_FALSE;
2938 t = eina_stringshare_add(elm_entry_entry_get(obj));
2939 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2940 elm_entry_entry_set(obj, t);
2941 eina_stringshare_del(t);
2946 * This sets the editable attribute of the entry.
2948 * @param obj The entry object
2949 * @param editable If true, the entry will be editable by the user.
2950 * If false, it will be set to the disabled state.
2955 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2957 ELM_CHECK_WIDTYPE(obj, widtype);
2958 Widget_Data *wd = elm_widget_data_get(obj);
2961 if (wd->editable == editable) return;
2962 wd->editable = editable;
2963 t = eina_stringshare_add(elm_entry_entry_get(obj));
2964 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2965 elm_entry_entry_set(obj, t);
2966 eina_stringshare_del(t);
2969 #ifdef HAVE_ELEMENTARY_X
2971 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2973 elm_drop_target_del(obj);
2978 * This gets the editable attribute of the entry.
2979 * See also elm_entry_editable_set().
2981 * @param obj The entry object
2982 * @return If true, the entry is editable by the user.
2983 * If false, it is not editable by the user
2988 elm_entry_editable_get(const Evas_Object *obj)
2990 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2991 Widget_Data *wd = elm_widget_data_get(obj);
2992 if (!wd) return EINA_FALSE;
2993 return wd->editable;
2997 * This drops any existing text selection within the entry.
2999 * @param obj The entry object
3004 elm_entry_select_none(Evas_Object *obj)
3006 ELM_CHECK_WIDTYPE(obj, widtype);
3007 Widget_Data *wd = elm_widget_data_get(obj);
3011 wd->selmode = EINA_FALSE;
3012 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3013 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3015 wd->have_selection = EINA_FALSE;
3016 edje_object_part_text_select_none(wd->ent, "elm.text");
3020 * This selects all text within the entry.
3022 * @param obj The entry object
3027 elm_entry_select_all(Evas_Object *obj)
3029 ELM_CHECK_WIDTYPE(obj, widtype);
3030 Widget_Data *wd = elm_widget_data_get(obj);
3034 wd->selmode = EINA_FALSE;
3035 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3036 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3038 wd->have_selection = EINA_TRUE;
3039 edje_object_part_text_select_all(wd->ent, "elm.text");
3043 * This function returns the geometry of the cursor.
3045 * It's useful if you want to draw something on the cursor (or where it is),
3046 * or for example in the case of scrolled entry where you want to show the
3049 * @param obj The entry object
3050 * @param x returned geometry
3051 * @param y returned geometry
3052 * @param w returned geometry
3053 * @param h returned geometry
3054 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3059 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3061 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3062 Widget_Data *wd = elm_widget_data_get(obj);
3063 if (!wd) return EINA_FALSE;
3064 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3069 * This moves the cursor one place to the right within the entry.
3071 * @param obj The entry object
3072 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3077 elm_entry_cursor_next(Evas_Object *obj)
3079 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3080 Widget_Data *wd = elm_widget_data_get(obj);
3081 if (!wd) return EINA_FALSE;
3082 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3086 * This moves the cursor one place to the left within the entry.
3088 * @param obj The entry object
3089 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3094 elm_entry_cursor_prev(Evas_Object *obj)
3096 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3097 Widget_Data *wd = elm_widget_data_get(obj);
3098 if (!wd) return EINA_FALSE;
3099 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3103 * This moves the cursor one line up within the entry.
3105 * @param obj The entry object
3106 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3111 elm_entry_cursor_up(Evas_Object *obj)
3113 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3114 Widget_Data *wd = elm_widget_data_get(obj);
3115 if (!wd) return EINA_FALSE;
3116 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3120 * This moves the cursor one line down within the entry.
3122 * @param obj The entry object
3123 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3128 elm_entry_cursor_down(Evas_Object *obj)
3130 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3131 Widget_Data *wd = elm_widget_data_get(obj);
3132 if (!wd) return EINA_FALSE;
3133 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3137 * This moves the cursor to the beginning of the entry.
3139 * @param obj The entry object
3144 elm_entry_cursor_begin_set(Evas_Object *obj)
3146 ELM_CHECK_WIDTYPE(obj, widtype);
3147 Widget_Data *wd = elm_widget_data_get(obj);
3149 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3153 * This moves the cursor to the end of the entry.
3155 * @param obj The entry object
3160 elm_entry_cursor_end_set(Evas_Object *obj)
3162 ELM_CHECK_WIDTYPE(obj, widtype);
3163 Widget_Data *wd = elm_widget_data_get(obj);
3165 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3169 * This moves the cursor to the beginning of the current line.
3171 * @param obj The entry object
3176 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3178 ELM_CHECK_WIDTYPE(obj, widtype);
3179 Widget_Data *wd = elm_widget_data_get(obj);
3181 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3185 * This moves the cursor to the end of the current line.
3187 * @param obj The entry object
3192 elm_entry_cursor_line_end_set(Evas_Object *obj)
3194 ELM_CHECK_WIDTYPE(obj, widtype);
3195 Widget_Data *wd = elm_widget_data_get(obj);
3197 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3201 * This begins a selection within the entry as though
3202 * the user were holding down the mouse button to make a selection.
3204 * @param obj The entry object
3209 elm_entry_cursor_selection_begin(Evas_Object *obj)
3211 ELM_CHECK_WIDTYPE(obj, widtype);
3212 Widget_Data *wd = elm_widget_data_get(obj);
3214 edje_object_part_text_select_begin(wd->ent, "elm.text");
3218 * This ends a selection within the entry as though
3219 * the user had just released the mouse button while making a selection.
3221 * @param obj The entry object
3226 elm_entry_cursor_selection_end(Evas_Object *obj)
3228 ELM_CHECK_WIDTYPE(obj, widtype);
3229 Widget_Data *wd = elm_widget_data_get(obj);
3231 edje_object_part_text_select_extend(wd->ent, "elm.text");
3235 * TODO: fill this in
3237 * @param obj The entry object
3238 * @return TODO: fill this in
3243 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3245 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3246 Widget_Data *wd = elm_widget_data_get(obj);
3247 if (!wd) return EINA_FALSE;
3248 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3252 * This returns whether the cursor is visible.
3254 * @param obj The entry object
3255 * @return If true, the cursor is visible.
3260 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3262 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3263 Widget_Data *wd = elm_widget_data_get(obj);
3264 if (!wd) return EINA_FALSE;
3265 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3269 * TODO: fill this in
3271 * @param obj The entry object
3272 * @return TODO: fill this in
3277 elm_entry_cursor_content_get(const Evas_Object *obj)
3279 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3280 Widget_Data *wd = elm_widget_data_get(obj);
3281 if (!wd) return NULL;
3282 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3286 * This executes a "cut" action on the selected text in the entry.
3288 * @param obj The entry object
3293 elm_entry_selection_cut(Evas_Object *obj)
3295 ELM_CHECK_WIDTYPE(obj, widtype);
3296 Widget_Data *wd = elm_widget_data_get(obj);
3298 _cut(obj, NULL, NULL);
3302 * This executes a "copy" action on the selected text in the entry.
3304 * @param obj The entry object
3309 elm_entry_selection_copy(Evas_Object *obj)
3311 ELM_CHECK_WIDTYPE(obj, widtype);
3312 Widget_Data *wd = elm_widget_data_get(obj);
3314 _copy(obj, NULL, NULL);
3318 * This executes a "paste" action in the entry.
3320 * @param obj The entry object
3325 elm_entry_selection_paste(Evas_Object *obj)
3327 ELM_CHECK_WIDTYPE(obj, widtype);
3328 Widget_Data *wd = elm_widget_data_get(obj);
3330 _paste(obj, NULL, NULL);
3334 * This clears and frees the items in a entry's contextual (right click) menu.
3336 * @param obj The entry object
3341 elm_entry_context_menu_clear(Evas_Object *obj)
3343 ELM_CHECK_WIDTYPE(obj, widtype);
3344 Widget_Data *wd = elm_widget_data_get(obj);
3345 Elm_Entry_Context_Menu_Item *it;
3347 EINA_LIST_FREE(wd->items, it)
3349 eina_stringshare_del(it->label);
3350 eina_stringshare_del(it->icon_file);
3351 eina_stringshare_del(it->icon_group);
3357 * This adds an item to the entry's contextual menu.
3359 * @param obj The entry object
3360 * @param label The item's text label
3361 * @param icon_file The item's icon file
3362 * @param icon_type The item's icon type
3363 * @param func The callback to execute when the item is clicked
3364 * @param data The data to associate with the item for related functions
3369 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)
3371 ELM_CHECK_WIDTYPE(obj, widtype);
3372 Widget_Data *wd = elm_widget_data_get(obj);
3373 Elm_Entry_Context_Menu_Item *it;
3375 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3377 wd->items = eina_list_append(wd->items, it);
3379 it->label = eina_stringshare_add(label);
3380 it->icon_file = eina_stringshare_add(icon_file);
3381 it->icon_type = icon_type;
3383 it->data = (void *)data;
3387 * This disables the entry's contextual (right click) menu.
3389 * @param obj The entry object
3390 * @param disabled If true, the menu is disabled
3395 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3397 ELM_CHECK_WIDTYPE(obj, widtype);
3398 Widget_Data *wd = elm_widget_data_get(obj);
3400 if (wd->context_menu == !disabled) return;
3401 wd->context_menu = !disabled;
3405 * This returns whether the entry's contextual (right click) menu is disabled.
3407 * @param obj The entry object
3408 * @return If true, the menu is disabled
3413 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3415 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3416 Widget_Data *wd = elm_widget_data_get(obj);
3417 if (!wd) return EINA_FALSE;
3418 return !wd->context_menu;
3422 * This appends a custom item provider to the list for that entry
3424 * This appends the given callback. The list is walked from beginning to end
3425 * with each function called given the item href string in the text. If the
3426 * function returns an object handle other than NULL (it should create an
3427 * and object to do this), then this object is used to replace that item. If
3428 * not the next provider is called until one provides an item object, or the
3429 * default provider in entry does.
3431 * @param obj The entry object
3432 * @param func The function called to provide the item object
3433 * @param data The data passed to @p func
3438 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3440 ELM_CHECK_WIDTYPE(obj, widtype);
3441 Widget_Data *wd = elm_widget_data_get(obj);
3443 EINA_SAFETY_ON_NULL_RETURN(func);
3444 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3448 wd->item_providers = eina_list_append(wd->item_providers, ip);
3452 * This prepends a custom item provider to the list for that entry
3454 * This prepends the given callback. See elm_entry_item_provider_append() for
3457 * @param obj The entry object
3458 * @param func The function called to provide the item object
3459 * @param data The data passed to @p func
3464 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3466 ELM_CHECK_WIDTYPE(obj, widtype);
3467 Widget_Data *wd = elm_widget_data_get(obj);
3469 EINA_SAFETY_ON_NULL_RETURN(func);
3470 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3474 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3478 * This removes a custom item provider to the list for that entry
3480 * This removes the given callback. See elm_entry_item_provider_append() for
3483 * @param obj The entry object
3484 * @param func The function called to provide the item object
3485 * @param data The data passed to @p func
3490 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3492 ELM_CHECK_WIDTYPE(obj, widtype);
3493 Widget_Data *wd = elm_widget_data_get(obj);
3495 Elm_Entry_Item_Provider *ip;
3497 EINA_SAFETY_ON_NULL_RETURN(func);
3498 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3500 if ((ip->func == func) && (ip->data == data))
3502 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3510 * Append a filter function for text inserted in the entry
3512 * Append the given callback to the list. This functions will be called
3513 * whenever any text is inserted into the entry, with the text to be inserted
3514 * as a parameter. The callback function is free to alter the text in any way
3515 * it wants, but it must remember to free the given pointer and update it.
3516 * If the new text is to be discarded, the function can free it and set it text
3517 * parameter to NULL. This will also prevent any following filters from being
3520 * @param obj The entry object
3521 * @param func The function to use as text filter
3522 * @param data User data to pass to @p func
3527 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3530 Elm_Entry_Text_Filter *tf;
3531 ELM_CHECK_WIDTYPE(obj, widtype);
3533 wd = elm_widget_data_get(obj);
3535 EINA_SAFETY_ON_NULL_RETURN(func);
3537 tf = ELM_NEW(Elm_Entry_Text_Filter);
3541 wd->text_filters = eina_list_append(wd->text_filters, tf);
3545 * Prepend a filter function for text insdrted in the entry
3547 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3548 * for more information
3550 * @param obj The entry object
3551 * @param func The function to use as text filter
3552 * @param data User data to pass to @p func
3557 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3560 Elm_Entry_Text_Filter *tf;
3561 ELM_CHECK_WIDTYPE(obj, widtype);
3563 wd = elm_widget_data_get(obj);
3565 EINA_SAFETY_ON_NULL_RETURN(func);
3567 tf = ELM_NEW(Elm_Entry_Text_Filter);
3571 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3575 * Remove a filter from the list
3577 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3578 * for more information.
3580 * @param obj The entry object
3581 * @param func The filter function to remove
3582 * @param data The user data passed when adding the function
3587 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3591 Elm_Entry_Text_Filter *tf;
3592 ELM_CHECK_WIDTYPE(obj, widtype);
3594 wd = elm_widget_data_get(obj);
3596 EINA_SAFETY_ON_NULL_RETURN(func);
3598 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3600 if ((tf->func == func) && (tf->data == data))
3602 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3610 * This converts a markup (HTML-like) string into UTF-8.
3612 * @param s The string (in markup) to be converted
3613 * @return The converted string (in UTF-8)
3618 elm_entry_markup_to_utf8(const char *s)
3620 char *ss = _elm_util_mkup_to_text(s);
3621 if (!ss) ss = strdup("");
3626 * This converts a UTF-8 string into markup (HTML-like).
3628 * @param s The string (in UTF-8) to be converted
3629 * @return The converted string (in markup)
3634 elm_entry_utf8_to_markup(const char *s)
3636 char *ss = _elm_util_text_to_mkup(s);
3637 if (!ss) ss = strdup("");
3642 * Get the input method context in the entry widget
3644 * @param obj The entry object
3645 * @return The input method context
3649 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3651 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3652 Widget_Data *wd = elm_widget_data_get(obj);
3653 if (!wd || !wd->ent) return NULL;
3655 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3659 * Set whether entry should enable the return key on soft keyboard automatically
3661 * @param obj The entry object
3662 * @param on If true, entry enables the return key on soft keyboard automatically.
3667 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3669 ELM_CHECK_WIDTYPE(obj, widtype);
3670 Widget_Data *wd = elm_widget_data_get(obj);
3673 wd->autoreturnkey = on;
3674 _check_enable_returnkey(obj);
3678 * Set whether entry should support auto capitalization
3680 * @param obj The entry object
3681 * @param on If true, entry suports auto capitalization.
3686 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3688 ELM_CHECK_WIDTYPE(obj, widtype);
3689 Widget_Data *wd = elm_widget_data_get(obj);
3693 wd->autocapital = EINA_FALSE;
3695 wd->autocapital = autocap;
3697 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3698 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3699 wd->autocapital = EINA_FALSE;
3701 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3705 * Set whether entry should support auto period
3707 * @param obj The entry object
3708 * @param on If true, entry suports auto period.
3713 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3715 ELM_CHECK_WIDTYPE(obj, widtype);
3716 Widget_Data *wd = elm_widget_data_get(obj);
3720 wd->autoperiod = EINA_FALSE;
3722 wd->autoperiod = autoperiod;
3724 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3725 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3726 wd->autoperiod = EINA_FALSE;
3728 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3732 * Set the font size on the entry object
3734 * @param obj The entry object
3735 * @param size font size
3740 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3742 ELM_CHECK_WIDTYPE(obj, widtype);
3743 Widget_Data *wd = elm_widget_data_get(obj);
3744 Eina_Strbuf *fontbuf = NULL;
3749 t = eina_stringshare_add(elm_entry_entry_get(obj));
3750 fontbuf = eina_strbuf_new();
3751 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3753 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3755 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3757 elm_entry_entry_set(obj, t);
3761 eina_strbuf_free(fontbuf);
3762 eina_stringshare_del(t);
3766 * Set the text align on the entry object
3768 * @param obj The entry object
3769 * @param align align mode
3774 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3776 ELM_CHECK_WIDTYPE(obj, widtype);
3777 Widget_Data *wd = elm_widget_data_get(obj);
3782 t = eina_stringshare_add(elm_entry_entry_get(obj));
3784 if (len <= 0) return;
3786 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3787 elm_entry_entry_set(obj, t);
3791 eina_stringshare_del(t);
3795 * Set the text color on the entry object
3797 * @param obj The entry object
3798 * @param r Red property background color of The entry object
3799 * @param g Green property background color of The entry object
3800 * @param b Blue property background color of The entry object
3801 * @param a Alpha property background alpha of The entry object
3806 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3808 ELM_CHECK_WIDTYPE(obj, widtype);
3809 Widget_Data *wd = elm_widget_data_get(obj);
3810 Eina_Strbuf *colorbuf = NULL;
3815 t = eina_stringshare_add(elm_entry_entry_get(obj));
3817 if (len <= 0) return;
3818 colorbuf = eina_strbuf_new();
3819 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3821 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3823 elm_entry_entry_set(obj, t);
3827 eina_strbuf_free(colorbuf);
3828 eina_stringshare_del(t);
3832 * Set background color of the entry
3834 * @param obj The entry object
3835 * @param r Red property background color of The entry object
3836 * @param g Green property background color of The entry object
3837 * @param b Blue property background color of The entry object
3838 * @param a Alpha property background alpha of The entry object
3842 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3844 ELM_CHECK_WIDTYPE(obj, widtype);
3845 Widget_Data *wd = elm_widget_data_get(obj);
3846 evas_object_color_set(wd->bg, r, g, b, a);
3848 if (wd->bgcolor == EINA_FALSE)
3851 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3856 * Set the ellipsis behavior of the entry
3858 * @param obj The entry object
3859 * @param ellipsis To ellipsis text or not
3863 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3865 ELM_CHECK_WIDTYPE(obj, widtype);
3866 Widget_Data *wd = elm_widget_data_get(obj);
3867 if (wd->ellipsis == ellipsis) return;
3868 wd->ellipsis = ellipsis;
3874 * Filter inserted text based on user defined character and byte limits
3876 * Add this filter to an entry to limit the characters that it will accept
3877 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
3878 * The funtion works on the UTF-8 representation of the string, converting
3879 * it from the set markup, thus not accounting for any format in it.
3881 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
3882 * it as data when setting the filter. In it it's possible to set limits
3883 * by character count or bytes (any of them is disabled if 0), and both can
3884 * be set at the same time. In that case, it first checks for characters,
3887 * The function will cut the inserted text in order to allow only the first
3888 * number of characters that are still allowed. The cut is made in
3889 * characters, even when limiting by bytes, in order to always contain
3890 * valid ones and avoid half unicode characters making it in.
3895 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3897 Elm_Entry_Filter_Limit_Size *lim = data;
3900 const char *(*text_get)(const Evas_Object *);
3901 const char *widget_type;
3903 EINA_SAFETY_ON_NULL_RETURN(data);
3904 EINA_SAFETY_ON_NULL_RETURN(entry);
3905 EINA_SAFETY_ON_NULL_RETURN(text);
3907 /* hack. I don't want to copy the entire function to work with
3909 widget_type = elm_widget_type_get(entry);
3910 if (!strcmp(widget_type, "entry"))
3911 text_get = elm_entry_entry_get;
3912 else if (!strcmp(widget_type, "scrolled_entry"))
3913 text_get = elm_scrolled_entry_entry_get;
3917 current = elm_entry_markup_to_utf8(text_get(entry));
3919 if (lim->max_char_count > 0)
3922 len = evas_string_char_len_get(current);
3923 if (len >= lim->max_char_count)
3925 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3931 newlen = evas_string_char_len_get(*text);
3932 cut = strlen(*text);
3933 while ((len + newlen) > lim->max_char_count)
3935 cut = evas_string_char_prev_get(*text, cut, NULL);
3941 if (lim->max_byte_count > 0)
3943 len = strlen(current);
3944 if (len >= lim->max_byte_count)
3946 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3952 newlen = strlen(*text);
3953 while ((len + newlen) > lim->max_byte_count)
3955 int p = evas_string_char_prev_get(*text, newlen, NULL);
3956 newlen -= (newlen - p);
3959 (*text)[newlen] = 0;
3970 * Filter inserted text based on accepted or rejected sets of characters
3972 * Add this filter to an entry to restrict the set of accepted characters
3973 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
3974 * This structure contains both accepted and rejected sets, but they are
3975 * mutually exclusive. If accepted is set, it will be used, otherwise it
3976 * goes on to the rejected set.
3979 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3981 Elm_Entry_Filter_Accept_Set *as = data;
3985 int read_idx, last_read_idx = 0, read_char;
3987 EINA_SAFETY_ON_NULL_RETURN(data);
3988 EINA_SAFETY_ON_NULL_RETURN(text);
3990 if ((!as->accepted) && (!as->rejected))
3996 goes_in = EINA_TRUE;
4001 goes_in = EINA_FALSE;
4005 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4008 int cmp_idx, cmp_char;
4009 Eina_Bool in_set = EINA_FALSE;
4011 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4014 if (read_char == cmp_char)
4019 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4021 if (in_set == goes_in)
4023 int size = read_idx - last_read_idx;
4024 const char *src = (*text) + last_read_idx;
4026 memcpy(insert, *text + last_read_idx, size);
4029 last_read_idx = read_idx;
4030 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4036 * This sets the file (and implicitly loads it) for the text to display and
4037 * then edit. All changes are written back to the file after a short delay if
4038 * the entry object is set to autosave.
4040 * @param obj The entry object
4041 * @param file The path to the file to load and save
4042 * @param format The file format
4047 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4049 ELM_CHECK_WIDTYPE(obj, widtype);
4050 Widget_Data *wd = elm_widget_data_get(obj);
4052 if (wd->delay_write)
4054 ecore_timer_del(wd->delay_write);
4055 wd->delay_write = NULL;
4057 if (wd->autosave) _save(obj);
4058 eina_stringshare_replace(&wd->file, file);
4059 wd->format = format;
4064 * Gets the file to load and save and the file format
4066 * @param obj The entry object
4067 * @param file The path to the file to load and save
4068 * @param format The file format
4073 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4075 ELM_CHECK_WIDTYPE(obj, widtype);
4076 Widget_Data *wd = elm_widget_data_get(obj);
4078 if (file) *file = wd->file;
4079 if (format) *format = wd->format;
4083 * This function writes any changes made to the file set with
4084 * elm_entry_file_set()
4086 * @param obj The entry object
4091 elm_entry_file_save(Evas_Object *obj)
4093 ELM_CHECK_WIDTYPE(obj, widtype);
4094 Widget_Data *wd = elm_widget_data_get(obj);
4096 if (wd->delay_write)
4098 ecore_timer_del(wd->delay_write);
4099 wd->delay_write = NULL;
4102 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4106 * This sets the entry object to 'autosave' the loaded text file or not.
4108 * @param obj The entry object
4109 * @param autosave Autosave the loaded file or not
4114 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4116 ELM_CHECK_WIDTYPE(obj, widtype);
4117 Widget_Data *wd = elm_widget_data_get(obj);
4119 wd->autosave = !!autosave;
4123 * This gets the entry object's 'autosave' status.
4125 * @param obj The entry object
4126 * @return Autosave the loaded file or not
4131 elm_entry_autosave_get(const Evas_Object *obj)
4133 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4134 Widget_Data *wd = elm_widget_data_get(obj);
4135 if (!wd) return EINA_FALSE;
4136 return wd->autosave;
4140 * Control pasting of text and images for the widget.
4142 * Normally the entry allows both text and images to be pasted. By setting
4143 * textonly to be true, this prevents images from being pasted.
4145 * Note this only changes the behaviour of text.
4147 * @param obj The entry object
4148 * @param pmode paste mode - 0 is text only, 1 is text+image+other.
4153 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4155 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4156 ELM_CHECK_WIDTYPE(obj, widtype);
4157 Widget_Data *wd = elm_widget_data_get(obj);
4159 textonly = !!textonly;
4160 if (wd->textonly == textonly) return;
4161 wd->textonly = !!textonly;
4165 * Getting elm_entry text paste/drop mode.
4167 * In textonly mode, only text may be pasted or dropped into the widget.
4169 * @param obj The entry object
4170 * @return If the widget only accepts text from pastes.
4175 elm_entry_cnp_textonly_get(Evas_Object *obj)
4177 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4178 Widget_Data *wd = elm_widget_data_get(obj);
4179 if (!wd) return EINA_FALSE;
4180 return wd->textonly;
4184 * This sets the attribute to show the input panel automatically.
4186 * @param obj The entry object
4187 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4192 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4194 ELM_CHECK_WIDTYPE(obj, widtype);
4195 Widget_Data *wd = elm_widget_data_get(obj);
4198 wd->input_panel_enable = enabled;
4199 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4203 * Set the input panel layout of the entry
4205 * @param obj The entry object
4206 * @param layout the layout to set
4211 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4213 ELM_CHECK_WIDTYPE(obj, widtype);
4214 Widget_Data *wd = elm_widget_data_get(obj);
4217 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4220 wd->input_panel_layout = layout;
4222 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4226 * Set the magnifier style of the entry
4228 * @param obj The entry object
4229 * @param type the magnifier style to set
4234 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4236 ELM_CHECK_WIDTYPE(obj, widtype);
4237 Widget_Data *wd = elm_widget_data_get(obj);
4240 wd->mgf_type = type;
4241 _magnifier_create(obj);