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:
78 * "changed" - The text within the entry was changed
79 * "activated" - The entry has had editing finished and changes are to be committed
80 (generally when enter key is pressed)
81 * "press" - The entry has been clicked
82 * "longpressed" - The entry has been clicked for a couple seconds
83 * "clicked" - The entry has been clicked
84 * "clicked,double" - The entry has been double clicked
85 * "focused" - The entry has received focus
86 * "unfocused" - The entry has lost focus
87 * "selection,paste" - A paste action has occurred
88 * "selection,copy" - A copy action has occurred
89 * "selection,cut" - A cut action has occurred
90 * "selection,start" - A selection has begun
91 * "selection,changed" - The selection has changed
92 * "selection,cleared" - The selection has been cleared
93 * "cursor,changed" - The cursor has changed
94 * "anchor,clicked" - The anchor has been clicked
95 * "preedit,changed" - The preedit string has changed
98 /* Maximum chunk size to be inserted to the entry at once
99 * FIXME: This size is arbitrary, should probably choose a better size.
100 * Possibly also find a way to set it to a low value for weak computers,
101 * and to a big value for better computers. */
102 #define _CHUNK_SIZE 10000
104 typedef struct _Mod_Api Mod_Api;
106 typedef struct _Widget_Data Widget_Data;
107 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
108 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
109 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
113 Evas_Object *ent, *scroller, *end, *icon;
115 Evas_Object *hoversel;
119 Evas_Object *mgf_proxy;
120 Evas_Object *mgf_clip;
122 Evas_Coord mgf_height;
125 Ecore_Job *deferred_recalc_job;
126 Ecore_Event_Handler *sel_notify_handler;
127 Ecore_Event_Handler *sel_clear_handler;
128 Ecore_Timer *longpress_timer;
129 Ecore_Timer *delay_write;
130 /* for deferred appending */
131 Ecore_Idler *append_text_idler;
132 char *append_text_left;
133 int append_text_position;
135 /* Only for clipboard */
140 Elm_Text_Format format;
141 Evas_Coord lastw, entmw, entmh;
142 Evas_Coord downx, downy;
143 Evas_Coord cx, cy, cw, ch;
145 Eina_List *item_providers;
146 Eina_List *text_filters;
147 Eina_List *match_list;
148 Ecore_Job *matchlist_job;
149 Ecore_Job *hovdeljob;
150 Mod_Api *api; // module api if supplied
152 Elm_Scroller_Policy policy_h, policy_v;
153 Elm_Wrap_Type linewrap;
154 Eina_Bool changed : 1;
155 Eina_Bool single_line : 1;
156 Eina_Bool password : 1;
157 Eina_Bool editable : 1;
158 Eina_Bool selection_asked : 1;
159 Eina_Bool have_selection : 1;
160 Eina_Bool selmode : 1;
161 Eina_Bool deferred_cur : 1;
162 Eina_Bool cur_changed : 1;
163 Eina_Bool disabled : 1;
164 Eina_Bool double_clicked : 1;
165 Eina_Bool long_pressed : 1;
166 Eina_Bool context_menu : 1;
167 Eina_Bool drag_selection_asked : 1;
168 Eina_Bool bgcolor : 1;
169 Eina_Bool can_write : 1;
170 Eina_Bool autosave : 1;
171 Eina_Bool textonly : 1;
172 Eina_Bool usedown : 1;
173 Eina_Bool scroll : 1;
174 Eina_Bool autoreturnkey : 1;
175 Eina_Bool input_panel_enable : 1;
176 Eina_Bool autocapital : 1;
177 Elm_Input_Panel_Layout input_panel_layout;
178 Eina_Bool autoperiod : 1;
179 Eina_Bool matchlist_list_clicked : 1;
180 Eina_Bool matchlist_case_sensitive : 1;
181 int matchlist_threshold;
184 struct _Elm_Entry_Context_Menu_Item
188 const char *icon_file;
189 const char *icon_group;
190 Elm_Icon_Type icon_type;
195 struct _Elm_Entry_Item_Provider
197 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
201 struct _Elm_Entry_Text_Filter
203 void (*func) (void *data, Evas_Object *entry, char **text);
207 typedef enum _Length_Unit
214 static const char *widtype = NULL;
216 static Evas_Object *cnpwidgetdata = NULL;
219 #ifdef HAVE_ELEMENTARY_X
220 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
222 static void _del_hook(Evas_Object *obj);
223 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
224 static void _theme_hook(Evas_Object *obj);
225 static void _disable_hook(Evas_Object *obj);
226 static void _sizing_eval(Evas_Object *obj);
227 static void _on_focus_hook(void *data, Evas_Object *obj);
228 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
229 static const char *_getbase(Evas_Object *obj);
230 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
231 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
232 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
233 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
234 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
235 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
236 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
237 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
238 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
239 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
240 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
241 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
242 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
243 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
244 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
245 static int _entry_length_get(Evas_Object *obj);
246 static void _magnifier_create(void *data);
247 static void _magnifier_show(void *data);
248 static void _magnifier_hide(void *data);
249 static void _magnifier_move(void *data);
251 static const char SIG_CHANGED[] = "changed";
252 static const char SIG_ACTIVATED[] = "activated";
253 static const char SIG_PRESS[] = "press";
254 static const char SIG_LONGPRESSED[] = "longpressed";
255 static const char SIG_CLICKED[] = "clicked";
256 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
257 static const char SIG_FOCUSED[] = "focused";
258 static const char SIG_UNFOCUSED[] = "unfocused";
259 static const char SIG_SELECTION_PASTE[] = "selection,paste";
260 static const char SIG_SELECTION_COPY[] = "selection,copy";
261 static const char SIG_SELECTION_CUT[] = "selection,cut";
262 static const char SIG_SELECTION_START[] = "selection,start";
263 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
264 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
265 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
266 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
267 static const char SIG_MATCHLIST_CLICKED[] = "matchlist,clicked";
268 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
269 static const Evas_Smart_Cb_Description _signals[] = {
273 {SIG_LONGPRESSED, ""},
275 {SIG_CLICKED_DOUBLE, ""},
278 {SIG_SELECTION_PASTE, ""},
279 {SIG_SELECTION_COPY, ""},
280 {SIG_SELECTION_CUT, ""},
281 {SIG_SELECTION_START, ""},
282 {SIG_SELECTION_CHANGED, ""},
283 {SIG_SELECTION_CLEARED, ""},
284 {SIG_CURSOR_CHANGED, ""},
285 {SIG_ANCHOR_CLICKED, ""},
286 {SIG_PREEDIT_CHANGED, ""},
287 {SIG_MATCHLIST_CLICKED, ""},
291 typedef enum _Elm_Entry_Magnifier_Type
293 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
294 _ENTRY_MAGNIFIER_FILLWIDTH,
295 _ENTRY_MAGNIFIER_CIRCULAR,
296 } Elm_Entry_Magnifier_Type;
299 static Eina_List *entries = NULL;
303 void (*obj_hook) (Evas_Object *obj);
304 void (*obj_unhook) (Evas_Object *obj);
305 void (*obj_longpress) (Evas_Object *obj);
306 void (*obj_hidemenu) (Evas_Object *obj);
307 void (*obj_mouseup) (Evas_Object *obj);
311 _module(Evas_Object *obj __UNUSED__)
313 static Elm_Module *m = NULL;
314 if (m) goto ok; // already found - just use
315 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
317 m->api = malloc(sizeof(Mod_Api));
318 if (!m->api) return NULL;
319 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
320 _elm_module_symbol_get(m, "obj_hook");
321 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
322 _elm_module_symbol_get(m, "obj_unhook");
323 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
324 _elm_module_symbol_get(m, "obj_longpress");
325 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
326 _elm_module_symbol_get(m, "obj_hidemenu");
327 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
328 _elm_module_symbol_get(m, "obj_mouseup");
329 ok: // ok - return api
334 _buf_append(char *buf, const char *str, int *len, int *alloc)
336 int len2 = strlen(str);
337 if ((*len + len2) >= *alloc)
339 char *buf2 = realloc(buf, *alloc + len2 + 512);
340 if (!buf2) return NULL;
342 *alloc += (512 + len2);
344 strcpy(buf + *len, str);
350 _load_file(const char *file)
354 int alloc = 0, len = 0;
355 char *text = NULL, buf[16384 + 1];
357 f = fopen(file, "rb");
359 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
363 tmp_text = _buf_append(text, buf, &len, &alloc);
364 if (!tmp_text) break;
372 _load_plain(const char *file)
376 text = _load_file(file);
381 text2 = elm_entry_utf8_to_markup(text);
389 _load(Evas_Object *obj)
391 Widget_Data *wd = elm_widget_data_get(obj);
396 elm_entry_entry_set(obj, "");
401 case ELM_TEXT_FORMAT_PLAIN_UTF8:
402 text = _load_plain(wd->file);
404 case ELM_TEXT_FORMAT_MARKUP_UTF8:
405 text = _load_file(wd->file);
413 elm_entry_entry_set(obj, text);
417 elm_entry_entry_set(obj, "");
421 _save_markup_utf8(const char *file, const char *text)
425 if ((!text) || (!text[0]))
427 ecore_file_unlink(file);
430 f = fopen(file, "wb");
433 // FIXME: report a write error
436 fputs(text, f); // FIXME: catch error
441 _save_plain_utf8(const char *file, const char *text)
445 text2 = elm_entry_markup_to_utf8(text);
448 _save_markup_utf8(file, text2);
453 _save(Evas_Object *obj)
455 Widget_Data *wd = elm_widget_data_get(obj);
457 if (!wd->file) return;
460 case ELM_TEXT_FORMAT_PLAIN_UTF8:
461 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
463 case ELM_TEXT_FORMAT_MARKUP_UTF8:
464 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
472 _delay_write(void *data)
474 Widget_Data *wd = elm_widget_data_get(data);
475 if (!wd) return ECORE_CALLBACK_CANCEL;
477 wd->delay_write = NULL;
478 return ECORE_CALLBACK_CANCEL;
481 static Elm_Entry_Text_Filter *
482 _filter_new(void (*func) (void *data, Evas_Object *entry, char **text), void *data)
484 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
485 if (!tf) return NULL;
488 if (func == elm_entry_filter_limit_size)
490 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
497 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
503 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
506 else if (func == elm_entry_filter_accept_set)
508 Elm_Entry_Filter_Accept_Set *as = data, *as2;
515 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
522 as2->accepted = eina_stringshare_add(as->accepted);
524 as2->accepted = NULL;
526 as2->rejected = eina_stringshare_add(as->rejected);
528 as2->rejected = NULL;
537 _filter_free(Elm_Entry_Text_Filter *tf)
539 if (tf->func == elm_entry_filter_limit_size)
541 Elm_Entry_Filter_Limit_Size *lim = tf->data;
544 else if (tf->func == elm_entry_filter_accept_set)
546 Elm_Entry_Filter_Accept_Set *as = tf->data;
549 if (as->accepted) eina_stringshare_del(as->accepted);
550 if (as->rejected) eina_stringshare_del(as->rejected);
558 _del_pre_hook(Evas_Object *obj)
560 Widget_Data *wd = elm_widget_data_get(obj);
564 ecore_timer_del(wd->delay_write);
565 wd->delay_write = NULL;
566 if (wd->autosave) _save(obj);
571 _del_hook(Evas_Object *obj)
573 Widget_Data *wd = elm_widget_data_get(obj);
574 Elm_Entry_Context_Menu_Item *it;
575 Elm_Entry_Item_Provider *ip;
576 Elm_Entry_Text_Filter *tf;
578 if (wd->file) eina_stringshare_del(wd->file);
580 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
581 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
583 entries = eina_list_remove(entries, obj);
584 #ifdef HAVE_ELEMENTARY_X
585 if (wd->sel_notify_handler)
586 ecore_event_handler_del(wd->sel_notify_handler);
587 if (wd->sel_clear_handler)
588 ecore_event_handler_del(wd->sel_clear_handler);
590 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
591 if (wd->text) eina_stringshare_del(wd->text);
592 if (wd->bg) evas_object_del(wd->bg);
593 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
594 if (wd->append_text_idler)
596 ecore_idler_del(wd->append_text_idler);
597 free(wd->append_text_left);
598 wd->append_text_left = NULL;
599 wd->append_text_idler = NULL;
601 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
602 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
603 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
604 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
605 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
607 EINA_LIST_FREE(wd->items, it)
609 eina_stringshare_del(it->label);
610 eina_stringshare_del(it->icon_file);
611 eina_stringshare_del(it->icon_group);
614 EINA_LIST_FREE(wd->item_providers, ip)
618 EINA_LIST_FREE(wd->text_filters, tf)
626 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
628 Widget_Data *wd = elm_widget_data_get(obj);
629 edje_object_mirrored_set(wd->ent, rtl);
633 _theme_hook(Evas_Object *obj)
635 Widget_Data *wd = elm_widget_data_get(obj);
637 Ecore_IMF_Context *ic;
638 _elm_widget_mirrored_reload(obj);
639 _mirrored_set(obj, elm_widget_mirrored_get(obj));
641 t = eina_stringshare_add(elm_entry_entry_get(obj));
642 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
643 if (_elm_config->desktop_entry)
644 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
645 elm_entry_entry_set(obj, t);
646 eina_stringshare_del(t);
647 if (elm_widget_disabled_get(obj))
648 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
649 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
650 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
651 if (elm_widget_focus_get(obj))
652 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
653 edje_object_message_signal_process(wd->ent);
654 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
655 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
656 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
657 elm_widget_style_get(obj));
663 edj = elm_smart_scroller_edje_object_get(wd->scroller);
664 str = edje_object_data_get(edj, "focus_highlight");
665 if ((str) && (!strcmp(str, "on")))
666 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
668 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
673 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", EINA_FALSE);
674 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", EINA_FALSE);
678 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
679 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
682 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
685 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
692 _disable_hook(Evas_Object *obj)
694 Widget_Data *wd = elm_widget_data_get(obj);
696 if (elm_widget_disabled_get(obj))
698 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
699 wd->disabled = EINA_TRUE;
703 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
704 wd->disabled = EINA_FALSE;
709 _recalc_cursor_geometry(Evas_Object *obj)
711 Widget_Data *wd = elm_widget_data_get(obj);
713 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
714 if (!elm_object_focus_get(obj)) return;
715 if (!wd->deferred_recalc_job)
717 Evas_Coord cx, cy, cw, ch;
718 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
722 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
723 wd->cur_changed = EINA_FALSE;
727 wd->deferred_cur = EINA_TRUE;
731 _elm_win_recalc_job(void *data)
733 Widget_Data *wd = elm_widget_data_get(data);
734 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
736 wd->deferred_recalc_job = NULL;
738 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
739 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
740 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
743 /* This is a hack to workaround the way min size hints are treated.
744 * If the minimum width is smaller than the restricted width, it means
745 * the mininmum doesn't matter. */
748 Evas_Coord ominw = -1;
749 evas_object_size_hint_min_get(data, &ominw, NULL);
753 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
756 Evas_Coord vmw = 0, vmh = 0;
758 edje_object_size_min_calc
759 (elm_smart_scroller_edje_object_get(wd->scroller),
763 evas_object_size_hint_min_set(data, vmw, minh + vmh);
764 evas_object_size_hint_max_set(data, -1, minh + vmh);
768 evas_object_size_hint_min_set(data, vmw, vmh);
769 evas_object_size_hint_max_set(data, -1, -1);
776 evas_object_size_hint_min_set(data, minw, minh);
777 evas_object_size_hint_max_set(data, -1, minh);
781 evas_object_size_hint_min_set(data, fw, minh);
782 evas_object_size_hint_max_set(data, -1, -1);
786 if ((wd->deferred_cur) && (elm_object_focus_get(data)))
788 Evas_Coord cx, cy, cw, ch;
789 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
793 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
794 wd->cur_changed = EINA_FALSE;
800 _sizing_eval(Evas_Object *obj)
802 Widget_Data *wd = elm_widget_data_get(obj);
803 Evas_Coord minw = -1, minh = -1;
804 Evas_Coord resw, resh;
807 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
810 if ((resw == wd->lastw) && (!wd->changed)) return;
811 wd->changed = EINA_FALSE;
815 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
817 evas_object_resize(wd->scroller, resw, resh);
818 edje_object_size_min_calc
819 (elm_smart_scroller_edje_object_get(wd->scroller),
821 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
822 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
825 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
827 if ((minw > 0) && (vw < minw)) vw = minw;
828 if (minh > vh) vh = minh;
830 if (wd->single_line) h = vmh + minh;
832 evas_object_resize(wd->ent, vw, vh);
833 evas_object_size_hint_min_get(obj, &w, NULL);
834 evas_object_size_hint_min_set(obj, w, h);
836 evas_object_size_hint_max_set(obj, -1, h);
838 evas_object_size_hint_max_set(obj, -1, -1);
842 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
843 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
848 if (!wd->changed) return;
849 wd->changed = EINA_FALSE;
853 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
855 edje_object_size_min_calc(wd->ent, &minw, &minh);
858 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
860 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
862 if ((minw > 0) && (vw < minw)) vw = minw;
863 if (minh > 0) vh = minh;
865 evas_object_resize(wd->ent, vw, vh);
866 edje_object_size_min_calc
867 (elm_smart_scroller_edje_object_get(wd->scroller),
869 if (wd->single_line) h = vmh + minh;
871 evas_object_size_hint_min_get(obj, &w, NULL);
872 evas_object_size_hint_min_set(obj, w, h);
874 evas_object_size_hint_max_set(obj, -1, h);
876 evas_object_size_hint_max_set(obj, -1, -1);
880 edje_object_size_min_calc(wd->ent, &minw, &minh);
883 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
884 evas_object_size_hint_min_set(obj, minw, minh);
886 evas_object_size_hint_max_set(obj, -1, minh);
888 evas_object_size_hint_max_set(obj, -1, -1);
892 _recalc_cursor_geometry(obj);
896 _check_enable_returnkey(Evas_Object *obj)
898 Widget_Data *wd = elm_widget_data_get(obj);
901 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
904 if (!wd->autoreturnkey) return;
906 if (_entry_length_get(obj) == 0)
908 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
912 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
917 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
919 Widget_Data *wd = elm_widget_data_get(obj);
920 Evas_Object *top = elm_widget_top_get(obj);
922 if (!wd->editable) return;
923 if (elm_widget_focus_get(obj))
925 printf("[Elm_entry::Focused] obj : %p\n", obj);
926 evas_object_focus_set(wd->ent, EINA_TRUE);
927 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
928 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
929 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
930 _check_enable_returnkey(obj);
931 wd->mgf_type = _ENTRY_MAGNIFIER_FILLWIDTH;
935 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
936 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
937 evas_object_focus_set(wd->ent, EINA_FALSE);
938 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
939 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
941 if ((wd->api) && (wd->api->obj_hidemenu))
943 wd->api->obj_hidemenu(obj);
949 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
951 Widget_Data *wd = elm_widget_data_get(obj);
953 edje_object_signal_emit(wd->ent, emission, source);
955 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
960 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
962 Widget_Data *wd = elm_widget_data_get(obj);
964 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
966 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
967 emission, source, func_cb, data);
971 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
973 Widget_Data *wd = elm_widget_data_get(obj);
974 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
977 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
978 emission, source, func_cb, data);
982 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
984 Widget_Data *wd = elm_widget_data_get(obj);
985 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
989 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
991 Widget_Data *wd = elm_widget_data_get(obj);
993 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
997 _show_region_hook(void *data, Evas_Object *obj)
999 Widget_Data *wd = elm_widget_data_get(data);
1000 Evas_Coord x, y, w, h;
1002 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1004 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1008 _hoversel_position(Evas_Object *obj)
1010 Widget_Data *wd = elm_widget_data_get(obj);
1011 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1016 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1025 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1026 &cx, &cy, &cw, &ch);
1027 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1030 cx += (cw - mw) / 2;
1035 cy += (ch - mh) / 2;
1038 evas_object_move(wd->hoversel, x + cx, y + cy);
1039 evas_object_resize(wd->hoversel, cw, ch);
1043 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1047 if (wd->hoversel) _hoversel_position(data);
1051 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1053 Widget_Data *wd = elm_widget_data_get(data);
1060 else if (wd->scroll)
1062 Evas_Coord vw = 0, vh = 0;
1064 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1065 if (vw < wd->entmw) vw = wd->entmw;
1066 if (vh < wd->entmh) vh = wd->entmh;
1067 evas_object_resize(wd->ent, vw, vh);
1069 if (wd->hoversel) _hoversel_position(data);
1073 _hover_del(void *data)
1075 Widget_Data *wd = elm_widget_data_get(data);
1080 evas_object_del(wd->hoversel);
1081 wd->hoversel = NULL;
1083 wd->hovdeljob = NULL;
1087 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1089 Widget_Data *wd = elm_widget_data_get(data);
1092 if (wd->hoversel) evas_object_hide(wd->hoversel);
1095 if (!_elm_config->desktop_entry)
1098 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1101 elm_widget_scroll_freeze_pop(data);
1102 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1103 wd->hovdeljob = ecore_job_add(_hover_del, data);
1107 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1109 Widget_Data *wd = elm_widget_data_get(data);
1111 wd->selmode = EINA_TRUE;
1112 edje_object_part_text_select_none(wd->ent, "elm.text");
1113 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1114 edje_object_part_text_select_all(wd->ent, "elm.text");
1115 elm_object_scroll_freeze_pop(data);
1119 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1121 Widget_Data *wd = elm_widget_data_get(data);
1123 wd->selmode = EINA_TRUE;
1124 edje_object_part_text_select_none(wd->ent, "elm.text");
1125 if (!_elm_config->desktop_entry)
1128 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1130 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1131 if (!_elm_config->desktop_entry)
1132 elm_object_scroll_freeze_pop(data);
1133 //elm_widget_scroll_hold_push(data);
1137 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1139 Widget_Data *wd = elm_widget_data_get(data);
1141 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1142 if (wd->sel_notify_handler)
1144 #ifdef HAVE_ELEMENTARY_X
1145 Elm_Sel_Format formats;
1146 wd->selection_asked = EINA_TRUE;
1147 formats = ELM_SEL_FORMAT_MARKUP;
1149 formats |= ELM_SEL_FORMAT_IMAGE;
1150 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1156 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1158 Widget_Data *wd = elm_widget_data_get(obj);
1162 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1163 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
1164 if (seltype == ELM_SEL_CLIPBOARD)
1165 eina_stringshare_replace(&wd->cut_sel, sel);
1169 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1171 Widget_Data *wd = elm_widget_data_get(data);
1174 wd->selmode = EINA_FALSE;
1175 if (!_elm_config->desktop_entry)
1176 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1177 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1178 if (!_elm_config->desktop_entry)
1179 elm_widget_scroll_hold_pop(data);
1180 _store_selection(ELM_SEL_CLIPBOARD, data);
1181 edje_object_part_text_insert(wd->ent, "elm.text", "");
1182 edje_object_part_text_select_none(wd->ent, "elm.text");
1186 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1188 Widget_Data *wd = elm_widget_data_get(data);
1190 wd->selmode = EINA_FALSE;
1191 if (!_elm_config->desktop_entry)
1193 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1194 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1195 elm_widget_scroll_hold_pop(data);
1197 _store_selection(ELM_SEL_CLIPBOARD, data);
1198 // edje_object_part_text_select_none(wd->ent, "elm.text");
1202 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1204 Widget_Data *wd = elm_widget_data_get(data);
1206 wd->selmode = EINA_FALSE;
1207 if (!_elm_config->desktop_entry)
1208 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1209 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1210 if (!_elm_config->desktop_entry)
1211 elm_widget_scroll_hold_pop(data);
1212 edje_object_part_text_select_none(wd->ent, "elm.text");
1216 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1218 Widget_Data *wd = elm_widget_data_get(data);
1222 #ifdef HAVE_ELEMENTARY_X
1223 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1225 cnpwidgetdata = data;
1226 elm_cbhm_helper_init(obj);
1227 if (elm_entry_cnp_textonly_get(obj))
1228 elm_cbhm_send_raw_data("show0");
1230 elm_cbhm_send_raw_data("show1");
1236 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1238 Widget_Data *wd = elm_widget_data_get(data);
1240 cnpwidgetdata = data;
1246 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1248 Elm_Entry_Context_Menu_Item *it = data;
1249 Evas_Object *obj2 = it->obj;
1250 if (it->func) it->func(it->data, obj2, NULL);
1254 _menu_press(Evas_Object *obj)
1256 Widget_Data *wd = elm_widget_data_get(obj);
1259 const Elm_Entry_Context_Menu_Item *it;
1261 if ((wd->api) && (wd->api->obj_longpress))
1263 wd->api->obj_longpress(obj);
1265 else if (wd->context_menu)
1267 const char *context_menu_orientation;
1269 if (wd->hoversel) evas_object_del(wd->hoversel);
1270 else elm_widget_scroll_freeze_push(obj);
1271 wd->hoversel = elm_hoversel_add(obj);
1272 context_menu_orientation = edje_object_data_get
1273 (wd->ent, "context_menu_orientation");
1274 if ((context_menu_orientation) &&
1275 (!strcmp(context_menu_orientation, "horizontal")))
1276 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1277 elm_object_style_set(wd->hoversel, "entry");
1278 elm_widget_sub_object_add(obj, wd->hoversel);
1279 elm_object_text_set(wd->hoversel, "Text");
1280 top = elm_widget_top_get(obj);
1281 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1282 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1286 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1288 if (1) // need way to detect if someone has a selection
1291 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1295 if ((!wd->password) && (wd->editable))
1296 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1297 _clipboard_menu, obj);
1304 if (wd->have_selection)
1306 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1309 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1312 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1316 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1317 _clipboard_menu, obj);
1321 EINA_LIST_FOREACH(wd->items, l, it)
1323 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1324 it->icon_type, _item_clicked, it);
1328 _hoversel_position(obj);
1329 evas_object_show(wd->hoversel);
1330 elm_hoversel_hover_begin(wd->hoversel);
1332 if (!_elm_config->desktop_entry)
1334 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1335 edje_object_part_text_select_abort(wd->ent, "elm.text");
1341 _magnifier_hide(void *data)
1343 Widget_Data *wd = elm_widget_data_get(data);
1346 evas_object_hide(wd->mgf_bg);
1347 evas_object_hide(wd->mgf_clip);
1350 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1354 _magnifier_show(void *data)
1356 Widget_Data *wd = elm_widget_data_get(data);
1359 evas_object_show(wd->mgf_bg);
1360 evas_object_show(wd->mgf_clip);
1364 _magnifier_move(void *data)
1366 Widget_Data *wd = elm_widget_data_get(data);
1369 Evas_Coord x, y, w, h, fs;
1370 Evas_Coord cx, cy, cw, ch, ox, oy;
1372 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1376 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1377 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1382 evas_object_geometry_get(data, &x, &y, &w, &h);
1385 fs = elm_finger_size_get();
1387 if ((cy + y) - wd->mgf_height - fs < 0)
1388 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1390 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1391 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1392 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1393 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1397 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);
1401 _magnifier_create(void *data)
1403 Widget_Data *wd = elm_widget_data_get(data);
1404 Evas_Coord x, y, w, h, mw, mh;
1405 const char* key_data = NULL;
1411 evas_object_image_source_unset(wd->mgf_proxy);
1412 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1413 evas_object_hide(wd->mgf_proxy);
1414 evas_object_clip_unset(wd->mgf_proxy);
1415 evas_object_del(wd->mgf_proxy);
1417 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1418 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1421 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1423 evas_object_geometry_get(data, &x, &y, &w, &h);
1425 if ((w <= 0) || (h <= 0))
1428 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1430 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1431 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1432 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1433 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1437 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1438 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1439 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1441 key_data = edje_object_data_get(wd->mgf_bg, "height");
1442 if (key_data) wd->mgf_height = atoi(key_data);
1443 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1444 if (key_data) wd->mgf_scale = atof(key_data);
1446 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1447 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1451 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1452 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1453 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1457 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1458 evas_object_image_source_set(wd->mgf_proxy, data);
1461 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1462 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1463 if ((mw <= 0) || (mh <= 0))
1466 evas_object_resize(wd->mgf_proxy, mw, mh);
1467 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1468 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1469 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1470 evas_object_show(wd->mgf_proxy);
1471 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1473 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1474 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1478 _long_press(void *data)
1480 Widget_Data *wd = elm_widget_data_get(data);
1481 if (!wd) return ECORE_CALLBACK_CANCEL;
1483 wd->long_pressed = EINA_TRUE;
1485 if (wd->longpress_timer)
1487 ecore_timer_del(wd->longpress_timer);
1488 wd->longpress_timer = NULL;
1491 _cancel(data, NULL, NULL);
1493 _magnifier_create(data);
1494 _magnifier_move(data);
1495 _magnifier_show(data);
1496 elm_object_scroll_freeze_push(data);
1498 wd->longpress_timer = NULL;
1499 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1500 return ECORE_CALLBACK_CANCEL;
1504 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1506 Widget_Data *wd = elm_widget_data_get(data);
1507 Evas_Event_Mouse_Down *ev = event_info;
1509 if (wd->disabled) return;
1510 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1511 wd->downx = ev->canvas.x;
1512 wd->downy = ev->canvas.y;
1513 wd->long_pressed = EINA_FALSE;
1514 if (ev->button == 1)
1516 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1517 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1522 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1524 Widget_Data *wd = elm_widget_data_get(data);
1525 Evas_Event_Mouse_Up *ev = event_info;
1527 if (wd->disabled) return;
1528 if (ev->button == 1)
1530 if (!wd->double_clicked)
1532 if ((wd->api) && (wd->api->obj_mouseup))
1534 wd->api->obj_mouseup(data);
1538 if (wd->longpress_timer)
1540 ecore_timer_del(wd->longpress_timer);
1541 wd->longpress_timer = NULL;
1544 _magnifier_hide(data);
1545 elm_object_scroll_freeze_pop(data);
1547 if (wd->long_pressed)
1553 else if (ev->button == 3)
1561 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1563 Widget_Data *wd = elm_widget_data_get(data);
1564 Evas_Event_Mouse_Move *ev = event_info;
1566 if (wd->disabled) return;
1569 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1571 if (wd->longpress_timer)
1573 ecore_timer_del(wd->longpress_timer);
1574 wd->longpress_timer = NULL;
1577 else if (wd->longpress_timer)
1581 dx = wd->downx - ev->cur.canvas.x;
1583 dy = wd->downy - ev->cur.canvas.y;
1586 ((_elm_config->finger_size / 2) *
1587 (_elm_config->finger_size / 2)))
1589 ecore_timer_del(wd->longpress_timer);
1590 wd->longpress_timer = NULL;
1594 else if (wd->longpress_timer)
1598 dx = wd->downx - ev->cur.canvas.x;
1600 dy = wd->downy - ev->cur.canvas.y;
1603 ((_elm_config->finger_size / 2) *
1604 (_elm_config->finger_size / 2)))
1606 ecore_timer_del(wd->longpress_timer);
1607 wd->longpress_timer = NULL;
1611 if (ev->buttons == 1)
1613 if (wd->long_pressed)
1615 _magnifier_show(data);
1616 _magnifier_move(data);
1622 _getbase(Evas_Object *obj)
1624 Widget_Data *wd = elm_widget_data_get(obj);
1625 if (!wd) return "base";
1628 if (wd->password) return "base-password";
1631 if (wd->single_line) return "base-single";
1634 switch (wd->linewrap)
1637 return "base-charwrap";
1640 case ELM_WRAP_MIXED:
1641 return "base-mixedwrap";
1644 return "base-nowrap";
1651 if (wd->password) return "base-password";
1654 if (wd->single_line) return "base-single-noedit";
1657 switch (wd->linewrap)
1660 return "base-noedit-charwrap";
1662 return "base-noedit";
1663 case ELM_WRAP_MIXED:
1664 return "base-noedit-mixedwrap";
1667 return "base-nowrap-noedit";
1677 _entry_length_get(Evas_Object *obj)
1680 const char *str = elm_entry_entry_get(obj);
1683 char *plain_str = _elm_util_mkup_to_text(str);
1684 if (!plain_str) return 0;
1686 len = strlen(plain_str);
1693 _matchlist_show(void *data)
1695 Widget_Data *wd = elm_widget_data_get(data);
1696 const char *text = NULL;
1698 char *str_list = NULL, *str_result = NULL;
1699 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1702 Eina_Bool textfound = EINA_FALSE;
1705 if (elm_widget_disabled_get(data)) return;
1707 wd->matchlist_job = NULL;
1709 if (wd->matchlist_list_clicked)
1711 evas_object_hide(wd->hover);
1712 wd->matchlist_list_clicked = EINA_FALSE;
1715 text = elm_entry_entry_get(data);
1718 textlen = strlen(text);
1720 if (textlen < wd->matchlist_threshold)
1722 evas_object_hide(wd->hover);
1726 evas_object_hide(wd->hover);
1730 elm_list_clear(wd->list);
1731 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1733 if (wd->matchlist_case_sensitive)
1734 str_result = strstr(str_list, text);
1736 str_result = strcasestr(str_list, text);
1740 str_mkup = malloc(strlen(str_list) + 16);
1741 if (str_mkup == NULL) return;
1743 textlen = strlen(str_list) - strlen(str_result);
1744 str_front = malloc(textlen + 1);
1745 if (str_front == NULL) return;
1747 memset(str_front, 0, textlen + 1);
1748 strncpy(str_front, str_list, textlen);
1750 textlen = strlen(text);
1751 str_mid = malloc(textlen + 1);
1752 if (str_mid == NULL) return;
1754 memset(str_mid, 0, textlen + 1);
1755 strncpy(str_mid, str_list + strlen(str_front), textlen);
1757 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1759 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1761 if (str_mkup) free(str_mkup);
1762 if (str_front) free(str_front);
1763 if (str_mid) free(str_mid);
1765 textfound=EINA_TRUE;
1774 elm_list_go(wd->list);
1775 evas_object_show(wd->hover);
1776 evas_object_raise(wd->hover);
1780 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1782 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1783 Widget_Data *wd = elm_widget_data_get(data);
1784 if ((it == NULL) || (wd == NULL))
1787 const char *text = elm_list_item_label_get(it);
1788 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1793 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1794 elm_entry_cursor_end_set(data);
1795 wd->matchlist_list_clicked = EINA_TRUE;
1797 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1800 elm_widget_focus_set(data, EINA_TRUE);
1804 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
1806 Widget_Data *wd = elm_widget_data_get(obj);
1811 Evas_Coord max_w = 9999, max_h = 9999;
1812 const char* key_data = NULL;
1814 wd->matchlist_threshold = 1;
1815 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
1816 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
1817 elm_hover_target_set(wd->hover, obj);
1818 elm_object_style_set(wd->hover, "matchlist");
1820 wd->layout = elm_layout_add(wd->hover);
1821 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
1822 wd->list = elm_list_add(wd->layout);
1823 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
1824 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1825 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
1826 elm_object_style_set(wd->list, "matchlist");
1828 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
1829 if (key_data) max_w = atoi(key_data);
1830 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
1831 if (key_data) max_h = atoi(key_data);
1833 elm_list_go(wd->list);
1834 evas_object_size_hint_max_set(wd->list, max_w, max_h);
1835 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
1836 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
1837 elm_hover_content_set(wd->hover, "bottom", wd->layout);
1839 wd->match_list = match_list;
1844 evas_object_del(wd->hover);
1846 wd->match_list = NULL;
1849 wd->matchlist_case_sensitive = case_sensitive;
1853 _entry_changed_common_handling(void *data, const char *event)
1855 Widget_Data *wd = elm_widget_data_get(data);
1856 Evas_Coord minw, minh;
1858 wd->changed = EINA_TRUE;
1859 /* Reset the size hints which are no more relevant.
1860 * Keep the height, this is a hack, but doesn't really matter
1861 * cause we'll re-eval in a moment. */
1864 evas_object_size_hint_min_get(data, &minw, &minh);
1865 evas_object_size_hint_min_set(data, minw, minh);
1869 evas_object_size_hint_min_get(data, NULL, &minh);
1870 evas_object_size_hint_min_set(data, -1, minh);
1874 if (wd->text) eina_stringshare_del(wd->text);
1876 _check_enable_returnkey(data);
1877 evas_object_smart_callback_call(data, event, NULL);
1878 if (wd->delay_write)
1880 ecore_timer_del(wd->delay_write);
1881 wd->delay_write = NULL;
1884 if ((wd->single_line) && (wd->match_list))
1886 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1887 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1889 if ((!wd->autosave) || (!wd->file)) return;
1890 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1894 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1896 _entry_changed_common_handling(data, SIG_CHANGED);
1900 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1902 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1907 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1909 Widget_Data *wd = elm_widget_data_get(data);
1910 elm_object_scroll_freeze_push(data);
1912 if ((wd->api) && (wd->api->obj_hidemenu))
1914 wd->api->obj_hidemenu(data);
1917 _magnifier_create(data);
1918 _magnifier_move(data);
1919 _magnifier_show(data);
1923 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1925 Widget_Data *wd = elm_widget_data_get(data);
1926 elm_object_scroll_freeze_pop(data);
1928 if (wd->have_selection)
1930 _magnifier_hide(data);
1936 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1938 _magnifier_move(data);
1939 _magnifier_show(data);
1943 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1945 _magnifier_hide(data);
1950 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1952 Widget_Data *wd = elm_widget_data_get(data);
1956 EINA_LIST_FOREACH(entries, l, entry)
1958 if (entry != data) elm_entry_select_none(entry);
1960 wd->have_selection = EINA_TRUE;
1961 wd->selmode = EINA_TRUE;
1962 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1963 #ifdef HAVE_ELEMENTARY_X
1964 if (wd->sel_notify_handler)
1966 const char *txt = elm_entry_selection_get(data);
1969 top = elm_widget_top_get(data);
1970 if ((top) && (elm_win_xwindow_get(top)))
1971 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1977 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1979 Evas_Coord cx, cy, cw, ch;
1980 Widget_Data *wd = elm_widget_data_get(data);
1983 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1984 if (!wd->deferred_recalc_job)
1985 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1988 wd->deferred_cur = EINA_TRUE;
1992 wd->ch = ch + elm_finger_size_get();
1997 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1999 Evas_Coord cx, cy, cw, ch;
2000 Widget_Data *wd = elm_widget_data_get(data);
2002 wd->have_selection = EINA_TRUE;
2003 wd->selmode = EINA_TRUE;
2004 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2005 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
2006 elm_entry_selection_get(data));
2008 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2009 if (!wd->deferred_recalc_job)
2010 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE);
2013 wd->deferred_cur = EINA_TRUE;
2017 wd->ch = ch + elm_finger_size_get();
2022 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2024 Widget_Data *wd = elm_widget_data_get(data);
2026 if (!wd->have_selection) return;
2027 wd->have_selection = EINA_FALSE;
2028 wd->selmode = EINA_FALSE;
2029 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2030 if (wd->sel_notify_handler)
2034 #ifdef HAVE_ELEMENTARY_X
2037 top = elm_widget_top_get(data);
2038 if ((top) && (elm_win_xwindow_get(top)))
2039 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2042 eina_stringshare_del(wd->cut_sel);
2047 #ifdef HAVE_ELEMENTARY_X
2050 top = elm_widget_top_get(data);
2051 if ((top) && (elm_win_xwindow_get(top)))
2052 elm_selection_clear(ELM_SEL_PRIMARY, data);
2057 if ((wd->api) && (wd->api->obj_hidemenu))
2059 wd->api->obj_hidemenu(data);
2064 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2066 Widget_Data *wd = elm_widget_data_get(data);
2068 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2069 if (wd->sel_notify_handler)
2071 #ifdef HAVE_ELEMENTARY_X
2074 top = elm_widget_top_get(data);
2075 if ((top) && (elm_win_xwindow_get(top)))
2077 wd->selection_asked = EINA_TRUE;
2078 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2086 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2088 Widget_Data *wd = elm_widget_data_get(data);
2090 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2091 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2092 elm_entry_selection_get(data));
2096 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2098 Widget_Data *wd = elm_widget_data_get(data);
2100 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2101 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2102 elm_entry_selection_get(data));
2103 edje_object_part_text_insert(wd->ent, "elm.text", "");
2104 wd->changed = EINA_TRUE;
2109 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2111 Widget_Data *wd = elm_widget_data_get(data);
2113 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2114 wd->cur_changed = EINA_TRUE;
2115 _recalc_cursor_geometry(data);
2119 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2121 Widget_Data *wd = elm_widget_data_get(data);
2126 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2128 Widget_Data *wd = elm_widget_data_get(data);
2133 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2135 Widget_Data *wd = elm_widget_data_get(data);
2136 Elm_Entry_Anchor_Info ei;
2137 char *buf2, *p, *p2, *n;
2139 p = strrchr(emission, ',');
2142 const Eina_List *geoms;
2146 while (p2 >= emission)
2148 if (*p2 == ',') break;
2152 buf2 = alloca(5 + p - p2);
2153 strncpy(buf2, p2, p - p2);
2156 ei.button = atoi(buf2);
2157 ei.x = ei.y = ei.w = ei.h = 0;
2159 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2162 Evas_Textblock_Rectangle *r;
2164 Evas_Coord px, py, x, y;
2166 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2167 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2168 EINA_LIST_FOREACH(geoms, l, r)
2170 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2171 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2182 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2187 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2189 Widget_Data *wd = elm_widget_data_get(data);
2194 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2196 Widget_Data *wd = elm_widget_data_get(data);
2201 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2203 Widget_Data *wd = elm_widget_data_get(data);
2208 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2210 Widget_Data *wd = elm_widget_data_get(data);
2212 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2216 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2218 Widget_Data *wd = elm_widget_data_get(data);
2220 wd->double_clicked = EINA_FALSE;
2221 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2223 if ((wd->api) && (wd->api->obj_hidemenu))
2225 wd->api->obj_hidemenu(data);
2230 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2232 Widget_Data *wd = elm_widget_data_get(data);
2234 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2238 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2240 Widget_Data *wd = elm_widget_data_get(data);
2242 wd->double_clicked = EINA_TRUE;
2243 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2246 #ifdef HAVE_ELEMENTARY_X
2248 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2250 Widget_Data *wd = elm_widget_data_get(data);
2251 Ecore_X_Event_Selection_Notify *ev = event;
2252 if (!wd) return ECORE_CALLBACK_PASS_ON;
2253 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2254 return ECORE_CALLBACK_PASS_ON;
2256 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2257 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2259 Ecore_X_Selection_Data_Text *text_data;
2261 text_data = ev->data;
2262 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2264 if (text_data->text)
2266 char *txt = _elm_util_text_to_mkup(text_data->text);
2270 elm_entry_entry_insert(data, txt);
2275 wd->selection_asked = EINA_FALSE;
2277 else if (ev->selection == ECORE_X_SELECTION_XDND)
2279 Ecore_X_Selection_Data_Text *text_data;
2281 text_data = ev->data;
2282 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2284 if (text_data->text)
2286 char *txt = _elm_util_text_to_mkup(text_data->text);
2290 /* Massive FIXME: this should be at the drag point */
2291 elm_entry_entry_insert(data, txt);
2296 wd->drag_selection_asked = EINA_FALSE;
2298 ecore_x_dnd_send_finished();
2301 return ECORE_CALLBACK_PASS_ON;
2305 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2308 Widget_Data *wd = elm_widget_data_get(data);
2309 Ecore_X_Event_Selection_Clear *ev = event;
2310 if (!wd) return ECORE_CALLBACK_PASS_ON;
2311 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2312 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2313 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2315 elm_entry_select_none(data);
2320 Evas_Object *top = elm_widget_top_get(data);
2321 Ecore_X_Event_Selection_Clear *ev = event;
2324 return ECORE_CALLBACK_PASS_ON;
2326 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2328 return ECORE_CALLBACK_PASS_ON;
2331 if (cnpwidgetdata == data)
2333 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2337 return ECORE_CALLBACK_PASS_ON;
2341 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2346 wd = elm_widget_data_get(obj);
2347 if (!wd) return EINA_FALSE;
2348 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2350 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2351 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2352 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2353 EDJE_CURSOR_MAIN,drop->x,drop->y);
2354 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2355 elm_entry_entry_insert(obj, drop->data);
2356 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2357 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2363 static Evas_Object *
2364 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2366 Widget_Data *wd = elm_widget_data_get(data);
2369 Elm_Entry_Item_Provider *ip;
2371 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2373 o = ip->func(ip->data, data, item);
2376 if (!strncmp(item, "file://", 7))
2378 const char *fname = item + 7;
2380 o = evas_object_image_filled_add(evas_object_evas_get(data));
2381 evas_object_image_file_set(o, fname, NULL);
2382 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2384 evas_object_show(o);
2389 o = edje_object_add(evas_object_evas_get(data));
2390 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2394 o = edje_object_add(evas_object_evas_get(data));
2395 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2396 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2401 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2403 const char *srcstring = NULL;
2404 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2405 char *curlocater, *replocater;
2406 char *starttag, *endtag;
2407 int tagtxtlen = 0, insertflag = 0;
2409 srcstring = eina_strbuf_string_get(srcbuf);
2410 curlocater = strstr(srcstring, key);
2412 if (!curlocater || !srcstring)
2420 starttag = strchr(srcstring, '<');
2421 endtag = strchr(srcstring, '>');
2422 tagtxtlen = endtag - starttag;
2423 if (tagtxtlen <= 0) tagtxtlen = 0;
2424 if (starttag < curlocater && curlocater < endtag) break;
2425 if (endtag != NULL && endtag+1 != NULL)
2426 srcstring = endtag+1;
2429 } while (strlen(srcstring) > 1);
2431 if (starttag && endtag && tagtxtlen > strlen(key))
2433 repbuf = eina_strbuf_new();
2434 diffbuf = eina_strbuf_new();
2435 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2436 srcstring = eina_strbuf_string_get(repbuf);
2437 curlocater = strstr(srcstring, key);
2439 if (curlocater != NULL)
2441 replocater = curlocater + strlen(key) + 1;
2443 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2446 if (replocater-curlocater > strlen(key)+1)
2448 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2457 eina_strbuf_reset(repbuf);
2465 if (repbuf == NULL) repbuf = eina_strbuf_new();
2466 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2470 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2471 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2477 eina_strbuf_prepend(diffbuf, "<");
2478 eina_strbuf_append(diffbuf, ">");
2479 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2483 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2484 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2488 if (repbuf) eina_strbuf_free(repbuf);
2489 if (diffbuf) eina_strbuf_free(diffbuf);
2495 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2497 Eina_Strbuf *sharebuf = NULL;
2499 sharebuf = eina_strbuf_new();
2500 eina_strbuf_append(sharebuf, *srcstring);
2501 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2502 eina_stringshare_del(*srcstring);
2503 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2504 eina_strbuf_free(sharebuf);
2510 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2512 Widget_Data *wd = elm_widget_data_get(data);
2514 Elm_Entry_Text_Filter *tf;
2516 if (type == EDJE_TEXT_FILTER_FORMAT)
2519 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2521 tf->func(tf->data, data, text);
2527 /* This function is used to insert text by chunks in jobs */
2529 _text_append_idler(void *data)
2533 Evas_Object *obj = (Evas_Object *) data;
2534 Widget_Data *wd = elm_widget_data_get(obj);
2535 if (wd->text) eina_stringshare_del(wd->text);
2537 wd->changed = EINA_TRUE;
2539 start = wd->append_text_position;
2540 if(start + _CHUNK_SIZE < wd->append_text_len)
2542 wd->append_text_position = (start + _CHUNK_SIZE);
2543 /* Go to the start of the nearest codepoint, because we don't want
2544 * to cut it in the middle */
2545 eina_unicode_utf8_get_prev(wd->append_text_left,
2546 &wd->append_text_position);
2550 wd->append_text_position = wd->append_text_len;
2553 backup = wd->append_text_left[wd->append_text_position];
2554 wd->append_text_left[wd->append_text_position] = '\0';
2556 edje_object_part_text_append(wd->ent, "elm.text",
2557 wd->append_text_left + start);
2559 wd->append_text_left[wd->append_text_position] = backup;
2561 /* If there's still more to go, renew the idler, else, cleanup */
2562 if (wd->append_text_position < wd->append_text_len)
2564 return ECORE_CALLBACK_RENEW;
2568 free(wd->append_text_left);
2569 wd->append_text_left = NULL;
2570 wd->append_text_idler = NULL;
2571 return ECORE_CALLBACK_CANCEL;
2576 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2578 int i = 0, unit_size;
2579 int current_len = strlen(*text);
2580 char *new_text = *text;
2581 if (unit >= LENGTH_UNIT_LAST) return;
2584 if (*new_text == '<')
2586 while (*new_text != '>')
2589 if (!*new_text) break;
2596 if (*new_text == '&')
2598 while (*(new_text + index) != ';')
2601 if (!*(new_text + index)) break;
2605 index = evas_string_char_next_get(new_text, index, NULL);
2606 markup = malloc(index + 1);
2607 strncpy(markup, new_text, index);
2609 if (unit == LENGTH_UNIT_BYTE)
2610 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2611 else if (unit == LENGTH_UNIT_CHAR)
2612 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2618 if (can_add < unit_size)
2622 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2628 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2629 current_len -= index;
2630 (*text)[current_len] = 0;
2635 can_add -= unit_size;
2640 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2644 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2647 ELM_CHECK_WIDTYPE(obj, widtype);
2648 if (item && strcmp(item, "default")) return;
2649 Widget_Data *wd = elm_widget_data_get(obj);
2651 if (!entry) entry = "";
2652 if (wd->text) eina_stringshare_del(wd->text);
2654 wd->changed = EINA_TRUE;
2656 /* Clear currently pending job if there is one */
2657 if (wd->append_text_idler)
2659 ecore_idler_del(wd->append_text_idler);
2660 free(wd->append_text_left);
2661 wd->append_text_left = NULL;
2662 wd->append_text_idler = NULL;
2665 len = strlen(entry);
2666 /* Split to ~_CHUNK_SIZE chunks */
2667 if (len > _CHUNK_SIZE)
2669 wd->append_text_left = (char *) malloc(len + 1);
2672 /* If we decided to use the idler */
2673 if (wd->append_text_left)
2675 /* Need to clear the entry first */
2676 edje_object_part_text_set(wd->ent, "elm.text", "");
2677 memcpy(wd->append_text_left, entry, len + 1);
2678 wd->append_text_position = 0;
2679 wd->append_text_len = len;
2680 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2684 edje_object_part_text_set(wd->ent, "elm.text", entry);
2689 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2691 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2692 Widget_Data *wd = elm_widget_data_get(obj);
2693 if (item && strcmp(item, "default")) return NULL;
2695 if (!wd) return NULL;
2699 return elm_entry_markup_to_utf8(wd->text);
2703 text = edje_object_part_text_get(wd->ent, "elm.text");
2706 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2709 eina_stringshare_replace(&wd->text, text);
2710 if (wd->password) return elm_entry_markup_to_utf8(wd->text);
2715 * This adds an entry to @p parent object.
2717 * @param parent The parent object
2718 * @return The new object or NULL if it cannot be created
2723 elm_entry_add(Evas_Object *parent)
2725 Evas_Object *obj, *top;
2729 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2731 ELM_SET_WIDTYPE(widtype, "entry");
2732 elm_widget_type_set(obj, "entry");
2733 elm_widget_sub_object_add(parent, obj);
2734 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2735 elm_widget_data_set(obj, wd);
2736 elm_widget_del_hook_set(obj, _del_hook);
2737 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2738 elm_widget_theme_hook_set(obj, _theme_hook);
2739 elm_widget_disable_hook_set(obj, _disable_hook);
2740 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2741 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2742 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2743 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2744 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2745 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2746 elm_widget_can_focus_set(obj, EINA_TRUE);
2747 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2748 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2749 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2751 wd->scroller = elm_smart_scroller_add(e);
2752 elm_widget_sub_object_add(obj, wd->scroller);
2753 elm_smart_scroller_widget_set(wd->scroller, obj);
2754 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2755 elm_widget_style_get(obj));
2756 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2757 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2758 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2759 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2761 wd->linewrap = ELM_WRAP_WORD;
2762 wd->editable = EINA_TRUE;
2763 wd->disabled = EINA_FALSE;
2764 wd->context_menu = EINA_TRUE;
2765 wd->autosave = EINA_TRUE;
2766 wd->textonly = EINA_FALSE;
2767 wd->autoperiod = EINA_TRUE;
2769 wd->ent = edje_object_add(e);
2770 elm_widget_sub_object_add(obj, wd->ent);
2771 edje_object_item_provider_set(wd->ent, _get_item, obj);
2772 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2773 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2774 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2776 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2778 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2780 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2782 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2783 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2784 _signal_entry_changed, obj);
2785 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2786 _signal_preedit_changed, obj);
2787 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2788 _signal_handler_move_start, obj);
2789 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2790 _signal_handler_move_end, obj);
2791 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2792 _signal_handler_moving, obj);
2793 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2794 _signal_selection_start, obj);
2795 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2796 _signal_selection_end, obj);
2797 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2798 _signal_magnifier_changed, obj);
2799 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2800 _signal_selection_changed, obj);
2801 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2802 _signal_selection_cleared, obj);
2803 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2804 _signal_entry_paste_request, obj);
2805 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2806 _signal_entry_copy_notify, obj);
2807 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2808 _signal_entry_cut_notify, obj);
2809 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2810 _signal_cursor_changed, obj);
2811 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2812 _signal_anchor_down, obj);
2813 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2814 _signal_anchor_up, obj);
2815 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2816 _signal_anchor_clicked, obj);
2817 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2818 _signal_anchor_move, obj);
2819 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2820 _signal_anchor_in, obj);
2821 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2822 _signal_anchor_out, obj);
2823 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2824 _signal_key_enter, obj);
2825 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2826 _signal_mouse_down, obj);
2827 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2828 _signal_mouse_clicked, obj);
2829 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2830 _signal_mouse_double, obj);
2831 edje_object_part_text_set(wd->ent, "elm.text", "");
2832 if (_elm_config->desktop_entry)
2833 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2834 elm_widget_resize_object_set(obj, wd->ent);
2837 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2839 #ifdef HAVE_ELEMENTARY_X
2840 top = elm_widget_top_get(obj);
2841 if ((top) && (elm_win_xwindow_get(top)))
2843 wd->sel_notify_handler =
2844 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2845 _event_selection_notify, obj);
2846 wd->sel_clear_handler =
2847 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2848 _event_selection_clear, obj);
2851 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2852 _drag_drop_cb, NULL);
2855 entries = eina_list_prepend(entries, obj);
2857 // module - find module for entry
2858 wd->api = _module(obj);
2859 // if found - hook in
2860 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2862 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2863 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2864 // TODO: and save some bytes, making descriptions per-class and not instance!
2865 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2869 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2871 ELM_CHECK_WIDTYPE(obj, widtype);
2872 Widget_Data *wd = elm_widget_data_get(obj);
2874 ext_mod->cancel = _cancel;
2875 ext_mod->copy = _copy;
2876 ext_mod->cut = _cut;
2877 ext_mod->paste = _paste;
2878 ext_mod->select = _select;
2879 ext_mod->selectall = _selectall;
2880 ext_mod->ent = wd->ent;
2881 ext_mod->items = wd->items;
2882 ext_mod->longpress_timer = wd->longpress_timer;
2883 ext_mod->editable = wd->editable;
2884 ext_mod->have_selection = wd->have_selection;
2885 ext_mod->password = wd->password;
2886 ext_mod->selmode = wd->selmode;
2887 ext_mod->cnpinit = _cnpinit;
2888 ext_mod->context_menu = wd->context_menu;
2889 ext_mod->textonly = wd->textonly;
2893 * This sets the entry object not to line wrap. All input will
2894 * be on a single line, and the entry box will extend with user input.
2896 * @param obj The entry object
2897 * @param single_line If true, the text in the entry
2898 * will be on a single line.
2903 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2905 ELM_CHECK_WIDTYPE(obj, widtype);
2906 Widget_Data *wd = elm_widget_data_get(obj);
2908 if (wd->single_line == single_line) return;
2909 wd->single_line = single_line;
2910 wd->linewrap = ELM_WRAP_NONE;
2911 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2915 if (wd->single_line)
2917 elm_smart_scroller_policy_set(wd->scroller,
2918 ELM_SMART_SCROLLER_POLICY_OFF,
2919 ELM_SMART_SCROLLER_POLICY_OFF);
2920 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2924 const Elm_Scroller_Policy map[3] =
2926 ELM_SMART_SCROLLER_POLICY_AUTO,
2927 ELM_SMART_SCROLLER_POLICY_ON,
2928 ELM_SMART_SCROLLER_POLICY_OFF
2930 elm_smart_scroller_policy_set(wd->scroller,
2933 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2940 * This returns true if the entry has been set to single line mode.
2941 * See also elm_entry_single_line_set().
2943 * @param obj The entry object
2944 * @return single_line If true, the text in the entry is set to display
2950 elm_entry_single_line_get(const Evas_Object *obj)
2952 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2953 Widget_Data *wd = elm_widget_data_get(obj);
2954 if (!wd) return EINA_FALSE;
2955 return wd->single_line;
2959 * This sets the entry object to password mode. All text entered
2960 * and/or displayed within the widget will be replaced with asterisks (*).
2962 * @param obj The entry object
2963 * @param password If true, password mode is enabled.
2968 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2970 ELM_CHECK_WIDTYPE(obj, widtype);
2971 Widget_Data *wd = elm_widget_data_get(obj);
2973 if (wd->password == password) return;
2974 wd->password = password;
2975 wd->single_line = EINA_TRUE;
2976 wd->linewrap = ELM_WRAP_NONE;
2981 * This returns whether password mode is enabled.
2982 * See also elm_entry_password_set().
2984 * @param obj The entry object
2985 * @return If true, the entry is set to display all characters
2991 elm_entry_password_get(const Evas_Object *obj)
2993 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2994 Widget_Data *wd = elm_widget_data_get(obj);
2995 if (!wd) return EINA_FALSE;
2996 return wd->password;
3000 * This sets the text displayed within the entry to @p entry.
3002 * @param obj The entry object
3003 * @param entry The text to be displayed
3008 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3010 _elm_entry_text_set(obj, NULL, entry);
3014 * This appends @p entry to the text of the entry.
3016 * @param obj The entry object
3017 * @param entry The text to be displayed
3022 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3025 ELM_CHECK_WIDTYPE(obj, widtype);
3026 Widget_Data *wd = elm_widget_data_get(obj);
3028 if (!entry) entry = "";
3029 wd->changed = EINA_TRUE;
3031 len = strlen(entry);
3032 if (wd->append_text_left)
3035 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3041 wd->append_text_left = tmpbuf;
3042 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3043 wd->append_text_len += len;
3047 /* FIXME: Add chunked appending here (like in entry_set) */
3048 edje_object_part_text_append(wd->ent, "elm.text", entry);
3053 * This returns the text currently shown in object @p entry.
3054 * See also elm_entry_entry_set().
3056 * @param obj The entry object
3057 * @return The currently displayed text or NULL on failure
3062 elm_entry_entry_get(const Evas_Object *obj)
3064 return _elm_entry_text_get(obj, NULL);
3068 * This returns EINA_TRUE if the entry is empty/there was an error
3069 * and EINA_FALSE if it is not empty.
3071 * @param obj The entry object
3072 * @return If the entry is empty or not.
3077 elm_entry_is_empty(const Evas_Object *obj)
3079 /* FIXME: until there's support for that in textblock, we just check
3080 * to see if the there is text or not. */
3081 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3082 Widget_Data *wd = elm_widget_data_get(obj);
3083 const Evas_Object *tb;
3084 //Evas_Textblock_Cursor *cur;
3086 if (!wd) return EINA_TRUE;
3089 /* It's a hack until we get the support suggested above.
3090 * We just create a cursor, point it to the begining, and then
3091 * try to advance it, if it can advance, the tb is not empty,
3092 * otherwise it is. */
3093 tb = edje_object_part_object_get(wd->ent, "elm.text");
3094 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3095 actually, ok for the time being, thsese hackish stuff will be removed
3096 once evas 1.0 is out*/
3097 evas_textblock_cursor_pos_set(cur, 0);
3098 ret = evas_textblock_cursor_char_next(cur);
3099 evas_textblock_cursor_free(cur);
3104 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3105 if (!str) return EINA_TRUE;
3107 ret = (strlen(str) == 0);
3113 * This returns all selected text within the entry.
3115 * @param obj The entry object
3116 * @return The selected text within the entry or NULL on failure
3121 elm_entry_selection_get(const Evas_Object *obj)
3123 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3124 Widget_Data *wd = elm_widget_data_get(obj);
3125 if (!wd) return NULL;
3126 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3130 * This inserts text in @p entry where the current cursor position.
3132 * This inserts text at the cursor position is as if it was typed
3133 * by the user (note this also allows markup which a user
3134 * can't just "type" as it would be converted to escaped text, so this
3135 * call can be used to insert things like emoticon items or bold push/pop
3136 * tags, other font and color change tags etc.)
3138 * @param obj The entry object
3139 * @param entry The text to insert
3144 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3146 ELM_CHECK_WIDTYPE(obj, widtype);
3147 Widget_Data *wd = elm_widget_data_get(obj);
3149 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3151 #ifdef HAVE_ELEMENTARY_X
3152 if (cnpwidgetdata == obj)
3153 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3156 wd->changed = EINA_TRUE;
3161 * This enables word line wrapping in the entry object. It is the opposite
3162 * of elm_entry_single_line_set(). Additionally, setting this disables
3163 * character line wrapping.
3165 * @param obj The entry object
3166 * @param wrap If true, the entry will be wrapped once it reaches the end
3167 * of the object. Wrapping will occur at the end of the word before the end of the
3173 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3175 ELM_CHECK_WIDTYPE(obj, widtype);
3176 Widget_Data *wd = elm_widget_data_get(obj);
3178 if (wd->linewrap == wrap) return;
3180 wd->linewrap = wrap;
3185 * Set wrap width of the entry
3187 * @param obj The entry object
3188 * @param w The wrap width in pixels at a minimum where words need to wrap
3192 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
3194 Widget_Data *wd = elm_widget_data_get(obj);
3195 if (wd->wrap_w == w) return;
3201 * get wrap width of the entry
3203 * @param obj The entry object
3204 * @return The wrap width in pixels at a minimum where words need to wrap
3208 elm_entry_wrap_width_get(const Evas_Object *obj)
3210 Widget_Data *wd = elm_widget_data_get(obj);
3215 * Get the wrapping behavior of the entry.
3216 * See also elm_entry_line_wrap_set().
3218 * @param obj The entry object
3224 elm_entry_line_wrap_get(const Evas_Object *obj)
3226 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3227 Widget_Data *wd = elm_widget_data_get(obj);
3228 if (!wd) return EINA_FALSE;
3229 return wd->linewrap;
3233 * This sets the editable attribute of the entry.
3235 * @param obj The entry object
3236 * @param editable If true, the entry will be editable by the user.
3237 * If false, it will be set to the disabled state.
3242 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3244 ELM_CHECK_WIDTYPE(obj, widtype);
3245 Widget_Data *wd = elm_widget_data_get(obj);
3247 if (wd->editable == editable) return;
3248 wd->editable = editable;
3251 #ifdef HAVE_ELEMENTARY_X
3253 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3255 elm_drop_target_del(obj);
3260 * This gets the editable attribute of the entry.
3261 * See also elm_entry_editable_set().
3263 * @param obj The entry object
3264 * @return If true, the entry is editable by the user.
3265 * If false, it is not editable by the user
3270 elm_entry_editable_get(const Evas_Object *obj)
3272 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3273 Widget_Data *wd = elm_widget_data_get(obj);
3274 if (!wd) return EINA_FALSE;
3275 return wd->editable;
3279 * This drops any existing text selection within the entry.
3281 * @param obj The entry object
3286 elm_entry_select_none(Evas_Object *obj)
3288 ELM_CHECK_WIDTYPE(obj, widtype);
3289 Widget_Data *wd = elm_widget_data_get(obj);
3293 wd->selmode = EINA_FALSE;
3294 if (!_elm_config->desktop_entry)
3295 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3296 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3298 wd->have_selection = EINA_FALSE;
3299 edje_object_part_text_select_none(wd->ent, "elm.text");
3303 * This selects all text within the entry.
3305 * @param obj The entry object
3310 elm_entry_select_all(Evas_Object *obj)
3312 ELM_CHECK_WIDTYPE(obj, widtype);
3313 Widget_Data *wd = elm_widget_data_get(obj);
3317 wd->selmode = EINA_FALSE;
3318 if (!_elm_config->desktop_entry)
3319 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3320 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3322 wd->have_selection = EINA_TRUE;
3323 edje_object_part_text_select_all(wd->ent, "elm.text");
3327 * This function returns the geometry of the cursor.
3329 * It's useful if you want to draw something on the cursor (or where it is),
3330 * or for example in the case of scrolled entry where you want to show the
3333 * @param obj The entry object
3334 * @param x returned geometry
3335 * @param y returned geometry
3336 * @param w returned geometry
3337 * @param h returned geometry
3338 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3343 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3345 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3346 Widget_Data *wd = elm_widget_data_get(obj);
3347 if (!wd) return EINA_FALSE;
3348 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3353 * This moves the cursor one place to the right within the entry.
3355 * @param obj The entry object
3356 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3361 elm_entry_cursor_next(Evas_Object *obj)
3363 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3364 Widget_Data *wd = elm_widget_data_get(obj);
3365 if (!wd) return EINA_FALSE;
3366 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3370 * This moves the cursor one place to the left within the entry.
3372 * @param obj The entry object
3373 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3378 elm_entry_cursor_prev(Evas_Object *obj)
3380 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3381 Widget_Data *wd = elm_widget_data_get(obj);
3382 if (!wd) return EINA_FALSE;
3383 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3387 * This moves the cursor one line up within the entry.
3389 * @param obj The entry object
3390 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3395 elm_entry_cursor_up(Evas_Object *obj)
3397 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3398 Widget_Data *wd = elm_widget_data_get(obj);
3399 if (!wd) return EINA_FALSE;
3400 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3404 * This moves the cursor one line down within the entry.
3406 * @param obj The entry object
3407 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3412 elm_entry_cursor_down(Evas_Object *obj)
3414 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3415 Widget_Data *wd = elm_widget_data_get(obj);
3416 if (!wd) return EINA_FALSE;
3417 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3421 * This moves the cursor to the beginning of the entry.
3423 * @param obj The entry object
3428 elm_entry_cursor_begin_set(Evas_Object *obj)
3430 ELM_CHECK_WIDTYPE(obj, widtype);
3431 Widget_Data *wd = elm_widget_data_get(obj);
3433 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3437 * This moves the cursor to the end of the entry.
3439 * @param obj The entry object
3444 elm_entry_cursor_end_set(Evas_Object *obj)
3446 ELM_CHECK_WIDTYPE(obj, widtype);
3447 Widget_Data *wd = elm_widget_data_get(obj);
3450 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3453 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3454 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3459 * This moves the cursor to the beginning of the current line.
3461 * @param obj The entry object
3466 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3468 ELM_CHECK_WIDTYPE(obj, widtype);
3469 Widget_Data *wd = elm_widget_data_get(obj);
3471 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3475 * This moves the cursor to the end of the current line.
3477 * @param obj The entry object
3482 elm_entry_cursor_line_end_set(Evas_Object *obj)
3484 ELM_CHECK_WIDTYPE(obj, widtype);
3485 Widget_Data *wd = elm_widget_data_get(obj);
3487 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3491 * This begins a selection within the entry as though
3492 * the user were holding down the mouse button to make a selection.
3494 * @param obj The entry object
3499 elm_entry_cursor_selection_begin(Evas_Object *obj)
3501 ELM_CHECK_WIDTYPE(obj, widtype);
3502 Widget_Data *wd = elm_widget_data_get(obj);
3504 edje_object_part_text_select_begin(wd->ent, "elm.text");
3508 * This ends a selection within the entry as though
3509 * the user had just released the mouse button while making a selection.
3511 * @param obj The entry object
3516 elm_entry_cursor_selection_end(Evas_Object *obj)
3518 ELM_CHECK_WIDTYPE(obj, widtype);
3519 Widget_Data *wd = elm_widget_data_get(obj);
3521 edje_object_part_text_select_extend(wd->ent, "elm.text");
3525 * TODO: fill this in
3527 * @param obj The entry object
3528 * @return TODO: fill this in
3533 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3535 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3536 Widget_Data *wd = elm_widget_data_get(obj);
3537 if (!wd) return EINA_FALSE;
3538 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3542 * This returns whether the cursor is visible.
3544 * @param obj The entry object
3545 * @return If true, the cursor is visible.
3550 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3552 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3553 Widget_Data *wd = elm_widget_data_get(obj);
3554 if (!wd) return EINA_FALSE;
3555 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3559 * TODO: fill this in
3561 * @param obj The entry object
3562 * @return TODO: fill this in
3567 elm_entry_cursor_content_get(const Evas_Object *obj)
3569 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3570 Widget_Data *wd = elm_widget_data_get(obj);
3571 if (!wd) return NULL;
3572 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3576 * Sets the cursor position in the entry to the given value
3578 * @param obj The entry object
3579 * @param pos The position of the cursor
3584 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3586 ELM_CHECK_WIDTYPE(obj, widtype);
3587 Widget_Data *wd = elm_widget_data_get(obj);
3589 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3590 edje_object_message_signal_process(wd->ent);
3594 * Retrieves the current position of the cursor in the entry
3596 * @param obj The entry object
3597 * @return The cursor position
3602 elm_entry_cursor_pos_get(const Evas_Object *obj)
3604 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3605 Widget_Data *wd = elm_widget_data_get(obj);
3607 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3611 * This executes a "cut" action on the selected text in the entry.
3613 * @param obj The entry object
3618 elm_entry_selection_cut(Evas_Object *obj)
3620 ELM_CHECK_WIDTYPE(obj, widtype);
3621 Widget_Data *wd = elm_widget_data_get(obj);
3623 _cut(obj, NULL, NULL);
3627 * This executes a "copy" action on the selected text in the entry.
3629 * @param obj The entry object
3634 elm_entry_selection_copy(Evas_Object *obj)
3636 ELM_CHECK_WIDTYPE(obj, widtype);
3637 Widget_Data *wd = elm_widget_data_get(obj);
3639 _copy(obj, NULL, NULL);
3643 * This executes a "paste" action in the entry.
3645 * @param obj The entry object
3650 elm_entry_selection_paste(Evas_Object *obj)
3652 ELM_CHECK_WIDTYPE(obj, widtype);
3653 Widget_Data *wd = elm_widget_data_get(obj);
3655 _paste(obj, NULL, NULL);
3659 * This clears and frees the items in a entry's contextual (right click) menu.
3661 * @param obj The entry object
3666 elm_entry_context_menu_clear(Evas_Object *obj)
3668 ELM_CHECK_WIDTYPE(obj, widtype);
3669 Widget_Data *wd = elm_widget_data_get(obj);
3670 Elm_Entry_Context_Menu_Item *it;
3672 EINA_LIST_FREE(wd->items, it)
3674 eina_stringshare_del(it->label);
3675 eina_stringshare_del(it->icon_file);
3676 eina_stringshare_del(it->icon_group);
3682 * This adds an item to the entry's contextual menu.
3684 * @param obj The entry object
3685 * @param label The item's text label
3686 * @param icon_file The item's icon file
3687 * @param icon_type The item's icon type
3688 * @param func The callback to execute when the item is clicked
3689 * @param data The data to associate with the item for related functions
3694 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)
3696 ELM_CHECK_WIDTYPE(obj, widtype);
3697 Widget_Data *wd = elm_widget_data_get(obj);
3698 Elm_Entry_Context_Menu_Item *it;
3700 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3702 wd->items = eina_list_append(wd->items, it);
3704 it->label = eina_stringshare_add(label);
3705 it->icon_file = eina_stringshare_add(icon_file);
3706 it->icon_type = icon_type;
3708 it->data = (void *)data;
3712 * This disables the entry's contextual (right click) menu.
3714 * @param obj The entry object
3715 * @param disabled If true, the menu is disabled
3720 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3722 ELM_CHECK_WIDTYPE(obj, widtype);
3723 Widget_Data *wd = elm_widget_data_get(obj);
3725 if (wd->context_menu == !disabled) return;
3726 wd->context_menu = !disabled;
3730 * This returns whether the entry's contextual (right click) menu is disabled.
3732 * @param obj The entry object
3733 * @return If true, the menu is disabled
3738 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3740 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3741 Widget_Data *wd = elm_widget_data_get(obj);
3742 if (!wd) return EINA_FALSE;
3743 return !wd->context_menu;
3747 * This appends a custom item provider to the list for that entry
3749 * This appends the given callback. The list is walked from beginning to end
3750 * with each function called given the item href string in the text. If the
3751 * function returns an object handle other than NULL (it should create an
3752 * and object to do this), then this object is used to replace that item. If
3753 * not the next provider is called until one provides an item object, or the
3754 * default provider in entry does.
3756 * @param obj The entry object
3757 * @param func The function called to provide the item object
3758 * @param data The data passed to @p func
3763 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3765 ELM_CHECK_WIDTYPE(obj, widtype);
3766 Widget_Data *wd = elm_widget_data_get(obj);
3768 EINA_SAFETY_ON_NULL_RETURN(func);
3769 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3773 wd->item_providers = eina_list_append(wd->item_providers, ip);
3777 * This prepends a custom item provider to the list for that entry
3779 * This prepends the given callback. See elm_entry_item_provider_append() for
3782 * @param obj The entry object
3783 * @param func The function called to provide the item object
3784 * @param data The data passed to @p func
3789 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3791 ELM_CHECK_WIDTYPE(obj, widtype);
3792 Widget_Data *wd = elm_widget_data_get(obj);
3794 EINA_SAFETY_ON_NULL_RETURN(func);
3795 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3799 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3803 * This removes a custom item provider to the list for that entry
3805 * This removes the given callback. See elm_entry_item_provider_append() for
3808 * @param obj The entry object
3809 * @param func The function called to provide the item object
3810 * @param data The data passed to @p func
3815 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3817 ELM_CHECK_WIDTYPE(obj, widtype);
3818 Widget_Data *wd = elm_widget_data_get(obj);
3820 Elm_Entry_Item_Provider *ip;
3822 EINA_SAFETY_ON_NULL_RETURN(func);
3823 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3825 if ((ip->func == func) && ((!data) || (ip->data == data)))
3827 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3835 * Append a filter function for text inserted in the entry
3837 * Append the given callback to the list. This functions will be called
3838 * whenever any text is inserted into the entry, with the text to be inserted
3839 * as a parameter. The callback function is free to alter the text in any way
3840 * it wants, but it must remember to free the given pointer and update it.
3841 * If the new text is to be discarded, the function can free it and set it text
3842 * parameter to NULL. This will also prevent any following filters from being
3845 * @param obj The entry object
3846 * @param func The function to use as text filter
3847 * @param data User data to pass to @p func
3852 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3855 Elm_Entry_Text_Filter *tf;
3856 ELM_CHECK_WIDTYPE(obj, widtype);
3858 wd = elm_widget_data_get(obj);
3860 EINA_SAFETY_ON_NULL_RETURN(func);
3862 tf = _filter_new(func, data);
3865 wd->text_filters = eina_list_append(wd->text_filters, tf);
3869 * Prepend a filter function for text insdrted in the entry
3871 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3872 * for more information
3874 * @param obj The entry object
3875 * @param func The function to use as text filter
3876 * @param data User data to pass to @p func
3881 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3884 Elm_Entry_Text_Filter *tf;
3885 ELM_CHECK_WIDTYPE(obj, widtype);
3887 wd = elm_widget_data_get(obj);
3889 EINA_SAFETY_ON_NULL_RETURN(func);
3891 tf = _filter_new(func, data);
3894 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3898 * Remove a filter from the list
3900 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3901 * for more information.
3903 * @param obj The entry object
3904 * @param func The filter function to remove
3905 * @param data The user data passed when adding the function
3910 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3914 Elm_Entry_Text_Filter *tf;
3915 ELM_CHECK_WIDTYPE(obj, widtype);
3917 wd = elm_widget_data_get(obj);
3919 EINA_SAFETY_ON_NULL_RETURN(func);
3921 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3923 if ((tf->func == func) && ((!data) || (tf->data == data)))
3925 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3933 * This converts a markup (HTML-like) string into UTF-8.
3934 * Returning string is obtained with malloc.
3935 * After use the returned string, it should be freed.
3937 * @param s The string (in markup) to be converted
3938 * @return The converted string (in UTF-8). It should be freed.
3943 elm_entry_markup_to_utf8(const char *s)
3945 char *ss = _elm_util_mkup_to_text(s);
3946 if (!ss) ss = strdup("");
3951 * This converts a UTF-8 string into markup (HTML-like).
3952 * Returning string is obtained with malloc.
3953 * After use the returned string, it should be freed.
3955 * @param s The string (in UTF-8) to be converted
3956 * @return The converted string (in markup). It should be freed.
3961 elm_entry_utf8_to_markup(const char *s)
3963 char *ss = _elm_util_text_to_mkup(s);
3964 if (!ss) ss = strdup("");
3969 * Get the input method context in the entry widget
3971 * @param obj The entry object
3972 * @return The input method context
3976 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3978 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3979 Widget_Data *wd = elm_widget_data_get(obj);
3980 if (!wd || !wd->ent) return NULL;
3982 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3986 * Set whether entry should enable the return key on soft keyboard automatically
3988 * @param obj The entry object
3989 * @param on If true, entry enables the return key on soft keyboard automatically.
3994 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3996 ELM_CHECK_WIDTYPE(obj, widtype);
3997 Widget_Data *wd = elm_widget_data_get(obj);
4000 wd->autoreturnkey = on;
4001 _check_enable_returnkey(obj);
4005 * Set whether entry should support auto capitalization
4007 * @param obj The entry object
4008 * @param on If true, entry suports auto capitalization.
4013 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4015 ELM_CHECK_WIDTYPE(obj, widtype);
4016 Widget_Data *wd = elm_widget_data_get(obj);
4020 wd->autocapital = EINA_FALSE;
4022 wd->autocapital = autocap;
4024 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4025 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4026 wd->autocapital = EINA_FALSE;
4028 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
4032 * Set whether entry should support auto period
4034 * @param obj The entry object
4035 * @param on If true, entry suports auto period.
4040 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4042 ELM_CHECK_WIDTYPE(obj, widtype);
4043 Widget_Data *wd = elm_widget_data_get(obj);
4047 wd->autoperiod = EINA_FALSE;
4049 wd->autoperiod = autoperiod;
4051 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4052 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4053 wd->autoperiod = EINA_FALSE;
4055 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4059 * Set the font size on the entry object
4061 * @param obj The entry object
4062 * @param size font size
4067 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
4069 ELM_CHECK_WIDTYPE(obj, widtype);
4070 Widget_Data *wd = elm_widget_data_get(obj);
4071 Eina_Strbuf *fontbuf = NULL;
4076 t = eina_stringshare_add(elm_entry_entry_get(obj));
4077 fontbuf = eina_strbuf_new();
4078 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
4080 if (fontsize == 0) removeflag = 1; // remove fontsize tag
4082 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
4084 elm_entry_entry_set(obj, t);
4088 eina_strbuf_free(fontbuf);
4089 eina_stringshare_del(t);
4093 * Set the text align on the entry object
4095 * @param obj The entry object
4096 * @param align align mode
4101 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
4103 ELM_CHECK_WIDTYPE(obj, widtype);
4104 Widget_Data *wd = elm_widget_data_get(obj);
4109 t = eina_stringshare_add(elm_entry_entry_get(obj));
4111 if (len <= 0) return;
4113 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
4114 elm_entry_entry_set(obj, t);
4118 eina_stringshare_del(t);
4122 * Set the text color on the entry object
4124 * @param obj The entry object
4125 * @param r Red property background color of The entry object
4126 * @param g Green property background color of The entry object
4127 * @param b Blue property background color of The entry object
4128 * @param a Alpha property background alpha of The entry object
4133 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4135 ELM_CHECK_WIDTYPE(obj, widtype);
4136 Widget_Data *wd = elm_widget_data_get(obj);
4137 Eina_Strbuf *colorbuf = NULL;
4142 t = eina_stringshare_add(elm_entry_entry_get(obj));
4144 if (len <= 0) return;
4145 colorbuf = eina_strbuf_new();
4146 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
4148 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
4150 elm_entry_entry_set(obj, t);
4154 eina_strbuf_free(colorbuf);
4155 eina_stringshare_del(t);
4159 * Set background color of the entry
4161 * @param obj The entry object
4162 * @param r Red property background color of The entry object
4163 * @param g Green property background color of The entry object
4164 * @param b Blue property background color of The entry object
4165 * @param a Alpha property background alpha of The entry object
4169 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4171 ELM_CHECK_WIDTYPE(obj, widtype);
4172 Widget_Data *wd = elm_widget_data_get(obj);
4173 evas_object_color_set(wd->bg, r, g, b, a);
4175 if (wd->bgcolor == EINA_FALSE)
4178 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4183 * Filter inserted text based on user defined character and byte limits
4185 * Add this filter to an entry to limit the characters that it will accept
4186 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
4187 * The funtion works on the UTF-8 representation of the string, converting
4188 * it from the set markup, thus not accounting for any format in it.
4190 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
4191 * it as data when setting the filter. In it it's possible to set limits
4192 * by character count or bytes (any of them is disabled if 0), and both can
4193 * be set at the same time. In that case, it first checks for characters,
4196 * The function will cut the inserted text in order to allow only the first
4197 * number of characters that are still allowed. The cut is made in
4198 * characters, even when limiting by bytes, in order to always contain
4199 * valid ones and avoid half unicode characters making it in.
4204 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4206 Elm_Entry_Filter_Limit_Size *lim = data;
4209 const char *(*text_get)(const Evas_Object *);
4210 const char *widget_type;
4212 EINA_SAFETY_ON_NULL_RETURN(data);
4213 EINA_SAFETY_ON_NULL_RETURN(entry);
4214 EINA_SAFETY_ON_NULL_RETURN(text);
4216 /* hack. I don't want to copy the entire function to work with
4218 widget_type = elm_widget_type_get(entry);
4219 if (!strcmp(widget_type, "entry"))
4220 text_get = elm_entry_entry_get;
4224 current = elm_entry_markup_to_utf8(text_get(entry));
4226 if (lim->max_char_count > 0)
4228 len = evas_string_char_len_get(current);
4229 if (len >= lim->max_char_count)
4231 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4237 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4238 if ((len + newlen) > lim->max_char_count)
4239 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4241 else if (lim->max_byte_count > 0)
4243 len = strlen(current);
4244 if (len >= lim->max_byte_count)
4246 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4252 newlen = strlen(elm_entry_markup_to_utf8(*text));
4253 if ((len + newlen) > lim->max_byte_count)
4254 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4260 * Filter inserted text based on accepted or rejected sets of characters
4262 * Add this filter to an entry to restrict the set of accepted characters
4263 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4264 * This structure contains both accepted and rejected sets, but they are
4265 * mutually exclusive. If accepted is set, it will be used, otherwise it
4266 * goes on to the rejected set.
4269 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4271 Elm_Entry_Filter_Accept_Set *as = data;
4275 int read_idx, last_read_idx = 0, read_char;
4277 EINA_SAFETY_ON_NULL_RETURN(data);
4278 EINA_SAFETY_ON_NULL_RETURN(text);
4280 if ((!as->accepted) && (!as->rejected))
4286 goes_in = EINA_TRUE;
4291 goes_in = EINA_FALSE;
4295 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4298 int cmp_idx, cmp_char;
4299 Eina_Bool in_set = EINA_FALSE;
4301 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4304 if (read_char == cmp_char)
4309 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4311 if (in_set == goes_in)
4313 int size = read_idx - last_read_idx;
4314 const char *src = (*text) + last_read_idx;
4316 memcpy(insert, *text + last_read_idx, size);
4319 last_read_idx = read_idx;
4320 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4326 * This sets the file (and implicitly loads it) for the text to display and
4327 * then edit. All changes are written back to the file after a short delay if
4328 * the entry object is set to autosave.
4330 * @param obj The entry object
4331 * @param file The path to the file to load and save
4332 * @param format The file format
4337 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4339 ELM_CHECK_WIDTYPE(obj, widtype);
4340 Widget_Data *wd = elm_widget_data_get(obj);
4342 if (wd->delay_write)
4344 ecore_timer_del(wd->delay_write);
4345 wd->delay_write = NULL;
4347 if (wd->autosave) _save(obj);
4348 eina_stringshare_replace(&wd->file, file);
4349 wd->format = format;
4354 * Gets the file to load and save and the file format
4356 * @param obj The entry object
4357 * @param file The path to the file to load and save
4358 * @param format The file format
4363 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4365 ELM_CHECK_WIDTYPE(obj, widtype);
4366 Widget_Data *wd = elm_widget_data_get(obj);
4368 if (file) *file = wd->file;
4369 if (format) *format = wd->format;
4373 * This function writes any changes made to the file set with
4374 * elm_entry_file_set()
4376 * @param obj The entry object
4381 elm_entry_file_save(Evas_Object *obj)
4383 ELM_CHECK_WIDTYPE(obj, widtype);
4384 Widget_Data *wd = elm_widget_data_get(obj);
4386 if (wd->delay_write)
4388 ecore_timer_del(wd->delay_write);
4389 wd->delay_write = NULL;
4392 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4396 * This sets the entry object to 'autosave' the loaded text file or not.
4398 * @param obj The entry object
4399 * @param autosave Autosave the loaded file or not
4404 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4406 ELM_CHECK_WIDTYPE(obj, widtype);
4407 Widget_Data *wd = elm_widget_data_get(obj);
4409 wd->autosave = !!autosave;
4413 * This gets the entry object's 'autosave' status.
4415 * @param obj The entry object
4416 * @return Autosave the loaded file or not
4421 elm_entry_autosave_get(const Evas_Object *obj)
4423 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4424 Widget_Data *wd = elm_widget_data_get(obj);
4425 if (!wd) return EINA_FALSE;
4426 return wd->autosave;
4430 * Control pasting of text and images for the widget.
4432 * Normally the entry allows both text and images to be pasted. By setting
4433 * textonly to be true, this prevents images from being pasted.
4435 * Note this only changes the behaviour of text.
4437 * @param obj The entry object
4438 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4443 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4445 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4446 ELM_CHECK_WIDTYPE(obj, widtype);
4447 Widget_Data *wd = elm_widget_data_get(obj);
4449 textonly = !!textonly;
4450 if (wd->textonly == textonly) return;
4451 wd->textonly = !!textonly;
4452 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4453 #ifdef HAVE_ELEMENTARY_X
4454 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4459 * Getting elm_entry text paste/drop mode.
4461 * In textonly mode, only text may be pasted or dropped into the widget.
4463 * @param obj The entry object
4464 * @return If the widget only accepts text from pastes.
4469 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4471 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4472 Widget_Data *wd = elm_widget_data_get(obj);
4473 if (!wd) return EINA_FALSE;
4474 return wd->textonly;
4478 * Enable or disable scrolling in entry
4480 * Normally the entry is not scrollable unless you enable it with this call.
4482 * @param obj The entry object
4483 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4488 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4490 ELM_CHECK_WIDTYPE(obj, widtype);
4491 Widget_Data *wd = elm_widget_data_get(obj);
4494 if (wd->scroll == scroll) return;
4495 wd->scroll = scroll;
4498 elm_widget_sub_object_del(obj, wd->scroller);
4499 elm_widget_resize_object_set(obj, wd->scroller);
4500 elm_widget_sub_object_add(obj, wd->ent);
4501 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4502 evas_object_show(wd->scroller);
4503 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4504 if (wd->single_line)
4506 elm_smart_scroller_policy_set(wd->scroller,
4507 ELM_SMART_SCROLLER_POLICY_OFF,
4508 ELM_SMART_SCROLLER_POLICY_OFF);
4509 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4513 const Elm_Scroller_Policy map[3] =
4515 ELM_SMART_SCROLLER_POLICY_AUTO,
4516 ELM_SMART_SCROLLER_POLICY_ON,
4517 ELM_SMART_SCROLLER_POLICY_OFF
4519 elm_smart_scroller_policy_set(wd->scroller,
4522 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4527 elm_smart_scroller_child_set(wd->scroller, NULL);
4528 elm_widget_sub_object_del(obj, wd->ent);
4529 elm_widget_resize_object_set(obj, wd->ent);
4530 evas_object_smart_member_add(wd->scroller, obj);
4531 elm_widget_sub_object_add(obj, wd->scroller);
4532 evas_object_hide(wd->scroller);
4533 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4540 * Get the scrollable state of the entry
4542 * Normally the entry is not scrollable. This gets the scrollable state
4543 * of the entry. See elm_entry_scrollable_set() for more information.
4545 * @param obj The entry object
4546 * @return The scrollable state
4551 elm_entry_scrollable_get(const Evas_Object *obj)
4553 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4554 Widget_Data *wd = elm_widget_data_get(obj);
4555 if (!wd) return EINA_FALSE;
4560 * This sets a widget to be displayed to the left of a scrolled entry.
4562 * @param obj The scrolled entry object
4563 * @param icon The widget to display on the left side of the scrolled
4566 * @note A previously set widget will be destroyed.
4567 * @note If the object being set does not have minimum size hints set,
4568 * it won't get properly displayed.
4571 * @see elm_entry_end_set
4574 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4576 ELM_CHECK_WIDTYPE(obj, widtype);
4577 Widget_Data *wd = elm_widget_data_get(obj);
4580 EINA_SAFETY_ON_NULL_RETURN(icon);
4581 if (wd->icon == icon) return;
4582 if (wd->icon) evas_object_del(wd->icon);
4584 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4586 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4587 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4592 * Gets the leftmost widget of the scrolled entry. This object is
4593 * owned by the scrolled entry and should not be modified.
4595 * @param obj The scrolled entry object
4596 * @return the left widget inside the scroller
4601 elm_entry_icon_get(const Evas_Object *obj)
4603 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4604 Widget_Data *wd = elm_widget_data_get(obj);
4605 if (!wd) return NULL;
4610 * Unset the leftmost widget of the scrolled entry, unparenting and
4613 * @param obj The scrolled entry object
4614 * @return the previously set icon sub-object of this entry, on
4617 * @see elm_entry_icon_set()
4622 elm_entry_icon_unset(Evas_Object *obj)
4624 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4625 Widget_Data *wd = elm_widget_data_get(obj);
4626 Evas_Object *ret = NULL;
4627 if (!wd) return NULL;
4630 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4631 if (!edje) return NULL;
4633 edje_object_part_unswallow(edje, wd->icon);
4634 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4642 * Sets the visibility of the left-side widget of the scrolled entry,
4643 * set by @elm_entry_icon_set().
4645 * @param obj The scrolled entry object
4646 * @param setting EINA_TRUE if the object should be displayed,
4647 * EINA_FALSE if not.
4652 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4654 ELM_CHECK_WIDTYPE(obj, widtype);
4655 Widget_Data *wd = elm_widget_data_get(obj);
4656 if ((!wd) || (!wd->icon)) return;
4658 evas_object_hide(wd->icon);
4660 evas_object_show(wd->icon);
4665 * This sets a widget to be displayed to the end of a scrolled entry.
4667 * @param obj The scrolled entry object
4668 * @param end The widget to display on the right side of the scrolled
4671 * @note A previously set widget will be destroyed.
4672 * @note If the object being set does not have minimum size hints set,
4673 * it won't get properly displayed.
4676 * @see elm_entry_icon_set
4679 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4681 ELM_CHECK_WIDTYPE(obj, widtype);
4682 Widget_Data *wd = elm_widget_data_get(obj);
4685 EINA_SAFETY_ON_NULL_RETURN(end);
4686 if (wd->end == end) return;
4687 if (wd->end) evas_object_del(wd->end);
4689 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4691 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4692 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4697 * Gets the endmost widget of the scrolled entry. This object is owned
4698 * by the scrolled entry and should not be modified.
4700 * @param obj The scrolled entry object
4701 * @return the right widget inside the scroller
4706 elm_entry_end_get(const Evas_Object *obj)
4708 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4709 Widget_Data *wd = elm_widget_data_get(obj);
4710 if (!wd) return NULL;
4715 * Unset the endmost widget of the scrolled entry, unparenting and
4718 * @param obj The scrolled entry object
4719 * @return the previously set icon sub-object of this entry, on
4722 * @see elm_entry_icon_set()
4727 elm_entry_end_unset(Evas_Object *obj)
4729 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4730 Widget_Data *wd = elm_widget_data_get(obj);
4731 Evas_Object *ret = NULL;
4732 if (!wd) return NULL;
4735 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4736 if (!edje) return NULL;
4738 edje_object_part_unswallow(edje, wd->end);
4739 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4747 * Sets the visibility of the end widget of the scrolled entry, set by
4748 * @elm_entry_end_set().
4750 * @param obj The scrolled entry object
4751 * @param setting EINA_TRUE if the object should be displayed,
4752 * EINA_FALSE if not.
4757 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4759 ELM_CHECK_WIDTYPE(obj, widtype);
4760 Widget_Data *wd = elm_widget_data_get(obj);
4761 if ((!wd) || (!wd->end)) return;
4763 evas_object_hide(wd->end);
4765 evas_object_show(wd->end);
4770 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4772 * @param obj The scrolled entry object
4773 * @param h The horizontal scrollbar policy to apply
4774 * @param v The vertical scrollbar policy to apply
4779 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4781 ELM_CHECK_WIDTYPE(obj, widtype);
4782 Widget_Data *wd = elm_widget_data_get(obj);
4783 const Elm_Scroller_Policy map[3] =
4785 ELM_SMART_SCROLLER_POLICY_AUTO,
4786 ELM_SMART_SCROLLER_POLICY_ON,
4787 ELM_SMART_SCROLLER_POLICY_OFF
4792 elm_smart_scroller_policy_set(wd->scroller,
4798 * This enables/disables bouncing within the entry.
4800 * @param obj The scrolled entry object
4801 * @param h The horizontal bounce state
4802 * @param v The vertical bounce state
4807 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4809 ELM_CHECK_WIDTYPE(obj, widtype);
4810 Widget_Data *wd = elm_widget_data_get(obj);
4812 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4816 * Get the bounce mode
4818 * @param obj The Entry object
4819 * @param h_bounce Allow bounce horizontally
4820 * @param v_bounce Allow bounce vertically
4825 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4827 ELM_CHECK_WIDTYPE(obj, widtype);
4828 Widget_Data *wd = elm_widget_data_get(obj);
4830 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4834 * This sets the attribute to show the input panel automatically.
4836 * @param obj The entry object
4837 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4842 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4844 ELM_CHECK_WIDTYPE(obj, widtype);
4845 Widget_Data *wd = elm_widget_data_get(obj);
4848 wd->input_panel_enable = enabled;
4849 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4853 * Set the input panel layout of the entry
4855 * @param obj The entry object
4856 * @param layout the layout to set
4861 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4863 ELM_CHECK_WIDTYPE(obj, widtype);
4864 Widget_Data *wd = elm_widget_data_get(obj);
4867 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4870 wd->input_panel_layout = layout;
4872 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4876 * Set the magnifier style of the entry
4878 * @param obj The entry object
4879 * @param type the magnifier style to set
4884 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4886 ELM_CHECK_WIDTYPE(obj, widtype);
4887 Widget_Data *wd = elm_widget_data_get(obj);
4890 wd->mgf_type = type;
4891 _magnifier_create(obj);
4894 EINA_DEPRECATED EAPI void
4895 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4897 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);