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 *delay_write;
129 /* for deferred appending */
130 Ecore_Idler *append_text_idler;
131 char *append_text_left;
132 int append_text_position;
134 /* Only for clipboard */
137 const char *password_text;
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 int matchlist_threshold;
150 Ecore_Job *hovdeljob;
151 Mod_Api *api; // module api if supplied
153 Elm_Scroller_Policy policy_h, policy_v;
154 Elm_Wrap_Type linewrap;
155 Elm_Input_Panel_Layout input_panel_layout;
156 Eina_Bool changed : 1;
157 Eina_Bool single_line : 1;
158 Eina_Bool password : 1;
159 Eina_Bool editable : 1;
160 Eina_Bool selection_asked : 1;
161 Eina_Bool have_selection : 1;
162 Eina_Bool selmode : 1;
163 Eina_Bool deferred_cur : 1;
164 Eina_Bool cur_changed : 1;
165 Eina_Bool disabled : 1;
166 Eina_Bool double_clicked : 1;
167 Eina_Bool long_pressed : 1;
168 Eina_Bool context_menu : 1;
169 Eina_Bool drag_selection_asked : 1;
170 Eina_Bool bgcolor : 1;
171 Eina_Bool can_write : 1;
172 Eina_Bool autosave : 1;
173 Eina_Bool textonly : 1;
174 Eina_Bool usedown : 1;
175 Eina_Bool scroll : 1;
176 Eina_Bool autoreturnkey : 1;
177 Eina_Bool input_panel_enable : 1;
178 Eina_Bool autocapital : 1;
179 Eina_Bool autoperiod : 1;
180 Eina_Bool matchlist_list_clicked : 1;
181 Eina_Bool matchlist_case_sensitive : 1;
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 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
229 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
230 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
231 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
232 static const char *_getbase(Evas_Object *obj);
233 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
234 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
235 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
236 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
237 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
238 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
239 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
240 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
241 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
242 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
243 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
244 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
245 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
246 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
247 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
248 static int _entry_length_get(Evas_Object *obj);
249 static void _magnifier_create(void *data);
250 static void _magnifier_show(void *data);
251 static void _magnifier_hide(void *data);
252 static void _magnifier_move(void *data);
254 static const char SIG_CHANGED[] = "changed";
255 static const char SIG_ACTIVATED[] = "activated";
256 static const char SIG_PRESS[] = "press";
257 static const char SIG_LONGPRESSED[] = "longpressed";
258 static const char SIG_CLICKED[] = "clicked";
259 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
260 static const char SIG_FOCUSED[] = "focused";
261 static const char SIG_UNFOCUSED[] = "unfocused";
262 static const char SIG_SELECTION_PASTE[] = "selection,paste";
263 static const char SIG_SELECTION_COPY[] = "selection,copy";
264 static const char SIG_SELECTION_CUT[] = "selection,cut";
265 static const char SIG_SELECTION_START[] = "selection,start";
266 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
267 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
268 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
269 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
270 static const char SIG_MATCHLIST_CLICKED[] = "matchlist,clicked";
271 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
272 static const Evas_Smart_Cb_Description _signals[] = {
276 {SIG_LONGPRESSED, ""},
278 {SIG_CLICKED_DOUBLE, ""},
281 {SIG_SELECTION_PASTE, ""},
282 {SIG_SELECTION_COPY, ""},
283 {SIG_SELECTION_CUT, ""},
284 {SIG_SELECTION_START, ""},
285 {SIG_SELECTION_CHANGED, ""},
286 {SIG_SELECTION_CLEARED, ""},
287 {SIG_CURSOR_CHANGED, ""},
288 {SIG_ANCHOR_CLICKED, ""},
289 {SIG_PREEDIT_CHANGED, ""},
290 {SIG_MATCHLIST_CLICKED, ""},
294 typedef enum _Elm_Entry_Magnifier_Type
296 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
297 _ENTRY_MAGNIFIER_FILLWIDTH,
298 _ENTRY_MAGNIFIER_CIRCULAR,
299 } Elm_Entry_Magnifier_Type;
302 static Eina_List *entries = NULL;
306 void (*obj_hook) (Evas_Object *obj);
307 void (*obj_unhook) (Evas_Object *obj);
308 void (*obj_longpress) (Evas_Object *obj);
309 void (*obj_hidemenu) (Evas_Object *obj);
310 void (*obj_mouseup) (Evas_Object *obj);
314 _module(Evas_Object *obj __UNUSED__)
316 static Elm_Module *m = NULL;
317 if (m) goto ok; // already found - just use
318 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
320 m->api = malloc(sizeof(Mod_Api));
321 if (!m->api) return NULL;
322 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
323 _elm_module_symbol_get(m, "obj_hook");
324 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
325 _elm_module_symbol_get(m, "obj_unhook");
326 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
327 _elm_module_symbol_get(m, "obj_longpress");
328 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
329 _elm_module_symbol_get(m, "obj_hidemenu");
330 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
331 _elm_module_symbol_get(m, "obj_mouseup");
332 ok: // ok - return api
337 _buf_append(char *buf, const char *str, int *len, int *alloc)
339 int len2 = strlen(str);
340 if ((*len + len2) >= *alloc)
342 char *buf2 = realloc(buf, *alloc + len2 + 512);
343 if (!buf2) return NULL;
345 *alloc += (512 + len2);
347 strcpy(buf + *len, str);
353 _load_file(const char *file)
357 int alloc = 0, len = 0;
358 char *text = NULL, buf[16384 + 1];
360 f = fopen(file, "rb");
362 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
366 tmp_text = _buf_append(text, buf, &len, &alloc);
367 if (!tmp_text) break;
375 _load_plain(const char *file)
379 text = _load_file(file);
384 text2 = elm_entry_utf8_to_markup(text);
392 _load(Evas_Object *obj)
394 Widget_Data *wd = elm_widget_data_get(obj);
399 elm_entry_entry_set(obj, "");
404 case ELM_TEXT_FORMAT_PLAIN_UTF8:
405 text = _load_plain(wd->file);
407 case ELM_TEXT_FORMAT_MARKUP_UTF8:
408 text = _load_file(wd->file);
416 elm_entry_entry_set(obj, text);
420 elm_entry_entry_set(obj, "");
424 _save_markup_utf8(const char *file, const char *text)
428 if ((!text) || (!text[0]))
430 ecore_file_unlink(file);
433 f = fopen(file, "wb");
436 // FIXME: report a write error
439 fputs(text, f); // FIXME: catch error
444 _save_plain_utf8(const char *file, const char *text)
448 text2 = elm_entry_markup_to_utf8(text);
451 _save_markup_utf8(file, text2);
456 _save(Evas_Object *obj)
458 Widget_Data *wd = elm_widget_data_get(obj);
460 if (!wd->file) return;
463 case ELM_TEXT_FORMAT_PLAIN_UTF8:
464 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
466 case ELM_TEXT_FORMAT_MARKUP_UTF8:
467 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
475 _delay_write(void *data)
477 Widget_Data *wd = elm_widget_data_get(data);
478 if (!wd) return ECORE_CALLBACK_CANCEL;
480 wd->delay_write = NULL;
481 return ECORE_CALLBACK_CANCEL;
484 static Elm_Entry_Text_Filter *
485 _filter_new(void (*func) (void *data, Evas_Object *entry, char **text), void *data)
487 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
488 if (!tf) return NULL;
491 if (func == elm_entry_filter_limit_size)
493 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
500 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
506 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
509 else if (func == elm_entry_filter_accept_set)
511 Elm_Entry_Filter_Accept_Set *as = data, *as2;
518 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
525 as2->accepted = eina_stringshare_add(as->accepted);
527 as2->accepted = NULL;
529 as2->rejected = eina_stringshare_add(as->rejected);
531 as2->rejected = NULL;
540 _filter_free(Elm_Entry_Text_Filter *tf)
542 if (tf->func == elm_entry_filter_limit_size)
544 Elm_Entry_Filter_Limit_Size *lim = tf->data;
547 else if (tf->func == elm_entry_filter_accept_set)
549 Elm_Entry_Filter_Accept_Set *as = tf->data;
552 if (as->accepted) eina_stringshare_del(as->accepted);
553 if (as->rejected) eina_stringshare_del(as->rejected);
561 _del_pre_hook(Evas_Object *obj)
563 Widget_Data *wd = elm_widget_data_get(obj);
567 ecore_timer_del(wd->delay_write);
568 wd->delay_write = NULL;
569 if (wd->autosave) _save(obj);
574 _del_hook(Evas_Object *obj)
576 Widget_Data *wd = elm_widget_data_get(obj);
577 Elm_Entry_Context_Menu_Item *it;
578 Elm_Entry_Item_Provider *ip;
579 Elm_Entry_Text_Filter *tf;
581 if (wd->file) eina_stringshare_del(wd->file);
583 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
584 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
586 entries = eina_list_remove(entries, obj);
587 #ifdef HAVE_ELEMENTARY_X
588 if (wd->sel_notify_handler)
589 ecore_event_handler_del(wd->sel_notify_handler);
590 if (wd->sel_clear_handler)
591 ecore_event_handler_del(wd->sel_clear_handler);
593 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
594 if (wd->text) eina_stringshare_del(wd->text);
595 if (wd->password_text) eina_stringshare_del(wd->password_text);
596 if (wd->bg) evas_object_del(wd->bg);
597 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
598 if (wd->append_text_idler)
600 ecore_idler_del(wd->append_text_idler);
601 free(wd->append_text_left);
602 wd->append_text_left = NULL;
603 wd->append_text_idler = NULL;
605 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
606 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
607 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
608 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
610 EINA_LIST_FREE(wd->items, it)
612 eina_stringshare_del(it->label);
613 eina_stringshare_del(it->icon_file);
614 eina_stringshare_del(it->icon_group);
617 EINA_LIST_FREE(wd->item_providers, ip)
621 EINA_LIST_FREE(wd->text_filters, tf)
625 if (wd->delay_write) ecore_timer_del(wd->delay_write);
630 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
632 Widget_Data *wd = elm_widget_data_get(obj);
633 edje_object_mirrored_set(wd->ent, rtl);
637 _theme_hook(Evas_Object *obj)
639 Widget_Data *wd = elm_widget_data_get(obj);
641 Ecore_IMF_Context *ic;
642 _elm_widget_mirrored_reload(obj);
643 _mirrored_set(obj, elm_widget_mirrored_get(obj));
645 t = eina_stringshare_add(elm_entry_entry_get(obj));
646 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
647 if (_elm_config->desktop_entry)
648 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
649 elm_entry_entry_set(obj, t);
650 eina_stringshare_del(t);
651 if (elm_widget_disabled_get(obj))
652 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
653 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
654 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
655 if (elm_widget_focus_get(obj))
656 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
657 edje_object_message_signal_process(wd->ent);
658 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
659 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
660 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
661 elm_widget_style_get(obj));
667 edj = elm_smart_scroller_edje_object_get(wd->scroller);
668 str = edje_object_data_get(edj, "focus_highlight");
669 if ((str) && (!strcmp(str, "on")))
670 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
672 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
677 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", EINA_FALSE);
678 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", EINA_FALSE);
682 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
683 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
686 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
689 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
696 _disable_hook(Evas_Object *obj)
698 Widget_Data *wd = elm_widget_data_get(obj);
700 if (elm_widget_disabled_get(obj))
702 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
703 wd->disabled = EINA_TRUE;
707 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
708 wd->disabled = EINA_FALSE;
713 _recalc_cursor_geometry(Evas_Object *obj)
715 Widget_Data *wd = elm_widget_data_get(obj);
717 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
718 if (!elm_object_focus_get(obj)) return;
719 if (!wd->deferred_recalc_job)
721 Evas_Coord cx, cy, cw, ch;
722 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
726 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
727 wd->cur_changed = EINA_FALSE;
731 wd->deferred_cur = EINA_TRUE;
735 _elm_win_recalc_job(void *data)
737 Widget_Data *wd = elm_widget_data_get(data);
738 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
740 wd->deferred_recalc_job = NULL;
742 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
743 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
744 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
747 /* This is a hack to workaround the way min size hints are treated.
748 * If the minimum width is smaller than the restricted width, it means
749 * the mininmum doesn't matter. */
752 Evas_Coord ominw = -1;
753 evas_object_size_hint_min_get(data, &ominw, NULL);
757 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
760 Evas_Coord vmw = 0, vmh = 0;
762 edje_object_size_min_calc
763 (elm_smart_scroller_edje_object_get(wd->scroller),
767 evas_object_size_hint_min_set(data, vmw, minh + vmh);
768 evas_object_size_hint_max_set(data, -1, minh + vmh);
772 evas_object_size_hint_min_set(data, vmw, vmh);
773 evas_object_size_hint_max_set(data, -1, -1);
780 evas_object_size_hint_min_set(data, minw, minh);
781 evas_object_size_hint_max_set(data, -1, minh);
785 evas_object_size_hint_min_set(data, fw, minh);
786 evas_object_size_hint_max_set(data, -1, -1);
790 if ((wd->deferred_cur) && (elm_object_focus_get(data)))
792 Evas_Coord cx, cy, cw, ch;
793 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
797 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
798 wd->cur_changed = EINA_FALSE;
804 _sizing_eval(Evas_Object *obj)
806 Widget_Data *wd = elm_widget_data_get(obj);
807 Evas_Coord minw = -1, minh = -1;
808 Evas_Coord resw, resh;
811 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
814 if ((resw == wd->lastw) && (!wd->changed)) return;
815 wd->changed = EINA_FALSE;
819 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
821 evas_object_resize(wd->scroller, resw, resh);
822 edje_object_size_min_calc
823 (elm_smart_scroller_edje_object_get(wd->scroller),
825 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
826 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
829 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
831 if ((minw > 0) && (vw < minw)) vw = minw;
832 if (minh > vh) vh = minh;
834 if (wd->single_line) h = vmh + minh;
836 evas_object_resize(wd->ent, vw, vh);
837 evas_object_size_hint_min_get(obj, &w, NULL);
838 evas_object_size_hint_min_set(obj, w, h);
840 evas_object_size_hint_max_set(obj, -1, h);
842 evas_object_size_hint_max_set(obj, -1, -1);
846 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
847 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
852 if (!wd->changed) return;
853 wd->changed = EINA_FALSE;
857 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
859 edje_object_size_min_calc(wd->ent, &minw, &minh);
862 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
864 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
866 if ((minw > 0) && (vw < minw)) vw = minw;
867 if (minh > 0) vh = minh;
869 evas_object_resize(wd->ent, vw, vh);
870 edje_object_size_min_calc
871 (elm_smart_scroller_edje_object_get(wd->scroller),
873 if (wd->single_line) h = vmh + minh;
875 evas_object_size_hint_min_get(obj, &w, NULL);
876 evas_object_size_hint_min_set(obj, w, h);
878 evas_object_size_hint_max_set(obj, -1, h);
880 evas_object_size_hint_max_set(obj, -1, -1);
884 edje_object_size_min_calc(wd->ent, &minw, &minh);
887 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
888 evas_object_size_hint_min_set(obj, minw, minh);
890 evas_object_size_hint_max_set(obj, -1, minh);
892 evas_object_size_hint_max_set(obj, -1, -1);
896 _recalc_cursor_geometry(obj);
900 _check_enable_returnkey(Evas_Object *obj)
902 Widget_Data *wd = elm_widget_data_get(obj);
905 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
908 if (!wd->autoreturnkey) return;
910 if (_entry_length_get(obj) == 0)
912 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
916 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
921 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
923 Widget_Data *wd = elm_widget_data_get(obj);
924 Evas_Object *top = elm_widget_top_get(obj);
926 if (elm_widget_focus_get(obj))
928 printf("[Elm_entry::Focused] obj : %p\n", obj);
929 evas_object_focus_set(wd->ent, EINA_TRUE);
930 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
931 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
932 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
933 _check_enable_returnkey(obj);
934 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
938 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
939 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
940 evas_object_focus_set(wd->ent, EINA_FALSE);
941 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
942 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
944 if ((wd->api) && (wd->api->obj_hidemenu))
946 wd->api->obj_hidemenu(obj);
953 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
955 Widget_Data *wd = elm_widget_data_get(obj);
957 if ((!wd) || (!content)) return;
961 edje = elm_smart_scroller_edje_object_get(wd->scroller);
962 if (!strcmp(part, "elm.swallow.icon"))
965 evas_object_del(wd->icon);
967 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
969 else if (!strcmp(part, "elm.swallow.end"))
972 evas_object_del(wd->end);
974 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
979 evas_event_freeze(evas_object_evas_get(obj));
980 elm_widget_sub_object_add(obj, content);
981 edje_object_part_swallow(edje, part, content);
983 evas_event_thaw(evas_object_evas_get(obj));
984 evas_event_thaw_eval(evas_object_evas_get(obj));
988 _content_unset_hook(Evas_Object *obj, const char *part)
990 Widget_Data *wd = elm_widget_data_get(obj);
991 Evas_Object *content, *edje;
992 if (!wd) return NULL;
996 edje = elm_smart_scroller_edje_object_get(wd->scroller);
997 if (!strcmp(part, "elm.swallow.icon"))
1000 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1002 else if (!strcmp(part, "elm.swallow.end"))
1005 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1011 content = edje_object_part_swallow_get(edje, part);
1012 edje_object_part_swallow(edje, part, NULL);
1013 if (!content) return NULL;
1014 evas_event_freeze(evas_object_evas_get(obj));
1015 elm_widget_sub_object_del(obj, content);
1016 edje_object_part_unswallow(wd->ent, content);
1018 evas_event_thaw(evas_object_evas_get(obj));
1019 evas_event_thaw_eval(evas_object_evas_get(obj));
1024 static Evas_Object *
1025 _content_get_hook(const Evas_Object *obj, const char *part)
1027 Widget_Data *wd = elm_widget_data_get(obj);
1028 Evas_Object *content = NULL, *edje;
1029 if (!wd) return NULL;
1033 if (!strcmp(part, "elm.swallow.icon"))
1035 if (!strcmp(part, "elm.swallow.end"))
1038 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1044 content = edje_object_part_swallow_get(edje, part);
1050 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
1052 Widget_Data *wd = elm_widget_data_get(obj);
1054 edje_object_signal_emit(wd->ent, emission, source);
1056 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
1061 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1063 Widget_Data *wd = elm_widget_data_get(obj);
1065 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
1067 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
1068 emission, source, func_cb, data);
1072 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1074 Widget_Data *wd = elm_widget_data_get(obj);
1075 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
1078 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
1079 emission, source, func_cb, data);
1083 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1085 Widget_Data *wd = elm_widget_data_get(obj);
1086 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
1090 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1092 Widget_Data *wd = elm_widget_data_get(obj);
1094 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1098 _show_region_hook(void *data, Evas_Object *obj)
1100 Widget_Data *wd = elm_widget_data_get(data);
1101 Evas_Coord x, y, w, h;
1103 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1105 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1109 _sub_del(void *data, Evas_Object *obj, void *event_info)
1111 Widget_Data *wd = data;
1112 Evas_Object *sub = event_info;
1115 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1116 if (sub == wd->icon)
1120 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1122 else if (sub == wd->end)
1126 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1132 _hoversel_position(Evas_Object *obj)
1134 Widget_Data *wd = elm_widget_data_get(obj);
1135 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1140 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1149 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1150 &cx, &cy, &cw, &ch);
1151 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1154 cx += (cw - mw) / 2;
1159 cy += (ch - mh) / 2;
1162 evas_object_move(wd->hoversel, x + cx, y + cy);
1163 evas_object_resize(wd->hoversel, cw, ch);
1167 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1169 Widget_Data *wd = elm_widget_data_get(data);
1171 if (wd->hoversel) _hoversel_position(data);
1175 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1177 Widget_Data *wd = elm_widget_data_get(data);
1184 else if (wd->scroll)
1186 Evas_Coord vw = 0, vh = 0;
1188 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1189 if (vw < wd->entmw) vw = wd->entmw;
1190 if (vh < wd->entmh) vh = wd->entmh;
1191 evas_object_resize(wd->ent, vw, vh);
1193 if (wd->hoversel) _hoversel_position(data);
1197 _hover_del(void *data)
1199 Widget_Data *wd = elm_widget_data_get(data);
1204 evas_object_del(wd->hoversel);
1205 wd->hoversel = NULL;
1207 wd->hovdeljob = NULL;
1211 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1213 Widget_Data *wd = elm_widget_data_get(data);
1216 if (wd->hoversel) evas_object_hide(wd->hoversel);
1219 if (!_elm_config->desktop_entry)
1222 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1225 elm_widget_scroll_freeze_pop(data);
1226 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1227 wd->hovdeljob = ecore_job_add(_hover_del, data);
1231 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1233 Widget_Data *wd = elm_widget_data_get(data);
1235 wd->selmode = EINA_TRUE;
1236 edje_object_part_text_select_none(wd->ent, "elm.text");
1237 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1238 edje_object_part_text_select_all(wd->ent, "elm.text");
1239 elm_object_scroll_freeze_pop(data);
1243 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1245 Widget_Data *wd = elm_widget_data_get(data);
1247 wd->selmode = EINA_TRUE;
1248 edje_object_part_text_select_none(wd->ent, "elm.text");
1249 if (!_elm_config->desktop_entry)
1252 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1254 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1255 if (!_elm_config->desktop_entry)
1256 elm_object_scroll_freeze_pop(data);
1257 //elm_widget_scroll_hold_push(data);
1261 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1263 Widget_Data *wd = elm_widget_data_get(data);
1265 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1266 if (wd->sel_notify_handler)
1268 #ifdef HAVE_ELEMENTARY_X
1269 Elm_Sel_Format formats;
1270 wd->selection_asked = EINA_TRUE;
1271 formats = ELM_SEL_FORMAT_MARKUP;
1273 formats |= ELM_SEL_FORMAT_IMAGE;
1274 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1280 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1282 Widget_Data *wd = elm_widget_data_get(obj);
1287 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1288 sel_str = strdup(sel);
1295 char *startTag = NULL;
1296 char *endTag = NULL;
1298 startTag = strstr(sel_str, "<item");
1300 startTag = strstr(sel_str, "</item");
1302 endTag = strstr(startTag, ">");
1305 if (!endTag || startTag > endTag)
1308 size_t sindex = startTag - sel_str;
1309 size_t eindex = endTag - sel_str + 1;
1311 Eina_Strbuf *buf = eina_strbuf_new();
1314 eina_strbuf_append(buf, sel_str);
1315 eina_strbuf_remove(buf, sindex, eindex);
1316 sel_str = eina_strbuf_string_steal(buf);
1317 eina_strbuf_free(buf);
1321 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str);
1322 if (seltype == ELM_SEL_CLIPBOARD)
1323 eina_stringshare_replace(&wd->cut_sel, sel_str);
1328 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1330 Widget_Data *wd = elm_widget_data_get(data);
1333 wd->selmode = EINA_FALSE;
1334 if (!_elm_config->desktop_entry)
1335 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1336 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1337 if (!_elm_config->desktop_entry)
1338 elm_widget_scroll_hold_pop(data);
1339 _store_selection(ELM_SEL_CLIPBOARD, data);
1340 edje_object_part_text_insert(wd->ent, "elm.text", "");
1341 edje_object_part_text_select_none(wd->ent, "elm.text");
1345 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1347 Widget_Data *wd = elm_widget_data_get(data);
1349 wd->selmode = EINA_TRUE;
1350 if (!_elm_config->desktop_entry)
1352 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1353 elm_widget_scroll_hold_pop(data);
1355 _store_selection(ELM_SEL_CLIPBOARD, data);
1359 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1361 Widget_Data *wd = elm_widget_data_get(data);
1363 wd->selmode = EINA_FALSE;
1364 if (!_elm_config->desktop_entry)
1365 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1366 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1367 if (!_elm_config->desktop_entry)
1368 elm_widget_scroll_hold_pop(data);
1369 edje_object_part_text_select_none(wd->ent, "elm.text");
1373 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1375 Widget_Data *wd = elm_widget_data_get(data);
1379 #ifdef HAVE_ELEMENTARY_X
1380 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1382 cnpwidgetdata = data;
1383 elm_cbhm_helper_init(obj);
1384 if (elm_entry_cnp_textonly_get(obj))
1385 elm_cbhm_send_raw_data("show0");
1387 elm_cbhm_send_raw_data("show1");
1393 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1395 Widget_Data *wd = elm_widget_data_get(data);
1397 cnpwidgetdata = data;
1403 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1405 Elm_Entry_Context_Menu_Item *it = data;
1406 Evas_Object *obj2 = it->obj;
1407 if (it->func) it->func(it->data, obj2, NULL);
1411 _menu_press(Evas_Object *obj)
1413 Widget_Data *wd = elm_widget_data_get(obj);
1416 const Elm_Entry_Context_Menu_Item *it;
1418 if ((wd->api) && (wd->api->obj_longpress))
1420 wd->api->obj_longpress(obj);
1422 else if (wd->context_menu)
1424 const char *context_menu_orientation;
1426 if (wd->hoversel) evas_object_del(wd->hoversel);
1427 else elm_widget_scroll_freeze_push(obj);
1428 wd->hoversel = elm_hoversel_add(obj);
1429 context_menu_orientation = edje_object_data_get
1430 (wd->ent, "context_menu_orientation");
1431 if ((context_menu_orientation) &&
1432 (!strcmp(context_menu_orientation, "horizontal")))
1433 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1434 elm_object_style_set(wd->hoversel, "entry");
1435 elm_widget_sub_object_add(obj, wd->hoversel);
1436 elm_object_text_set(wd->hoversel, "Text");
1437 top = elm_widget_top_get(obj);
1438 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1439 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1443 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1445 if (1) // need way to detect if someone has a selection
1448 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1452 if ((!wd->password) && (wd->editable))
1453 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1454 _clipboard_menu, obj);
1461 if (wd->have_selection)
1463 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1466 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1469 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1473 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1474 _clipboard_menu, obj);
1478 EINA_LIST_FOREACH(wd->items, l, it)
1480 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1481 it->icon_type, _item_clicked, it);
1485 _hoversel_position(obj);
1486 evas_object_show(wd->hoversel);
1487 elm_hoversel_hover_begin(wd->hoversel);
1489 if (!_elm_config->desktop_entry)
1491 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1492 edje_object_part_text_select_abort(wd->ent, "elm.text");
1498 _magnifier_hide(void *data)
1500 Widget_Data *wd = elm_widget_data_get(data);
1503 evas_object_hide(wd->mgf_bg);
1504 evas_object_hide(wd->mgf_clip);
1507 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1511 _magnifier_show(void *data)
1513 Widget_Data *wd = elm_widget_data_get(data);
1516 evas_object_show(wd->mgf_bg);
1517 evas_object_show(wd->mgf_clip);
1521 _magnifier_move(void *data)
1523 Widget_Data *wd = elm_widget_data_get(data);
1526 Evas_Coord x, y, w, h;
1527 Evas_Coord cx, cy, cw, ch, ox, oy;
1529 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1533 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1534 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1539 evas_object_geometry_get(data, &x, &y, &w, &h);
1543 if ((cy + y) - wd->mgf_height < 0)
1544 oy = -1 * ((cy + y) - wd->mgf_height);
1546 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1547 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height + oy);
1548 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1549 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height + oy);
1553 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 + oy);
1557 _magnifier_create(void *data)
1559 Widget_Data *wd = elm_widget_data_get(data);
1560 Evas_Coord x, y, w, h, mw, mh;
1561 const char* key_data = NULL;
1568 evas_object_image_source_unset(wd->mgf_proxy);
1569 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1570 evas_object_hide(wd->mgf_proxy);
1571 evas_object_clip_unset(wd->mgf_proxy);
1572 evas_object_del(wd->mgf_proxy);
1574 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1575 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1578 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1580 evas_object_geometry_get(data, &x, &y, &w, &h);
1582 if ((w <= 0) || (h <= 0))
1585 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1587 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1588 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1589 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1590 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1594 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1595 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1596 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1598 key_data = edje_object_data_get(wd->mgf_bg, "height");
1599 if (key_data) wd->mgf_height = atoi(key_data);
1600 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1601 if (key_data) wd->mgf_scale = atof(key_data);
1603 elm_scale = elm_scale_get();
1604 wd->mgf_height = (int)((float)wd->mgf_height * elm_scale);
1606 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1607 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1611 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1612 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1613 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1617 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1618 evas_object_image_source_set(wd->mgf_proxy, data);
1621 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1622 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1623 if ((mw <= 0) || (mh <= 0))
1626 evas_object_resize(wd->mgf_proxy, mw, mh);
1627 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1628 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1629 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1630 evas_object_show(wd->mgf_proxy);
1631 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1633 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1634 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1638 _signal_long_pressed(void *data)
1640 Widget_Data *wd = elm_widget_data_get(data);
1641 if (!wd) return ECORE_CALLBACK_CANCEL;
1643 wd->long_pressed = EINA_TRUE;
1645 _cancel(data, NULL, NULL);
1647 _magnifier_create(data);
1648 _magnifier_move(data);
1649 _magnifier_show(data);
1650 elm_object_scroll_freeze_push(data);
1652 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1653 return ECORE_CALLBACK_CANCEL;
1657 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1659 Widget_Data *wd = elm_widget_data_get(data);
1660 Evas_Event_Mouse_Down *ev = event_info;
1662 if (wd->disabled) return;
1663 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1664 wd->downx = ev->canvas.x;
1665 wd->downy = ev->canvas.y;
1666 wd->long_pressed = EINA_FALSE;
1670 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1672 Widget_Data *wd = elm_widget_data_get(data);
1673 Evas_Event_Mouse_Up *ev = event_info;
1675 if (wd->disabled) return;
1676 if (ev->button == 1)
1678 if (!wd->double_clicked)
1680 if ((wd->api) && (wd->api->obj_mouseup))
1681 wd->api->obj_mouseup(data);
1683 _magnifier_hide(data);
1684 elm_object_scroll_freeze_pop(data);
1686 if (wd->long_pressed)
1689 else if (ev->button == 3)
1697 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1699 Widget_Data *wd = elm_widget_data_get(data);
1700 Evas_Event_Mouse_Move *ev = event_info;
1702 if (wd->disabled) return;
1704 if (ev->buttons == 1)
1706 if (wd->long_pressed)
1708 _magnifier_show(data);
1709 _magnifier_move(data);
1715 _getbase(Evas_Object *obj)
1717 Widget_Data *wd = elm_widget_data_get(obj);
1718 if (!wd) return "base";
1721 if (wd->password) return "base-password";
1724 if (wd->single_line) return "base-single";
1727 switch (wd->linewrap)
1730 return "base-charwrap";
1733 case ELM_WRAP_MIXED:
1734 return "base-mixedwrap";
1737 return "base-nowrap";
1744 if (wd->password) return "base-password";
1747 if (wd->single_line) return "base-single-noedit";
1750 switch (wd->linewrap)
1753 return "base-noedit-charwrap";
1755 return "base-noedit";
1756 case ELM_WRAP_MIXED:
1757 return "base-noedit-mixedwrap";
1760 return "base-nowrap-noedit";
1770 _entry_length_get(Evas_Object *obj)
1773 const char *str = elm_entry_entry_get(obj);
1776 char *plain_str = _elm_util_mkup_to_text(str);
1777 if (!plain_str) return 0;
1779 len = strlen(plain_str);
1785 #ifndef HAVE_STRCASESTR
1786 char* _strcasestr(const char *s, const char *find)
1791 if ((c = *find++) != 0) {
1792 c = tolower((unsigned char) c);
1796 if( (sc = *s++) == 0)
1798 } while ((char)tolower((unsigned char)sc) != c);
1799 } while (strncasecmp(s, find, len) != 0);
1807 _matchlist_show(void *data)
1809 Widget_Data *wd = elm_widget_data_get(data);
1810 const char *text = NULL;
1812 char *str_list = NULL, *str_result = NULL;
1813 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1816 Eina_Bool textfound = EINA_FALSE;
1819 if (elm_widget_disabled_get(data)) return;
1821 wd->matchlist_job = NULL;
1823 if (wd->matchlist_list_clicked)
1825 evas_object_hide(wd->hover);
1826 wd->matchlist_list_clicked = EINA_FALSE;
1829 text = elm_entry_entry_get(data);
1832 textlen = strlen(text);
1834 if (textlen < wd->matchlist_threshold)
1836 evas_object_hide(wd->hover);
1840 evas_object_hide(wd->hover);
1844 elm_list_clear(wd->list);
1845 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1847 if (wd->matchlist_case_sensitive)
1848 str_result = strstr(str_list, text);
1850 #ifdef HAVE_STRCASESTR
1851 str_result = strcasestr(str_list, text);
1853 str_result = _strcasestr(str_list, text);
1858 str_mkup = malloc(strlen(str_list) + 16);
1859 if (str_mkup == NULL) return;
1861 textlen = strlen(str_list) - strlen(str_result);
1862 str_front = malloc(textlen + 1);
1863 if (str_front == NULL) return;
1865 memset(str_front, 0, textlen + 1);
1866 strncpy(str_front, str_list, textlen);
1868 textlen = strlen(text);
1869 str_mid = malloc(textlen + 1);
1870 if (str_mid == NULL) return;
1872 memset(str_mid, 0, textlen + 1);
1873 strncpy(str_mid, str_list + strlen(str_front), textlen);
1875 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1877 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1879 if (str_mkup) free(str_mkup);
1880 if (str_front) free(str_front);
1881 if (str_mid) free(str_mid);
1883 textfound=EINA_TRUE;
1892 elm_list_go(wd->list);
1893 evas_object_show(wd->hover);
1894 evas_object_raise(wd->hover);
1898 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1900 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1901 Widget_Data *wd = elm_widget_data_get(data);
1902 if ((it == NULL) || (wd == NULL))
1905 const char *text = elm_list_item_label_get(it);
1906 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1911 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1912 elm_entry_cursor_end_set(data);
1913 wd->matchlist_list_clicked = EINA_TRUE;
1915 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1918 elm_widget_focus_set(data, EINA_TRUE);
1922 _entry_changed_common_handling(void *data, const char *event)
1924 Widget_Data *wd = elm_widget_data_get(data);
1925 Evas_Coord minw, minh;
1927 wd->changed = EINA_TRUE;
1928 /* Reset the size hints which are no more relevant.
1929 * Keep the height, this is a hack, but doesn't really matter
1930 * cause we'll re-eval in a moment. */
1933 evas_object_size_hint_min_get(data, &minw, &minh);
1934 evas_object_size_hint_min_set(data, minw, minh);
1938 evas_object_size_hint_min_get(data, NULL, &minh);
1939 evas_object_size_hint_min_set(data, -1, minh);
1943 if (wd->text) eina_stringshare_del(wd->text);
1945 if (wd->password_text) eina_stringshare_del(wd->password_text);
1946 wd->password_text = NULL;
1947 _check_enable_returnkey(data);
1948 if (wd->delay_write)
1950 ecore_timer_del(wd->delay_write);
1951 wd->delay_write = NULL;
1954 if ((wd->single_line) && (wd->match_list))
1956 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1957 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1960 if ((wd->api) && (wd->api->obj_hidemenu))
1961 wd->api->obj_hidemenu(data);
1963 if ((wd->autosave) && (wd->file))
1964 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1966 /* callback - this could call callbacks that delete the entry... thus...
1967 * any access to wd after this could be invalid */
1968 evas_object_smart_callback_call(data, event, NULL);
1972 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1974 Widget_Data *wd = elm_widget_data_get(data);
1977 _entry_changed_common_handling(data, SIG_CHANGED);
1981 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1983 Widget_Data *wd = elm_widget_data_get(data);
1986 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1990 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1992 Widget_Data *wd = elm_widget_data_get(data);
1995 elm_object_scroll_freeze_push(data);
1997 if ((wd->api) && (wd->api->obj_hidemenu))
1998 wd->api->obj_hidemenu(data);
2000 _magnifier_create(data);
2001 _magnifier_move(data);
2002 _magnifier_show(data);
2006 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2008 Widget_Data *wd = elm_widget_data_get(data);
2011 elm_object_scroll_freeze_pop(data);
2013 if (wd->have_selection)
2015 _magnifier_hide(data);
2021 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2023 _magnifier_move(data);
2024 _magnifier_show(data);
2027 static Evas_Object *
2028 _viewport_obj_get(Evas_Object *data)
2030 Widget_Data *wd = elm_widget_data_get(data);
2031 if (!wd) return NULL;
2033 if(!data || !strlen(elm_widget_type_get(data)))
2036 Evas_Coord x, y, w, h;
2041 //evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
2042 //printf(">>> wd->scroller (%d, %d, %d, %d) \n", x, y, w, h);
2043 return wd->scroller;
2046 Evas_Object *parent_obj = data;
2048 while(parent_obj = elm_widget_parent_get(parent_obj))
2050 //evas_object_geometry_get(parent_obj, &x, &y, &w, &h);
2051 //printf(">>> %s (%d, %d, %d, %d) \n", elm_widget_type_get(parent_obj), x, y, w, h);
2052 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
2053 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
2061 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2063 _magnifier_hide(data);
2068 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2070 Widget_Data *wd = elm_widget_data_get(data);
2074 EINA_LIST_FOREACH(entries, l, entry)
2076 if (entry != data) elm_entry_select_none(entry);
2078 wd->have_selection = EINA_TRUE;
2079 wd->selmode = EINA_TRUE;
2080 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2081 #ifdef HAVE_ELEMENTARY_X
2082 if (wd->sel_notify_handler)
2084 const char *txt = elm_entry_selection_get(data);
2087 top = elm_widget_top_get(data);
2088 if ((top) && (elm_win_xwindow_get(top)))
2089 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
2093 if (!_elm_config->desktop_entry)
2094 edje_object_part_text_viewport_object_set(wd->ent, "elm.text", _viewport_obj_get(data));
2098 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2100 Evas_Coord cx, cy, cw, ch;
2101 Widget_Data *wd = elm_widget_data_get(data);
2104 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2105 if (!wd->deferred_recalc_job)
2106 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2109 wd->deferred_cur = EINA_TRUE;
2118 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2120 Evas_Coord cx, cy, cw, ch;
2121 Widget_Data *wd = elm_widget_data_get(data);
2123 wd->have_selection = EINA_TRUE;
2124 wd->selmode = EINA_TRUE;
2125 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2126 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
2127 elm_entry_selection_get(data));
2129 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2130 if (!wd->deferred_recalc_job)
2131 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2134 wd->deferred_cur = EINA_TRUE;
2143 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2145 Widget_Data *wd = elm_widget_data_get(data);
2147 if (!wd->have_selection) return;
2148 wd->have_selection = EINA_FALSE;
2149 wd->selmode = EINA_FALSE;
2150 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2151 if (wd->sel_notify_handler)
2155 #ifdef HAVE_ELEMENTARY_X
2158 top = elm_widget_top_get(data);
2159 if ((top) && (elm_win_xwindow_get(top)))
2160 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2163 eina_stringshare_del(wd->cut_sel);
2168 #ifdef HAVE_ELEMENTARY_X
2171 top = elm_widget_top_get(data);
2172 if ((top) && (elm_win_xwindow_get(top)))
2173 elm_selection_clear(ELM_SEL_PRIMARY, data);
2178 if ((wd->api) && (wd->api->obj_hidemenu))
2180 wd->api->obj_hidemenu(data);
2185 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2187 Widget_Data *wd = elm_widget_data_get(data);
2189 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2190 if (wd->sel_notify_handler)
2192 #ifdef HAVE_ELEMENTARY_X
2195 top = elm_widget_top_get(data);
2196 if ((top) && (elm_win_xwindow_get(top)))
2198 wd->selection_asked = EINA_TRUE;
2199 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2207 _signal_entry_copy_notify(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_SELECTION_COPY, NULL);
2212 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2213 elm_entry_selection_get(data));
2217 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2219 Widget_Data *wd = elm_widget_data_get(data);
2221 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2222 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2223 elm_entry_selection_get(data));
2224 edje_object_part_text_insert(wd->ent, "elm.text", "");
2225 wd->changed = EINA_TRUE;
2230 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2232 Widget_Data *wd = elm_widget_data_get(data);
2234 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2235 wd->cur_changed = EINA_TRUE;
2236 _recalc_cursor_geometry(data);
2240 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2242 Widget_Data *wd = elm_widget_data_get(data);
2247 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2249 Widget_Data *wd = elm_widget_data_get(data);
2254 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2256 Widget_Data *wd = elm_widget_data_get(data);
2257 Elm_Entry_Anchor_Info ei;
2258 char *buf2, *p, *p2, *n;
2260 p = strrchr(emission, ',');
2263 const Eina_List *geoms;
2267 while (p2 >= emission)
2269 if (*p2 == ',') break;
2273 buf2 = alloca(5 + p - p2);
2274 strncpy(buf2, p2, p - p2);
2277 ei.button = atoi(buf2);
2278 ei.x = ei.y = ei.w = ei.h = 0;
2280 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2283 Evas_Textblock_Rectangle *r;
2285 Evas_Coord px, py, x, y;
2287 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2288 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2289 EINA_LIST_FOREACH(geoms, l, r)
2291 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2292 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2303 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2308 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2310 Widget_Data *wd = elm_widget_data_get(data);
2315 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2317 Widget_Data *wd = elm_widget_data_get(data);
2322 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2324 Widget_Data *wd = elm_widget_data_get(data);
2329 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2331 Widget_Data *wd = elm_widget_data_get(data);
2333 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2337 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2339 Widget_Data *wd = elm_widget_data_get(data);
2341 wd->double_clicked = EINA_FALSE;
2342 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2344 if ((wd->api) && (wd->api->obj_hidemenu))
2345 wd->api->obj_hidemenu(data);
2349 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2351 Widget_Data *wd = elm_widget_data_get(data);
2353 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2355 if (!_elm_config->desktop_entry && !wd->double_clicked)
2356 _cancel(data, NULL, NULL);
2360 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2362 Widget_Data *wd = elm_widget_data_get(data);
2364 wd->double_clicked = EINA_TRUE;
2365 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2368 #ifdef HAVE_ELEMENTARY_X
2370 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2372 Widget_Data *wd = elm_widget_data_get(data);
2373 Ecore_X_Event_Selection_Notify *ev = event;
2374 if (!wd) return ECORE_CALLBACK_PASS_ON;
2375 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2376 return ECORE_CALLBACK_PASS_ON;
2378 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2379 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2381 Ecore_X_Selection_Data_Text *text_data;
2383 text_data = ev->data;
2384 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2386 if (text_data->text)
2388 char *txt = _elm_util_text_to_mkup(text_data->text);
2392 elm_entry_entry_insert(data, txt);
2397 wd->selection_asked = EINA_FALSE;
2399 else if (ev->selection == ECORE_X_SELECTION_XDND)
2401 Ecore_X_Selection_Data_Text *text_data;
2403 text_data = ev->data;
2404 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2406 if (text_data->text)
2408 char *txt = _elm_util_text_to_mkup(text_data->text);
2412 /* Massive FIXME: this should be at the drag point */
2413 elm_entry_entry_insert(data, txt);
2418 wd->drag_selection_asked = EINA_FALSE;
2420 ecore_x_dnd_send_finished();
2423 return ECORE_CALLBACK_PASS_ON;
2427 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2430 Widget_Data *wd = elm_widget_data_get(data);
2431 Ecore_X_Event_Selection_Clear *ev = event;
2432 if (!wd) return ECORE_CALLBACK_PASS_ON;
2433 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2434 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2435 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2437 elm_entry_select_none(data);
2442 Evas_Object *top = elm_widget_top_get(data);
2443 Ecore_X_Event_Selection_Clear *ev = event;
2446 return ECORE_CALLBACK_PASS_ON;
2448 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2450 return ECORE_CALLBACK_PASS_ON;
2453 if (cnpwidgetdata == data)
2455 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2456 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2460 return ECORE_CALLBACK_PASS_ON;
2464 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2469 wd = elm_widget_data_get(obj);
2470 if (!wd) return EINA_FALSE;
2471 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2473 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2474 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2475 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2476 EDJE_CURSOR_MAIN,drop->x,drop->y);
2477 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2478 elm_entry_entry_insert(obj, drop->data);
2479 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2480 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2486 static Evas_Object *
2487 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2489 Widget_Data *wd = elm_widget_data_get(data);
2492 Elm_Entry_Item_Provider *ip;
2494 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2496 o = ip->func(ip->data, data, item);
2499 if (!strncmp(item, "file://", 7))
2501 const char *fname = item + 7;
2503 o = evas_object_image_filled_add(evas_object_evas_get(data));
2504 evas_object_image_file_set(o, fname, NULL);
2505 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2507 evas_object_show(o);
2512 o = edje_object_add(evas_object_evas_get(data));
2513 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2517 o = edje_object_add(evas_object_evas_get(data));
2518 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2519 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2524 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2526 const char *srcstring = NULL;
2527 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2528 char *curlocater, *replocater;
2529 char *starttag, *endtag;
2530 int tagtxtlen = 0, insertflag = 0;
2532 srcstring = eina_strbuf_string_get(srcbuf);
2533 curlocater = strstr(srcstring, key);
2535 if (!curlocater || !srcstring)
2543 starttag = strchr(srcstring, '<');
2544 endtag = strchr(srcstring, '>');
2545 tagtxtlen = endtag - starttag;
2546 if (tagtxtlen <= 0) tagtxtlen = 0;
2547 if (starttag < curlocater && curlocater < endtag) break;
2548 if (endtag != NULL && endtag+1 != NULL)
2549 srcstring = endtag+1;
2552 } while (strlen(srcstring) > 1);
2554 if (starttag && endtag && tagtxtlen > strlen(key))
2556 repbuf = eina_strbuf_new();
2557 diffbuf = eina_strbuf_new();
2558 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2559 srcstring = eina_strbuf_string_get(repbuf);
2560 curlocater = strstr(srcstring, key);
2562 if (curlocater != NULL)
2564 replocater = curlocater + strlen(key) + 1;
2566 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2569 if (replocater-curlocater > strlen(key)+1)
2571 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2580 eina_strbuf_reset(repbuf);
2588 if (repbuf == NULL) repbuf = eina_strbuf_new();
2589 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2593 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2594 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2600 eina_strbuf_prepend(diffbuf, "<");
2601 eina_strbuf_append(diffbuf, ">");
2602 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2606 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2607 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2611 if (repbuf) eina_strbuf_free(repbuf);
2612 if (diffbuf) eina_strbuf_free(diffbuf);
2618 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2620 Eina_Strbuf *sharebuf = NULL;
2622 sharebuf = eina_strbuf_new();
2623 eina_strbuf_append(sharebuf, *srcstring);
2624 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2625 eina_stringshare_del(*srcstring);
2626 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2627 eina_strbuf_free(sharebuf);
2633 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2635 Widget_Data *wd = elm_widget_data_get(data);
2637 Elm_Entry_Text_Filter *tf;
2639 if (type == EDJE_TEXT_FILTER_FORMAT)
2642 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2644 tf->func(tf->data, data, text);
2650 /* This function is used to insert text by chunks in jobs */
2652 _text_append_idler(void *data)
2656 Evas_Object *obj = (Evas_Object *) data;
2657 Widget_Data *wd = elm_widget_data_get(obj);
2658 if (wd->text) eina_stringshare_del(wd->text);
2660 if (wd->password_text) eina_stringshare_del(wd->password_text);
2661 wd->password_text = NULL;
2662 wd->changed = EINA_TRUE;
2664 start = wd->append_text_position;
2665 if (start + _CHUNK_SIZE < wd->append_text_len)
2668 int tag_start, esc_start;
2670 tag_start = esc_start = -1;
2671 /* Find proper markup cut place */
2672 while (pos - start < _CHUNK_SIZE)
2676 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2677 if (esc_start == -1)
2680 tag_start = prev_pos;
2681 else if (tmp == '>')
2684 else if (tag_start == -1)
2687 esc_start = prev_pos;
2688 else if (tmp == ';')
2695 wd->append_text_position = tag_start;
2697 else if (esc_start >= 0)
2699 wd->append_text_position = esc_start;
2703 wd->append_text_position = pos;
2708 wd->append_text_position = wd->append_text_len;
2711 backup = wd->append_text_left[wd->append_text_position];
2712 wd->append_text_left[wd->append_text_position] = '\0';
2714 edje_object_part_text_append(wd->ent, "elm.text",
2715 wd->append_text_left + start);
2717 wd->append_text_left[wd->append_text_position] = backup;
2719 /* If there's still more to go, renew the idler, else, cleanup */
2720 if (wd->append_text_position < wd->append_text_len)
2722 return ECORE_CALLBACK_RENEW;
2726 free(wd->append_text_left);
2727 wd->append_text_left = NULL;
2728 wd->append_text_idler = NULL;
2729 return ECORE_CALLBACK_CANCEL;
2734 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2736 int i = 0, unit_size;
2737 int current_len = strlen(*text);
2738 char *new_text = *text;
2739 if (unit >= LENGTH_UNIT_LAST) return;
2742 if (*new_text == '<')
2744 while (*new_text != '>')
2747 if (!*new_text) break;
2754 if (*new_text == '&')
2756 while (*(new_text + index) != ';')
2759 if (!*(new_text + index)) break;
2763 index = evas_string_char_next_get(new_text, index, NULL);
2764 markup = malloc(index + 1);
2765 strncpy(markup, new_text, index);
2767 if (unit == LENGTH_UNIT_BYTE)
2768 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2769 else if (unit == LENGTH_UNIT_CHAR)
2770 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2776 if (can_add < unit_size)
2780 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2786 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2787 current_len -= index;
2788 (*text)[current_len] = 0;
2793 can_add -= unit_size;
2798 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2802 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2805 ELM_CHECK_WIDTYPE(obj, widtype);
2806 Widget_Data *wd = elm_widget_data_get(obj);
2808 if (!entry) entry = "";
2809 if (item && strcmp(item, "default"))
2811 edje_object_part_text_set(wd->ent, item, entry);
2814 if (wd->text) eina_stringshare_del(wd->text);
2816 if (wd->password_text) eina_stringshare_del(wd->password_text);
2817 wd->password_text = NULL;
2818 wd->changed = EINA_TRUE;
2820 /* Clear currently pending job if there is one */
2821 if (wd->append_text_idler)
2823 ecore_idler_del(wd->append_text_idler);
2824 free(wd->append_text_left);
2825 wd->append_text_left = NULL;
2826 wd->append_text_idler = NULL;
2829 len = strlen(entry);
2830 /* Split to ~_CHUNK_SIZE chunks */
2831 if (len > _CHUNK_SIZE)
2833 wd->append_text_left = (char *) malloc(len + 1);
2836 /* If we decided to use the idler */
2837 if (wd->append_text_left)
2839 /* Need to clear the entry first */
2840 edje_object_part_text_set(wd->ent, "elm.text", "");
2841 memcpy(wd->append_text_left, entry, len + 1);
2842 wd->append_text_position = 0;
2843 wd->append_text_len = len;
2844 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2848 edje_object_part_text_set(wd->ent, "elm.text", entry);
2853 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2855 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2856 Widget_Data *wd = elm_widget_data_get(obj);
2857 if (item && strcmp(item, "default")) return NULL;
2859 if (!wd) return NULL;
2862 if(wd->password_text) return wd->password_text;
2868 text = edje_object_part_text_get(wd->ent, "elm.text");
2871 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2874 eina_stringshare_replace(&wd->text, text);
2877 const char *pw_text;
2878 pw_text = elm_entry_markup_to_utf8(wd->text);
2881 eina_stringshare_replace(&wd->password_text, pw_text);
2883 return wd->password_text;
2890 * This adds an entry to @p parent object.
2892 * @param parent The parent object
2893 * @return The new object or NULL if it cannot be created
2898 elm_entry_add(Evas_Object *parent)
2900 Evas_Object *obj, *top;
2904 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2906 ELM_SET_WIDTYPE(widtype, "entry");
2907 elm_widget_type_set(obj, "entry");
2908 elm_widget_sub_object_add(parent, obj);
2909 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2910 elm_widget_data_set(obj, wd);
2911 elm_widget_del_hook_set(obj, _del_hook);
2912 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2913 elm_widget_theme_hook_set(obj, _theme_hook);
2914 elm_widget_disable_hook_set(obj, _disable_hook);
2915 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2916 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2917 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2918 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2919 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2920 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2921 elm_widget_can_focus_set(obj, EINA_TRUE);
2922 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2923 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2924 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2925 elm_widget_content_set_hook_set(obj, _content_set_hook);
2926 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2927 elm_widget_content_get_hook_set(obj, _content_get_hook);
2929 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2930 wd->scroller = elm_smart_scroller_add(e);
2931 elm_widget_sub_object_add(obj, wd->scroller);
2932 elm_smart_scroller_widget_set(wd->scroller, obj);
2933 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2934 elm_widget_style_get(obj));
2935 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2936 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2937 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2938 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2940 wd->linewrap = ELM_WRAP_WORD;
2941 wd->editable = EINA_TRUE;
2942 wd->disabled = EINA_FALSE;
2943 wd->context_menu = EINA_TRUE;
2944 wd->autosave = EINA_TRUE;
2945 wd->textonly = EINA_FALSE;
2946 wd->autoperiod = EINA_TRUE;
2948 wd->ent = edje_object_add(e);
2949 elm_widget_sub_object_add(obj, wd->ent);
2950 edje_object_item_provider_set(wd->ent, _get_item, obj);
2951 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2952 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2953 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2955 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2957 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2959 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2961 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2962 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2963 _signal_entry_changed, obj);
2964 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2965 _signal_preedit_changed, obj);
2966 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2967 _signal_handler_move_start, obj);
2968 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2969 _signal_handler_move_end, obj);
2970 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2971 _signal_handler_moving, obj);
2972 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2973 _signal_selection_start, obj);
2974 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2975 _signal_selection_end, obj);
2976 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
2977 _signal_long_pressed, obj);
2978 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2979 _signal_magnifier_changed, obj);
2980 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2981 _signal_selection_changed, obj);
2982 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2983 _signal_selection_cleared, obj);
2984 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2985 _signal_entry_paste_request, obj);
2986 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2987 _signal_entry_copy_notify, obj);
2988 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2989 _signal_entry_cut_notify, obj);
2990 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2991 _signal_cursor_changed, obj);
2992 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2993 _signal_anchor_down, obj);
2994 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2995 _signal_anchor_up, obj);
2996 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2997 _signal_anchor_clicked, obj);
2998 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2999 _signal_anchor_move, obj);
3000 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
3001 _signal_anchor_in, obj);
3002 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
3003 _signal_anchor_out, obj);
3004 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
3005 _signal_key_enter, obj);
3006 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
3007 _signal_mouse_down, obj);
3008 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
3009 _signal_mouse_clicked, obj);
3010 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
3011 _signal_mouse_double, obj);
3012 edje_object_part_text_set(wd->ent, "elm.text", "");
3013 if (_elm_config->desktop_entry)
3014 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
3015 elm_widget_resize_object_set(obj, wd->ent);
3018 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
3020 #ifdef HAVE_ELEMENTARY_X
3021 top = elm_widget_top_get(obj);
3022 if ((top) && (elm_win_xwindow_get(top)))
3024 wd->sel_notify_handler =
3025 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
3026 _event_selection_notify, obj);
3027 wd->sel_clear_handler =
3028 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
3029 _event_selection_clear, obj);
3032 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3033 _drag_drop_cb, NULL);
3036 entries = eina_list_prepend(entries, obj);
3038 // module - find module for entry
3039 wd->api = _module(obj);
3040 // if found - hook in
3041 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
3043 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3044 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3045 // TODO: and save some bytes, making descriptions per-class and not instance!
3046 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3050 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
3052 ELM_CHECK_WIDTYPE(obj, widtype);
3053 Widget_Data *wd = elm_widget_data_get(obj);
3055 ext_mod->cancel = _cancel;
3056 ext_mod->copy = _copy;
3057 ext_mod->cut = _cut;
3058 ext_mod->paste = _paste;
3059 ext_mod->select = _select;
3060 ext_mod->selectall = _selectall;
3061 ext_mod->ent = wd->ent;
3062 ext_mod->viewport_obj = _viewport_obj_get(obj);
3063 ext_mod->items = wd->items;
3064 ext_mod->editable = wd->editable;
3065 ext_mod->have_selection = wd->have_selection;
3066 ext_mod->password = wd->password;
3067 ext_mod->selmode = wd->selmode;
3068 ext_mod->cnpinit = _cnpinit;
3069 ext_mod->context_menu = wd->context_menu;
3070 ext_mod->textonly = wd->textonly;
3074 * This sets the entry object not to line wrap. All input will
3075 * be on a single line, and the entry box will extend with user input.
3077 * @param obj The entry object
3078 * @param single_line If true, the text in the entry
3079 * will be on a single line.
3084 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
3086 ELM_CHECK_WIDTYPE(obj, widtype);
3087 Widget_Data *wd = elm_widget_data_get(obj);
3089 if (wd->single_line == single_line) return;
3090 wd->single_line = single_line;
3091 wd->linewrap = ELM_WRAP_NONE;
3092 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
3096 if (wd->single_line)
3098 elm_smart_scroller_policy_set(wd->scroller,
3099 ELM_SMART_SCROLLER_POLICY_OFF,
3100 ELM_SMART_SCROLLER_POLICY_OFF);
3101 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3105 const Elm_Scroller_Policy map[3] =
3107 ELM_SMART_SCROLLER_POLICY_AUTO,
3108 ELM_SMART_SCROLLER_POLICY_ON,
3109 ELM_SMART_SCROLLER_POLICY_OFF
3111 elm_smart_scroller_policy_set(wd->scroller,
3114 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3121 * This returns true if the entry has been set to single line mode.
3122 * See also elm_entry_single_line_set().
3124 * @param obj The entry object
3125 * @return single_line If true, the text in the entry is set to display
3131 elm_entry_single_line_get(const Evas_Object *obj)
3133 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3134 Widget_Data *wd = elm_widget_data_get(obj);
3135 if (!wd) return EINA_FALSE;
3136 return wd->single_line;
3140 * This sets the entry object to password mode. All text entered
3141 * and/or displayed within the widget will be replaced with asterisks (*).
3143 * @param obj The entry object
3144 * @param password If true, password mode is enabled.
3149 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3151 ELM_CHECK_WIDTYPE(obj, widtype);
3152 Widget_Data *wd = elm_widget_data_get(obj);
3154 if (wd->password == password) return;
3155 wd->password = password;
3156 wd->single_line = EINA_TRUE;
3157 wd->linewrap = ELM_WRAP_NONE;
3162 * This returns whether password mode is enabled.
3163 * See also elm_entry_password_set().
3165 * @param obj The entry object
3166 * @return If true, the entry is set to display all characters
3172 elm_entry_password_get(const Evas_Object *obj)
3174 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3175 Widget_Data *wd = elm_widget_data_get(obj);
3176 if (!wd) return EINA_FALSE;
3177 return wd->password;
3181 * This sets the text displayed within the entry to @p entry.
3183 * @param obj The entry object
3184 * @param entry The text to be displayed
3189 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3191 _elm_entry_text_set(obj, NULL, entry);
3195 * This appends @p entry to the text of the entry.
3197 * @param obj The entry object
3198 * @param entry The text to be displayed
3203 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3206 ELM_CHECK_WIDTYPE(obj, widtype);
3207 Widget_Data *wd = elm_widget_data_get(obj);
3209 if (!entry) entry = "";
3210 wd->changed = EINA_TRUE;
3212 len = strlen(entry);
3213 if (wd->append_text_left)
3216 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3222 wd->append_text_left = tmpbuf;
3223 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3224 wd->append_text_len += len;
3228 /* FIXME: Add chunked appending here (like in entry_set) */
3229 edje_object_part_text_append(wd->ent, "elm.text", entry);
3234 * This returns the text currently shown in object @p entry.
3235 * See also elm_entry_entry_set().
3237 * @param obj The entry object
3238 * @return The currently displayed text or NULL on failure
3243 elm_entry_entry_get(const Evas_Object *obj)
3245 return _elm_entry_text_get(obj, NULL);
3249 * This returns EINA_TRUE if the entry is empty/there was an error
3250 * and EINA_FALSE if it is not empty.
3252 * @param obj The entry object
3253 * @return If the entry is empty or not.
3258 elm_entry_is_empty(const Evas_Object *obj)
3260 /* FIXME: until there's support for that in textblock, we just check
3261 * to see if the there is text or not. */
3262 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3263 Widget_Data *wd = elm_widget_data_get(obj);
3264 const Evas_Object *tb;
3265 //Evas_Textblock_Cursor *cur;
3267 if (!wd) return EINA_TRUE;
3270 /* It's a hack until we get the support suggested above.
3271 * We just create a cursor, point it to the begining, and then
3272 * try to advance it, if it can advance, the tb is not empty,
3273 * otherwise it is. */
3274 tb = edje_object_part_object_get(wd->ent, "elm.text");
3275 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3276 actually, ok for the time being, thsese hackish stuff will be removed
3277 once evas 1.0 is out*/
3278 evas_textblock_cursor_pos_set(cur, 0);
3279 ret = evas_textblock_cursor_char_next(cur);
3280 evas_textblock_cursor_free(cur);
3285 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3286 if (!str) return EINA_TRUE;
3288 ret = (strlen(str) == 0);
3294 * This returns all selected text within the entry.
3296 * @param obj The entry object
3297 * @return The selected text within the entry or NULL on failure
3302 elm_entry_selection_get(const Evas_Object *obj)
3304 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3305 Widget_Data *wd = elm_widget_data_get(obj);
3306 if (!wd) return NULL;
3307 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3311 * This inserts text in @p entry where the current cursor position.
3313 * This inserts text at the cursor position is as if it was typed
3314 * by the user (note this also allows markup which a user
3315 * can't just "type" as it would be converted to escaped text, so this
3316 * call can be used to insert things like emoticon items or bold push/pop
3317 * tags, other font and color change tags etc.)
3319 * @param obj The entry object
3320 * @param entry The text to insert
3325 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3327 ELM_CHECK_WIDTYPE(obj, widtype);
3328 Widget_Data *wd = elm_widget_data_get(obj);
3330 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3332 #ifdef HAVE_ELEMENTARY_X
3333 if (cnpwidgetdata == obj)
3334 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3337 wd->changed = EINA_TRUE;
3342 * This enables word line wrapping in the entry object. It is the opposite
3343 * of elm_entry_single_line_set(). Additionally, setting this disables
3344 * character line wrapping.
3346 * @param obj The entry object
3347 * @param wrap If true, the entry will be wrapped once it reaches the end
3348 * of the object. Wrapping will occur at the end of the word before the end of the
3354 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3356 ELM_CHECK_WIDTYPE(obj, widtype);
3357 Widget_Data *wd = elm_widget_data_get(obj);
3359 if (wd->linewrap == wrap) return;
3361 wd->linewrap = wrap;
3366 * Get the wrapping behavior of the entry.
3367 * See also elm_entry_line_wrap_set().
3369 * @param obj The entry object
3375 elm_entry_line_wrap_get(const Evas_Object *obj)
3377 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3378 Widget_Data *wd = elm_widget_data_get(obj);
3379 if (!wd) return EINA_FALSE;
3380 return wd->linewrap;
3384 * This sets the editable attribute of the entry.
3386 * @param obj The entry object
3387 * @param editable If true, the entry will be editable by the user.
3388 * If false, it will be set to the disabled state.
3393 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3395 ELM_CHECK_WIDTYPE(obj, widtype);
3396 Widget_Data *wd = elm_widget_data_get(obj);
3398 if (wd->editable == editable) return;
3399 wd->editable = editable;
3402 #ifdef HAVE_ELEMENTARY_X
3404 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3406 elm_drop_target_del(obj);
3411 * This gets the editable attribute of the entry.
3412 * See also elm_entry_editable_set().
3414 * @param obj The entry object
3415 * @return If true, the entry is editable by the user.
3416 * If false, it is not editable by the user
3421 elm_entry_editable_get(const Evas_Object *obj)
3423 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3424 Widget_Data *wd = elm_widget_data_get(obj);
3425 if (!wd) return EINA_FALSE;
3426 return wd->editable;
3430 * This drops any existing text selection within the entry.
3432 * @param obj The entry object
3437 elm_entry_select_none(Evas_Object *obj)
3439 ELM_CHECK_WIDTYPE(obj, widtype);
3440 Widget_Data *wd = elm_widget_data_get(obj);
3444 wd->selmode = EINA_FALSE;
3445 if (!_elm_config->desktop_entry)
3446 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3447 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3449 wd->have_selection = EINA_FALSE;
3450 edje_object_part_text_select_none(wd->ent, "elm.text");
3454 * This selects all text within the entry.
3456 * @param obj The entry object
3461 elm_entry_select_all(Evas_Object *obj)
3463 ELM_CHECK_WIDTYPE(obj, widtype);
3464 Widget_Data *wd = elm_widget_data_get(obj);
3468 wd->selmode = EINA_FALSE;
3469 if (!_elm_config->desktop_entry)
3470 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3471 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3473 wd->have_selection = EINA_TRUE;
3474 edje_object_part_text_select_all(wd->ent, "elm.text");
3478 * This function returns the geometry of the cursor.
3480 * It's useful if you want to draw something on the cursor (or where it is),
3481 * or for example in the case of scrolled entry where you want to show the
3484 * @param obj The entry object
3485 * @param x returned geometry
3486 * @param y returned geometry
3487 * @param w returned geometry
3488 * @param h returned geometry
3489 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3494 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3496 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3497 Widget_Data *wd = elm_widget_data_get(obj);
3498 if (!wd) return EINA_FALSE;
3499 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3504 * This moves the cursor one place to the right within the entry.
3506 * @param obj The entry object
3507 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3512 elm_entry_cursor_next(Evas_Object *obj)
3514 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3515 Widget_Data *wd = elm_widget_data_get(obj);
3516 if (!wd) return EINA_FALSE;
3517 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3521 * This moves the cursor one place to the left within the entry.
3523 * @param obj The entry object
3524 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3529 elm_entry_cursor_prev(Evas_Object *obj)
3531 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3532 Widget_Data *wd = elm_widget_data_get(obj);
3533 if (!wd) return EINA_FALSE;
3534 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3538 * This moves the cursor one line up within the entry.
3540 * @param obj The entry object
3541 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3546 elm_entry_cursor_up(Evas_Object *obj)
3548 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3549 Widget_Data *wd = elm_widget_data_get(obj);
3550 if (!wd) return EINA_FALSE;
3551 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3555 * This moves the cursor one line down within the entry.
3557 * @param obj The entry object
3558 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3563 elm_entry_cursor_down(Evas_Object *obj)
3565 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3566 Widget_Data *wd = elm_widget_data_get(obj);
3567 if (!wd) return EINA_FALSE;
3568 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3572 * This moves the cursor to the beginning of the entry.
3574 * @param obj The entry object
3579 elm_entry_cursor_begin_set(Evas_Object *obj)
3581 ELM_CHECK_WIDTYPE(obj, widtype);
3582 Widget_Data *wd = elm_widget_data_get(obj);
3584 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3588 * This moves the cursor to the end of the entry.
3590 * @param obj The entry object
3595 elm_entry_cursor_end_set(Evas_Object *obj)
3597 ELM_CHECK_WIDTYPE(obj, widtype);
3598 Widget_Data *wd = elm_widget_data_get(obj);
3601 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3604 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3605 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3610 * This moves the cursor to the beginning of the current line.
3612 * @param obj The entry object
3617 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3619 ELM_CHECK_WIDTYPE(obj, widtype);
3620 Widget_Data *wd = elm_widget_data_get(obj);
3622 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3626 * This moves the cursor to the end of the current line.
3628 * @param obj The entry object
3633 elm_entry_cursor_line_end_set(Evas_Object *obj)
3635 ELM_CHECK_WIDTYPE(obj, widtype);
3636 Widget_Data *wd = elm_widget_data_get(obj);
3638 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3642 * This begins a selection within the entry as though
3643 * the user were holding down the mouse button to make a selection.
3645 * @param obj The entry object
3650 elm_entry_cursor_selection_begin(Evas_Object *obj)
3652 ELM_CHECK_WIDTYPE(obj, widtype);
3653 Widget_Data *wd = elm_widget_data_get(obj);
3655 edje_object_part_text_select_begin(wd->ent, "elm.text");
3659 * This ends a selection within the entry as though
3660 * the user had just released the mouse button while making a selection.
3662 * @param obj The entry object
3667 elm_entry_cursor_selection_end(Evas_Object *obj)
3669 ELM_CHECK_WIDTYPE(obj, widtype);
3670 Widget_Data *wd = elm_widget_data_get(obj);
3672 edje_object_part_text_select_extend(wd->ent, "elm.text");
3676 * TODO: fill this in
3678 * @param obj The entry object
3679 * @return TODO: fill this in
3684 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3686 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3687 Widget_Data *wd = elm_widget_data_get(obj);
3688 if (!wd) return EINA_FALSE;
3689 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3693 * This returns whether the cursor is visible.
3695 * @param obj The entry object
3696 * @return If true, the cursor is visible.
3701 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3703 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3704 Widget_Data *wd = elm_widget_data_get(obj);
3705 if (!wd) return EINA_FALSE;
3706 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3710 * TODO: fill this in
3712 * @param obj The entry object
3713 * @return TODO: fill this in
3718 elm_entry_cursor_content_get(const Evas_Object *obj)
3720 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3721 Widget_Data *wd = elm_widget_data_get(obj);
3722 if (!wd) return NULL;
3723 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3727 * Sets the cursor position in the entry to the given value
3729 * @param obj The entry object
3730 * @param pos The position of the cursor
3735 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3737 ELM_CHECK_WIDTYPE(obj, widtype);
3738 Widget_Data *wd = elm_widget_data_get(obj);
3740 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3741 edje_object_message_signal_process(wd->ent);
3745 * Retrieves the current position of the cursor in the entry
3747 * @param obj The entry object
3748 * @return The cursor position
3753 elm_entry_cursor_pos_get(const Evas_Object *obj)
3755 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3756 Widget_Data *wd = elm_widget_data_get(obj);
3758 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3762 * This executes a "cut" action on the selected text in the entry.
3764 * @param obj The entry object
3769 elm_entry_selection_cut(Evas_Object *obj)
3771 ELM_CHECK_WIDTYPE(obj, widtype);
3772 Widget_Data *wd = elm_widget_data_get(obj);
3774 _cut(obj, NULL, NULL);
3778 * This executes a "copy" action on the selected text in the entry.
3780 * @param obj The entry object
3785 elm_entry_selection_copy(Evas_Object *obj)
3787 ELM_CHECK_WIDTYPE(obj, widtype);
3788 Widget_Data *wd = elm_widget_data_get(obj);
3790 _copy(obj, NULL, NULL);
3794 * This executes a "paste" action in the entry.
3796 * @param obj The entry object
3801 elm_entry_selection_paste(Evas_Object *obj)
3803 ELM_CHECK_WIDTYPE(obj, widtype);
3804 Widget_Data *wd = elm_widget_data_get(obj);
3806 _paste(obj, NULL, NULL);
3810 * This clears and frees the items in a entry's contextual (right click) menu.
3812 * @param obj The entry object
3817 elm_entry_context_menu_clear(Evas_Object *obj)
3819 ELM_CHECK_WIDTYPE(obj, widtype);
3820 Widget_Data *wd = elm_widget_data_get(obj);
3821 Elm_Entry_Context_Menu_Item *it;
3823 EINA_LIST_FREE(wd->items, it)
3825 eina_stringshare_del(it->label);
3826 eina_stringshare_del(it->icon_file);
3827 eina_stringshare_del(it->icon_group);
3833 * This adds an item to the entry's contextual menu.
3835 * @param obj The entry object
3836 * @param label The item's text label
3837 * @param icon_file The item's icon file
3838 * @param icon_type The item's icon type
3839 * @param func The callback to execute when the item is clicked
3840 * @param data The data to associate with the item for related functions
3845 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)
3847 ELM_CHECK_WIDTYPE(obj, widtype);
3848 Widget_Data *wd = elm_widget_data_get(obj);
3849 Elm_Entry_Context_Menu_Item *it;
3851 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3853 wd->items = eina_list_append(wd->items, it);
3855 it->label = eina_stringshare_add(label);
3856 it->icon_file = eina_stringshare_add(icon_file);
3857 it->icon_type = icon_type;
3859 it->data = (void *)data;
3863 * This disables the entry's contextual (right click) menu.
3865 * @param obj The entry object
3866 * @param disabled If true, the menu is disabled
3871 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3873 ELM_CHECK_WIDTYPE(obj, widtype);
3874 Widget_Data *wd = elm_widget_data_get(obj);
3876 if (wd->context_menu == !disabled) return;
3877 wd->context_menu = !disabled;
3881 * This returns whether the entry's contextual (right click) menu is disabled.
3883 * @param obj The entry object
3884 * @return If true, the menu is disabled
3889 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3891 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3892 Widget_Data *wd = elm_widget_data_get(obj);
3893 if (!wd) return EINA_FALSE;
3894 return !wd->context_menu;
3898 * This appends a custom item provider to the list for that entry
3900 * This appends the given callback. The list is walked from beginning to end
3901 * with each function called given the item href string in the text. If the
3902 * function returns an object handle other than NULL (it should create an
3903 * and object to do this), then this object is used to replace that item. If
3904 * not the next provider is called until one provides an item object, or the
3905 * default provider in entry does.
3907 * @param obj The entry object
3908 * @param func The function called to provide the item object
3909 * @param data The data passed to @p func
3914 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3916 ELM_CHECK_WIDTYPE(obj, widtype);
3917 Widget_Data *wd = elm_widget_data_get(obj);
3919 EINA_SAFETY_ON_NULL_RETURN(func);
3920 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3924 wd->item_providers = eina_list_append(wd->item_providers, ip);
3928 * This prepends a custom item provider to the list for that entry
3930 * This prepends the given callback. See elm_entry_item_provider_append() for
3933 * @param obj The entry object
3934 * @param func The function called to provide the item object
3935 * @param data The data passed to @p func
3940 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3942 ELM_CHECK_WIDTYPE(obj, widtype);
3943 Widget_Data *wd = elm_widget_data_get(obj);
3945 EINA_SAFETY_ON_NULL_RETURN(func);
3946 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3950 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3954 * This removes a custom item provider to the list for that entry
3956 * This removes the given callback. See elm_entry_item_provider_append() for
3959 * @param obj The entry object
3960 * @param func The function called to provide the item object
3961 * @param data The data passed to @p func
3966 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3968 ELM_CHECK_WIDTYPE(obj, widtype);
3969 Widget_Data *wd = elm_widget_data_get(obj);
3971 Elm_Entry_Item_Provider *ip;
3973 EINA_SAFETY_ON_NULL_RETURN(func);
3974 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3976 if ((ip->func == func) && ((!data) || (ip->data == data)))
3978 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3986 * Append a filter function for text inserted in the entry
3988 * Append the given callback to the list. This functions will be called
3989 * whenever any text is inserted into the entry, with the text to be inserted
3990 * as a parameter. The callback function is free to alter the text in any way
3991 * it wants, but it must remember to free the given pointer and update it.
3992 * If the new text is to be discarded, the function can free it and set it text
3993 * parameter to NULL. This will also prevent any following filters from being
3996 * @param obj The entry object
3997 * @param func The function to use as text filter
3998 * @param data User data to pass to @p func
4003 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4006 Elm_Entry_Text_Filter *tf;
4007 ELM_CHECK_WIDTYPE(obj, widtype);
4009 wd = elm_widget_data_get(obj);
4011 EINA_SAFETY_ON_NULL_RETURN(func);
4013 tf = _filter_new(func, data);
4016 wd->text_filters = eina_list_append(wd->text_filters, tf);
4020 * Prepend a filter function for text insdrted in the entry
4022 * Prepend the given callback to the list. See elm_entry_text_filter_append()
4023 * for more information
4025 * @param obj The entry object
4026 * @param func The function to use as text filter
4027 * @param data User data to pass to @p func
4032 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4035 Elm_Entry_Text_Filter *tf;
4036 ELM_CHECK_WIDTYPE(obj, widtype);
4038 wd = elm_widget_data_get(obj);
4040 EINA_SAFETY_ON_NULL_RETURN(func);
4042 tf = _filter_new(func, data);
4045 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
4049 * Remove a filter from the list
4051 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
4052 * for more information.
4054 * @param obj The entry object
4055 * @param func The filter function to remove
4056 * @param data The user data passed when adding the function
4061 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4065 Elm_Entry_Text_Filter *tf;
4066 ELM_CHECK_WIDTYPE(obj, widtype);
4068 wd = elm_widget_data_get(obj);
4070 EINA_SAFETY_ON_NULL_RETURN(func);
4072 EINA_LIST_FOREACH(wd->text_filters, l, tf)
4074 if ((tf->func == func) && ((!data) || (tf->data == data)))
4076 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
4084 * This converts a markup (HTML-like) string into UTF-8.
4085 * Returning string is obtained with malloc.
4086 * After use the returned string, it should be freed.
4088 * @param s The string (in markup) to be converted
4089 * @return The converted string (in UTF-8). It should be freed.
4094 elm_entry_markup_to_utf8(const char *s)
4096 char *ss = _elm_util_mkup_to_text(s);
4097 if (!ss) ss = strdup("");
4102 * This converts a UTF-8 string into markup (HTML-like).
4103 * Returning string is obtained with malloc.
4104 * After use the returned string, it should be freed.
4106 * @param s The string (in UTF-8) to be converted
4107 * @return The converted string (in markup). It should be freed.
4112 elm_entry_utf8_to_markup(const char *s)
4114 char *ss = _elm_util_text_to_mkup(s);
4115 if (!ss) ss = strdup("");
4120 * Filter inserted text based on user defined character and byte limits
4122 * Add this filter to an entry to limit the characters that it will accept
4123 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
4124 * The funtion works on the UTF-8 representation of the string, converting
4125 * it from the set markup, thus not accounting for any format in it.
4127 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
4128 * it as data when setting the filter. In it it's possible to set limits
4129 * by character count or bytes (any of them is disabled if 0), and both can
4130 * be set at the same time. In that case, it first checks for characters,
4133 * The function will cut the inserted text in order to allow only the first
4134 * number of characters that are still allowed. The cut is made in
4135 * characters, even when limiting by bytes, in order to always contain
4136 * valid ones and avoid half unicode characters making it in.
4141 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4143 Elm_Entry_Filter_Limit_Size *lim = data;
4146 const char *(*text_get)(const Evas_Object *);
4147 const char *widget_type;
4149 EINA_SAFETY_ON_NULL_RETURN(data);
4150 EINA_SAFETY_ON_NULL_RETURN(entry);
4151 EINA_SAFETY_ON_NULL_RETURN(text);
4153 /* hack. I don't want to copy the entire function to work with
4155 widget_type = elm_widget_type_get(entry);
4156 if (!strcmp(widget_type, "entry"))
4157 text_get = elm_entry_entry_get;
4161 current = elm_entry_markup_to_utf8(text_get(entry));
4163 if (lim->max_char_count > 0)
4165 len = evas_string_char_len_get(current);
4166 if (len >= lim->max_char_count)
4168 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4174 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4175 if ((len + newlen) > lim->max_char_count)
4176 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4178 else if (lim->max_byte_count > 0)
4180 len = strlen(current);
4181 if (len >= lim->max_byte_count)
4183 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4189 newlen = strlen(elm_entry_markup_to_utf8(*text));
4190 if ((len + newlen) > lim->max_byte_count)
4191 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4197 * Filter inserted text based on accepted or rejected sets of characters
4199 * Add this filter to an entry to restrict the set of accepted characters
4200 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4201 * This structure contains both accepted and rejected sets, but they are
4202 * mutually exclusive. If accepted is set, it will be used, otherwise it
4203 * goes on to the rejected set.
4206 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4208 Elm_Entry_Filter_Accept_Set *as = data;
4212 int read_idx, last_read_idx = 0, read_char;
4214 EINA_SAFETY_ON_NULL_RETURN(data);
4215 EINA_SAFETY_ON_NULL_RETURN(text);
4217 if ((!as->accepted) && (!as->rejected))
4223 goes_in = EINA_TRUE;
4228 goes_in = EINA_FALSE;
4232 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4235 int cmp_idx, cmp_char;
4236 Eina_Bool in_set = EINA_FALSE;
4238 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4241 if (read_char == cmp_char)
4246 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4248 if (in_set == goes_in)
4250 int size = read_idx - last_read_idx;
4251 const char *src = (*text) + last_read_idx;
4253 memcpy(insert, *text + last_read_idx, size);
4256 last_read_idx = read_idx;
4257 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4263 * This sets the file (and implicitly loads it) for the text to display and
4264 * then edit. All changes are written back to the file after a short delay if
4265 * the entry object is set to autosave.
4267 * @param obj The entry object
4268 * @param file The path to the file to load and save
4269 * @param format The file format
4274 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4276 ELM_CHECK_WIDTYPE(obj, widtype);
4277 Widget_Data *wd = elm_widget_data_get(obj);
4279 if (wd->delay_write)
4281 ecore_timer_del(wd->delay_write);
4282 wd->delay_write = NULL;
4284 if (wd->autosave) _save(obj);
4285 eina_stringshare_replace(&wd->file, file);
4286 wd->format = format;
4291 * Gets the file to load and save and the file format
4293 * @param obj The entry object
4294 * @param file The path to the file to load and save
4295 * @param format The file format
4300 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4302 ELM_CHECK_WIDTYPE(obj, widtype);
4303 Widget_Data *wd = elm_widget_data_get(obj);
4305 if (file) *file = wd->file;
4306 if (format) *format = wd->format;
4310 * This function writes any changes made to the file set with
4311 * elm_entry_file_set()
4313 * @param obj The entry object
4318 elm_entry_file_save(Evas_Object *obj)
4320 ELM_CHECK_WIDTYPE(obj, widtype);
4321 Widget_Data *wd = elm_widget_data_get(obj);
4323 if (wd->delay_write)
4325 ecore_timer_del(wd->delay_write);
4326 wd->delay_write = NULL;
4329 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4333 * This sets the entry object to 'autosave' the loaded text file or not.
4335 * @param obj The entry object
4336 * @param autosave Autosave the loaded file or not
4341 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4343 ELM_CHECK_WIDTYPE(obj, widtype);
4344 Widget_Data *wd = elm_widget_data_get(obj);
4346 wd->autosave = !!autosave;
4350 * This gets the entry object's 'autosave' status.
4352 * @param obj The entry object
4353 * @return Autosave the loaded file or not
4358 elm_entry_autosave_get(const Evas_Object *obj)
4360 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4361 Widget_Data *wd = elm_widget_data_get(obj);
4362 if (!wd) return EINA_FALSE;
4363 return wd->autosave;
4367 * Control pasting of text and images for the widget.
4369 * Normally the entry allows both text and images to be pasted. By setting
4370 * textonly to be true, this prevents images from being pasted.
4372 * Note this only changes the behaviour of text.
4374 * @param obj The entry object
4375 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4380 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4382 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4383 ELM_CHECK_WIDTYPE(obj, widtype);
4384 Widget_Data *wd = elm_widget_data_get(obj);
4386 textonly = !!textonly;
4387 if (wd->textonly == textonly) return;
4388 wd->textonly = !!textonly;
4389 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4390 #ifdef HAVE_ELEMENTARY_X
4391 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4396 * Getting elm_entry text paste/drop mode.
4398 * In textonly mode, only text may be pasted or dropped into the widget.
4400 * @param obj The entry object
4401 * @return If the widget only accepts text from pastes.
4406 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4408 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4409 Widget_Data *wd = elm_widget_data_get(obj);
4410 if (!wd) return EINA_FALSE;
4411 return wd->textonly;
4415 * Enable or disable scrolling in entry
4417 * Normally the entry is not scrollable unless you enable it with this call.
4419 * @param obj The entry object
4420 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4425 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4427 ELM_CHECK_WIDTYPE(obj, widtype);
4428 Widget_Data *wd = elm_widget_data_get(obj);
4431 if (wd->scroll == scroll) return;
4432 wd->scroll = scroll;
4435 elm_widget_sub_object_del(obj, wd->scroller);
4436 elm_widget_resize_object_set(obj, wd->scroller);
4437 elm_widget_sub_object_add(obj, wd->ent);
4438 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4439 evas_object_show(wd->scroller);
4440 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4441 if (wd->single_line)
4443 elm_smart_scroller_policy_set(wd->scroller,
4444 ELM_SMART_SCROLLER_POLICY_OFF,
4445 ELM_SMART_SCROLLER_POLICY_OFF);
4446 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4450 const Elm_Scroller_Policy map[3] =
4452 ELM_SMART_SCROLLER_POLICY_AUTO,
4453 ELM_SMART_SCROLLER_POLICY_ON,
4454 ELM_SMART_SCROLLER_POLICY_OFF
4456 elm_smart_scroller_policy_set(wd->scroller,
4459 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4464 elm_smart_scroller_child_set(wd->scroller, NULL);
4465 elm_widget_sub_object_del(obj, wd->ent);
4466 elm_widget_resize_object_set(obj, wd->ent);
4467 evas_object_smart_member_add(wd->scroller, obj);
4468 elm_widget_sub_object_add(obj, wd->scroller);
4469 evas_object_hide(wd->scroller);
4470 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4477 * Get the scrollable state of the entry
4479 * Normally the entry is not scrollable. This gets the scrollable state
4480 * of the entry. See elm_entry_scrollable_set() for more information.
4482 * @param obj The entry object
4483 * @return The scrollable state
4488 elm_entry_scrollable_get(const Evas_Object *obj)
4490 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4491 Widget_Data *wd = elm_widget_data_get(obj);
4492 if (!wd) return EINA_FALSE;
4497 * This sets a widget to be displayed to the left of a scrolled entry.
4499 * @param obj The scrolled entry object
4500 * @param icon The widget to display on the left side of the scrolled
4503 * @note A previously set widget will be destroyed.
4504 * @note If the object being set does not have minimum size hints set,
4505 * it won't get properly displayed.
4508 * @see elm_entry_end_set
4511 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4513 ELM_CHECK_WIDTYPE(obj, widtype);
4514 Widget_Data *wd = elm_widget_data_get(obj);
4517 EINA_SAFETY_ON_NULL_RETURN(icon);
4518 if (wd->icon == icon) return;
4519 if (wd->icon) evas_object_del(wd->icon);
4521 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4523 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4524 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4529 * Gets the leftmost widget of the scrolled entry. This object is
4530 * owned by the scrolled entry and should not be modified.
4532 * @param obj The scrolled entry object
4533 * @return the left widget inside the scroller
4538 elm_entry_icon_get(const Evas_Object *obj)
4540 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4541 Widget_Data *wd = elm_widget_data_get(obj);
4542 if (!wd) return NULL;
4547 * Unset the leftmost widget of the scrolled entry, unparenting and
4550 * @param obj The scrolled entry object
4551 * @return the previously set icon sub-object of this entry, on
4554 * @see elm_entry_icon_set()
4559 elm_entry_icon_unset(Evas_Object *obj)
4561 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4562 Widget_Data *wd = elm_widget_data_get(obj);
4563 Evas_Object *ret = NULL;
4564 if (!wd) return NULL;
4567 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4568 if (!edje) return NULL;
4570 edje_object_part_unswallow(edje, wd->icon);
4571 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4579 * Sets the visibility of the left-side widget of the scrolled entry,
4580 * set by @elm_entry_icon_set().
4582 * @param obj The scrolled entry object
4583 * @param setting EINA_TRUE if the object should be displayed,
4584 * EINA_FALSE if not.
4589 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4591 ELM_CHECK_WIDTYPE(obj, widtype);
4592 Widget_Data *wd = elm_widget_data_get(obj);
4593 if ((!wd) || (!wd->icon)) return;
4595 evas_object_hide(wd->icon);
4597 evas_object_show(wd->icon);
4602 * This sets a widget to be displayed to the end of a scrolled entry.
4604 * @param obj The scrolled entry object
4605 * @param end The widget to display on the right side of the scrolled
4608 * @note A previously set widget will be destroyed.
4609 * @note If the object being set does not have minimum size hints set,
4610 * it won't get properly displayed.
4613 * @see elm_entry_icon_set
4616 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4618 ELM_CHECK_WIDTYPE(obj, widtype);
4619 Widget_Data *wd = elm_widget_data_get(obj);
4622 EINA_SAFETY_ON_NULL_RETURN(end);
4623 if (wd->end == end) return;
4624 if (wd->end) evas_object_del(wd->end);
4626 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4628 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4629 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4634 * Gets the endmost widget of the scrolled entry. This object is owned
4635 * by the scrolled entry and should not be modified.
4637 * @param obj The scrolled entry object
4638 * @return the right widget inside the scroller
4643 elm_entry_end_get(const Evas_Object *obj)
4645 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4646 Widget_Data *wd = elm_widget_data_get(obj);
4647 if (!wd) return NULL;
4652 * Unset the endmost widget of the scrolled entry, unparenting and
4655 * @param obj The scrolled entry object
4656 * @return the previously set icon sub-object of this entry, on
4659 * @see elm_entry_icon_set()
4664 elm_entry_end_unset(Evas_Object *obj)
4666 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4667 Widget_Data *wd = elm_widget_data_get(obj);
4668 Evas_Object *ret = NULL;
4669 if (!wd) return NULL;
4672 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4673 if (!edje) return NULL;
4675 edje_object_part_unswallow(edje, wd->end);
4676 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4684 * Sets the visibility of the end widget of the scrolled entry, set by
4685 * @elm_entry_end_set().
4687 * @param obj The scrolled entry object
4688 * @param setting EINA_TRUE if the object should be displayed,
4689 * EINA_FALSE if not.
4694 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4696 ELM_CHECK_WIDTYPE(obj, widtype);
4697 Widget_Data *wd = elm_widget_data_get(obj);
4698 if ((!wd) || (!wd->end)) return;
4700 evas_object_hide(wd->end);
4702 evas_object_show(wd->end);
4707 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4709 * @param obj The scrolled entry object
4710 * @param h The horizontal scrollbar policy to apply
4711 * @param v The vertical scrollbar policy to apply
4716 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4718 ELM_CHECK_WIDTYPE(obj, widtype);
4719 Widget_Data *wd = elm_widget_data_get(obj);
4720 const Elm_Scroller_Policy map[3] =
4722 ELM_SMART_SCROLLER_POLICY_AUTO,
4723 ELM_SMART_SCROLLER_POLICY_ON,
4724 ELM_SMART_SCROLLER_POLICY_OFF
4729 elm_smart_scroller_policy_set(wd->scroller,
4735 * This enables/disables bouncing within the entry.
4737 * @param obj The scrolled entry object
4738 * @param h The horizontal bounce state
4739 * @param v The vertical bounce state
4744 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4746 ELM_CHECK_WIDTYPE(obj, widtype);
4747 Widget_Data *wd = elm_widget_data_get(obj);
4749 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4753 * Get the bounce mode
4755 * @param obj The Entry object
4756 * @param h_bounce Allow bounce horizontally
4757 * @param v_bounce Allow bounce vertically
4762 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4764 ELM_CHECK_WIDTYPE(obj, widtype);
4765 Widget_Data *wd = elm_widget_data_get(obj);
4767 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4770 EINA_DEPRECATED EAPI void
4771 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4773 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);
4777 * Set background color of the entry
4779 * @param obj The entry object
4780 * @param r Red property background color of The entry object
4781 * @param g Green property background color of The entry object
4782 * @param b Blue property background color of The entry object
4783 * @param a Alpha property background alpha of The entry object
4787 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4789 ELM_CHECK_WIDTYPE(obj, widtype);
4790 Widget_Data *wd = elm_widget_data_get(obj);
4791 evas_object_color_set(wd->bg, r, g, b, a);
4793 if (wd->bgcolor == EINA_FALSE)
4796 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4801 * Set whether entry should support auto capitalization
4803 * @param obj The entry object
4804 * @param on If true, entry suports auto capitalization.
4809 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4811 ELM_CHECK_WIDTYPE(obj, widtype);
4812 Widget_Data *wd = elm_widget_data_get(obj);
4816 wd->autocapital = EINA_FALSE;
4818 wd->autocapital = autocap;
4820 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4821 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4822 wd->autocapital = EINA_FALSE;
4824 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
4828 * Set whether entry should support auto period
4830 * @param obj The entry object
4831 * @param on If true, entry suports auto period.
4836 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4838 ELM_CHECK_WIDTYPE(obj, widtype);
4839 Widget_Data *wd = elm_widget_data_get(obj);
4843 wd->autoperiod = EINA_FALSE;
4845 wd->autoperiod = autoperiod;
4847 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4848 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4849 wd->autoperiod = EINA_FALSE;
4851 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4855 * Set whether entry should enable the return key on soft keyboard automatically
4857 * @param obj The entry object
4858 * @param on If true, entry enables the return key on soft keyboard automatically.
4863 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
4865 ELM_CHECK_WIDTYPE(obj, widtype);
4866 Widget_Data *wd = elm_widget_data_get(obj);
4869 wd->autoreturnkey = on;
4870 _check_enable_returnkey(obj);
4874 * This sets the attribute to show the input panel automatically.
4876 * @param obj The entry object
4877 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4882 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4884 ELM_CHECK_WIDTYPE(obj, widtype);
4885 Widget_Data *wd = elm_widget_data_get(obj);
4888 wd->input_panel_enable = enabled;
4889 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4893 * Set the input panel layout of the entry
4895 * @param obj The entry object
4896 * @param layout the layout to set
4901 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4903 ELM_CHECK_WIDTYPE(obj, widtype);
4904 Widget_Data *wd = elm_widget_data_get(obj);
4907 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4910 wd->input_panel_layout = layout;
4912 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4916 * Get the input method context in the entry widget
4918 * @param obj The entry object
4919 * @return The input method context
4923 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
4925 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4926 Widget_Data *wd = elm_widget_data_get(obj);
4927 if (!wd || !wd->ent) return NULL;
4929 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4933 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
4935 Widget_Data *wd = elm_widget_data_get(obj);
4940 Evas_Coord max_w = 9999, max_h = 9999;
4941 const char* key_data = NULL;
4943 wd->matchlist_threshold = 1;
4944 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
4945 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
4946 elm_hover_target_set(wd->hover, obj);
4947 elm_object_style_set(wd->hover, "matchlist");
4949 wd->layout = elm_layout_add(wd->hover);
4950 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
4951 wd->list = elm_list_add(wd->layout);
4952 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
4953 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
4954 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
4955 elm_object_style_set(wd->list, "matchlist");
4957 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
4958 if (key_data) max_w = atoi(key_data);
4959 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
4960 if (key_data) max_h = atoi(key_data);
4962 elm_list_go(wd->list);
4963 evas_object_size_hint_max_set(wd->list, max_w, max_h);
4964 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
4965 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
4966 elm_hover_content_set(wd->hover, "bottom", wd->layout);
4968 wd->match_list = match_list;
4973 evas_object_del(wd->hover);
4975 wd->match_list = NULL;
4978 wd->matchlist_case_sensitive = case_sensitive;
4982 * Set the magnifier style of the entry
4984 * @param obj The entry object
4985 * @param type the magnifier style to set
4990 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4992 ELM_CHECK_WIDTYPE(obj, widtype);
4993 Widget_Data *wd = elm_widget_data_get(obj);
4996 wd->mgf_type = type;
4997 _magnifier_create(obj);
5001 * Set wrap width of the entry
5003 * @param obj The entry object
5004 * @param w The wrap width in pixels at a minimum where words need to wrap
5008 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
5010 Widget_Data *wd = elm_widget_data_get(obj);
5012 if (wd->wrap_w == w) return;
5018 * get wrap width of the entry
5020 * @param obj The entry object
5021 * @return The wrap width in pixels at a minimum where words need to wrap
5025 elm_entry_wrap_width_get(const Evas_Object *obj)
5027 Widget_Data *wd = elm_widget_data_get(obj);
5033 * Set the font size on the entry object
5035 * @param obj The entry object
5036 * @param size font size
5041 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
5043 ELM_CHECK_WIDTYPE(obj, widtype);
5044 Widget_Data *wd = elm_widget_data_get(obj);
5045 Eina_Strbuf *fontbuf = NULL;
5050 t = eina_stringshare_add(elm_entry_entry_get(obj));
5051 fontbuf = eina_strbuf_new();
5052 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
5054 if (fontsize == 0) removeflag = 1; // remove fontsize tag
5056 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
5058 elm_entry_entry_set(obj, t);
5062 eina_strbuf_free(fontbuf);
5063 eina_stringshare_del(t);
5067 * Set the text color on the entry object
5069 * @param obj The entry object
5070 * @param r Red property background color of The entry object
5071 * @param g Green property background color of The entry object
5072 * @param b Blue property background color of The entry object
5073 * @param a Alpha property background alpha of The entry object
5078 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
5080 ELM_CHECK_WIDTYPE(obj, widtype);
5081 Widget_Data *wd = elm_widget_data_get(obj);
5082 Eina_Strbuf *colorbuf = NULL;
5087 t = eina_stringshare_add(elm_entry_entry_get(obj));
5089 if (len <= 0) return;
5090 colorbuf = eina_strbuf_new();
5091 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
5093 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
5095 elm_entry_entry_set(obj, t);
5099 eina_strbuf_free(colorbuf);
5100 eina_stringshare_del(t);
5104 * Set the text align on the entry object
5106 * @param obj The entry object
5107 * @param align align mode
5112 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
5114 ELM_CHECK_WIDTYPE(obj, widtype);
5115 Widget_Data *wd = elm_widget_data_get(obj);
5120 t = eina_stringshare_add(elm_entry_entry_get(obj));
5122 if (len <= 0) return;
5124 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
5125 elm_entry_entry_set(obj, t);
5129 eina_stringshare_del(t);