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 (!wd->deferred_recalc_job)
716 Evas_Coord cx, cy, cw, ch;
717 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
721 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
722 wd->cur_changed = EINA_FALSE;
726 wd->deferred_cur = EINA_TRUE;
730 _elm_win_recalc_job(void *data)
732 Widget_Data *wd = elm_widget_data_get(data);
733 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
735 wd->deferred_recalc_job = NULL;
737 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
738 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
739 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
742 /* This is a hack to workaround the way min size hints are treated.
743 * If the minimum width is smaller than the restricted width, it means
744 * the mininmum doesn't matter. */
747 Evas_Coord ominw = -1;
748 evas_object_size_hint_min_get(data, &ominw, NULL);
752 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
755 Evas_Coord vmw = 0, vmh = 0;
757 edje_object_size_min_calc
758 (elm_smart_scroller_edje_object_get(wd->scroller),
762 evas_object_size_hint_min_set(data, vmw, minh + vmh);
763 evas_object_size_hint_max_set(data, -1, minh + vmh);
767 evas_object_size_hint_min_set(data, vmw, vmh);
768 evas_object_size_hint_max_set(data, -1, -1);
775 evas_object_size_hint_min_set(data, minw, minh);
776 evas_object_size_hint_max_set(data, -1, minh);
780 evas_object_size_hint_min_set(data, fw, minh);
781 evas_object_size_hint_max_set(data, -1, -1);
785 if (wd->deferred_cur)
787 Evas_Coord cx, cy, cw, ch;
788 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
792 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
793 wd->cur_changed = EINA_FALSE;
799 _sizing_eval(Evas_Object *obj)
801 Widget_Data *wd = elm_widget_data_get(obj);
802 Evas_Coord minw = -1, minh = -1;
803 Evas_Coord resw, resh;
806 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
809 if ((resw == wd->lastw) && (!wd->changed)) return;
810 wd->changed = EINA_FALSE;
814 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
816 evas_object_resize(wd->scroller, resw, resh);
817 edje_object_size_min_calc
818 (elm_smart_scroller_edje_object_get(wd->scroller),
820 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
821 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
824 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
826 if ((minw > 0) && (vw < minw)) vw = minw;
827 if (minh > vh) vh = minh;
829 if (wd->single_line) h = vmh + minh;
831 evas_object_resize(wd->ent, vw, vh);
832 evas_object_size_hint_min_get(obj, &w, NULL);
833 evas_object_size_hint_min_set(obj, w, h);
835 evas_object_size_hint_max_set(obj, -1, h);
837 evas_object_size_hint_max_set(obj, -1, -1);
841 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
842 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
847 if (!wd->changed) return;
848 wd->changed = EINA_FALSE;
852 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
854 edje_object_size_min_calc(wd->ent, &minw, &minh);
857 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
859 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
861 if ((minw > 0) && (vw < minw)) vw = minw;
862 if (minh > 0) vh = minh;
864 evas_object_resize(wd->ent, vw, vh);
865 edje_object_size_min_calc
866 (elm_smart_scroller_edje_object_get(wd->scroller),
868 if (wd->single_line) h = vmh + minh;
870 evas_object_size_hint_min_get(obj, &w, NULL);
871 evas_object_size_hint_min_set(obj, w, h);
873 evas_object_size_hint_max_set(obj, -1, h);
875 evas_object_size_hint_max_set(obj, -1, -1);
879 edje_object_size_min_calc(wd->ent, &minw, &minh);
882 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
883 evas_object_size_hint_min_set(obj, minw, minh);
885 evas_object_size_hint_max_set(obj, -1, minh);
887 evas_object_size_hint_max_set(obj, -1, -1);
891 _recalc_cursor_geometry(obj);
895 _check_enable_returnkey(Evas_Object *obj)
897 Widget_Data *wd = elm_widget_data_get(obj);
900 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
903 if (!wd->autoreturnkey) return;
905 if (_entry_length_get(obj) == 0)
907 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
911 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
916 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
918 Widget_Data *wd = elm_widget_data_get(obj);
919 Evas_Object *top = elm_widget_top_get(obj);
921 if (!wd->editable) return;
922 if (elm_widget_focus_get(obj))
924 printf("[Elm_entry::Focused] obj : %p\n", obj);
925 evas_object_focus_set(wd->ent, EINA_TRUE);
926 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
927 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
928 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
929 _check_enable_returnkey(obj);
930 wd->mgf_type = _ENTRY_MAGNIFIER_FILLWIDTH;
934 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
935 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
936 evas_object_focus_set(wd->ent, EINA_FALSE);
937 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
938 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
940 if ((wd->api) && (wd->api->obj_hidemenu))
942 wd->api->obj_hidemenu(obj);
948 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
950 Widget_Data *wd = elm_widget_data_get(obj);
952 edje_object_signal_emit(wd->ent, emission, source);
954 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
959 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
961 Widget_Data *wd = elm_widget_data_get(obj);
963 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
965 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
966 emission, source, func_cb, data);
970 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
972 Widget_Data *wd = elm_widget_data_get(obj);
973 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
976 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
977 emission, source, func_cb, data);
981 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
983 Widget_Data *wd = elm_widget_data_get(obj);
984 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
988 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
990 Widget_Data *wd = elm_widget_data_get(obj);
992 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
996 _show_region_hook(void *data, Evas_Object *obj)
998 Widget_Data *wd = elm_widget_data_get(data);
999 Evas_Coord x, y, w, h;
1001 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1003 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1007 _hoversel_position(Evas_Object *obj)
1009 Widget_Data *wd = elm_widget_data_get(obj);
1010 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1015 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1024 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1025 &cx, &cy, &cw, &ch);
1026 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1029 cx += (cw - mw) / 2;
1034 cy += (ch - mh) / 2;
1037 evas_object_move(wd->hoversel, x + cx, y + cy);
1038 evas_object_resize(wd->hoversel, cw, ch);
1042 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1044 Widget_Data *wd = elm_widget_data_get(data);
1046 if (wd->hoversel) _hoversel_position(data);
1050 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1052 Widget_Data *wd = elm_widget_data_get(data);
1059 else if (wd->scroll)
1061 Evas_Coord vw = 0, vh = 0;
1063 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1064 if (vw < wd->entmw) vw = wd->entmw;
1065 if (vh < wd->entmh) vh = wd->entmh;
1066 evas_object_resize(wd->ent, vw, vh);
1068 if (wd->hoversel) _hoversel_position(data);
1072 _hover_del(void *data)
1074 Widget_Data *wd = elm_widget_data_get(data);
1079 evas_object_del(wd->hoversel);
1080 wd->hoversel = NULL;
1082 wd->hovdeljob = NULL;
1086 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1088 Widget_Data *wd = elm_widget_data_get(data);
1091 if (wd->hoversel) evas_object_hide(wd->hoversel);
1094 if (!_elm_config->desktop_entry)
1097 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1100 elm_widget_scroll_freeze_pop(data);
1101 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1102 wd->hovdeljob = ecore_job_add(_hover_del, data);
1106 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1108 Widget_Data *wd = elm_widget_data_get(data);
1110 wd->selmode = EINA_TRUE;
1111 edje_object_part_text_select_none(wd->ent, "elm.text");
1112 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1113 edje_object_part_text_select_all(wd->ent, "elm.text");
1114 elm_object_scroll_freeze_pop(data);
1118 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1120 Widget_Data *wd = elm_widget_data_get(data);
1122 wd->selmode = EINA_TRUE;
1123 edje_object_part_text_select_none(wd->ent, "elm.text");
1124 if (!_elm_config->desktop_entry)
1127 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1129 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1130 if (!_elm_config->desktop_entry)
1131 elm_object_scroll_freeze_pop(data);
1132 //elm_widget_scroll_hold_push(data);
1136 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1138 Widget_Data *wd = elm_widget_data_get(data);
1140 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1141 if (wd->sel_notify_handler)
1143 #ifdef HAVE_ELEMENTARY_X
1144 Elm_Sel_Format formats;
1145 wd->selection_asked = EINA_TRUE;
1146 formats = ELM_SEL_FORMAT_MARKUP;
1148 formats |= ELM_SEL_FORMAT_IMAGE;
1149 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1155 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1157 Widget_Data *wd = elm_widget_data_get(obj);
1161 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1162 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
1163 if (seltype == ELM_SEL_CLIPBOARD)
1164 eina_stringshare_replace(&wd->cut_sel, sel);
1168 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1170 Widget_Data *wd = elm_widget_data_get(data);
1173 wd->selmode = EINA_FALSE;
1174 if (!_elm_config->desktop_entry)
1175 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1176 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1177 if (!_elm_config->desktop_entry)
1178 elm_widget_scroll_hold_pop(data);
1179 _store_selection(ELM_SEL_CLIPBOARD, data);
1180 edje_object_part_text_insert(wd->ent, "elm.text", "");
1181 edje_object_part_text_select_none(wd->ent, "elm.text");
1185 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1187 Widget_Data *wd = elm_widget_data_get(data);
1189 wd->selmode = EINA_FALSE;
1190 if (!_elm_config->desktop_entry)
1192 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1193 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1194 elm_widget_scroll_hold_pop(data);
1196 _store_selection(ELM_SEL_CLIPBOARD, data);
1197 // edje_object_part_text_select_none(wd->ent, "elm.text");
1201 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1203 Widget_Data *wd = elm_widget_data_get(data);
1205 wd->selmode = EINA_FALSE;
1206 if (!_elm_config->desktop_entry)
1207 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1208 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1209 if (!_elm_config->desktop_entry)
1210 elm_widget_scroll_hold_pop(data);
1211 edje_object_part_text_select_none(wd->ent, "elm.text");
1215 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1217 Widget_Data *wd = elm_widget_data_get(data);
1221 #ifdef HAVE_ELEMENTARY_X
1222 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1224 cnpwidgetdata = data;
1225 elm_cbhm_helper_init(obj);
1226 if (elm_entry_cnp_textonly_get(obj))
1227 elm_cbhm_send_raw_data("show0");
1229 elm_cbhm_send_raw_data("show1");
1235 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1237 Widget_Data *wd = elm_widget_data_get(data);
1239 cnpwidgetdata = data;
1245 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1247 Elm_Entry_Context_Menu_Item *it = data;
1248 Evas_Object *obj2 = it->obj;
1249 if (it->func) it->func(it->data, obj2, NULL);
1253 _menu_press(Evas_Object *obj)
1255 Widget_Data *wd = elm_widget_data_get(obj);
1258 const Elm_Entry_Context_Menu_Item *it;
1260 if ((wd->api) && (wd->api->obj_longpress))
1262 wd->api->obj_longpress(obj);
1264 else if (wd->context_menu)
1266 const char *context_menu_orientation;
1268 if (wd->hoversel) evas_object_del(wd->hoversel);
1269 else elm_widget_scroll_freeze_push(obj);
1270 wd->hoversel = elm_hoversel_add(obj);
1271 context_menu_orientation = edje_object_data_get
1272 (wd->ent, "context_menu_orientation");
1273 if ((context_menu_orientation) &&
1274 (!strcmp(context_menu_orientation, "horizontal")))
1275 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1276 elm_object_style_set(wd->hoversel, "entry");
1277 elm_widget_sub_object_add(obj, wd->hoversel);
1278 elm_object_text_set(wd->hoversel, "Text");
1279 top = elm_widget_top_get(obj);
1280 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1281 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1285 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1287 if (1) // need way to detect if someone has a selection
1290 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1294 if ((!wd->password) && (wd->editable))
1295 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1296 _clipboard_menu, obj);
1303 if (wd->have_selection)
1305 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1308 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1311 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1315 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1316 _clipboard_menu, obj);
1320 EINA_LIST_FOREACH(wd->items, l, it)
1322 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1323 it->icon_type, _item_clicked, it);
1327 _hoversel_position(obj);
1328 evas_object_show(wd->hoversel);
1329 elm_hoversel_hover_begin(wd->hoversel);
1331 if (!_elm_config->desktop_entry)
1333 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1334 edje_object_part_text_select_abort(wd->ent, "elm.text");
1340 _magnifier_hide(void *data)
1342 Widget_Data *wd = elm_widget_data_get(data);
1345 evas_object_hide(wd->mgf_bg);
1346 evas_object_hide(wd->mgf_clip);
1349 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1353 _magnifier_show(void *data)
1355 Widget_Data *wd = elm_widget_data_get(data);
1358 evas_object_show(wd->mgf_bg);
1359 evas_object_show(wd->mgf_clip);
1363 _magnifier_move(void *data)
1365 Widget_Data *wd = elm_widget_data_get(data);
1368 Evas_Coord x, y, w, h, fs;
1369 Evas_Coord cx, cy, cw, ch, ox, oy;
1371 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1375 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1376 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1381 evas_object_geometry_get(data, &x, &y, &w, &h);
1384 fs = elm_finger_size_get();
1386 if ((cy + y) - wd->mgf_height - fs < 0)
1387 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1389 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1390 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1391 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1392 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1396 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);
1400 _magnifier_create(void *data)
1402 Widget_Data *wd = elm_widget_data_get(data);
1403 Evas_Coord x, y, w, h, mw, mh;
1404 const char* key_data = NULL;
1410 evas_object_image_source_unset(wd->mgf_proxy);
1411 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1412 evas_object_hide(wd->mgf_proxy);
1413 evas_object_clip_unset(wd->mgf_proxy);
1414 evas_object_del(wd->mgf_proxy);
1416 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1417 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1420 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1422 evas_object_geometry_get(data, &x, &y, &w, &h);
1424 if ((w <= 0) || (h <= 0))
1427 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1429 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1430 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1431 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1432 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1436 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1437 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1438 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1440 key_data = edje_object_data_get(wd->mgf_bg, "height");
1441 if (key_data) wd->mgf_height = atoi(key_data);
1442 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1443 if (key_data) wd->mgf_scale = atof(key_data);
1445 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1446 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1450 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1451 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1452 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1456 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1457 evas_object_image_source_set(wd->mgf_proxy, data);
1460 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1461 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1462 if ((mw <= 0) || (mh <= 0))
1465 evas_object_resize(wd->mgf_proxy, mw, mh);
1466 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1467 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1468 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1469 evas_object_show(wd->mgf_proxy);
1470 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1472 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1473 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1477 _long_press(void *data)
1479 Widget_Data *wd = elm_widget_data_get(data);
1480 if (!wd) return ECORE_CALLBACK_CANCEL;
1482 wd->long_pressed = EINA_TRUE;
1484 if (wd->longpress_timer)
1486 ecore_timer_del(wd->longpress_timer);
1487 wd->longpress_timer = NULL;
1490 _cancel(data, NULL, NULL);
1492 _magnifier_create(data);
1493 _magnifier_move(data);
1494 _magnifier_show(data);
1495 elm_object_scroll_freeze_push(data);
1497 wd->longpress_timer = NULL;
1498 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1499 return ECORE_CALLBACK_CANCEL;
1503 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1505 Widget_Data *wd = elm_widget_data_get(data);
1506 Evas_Event_Mouse_Down *ev = event_info;
1508 if (wd->disabled) return;
1509 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1510 wd->downx = ev->canvas.x;
1511 wd->downy = ev->canvas.y;
1512 wd->long_pressed = EINA_FALSE;
1513 if (ev->button == 1)
1515 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1516 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1521 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1523 Widget_Data *wd = elm_widget_data_get(data);
1524 Evas_Event_Mouse_Up *ev = event_info;
1526 if (wd->disabled) return;
1527 if (ev->button == 1)
1529 if (!wd->double_clicked)
1531 if ((wd->api) && (wd->api->obj_mouseup))
1533 wd->api->obj_mouseup(data);
1537 if (wd->longpress_timer)
1539 ecore_timer_del(wd->longpress_timer);
1540 wd->longpress_timer = NULL;
1543 _magnifier_hide(data);
1544 elm_object_scroll_freeze_pop(data);
1546 if (wd->long_pressed)
1552 else if (ev->button == 3)
1560 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1562 Widget_Data *wd = elm_widget_data_get(data);
1563 Evas_Event_Mouse_Move *ev = event_info;
1565 if (wd->disabled) return;
1568 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1570 if (wd->longpress_timer)
1572 ecore_timer_del(wd->longpress_timer);
1573 wd->longpress_timer = NULL;
1576 else if (wd->longpress_timer)
1580 dx = wd->downx - ev->cur.canvas.x;
1582 dy = wd->downy - ev->cur.canvas.y;
1585 ((_elm_config->finger_size / 2) *
1586 (_elm_config->finger_size / 2)))
1588 ecore_timer_del(wd->longpress_timer);
1589 wd->longpress_timer = NULL;
1593 else if (wd->longpress_timer)
1597 dx = wd->downx - ev->cur.canvas.x;
1599 dy = wd->downy - ev->cur.canvas.y;
1602 ((_elm_config->finger_size / 2) *
1603 (_elm_config->finger_size / 2)))
1605 ecore_timer_del(wd->longpress_timer);
1606 wd->longpress_timer = NULL;
1610 if (ev->buttons == 1)
1612 if (wd->long_pressed)
1614 _magnifier_show(data);
1615 _magnifier_move(data);
1621 _getbase(Evas_Object *obj)
1623 Widget_Data *wd = elm_widget_data_get(obj);
1624 if (!wd) return "base";
1627 if (wd->password) return "base-password";
1630 if (wd->single_line) return "base-single";
1633 switch (wd->linewrap)
1636 return "base-charwrap";
1639 case ELM_WRAP_MIXED:
1640 return "base-mixedwrap";
1643 return "base-nowrap";
1650 if (wd->password) return "base-password";
1653 if (wd->single_line) return "base-single-noedit";
1656 switch (wd->linewrap)
1659 return "base-noedit-charwrap";
1661 return "base-noedit";
1662 case ELM_WRAP_MIXED:
1663 return "base-noedit-mixedwrap";
1666 return "base-nowrap-noedit";
1676 _entry_length_get(Evas_Object *obj)
1679 const char *str = elm_entry_entry_get(obj);
1682 char *plain_str = _elm_util_mkup_to_text(str);
1683 if (!plain_str) return 0;
1685 len = strlen(plain_str);
1692 _matchlist_show(void *data)
1694 Widget_Data *wd = elm_widget_data_get(data);
1695 const char *text = NULL;
1697 char *str_list = NULL, *str_result = NULL;
1698 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1701 Eina_Bool textfound = EINA_FALSE;
1704 if (elm_widget_disabled_get(data)) return;
1706 wd->matchlist_job = NULL;
1708 if (wd->matchlist_list_clicked)
1710 evas_object_hide(wd->hover);
1711 wd->matchlist_list_clicked = EINA_FALSE;
1714 text = elm_entry_entry_get(data);
1717 textlen = strlen(text);
1719 if (textlen < wd->matchlist_threshold)
1721 evas_object_hide(wd->hover);
1725 evas_object_hide(wd->hover);
1729 elm_list_clear(wd->list);
1730 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1732 if (wd->matchlist_case_sensitive)
1733 str_result = strstr(str_list, text);
1735 str_result = strcasestr(str_list, text);
1739 str_mkup = malloc(strlen(str_list) + 16);
1740 if (str_mkup == NULL) return;
1742 textlen = strlen(str_list) - strlen(str_result);
1743 str_front = malloc(textlen + 1);
1744 if (str_front == NULL) return;
1746 memset(str_front, 0, textlen + 1);
1747 strncpy(str_front, str_list, textlen);
1749 textlen = strlen(text);
1750 str_mid = malloc(textlen + 1);
1751 if (str_mid == NULL) return;
1753 memset(str_mid, 0, textlen + 1);
1754 strncpy(str_mid, str_list + strlen(str_front), textlen);
1756 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1758 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1760 if (str_mkup) free(str_mkup);
1761 if (str_front) free(str_front);
1762 if (str_mid) free(str_mid);
1764 textfound=EINA_TRUE;
1773 elm_list_go(wd->list);
1774 evas_object_show(wd->hover);
1775 evas_object_raise(wd->hover);
1779 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1781 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1782 Widget_Data *wd = elm_widget_data_get(data);
1783 if ((it == NULL) || (wd == NULL))
1786 const char *text = elm_list_item_label_get(it);
1787 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1792 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1793 elm_entry_cursor_end_set(data);
1794 wd->matchlist_list_clicked = EINA_TRUE;
1796 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1799 elm_widget_focus_set(data, EINA_TRUE);
1803 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
1805 Widget_Data *wd = elm_widget_data_get(obj);
1810 Evas_Coord max_w = 9999, max_h = 9999;
1811 const char* key_data = NULL;
1813 wd->matchlist_threshold = 1;
1814 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
1815 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
1816 elm_hover_target_set(wd->hover, obj);
1817 elm_object_style_set(wd->hover, "matchlist");
1819 wd->layout = elm_layout_add(wd->hover);
1820 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
1821 wd->list = elm_list_add(wd->layout);
1822 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
1823 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1824 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
1825 elm_object_style_set(wd->list, "matchlist");
1827 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
1828 if (key_data) max_w = atoi(key_data);
1829 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
1830 if (key_data) max_h = atoi(key_data);
1832 elm_list_go(wd->list);
1833 evas_object_size_hint_max_set(wd->list, max_w, max_h);
1834 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
1835 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
1836 elm_hover_content_set(wd->hover, "bottom", wd->layout);
1838 wd->match_list = match_list;
1843 evas_object_del(wd->hover);
1845 wd->match_list = NULL;
1848 wd->matchlist_case_sensitive = case_sensitive;
1852 _entry_changed_common_handling(void *data, const char *event)
1854 Widget_Data *wd = elm_widget_data_get(data);
1855 Evas_Coord minw, minh;
1857 wd->changed = EINA_TRUE;
1858 /* Reset the size hints which are no more relevant.
1859 * Keep the height, this is a hack, but doesn't really matter
1860 * cause we'll re-eval in a moment. */
1863 evas_object_size_hint_min_get(data, &minw, &minh);
1864 evas_object_size_hint_min_set(data, minw, minh);
1868 evas_object_size_hint_min_get(data, NULL, &minh);
1869 evas_object_size_hint_min_set(data, -1, minh);
1873 if (wd->text) eina_stringshare_del(wd->text);
1875 _check_enable_returnkey(data);
1876 evas_object_smart_callback_call(data, event, NULL);
1877 if (wd->delay_write)
1879 ecore_timer_del(wd->delay_write);
1880 wd->delay_write = NULL;
1883 if ((wd->single_line) && (wd->match_list))
1885 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1886 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1888 if ((!wd->autosave) || (!wd->file)) return;
1889 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1893 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1895 _entry_changed_common_handling(data, SIG_CHANGED);
1899 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1901 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1906 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1908 Widget_Data *wd = elm_widget_data_get(data);
1909 elm_object_scroll_freeze_push(data);
1911 if ((wd->api) && (wd->api->obj_hidemenu))
1913 wd->api->obj_hidemenu(data);
1916 _magnifier_create(data);
1917 _magnifier_move(data);
1918 _magnifier_show(data);
1922 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1924 Widget_Data *wd = elm_widget_data_get(data);
1925 elm_object_scroll_freeze_pop(data);
1927 if (wd->have_selection)
1929 _magnifier_hide(data);
1935 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1937 _magnifier_move(data);
1938 _magnifier_show(data);
1942 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1944 _magnifier_hide(data);
1949 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1951 Widget_Data *wd = elm_widget_data_get(data);
1955 EINA_LIST_FOREACH(entries, l, entry)
1957 if (entry != data) elm_entry_select_none(entry);
1959 wd->have_selection = EINA_TRUE;
1960 wd->selmode = EINA_TRUE;
1961 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1962 #ifdef HAVE_ELEMENTARY_X
1963 if (wd->sel_notify_handler)
1965 const char *txt = elm_entry_selection_get(data);
1968 top = elm_widget_top_get(data);
1969 if ((top) && (elm_win_xwindow_get(top)))
1970 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1976 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1978 Evas_Coord cx, cy, cw, ch;
1979 Widget_Data *wd = elm_widget_data_get(data);
1982 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1983 if (!wd->deferred_recalc_job)
1984 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1987 wd->deferred_cur = EINA_TRUE;
1991 wd->ch = ch + elm_finger_size_get();
1996 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1998 Evas_Coord cx, cy, cw, ch;
1999 Widget_Data *wd = elm_widget_data_get(data);
2001 wd->have_selection = EINA_TRUE;
2002 wd->selmode = EINA_TRUE;
2003 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2004 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
2005 elm_entry_selection_get(data));
2007 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2008 if (!wd->deferred_recalc_job)
2009 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE);
2012 wd->deferred_cur = EINA_TRUE;
2016 wd->ch = ch + elm_finger_size_get();
2021 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2023 Widget_Data *wd = elm_widget_data_get(data);
2025 if (!wd->have_selection) return;
2026 wd->have_selection = EINA_FALSE;
2027 wd->selmode = EINA_FALSE;
2028 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2029 if (wd->sel_notify_handler)
2033 #ifdef HAVE_ELEMENTARY_X
2036 top = elm_widget_top_get(data);
2037 if ((top) && (elm_win_xwindow_get(top)))
2038 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2041 eina_stringshare_del(wd->cut_sel);
2046 #ifdef HAVE_ELEMENTARY_X
2049 top = elm_widget_top_get(data);
2050 if ((top) && (elm_win_xwindow_get(top)))
2051 elm_selection_clear(ELM_SEL_PRIMARY, data);
2056 if ((wd->api) && (wd->api->obj_hidemenu))
2058 wd->api->obj_hidemenu(data);
2063 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2065 Widget_Data *wd = elm_widget_data_get(data);
2067 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2068 if (wd->sel_notify_handler)
2070 #ifdef HAVE_ELEMENTARY_X
2073 top = elm_widget_top_get(data);
2074 if ((top) && (elm_win_xwindow_get(top)))
2076 wd->selection_asked = EINA_TRUE;
2077 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2085 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2087 Widget_Data *wd = elm_widget_data_get(data);
2089 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2090 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2091 elm_entry_selection_get(data));
2095 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2097 Widget_Data *wd = elm_widget_data_get(data);
2099 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2100 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2101 elm_entry_selection_get(data));
2102 edje_object_part_text_insert(wd->ent, "elm.text", "");
2103 wd->changed = EINA_TRUE;
2108 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2110 Widget_Data *wd = elm_widget_data_get(data);
2112 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2113 wd->cur_changed = EINA_TRUE;
2114 _recalc_cursor_geometry(data);
2118 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2120 Widget_Data *wd = elm_widget_data_get(data);
2125 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2127 Widget_Data *wd = elm_widget_data_get(data);
2132 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2134 Widget_Data *wd = elm_widget_data_get(data);
2135 Elm_Entry_Anchor_Info ei;
2136 char *buf2, *p, *p2, *n;
2138 p = strrchr(emission, ',');
2141 const Eina_List *geoms;
2145 while (p2 >= emission)
2147 if (*p2 == ',') break;
2151 buf2 = alloca(5 + p - p2);
2152 strncpy(buf2, p2, p - p2);
2155 ei.button = atoi(buf2);
2156 ei.x = ei.y = ei.w = ei.h = 0;
2158 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2161 Evas_Textblock_Rectangle *r;
2163 Evas_Coord px, py, x, y;
2165 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2166 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2167 EINA_LIST_FOREACH(geoms, l, r)
2169 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2170 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2181 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2186 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2188 Widget_Data *wd = elm_widget_data_get(data);
2193 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2195 Widget_Data *wd = elm_widget_data_get(data);
2200 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2202 Widget_Data *wd = elm_widget_data_get(data);
2207 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2209 Widget_Data *wd = elm_widget_data_get(data);
2211 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2215 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2217 Widget_Data *wd = elm_widget_data_get(data);
2219 wd->double_clicked = EINA_FALSE;
2220 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2222 if ((wd->api) && (wd->api->obj_hidemenu))
2224 wd->api->obj_hidemenu(data);
2229 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2231 Widget_Data *wd = elm_widget_data_get(data);
2233 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2237 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2239 Widget_Data *wd = elm_widget_data_get(data);
2241 wd->double_clicked = EINA_TRUE;
2242 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2245 #ifdef HAVE_ELEMENTARY_X
2247 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2249 Widget_Data *wd = elm_widget_data_get(data);
2250 Ecore_X_Event_Selection_Notify *ev = event;
2251 if (!wd) return ECORE_CALLBACK_PASS_ON;
2252 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2253 return ECORE_CALLBACK_PASS_ON;
2255 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2256 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2258 Ecore_X_Selection_Data_Text *text_data;
2260 text_data = ev->data;
2261 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2263 if (text_data->text)
2265 char *txt = _elm_util_text_to_mkup(text_data->text);
2269 elm_entry_entry_insert(data, txt);
2274 wd->selection_asked = EINA_FALSE;
2276 else if (ev->selection == ECORE_X_SELECTION_XDND)
2278 Ecore_X_Selection_Data_Text *text_data;
2280 text_data = ev->data;
2281 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2283 if (text_data->text)
2285 char *txt = _elm_util_text_to_mkup(text_data->text);
2289 /* Massive FIXME: this should be at the drag point */
2290 elm_entry_entry_insert(data, txt);
2295 wd->drag_selection_asked = EINA_FALSE;
2297 ecore_x_dnd_send_finished();
2300 return ECORE_CALLBACK_PASS_ON;
2304 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2307 Widget_Data *wd = elm_widget_data_get(data);
2308 Ecore_X_Event_Selection_Clear *ev = event;
2309 if (!wd) return ECORE_CALLBACK_PASS_ON;
2310 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2311 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2312 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2314 elm_entry_select_none(data);
2319 Evas_Object *top = elm_widget_top_get(data);
2320 Ecore_X_Event_Selection_Clear *ev = event;
2323 return ECORE_CALLBACK_PASS_ON;
2325 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2327 return ECORE_CALLBACK_PASS_ON;
2330 if (cnpwidgetdata == data)
2332 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2336 return ECORE_CALLBACK_PASS_ON;
2340 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2345 wd = elm_widget_data_get(obj);
2346 if (!wd) return EINA_FALSE;
2347 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2349 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2350 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2351 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2352 EDJE_CURSOR_MAIN,drop->x,drop->y);
2353 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2354 elm_entry_entry_insert(obj, drop->data);
2355 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2356 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2362 static Evas_Object *
2363 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2365 Widget_Data *wd = elm_widget_data_get(data);
2368 Elm_Entry_Item_Provider *ip;
2370 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2372 o = ip->func(ip->data, data, item);
2375 if (!strncmp(item, "file://", 7))
2377 const char *fname = item + 7;
2379 o = evas_object_image_filled_add(evas_object_evas_get(data));
2380 evas_object_image_file_set(o, fname, NULL);
2381 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2383 evas_object_show(o);
2388 o = edje_object_add(evas_object_evas_get(data));
2389 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2393 o = edje_object_add(evas_object_evas_get(data));
2394 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2395 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2400 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2402 const char *srcstring = NULL;
2403 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2404 char *curlocater, *replocater;
2405 char *starttag, *endtag;
2406 int tagtxtlen = 0, insertflag = 0;
2408 srcstring = eina_strbuf_string_get(srcbuf);
2409 curlocater = strstr(srcstring, key);
2411 if (!curlocater || !srcstring)
2419 starttag = strchr(srcstring, '<');
2420 endtag = strchr(srcstring, '>');
2421 tagtxtlen = endtag - starttag;
2422 if (tagtxtlen <= 0) tagtxtlen = 0;
2423 if (starttag < curlocater && curlocater < endtag) break;
2424 if (endtag != NULL && endtag+1 != NULL)
2425 srcstring = endtag+1;
2428 } while (strlen(srcstring) > 1);
2430 if (starttag && endtag && tagtxtlen > strlen(key))
2432 repbuf = eina_strbuf_new();
2433 diffbuf = eina_strbuf_new();
2434 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2435 srcstring = eina_strbuf_string_get(repbuf);
2436 curlocater = strstr(srcstring, key);
2438 if (curlocater != NULL)
2440 replocater = curlocater + strlen(key) + 1;
2442 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2445 if (replocater-curlocater > strlen(key)+1)
2447 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2456 eina_strbuf_reset(repbuf);
2464 if (repbuf == NULL) repbuf = eina_strbuf_new();
2465 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2469 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2470 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2476 eina_strbuf_prepend(diffbuf, "<");
2477 eina_strbuf_append(diffbuf, ">");
2478 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2482 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2483 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2487 if (repbuf) eina_strbuf_free(repbuf);
2488 if (diffbuf) eina_strbuf_free(diffbuf);
2494 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2496 Eina_Strbuf *sharebuf = NULL;
2498 sharebuf = eina_strbuf_new();
2499 eina_strbuf_append(sharebuf, *srcstring);
2500 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2501 eina_stringshare_del(*srcstring);
2502 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2503 eina_strbuf_free(sharebuf);
2509 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2511 Widget_Data *wd = elm_widget_data_get(data);
2513 Elm_Entry_Text_Filter *tf;
2515 if (type == EDJE_TEXT_FILTER_FORMAT)
2518 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2520 tf->func(tf->data, data, text);
2526 /* This function is used to insert text by chunks in jobs */
2528 _text_append_idler(void *data)
2532 Evas_Object *obj = (Evas_Object *) data;
2533 Widget_Data *wd = elm_widget_data_get(obj);
2534 if (wd->text) eina_stringshare_del(wd->text);
2536 wd->changed = EINA_TRUE;
2538 start = wd->append_text_position;
2539 if(start + _CHUNK_SIZE < wd->append_text_len)
2541 wd->append_text_position = (start + _CHUNK_SIZE);
2542 /* Go to the start of the nearest codepoint, because we don't want
2543 * to cut it in the middle */
2544 eina_unicode_utf8_get_prev(wd->append_text_left,
2545 &wd->append_text_position);
2549 wd->append_text_position = wd->append_text_len;
2552 backup = wd->append_text_left[wd->append_text_position];
2553 wd->append_text_left[wd->append_text_position] = '\0';
2555 edje_object_part_text_append(wd->ent, "elm.text",
2556 wd->append_text_left + start);
2558 wd->append_text_left[wd->append_text_position] = backup;
2560 /* If there's still more to go, renew the idler, else, cleanup */
2561 if (wd->append_text_position < wd->append_text_len)
2563 return ECORE_CALLBACK_RENEW;
2567 free(wd->append_text_left);
2568 wd->append_text_left = NULL;
2569 wd->append_text_idler = NULL;
2570 return ECORE_CALLBACK_CANCEL;
2575 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2577 int i = 0, unit_size;
2578 int current_len = strlen(*text);
2579 char *new_text = *text;
2580 if (unit >= LENGTH_UNIT_LAST) return;
2583 if (*new_text == '<')
2585 while (*new_text != '>')
2588 if (!*new_text) break;
2595 if (*new_text == '&')
2597 while (*(new_text + index) != ';')
2600 if (!*(new_text + index)) break;
2604 index = evas_string_char_next_get(new_text, index, NULL);
2605 markup = malloc(index + 1);
2606 strncpy(markup, new_text, index);
2608 if (unit == LENGTH_UNIT_BYTE)
2609 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2610 else if (unit == LENGTH_UNIT_CHAR)
2611 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2617 if (can_add < unit_size)
2621 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2627 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2628 current_len -= index;
2629 (*text)[current_len] = 0;
2634 can_add -= unit_size;
2639 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2643 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2646 ELM_CHECK_WIDTYPE(obj, widtype);
2647 if (item && strcmp(item, "default")) return;
2648 Widget_Data *wd = elm_widget_data_get(obj);
2650 if (!entry) entry = "";
2651 if (wd->text) eina_stringshare_del(wd->text);
2653 wd->changed = EINA_TRUE;
2655 /* Clear currently pending job if there is one */
2656 if (wd->append_text_idler)
2658 ecore_idler_del(wd->append_text_idler);
2659 free(wd->append_text_left);
2660 wd->append_text_left = NULL;
2661 wd->append_text_idler = NULL;
2664 len = strlen(entry);
2665 /* Split to ~_CHUNK_SIZE chunks */
2666 if (len > _CHUNK_SIZE)
2668 wd->append_text_left = (char *) malloc(len + 1);
2671 /* If we decided to use the idler */
2672 if (wd->append_text_left)
2674 /* Need to clear the entry first */
2675 edje_object_part_text_set(wd->ent, "elm.text", "");
2676 memcpy(wd->append_text_left, entry, len + 1);
2677 wd->append_text_position = 0;
2678 wd->append_text_len = len;
2679 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2683 edje_object_part_text_set(wd->ent, "elm.text", entry);
2688 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2690 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2691 Widget_Data *wd = elm_widget_data_get(obj);
2692 if (item && strcmp(item, "default")) return NULL;
2694 if (!wd) return NULL;
2698 return elm_entry_markup_to_utf8(wd->text);
2702 text = edje_object_part_text_get(wd->ent, "elm.text");
2705 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2708 eina_stringshare_replace(&wd->text, text);
2709 if (wd->password) return elm_entry_markup_to_utf8(wd->text);
2714 * This adds an entry to @p parent object.
2716 * @param parent The parent object
2717 * @return The new object or NULL if it cannot be created
2722 elm_entry_add(Evas_Object *parent)
2724 Evas_Object *obj, *top;
2728 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2730 ELM_SET_WIDTYPE(widtype, "entry");
2731 elm_widget_type_set(obj, "entry");
2732 elm_widget_sub_object_add(parent, obj);
2733 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2734 elm_widget_data_set(obj, wd);
2735 elm_widget_del_hook_set(obj, _del_hook);
2736 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2737 elm_widget_theme_hook_set(obj, _theme_hook);
2738 elm_widget_disable_hook_set(obj, _disable_hook);
2739 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2740 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2741 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2742 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2743 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2744 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2745 elm_widget_can_focus_set(obj, EINA_TRUE);
2746 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2747 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2748 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2750 wd->scroller = elm_smart_scroller_add(e);
2751 elm_widget_sub_object_add(obj, wd->scroller);
2752 elm_smart_scroller_widget_set(wd->scroller, obj);
2753 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2754 elm_widget_style_get(obj));
2755 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2756 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2757 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2758 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2760 wd->linewrap = ELM_WRAP_WORD;
2761 wd->editable = EINA_TRUE;
2762 wd->disabled = EINA_FALSE;
2763 wd->context_menu = EINA_TRUE;
2764 wd->autosave = EINA_TRUE;
2765 wd->textonly = EINA_FALSE;
2766 wd->autoperiod = EINA_TRUE;
2768 wd->ent = edje_object_add(e);
2769 elm_widget_sub_object_add(obj, wd->ent);
2770 edje_object_item_provider_set(wd->ent, _get_item, obj);
2771 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2772 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2773 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2775 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2777 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2779 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2781 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2782 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2783 _signal_entry_changed, obj);
2784 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2785 _signal_preedit_changed, obj);
2786 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2787 _signal_handler_move_start, obj);
2788 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2789 _signal_handler_move_end, obj);
2790 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2791 _signal_handler_moving, obj);
2792 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2793 _signal_selection_start, obj);
2794 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2795 _signal_selection_end, obj);
2796 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2797 _signal_magnifier_changed, obj);
2798 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2799 _signal_selection_changed, obj);
2800 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2801 _signal_selection_cleared, obj);
2802 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2803 _signal_entry_paste_request, obj);
2804 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2805 _signal_entry_copy_notify, obj);
2806 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2807 _signal_entry_cut_notify, obj);
2808 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2809 _signal_cursor_changed, obj);
2810 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2811 _signal_anchor_down, obj);
2812 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2813 _signal_anchor_up, obj);
2814 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2815 _signal_anchor_clicked, obj);
2816 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2817 _signal_anchor_move, obj);
2818 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2819 _signal_anchor_in, obj);
2820 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2821 _signal_anchor_out, obj);
2822 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2823 _signal_key_enter, obj);
2824 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2825 _signal_mouse_down, obj);
2826 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2827 _signal_mouse_clicked, obj);
2828 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2829 _signal_mouse_double, obj);
2830 edje_object_part_text_set(wd->ent, "elm.text", "");
2831 if (_elm_config->desktop_entry)
2832 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2833 elm_widget_resize_object_set(obj, wd->ent);
2836 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2838 #ifdef HAVE_ELEMENTARY_X
2839 top = elm_widget_top_get(obj);
2840 if ((top) && (elm_win_xwindow_get(top)))
2842 wd->sel_notify_handler =
2843 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2844 _event_selection_notify, obj);
2845 wd->sel_clear_handler =
2846 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2847 _event_selection_clear, obj);
2850 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2851 _drag_drop_cb, NULL);
2854 entries = eina_list_prepend(entries, obj);
2856 // module - find module for entry
2857 wd->api = _module(obj);
2858 // if found - hook in
2859 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2861 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2862 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2863 // TODO: and save some bytes, making descriptions per-class and not instance!
2864 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2868 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2870 ELM_CHECK_WIDTYPE(obj, widtype);
2871 Widget_Data *wd = elm_widget_data_get(obj);
2873 ext_mod->cancel = _cancel;
2874 ext_mod->copy = _copy;
2875 ext_mod->cut = _cut;
2876 ext_mod->paste = _paste;
2877 ext_mod->select = _select;
2878 ext_mod->selectall = _selectall;
2879 ext_mod->ent = wd->ent;
2880 ext_mod->items = wd->items;
2881 ext_mod->longpress_timer = wd->longpress_timer;
2882 ext_mod->editable = wd->editable;
2883 ext_mod->have_selection = wd->have_selection;
2884 ext_mod->password = wd->password;
2885 ext_mod->selmode = wd->selmode;
2886 ext_mod->cnpinit = _cnpinit;
2887 ext_mod->context_menu = wd->context_menu;
2888 ext_mod->textonly = wd->textonly;
2892 * This sets the entry object not to line wrap. All input will
2893 * be on a single line, and the entry box will extend with user input.
2895 * @param obj The entry object
2896 * @param single_line If true, the text in the entry
2897 * will be on a single line.
2902 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2904 ELM_CHECK_WIDTYPE(obj, widtype);
2905 Widget_Data *wd = elm_widget_data_get(obj);
2907 if (wd->single_line == single_line) return;
2908 wd->single_line = single_line;
2909 wd->linewrap = ELM_WRAP_NONE;
2910 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2914 if (wd->single_line)
2916 elm_smart_scroller_policy_set(wd->scroller,
2917 ELM_SMART_SCROLLER_POLICY_OFF,
2918 ELM_SMART_SCROLLER_POLICY_OFF);
2919 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2923 const Elm_Scroller_Policy map[3] =
2925 ELM_SMART_SCROLLER_POLICY_AUTO,
2926 ELM_SMART_SCROLLER_POLICY_ON,
2927 ELM_SMART_SCROLLER_POLICY_OFF
2929 elm_smart_scroller_policy_set(wd->scroller,
2932 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2939 * This returns true if the entry has been set to single line mode.
2940 * See also elm_entry_single_line_set().
2942 * @param obj The entry object
2943 * @return single_line If true, the text in the entry is set to display
2949 elm_entry_single_line_get(const Evas_Object *obj)
2951 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2952 Widget_Data *wd = elm_widget_data_get(obj);
2953 if (!wd) return EINA_FALSE;
2954 return wd->single_line;
2958 * This sets the entry object to password mode. All text entered
2959 * and/or displayed within the widget will be replaced with asterisks (*).
2961 * @param obj The entry object
2962 * @param password If true, password mode is enabled.
2967 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2969 ELM_CHECK_WIDTYPE(obj, widtype);
2970 Widget_Data *wd = elm_widget_data_get(obj);
2972 if (wd->password == password) return;
2973 wd->password = password;
2974 wd->single_line = EINA_TRUE;
2975 wd->linewrap = ELM_WRAP_NONE;
2980 * This returns whether password mode is enabled.
2981 * See also elm_entry_password_set().
2983 * @param obj The entry object
2984 * @return If true, the entry is set to display all characters
2990 elm_entry_password_get(const Evas_Object *obj)
2992 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2993 Widget_Data *wd = elm_widget_data_get(obj);
2994 if (!wd) return EINA_FALSE;
2995 return wd->password;
2999 * This sets the text displayed within the entry to @p entry.
3001 * @param obj The entry object
3002 * @param entry The text to be displayed
3007 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3009 _elm_entry_text_set(obj, NULL, entry);
3013 * This appends @p entry to the text of the entry.
3015 * @param obj The entry object
3016 * @param entry The text to be displayed
3021 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3024 ELM_CHECK_WIDTYPE(obj, widtype);
3025 Widget_Data *wd = elm_widget_data_get(obj);
3027 if (!entry) entry = "";
3028 wd->changed = EINA_TRUE;
3030 len = strlen(entry);
3031 if (wd->append_text_left)
3034 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3040 wd->append_text_left = tmpbuf;
3041 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3042 wd->append_text_len += len;
3046 /* FIXME: Add chunked appending here (like in entry_set) */
3047 edje_object_part_text_append(wd->ent, "elm.text", entry);
3052 * This returns the text currently shown in object @p entry.
3053 * See also elm_entry_entry_set().
3055 * @param obj The entry object
3056 * @return The currently displayed text or NULL on failure
3061 elm_entry_entry_get(const Evas_Object *obj)
3063 return _elm_entry_text_get(obj, NULL);
3067 * This returns EINA_TRUE if the entry is empty/there was an error
3068 * and EINA_FALSE if it is not empty.
3070 * @param obj The entry object
3071 * @return If the entry is empty or not.
3076 elm_entry_is_empty(const Evas_Object *obj)
3078 /* FIXME: until there's support for that in textblock, we just check
3079 * to see if the there is text or not. */
3080 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3081 Widget_Data *wd = elm_widget_data_get(obj);
3082 const Evas_Object *tb;
3083 //Evas_Textblock_Cursor *cur;
3085 if (!wd) return EINA_TRUE;
3088 /* It's a hack until we get the support suggested above.
3089 * We just create a cursor, point it to the begining, and then
3090 * try to advance it, if it can advance, the tb is not empty,
3091 * otherwise it is. */
3092 tb = edje_object_part_object_get(wd->ent, "elm.text");
3093 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3094 actually, ok for the time being, thsese hackish stuff will be removed
3095 once evas 1.0 is out*/
3096 evas_textblock_cursor_pos_set(cur, 0);
3097 ret = evas_textblock_cursor_char_next(cur);
3098 evas_textblock_cursor_free(cur);
3103 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3104 if (!str) return EINA_TRUE;
3106 ret = (strlen(str) == 0);
3112 * This returns all selected text within the entry.
3114 * @param obj The entry object
3115 * @return The selected text within the entry or NULL on failure
3120 elm_entry_selection_get(const Evas_Object *obj)
3122 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3123 Widget_Data *wd = elm_widget_data_get(obj);
3124 if (!wd) return NULL;
3125 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3129 * This inserts text in @p entry where the current cursor position.
3131 * This inserts text at the cursor position is as if it was typed
3132 * by the user (note this also allows markup which a user
3133 * can't just "type" as it would be converted to escaped text, so this
3134 * call can be used to insert things like emoticon items or bold push/pop
3135 * tags, other font and color change tags etc.)
3137 * @param obj The entry object
3138 * @param entry The text to insert
3143 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3145 ELM_CHECK_WIDTYPE(obj, widtype);
3146 Widget_Data *wd = elm_widget_data_get(obj);
3148 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3150 #ifdef HAVE_ELEMENTARY_X
3151 if (cnpwidgetdata == obj)
3152 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3155 wd->changed = EINA_TRUE;
3160 * This enables word line wrapping in the entry object. It is the opposite
3161 * of elm_entry_single_line_set(). Additionally, setting this disables
3162 * character line wrapping.
3164 * @param obj The entry object
3165 * @param wrap If true, the entry will be wrapped once it reaches the end
3166 * of the object. Wrapping will occur at the end of the word before the end of the
3172 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3174 ELM_CHECK_WIDTYPE(obj, widtype);
3175 Widget_Data *wd = elm_widget_data_get(obj);
3177 if (wd->linewrap == wrap) return;
3179 wd->linewrap = wrap;
3184 * Set wrap width of the entry
3186 * @param obj The entry object
3187 * @param w The wrap width in pixels at a minimum where words need to wrap
3191 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
3193 Widget_Data *wd = elm_widget_data_get(obj);
3194 if (wd->wrap_w == w) return;
3200 * get wrap width of the entry
3202 * @param obj The entry object
3203 * @return The wrap width in pixels at a minimum where words need to wrap
3207 elm_entry_wrap_width_get(const Evas_Object *obj)
3209 Widget_Data *wd = elm_widget_data_get(obj);
3214 * Get the wrapping behavior of the entry.
3215 * See also elm_entry_line_wrap_set().
3217 * @param obj The entry object
3223 elm_entry_line_wrap_get(const Evas_Object *obj)
3225 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3226 Widget_Data *wd = elm_widget_data_get(obj);
3227 if (!wd) return EINA_FALSE;
3228 return wd->linewrap;
3232 * This sets the editable attribute of the entry.
3234 * @param obj The entry object
3235 * @param editable If true, the entry will be editable by the user.
3236 * If false, it will be set to the disabled state.
3241 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3243 ELM_CHECK_WIDTYPE(obj, widtype);
3244 Widget_Data *wd = elm_widget_data_get(obj);
3246 if (wd->editable == editable) return;
3247 wd->editable = editable;
3250 #ifdef HAVE_ELEMENTARY_X
3252 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3254 elm_drop_target_del(obj);
3259 * This gets the editable attribute of the entry.
3260 * See also elm_entry_editable_set().
3262 * @param obj The entry object
3263 * @return If true, the entry is editable by the user.
3264 * If false, it is not editable by the user
3269 elm_entry_editable_get(const Evas_Object *obj)
3271 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3272 Widget_Data *wd = elm_widget_data_get(obj);
3273 if (!wd) return EINA_FALSE;
3274 return wd->editable;
3278 * This drops any existing text selection within the entry.
3280 * @param obj The entry object
3285 elm_entry_select_none(Evas_Object *obj)
3287 ELM_CHECK_WIDTYPE(obj, widtype);
3288 Widget_Data *wd = elm_widget_data_get(obj);
3292 wd->selmode = EINA_FALSE;
3293 if (!_elm_config->desktop_entry)
3294 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3295 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3297 wd->have_selection = EINA_FALSE;
3298 edje_object_part_text_select_none(wd->ent, "elm.text");
3302 * This selects all text within the entry.
3304 * @param obj The entry object
3309 elm_entry_select_all(Evas_Object *obj)
3311 ELM_CHECK_WIDTYPE(obj, widtype);
3312 Widget_Data *wd = elm_widget_data_get(obj);
3316 wd->selmode = EINA_FALSE;
3317 if (!_elm_config->desktop_entry)
3318 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3319 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3321 wd->have_selection = EINA_TRUE;
3322 edje_object_part_text_select_all(wd->ent, "elm.text");
3326 * This function returns the geometry of the cursor.
3328 * It's useful if you want to draw something on the cursor (or where it is),
3329 * or for example in the case of scrolled entry where you want to show the
3332 * @param obj The entry object
3333 * @param x returned geometry
3334 * @param y returned geometry
3335 * @param w returned geometry
3336 * @param h returned geometry
3337 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3342 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3344 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3345 Widget_Data *wd = elm_widget_data_get(obj);
3346 if (!wd) return EINA_FALSE;
3347 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3352 * This moves the cursor one place to the right within the entry.
3354 * @param obj The entry object
3355 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3360 elm_entry_cursor_next(Evas_Object *obj)
3362 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3363 Widget_Data *wd = elm_widget_data_get(obj);
3364 if (!wd) return EINA_FALSE;
3365 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3369 * This moves the cursor one place to the left within the entry.
3371 * @param obj The entry object
3372 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3377 elm_entry_cursor_prev(Evas_Object *obj)
3379 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3380 Widget_Data *wd = elm_widget_data_get(obj);
3381 if (!wd) return EINA_FALSE;
3382 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3386 * This moves the cursor one line up within the entry.
3388 * @param obj The entry object
3389 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3394 elm_entry_cursor_up(Evas_Object *obj)
3396 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3397 Widget_Data *wd = elm_widget_data_get(obj);
3398 if (!wd) return EINA_FALSE;
3399 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3403 * This moves the cursor one line down within the entry.
3405 * @param obj The entry object
3406 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3411 elm_entry_cursor_down(Evas_Object *obj)
3413 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3414 Widget_Data *wd = elm_widget_data_get(obj);
3415 if (!wd) return EINA_FALSE;
3416 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3420 * This moves the cursor to the beginning of the entry.
3422 * @param obj The entry object
3427 elm_entry_cursor_begin_set(Evas_Object *obj)
3429 ELM_CHECK_WIDTYPE(obj, widtype);
3430 Widget_Data *wd = elm_widget_data_get(obj);
3432 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3436 * This moves the cursor to the end of the entry.
3438 * @param obj The entry object
3443 elm_entry_cursor_end_set(Evas_Object *obj)
3445 ELM_CHECK_WIDTYPE(obj, widtype);
3446 Widget_Data *wd = elm_widget_data_get(obj);
3449 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3452 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3453 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3458 * This moves the cursor to the beginning of the current line.
3460 * @param obj The entry object
3465 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3467 ELM_CHECK_WIDTYPE(obj, widtype);
3468 Widget_Data *wd = elm_widget_data_get(obj);
3470 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3474 * This moves the cursor to the end of the current line.
3476 * @param obj The entry object
3481 elm_entry_cursor_line_end_set(Evas_Object *obj)
3483 ELM_CHECK_WIDTYPE(obj, widtype);
3484 Widget_Data *wd = elm_widget_data_get(obj);
3486 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3490 * This begins a selection within the entry as though
3491 * the user were holding down the mouse button to make a selection.
3493 * @param obj The entry object
3498 elm_entry_cursor_selection_begin(Evas_Object *obj)
3500 ELM_CHECK_WIDTYPE(obj, widtype);
3501 Widget_Data *wd = elm_widget_data_get(obj);
3503 edje_object_part_text_select_begin(wd->ent, "elm.text");
3507 * This ends a selection within the entry as though
3508 * the user had just released the mouse button while making a selection.
3510 * @param obj The entry object
3515 elm_entry_cursor_selection_end(Evas_Object *obj)
3517 ELM_CHECK_WIDTYPE(obj, widtype);
3518 Widget_Data *wd = elm_widget_data_get(obj);
3520 edje_object_part_text_select_extend(wd->ent, "elm.text");
3524 * TODO: fill this in
3526 * @param obj The entry object
3527 * @return TODO: fill this in
3532 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3534 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3535 Widget_Data *wd = elm_widget_data_get(obj);
3536 if (!wd) return EINA_FALSE;
3537 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3541 * This returns whether the cursor is visible.
3543 * @param obj The entry object
3544 * @return If true, the cursor is visible.
3549 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3551 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3552 Widget_Data *wd = elm_widget_data_get(obj);
3553 if (!wd) return EINA_FALSE;
3554 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3558 * TODO: fill this in
3560 * @param obj The entry object
3561 * @return TODO: fill this in
3566 elm_entry_cursor_content_get(const Evas_Object *obj)
3568 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3569 Widget_Data *wd = elm_widget_data_get(obj);
3570 if (!wd) return NULL;
3571 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3575 * Sets the cursor position in the entry to the given value
3577 * @param obj The entry object
3578 * @param pos The position of the cursor
3583 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3585 ELM_CHECK_WIDTYPE(obj, widtype);
3586 Widget_Data *wd = elm_widget_data_get(obj);
3588 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3589 edje_object_message_signal_process(wd->ent);
3593 * Retrieves the current position of the cursor in the entry
3595 * @param obj The entry object
3596 * @return The cursor position
3601 elm_entry_cursor_pos_get(const Evas_Object *obj)
3603 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3604 Widget_Data *wd = elm_widget_data_get(obj);
3606 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3610 * This executes a "cut" action on the selected text in the entry.
3612 * @param obj The entry object
3617 elm_entry_selection_cut(Evas_Object *obj)
3619 ELM_CHECK_WIDTYPE(obj, widtype);
3620 Widget_Data *wd = elm_widget_data_get(obj);
3622 _cut(obj, NULL, NULL);
3626 * This executes a "copy" action on the selected text in the entry.
3628 * @param obj The entry object
3633 elm_entry_selection_copy(Evas_Object *obj)
3635 ELM_CHECK_WIDTYPE(obj, widtype);
3636 Widget_Data *wd = elm_widget_data_get(obj);
3638 _copy(obj, NULL, NULL);
3642 * This executes a "paste" action in the entry.
3644 * @param obj The entry object
3649 elm_entry_selection_paste(Evas_Object *obj)
3651 ELM_CHECK_WIDTYPE(obj, widtype);
3652 Widget_Data *wd = elm_widget_data_get(obj);
3654 _paste(obj, NULL, NULL);
3658 * This clears and frees the items in a entry's contextual (right click) menu.
3660 * @param obj The entry object
3665 elm_entry_context_menu_clear(Evas_Object *obj)
3667 ELM_CHECK_WIDTYPE(obj, widtype);
3668 Widget_Data *wd = elm_widget_data_get(obj);
3669 Elm_Entry_Context_Menu_Item *it;
3671 EINA_LIST_FREE(wd->items, it)
3673 eina_stringshare_del(it->label);
3674 eina_stringshare_del(it->icon_file);
3675 eina_stringshare_del(it->icon_group);
3681 * This adds an item to the entry's contextual menu.
3683 * @param obj The entry object
3684 * @param label The item's text label
3685 * @param icon_file The item's icon file
3686 * @param icon_type The item's icon type
3687 * @param func The callback to execute when the item is clicked
3688 * @param data The data to associate with the item for related functions
3693 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)
3695 ELM_CHECK_WIDTYPE(obj, widtype);
3696 Widget_Data *wd = elm_widget_data_get(obj);
3697 Elm_Entry_Context_Menu_Item *it;
3699 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3701 wd->items = eina_list_append(wd->items, it);
3703 it->label = eina_stringshare_add(label);
3704 it->icon_file = eina_stringshare_add(icon_file);
3705 it->icon_type = icon_type;
3707 it->data = (void *)data;
3711 * This disables the entry's contextual (right click) menu.
3713 * @param obj The entry object
3714 * @param disabled If true, the menu is disabled
3719 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3721 ELM_CHECK_WIDTYPE(obj, widtype);
3722 Widget_Data *wd = elm_widget_data_get(obj);
3724 if (wd->context_menu == !disabled) return;
3725 wd->context_menu = !disabled;
3729 * This returns whether the entry's contextual (right click) menu is disabled.
3731 * @param obj The entry object
3732 * @return If true, the menu is disabled
3737 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3739 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3740 Widget_Data *wd = elm_widget_data_get(obj);
3741 if (!wd) return EINA_FALSE;
3742 return !wd->context_menu;
3746 * This appends a custom item provider to the list for that entry
3748 * This appends the given callback. The list is walked from beginning to end
3749 * with each function called given the item href string in the text. If the
3750 * function returns an object handle other than NULL (it should create an
3751 * and object to do this), then this object is used to replace that item. If
3752 * not the next provider is called until one provides an item object, or the
3753 * default provider in entry does.
3755 * @param obj The entry object
3756 * @param func The function called to provide the item object
3757 * @param data The data passed to @p func
3762 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3764 ELM_CHECK_WIDTYPE(obj, widtype);
3765 Widget_Data *wd = elm_widget_data_get(obj);
3767 EINA_SAFETY_ON_NULL_RETURN(func);
3768 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3772 wd->item_providers = eina_list_append(wd->item_providers, ip);
3776 * This prepends a custom item provider to the list for that entry
3778 * This prepends the given callback. See elm_entry_item_provider_append() for
3781 * @param obj The entry object
3782 * @param func The function called to provide the item object
3783 * @param data The data passed to @p func
3788 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3790 ELM_CHECK_WIDTYPE(obj, widtype);
3791 Widget_Data *wd = elm_widget_data_get(obj);
3793 EINA_SAFETY_ON_NULL_RETURN(func);
3794 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3798 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3802 * This removes a custom item provider to the list for that entry
3804 * This removes the given callback. See elm_entry_item_provider_append() for
3807 * @param obj The entry object
3808 * @param func The function called to provide the item object
3809 * @param data The data passed to @p func
3814 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3816 ELM_CHECK_WIDTYPE(obj, widtype);
3817 Widget_Data *wd = elm_widget_data_get(obj);
3819 Elm_Entry_Item_Provider *ip;
3821 EINA_SAFETY_ON_NULL_RETURN(func);
3822 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3824 if ((ip->func == func) && ((!data) || (ip->data == data)))
3826 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3834 * Append a filter function for text inserted in the entry
3836 * Append the given callback to the list. This functions will be called
3837 * whenever any text is inserted into the entry, with the text to be inserted
3838 * as a parameter. The callback function is free to alter the text in any way
3839 * it wants, but it must remember to free the given pointer and update it.
3840 * If the new text is to be discarded, the function can free it and set it text
3841 * parameter to NULL. This will also prevent any following filters from being
3844 * @param obj The entry object
3845 * @param func The function to use as text filter
3846 * @param data User data to pass to @p func
3851 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3854 Elm_Entry_Text_Filter *tf;
3855 ELM_CHECK_WIDTYPE(obj, widtype);
3857 wd = elm_widget_data_get(obj);
3859 EINA_SAFETY_ON_NULL_RETURN(func);
3861 tf = _filter_new(func, data);
3864 wd->text_filters = eina_list_append(wd->text_filters, tf);
3868 * Prepend a filter function for text insdrted in the entry
3870 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3871 * for more information
3873 * @param obj The entry object
3874 * @param func The function to use as text filter
3875 * @param data User data to pass to @p func
3880 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3883 Elm_Entry_Text_Filter *tf;
3884 ELM_CHECK_WIDTYPE(obj, widtype);
3886 wd = elm_widget_data_get(obj);
3888 EINA_SAFETY_ON_NULL_RETURN(func);
3890 tf = _filter_new(func, data);
3893 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3897 * Remove a filter from the list
3899 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3900 * for more information.
3902 * @param obj The entry object
3903 * @param func The filter function to remove
3904 * @param data The user data passed when adding the function
3909 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3913 Elm_Entry_Text_Filter *tf;
3914 ELM_CHECK_WIDTYPE(obj, widtype);
3916 wd = elm_widget_data_get(obj);
3918 EINA_SAFETY_ON_NULL_RETURN(func);
3920 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3922 if ((tf->func == func) && ((!data) || (tf->data == data)))
3924 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3932 * This converts a markup (HTML-like) string into UTF-8.
3933 * Returning string is obtained with malloc.
3934 * After use the returned string, it should be freed.
3936 * @param s The string (in markup) to be converted
3937 * @return The converted string (in UTF-8). It should be freed.
3942 elm_entry_markup_to_utf8(const char *s)
3944 char *ss = _elm_util_mkup_to_text(s);
3945 if (!ss) ss = strdup("");
3950 * This converts a UTF-8 string into markup (HTML-like).
3951 * Returning string is obtained with malloc.
3952 * After use the returned string, it should be freed.
3954 * @param s The string (in UTF-8) to be converted
3955 * @return The converted string (in markup). It should be freed.
3960 elm_entry_utf8_to_markup(const char *s)
3962 char *ss = _elm_util_text_to_mkup(s);
3963 if (!ss) ss = strdup("");
3968 * Get the input method context in the entry widget
3970 * @param obj The entry object
3971 * @return The input method context
3975 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3977 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3978 Widget_Data *wd = elm_widget_data_get(obj);
3979 if (!wd || !wd->ent) return NULL;
3981 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3985 * Set whether entry should enable the return key on soft keyboard automatically
3987 * @param obj The entry object
3988 * @param on If true, entry enables the return key on soft keyboard automatically.
3993 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3995 ELM_CHECK_WIDTYPE(obj, widtype);
3996 Widget_Data *wd = elm_widget_data_get(obj);
3999 wd->autoreturnkey = on;
4000 _check_enable_returnkey(obj);
4004 * Set whether entry should support auto capitalization
4006 * @param obj The entry object
4007 * @param on If true, entry suports auto capitalization.
4012 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4014 ELM_CHECK_WIDTYPE(obj, widtype);
4015 Widget_Data *wd = elm_widget_data_get(obj);
4019 wd->autocapital = EINA_FALSE;
4021 wd->autocapital = autocap;
4023 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4024 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4025 wd->autocapital = EINA_FALSE;
4027 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
4031 * Set whether entry should support auto period
4033 * @param obj The entry object
4034 * @param on If true, entry suports auto period.
4039 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4041 ELM_CHECK_WIDTYPE(obj, widtype);
4042 Widget_Data *wd = elm_widget_data_get(obj);
4046 wd->autoperiod = EINA_FALSE;
4048 wd->autoperiod = autoperiod;
4050 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4051 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4052 wd->autoperiod = EINA_FALSE;
4054 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4058 * Set the font size on the entry object
4060 * @param obj The entry object
4061 * @param size font size
4066 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
4068 ELM_CHECK_WIDTYPE(obj, widtype);
4069 Widget_Data *wd = elm_widget_data_get(obj);
4070 Eina_Strbuf *fontbuf = NULL;
4075 t = eina_stringshare_add(elm_entry_entry_get(obj));
4076 fontbuf = eina_strbuf_new();
4077 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
4079 if (fontsize == 0) removeflag = 1; // remove fontsize tag
4081 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
4083 elm_entry_entry_set(obj, t);
4087 eina_strbuf_free(fontbuf);
4088 eina_stringshare_del(t);
4092 * Set the text align on the entry object
4094 * @param obj The entry object
4095 * @param align align mode
4100 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
4102 ELM_CHECK_WIDTYPE(obj, widtype);
4103 Widget_Data *wd = elm_widget_data_get(obj);
4108 t = eina_stringshare_add(elm_entry_entry_get(obj));
4110 if (len <= 0) return;
4112 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
4113 elm_entry_entry_set(obj, t);
4117 eina_stringshare_del(t);
4121 * Set the text color on the entry object
4123 * @param obj The entry object
4124 * @param r Red property background color of The entry object
4125 * @param g Green property background color of The entry object
4126 * @param b Blue property background color of The entry object
4127 * @param a Alpha property background alpha of The entry object
4132 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4134 ELM_CHECK_WIDTYPE(obj, widtype);
4135 Widget_Data *wd = elm_widget_data_get(obj);
4136 Eina_Strbuf *colorbuf = NULL;
4141 t = eina_stringshare_add(elm_entry_entry_get(obj));
4143 if (len <= 0) return;
4144 colorbuf = eina_strbuf_new();
4145 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
4147 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
4149 elm_entry_entry_set(obj, t);
4153 eina_strbuf_free(colorbuf);
4154 eina_stringshare_del(t);
4158 * Set background color of the entry
4160 * @param obj The entry object
4161 * @param r Red property background color of The entry object
4162 * @param g Green property background color of The entry object
4163 * @param b Blue property background color of The entry object
4164 * @param a Alpha property background alpha of The entry object
4168 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4170 ELM_CHECK_WIDTYPE(obj, widtype);
4171 Widget_Data *wd = elm_widget_data_get(obj);
4172 evas_object_color_set(wd->bg, r, g, b, a);
4174 if (wd->bgcolor == EINA_FALSE)
4177 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4182 * Filter inserted text based on user defined character and byte limits
4184 * Add this filter to an entry to limit the characters that it will accept
4185 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
4186 * The funtion works on the UTF-8 representation of the string, converting
4187 * it from the set markup, thus not accounting for any format in it.
4189 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
4190 * it as data when setting the filter. In it it's possible to set limits
4191 * by character count or bytes (any of them is disabled if 0), and both can
4192 * be set at the same time. In that case, it first checks for characters,
4195 * The function will cut the inserted text in order to allow only the first
4196 * number of characters that are still allowed. The cut is made in
4197 * characters, even when limiting by bytes, in order to always contain
4198 * valid ones and avoid half unicode characters making it in.
4203 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4205 Elm_Entry_Filter_Limit_Size *lim = data;
4208 const char *(*text_get)(const Evas_Object *);
4209 const char *widget_type;
4211 EINA_SAFETY_ON_NULL_RETURN(data);
4212 EINA_SAFETY_ON_NULL_RETURN(entry);
4213 EINA_SAFETY_ON_NULL_RETURN(text);
4215 /* hack. I don't want to copy the entire function to work with
4217 widget_type = elm_widget_type_get(entry);
4218 if (!strcmp(widget_type, "entry"))
4219 text_get = elm_entry_entry_get;
4223 current = elm_entry_markup_to_utf8(text_get(entry));
4225 if (lim->max_char_count > 0)
4227 len = evas_string_char_len_get(current);
4228 if (len >= lim->max_char_count)
4230 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4236 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4237 if ((len + newlen) > lim->max_char_count)
4238 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4240 else if (lim->max_byte_count > 0)
4242 len = strlen(current);
4243 if (len >= lim->max_byte_count)
4245 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4251 newlen = strlen(elm_entry_markup_to_utf8(*text));
4252 if ((len + newlen) > lim->max_byte_count)
4253 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4259 * Filter inserted text based on accepted or rejected sets of characters
4261 * Add this filter to an entry to restrict the set of accepted characters
4262 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4263 * This structure contains both accepted and rejected sets, but they are
4264 * mutually exclusive. If accepted is set, it will be used, otherwise it
4265 * goes on to the rejected set.
4268 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4270 Elm_Entry_Filter_Accept_Set *as = data;
4274 int read_idx, last_read_idx = 0, read_char;
4276 EINA_SAFETY_ON_NULL_RETURN(data);
4277 EINA_SAFETY_ON_NULL_RETURN(text);
4279 if ((!as->accepted) && (!as->rejected))
4285 goes_in = EINA_TRUE;
4290 goes_in = EINA_FALSE;
4294 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4297 int cmp_idx, cmp_char;
4298 Eina_Bool in_set = EINA_FALSE;
4300 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4303 if (read_char == cmp_char)
4308 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4310 if (in_set == goes_in)
4312 int size = read_idx - last_read_idx;
4313 const char *src = (*text) + last_read_idx;
4315 memcpy(insert, *text + last_read_idx, size);
4318 last_read_idx = read_idx;
4319 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4325 * This sets the file (and implicitly loads it) for the text to display and
4326 * then edit. All changes are written back to the file after a short delay if
4327 * the entry object is set to autosave.
4329 * @param obj The entry object
4330 * @param file The path to the file to load and save
4331 * @param format The file format
4336 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4338 ELM_CHECK_WIDTYPE(obj, widtype);
4339 Widget_Data *wd = elm_widget_data_get(obj);
4341 if (wd->delay_write)
4343 ecore_timer_del(wd->delay_write);
4344 wd->delay_write = NULL;
4346 if (wd->autosave) _save(obj);
4347 eina_stringshare_replace(&wd->file, file);
4348 wd->format = format;
4353 * Gets the file to load and save and the file format
4355 * @param obj The entry object
4356 * @param file The path to the file to load and save
4357 * @param format The file format
4362 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4364 ELM_CHECK_WIDTYPE(obj, widtype);
4365 Widget_Data *wd = elm_widget_data_get(obj);
4367 if (file) *file = wd->file;
4368 if (format) *format = wd->format;
4372 * This function writes any changes made to the file set with
4373 * elm_entry_file_set()
4375 * @param obj The entry object
4380 elm_entry_file_save(Evas_Object *obj)
4382 ELM_CHECK_WIDTYPE(obj, widtype);
4383 Widget_Data *wd = elm_widget_data_get(obj);
4385 if (wd->delay_write)
4387 ecore_timer_del(wd->delay_write);
4388 wd->delay_write = NULL;
4391 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4395 * This sets the entry object to 'autosave' the loaded text file or not.
4397 * @param obj The entry object
4398 * @param autosave Autosave the loaded file or not
4403 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4405 ELM_CHECK_WIDTYPE(obj, widtype);
4406 Widget_Data *wd = elm_widget_data_get(obj);
4408 wd->autosave = !!autosave;
4412 * This gets the entry object's 'autosave' status.
4414 * @param obj The entry object
4415 * @return Autosave the loaded file or not
4420 elm_entry_autosave_get(const Evas_Object *obj)
4422 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4423 Widget_Data *wd = elm_widget_data_get(obj);
4424 if (!wd) return EINA_FALSE;
4425 return wd->autosave;
4429 * Control pasting of text and images for the widget.
4431 * Normally the entry allows both text and images to be pasted. By setting
4432 * textonly to be true, this prevents images from being pasted.
4434 * Note this only changes the behaviour of text.
4436 * @param obj The entry object
4437 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4442 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4444 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4445 ELM_CHECK_WIDTYPE(obj, widtype);
4446 Widget_Data *wd = elm_widget_data_get(obj);
4448 textonly = !!textonly;
4449 if (wd->textonly == textonly) return;
4450 wd->textonly = !!textonly;
4451 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4452 #ifdef HAVE_ELEMENTARY_X
4453 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4458 * Getting elm_entry text paste/drop mode.
4460 * In textonly mode, only text may be pasted or dropped into the widget.
4462 * @param obj The entry object
4463 * @return If the widget only accepts text from pastes.
4468 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4470 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4471 Widget_Data *wd = elm_widget_data_get(obj);
4472 if (!wd) return EINA_FALSE;
4473 return wd->textonly;
4477 * Enable or disable scrolling in entry
4479 * Normally the entry is not scrollable unless you enable it with this call.
4481 * @param obj The entry object
4482 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4487 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4489 ELM_CHECK_WIDTYPE(obj, widtype);
4490 Widget_Data *wd = elm_widget_data_get(obj);
4493 if (wd->scroll == scroll) return;
4494 wd->scroll = scroll;
4497 elm_widget_sub_object_del(obj, wd->scroller);
4498 elm_widget_resize_object_set(obj, wd->scroller);
4499 elm_widget_sub_object_add(obj, wd->ent);
4500 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4501 evas_object_show(wd->scroller);
4502 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4503 if (wd->single_line)
4505 elm_smart_scroller_policy_set(wd->scroller,
4506 ELM_SMART_SCROLLER_POLICY_OFF,
4507 ELM_SMART_SCROLLER_POLICY_OFF);
4508 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4512 const Elm_Scroller_Policy map[3] =
4514 ELM_SMART_SCROLLER_POLICY_AUTO,
4515 ELM_SMART_SCROLLER_POLICY_ON,
4516 ELM_SMART_SCROLLER_POLICY_OFF
4518 elm_smart_scroller_policy_set(wd->scroller,
4521 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4526 elm_smart_scroller_child_set(wd->scroller, NULL);
4527 elm_widget_sub_object_del(obj, wd->ent);
4528 elm_widget_resize_object_set(obj, wd->ent);
4529 evas_object_smart_member_add(wd->scroller, obj);
4530 elm_widget_sub_object_add(obj, wd->scroller);
4531 evas_object_hide(wd->scroller);
4532 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4539 * Get the scrollable state of the entry
4541 * Normally the entry is not scrollable. This gets the scrollable state
4542 * of the entry. See elm_entry_scrollable_set() for more information.
4544 * @param obj The entry object
4545 * @return The scrollable state
4550 elm_entry_scrollable_get(const Evas_Object *obj)
4552 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4553 Widget_Data *wd = elm_widget_data_get(obj);
4554 if (!wd) return EINA_FALSE;
4559 * This sets a widget to be displayed to the left of a scrolled entry.
4561 * @param obj The scrolled entry object
4562 * @param icon The widget to display on the left side of the scrolled
4565 * @note A previously set widget will be destroyed.
4566 * @note If the object being set does not have minimum size hints set,
4567 * it won't get properly displayed.
4570 * @see elm_entry_end_set
4573 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4575 ELM_CHECK_WIDTYPE(obj, widtype);
4576 Widget_Data *wd = elm_widget_data_get(obj);
4579 EINA_SAFETY_ON_NULL_RETURN(icon);
4580 if (wd->icon == icon) return;
4581 if (wd->icon) evas_object_del(wd->icon);
4583 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4585 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4586 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4591 * Gets the leftmost widget of the scrolled entry. This object is
4592 * owned by the scrolled entry and should not be modified.
4594 * @param obj The scrolled entry object
4595 * @return the left widget inside the scroller
4600 elm_entry_icon_get(const Evas_Object *obj)
4602 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4603 Widget_Data *wd = elm_widget_data_get(obj);
4604 if (!wd) return NULL;
4609 * Unset the leftmost widget of the scrolled entry, unparenting and
4612 * @param obj The scrolled entry object
4613 * @return the previously set icon sub-object of this entry, on
4616 * @see elm_entry_icon_set()
4621 elm_entry_icon_unset(Evas_Object *obj)
4623 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4624 Widget_Data *wd = elm_widget_data_get(obj);
4625 Evas_Object *ret = NULL;
4626 if (!wd) return NULL;
4629 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4630 if (!edje) return NULL;
4632 edje_object_part_unswallow(edje, wd->icon);
4633 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4641 * Sets the visibility of the left-side widget of the scrolled entry,
4642 * set by @elm_entry_icon_set().
4644 * @param obj The scrolled entry object
4645 * @param setting EINA_TRUE if the object should be displayed,
4646 * EINA_FALSE if not.
4651 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4653 ELM_CHECK_WIDTYPE(obj, widtype);
4654 Widget_Data *wd = elm_widget_data_get(obj);
4655 if ((!wd) || (!wd->icon)) return;
4657 evas_object_hide(wd->icon);
4659 evas_object_show(wd->icon);
4664 * This sets a widget to be displayed to the end of a scrolled entry.
4666 * @param obj The scrolled entry object
4667 * @param end The widget to display on the right side of the scrolled
4670 * @note A previously set widget will be destroyed.
4671 * @note If the object being set does not have minimum size hints set,
4672 * it won't get properly displayed.
4675 * @see elm_entry_icon_set
4678 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4680 ELM_CHECK_WIDTYPE(obj, widtype);
4681 Widget_Data *wd = elm_widget_data_get(obj);
4684 EINA_SAFETY_ON_NULL_RETURN(end);
4685 if (wd->end == end) return;
4686 if (wd->end) evas_object_del(wd->end);
4688 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4690 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4691 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4696 * Gets the endmost widget of the scrolled entry. This object is owned
4697 * by the scrolled entry and should not be modified.
4699 * @param obj The scrolled entry object
4700 * @return the right widget inside the scroller
4705 elm_entry_end_get(const Evas_Object *obj)
4707 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4708 Widget_Data *wd = elm_widget_data_get(obj);
4709 if (!wd) return NULL;
4714 * Unset the endmost widget of the scrolled entry, unparenting and
4717 * @param obj The scrolled entry object
4718 * @return the previously set icon sub-object of this entry, on
4721 * @see elm_entry_icon_set()
4726 elm_entry_end_unset(Evas_Object *obj)
4728 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4729 Widget_Data *wd = elm_widget_data_get(obj);
4730 Evas_Object *ret = NULL;
4731 if (!wd) return NULL;
4734 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4735 if (!edje) return NULL;
4737 edje_object_part_unswallow(edje, wd->end);
4738 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4746 * Sets the visibility of the end widget of the scrolled entry, set by
4747 * @elm_entry_end_set().
4749 * @param obj The scrolled entry object
4750 * @param setting EINA_TRUE if the object should be displayed,
4751 * EINA_FALSE if not.
4756 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4758 ELM_CHECK_WIDTYPE(obj, widtype);
4759 Widget_Data *wd = elm_widget_data_get(obj);
4760 if ((!wd) || (!wd->end)) return;
4762 evas_object_hide(wd->end);
4764 evas_object_show(wd->end);
4769 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4771 * @param obj The scrolled entry object
4772 * @param h The horizontal scrollbar policy to apply
4773 * @param v The vertical scrollbar policy to apply
4778 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4780 ELM_CHECK_WIDTYPE(obj, widtype);
4781 Widget_Data *wd = elm_widget_data_get(obj);
4782 const Elm_Scroller_Policy map[3] =
4784 ELM_SMART_SCROLLER_POLICY_AUTO,
4785 ELM_SMART_SCROLLER_POLICY_ON,
4786 ELM_SMART_SCROLLER_POLICY_OFF
4791 elm_smart_scroller_policy_set(wd->scroller,
4797 * This enables/disables bouncing within the entry.
4799 * @param obj The scrolled entry object
4800 * @param h The horizontal bounce state
4801 * @param v The vertical bounce state
4806 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4808 ELM_CHECK_WIDTYPE(obj, widtype);
4809 Widget_Data *wd = elm_widget_data_get(obj);
4811 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4815 * Get the bounce mode
4817 * @param obj The Entry object
4818 * @param h_bounce Allow bounce horizontally
4819 * @param v_bounce Allow bounce vertically
4824 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4826 ELM_CHECK_WIDTYPE(obj, widtype);
4827 Widget_Data *wd = elm_widget_data_get(obj);
4829 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4833 * This sets the attribute to show the input panel automatically.
4835 * @param obj The entry object
4836 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4841 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4843 ELM_CHECK_WIDTYPE(obj, widtype);
4844 Widget_Data *wd = elm_widget_data_get(obj);
4847 wd->input_panel_enable = enabled;
4848 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4852 * Set the input panel layout of the entry
4854 * @param obj The entry object
4855 * @param layout the layout to set
4860 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4862 ELM_CHECK_WIDTYPE(obj, widtype);
4863 Widget_Data *wd = elm_widget_data_get(obj);
4866 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4869 wd->input_panel_layout = layout;
4871 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4875 * Set the magnifier style of the entry
4877 * @param obj The entry object
4878 * @param type the magnifier style to set
4883 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4885 ELM_CHECK_WIDTYPE(obj, widtype);
4886 Widget_Data *wd = elm_widget_data_get(obj);
4889 wd->mgf_type = type;
4890 _magnifier_create(obj);
4893 EINA_DEPRECATED EAPI void
4894 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4896 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);