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, fs;
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);
1542 fs = elm_finger_size_get();
1544 if ((cy + y) - wd->mgf_height - fs < 0)
1545 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1547 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1548 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1549 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1550 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1554 evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 - fs + oy);
1558 _magnifier_create(void *data)
1560 Widget_Data *wd = elm_widget_data_get(data);
1561 Evas_Coord x, y, w, h, mw, mh;
1562 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 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1604 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1608 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1609 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1610 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1614 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1615 evas_object_image_source_set(wd->mgf_proxy, data);
1618 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1619 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1620 if ((mw <= 0) || (mh <= 0))
1623 evas_object_resize(wd->mgf_proxy, mw, mh);
1624 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1625 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1626 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1627 evas_object_show(wd->mgf_proxy);
1628 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1630 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1631 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1635 _signal_long_pressed(void *data)
1637 Widget_Data *wd = elm_widget_data_get(data);
1638 if (!wd) return ECORE_CALLBACK_CANCEL;
1640 wd->long_pressed = EINA_TRUE;
1642 _cancel(data, NULL, NULL);
1644 _magnifier_create(data);
1645 _magnifier_move(data);
1646 _magnifier_show(data);
1647 elm_object_scroll_freeze_push(data);
1649 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1650 return ECORE_CALLBACK_CANCEL;
1654 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1656 Widget_Data *wd = elm_widget_data_get(data);
1657 Evas_Event_Mouse_Down *ev = event_info;
1659 if (wd->disabled) return;
1660 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1661 wd->downx = ev->canvas.x;
1662 wd->downy = ev->canvas.y;
1663 wd->long_pressed = EINA_FALSE;
1667 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1669 Widget_Data *wd = elm_widget_data_get(data);
1670 Evas_Event_Mouse_Up *ev = event_info;
1672 if (wd->disabled) return;
1673 if (ev->button == 1)
1675 if (!wd->double_clicked)
1677 if ((wd->api) && (wd->api->obj_mouseup))
1678 wd->api->obj_mouseup(data);
1680 _magnifier_hide(data);
1681 elm_object_scroll_freeze_pop(data);
1683 if (wd->long_pressed)
1686 else if (ev->button == 3)
1694 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1696 Widget_Data *wd = elm_widget_data_get(data);
1697 Evas_Event_Mouse_Move *ev = event_info;
1699 if (wd->disabled) return;
1701 if (ev->buttons == 1)
1703 if (wd->long_pressed)
1705 _magnifier_show(data);
1706 _magnifier_move(data);
1712 _getbase(Evas_Object *obj)
1714 Widget_Data *wd = elm_widget_data_get(obj);
1715 if (!wd) return "base";
1718 if (wd->password) return "base-password";
1721 if (wd->single_line) return "base-single";
1724 switch (wd->linewrap)
1727 return "base-charwrap";
1730 case ELM_WRAP_MIXED:
1731 return "base-mixedwrap";
1734 return "base-nowrap";
1741 if (wd->password) return "base-password";
1744 if (wd->single_line) return "base-single-noedit";
1747 switch (wd->linewrap)
1750 return "base-noedit-charwrap";
1752 return "base-noedit";
1753 case ELM_WRAP_MIXED:
1754 return "base-noedit-mixedwrap";
1757 return "base-nowrap-noedit";
1767 _entry_length_get(Evas_Object *obj)
1770 const char *str = elm_entry_entry_get(obj);
1773 char *plain_str = _elm_util_mkup_to_text(str);
1774 if (!plain_str) return 0;
1776 len = strlen(plain_str);
1782 #ifndef HAVE_STRCASESTR
1783 char* _strcasestr(const char *s, const char *find)
1788 if ((c = *find++) != 0) {
1789 c = tolower((unsigned char) c);
1793 if( (sc = *s++) == 0)
1795 } while ((char)tolower((unsigned char)sc) != c);
1796 } while (strncasecmp(s, find, len) != 0);
1804 _matchlist_show(void *data)
1806 Widget_Data *wd = elm_widget_data_get(data);
1807 const char *text = NULL;
1809 char *str_list = NULL, *str_result = NULL;
1810 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1813 Eina_Bool textfound = EINA_FALSE;
1816 if (elm_widget_disabled_get(data)) return;
1818 wd->matchlist_job = NULL;
1820 if (wd->matchlist_list_clicked)
1822 evas_object_hide(wd->hover);
1823 wd->matchlist_list_clicked = EINA_FALSE;
1826 text = elm_entry_entry_get(data);
1829 textlen = strlen(text);
1831 if (textlen < wd->matchlist_threshold)
1833 evas_object_hide(wd->hover);
1837 evas_object_hide(wd->hover);
1841 elm_list_clear(wd->list);
1842 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1844 if (wd->matchlist_case_sensitive)
1845 str_result = strstr(str_list, text);
1847 #ifdef HAVE_STRCASESTR
1848 str_result = strcasestr(str_list, text);
1850 str_result = _strcasestr(str_list, text);
1855 str_mkup = malloc(strlen(str_list) + 16);
1856 if (str_mkup == NULL) return;
1858 textlen = strlen(str_list) - strlen(str_result);
1859 str_front = malloc(textlen + 1);
1860 if (str_front == NULL) return;
1862 memset(str_front, 0, textlen + 1);
1863 strncpy(str_front, str_list, textlen);
1865 textlen = strlen(text);
1866 str_mid = malloc(textlen + 1);
1867 if (str_mid == NULL) return;
1869 memset(str_mid, 0, textlen + 1);
1870 strncpy(str_mid, str_list + strlen(str_front), textlen);
1872 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1874 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1876 if (str_mkup) free(str_mkup);
1877 if (str_front) free(str_front);
1878 if (str_mid) free(str_mid);
1880 textfound=EINA_TRUE;
1889 elm_list_go(wd->list);
1890 evas_object_show(wd->hover);
1891 evas_object_raise(wd->hover);
1895 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1897 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1898 Widget_Data *wd = elm_widget_data_get(data);
1899 if ((it == NULL) || (wd == NULL))
1902 const char *text = elm_list_item_label_get(it);
1903 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1908 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1909 elm_entry_cursor_end_set(data);
1910 wd->matchlist_list_clicked = EINA_TRUE;
1912 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1915 elm_widget_focus_set(data, EINA_TRUE);
1919 _entry_changed_common_handling(void *data, const char *event)
1921 Widget_Data *wd = elm_widget_data_get(data);
1922 Evas_Coord minw, minh;
1924 wd->changed = EINA_TRUE;
1925 /* Reset the size hints which are no more relevant.
1926 * Keep the height, this is a hack, but doesn't really matter
1927 * cause we'll re-eval in a moment. */
1930 evas_object_size_hint_min_get(data, &minw, &minh);
1931 evas_object_size_hint_min_set(data, minw, minh);
1935 evas_object_size_hint_min_get(data, NULL, &minh);
1936 evas_object_size_hint_min_set(data, -1, minh);
1940 if (wd->text) eina_stringshare_del(wd->text);
1942 if (wd->password_text) eina_stringshare_del(wd->password_text);
1943 wd->password_text = NULL;
1944 _check_enable_returnkey(data);
1945 evas_object_smart_callback_call(data, event, NULL);
1946 if (wd->delay_write)
1948 ecore_timer_del(wd->delay_write);
1949 wd->delay_write = NULL;
1952 if ((wd->single_line) && (wd->match_list))
1954 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1955 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1957 if ((!wd->autosave) || (!wd->file)) return;
1958 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1962 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1964 Widget_Data *wd = elm_widget_data_get(data);
1967 _entry_changed_common_handling(data, SIG_CHANGED);
1969 if ((wd->api) && (wd->api->obj_hidemenu))
1970 wd->api->obj_hidemenu(data);
1974 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1976 Widget_Data *wd = elm_widget_data_get(data);
1979 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1981 if ((wd->api) && (wd->api->obj_hidemenu))
1982 wd->api->obj_hidemenu(data);
1986 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1988 Widget_Data *wd = elm_widget_data_get(data);
1991 elm_object_scroll_freeze_push(data);
1993 if ((wd->api) && (wd->api->obj_hidemenu))
1994 wd->api->obj_hidemenu(data);
1996 _magnifier_create(data);
1997 _magnifier_move(data);
1998 _magnifier_show(data);
2002 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2004 Widget_Data *wd = elm_widget_data_get(data);
2007 elm_object_scroll_freeze_pop(data);
2009 if (wd->have_selection)
2011 _magnifier_hide(data);
2017 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2019 _magnifier_move(data);
2020 _magnifier_show(data);
2023 static Evas_Object *
2024 _viewport_obj_get(Evas_Object *data)
2026 Widget_Data *wd = elm_widget_data_get(data);
2027 if (!wd) return NULL;
2029 if(!data || !strlen(elm_widget_type_get(data)))
2032 Evas_Coord x, y, w, h;
2037 //evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
2038 //printf(">>> wd->scroller (%d, %d, %d, %d) \n", x, y, w, h);
2039 return wd->scroller;
2042 Evas_Object *parent_obj = data;
2044 while(parent_obj = elm_widget_parent_get(parent_obj))
2046 //evas_object_geometry_get(parent_obj, &x, &y, &w, &h);
2047 //printf(">>> %s (%d, %d, %d, %d) \n", elm_widget_type_get(parent_obj), x, y, w, h);
2048 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
2049 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
2057 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2059 _magnifier_hide(data);
2064 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2066 Widget_Data *wd = elm_widget_data_get(data);
2070 EINA_LIST_FOREACH(entries, l, entry)
2072 if (entry != data) elm_entry_select_none(entry);
2074 wd->have_selection = EINA_TRUE;
2075 wd->selmode = EINA_TRUE;
2076 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2077 #ifdef HAVE_ELEMENTARY_X
2078 if (wd->sel_notify_handler)
2080 const char *txt = elm_entry_selection_get(data);
2083 top = elm_widget_top_get(data);
2084 if ((top) && (elm_win_xwindow_get(top)))
2085 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
2089 if (!_elm_config->desktop_entry)
2090 edje_object_part_text_viewport_object_set(wd->ent, "elm.text", _viewport_obj_get(data));
2094 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2096 Evas_Coord cx, cy, cw, ch;
2097 Widget_Data *wd = elm_widget_data_get(data);
2100 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2101 if (!wd->deferred_recalc_job)
2102 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2105 wd->deferred_cur = EINA_TRUE;
2109 wd->ch = ch + elm_finger_size_get();
2114 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2116 Evas_Coord cx, cy, cw, ch;
2117 Widget_Data *wd = elm_widget_data_get(data);
2119 wd->have_selection = EINA_TRUE;
2120 wd->selmode = EINA_TRUE;
2121 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2122 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
2123 elm_entry_selection_get(data));
2125 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2126 if (!wd->deferred_recalc_job)
2127 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE);
2130 wd->deferred_cur = EINA_TRUE;
2134 wd->ch = ch + elm_finger_size_get();
2139 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2141 Widget_Data *wd = elm_widget_data_get(data);
2143 if (!wd->have_selection) return;
2144 wd->have_selection = EINA_FALSE;
2145 wd->selmode = EINA_FALSE;
2146 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2147 if (wd->sel_notify_handler)
2151 #ifdef HAVE_ELEMENTARY_X
2154 top = elm_widget_top_get(data);
2155 if ((top) && (elm_win_xwindow_get(top)))
2156 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2159 eina_stringshare_del(wd->cut_sel);
2164 #ifdef HAVE_ELEMENTARY_X
2167 top = elm_widget_top_get(data);
2168 if ((top) && (elm_win_xwindow_get(top)))
2169 elm_selection_clear(ELM_SEL_PRIMARY, data);
2174 if ((wd->api) && (wd->api->obj_hidemenu))
2176 wd->api->obj_hidemenu(data);
2181 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2183 Widget_Data *wd = elm_widget_data_get(data);
2185 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2186 if (wd->sel_notify_handler)
2188 #ifdef HAVE_ELEMENTARY_X
2191 top = elm_widget_top_get(data);
2192 if ((top) && (elm_win_xwindow_get(top)))
2194 wd->selection_asked = EINA_TRUE;
2195 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2203 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2205 Widget_Data *wd = elm_widget_data_get(data);
2207 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2208 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2209 elm_entry_selection_get(data));
2213 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2215 Widget_Data *wd = elm_widget_data_get(data);
2217 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2218 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2219 elm_entry_selection_get(data));
2220 edje_object_part_text_insert(wd->ent, "elm.text", "");
2221 wd->changed = EINA_TRUE;
2226 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2228 Widget_Data *wd = elm_widget_data_get(data);
2230 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2231 wd->cur_changed = EINA_TRUE;
2232 _recalc_cursor_geometry(data);
2236 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2238 Widget_Data *wd = elm_widget_data_get(data);
2243 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2245 Widget_Data *wd = elm_widget_data_get(data);
2250 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2252 Widget_Data *wd = elm_widget_data_get(data);
2253 Elm_Entry_Anchor_Info ei;
2254 char *buf2, *p, *p2, *n;
2256 p = strrchr(emission, ',');
2259 const Eina_List *geoms;
2263 while (p2 >= emission)
2265 if (*p2 == ',') break;
2269 buf2 = alloca(5 + p - p2);
2270 strncpy(buf2, p2, p - p2);
2273 ei.button = atoi(buf2);
2274 ei.x = ei.y = ei.w = ei.h = 0;
2276 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2279 Evas_Textblock_Rectangle *r;
2281 Evas_Coord px, py, x, y;
2283 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2284 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2285 EINA_LIST_FOREACH(geoms, l, r)
2287 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2288 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2299 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2304 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2306 Widget_Data *wd = elm_widget_data_get(data);
2311 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2313 Widget_Data *wd = elm_widget_data_get(data);
2318 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2320 Widget_Data *wd = elm_widget_data_get(data);
2325 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2327 Widget_Data *wd = elm_widget_data_get(data);
2329 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2333 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2335 Widget_Data *wd = elm_widget_data_get(data);
2337 wd->double_clicked = EINA_FALSE;
2338 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2340 if ((wd->api) && (wd->api->obj_hidemenu))
2341 wd->api->obj_hidemenu(data);
2345 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2347 Widget_Data *wd = elm_widget_data_get(data);
2349 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2351 if (!_elm_config->desktop_entry && !wd->double_clicked)
2352 _cancel(data, NULL, NULL);
2356 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2358 Widget_Data *wd = elm_widget_data_get(data);
2360 wd->double_clicked = EINA_TRUE;
2361 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2364 #ifdef HAVE_ELEMENTARY_X
2366 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2368 Widget_Data *wd = elm_widget_data_get(data);
2369 Ecore_X_Event_Selection_Notify *ev = event;
2370 if (!wd) return ECORE_CALLBACK_PASS_ON;
2371 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2372 return ECORE_CALLBACK_PASS_ON;
2374 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2375 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2377 Ecore_X_Selection_Data_Text *text_data;
2379 text_data = ev->data;
2380 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2382 if (text_data->text)
2384 char *txt = _elm_util_text_to_mkup(text_data->text);
2388 elm_entry_entry_insert(data, txt);
2393 wd->selection_asked = EINA_FALSE;
2395 else if (ev->selection == ECORE_X_SELECTION_XDND)
2397 Ecore_X_Selection_Data_Text *text_data;
2399 text_data = ev->data;
2400 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2402 if (text_data->text)
2404 char *txt = _elm_util_text_to_mkup(text_data->text);
2408 /* Massive FIXME: this should be at the drag point */
2409 elm_entry_entry_insert(data, txt);
2414 wd->drag_selection_asked = EINA_FALSE;
2416 ecore_x_dnd_send_finished();
2419 return ECORE_CALLBACK_PASS_ON;
2423 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2426 Widget_Data *wd = elm_widget_data_get(data);
2427 Ecore_X_Event_Selection_Clear *ev = event;
2428 if (!wd) return ECORE_CALLBACK_PASS_ON;
2429 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2430 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2431 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2433 elm_entry_select_none(data);
2438 Evas_Object *top = elm_widget_top_get(data);
2439 Ecore_X_Event_Selection_Clear *ev = event;
2442 return ECORE_CALLBACK_PASS_ON;
2444 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2446 return ECORE_CALLBACK_PASS_ON;
2449 if (cnpwidgetdata == data)
2451 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2452 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2456 return ECORE_CALLBACK_PASS_ON;
2460 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2465 wd = elm_widget_data_get(obj);
2466 if (!wd) return EINA_FALSE;
2467 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2469 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2470 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2471 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2472 EDJE_CURSOR_MAIN,drop->x,drop->y);
2473 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2474 elm_entry_entry_insert(obj, drop->data);
2475 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2476 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2482 static Evas_Object *
2483 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2485 Widget_Data *wd = elm_widget_data_get(data);
2488 Elm_Entry_Item_Provider *ip;
2490 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2492 o = ip->func(ip->data, data, item);
2495 if (!strncmp(item, "file://", 7))
2497 const char *fname = item + 7;
2499 o = evas_object_image_filled_add(evas_object_evas_get(data));
2500 evas_object_image_file_set(o, fname, NULL);
2501 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2503 evas_object_show(o);
2508 o = edje_object_add(evas_object_evas_get(data));
2509 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2513 o = edje_object_add(evas_object_evas_get(data));
2514 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2515 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2520 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2522 const char *srcstring = NULL;
2523 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2524 char *curlocater, *replocater;
2525 char *starttag, *endtag;
2526 int tagtxtlen = 0, insertflag = 0;
2528 srcstring = eina_strbuf_string_get(srcbuf);
2529 curlocater = strstr(srcstring, key);
2531 if (!curlocater || !srcstring)
2539 starttag = strchr(srcstring, '<');
2540 endtag = strchr(srcstring, '>');
2541 tagtxtlen = endtag - starttag;
2542 if (tagtxtlen <= 0) tagtxtlen = 0;
2543 if (starttag < curlocater && curlocater < endtag) break;
2544 if (endtag != NULL && endtag+1 != NULL)
2545 srcstring = endtag+1;
2548 } while (strlen(srcstring) > 1);
2550 if (starttag && endtag && tagtxtlen > strlen(key))
2552 repbuf = eina_strbuf_new();
2553 diffbuf = eina_strbuf_new();
2554 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2555 srcstring = eina_strbuf_string_get(repbuf);
2556 curlocater = strstr(srcstring, key);
2558 if (curlocater != NULL)
2560 replocater = curlocater + strlen(key) + 1;
2562 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2565 if (replocater-curlocater > strlen(key)+1)
2567 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2576 eina_strbuf_reset(repbuf);
2584 if (repbuf == NULL) repbuf = eina_strbuf_new();
2585 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2589 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2590 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2596 eina_strbuf_prepend(diffbuf, "<");
2597 eina_strbuf_append(diffbuf, ">");
2598 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2602 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2603 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2607 if (repbuf) eina_strbuf_free(repbuf);
2608 if (diffbuf) eina_strbuf_free(diffbuf);
2614 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2616 Eina_Strbuf *sharebuf = NULL;
2618 sharebuf = eina_strbuf_new();
2619 eina_strbuf_append(sharebuf, *srcstring);
2620 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2621 eina_stringshare_del(*srcstring);
2622 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2623 eina_strbuf_free(sharebuf);
2629 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2631 Widget_Data *wd = elm_widget_data_get(data);
2633 Elm_Entry_Text_Filter *tf;
2635 if (type == EDJE_TEXT_FILTER_FORMAT)
2638 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2640 tf->func(tf->data, data, text);
2646 /* This function is used to insert text by chunks in jobs */
2648 _text_append_idler(void *data)
2652 Evas_Object *obj = (Evas_Object *) data;
2653 Widget_Data *wd = elm_widget_data_get(obj);
2654 if (wd->text) eina_stringshare_del(wd->text);
2656 if (wd->password_text) eina_stringshare_del(wd->password_text);
2657 wd->password_text = NULL;
2658 wd->changed = EINA_TRUE;
2660 start = wd->append_text_position;
2661 if (start + _CHUNK_SIZE < wd->append_text_len)
2664 int tag_start, esc_start;
2666 tag_start = esc_start = -1;
2667 /* Find proper markup cut place */
2668 while (pos - start < _CHUNK_SIZE)
2672 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2673 if (esc_start == -1)
2676 tag_start = prev_pos;
2677 else if (tmp == '>')
2680 else if (tag_start == -1)
2683 esc_start = prev_pos;
2684 else if (tmp == ';')
2691 wd->append_text_position = tag_start;
2693 else if (esc_start >= 0)
2695 wd->append_text_position = esc_start;
2699 wd->append_text_position = pos;
2704 wd->append_text_position = wd->append_text_len;
2707 backup = wd->append_text_left[wd->append_text_position];
2708 wd->append_text_left[wd->append_text_position] = '\0';
2710 edje_object_part_text_append(wd->ent, "elm.text",
2711 wd->append_text_left + start);
2713 wd->append_text_left[wd->append_text_position] = backup;
2715 /* If there's still more to go, renew the idler, else, cleanup */
2716 if (wd->append_text_position < wd->append_text_len)
2718 return ECORE_CALLBACK_RENEW;
2722 free(wd->append_text_left);
2723 wd->append_text_left = NULL;
2724 wd->append_text_idler = NULL;
2725 return ECORE_CALLBACK_CANCEL;
2730 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2732 int i = 0, unit_size;
2733 int current_len = strlen(*text);
2734 char *new_text = *text;
2735 if (unit >= LENGTH_UNIT_LAST) return;
2738 if (*new_text == '<')
2740 while (*new_text != '>')
2743 if (!*new_text) break;
2750 if (*new_text == '&')
2752 while (*(new_text + index) != ';')
2755 if (!*(new_text + index)) break;
2759 index = evas_string_char_next_get(new_text, index, NULL);
2760 markup = malloc(index + 1);
2761 strncpy(markup, new_text, index);
2763 if (unit == LENGTH_UNIT_BYTE)
2764 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2765 else if (unit == LENGTH_UNIT_CHAR)
2766 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2772 if (can_add < unit_size)
2776 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2782 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2783 current_len -= index;
2784 (*text)[current_len] = 0;
2789 can_add -= unit_size;
2794 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2798 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2801 ELM_CHECK_WIDTYPE(obj, widtype);
2802 Widget_Data *wd = elm_widget_data_get(obj);
2804 if (!entry) entry = "";
2805 if (item && strcmp(item, "default"))
2807 edje_object_part_text_set(wd->ent, item, entry);
2810 if (wd->text) eina_stringshare_del(wd->text);
2812 if (wd->password_text) eina_stringshare_del(wd->password_text);
2813 wd->password_text = NULL;
2814 wd->changed = EINA_TRUE;
2816 /* Clear currently pending job if there is one */
2817 if (wd->append_text_idler)
2819 ecore_idler_del(wd->append_text_idler);
2820 free(wd->append_text_left);
2821 wd->append_text_left = NULL;
2822 wd->append_text_idler = NULL;
2825 len = strlen(entry);
2826 /* Split to ~_CHUNK_SIZE chunks */
2827 if (len > _CHUNK_SIZE)
2829 wd->append_text_left = (char *) malloc(len + 1);
2832 /* If we decided to use the idler */
2833 if (wd->append_text_left)
2835 /* Need to clear the entry first */
2836 edje_object_part_text_set(wd->ent, "elm.text", "");
2837 memcpy(wd->append_text_left, entry, len + 1);
2838 wd->append_text_position = 0;
2839 wd->append_text_len = len;
2840 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2844 edje_object_part_text_set(wd->ent, "elm.text", entry);
2849 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2851 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2852 Widget_Data *wd = elm_widget_data_get(obj);
2853 if (item && strcmp(item, "default")) return NULL;
2855 if (!wd) return NULL;
2858 if(wd->password_text) return wd->password_text;
2864 text = edje_object_part_text_get(wd->ent, "elm.text");
2867 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2870 eina_stringshare_replace(&wd->text, text);
2873 const char *pw_text;
2874 pw_text = elm_entry_markup_to_utf8(wd->text);
2877 eina_stringshare_replace(&wd->password_text, pw_text);
2879 return wd->password_text;
2886 * This adds an entry to @p parent object.
2888 * @param parent The parent object
2889 * @return The new object or NULL if it cannot be created
2894 elm_entry_add(Evas_Object *parent)
2896 Evas_Object *obj, *top;
2900 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2902 ELM_SET_WIDTYPE(widtype, "entry");
2903 elm_widget_type_set(obj, "entry");
2904 elm_widget_sub_object_add(parent, obj);
2905 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2906 elm_widget_data_set(obj, wd);
2907 elm_widget_del_hook_set(obj, _del_hook);
2908 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2909 elm_widget_theme_hook_set(obj, _theme_hook);
2910 elm_widget_disable_hook_set(obj, _disable_hook);
2911 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2912 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2913 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2914 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2915 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2916 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2917 elm_widget_can_focus_set(obj, EINA_TRUE);
2918 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2919 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2920 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2921 elm_widget_content_set_hook_set(obj, _content_set_hook);
2922 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2923 elm_widget_content_get_hook_set(obj, _content_get_hook);
2925 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2926 wd->scroller = elm_smart_scroller_add(e);
2927 elm_widget_sub_object_add(obj, wd->scroller);
2928 elm_smart_scroller_widget_set(wd->scroller, obj);
2929 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2930 elm_widget_style_get(obj));
2931 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2932 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2933 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2934 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2936 wd->linewrap = ELM_WRAP_WORD;
2937 wd->editable = EINA_TRUE;
2938 wd->disabled = EINA_FALSE;
2939 wd->context_menu = EINA_TRUE;
2940 wd->autosave = EINA_TRUE;
2941 wd->textonly = EINA_FALSE;
2942 wd->autoperiod = EINA_TRUE;
2944 wd->ent = edje_object_add(e);
2945 elm_widget_sub_object_add(obj, wd->ent);
2946 edje_object_item_provider_set(wd->ent, _get_item, obj);
2947 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2948 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2949 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2951 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2953 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2955 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2957 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2958 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2959 _signal_entry_changed, obj);
2960 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2961 _signal_preedit_changed, obj);
2962 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2963 _signal_handler_move_start, obj);
2964 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2965 _signal_handler_move_end, obj);
2966 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2967 _signal_handler_moving, obj);
2968 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2969 _signal_selection_start, obj);
2970 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2971 _signal_selection_end, obj);
2972 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
2973 _signal_long_pressed, obj);
2974 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2975 _signal_magnifier_changed, obj);
2976 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2977 _signal_selection_changed, obj);
2978 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2979 _signal_selection_cleared, obj);
2980 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2981 _signal_entry_paste_request, obj);
2982 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2983 _signal_entry_copy_notify, obj);
2984 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2985 _signal_entry_cut_notify, obj);
2986 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2987 _signal_cursor_changed, obj);
2988 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2989 _signal_anchor_down, obj);
2990 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2991 _signal_anchor_up, obj);
2992 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2993 _signal_anchor_clicked, obj);
2994 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2995 _signal_anchor_move, obj);
2996 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2997 _signal_anchor_in, obj);
2998 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2999 _signal_anchor_out, obj);
3000 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
3001 _signal_key_enter, obj);
3002 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
3003 _signal_mouse_down, obj);
3004 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
3005 _signal_mouse_clicked, obj);
3006 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
3007 _signal_mouse_double, obj);
3008 edje_object_part_text_set(wd->ent, "elm.text", "");
3009 if (_elm_config->desktop_entry)
3010 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
3011 elm_widget_resize_object_set(obj, wd->ent);
3014 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
3016 #ifdef HAVE_ELEMENTARY_X
3017 top = elm_widget_top_get(obj);
3018 if ((top) && (elm_win_xwindow_get(top)))
3020 wd->sel_notify_handler =
3021 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
3022 _event_selection_notify, obj);
3023 wd->sel_clear_handler =
3024 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
3025 _event_selection_clear, obj);
3028 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3029 _drag_drop_cb, NULL);
3032 entries = eina_list_prepend(entries, obj);
3034 // module - find module for entry
3035 wd->api = _module(obj);
3036 // if found - hook in
3037 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
3039 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3040 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3041 // TODO: and save some bytes, making descriptions per-class and not instance!
3042 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3046 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
3048 ELM_CHECK_WIDTYPE(obj, widtype);
3049 Widget_Data *wd = elm_widget_data_get(obj);
3051 ext_mod->cancel = _cancel;
3052 ext_mod->copy = _copy;
3053 ext_mod->cut = _cut;
3054 ext_mod->paste = _paste;
3055 ext_mod->select = _select;
3056 ext_mod->selectall = _selectall;
3057 ext_mod->ent = wd->ent;
3058 ext_mod->viewport_obj = _viewport_obj_get(obj);
3059 ext_mod->items = wd->items;
3060 ext_mod->editable = wd->editable;
3061 ext_mod->have_selection = wd->have_selection;
3062 ext_mod->password = wd->password;
3063 ext_mod->selmode = wd->selmode;
3064 ext_mod->cnpinit = _cnpinit;
3065 ext_mod->context_menu = wd->context_menu;
3066 ext_mod->textonly = wd->textonly;
3070 * This sets the entry object not to line wrap. All input will
3071 * be on a single line, and the entry box will extend with user input.
3073 * @param obj The entry object
3074 * @param single_line If true, the text in the entry
3075 * will be on a single line.
3080 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
3082 ELM_CHECK_WIDTYPE(obj, widtype);
3083 Widget_Data *wd = elm_widget_data_get(obj);
3085 if (wd->single_line == single_line) return;
3086 wd->single_line = single_line;
3087 wd->linewrap = ELM_WRAP_NONE;
3088 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
3092 if (wd->single_line)
3094 elm_smart_scroller_policy_set(wd->scroller,
3095 ELM_SMART_SCROLLER_POLICY_OFF,
3096 ELM_SMART_SCROLLER_POLICY_OFF);
3097 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3101 const Elm_Scroller_Policy map[3] =
3103 ELM_SMART_SCROLLER_POLICY_AUTO,
3104 ELM_SMART_SCROLLER_POLICY_ON,
3105 ELM_SMART_SCROLLER_POLICY_OFF
3107 elm_smart_scroller_policy_set(wd->scroller,
3110 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3117 * This returns true if the entry has been set to single line mode.
3118 * See also elm_entry_single_line_set().
3120 * @param obj The entry object
3121 * @return single_line If true, the text in the entry is set to display
3127 elm_entry_single_line_get(const Evas_Object *obj)
3129 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3130 Widget_Data *wd = elm_widget_data_get(obj);
3131 if (!wd) return EINA_FALSE;
3132 return wd->single_line;
3136 * This sets the entry object to password mode. All text entered
3137 * and/or displayed within the widget will be replaced with asterisks (*).
3139 * @param obj The entry object
3140 * @param password If true, password mode is enabled.
3145 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3147 ELM_CHECK_WIDTYPE(obj, widtype);
3148 Widget_Data *wd = elm_widget_data_get(obj);
3150 if (wd->password == password) return;
3151 wd->password = password;
3152 wd->single_line = EINA_TRUE;
3153 wd->linewrap = ELM_WRAP_NONE;
3158 * This returns whether password mode is enabled.
3159 * See also elm_entry_password_set().
3161 * @param obj The entry object
3162 * @return If true, the entry is set to display all characters
3168 elm_entry_password_get(const Evas_Object *obj)
3170 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3171 Widget_Data *wd = elm_widget_data_get(obj);
3172 if (!wd) return EINA_FALSE;
3173 return wd->password;
3177 * This sets the text displayed within the entry to @p entry.
3179 * @param obj The entry object
3180 * @param entry The text to be displayed
3185 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3187 _elm_entry_text_set(obj, NULL, entry);
3191 * This appends @p entry to the text of the entry.
3193 * @param obj The entry object
3194 * @param entry The text to be displayed
3199 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3202 ELM_CHECK_WIDTYPE(obj, widtype);
3203 Widget_Data *wd = elm_widget_data_get(obj);
3205 if (!entry) entry = "";
3206 wd->changed = EINA_TRUE;
3208 len = strlen(entry);
3209 if (wd->append_text_left)
3212 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3218 wd->append_text_left = tmpbuf;
3219 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3220 wd->append_text_len += len;
3224 /* FIXME: Add chunked appending here (like in entry_set) */
3225 edje_object_part_text_append(wd->ent, "elm.text", entry);
3230 * This returns the text currently shown in object @p entry.
3231 * See also elm_entry_entry_set().
3233 * @param obj The entry object
3234 * @return The currently displayed text or NULL on failure
3239 elm_entry_entry_get(const Evas_Object *obj)
3241 return _elm_entry_text_get(obj, NULL);
3245 * This returns EINA_TRUE if the entry is empty/there was an error
3246 * and EINA_FALSE if it is not empty.
3248 * @param obj The entry object
3249 * @return If the entry is empty or not.
3254 elm_entry_is_empty(const Evas_Object *obj)
3256 /* FIXME: until there's support for that in textblock, we just check
3257 * to see if the there is text or not. */
3258 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3259 Widget_Data *wd = elm_widget_data_get(obj);
3260 const Evas_Object *tb;
3261 //Evas_Textblock_Cursor *cur;
3263 if (!wd) return EINA_TRUE;
3266 /* It's a hack until we get the support suggested above.
3267 * We just create a cursor, point it to the begining, and then
3268 * try to advance it, if it can advance, the tb is not empty,
3269 * otherwise it is. */
3270 tb = edje_object_part_object_get(wd->ent, "elm.text");
3271 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3272 actually, ok for the time being, thsese hackish stuff will be removed
3273 once evas 1.0 is out*/
3274 evas_textblock_cursor_pos_set(cur, 0);
3275 ret = evas_textblock_cursor_char_next(cur);
3276 evas_textblock_cursor_free(cur);
3281 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3282 if (!str) return EINA_TRUE;
3284 ret = (strlen(str) == 0);
3290 * This returns all selected text within the entry.
3292 * @param obj The entry object
3293 * @return The selected text within the entry or NULL on failure
3298 elm_entry_selection_get(const Evas_Object *obj)
3300 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3301 Widget_Data *wd = elm_widget_data_get(obj);
3302 if (!wd) return NULL;
3303 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3307 * This inserts text in @p entry where the current cursor position.
3309 * This inserts text at the cursor position is as if it was typed
3310 * by the user (note this also allows markup which a user
3311 * can't just "type" as it would be converted to escaped text, so this
3312 * call can be used to insert things like emoticon items or bold push/pop
3313 * tags, other font and color change tags etc.)
3315 * @param obj The entry object
3316 * @param entry The text to insert
3321 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3323 ELM_CHECK_WIDTYPE(obj, widtype);
3324 Widget_Data *wd = elm_widget_data_get(obj);
3326 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3328 #ifdef HAVE_ELEMENTARY_X
3329 if (cnpwidgetdata == obj)
3330 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3333 wd->changed = EINA_TRUE;
3338 * This enables word line wrapping in the entry object. It is the opposite
3339 * of elm_entry_single_line_set(). Additionally, setting this disables
3340 * character line wrapping.
3342 * @param obj The entry object
3343 * @param wrap If true, the entry will be wrapped once it reaches the end
3344 * of the object. Wrapping will occur at the end of the word before the end of the
3350 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3352 ELM_CHECK_WIDTYPE(obj, widtype);
3353 Widget_Data *wd = elm_widget_data_get(obj);
3355 if (wd->linewrap == wrap) return;
3357 wd->linewrap = wrap;
3362 * Get the wrapping behavior of the entry.
3363 * See also elm_entry_line_wrap_set().
3365 * @param obj The entry object
3371 elm_entry_line_wrap_get(const Evas_Object *obj)
3373 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3374 Widget_Data *wd = elm_widget_data_get(obj);
3375 if (!wd) return EINA_FALSE;
3376 return wd->linewrap;
3380 * This sets the editable attribute of the entry.
3382 * @param obj The entry object
3383 * @param editable If true, the entry will be editable by the user.
3384 * If false, it will be set to the disabled state.
3389 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3391 ELM_CHECK_WIDTYPE(obj, widtype);
3392 Widget_Data *wd = elm_widget_data_get(obj);
3394 if (wd->editable == editable) return;
3395 wd->editable = editable;
3398 #ifdef HAVE_ELEMENTARY_X
3400 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3402 elm_drop_target_del(obj);
3407 * This gets the editable attribute of the entry.
3408 * See also elm_entry_editable_set().
3410 * @param obj The entry object
3411 * @return If true, the entry is editable by the user.
3412 * If false, it is not editable by the user
3417 elm_entry_editable_get(const Evas_Object *obj)
3419 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3420 Widget_Data *wd = elm_widget_data_get(obj);
3421 if (!wd) return EINA_FALSE;
3422 return wd->editable;
3426 * This drops any existing text selection within the entry.
3428 * @param obj The entry object
3433 elm_entry_select_none(Evas_Object *obj)
3435 ELM_CHECK_WIDTYPE(obj, widtype);
3436 Widget_Data *wd = elm_widget_data_get(obj);
3440 wd->selmode = EINA_FALSE;
3441 if (!_elm_config->desktop_entry)
3442 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3443 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3445 wd->have_selection = EINA_FALSE;
3446 edje_object_part_text_select_none(wd->ent, "elm.text");
3450 * This selects all text within the entry.
3452 * @param obj The entry object
3457 elm_entry_select_all(Evas_Object *obj)
3459 ELM_CHECK_WIDTYPE(obj, widtype);
3460 Widget_Data *wd = elm_widget_data_get(obj);
3464 wd->selmode = EINA_FALSE;
3465 if (!_elm_config->desktop_entry)
3466 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3467 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3469 wd->have_selection = EINA_TRUE;
3470 edje_object_part_text_select_all(wd->ent, "elm.text");
3474 * This function returns the geometry of the cursor.
3476 * It's useful if you want to draw something on the cursor (or where it is),
3477 * or for example in the case of scrolled entry where you want to show the
3480 * @param obj The entry object
3481 * @param x returned geometry
3482 * @param y returned geometry
3483 * @param w returned geometry
3484 * @param h returned geometry
3485 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3490 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3492 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3493 Widget_Data *wd = elm_widget_data_get(obj);
3494 if (!wd) return EINA_FALSE;
3495 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3500 * This moves the cursor one place to the right within the entry.
3502 * @param obj The entry object
3503 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3508 elm_entry_cursor_next(Evas_Object *obj)
3510 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3511 Widget_Data *wd = elm_widget_data_get(obj);
3512 if (!wd) return EINA_FALSE;
3513 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3517 * This moves the cursor one place to the left within the entry.
3519 * @param obj The entry object
3520 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3525 elm_entry_cursor_prev(Evas_Object *obj)
3527 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3528 Widget_Data *wd = elm_widget_data_get(obj);
3529 if (!wd) return EINA_FALSE;
3530 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3534 * This moves the cursor one line up within the entry.
3536 * @param obj The entry object
3537 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3542 elm_entry_cursor_up(Evas_Object *obj)
3544 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3545 Widget_Data *wd = elm_widget_data_get(obj);
3546 if (!wd) return EINA_FALSE;
3547 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3551 * This moves the cursor one line down within the entry.
3553 * @param obj The entry object
3554 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3559 elm_entry_cursor_down(Evas_Object *obj)
3561 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3562 Widget_Data *wd = elm_widget_data_get(obj);
3563 if (!wd) return EINA_FALSE;
3564 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3568 * This moves the cursor to the beginning of the entry.
3570 * @param obj The entry object
3575 elm_entry_cursor_begin_set(Evas_Object *obj)
3577 ELM_CHECK_WIDTYPE(obj, widtype);
3578 Widget_Data *wd = elm_widget_data_get(obj);
3580 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3584 * This moves the cursor to the end of the entry.
3586 * @param obj The entry object
3591 elm_entry_cursor_end_set(Evas_Object *obj)
3593 ELM_CHECK_WIDTYPE(obj, widtype);
3594 Widget_Data *wd = elm_widget_data_get(obj);
3597 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3600 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3601 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3606 * This moves the cursor to the beginning of the current line.
3608 * @param obj The entry object
3613 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3615 ELM_CHECK_WIDTYPE(obj, widtype);
3616 Widget_Data *wd = elm_widget_data_get(obj);
3618 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3622 * This moves the cursor to the end of the current line.
3624 * @param obj The entry object
3629 elm_entry_cursor_line_end_set(Evas_Object *obj)
3631 ELM_CHECK_WIDTYPE(obj, widtype);
3632 Widget_Data *wd = elm_widget_data_get(obj);
3634 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3638 * This begins a selection within the entry as though
3639 * the user were holding down the mouse button to make a selection.
3641 * @param obj The entry object
3646 elm_entry_cursor_selection_begin(Evas_Object *obj)
3648 ELM_CHECK_WIDTYPE(obj, widtype);
3649 Widget_Data *wd = elm_widget_data_get(obj);
3651 edje_object_part_text_select_begin(wd->ent, "elm.text");
3655 * This ends a selection within the entry as though
3656 * the user had just released the mouse button while making a selection.
3658 * @param obj The entry object
3663 elm_entry_cursor_selection_end(Evas_Object *obj)
3665 ELM_CHECK_WIDTYPE(obj, widtype);
3666 Widget_Data *wd = elm_widget_data_get(obj);
3668 edje_object_part_text_select_extend(wd->ent, "elm.text");
3672 * TODO: fill this in
3674 * @param obj The entry object
3675 * @return TODO: fill this in
3680 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3682 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3683 Widget_Data *wd = elm_widget_data_get(obj);
3684 if (!wd) return EINA_FALSE;
3685 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3689 * This returns whether the cursor is visible.
3691 * @param obj The entry object
3692 * @return If true, the cursor is visible.
3697 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3699 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3700 Widget_Data *wd = elm_widget_data_get(obj);
3701 if (!wd) return EINA_FALSE;
3702 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3706 * TODO: fill this in
3708 * @param obj The entry object
3709 * @return TODO: fill this in
3714 elm_entry_cursor_content_get(const Evas_Object *obj)
3716 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3717 Widget_Data *wd = elm_widget_data_get(obj);
3718 if (!wd) return NULL;
3719 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3723 * Sets the cursor position in the entry to the given value
3725 * @param obj The entry object
3726 * @param pos The position of the cursor
3731 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3733 ELM_CHECK_WIDTYPE(obj, widtype);
3734 Widget_Data *wd = elm_widget_data_get(obj);
3736 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3737 edje_object_message_signal_process(wd->ent);
3741 * Retrieves the current position of the cursor in the entry
3743 * @param obj The entry object
3744 * @return The cursor position
3749 elm_entry_cursor_pos_get(const Evas_Object *obj)
3751 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3752 Widget_Data *wd = elm_widget_data_get(obj);
3754 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3758 * This executes a "cut" action on the selected text in the entry.
3760 * @param obj The entry object
3765 elm_entry_selection_cut(Evas_Object *obj)
3767 ELM_CHECK_WIDTYPE(obj, widtype);
3768 Widget_Data *wd = elm_widget_data_get(obj);
3770 _cut(obj, NULL, NULL);
3774 * This executes a "copy" action on the selected text in the entry.
3776 * @param obj The entry object
3781 elm_entry_selection_copy(Evas_Object *obj)
3783 ELM_CHECK_WIDTYPE(obj, widtype);
3784 Widget_Data *wd = elm_widget_data_get(obj);
3786 _copy(obj, NULL, NULL);
3790 * This executes a "paste" action in the entry.
3792 * @param obj The entry object
3797 elm_entry_selection_paste(Evas_Object *obj)
3799 ELM_CHECK_WIDTYPE(obj, widtype);
3800 Widget_Data *wd = elm_widget_data_get(obj);
3802 _paste(obj, NULL, NULL);
3806 * This clears and frees the items in a entry's contextual (right click) menu.
3808 * @param obj The entry object
3813 elm_entry_context_menu_clear(Evas_Object *obj)
3815 ELM_CHECK_WIDTYPE(obj, widtype);
3816 Widget_Data *wd = elm_widget_data_get(obj);
3817 Elm_Entry_Context_Menu_Item *it;
3819 EINA_LIST_FREE(wd->items, it)
3821 eina_stringshare_del(it->label);
3822 eina_stringshare_del(it->icon_file);
3823 eina_stringshare_del(it->icon_group);
3829 * This adds an item to the entry's contextual menu.
3831 * @param obj The entry object
3832 * @param label The item's text label
3833 * @param icon_file The item's icon file
3834 * @param icon_type The item's icon type
3835 * @param func The callback to execute when the item is clicked
3836 * @param data The data to associate with the item for related functions
3841 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)
3843 ELM_CHECK_WIDTYPE(obj, widtype);
3844 Widget_Data *wd = elm_widget_data_get(obj);
3845 Elm_Entry_Context_Menu_Item *it;
3847 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3849 wd->items = eina_list_append(wd->items, it);
3851 it->label = eina_stringshare_add(label);
3852 it->icon_file = eina_stringshare_add(icon_file);
3853 it->icon_type = icon_type;
3855 it->data = (void *)data;
3859 * This disables the entry's contextual (right click) menu.
3861 * @param obj The entry object
3862 * @param disabled If true, the menu is disabled
3867 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3869 ELM_CHECK_WIDTYPE(obj, widtype);
3870 Widget_Data *wd = elm_widget_data_get(obj);
3872 if (wd->context_menu == !disabled) return;
3873 wd->context_menu = !disabled;
3877 * This returns whether the entry's contextual (right click) menu is disabled.
3879 * @param obj The entry object
3880 * @return If true, the menu is disabled
3885 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3887 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3888 Widget_Data *wd = elm_widget_data_get(obj);
3889 if (!wd) return EINA_FALSE;
3890 return !wd->context_menu;
3894 * This appends a custom item provider to the list for that entry
3896 * This appends the given callback. The list is walked from beginning to end
3897 * with each function called given the item href string in the text. If the
3898 * function returns an object handle other than NULL (it should create an
3899 * and object to do this), then this object is used to replace that item. If
3900 * not the next provider is called until one provides an item object, or the
3901 * default provider in entry does.
3903 * @param obj The entry object
3904 * @param func The function called to provide the item object
3905 * @param data The data passed to @p func
3910 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3912 ELM_CHECK_WIDTYPE(obj, widtype);
3913 Widget_Data *wd = elm_widget_data_get(obj);
3915 EINA_SAFETY_ON_NULL_RETURN(func);
3916 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3920 wd->item_providers = eina_list_append(wd->item_providers, ip);
3924 * This prepends a custom item provider to the list for that entry
3926 * This prepends the given callback. See elm_entry_item_provider_append() for
3929 * @param obj The entry object
3930 * @param func The function called to provide the item object
3931 * @param data The data passed to @p func
3936 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3938 ELM_CHECK_WIDTYPE(obj, widtype);
3939 Widget_Data *wd = elm_widget_data_get(obj);
3941 EINA_SAFETY_ON_NULL_RETURN(func);
3942 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3946 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3950 * This removes a custom item provider to the list for that entry
3952 * This removes the given callback. See elm_entry_item_provider_append() for
3955 * @param obj The entry object
3956 * @param func The function called to provide the item object
3957 * @param data The data passed to @p func
3962 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3964 ELM_CHECK_WIDTYPE(obj, widtype);
3965 Widget_Data *wd = elm_widget_data_get(obj);
3967 Elm_Entry_Item_Provider *ip;
3969 EINA_SAFETY_ON_NULL_RETURN(func);
3970 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3972 if ((ip->func == func) && ((!data) || (ip->data == data)))
3974 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3982 * Append a filter function for text inserted in the entry
3984 * Append the given callback to the list. This functions will be called
3985 * whenever any text is inserted into the entry, with the text to be inserted
3986 * as a parameter. The callback function is free to alter the text in any way
3987 * it wants, but it must remember to free the given pointer and update it.
3988 * If the new text is to be discarded, the function can free it and set it text
3989 * parameter to NULL. This will also prevent any following filters from being
3992 * @param obj The entry object
3993 * @param func The function to use as text filter
3994 * @param data User data to pass to @p func
3999 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4002 Elm_Entry_Text_Filter *tf;
4003 ELM_CHECK_WIDTYPE(obj, widtype);
4005 wd = elm_widget_data_get(obj);
4007 EINA_SAFETY_ON_NULL_RETURN(func);
4009 tf = _filter_new(func, data);
4012 wd->text_filters = eina_list_append(wd->text_filters, tf);
4016 * Prepend a filter function for text insdrted in the entry
4018 * Prepend the given callback to the list. See elm_entry_text_filter_append()
4019 * for more information
4021 * @param obj The entry object
4022 * @param func The function to use as text filter
4023 * @param data User data to pass to @p func
4028 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4031 Elm_Entry_Text_Filter *tf;
4032 ELM_CHECK_WIDTYPE(obj, widtype);
4034 wd = elm_widget_data_get(obj);
4036 EINA_SAFETY_ON_NULL_RETURN(func);
4038 tf = _filter_new(func, data);
4041 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
4045 * Remove a filter from the list
4047 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
4048 * for more information.
4050 * @param obj The entry object
4051 * @param func The filter function to remove
4052 * @param data The user data passed when adding the function
4057 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4061 Elm_Entry_Text_Filter *tf;
4062 ELM_CHECK_WIDTYPE(obj, widtype);
4064 wd = elm_widget_data_get(obj);
4066 EINA_SAFETY_ON_NULL_RETURN(func);
4068 EINA_LIST_FOREACH(wd->text_filters, l, tf)
4070 if ((tf->func == func) && ((!data) || (tf->data == data)))
4072 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
4080 * This converts a markup (HTML-like) string into UTF-8.
4081 * Returning string is obtained with malloc.
4082 * After use the returned string, it should be freed.
4084 * @param s The string (in markup) to be converted
4085 * @return The converted string (in UTF-8). It should be freed.
4090 elm_entry_markup_to_utf8(const char *s)
4092 char *ss = _elm_util_mkup_to_text(s);
4093 if (!ss) ss = strdup("");
4098 * This converts a UTF-8 string into markup (HTML-like).
4099 * Returning string is obtained with malloc.
4100 * After use the returned string, it should be freed.
4102 * @param s The string (in UTF-8) to be converted
4103 * @return The converted string (in markup). It should be freed.
4108 elm_entry_utf8_to_markup(const char *s)
4110 char *ss = _elm_util_text_to_mkup(s);
4111 if (!ss) ss = strdup("");
4116 * Filter inserted text based on user defined character and byte limits
4118 * Add this filter to an entry to limit the characters that it will accept
4119 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
4120 * The funtion works on the UTF-8 representation of the string, converting
4121 * it from the set markup, thus not accounting for any format in it.
4123 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
4124 * it as data when setting the filter. In it it's possible to set limits
4125 * by character count or bytes (any of them is disabled if 0), and both can
4126 * be set at the same time. In that case, it first checks for characters,
4129 * The function will cut the inserted text in order to allow only the first
4130 * number of characters that are still allowed. The cut is made in
4131 * characters, even when limiting by bytes, in order to always contain
4132 * valid ones and avoid half unicode characters making it in.
4137 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4139 Elm_Entry_Filter_Limit_Size *lim = data;
4142 const char *(*text_get)(const Evas_Object *);
4143 const char *widget_type;
4145 EINA_SAFETY_ON_NULL_RETURN(data);
4146 EINA_SAFETY_ON_NULL_RETURN(entry);
4147 EINA_SAFETY_ON_NULL_RETURN(text);
4149 /* hack. I don't want to copy the entire function to work with
4151 widget_type = elm_widget_type_get(entry);
4152 if (!strcmp(widget_type, "entry"))
4153 text_get = elm_entry_entry_get;
4157 current = elm_entry_markup_to_utf8(text_get(entry));
4159 if (lim->max_char_count > 0)
4161 len = evas_string_char_len_get(current);
4162 if (len >= lim->max_char_count)
4164 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4170 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4171 if ((len + newlen) > lim->max_char_count)
4172 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4174 else if (lim->max_byte_count > 0)
4176 len = strlen(current);
4177 if (len >= lim->max_byte_count)
4179 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4185 newlen = strlen(elm_entry_markup_to_utf8(*text));
4186 if ((len + newlen) > lim->max_byte_count)
4187 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4193 * Filter inserted text based on accepted or rejected sets of characters
4195 * Add this filter to an entry to restrict the set of accepted characters
4196 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4197 * This structure contains both accepted and rejected sets, but they are
4198 * mutually exclusive. If accepted is set, it will be used, otherwise it
4199 * goes on to the rejected set.
4202 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4204 Elm_Entry_Filter_Accept_Set *as = data;
4208 int read_idx, last_read_idx = 0, read_char;
4210 EINA_SAFETY_ON_NULL_RETURN(data);
4211 EINA_SAFETY_ON_NULL_RETURN(text);
4213 if ((!as->accepted) && (!as->rejected))
4219 goes_in = EINA_TRUE;
4224 goes_in = EINA_FALSE;
4228 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4231 int cmp_idx, cmp_char;
4232 Eina_Bool in_set = EINA_FALSE;
4234 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4237 if (read_char == cmp_char)
4242 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4244 if (in_set == goes_in)
4246 int size = read_idx - last_read_idx;
4247 const char *src = (*text) + last_read_idx;
4249 memcpy(insert, *text + last_read_idx, size);
4252 last_read_idx = read_idx;
4253 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4259 * This sets the file (and implicitly loads it) for the text to display and
4260 * then edit. All changes are written back to the file after a short delay if
4261 * the entry object is set to autosave.
4263 * @param obj The entry object
4264 * @param file The path to the file to load and save
4265 * @param format The file format
4270 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4272 ELM_CHECK_WIDTYPE(obj, widtype);
4273 Widget_Data *wd = elm_widget_data_get(obj);
4275 if (wd->delay_write)
4277 ecore_timer_del(wd->delay_write);
4278 wd->delay_write = NULL;
4280 if (wd->autosave) _save(obj);
4281 eina_stringshare_replace(&wd->file, file);
4282 wd->format = format;
4287 * Gets the file to load and save and the file format
4289 * @param obj The entry object
4290 * @param file The path to the file to load and save
4291 * @param format The file format
4296 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4298 ELM_CHECK_WIDTYPE(obj, widtype);
4299 Widget_Data *wd = elm_widget_data_get(obj);
4301 if (file) *file = wd->file;
4302 if (format) *format = wd->format;
4306 * This function writes any changes made to the file set with
4307 * elm_entry_file_set()
4309 * @param obj The entry object
4314 elm_entry_file_save(Evas_Object *obj)
4316 ELM_CHECK_WIDTYPE(obj, widtype);
4317 Widget_Data *wd = elm_widget_data_get(obj);
4319 if (wd->delay_write)
4321 ecore_timer_del(wd->delay_write);
4322 wd->delay_write = NULL;
4325 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4329 * This sets the entry object to 'autosave' the loaded text file or not.
4331 * @param obj The entry object
4332 * @param autosave Autosave the loaded file or not
4337 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4339 ELM_CHECK_WIDTYPE(obj, widtype);
4340 Widget_Data *wd = elm_widget_data_get(obj);
4342 wd->autosave = !!autosave;
4346 * This gets the entry object's 'autosave' status.
4348 * @param obj The entry object
4349 * @return Autosave the loaded file or not
4354 elm_entry_autosave_get(const Evas_Object *obj)
4356 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4357 Widget_Data *wd = elm_widget_data_get(obj);
4358 if (!wd) return EINA_FALSE;
4359 return wd->autosave;
4363 * Control pasting of text and images for the widget.
4365 * Normally the entry allows both text and images to be pasted. By setting
4366 * textonly to be true, this prevents images from being pasted.
4368 * Note this only changes the behaviour of text.
4370 * @param obj The entry object
4371 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4376 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4378 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4379 ELM_CHECK_WIDTYPE(obj, widtype);
4380 Widget_Data *wd = elm_widget_data_get(obj);
4382 textonly = !!textonly;
4383 if (wd->textonly == textonly) return;
4384 wd->textonly = !!textonly;
4385 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4386 #ifdef HAVE_ELEMENTARY_X
4387 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4392 * Getting elm_entry text paste/drop mode.
4394 * In textonly mode, only text may be pasted or dropped into the widget.
4396 * @param obj The entry object
4397 * @return If the widget only accepts text from pastes.
4402 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4404 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4405 Widget_Data *wd = elm_widget_data_get(obj);
4406 if (!wd) return EINA_FALSE;
4407 return wd->textonly;
4411 * Enable or disable scrolling in entry
4413 * Normally the entry is not scrollable unless you enable it with this call.
4415 * @param obj The entry object
4416 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4421 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4423 ELM_CHECK_WIDTYPE(obj, widtype);
4424 Widget_Data *wd = elm_widget_data_get(obj);
4427 if (wd->scroll == scroll) return;
4428 wd->scroll = scroll;
4431 elm_widget_sub_object_del(obj, wd->scroller);
4432 elm_widget_resize_object_set(obj, wd->scroller);
4433 elm_widget_sub_object_add(obj, wd->ent);
4434 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4435 evas_object_show(wd->scroller);
4436 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4437 if (wd->single_line)
4439 elm_smart_scroller_policy_set(wd->scroller,
4440 ELM_SMART_SCROLLER_POLICY_OFF,
4441 ELM_SMART_SCROLLER_POLICY_OFF);
4442 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4446 const Elm_Scroller_Policy map[3] =
4448 ELM_SMART_SCROLLER_POLICY_AUTO,
4449 ELM_SMART_SCROLLER_POLICY_ON,
4450 ELM_SMART_SCROLLER_POLICY_OFF
4452 elm_smart_scroller_policy_set(wd->scroller,
4455 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4460 elm_smart_scroller_child_set(wd->scroller, NULL);
4461 elm_widget_sub_object_del(obj, wd->ent);
4462 elm_widget_resize_object_set(obj, wd->ent);
4463 evas_object_smart_member_add(wd->scroller, obj);
4464 elm_widget_sub_object_add(obj, wd->scroller);
4465 evas_object_hide(wd->scroller);
4466 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4473 * Get the scrollable state of the entry
4475 * Normally the entry is not scrollable. This gets the scrollable state
4476 * of the entry. See elm_entry_scrollable_set() for more information.
4478 * @param obj The entry object
4479 * @return The scrollable state
4484 elm_entry_scrollable_get(const Evas_Object *obj)
4486 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4487 Widget_Data *wd = elm_widget_data_get(obj);
4488 if (!wd) return EINA_FALSE;
4493 * This sets a widget to be displayed to the left of a scrolled entry.
4495 * @param obj The scrolled entry object
4496 * @param icon The widget to display on the left side of the scrolled
4499 * @note A previously set widget will be destroyed.
4500 * @note If the object being set does not have minimum size hints set,
4501 * it won't get properly displayed.
4504 * @see elm_entry_end_set
4507 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4509 ELM_CHECK_WIDTYPE(obj, widtype);
4510 Widget_Data *wd = elm_widget_data_get(obj);
4513 EINA_SAFETY_ON_NULL_RETURN(icon);
4514 if (wd->icon == icon) return;
4515 if (wd->icon) evas_object_del(wd->icon);
4517 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4519 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4520 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4525 * Gets the leftmost widget of the scrolled entry. This object is
4526 * owned by the scrolled entry and should not be modified.
4528 * @param obj The scrolled entry object
4529 * @return the left widget inside the scroller
4534 elm_entry_icon_get(const Evas_Object *obj)
4536 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4537 Widget_Data *wd = elm_widget_data_get(obj);
4538 if (!wd) return NULL;
4543 * Unset the leftmost widget of the scrolled entry, unparenting and
4546 * @param obj The scrolled entry object
4547 * @return the previously set icon sub-object of this entry, on
4550 * @see elm_entry_icon_set()
4555 elm_entry_icon_unset(Evas_Object *obj)
4557 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4558 Widget_Data *wd = elm_widget_data_get(obj);
4559 Evas_Object *ret = NULL;
4560 if (!wd) return NULL;
4563 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4564 if (!edje) return NULL;
4566 edje_object_part_unswallow(edje, wd->icon);
4567 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4575 * Sets the visibility of the left-side widget of the scrolled entry,
4576 * set by @elm_entry_icon_set().
4578 * @param obj The scrolled entry object
4579 * @param setting EINA_TRUE if the object should be displayed,
4580 * EINA_FALSE if not.
4585 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4587 ELM_CHECK_WIDTYPE(obj, widtype);
4588 Widget_Data *wd = elm_widget_data_get(obj);
4589 if ((!wd) || (!wd->icon)) return;
4591 evas_object_hide(wd->icon);
4593 evas_object_show(wd->icon);
4598 * This sets a widget to be displayed to the end of a scrolled entry.
4600 * @param obj The scrolled entry object
4601 * @param end The widget to display on the right side of the scrolled
4604 * @note A previously set widget will be destroyed.
4605 * @note If the object being set does not have minimum size hints set,
4606 * it won't get properly displayed.
4609 * @see elm_entry_icon_set
4612 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4614 ELM_CHECK_WIDTYPE(obj, widtype);
4615 Widget_Data *wd = elm_widget_data_get(obj);
4618 EINA_SAFETY_ON_NULL_RETURN(end);
4619 if (wd->end == end) return;
4620 if (wd->end) evas_object_del(wd->end);
4622 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4624 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4625 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4630 * Gets the endmost widget of the scrolled entry. This object is owned
4631 * by the scrolled entry and should not be modified.
4633 * @param obj The scrolled entry object
4634 * @return the right widget inside the scroller
4639 elm_entry_end_get(const Evas_Object *obj)
4641 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4642 Widget_Data *wd = elm_widget_data_get(obj);
4643 if (!wd) return NULL;
4648 * Unset the endmost widget of the scrolled entry, unparenting and
4651 * @param obj The scrolled entry object
4652 * @return the previously set icon sub-object of this entry, on
4655 * @see elm_entry_icon_set()
4660 elm_entry_end_unset(Evas_Object *obj)
4662 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4663 Widget_Data *wd = elm_widget_data_get(obj);
4664 Evas_Object *ret = NULL;
4665 if (!wd) return NULL;
4668 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4669 if (!edje) return NULL;
4671 edje_object_part_unswallow(edje, wd->end);
4672 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4680 * Sets the visibility of the end widget of the scrolled entry, set by
4681 * @elm_entry_end_set().
4683 * @param obj The scrolled entry object
4684 * @param setting EINA_TRUE if the object should be displayed,
4685 * EINA_FALSE if not.
4690 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4692 ELM_CHECK_WIDTYPE(obj, widtype);
4693 Widget_Data *wd = elm_widget_data_get(obj);
4694 if ((!wd) || (!wd->end)) return;
4696 evas_object_hide(wd->end);
4698 evas_object_show(wd->end);
4703 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4705 * @param obj The scrolled entry object
4706 * @param h The horizontal scrollbar policy to apply
4707 * @param v The vertical scrollbar policy to apply
4712 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4714 ELM_CHECK_WIDTYPE(obj, widtype);
4715 Widget_Data *wd = elm_widget_data_get(obj);
4716 const Elm_Scroller_Policy map[3] =
4718 ELM_SMART_SCROLLER_POLICY_AUTO,
4719 ELM_SMART_SCROLLER_POLICY_ON,
4720 ELM_SMART_SCROLLER_POLICY_OFF
4725 elm_smart_scroller_policy_set(wd->scroller,
4731 * This enables/disables bouncing within the entry.
4733 * @param obj The scrolled entry object
4734 * @param h The horizontal bounce state
4735 * @param v The vertical bounce state
4740 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4742 ELM_CHECK_WIDTYPE(obj, widtype);
4743 Widget_Data *wd = elm_widget_data_get(obj);
4745 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4749 * Get the bounce mode
4751 * @param obj The Entry object
4752 * @param h_bounce Allow bounce horizontally
4753 * @param v_bounce Allow bounce vertically
4758 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4760 ELM_CHECK_WIDTYPE(obj, widtype);
4761 Widget_Data *wd = elm_widget_data_get(obj);
4763 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4766 EINA_DEPRECATED EAPI void
4767 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4769 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);
4773 * Set background color of the entry
4775 * @param obj The entry object
4776 * @param r Red property background color of The entry object
4777 * @param g Green property background color of The entry object
4778 * @param b Blue property background color of The entry object
4779 * @param a Alpha property background alpha of The entry object
4783 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4785 ELM_CHECK_WIDTYPE(obj, widtype);
4786 Widget_Data *wd = elm_widget_data_get(obj);
4787 evas_object_color_set(wd->bg, r, g, b, a);
4789 if (wd->bgcolor == EINA_FALSE)
4792 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4797 * Set whether entry should support auto capitalization
4799 * @param obj The entry object
4800 * @param on If true, entry suports auto capitalization.
4805 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4807 ELM_CHECK_WIDTYPE(obj, widtype);
4808 Widget_Data *wd = elm_widget_data_get(obj);
4812 wd->autocapital = EINA_FALSE;
4814 wd->autocapital = autocap;
4816 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4817 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4818 wd->autocapital = EINA_FALSE;
4820 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
4824 * Set whether entry should support auto period
4826 * @param obj The entry object
4827 * @param on If true, entry suports auto period.
4832 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4834 ELM_CHECK_WIDTYPE(obj, widtype);
4835 Widget_Data *wd = elm_widget_data_get(obj);
4839 wd->autoperiod = EINA_FALSE;
4841 wd->autoperiod = autoperiod;
4843 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4844 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4845 wd->autoperiod = EINA_FALSE;
4847 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4851 * Set whether entry should enable the return key on soft keyboard automatically
4853 * @param obj The entry object
4854 * @param on If true, entry enables the return key on soft keyboard automatically.
4859 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
4861 ELM_CHECK_WIDTYPE(obj, widtype);
4862 Widget_Data *wd = elm_widget_data_get(obj);
4865 wd->autoreturnkey = on;
4866 _check_enable_returnkey(obj);
4870 * This sets the attribute to show the input panel automatically.
4872 * @param obj The entry object
4873 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4878 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4880 ELM_CHECK_WIDTYPE(obj, widtype);
4881 Widget_Data *wd = elm_widget_data_get(obj);
4884 wd->input_panel_enable = enabled;
4885 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4889 * Set the input panel layout of the entry
4891 * @param obj The entry object
4892 * @param layout the layout to set
4897 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4899 ELM_CHECK_WIDTYPE(obj, widtype);
4900 Widget_Data *wd = elm_widget_data_get(obj);
4903 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4906 wd->input_panel_layout = layout;
4908 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4912 * Get the input method context in the entry widget
4914 * @param obj The entry object
4915 * @return The input method context
4919 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
4921 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4922 Widget_Data *wd = elm_widget_data_get(obj);
4923 if (!wd || !wd->ent) return NULL;
4925 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4929 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
4931 Widget_Data *wd = elm_widget_data_get(obj);
4936 Evas_Coord max_w = 9999, max_h = 9999;
4937 const char* key_data = NULL;
4939 wd->matchlist_threshold = 1;
4940 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
4941 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
4942 elm_hover_target_set(wd->hover, obj);
4943 elm_object_style_set(wd->hover, "matchlist");
4945 wd->layout = elm_layout_add(wd->hover);
4946 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
4947 wd->list = elm_list_add(wd->layout);
4948 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
4949 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
4950 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
4951 elm_object_style_set(wd->list, "matchlist");
4953 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
4954 if (key_data) max_w = atoi(key_data);
4955 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
4956 if (key_data) max_h = atoi(key_data);
4958 elm_list_go(wd->list);
4959 evas_object_size_hint_max_set(wd->list, max_w, max_h);
4960 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
4961 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
4962 elm_hover_content_set(wd->hover, "bottom", wd->layout);
4964 wd->match_list = match_list;
4969 evas_object_del(wd->hover);
4971 wd->match_list = NULL;
4974 wd->matchlist_case_sensitive = case_sensitive;
4978 * Set the magnifier style of the entry
4980 * @param obj The entry object
4981 * @param type the magnifier style to set
4986 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4988 ELM_CHECK_WIDTYPE(obj, widtype);
4989 Widget_Data *wd = elm_widget_data_get(obj);
4992 wd->mgf_type = type;
4993 _magnifier_create(obj);
4997 * Set wrap width of the entry
4999 * @param obj The entry object
5000 * @param w The wrap width in pixels at a minimum where words need to wrap
5004 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
5006 Widget_Data *wd = elm_widget_data_get(obj);
5008 if (wd->wrap_w == w) return;
5014 * get wrap width of the entry
5016 * @param obj The entry object
5017 * @return The wrap width in pixels at a minimum where words need to wrap
5021 elm_entry_wrap_width_get(const Evas_Object *obj)
5023 Widget_Data *wd = elm_widget_data_get(obj);
5029 * Set the font size on the entry object
5031 * @param obj The entry object
5032 * @param size font size
5037 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
5039 ELM_CHECK_WIDTYPE(obj, widtype);
5040 Widget_Data *wd = elm_widget_data_get(obj);
5041 Eina_Strbuf *fontbuf = NULL;
5046 t = eina_stringshare_add(elm_entry_entry_get(obj));
5047 fontbuf = eina_strbuf_new();
5048 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
5050 if (fontsize == 0) removeflag = 1; // remove fontsize tag
5052 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
5054 elm_entry_entry_set(obj, t);
5058 eina_strbuf_free(fontbuf);
5059 eina_stringshare_del(t);
5063 * Set the text color on the entry object
5065 * @param obj The entry object
5066 * @param r Red property background color of The entry object
5067 * @param g Green property background color of The entry object
5068 * @param b Blue property background color of The entry object
5069 * @param a Alpha property background alpha of The entry object
5074 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
5076 ELM_CHECK_WIDTYPE(obj, widtype);
5077 Widget_Data *wd = elm_widget_data_get(obj);
5078 Eina_Strbuf *colorbuf = NULL;
5083 t = eina_stringshare_add(elm_entry_entry_get(obj));
5085 if (len <= 0) return;
5086 colorbuf = eina_strbuf_new();
5087 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
5089 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
5091 elm_entry_entry_set(obj, t);
5095 eina_strbuf_free(colorbuf);
5096 eina_stringshare_del(t);
5100 * Set the text align on the entry object
5102 * @param obj The entry object
5103 * @param align align mode
5108 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
5110 ELM_CHECK_WIDTYPE(obj, widtype);
5111 Widget_Data *wd = elm_widget_data_get(obj);
5116 t = eina_stringshare_add(elm_entry_entry_get(obj));
5118 if (len <= 0) return;
5120 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
5121 elm_entry_entry_set(obj, t);
5125 eina_stringshare_del(t);