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 Elm_Autocapital_Type autocapital_type;
157 Eina_Bool changed : 1;
158 Eina_Bool single_line : 1;
159 Eina_Bool password : 1;
160 Eina_Bool editable : 1;
161 Eina_Bool selection_asked : 1;
162 Eina_Bool have_selection : 1;
163 Eina_Bool selmode : 1;
164 Eina_Bool deferred_cur : 1;
165 Eina_Bool cur_changed : 1;
166 Eina_Bool disabled : 1;
167 Eina_Bool double_clicked : 1;
168 Eina_Bool long_pressed : 1;
169 Eina_Bool context_menu : 1;
170 Eina_Bool drag_selection_asked : 1;
171 Eina_Bool bgcolor : 1;
172 Eina_Bool can_write : 1;
173 Eina_Bool autosave : 1;
174 Eina_Bool textonly : 1;
175 Eina_Bool usedown : 1;
176 Eina_Bool scroll : 1;
177 Eina_Bool input_panel_enable : 1;
178 Eina_Bool autoreturnkey : 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 _elm_widget_mirrored_reload(obj);
642 _mirrored_set(obj, elm_widget_mirrored_get(obj));
644 t = eina_stringshare_add(elm_entry_entry_get(obj));
645 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
646 if (_elm_config->desktop_entry)
647 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
648 elm_entry_entry_set(obj, t);
649 eina_stringshare_del(t);
650 if (elm_widget_disabled_get(obj))
651 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
652 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
653 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
654 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
655 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
656 if (elm_widget_focus_get(obj))
657 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
658 edje_object_message_signal_process(wd->ent);
659 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
660 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
661 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
662 elm_widget_style_get(obj));
668 edj = elm_smart_scroller_edje_object_get(wd->scroller);
669 str = edje_object_data_get(edj, "focus_highlight");
670 if ((str) && (!strcmp(str, "on")))
671 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
673 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
679 _disable_hook(Evas_Object *obj)
681 Widget_Data *wd = elm_widget_data_get(obj);
683 if (elm_widget_disabled_get(obj))
685 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
686 wd->disabled = EINA_TRUE;
690 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
691 wd->disabled = EINA_FALSE;
696 _recalc_cursor_geometry(Evas_Object *obj)
698 Widget_Data *wd = elm_widget_data_get(obj);
700 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
701 if (!elm_object_focus_get(obj)) return;
702 if (!wd->deferred_recalc_job)
704 Evas_Coord cx, cy, cw, ch;
705 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
709 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
710 wd->cur_changed = EINA_FALSE;
714 wd->deferred_cur = EINA_TRUE;
718 _elm_win_recalc_job(void *data)
720 Widget_Data *wd = elm_widget_data_get(data);
721 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
723 wd->deferred_recalc_job = NULL;
725 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
726 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
727 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
730 /* This is a hack to workaround the way min size hints are treated.
731 * If the minimum width is smaller than the restricted width, it means
732 * the mininmum doesn't matter. */
735 Evas_Coord ominw = -1;
736 evas_object_size_hint_min_get(data, &ominw, NULL);
740 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
743 Evas_Coord vmw = 0, vmh = 0;
745 edje_object_size_min_calc
746 (elm_smart_scroller_edje_object_get(wd->scroller),
750 evas_object_size_hint_min_set(data, vmw, minh + vmh);
751 evas_object_size_hint_max_set(data, -1, minh + vmh);
755 evas_object_size_hint_min_set(data, vmw, vmh);
756 evas_object_size_hint_max_set(data, -1, -1);
763 evas_object_size_hint_min_set(data, minw, minh);
764 evas_object_size_hint_max_set(data, -1, minh);
768 evas_object_size_hint_min_set(data, fw, minh);
769 evas_object_size_hint_max_set(data, -1, -1);
773 if ((wd->deferred_cur) && (elm_object_focus_get(data)))
775 Evas_Coord cx, cy, cw, ch;
776 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
780 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
781 wd->cur_changed = EINA_FALSE;
787 _sizing_eval(Evas_Object *obj)
789 Widget_Data *wd = elm_widget_data_get(obj);
790 Evas_Coord minw = -1, minh = -1;
791 Evas_Coord resw, resh;
794 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
797 if ((resw == wd->lastw) && (!wd->changed)) return;
798 wd->changed = EINA_FALSE;
802 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
804 evas_object_resize(wd->scroller, resw, resh);
805 edje_object_size_min_calc
806 (elm_smart_scroller_edje_object_get(wd->scroller),
808 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
809 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
812 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
814 if ((minw > 0) && (vw < minw)) vw = minw;
815 if (minh > vh) vh = minh;
817 if (wd->single_line) h = vmh + minh;
819 evas_object_resize(wd->ent, vw, vh);
820 evas_object_size_hint_min_get(obj, &w, NULL);
821 evas_object_size_hint_min_set(obj, w, h);
823 evas_object_size_hint_max_set(obj, -1, h);
825 evas_object_size_hint_max_set(obj, -1, -1);
829 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
830 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
835 if (!wd->changed) return;
836 wd->changed = EINA_FALSE;
840 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
842 edje_object_size_min_calc(wd->ent, &minw, &minh);
845 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
847 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
849 if ((minw > 0) && (vw < minw)) vw = minw;
850 if (minh > 0) vh = minh;
852 evas_object_resize(wd->ent, vw, vh);
853 edje_object_size_min_calc
854 (elm_smart_scroller_edje_object_get(wd->scroller),
856 if (wd->single_line) h = vmh + minh;
858 evas_object_size_hint_min_get(obj, &w, NULL);
859 evas_object_size_hint_min_set(obj, w, h);
861 evas_object_size_hint_max_set(obj, -1, h);
863 evas_object_size_hint_max_set(obj, -1, -1);
867 edje_object_size_min_calc(wd->ent, &minw, &minh);
870 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
871 evas_object_size_hint_min_set(obj, minw, minh);
873 evas_object_size_hint_max_set(obj, -1, minh);
875 evas_object_size_hint_max_set(obj, -1, -1);
879 _recalc_cursor_geometry(obj);
883 _check_enable_returnkey(Evas_Object *obj)
885 Widget_Data *wd = elm_widget_data_get(obj);
888 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
891 if (!wd->autoreturnkey) return;
893 if (_entry_length_get(obj) == 0)
895 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
899 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
904 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
906 Widget_Data *wd = elm_widget_data_get(obj);
907 Evas_Object *top = elm_widget_top_get(obj);
909 if (elm_widget_focus_get(obj))
911 printf("[Elm_entry::Focused] obj : %p\n", obj);
912 evas_object_focus_set(wd->ent, EINA_TRUE);
913 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
914 if (top && wd->input_panel_enable)
915 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
916 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
917 _check_enable_returnkey(obj);
918 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
922 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
923 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
924 evas_object_focus_set(wd->ent, EINA_FALSE);
925 if (top && wd->input_panel_enable)
926 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
927 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
929 if ((wd->api) && (wd->api->obj_hidemenu))
931 wd->api->obj_hidemenu(obj);
938 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
940 Widget_Data *wd = elm_widget_data_get(obj);
942 if ((!wd) || (!content)) return;
946 edje = elm_smart_scroller_edje_object_get(wd->scroller);
947 if (!strcmp(part, "elm.swallow.icon"))
950 evas_object_del(wd->icon);
952 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
954 else if (!strcmp(part, "elm.swallow.end"))
957 evas_object_del(wd->end);
959 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
964 evas_event_freeze(evas_object_evas_get(obj));
965 elm_widget_sub_object_add(obj, content);
966 edje_object_part_swallow(edje, part, content);
968 evas_event_thaw(evas_object_evas_get(obj));
969 evas_event_thaw_eval(evas_object_evas_get(obj));
973 _content_unset_hook(Evas_Object *obj, const char *part)
975 Widget_Data *wd = elm_widget_data_get(obj);
976 Evas_Object *content, *edje;
977 if (!wd) return NULL;
981 edje = elm_smart_scroller_edje_object_get(wd->scroller);
982 if (!strcmp(part, "elm.swallow.icon"))
985 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
987 else if (!strcmp(part, "elm.swallow.end"))
990 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
996 content = edje_object_part_swallow_get(edje, part);
997 edje_object_part_swallow(edje, part, NULL);
998 if (!content) return NULL;
999 evas_event_freeze(evas_object_evas_get(obj));
1000 elm_widget_sub_object_del(obj, content);
1001 edje_object_part_unswallow(wd->ent, content);
1003 evas_event_thaw(evas_object_evas_get(obj));
1004 evas_event_thaw_eval(evas_object_evas_get(obj));
1009 static Evas_Object *
1010 _content_get_hook(const Evas_Object *obj, const char *part)
1012 Widget_Data *wd = elm_widget_data_get(obj);
1013 Evas_Object *content = NULL, *edje;
1014 if (!wd) return NULL;
1018 if (!strcmp(part, "elm.swallow.icon"))
1020 if (!strcmp(part, "elm.swallow.end"))
1023 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1029 content = edje_object_part_swallow_get(edje, part);
1035 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
1037 Widget_Data *wd = elm_widget_data_get(obj);
1039 edje_object_signal_emit(wd->ent, emission, source);
1041 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
1046 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1048 Widget_Data *wd = elm_widget_data_get(obj);
1050 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
1052 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
1053 emission, source, func_cb, data);
1057 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1059 Widget_Data *wd = elm_widget_data_get(obj);
1060 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
1063 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
1064 emission, source, func_cb, data);
1068 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1070 Widget_Data *wd = elm_widget_data_get(obj);
1071 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
1075 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1077 Widget_Data *wd = elm_widget_data_get(obj);
1079 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1083 _show_region_hook(void *data, Evas_Object *obj)
1085 Widget_Data *wd = elm_widget_data_get(data);
1086 Evas_Coord x, y, w, h;
1088 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1090 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1094 _sub_del(void *data, Evas_Object *obj, void *event_info)
1096 Widget_Data *wd = data;
1097 Evas_Object *sub = event_info;
1100 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1101 if (sub == wd->icon)
1105 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1107 else if (sub == wd->end)
1111 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1117 _hoversel_position(Evas_Object *obj)
1119 Widget_Data *wd = elm_widget_data_get(obj);
1120 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1125 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1134 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1135 &cx, &cy, &cw, &ch);
1136 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1139 cx += (cw - mw) / 2;
1144 cy += (ch - mh) / 2;
1147 evas_object_move(wd->hoversel, x + cx, y + cy);
1148 evas_object_resize(wd->hoversel, cw, ch);
1152 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1154 Widget_Data *wd = elm_widget_data_get(data);
1156 if (wd->hoversel) _hoversel_position(data);
1160 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1162 Widget_Data *wd = elm_widget_data_get(data);
1169 else if (wd->scroll)
1171 Evas_Coord vw = 0, vh = 0;
1173 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1174 if (vw < wd->entmw) vw = wd->entmw;
1175 if (vh < wd->entmh) vh = wd->entmh;
1176 evas_object_resize(wd->ent, vw, vh);
1178 if (wd->hoversel) _hoversel_position(data);
1182 _hover_del(void *data)
1184 Widget_Data *wd = elm_widget_data_get(data);
1189 evas_object_del(wd->hoversel);
1190 wd->hoversel = NULL;
1192 wd->hovdeljob = NULL;
1196 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1198 Widget_Data *wd = elm_widget_data_get(data);
1201 if (wd->hoversel) evas_object_hide(wd->hoversel);
1204 if (!_elm_config->desktop_entry)
1207 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1210 elm_widget_scroll_freeze_pop(data);
1211 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1212 wd->hovdeljob = ecore_job_add(_hover_del, data);
1216 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1218 Widget_Data *wd = elm_widget_data_get(data);
1220 wd->selmode = EINA_TRUE;
1221 edje_object_part_text_select_none(wd->ent, "elm.text");
1222 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1223 edje_object_part_text_select_all(wd->ent, "elm.text");
1224 elm_object_scroll_freeze_pop(data);
1228 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1230 Widget_Data *wd = elm_widget_data_get(data);
1232 wd->selmode = EINA_TRUE;
1233 edje_object_part_text_select_none(wd->ent, "elm.text");
1234 if (!_elm_config->desktop_entry)
1237 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1239 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1240 if (!_elm_config->desktop_entry)
1241 elm_object_scroll_freeze_pop(data);
1242 //elm_widget_scroll_hold_push(data);
1246 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1248 Widget_Data *wd = elm_widget_data_get(data);
1250 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1251 if (wd->sel_notify_handler)
1253 #ifdef HAVE_ELEMENTARY_X
1254 Elm_Sel_Format formats;
1255 wd->selection_asked = EINA_TRUE;
1256 formats = ELM_SEL_FORMAT_MARKUP;
1258 formats |= ELM_SEL_FORMAT_IMAGE;
1259 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1265 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1267 Widget_Data *wd = elm_widget_data_get(obj);
1272 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1273 sel_str = strdup(sel);
1280 char *startTag = NULL;
1281 char *endTag = NULL;
1283 startTag = strstr(sel_str, "<item");
1285 startTag = strstr(sel_str, "</item");
1287 endTag = strstr(startTag, ">");
1290 if (!endTag || startTag > endTag)
1293 size_t sindex = startTag - sel_str;
1294 size_t eindex = endTag - sel_str + 1;
1296 Eina_Strbuf *buf = eina_strbuf_new();
1299 eina_strbuf_append(buf, sel_str);
1300 eina_strbuf_remove(buf, sindex, eindex);
1301 sel_str = eina_strbuf_string_steal(buf);
1302 eina_strbuf_free(buf);
1306 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str);
1307 if (seltype == ELM_SEL_CLIPBOARD)
1308 eina_stringshare_replace(&wd->cut_sel, sel_str);
1313 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1315 Widget_Data *wd = elm_widget_data_get(data);
1318 wd->selmode = EINA_FALSE;
1319 if (!_elm_config->desktop_entry)
1320 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1321 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1322 if (!_elm_config->desktop_entry)
1323 elm_widget_scroll_hold_pop(data);
1324 _store_selection(ELM_SEL_CLIPBOARD, data);
1325 edje_object_part_text_insert(wd->ent, "elm.text", "");
1326 edje_object_part_text_select_none(wd->ent, "elm.text");
1330 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1332 Widget_Data *wd = elm_widget_data_get(data);
1334 wd->selmode = EINA_TRUE;
1335 if (!_elm_config->desktop_entry)
1337 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1338 elm_widget_scroll_hold_pop(data);
1340 _store_selection(ELM_SEL_CLIPBOARD, data);
1344 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1346 Widget_Data *wd = elm_widget_data_get(data);
1348 wd->selmode = EINA_FALSE;
1349 if (!_elm_config->desktop_entry)
1350 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1351 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1352 if (!_elm_config->desktop_entry)
1353 elm_widget_scroll_hold_pop(data);
1354 edje_object_part_text_select_none(wd->ent, "elm.text");
1358 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1360 Widget_Data *wd = elm_widget_data_get(data);
1364 #ifdef HAVE_ELEMENTARY_X
1365 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1367 cnpwidgetdata = data;
1368 elm_cbhm_helper_init(obj);
1369 if (elm_entry_cnp_textonly_get(obj))
1370 elm_cbhm_send_raw_data("show0");
1372 elm_cbhm_send_raw_data("show1");
1378 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1380 Widget_Data *wd = elm_widget_data_get(data);
1382 cnpwidgetdata = data;
1388 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1390 Elm_Entry_Context_Menu_Item *it = data;
1391 Evas_Object *obj2 = it->obj;
1392 if (it->func) it->func(it->data, obj2, NULL);
1396 _menu_press(Evas_Object *obj)
1398 Widget_Data *wd = elm_widget_data_get(obj);
1401 const Elm_Entry_Context_Menu_Item *it;
1403 if ((wd->api) && (wd->api->obj_longpress))
1405 wd->api->obj_longpress(obj);
1407 else if (wd->context_menu)
1409 const char *context_menu_orientation;
1411 if (wd->hoversel) evas_object_del(wd->hoversel);
1412 else elm_widget_scroll_freeze_push(obj);
1413 wd->hoversel = elm_hoversel_add(obj);
1414 context_menu_orientation = edje_object_data_get
1415 (wd->ent, "context_menu_orientation");
1416 if ((context_menu_orientation) &&
1417 (!strcmp(context_menu_orientation, "horizontal")))
1418 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1419 elm_object_style_set(wd->hoversel, "entry");
1420 elm_widget_sub_object_add(obj, wd->hoversel);
1421 elm_object_text_set(wd->hoversel, "Text");
1422 top = elm_widget_top_get(obj);
1423 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1424 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1428 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1430 if (1) // need way to detect if someone has a selection
1433 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1437 if ((!wd->password) && (wd->editable))
1438 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1439 _clipboard_menu, obj);
1446 if (wd->have_selection)
1448 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1451 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1454 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1458 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1459 _clipboard_menu, obj);
1463 EINA_LIST_FOREACH(wd->items, l, it)
1465 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1466 it->icon_type, _item_clicked, it);
1470 _hoversel_position(obj);
1471 evas_object_show(wd->hoversel);
1472 elm_hoversel_hover_begin(wd->hoversel);
1474 if (!_elm_config->desktop_entry)
1476 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1477 edje_object_part_text_select_abort(wd->ent, "elm.text");
1483 _magnifier_hide(void *data)
1485 Widget_Data *wd = elm_widget_data_get(data);
1488 evas_object_hide(wd->mgf_bg);
1489 evas_object_hide(wd->mgf_clip);
1492 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1496 _magnifier_show(void *data)
1498 Widget_Data *wd = elm_widget_data_get(data);
1501 evas_object_show(wd->mgf_bg);
1502 evas_object_show(wd->mgf_clip);
1506 _magnifier_move(void *data)
1508 Widget_Data *wd = elm_widget_data_get(data);
1511 Evas_Coord x, y, w, h;
1512 Evas_Coord cx, cy, cw, ch, ox, oy;
1514 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1518 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1519 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1524 evas_object_geometry_get(data, &x, &y, &w, &h);
1528 if ((cy + y) - wd->mgf_height < 0)
1529 oy = -1 * ((cy + y) - wd->mgf_height);
1531 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1532 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height + oy);
1533 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1534 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height + oy);
1538 evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 + oy);
1542 _magnifier_create(void *data)
1544 Widget_Data *wd = elm_widget_data_get(data);
1545 Evas_Coord x, y, w, h, mw, mh;
1546 const char* key_data = NULL;
1553 evas_object_image_source_unset(wd->mgf_proxy);
1554 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1555 evas_object_hide(wd->mgf_proxy);
1556 evas_object_clip_unset(wd->mgf_proxy);
1557 evas_object_del(wd->mgf_proxy);
1559 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1560 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1563 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1565 evas_object_geometry_get(data, &x, &y, &w, &h);
1567 if ((w <= 0) || (h <= 0))
1570 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1572 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1573 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1574 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1575 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1579 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1580 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1581 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1583 key_data = edje_object_data_get(wd->mgf_bg, "height");
1584 if (key_data) wd->mgf_height = atoi(key_data);
1585 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1586 if (key_data) wd->mgf_scale = atof(key_data);
1588 elm_scale = elm_scale_get();
1589 wd->mgf_height = (int)((float)wd->mgf_height * elm_scale);
1591 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1592 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1596 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1597 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1598 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1602 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1603 evas_object_image_source_set(wd->mgf_proxy, data);
1606 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1607 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1608 if ((mw <= 0) || (mh <= 0))
1611 evas_object_resize(wd->mgf_proxy, mw, mh);
1612 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1613 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1614 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1615 evas_object_show(wd->mgf_proxy);
1616 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1618 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1619 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1623 _signal_long_pressed(void *data)
1625 Widget_Data *wd = elm_widget_data_get(data);
1626 if (!wd) return ECORE_CALLBACK_CANCEL;
1628 wd->long_pressed = EINA_TRUE;
1630 _cancel(data, NULL, NULL);
1632 _magnifier_create(data);
1633 _magnifier_move(data);
1634 _magnifier_show(data);
1635 elm_object_scroll_freeze_push(data);
1637 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1638 return ECORE_CALLBACK_CANCEL;
1642 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1644 Widget_Data *wd = elm_widget_data_get(data);
1645 Evas_Event_Mouse_Down *ev = event_info;
1647 if (wd->disabled) return;
1648 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1649 wd->downx = ev->canvas.x;
1650 wd->downy = ev->canvas.y;
1651 wd->long_pressed = EINA_FALSE;
1655 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1657 Widget_Data *wd = elm_widget_data_get(data);
1658 Evas_Event_Mouse_Up *ev = event_info;
1660 if (wd->disabled) return;
1661 if (ev->button == 1)
1663 if (!wd->double_clicked)
1665 if ((wd->api) && (wd->api->obj_mouseup))
1666 wd->api->obj_mouseup(data);
1668 _magnifier_hide(data);
1669 elm_object_scroll_freeze_pop(data);
1671 if (wd->long_pressed)
1674 else if (ev->button == 3)
1682 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1684 Widget_Data *wd = elm_widget_data_get(data);
1685 Evas_Event_Mouse_Move *ev = event_info;
1687 if (wd->disabled) return;
1689 if (ev->buttons == 1)
1691 if (wd->long_pressed)
1693 _magnifier_show(data);
1694 _magnifier_move(data);
1700 _getbase(Evas_Object *obj)
1702 Widget_Data *wd = elm_widget_data_get(obj);
1703 if (!wd) return "base";
1706 if (wd->password) return "base-password";
1709 if (wd->single_line) return "base-single";
1712 switch (wd->linewrap)
1715 return "base-charwrap";
1718 case ELM_WRAP_MIXED:
1719 return "base-mixedwrap";
1722 return "base-nowrap";
1729 if (wd->password) return "base-password";
1732 if (wd->single_line) return "base-single-noedit";
1735 switch (wd->linewrap)
1738 return "base-noedit-charwrap";
1740 return "base-noedit";
1741 case ELM_WRAP_MIXED:
1742 return "base-noedit-mixedwrap";
1745 return "base-nowrap-noedit";
1755 _entry_length_get(Evas_Object *obj)
1758 const char *str = elm_entry_entry_get(obj);
1761 char *plain_str = _elm_util_mkup_to_text(str);
1762 if (!plain_str) return 0;
1764 len = strlen(plain_str);
1770 #ifndef HAVE_STRCASESTR
1771 char* _strcasestr(const char *s, const char *find)
1776 if ((c = *find++) != 0) {
1777 c = tolower((unsigned char) c);
1781 if( (sc = *s++) == 0)
1783 } while ((char)tolower((unsigned char)sc) != c);
1784 } while (strncasecmp(s, find, len) != 0);
1792 _matchlist_show(void *data)
1794 Widget_Data *wd = elm_widget_data_get(data);
1795 const char *text = NULL;
1797 char *str_list = NULL, *str_result = NULL;
1798 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1801 Eina_Bool textfound = EINA_FALSE;
1804 if (elm_widget_disabled_get(data)) return;
1806 wd->matchlist_job = NULL;
1808 if (wd->matchlist_list_clicked)
1810 evas_object_hide(wd->hover);
1811 wd->matchlist_list_clicked = EINA_FALSE;
1814 text = elm_entry_entry_get(data);
1817 textlen = strlen(text);
1819 if (textlen < wd->matchlist_threshold)
1821 evas_object_hide(wd->hover);
1825 evas_object_hide(wd->hover);
1829 elm_list_clear(wd->list);
1830 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1832 if (wd->matchlist_case_sensitive)
1833 str_result = strstr(str_list, text);
1835 #ifdef HAVE_STRCASESTR
1836 str_result = strcasestr(str_list, text);
1838 str_result = _strcasestr(str_list, text);
1843 str_mkup = malloc(strlen(str_list) + 16);
1844 if (str_mkup == NULL) return;
1846 textlen = strlen(str_list) - strlen(str_result);
1847 str_front = malloc(textlen + 1);
1848 if (str_front == NULL) return;
1850 memset(str_front, 0, textlen + 1);
1851 strncpy(str_front, str_list, textlen);
1853 textlen = strlen(text);
1854 str_mid = malloc(textlen + 1);
1855 if (str_mid == NULL) return;
1857 memset(str_mid, 0, textlen + 1);
1858 strncpy(str_mid, str_list + strlen(str_front), textlen);
1860 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1862 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1864 if (str_mkup) free(str_mkup);
1865 if (str_front) free(str_front);
1866 if (str_mid) free(str_mid);
1868 textfound=EINA_TRUE;
1877 elm_list_go(wd->list);
1878 evas_object_show(wd->hover);
1879 evas_object_raise(wd->hover);
1883 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1885 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1886 Widget_Data *wd = elm_widget_data_get(data);
1887 if ((it == NULL) || (wd == NULL))
1890 const char *text = elm_list_item_label_get(it);
1891 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1896 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1897 elm_entry_cursor_end_set(data);
1898 wd->matchlist_list_clicked = EINA_TRUE;
1900 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1903 elm_widget_focus_set(data, EINA_TRUE);
1907 _entry_changed_common_handling(void *data, const char *event)
1909 Widget_Data *wd = elm_widget_data_get(data);
1910 Evas_Coord minw, minh;
1912 wd->changed = EINA_TRUE;
1913 /* Reset the size hints which are no more relevant.
1914 * Keep the height, this is a hack, but doesn't really matter
1915 * cause we'll re-eval in a moment. */
1918 evas_object_size_hint_min_get(data, &minw, &minh);
1919 evas_object_size_hint_min_set(data, minw, minh);
1923 evas_object_size_hint_min_get(data, NULL, &minh);
1924 evas_object_size_hint_min_set(data, -1, minh);
1928 if (wd->text) eina_stringshare_del(wd->text);
1930 if (wd->password_text) eina_stringshare_del(wd->password_text);
1931 wd->password_text = NULL;
1932 _check_enable_returnkey(data);
1933 if (wd->delay_write)
1935 ecore_timer_del(wd->delay_write);
1936 wd->delay_write = NULL;
1939 if ((wd->single_line) && (wd->match_list))
1941 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1942 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1945 if ((wd->api) && (wd->api->obj_hidemenu))
1946 wd->api->obj_hidemenu(data);
1948 if ((wd->autosave) && (wd->file))
1949 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1951 /* callback - this could call callbacks that delete the entry... thus...
1952 * any access to wd after this could be invalid */
1953 evas_object_smart_callback_call(data, event, NULL);
1957 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1959 Widget_Data *wd = elm_widget_data_get(data);
1962 _entry_changed_common_handling(data, SIG_CHANGED);
1966 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1968 Widget_Data *wd = elm_widget_data_get(data);
1971 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1975 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1977 Widget_Data *wd = elm_widget_data_get(data);
1980 elm_object_scroll_freeze_push(data);
1982 if ((wd->api) && (wd->api->obj_hidemenu))
1983 wd->api->obj_hidemenu(data);
1985 _magnifier_create(data);
1986 _magnifier_move(data);
1987 _magnifier_show(data);
1991 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1993 Widget_Data *wd = elm_widget_data_get(data);
1996 elm_object_scroll_freeze_pop(data);
1998 if (wd->have_selection)
2000 _magnifier_hide(data);
2006 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2008 _magnifier_move(data);
2009 _magnifier_show(data);
2012 static Evas_Object *
2013 _viewport_obj_get(Evas_Object *data)
2015 Widget_Data *wd = elm_widget_data_get(data);
2016 if (!wd) return NULL;
2018 if(!data || !strlen(elm_widget_type_get(data)))
2021 Evas_Coord x, y, w, h;
2026 //evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
2027 //printf(">>> wd->scroller (%d, %d, %d, %d) \n", x, y, w, h);
2028 return wd->scroller;
2031 Evas_Object *parent_obj = data;
2033 while(parent_obj = elm_widget_parent_get(parent_obj))
2035 //evas_object_geometry_get(parent_obj, &x, &y, &w, &h);
2036 //printf(">>> %s (%d, %d, %d, %d) \n", elm_widget_type_get(parent_obj), x, y, w, h);
2037 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
2038 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
2046 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2048 _magnifier_hide(data);
2053 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2055 Widget_Data *wd = elm_widget_data_get(data);
2059 EINA_LIST_FOREACH(entries, l, entry)
2061 if (entry != data) elm_entry_select_none(entry);
2063 wd->have_selection = EINA_TRUE;
2064 wd->selmode = EINA_TRUE;
2065 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2066 #ifdef HAVE_ELEMENTARY_X
2067 if (wd->sel_notify_handler)
2069 const char *txt = elm_entry_selection_get(data);
2072 top = elm_widget_top_get(data);
2073 if ((top) && (elm_win_xwindow_get(top)))
2074 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
2078 if (!_elm_config->desktop_entry)
2079 edje_object_part_text_viewport_object_set(wd->ent, "elm.text", _viewport_obj_get(data));
2083 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2085 Evas_Coord cx, cy, cw, ch;
2086 Widget_Data *wd = elm_widget_data_get(data);
2089 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2090 if (!wd->deferred_recalc_job)
2091 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2094 wd->deferred_cur = EINA_TRUE;
2103 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2105 Evas_Coord cx, cy, cw, ch;
2106 Widget_Data *wd = elm_widget_data_get(data);
2108 wd->have_selection = EINA_TRUE;
2109 wd->selmode = EINA_TRUE;
2110 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2111 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
2112 elm_entry_selection_get(data));
2114 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2115 if (!wd->deferred_recalc_job)
2116 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2119 wd->deferred_cur = EINA_TRUE;
2128 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2130 Widget_Data *wd = elm_widget_data_get(data);
2132 if (!wd->have_selection) return;
2133 wd->have_selection = EINA_FALSE;
2134 wd->selmode = EINA_FALSE;
2135 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2136 if (wd->sel_notify_handler)
2140 #ifdef HAVE_ELEMENTARY_X
2143 top = elm_widget_top_get(data);
2144 if ((top) && (elm_win_xwindow_get(top)))
2145 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2148 eina_stringshare_del(wd->cut_sel);
2153 #ifdef HAVE_ELEMENTARY_X
2156 top = elm_widget_top_get(data);
2157 if ((top) && (elm_win_xwindow_get(top)))
2158 elm_selection_clear(ELM_SEL_PRIMARY, data);
2163 if ((wd->api) && (wd->api->obj_hidemenu))
2165 wd->api->obj_hidemenu(data);
2170 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2172 Widget_Data *wd = elm_widget_data_get(data);
2174 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2175 if (wd->sel_notify_handler)
2177 #ifdef HAVE_ELEMENTARY_X
2180 top = elm_widget_top_get(data);
2181 if ((top) && (elm_win_xwindow_get(top)))
2183 wd->selection_asked = EINA_TRUE;
2184 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2192 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2194 Widget_Data *wd = elm_widget_data_get(data);
2196 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2197 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2198 elm_entry_selection_get(data));
2202 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2204 Widget_Data *wd = elm_widget_data_get(data);
2206 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2207 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2208 elm_entry_selection_get(data));
2209 edje_object_part_text_insert(wd->ent, "elm.text", "");
2210 wd->changed = EINA_TRUE;
2215 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2217 Widget_Data *wd = elm_widget_data_get(data);
2219 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2220 wd->cur_changed = EINA_TRUE;
2221 _recalc_cursor_geometry(data);
2225 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2227 Widget_Data *wd = elm_widget_data_get(data);
2232 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2234 Widget_Data *wd = elm_widget_data_get(data);
2239 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2241 Widget_Data *wd = elm_widget_data_get(data);
2242 Elm_Entry_Anchor_Info ei;
2243 char *buf2, *p, *p2, *n;
2245 p = strrchr(emission, ',');
2248 const Eina_List *geoms;
2252 while (p2 >= emission)
2254 if (*p2 == ',') break;
2258 buf2 = alloca(5 + p - p2);
2259 strncpy(buf2, p2, p - p2);
2262 ei.button = atoi(buf2);
2263 ei.x = ei.y = ei.w = ei.h = 0;
2265 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2268 Evas_Textblock_Rectangle *r;
2270 Evas_Coord px, py, x, y;
2272 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2273 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2274 EINA_LIST_FOREACH(geoms, l, r)
2276 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2277 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2288 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2293 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2295 Widget_Data *wd = elm_widget_data_get(data);
2300 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2302 Widget_Data *wd = elm_widget_data_get(data);
2307 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2309 Widget_Data *wd = elm_widget_data_get(data);
2314 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2316 Widget_Data *wd = elm_widget_data_get(data);
2318 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2322 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2324 Widget_Data *wd = elm_widget_data_get(data);
2326 wd->double_clicked = EINA_FALSE;
2327 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2329 if ((wd->api) && (wd->api->obj_hidemenu))
2330 wd->api->obj_hidemenu(data);
2334 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2336 Widget_Data *wd = elm_widget_data_get(data);
2338 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2340 if (!_elm_config->desktop_entry && !wd->double_clicked)
2341 _cancel(data, NULL, NULL);
2345 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2347 Widget_Data *wd = elm_widget_data_get(data);
2349 wd->double_clicked = EINA_TRUE;
2350 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2353 #ifdef HAVE_ELEMENTARY_X
2355 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2357 Widget_Data *wd = elm_widget_data_get(data);
2358 Ecore_X_Event_Selection_Notify *ev = event;
2359 if (!wd) return ECORE_CALLBACK_PASS_ON;
2360 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2361 return ECORE_CALLBACK_PASS_ON;
2363 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2364 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2366 Ecore_X_Selection_Data_Text *text_data;
2368 text_data = ev->data;
2369 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2371 if (text_data->text)
2373 char *txt = _elm_util_text_to_mkup(text_data->text);
2377 elm_entry_entry_insert(data, txt);
2382 wd->selection_asked = EINA_FALSE;
2384 else if (ev->selection == ECORE_X_SELECTION_XDND)
2386 Ecore_X_Selection_Data_Text *text_data;
2388 text_data = ev->data;
2389 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2391 if (text_data->text)
2393 char *txt = _elm_util_text_to_mkup(text_data->text);
2397 /* Massive FIXME: this should be at the drag point */
2398 elm_entry_entry_insert(data, txt);
2403 wd->drag_selection_asked = EINA_FALSE;
2405 ecore_x_dnd_send_finished();
2408 return ECORE_CALLBACK_PASS_ON;
2412 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2415 Widget_Data *wd = elm_widget_data_get(data);
2416 Ecore_X_Event_Selection_Clear *ev = event;
2417 if (!wd) return ECORE_CALLBACK_PASS_ON;
2418 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2419 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2420 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2422 elm_entry_select_none(data);
2427 Evas_Object *top = elm_widget_top_get(data);
2428 Ecore_X_Event_Selection_Clear *ev = event;
2431 return ECORE_CALLBACK_PASS_ON;
2433 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2435 return ECORE_CALLBACK_PASS_ON;
2438 if (cnpwidgetdata == data)
2440 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2441 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2445 return ECORE_CALLBACK_PASS_ON;
2449 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2454 wd = elm_widget_data_get(obj);
2455 if (!wd) return EINA_FALSE;
2456 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2458 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2459 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2460 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2461 EDJE_CURSOR_MAIN,drop->x,drop->y);
2462 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2463 elm_entry_entry_insert(obj, drop->data);
2464 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2465 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2471 static Evas_Object *
2472 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2474 Widget_Data *wd = elm_widget_data_get(data);
2477 Elm_Entry_Item_Provider *ip;
2479 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2481 o = ip->func(ip->data, data, item);
2484 if (!strncmp(item, "file://", 7))
2486 const char *fname = item + 7;
2488 o = evas_object_image_filled_add(evas_object_evas_get(data));
2489 evas_object_image_file_set(o, fname, NULL);
2490 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2492 evas_object_show(o);
2497 o = edje_object_add(evas_object_evas_get(data));
2498 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2502 o = edje_object_add(evas_object_evas_get(data));
2503 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2504 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2509 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2511 const char *srcstring = NULL;
2512 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2513 char *curlocater, *replocater;
2514 char *starttag, *endtag;
2515 int tagtxtlen = 0, insertflag = 0;
2517 srcstring = eina_strbuf_string_get(srcbuf);
2518 curlocater = strstr(srcstring, key);
2520 if (!curlocater || !srcstring)
2528 starttag = strchr(srcstring, '<');
2529 endtag = strchr(srcstring, '>');
2530 tagtxtlen = endtag - starttag;
2531 if (tagtxtlen <= 0) tagtxtlen = 0;
2532 if (starttag < curlocater && curlocater < endtag) break;
2533 if (endtag != NULL && endtag+1 != NULL)
2534 srcstring = endtag+1;
2537 } while (strlen(srcstring) > 1);
2539 if (starttag && endtag && tagtxtlen > strlen(key))
2541 repbuf = eina_strbuf_new();
2542 diffbuf = eina_strbuf_new();
2543 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2544 srcstring = eina_strbuf_string_get(repbuf);
2545 curlocater = strstr(srcstring, key);
2547 if (curlocater != NULL)
2549 replocater = curlocater + strlen(key) + 1;
2551 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2554 if (replocater-curlocater > strlen(key)+1)
2556 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2565 eina_strbuf_reset(repbuf);
2573 if (repbuf == NULL) repbuf = eina_strbuf_new();
2574 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2578 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2579 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2585 eina_strbuf_prepend(diffbuf, "<");
2586 eina_strbuf_append(diffbuf, ">");
2587 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2591 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2592 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2596 if (repbuf) eina_strbuf_free(repbuf);
2597 if (diffbuf) eina_strbuf_free(diffbuf);
2603 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2605 Eina_Strbuf *sharebuf = NULL;
2607 sharebuf = eina_strbuf_new();
2608 eina_strbuf_append(sharebuf, *srcstring);
2609 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2610 eina_stringshare_del(*srcstring);
2611 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2612 eina_strbuf_free(sharebuf);
2618 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2620 Widget_Data *wd = elm_widget_data_get(data);
2622 Elm_Entry_Text_Filter *tf;
2624 if (type == EDJE_TEXT_FILTER_FORMAT)
2627 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2629 tf->func(tf->data, data, text);
2635 /* This function is used to insert text by chunks in jobs */
2637 _text_append_idler(void *data)
2641 Evas_Object *obj = (Evas_Object *) data;
2642 Widget_Data *wd = elm_widget_data_get(obj);
2643 if (wd->text) eina_stringshare_del(wd->text);
2645 if (wd->password_text) eina_stringshare_del(wd->password_text);
2646 wd->password_text = NULL;
2647 wd->changed = EINA_TRUE;
2649 start = wd->append_text_position;
2650 if (start + _CHUNK_SIZE < wd->append_text_len)
2653 int tag_start, esc_start;
2655 tag_start = esc_start = -1;
2656 /* Find proper markup cut place */
2657 while (pos - start < _CHUNK_SIZE)
2661 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2662 if (esc_start == -1)
2665 tag_start = prev_pos;
2666 else if (tmp == '>')
2669 else if (tag_start == -1)
2672 esc_start = prev_pos;
2673 else if (tmp == ';')
2680 wd->append_text_position = tag_start;
2682 else if (esc_start >= 0)
2684 wd->append_text_position = esc_start;
2688 wd->append_text_position = pos;
2693 wd->append_text_position = wd->append_text_len;
2696 backup = wd->append_text_left[wd->append_text_position];
2697 wd->append_text_left[wd->append_text_position] = '\0';
2699 edje_object_part_text_append(wd->ent, "elm.text",
2700 wd->append_text_left + start);
2702 wd->append_text_left[wd->append_text_position] = backup;
2704 /* If there's still more to go, renew the idler, else, cleanup */
2705 if (wd->append_text_position < wd->append_text_len)
2707 return ECORE_CALLBACK_RENEW;
2711 free(wd->append_text_left);
2712 wd->append_text_left = NULL;
2713 wd->append_text_idler = NULL;
2714 return ECORE_CALLBACK_CANCEL;
2719 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2721 int i = 0, unit_size;
2722 int current_len = strlen(*text);
2723 char *new_text = *text;
2724 if (unit >= LENGTH_UNIT_LAST) return;
2727 if (*new_text == '<')
2729 while (*new_text != '>')
2732 if (!*new_text) break;
2739 if (*new_text == '&')
2741 while (*(new_text + index) != ';')
2744 if (!*(new_text + index)) break;
2748 index = evas_string_char_next_get(new_text, index, NULL);
2749 markup = malloc(index + 1);
2750 strncpy(markup, new_text, index);
2752 if (unit == LENGTH_UNIT_BYTE)
2753 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2754 else if (unit == LENGTH_UNIT_CHAR)
2755 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2761 if (can_add < unit_size)
2765 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2771 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2772 current_len -= index;
2773 (*text)[current_len] = 0;
2778 can_add -= unit_size;
2783 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2787 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2790 ELM_CHECK_WIDTYPE(obj, widtype);
2791 Widget_Data *wd = elm_widget_data_get(obj);
2793 if (!entry) entry = "";
2794 if (item && strcmp(item, "default"))
2796 edje_object_part_text_set(wd->ent, item, entry);
2799 if (wd->text) eina_stringshare_del(wd->text);
2801 if (wd->password_text) eina_stringshare_del(wd->password_text);
2802 wd->password_text = NULL;
2803 wd->changed = EINA_TRUE;
2805 /* Clear currently pending job if there is one */
2806 if (wd->append_text_idler)
2808 ecore_idler_del(wd->append_text_idler);
2809 free(wd->append_text_left);
2810 wd->append_text_left = NULL;
2811 wd->append_text_idler = NULL;
2814 len = strlen(entry);
2815 /* Split to ~_CHUNK_SIZE chunks */
2816 if (len > _CHUNK_SIZE)
2818 wd->append_text_left = (char *) malloc(len + 1);
2821 /* If we decided to use the idler */
2822 if (wd->append_text_left)
2824 /* Need to clear the entry first */
2825 edje_object_part_text_set(wd->ent, "elm.text", "");
2826 memcpy(wd->append_text_left, entry, len + 1);
2827 wd->append_text_position = 0;
2828 wd->append_text_len = len;
2829 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2833 edje_object_part_text_set(wd->ent, "elm.text", entry);
2838 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2840 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2841 Widget_Data *wd = elm_widget_data_get(obj);
2842 if (item && strcmp(item, "default")) return NULL;
2844 if (!wd) return NULL;
2847 if(wd->password_text) return wd->password_text;
2853 text = edje_object_part_text_get(wd->ent, "elm.text");
2856 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2859 eina_stringshare_replace(&wd->text, text);
2862 const char *pw_text;
2863 pw_text = elm_entry_markup_to_utf8(wd->text);
2866 eina_stringshare_replace(&wd->password_text, pw_text);
2868 return wd->password_text;
2875 * This adds an entry to @p parent object.
2877 * @param parent The parent object
2878 * @return The new object or NULL if it cannot be created
2883 elm_entry_add(Evas_Object *parent)
2885 Evas_Object *obj, *top;
2889 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2891 ELM_SET_WIDTYPE(widtype, "entry");
2892 elm_widget_type_set(obj, "entry");
2893 elm_widget_sub_object_add(parent, obj);
2894 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2895 elm_widget_data_set(obj, wd);
2896 elm_widget_del_hook_set(obj, _del_hook);
2897 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2898 elm_widget_theme_hook_set(obj, _theme_hook);
2899 elm_widget_disable_hook_set(obj, _disable_hook);
2900 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2901 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2902 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2903 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2904 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2905 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2906 elm_widget_can_focus_set(obj, EINA_TRUE);
2907 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2908 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2909 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2910 elm_widget_content_set_hook_set(obj, _content_set_hook);
2911 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2912 elm_widget_content_get_hook_set(obj, _content_get_hook);
2914 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2915 wd->scroller = elm_smart_scroller_add(e);
2916 elm_widget_sub_object_add(obj, wd->scroller);
2917 elm_smart_scroller_widget_set(wd->scroller, obj);
2918 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2919 elm_widget_style_get(obj));
2920 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2921 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2922 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2923 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2925 wd->linewrap = ELM_WRAP_WORD;
2926 wd->editable = EINA_TRUE;
2927 wd->disabled = EINA_FALSE;
2928 wd->context_menu = EINA_TRUE;
2929 wd->autosave = EINA_TRUE;
2930 wd->textonly = EINA_FALSE;
2931 wd->autoperiod = EINA_TRUE;
2933 wd->ent = edje_object_add(e);
2934 elm_widget_sub_object_add(obj, wd->ent);
2935 edje_object_item_provider_set(wd->ent, _get_item, obj);
2936 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2937 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2938 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2940 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2942 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2944 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2946 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2947 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2948 _signal_entry_changed, obj);
2949 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2950 _signal_preedit_changed, obj);
2951 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2952 _signal_handler_move_start, obj);
2953 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2954 _signal_handler_move_end, obj);
2955 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2956 _signal_handler_moving, obj);
2957 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2958 _signal_selection_start, obj);
2959 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2960 _signal_selection_end, obj);
2961 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
2962 _signal_long_pressed, obj);
2963 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2964 _signal_magnifier_changed, obj);
2965 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2966 _signal_selection_changed, obj);
2967 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2968 _signal_selection_cleared, obj);
2969 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2970 _signal_entry_paste_request, obj);
2971 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2972 _signal_entry_copy_notify, obj);
2973 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2974 _signal_entry_cut_notify, obj);
2975 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2976 _signal_cursor_changed, obj);
2977 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2978 _signal_anchor_down, obj);
2979 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2980 _signal_anchor_up, obj);
2981 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2982 _signal_anchor_clicked, obj);
2983 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2984 _signal_anchor_move, obj);
2985 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2986 _signal_anchor_in, obj);
2987 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2988 _signal_anchor_out, obj);
2989 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2990 _signal_key_enter, obj);
2991 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2992 _signal_mouse_down, obj);
2993 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2994 _signal_mouse_clicked, obj);
2995 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2996 _signal_mouse_double, obj);
2997 edje_object_part_text_set(wd->ent, "elm.text", "");
2998 if (_elm_config->desktop_entry)
2999 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
3000 elm_widget_resize_object_set(obj, wd->ent);
3003 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
3005 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
3006 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
3008 #ifdef HAVE_ELEMENTARY_X
3009 top = elm_widget_top_get(obj);
3010 if ((top) && (elm_win_xwindow_get(top)))
3012 wd->sel_notify_handler =
3013 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
3014 _event_selection_notify, obj);
3015 wd->sel_clear_handler =
3016 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
3017 _event_selection_clear, obj);
3020 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3021 _drag_drop_cb, NULL);
3024 entries = eina_list_prepend(entries, obj);
3026 // module - find module for entry
3027 wd->api = _module(obj);
3028 // if found - hook in
3029 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
3031 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3032 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3033 // TODO: and save some bytes, making descriptions per-class and not instance!
3034 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3038 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
3040 ELM_CHECK_WIDTYPE(obj, widtype);
3041 Widget_Data *wd = elm_widget_data_get(obj);
3043 ext_mod->cancel = _cancel;
3044 ext_mod->copy = _copy;
3045 ext_mod->cut = _cut;
3046 ext_mod->paste = _paste;
3047 ext_mod->select = _select;
3048 ext_mod->selectall = _selectall;
3049 ext_mod->ent = wd->ent;
3050 ext_mod->viewport_obj = _viewport_obj_get(obj);
3051 ext_mod->items = wd->items;
3052 ext_mod->editable = wd->editable;
3053 ext_mod->have_selection = wd->have_selection;
3054 ext_mod->password = wd->password;
3055 ext_mod->selmode = wd->selmode;
3056 ext_mod->cnpinit = _cnpinit;
3057 ext_mod->context_menu = wd->context_menu;
3058 ext_mod->textonly = wd->textonly;
3062 * This sets the entry object not to line wrap. All input will
3063 * be on a single line, and the entry box will extend with user input.
3065 * @param obj The entry object
3066 * @param single_line If true, the text in the entry
3067 * will be on a single line.
3072 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
3074 ELM_CHECK_WIDTYPE(obj, widtype);
3075 Widget_Data *wd = elm_widget_data_get(obj);
3077 if (wd->single_line == single_line) return;
3078 wd->single_line = single_line;
3079 wd->linewrap = ELM_WRAP_NONE;
3080 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
3084 if (wd->single_line)
3086 elm_smart_scroller_policy_set(wd->scroller,
3087 ELM_SMART_SCROLLER_POLICY_OFF,
3088 ELM_SMART_SCROLLER_POLICY_OFF);
3089 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3093 const Elm_Scroller_Policy map[3] =
3095 ELM_SMART_SCROLLER_POLICY_AUTO,
3096 ELM_SMART_SCROLLER_POLICY_ON,
3097 ELM_SMART_SCROLLER_POLICY_OFF
3099 elm_smart_scroller_policy_set(wd->scroller,
3102 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3109 * This returns true if the entry has been set to single line mode.
3110 * See also elm_entry_single_line_set().
3112 * @param obj The entry object
3113 * @return single_line If true, the text in the entry is set to display
3119 elm_entry_single_line_get(const Evas_Object *obj)
3121 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3122 Widget_Data *wd = elm_widget_data_get(obj);
3123 if (!wd) return EINA_FALSE;
3124 return wd->single_line;
3128 * This sets the entry object to password mode. All text entered
3129 * and/or displayed within the widget will be replaced with asterisks (*).
3131 * @param obj The entry object
3132 * @param password If true, password mode is enabled.
3137 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3139 ELM_CHECK_WIDTYPE(obj, widtype);
3140 Widget_Data *wd = elm_widget_data_get(obj);
3142 if (wd->password == password) return;
3143 wd->password = password;
3144 wd->single_line = EINA_TRUE;
3145 wd->linewrap = ELM_WRAP_NONE;
3150 * This returns whether password mode is enabled.
3151 * See also elm_entry_password_set().
3153 * @param obj The entry object
3154 * @return If true, the entry is set to display all characters
3160 elm_entry_password_get(const Evas_Object *obj)
3162 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3163 Widget_Data *wd = elm_widget_data_get(obj);
3164 if (!wd) return EINA_FALSE;
3165 return wd->password;
3169 * This sets the text displayed within the entry to @p entry.
3171 * @param obj The entry object
3172 * @param entry The text to be displayed
3177 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3179 _elm_entry_text_set(obj, NULL, entry);
3183 * This appends @p entry to the text of the entry.
3185 * @param obj The entry object
3186 * @param entry The text to be displayed
3191 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3194 ELM_CHECK_WIDTYPE(obj, widtype);
3195 Widget_Data *wd = elm_widget_data_get(obj);
3197 if (!entry) entry = "";
3198 wd->changed = EINA_TRUE;
3200 len = strlen(entry);
3201 if (wd->append_text_left)
3204 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3210 wd->append_text_left = tmpbuf;
3211 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3212 wd->append_text_len += len;
3216 /* FIXME: Add chunked appending here (like in entry_set) */
3217 edje_object_part_text_append(wd->ent, "elm.text", entry);
3222 * This returns the text currently shown in object @p entry.
3223 * See also elm_entry_entry_set().
3225 * @param obj The entry object
3226 * @return The currently displayed text or NULL on failure
3231 elm_entry_entry_get(const Evas_Object *obj)
3233 return _elm_entry_text_get(obj, NULL);
3237 * This returns EINA_TRUE if the entry is empty/there was an error
3238 * and EINA_FALSE if it is not empty.
3240 * @param obj The entry object
3241 * @return If the entry is empty or not.
3246 elm_entry_is_empty(const Evas_Object *obj)
3248 /* FIXME: until there's support for that in textblock, we just check
3249 * to see if the there is text or not. */
3250 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3251 Widget_Data *wd = elm_widget_data_get(obj);
3252 const Evas_Object *tb;
3253 //Evas_Textblock_Cursor *cur;
3255 if (!wd) return EINA_TRUE;
3258 /* It's a hack until we get the support suggested above.
3259 * We just create a cursor, point it to the begining, and then
3260 * try to advance it, if it can advance, the tb is not empty,
3261 * otherwise it is. */
3262 tb = edje_object_part_object_get(wd->ent, "elm.text");
3263 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3264 actually, ok for the time being, thsese hackish stuff will be removed
3265 once evas 1.0 is out*/
3266 evas_textblock_cursor_pos_set(cur, 0);
3267 ret = evas_textblock_cursor_char_next(cur);
3268 evas_textblock_cursor_free(cur);
3273 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3274 if (!str) return EINA_TRUE;
3276 ret = (strlen(str) == 0);
3282 * This returns all selected text within the entry.
3284 * @param obj The entry object
3285 * @return The selected text within the entry or NULL on failure
3290 elm_entry_selection_get(const Evas_Object *obj)
3292 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3293 Widget_Data *wd = elm_widget_data_get(obj);
3294 if (!wd) return NULL;
3295 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3299 * This inserts text in @p entry where the current cursor position.
3301 * This inserts text at the cursor position is as if it was typed
3302 * by the user (note this also allows markup which a user
3303 * can't just "type" as it would be converted to escaped text, so this
3304 * call can be used to insert things like emoticon items or bold push/pop
3305 * tags, other font and color change tags etc.)
3307 * @param obj The entry object
3308 * @param entry The text to insert
3313 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3315 ELM_CHECK_WIDTYPE(obj, widtype);
3316 Widget_Data *wd = elm_widget_data_get(obj);
3318 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3320 #ifdef HAVE_ELEMENTARY_X
3321 if (cnpwidgetdata == obj)
3322 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3325 wd->changed = EINA_TRUE;
3330 * This enables word line wrapping in the entry object. It is the opposite
3331 * of elm_entry_single_line_set(). Additionally, setting this disables
3332 * character line wrapping.
3334 * @param obj The entry object
3335 * @param wrap If true, the entry will be wrapped once it reaches the end
3336 * of the object. Wrapping will occur at the end of the word before the end of the
3342 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3344 ELM_CHECK_WIDTYPE(obj, widtype);
3345 Widget_Data *wd = elm_widget_data_get(obj);
3347 if (wd->linewrap == wrap) return;
3349 wd->linewrap = wrap;
3354 * Get the wrapping behavior of the entry.
3355 * See also elm_entry_line_wrap_set().
3357 * @param obj The entry object
3363 elm_entry_line_wrap_get(const Evas_Object *obj)
3365 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3366 Widget_Data *wd = elm_widget_data_get(obj);
3367 if (!wd) return EINA_FALSE;
3368 return wd->linewrap;
3372 * This sets the editable attribute of the entry.
3374 * @param obj The entry object
3375 * @param editable If true, the entry will be editable by the user.
3376 * If false, it will be set to the disabled state.
3381 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3383 ELM_CHECK_WIDTYPE(obj, widtype);
3384 Widget_Data *wd = elm_widget_data_get(obj);
3386 if (wd->editable == editable) return;
3387 wd->editable = editable;
3390 #ifdef HAVE_ELEMENTARY_X
3392 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3394 elm_drop_target_del(obj);
3399 * This gets the editable attribute of the entry.
3400 * See also elm_entry_editable_set().
3402 * @param obj The entry object
3403 * @return If true, the entry is editable by the user.
3404 * If false, it is not editable by the user
3409 elm_entry_editable_get(const Evas_Object *obj)
3411 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3412 Widget_Data *wd = elm_widget_data_get(obj);
3413 if (!wd) return EINA_FALSE;
3414 return wd->editable;
3418 * This drops any existing text selection within the entry.
3420 * @param obj The entry object
3425 elm_entry_select_none(Evas_Object *obj)
3427 ELM_CHECK_WIDTYPE(obj, widtype);
3428 Widget_Data *wd = elm_widget_data_get(obj);
3432 wd->selmode = EINA_FALSE;
3433 if (!_elm_config->desktop_entry)
3434 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3435 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3437 wd->have_selection = EINA_FALSE;
3438 edje_object_part_text_select_none(wd->ent, "elm.text");
3442 * This selects all text within the entry.
3444 * @param obj The entry object
3449 elm_entry_select_all(Evas_Object *obj)
3451 ELM_CHECK_WIDTYPE(obj, widtype);
3452 Widget_Data *wd = elm_widget_data_get(obj);
3456 wd->selmode = EINA_FALSE;
3457 if (!_elm_config->desktop_entry)
3458 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3459 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3461 wd->have_selection = EINA_TRUE;
3462 edje_object_part_text_select_all(wd->ent, "elm.text");
3466 * This function returns the geometry of the cursor.
3468 * It's useful if you want to draw something on the cursor (or where it is),
3469 * or for example in the case of scrolled entry where you want to show the
3472 * @param obj The entry object
3473 * @param x returned geometry
3474 * @param y returned geometry
3475 * @param w returned geometry
3476 * @param h returned geometry
3477 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3482 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3484 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3485 Widget_Data *wd = elm_widget_data_get(obj);
3486 if (!wd) return EINA_FALSE;
3487 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3492 * This moves the cursor one place to the right within the entry.
3494 * @param obj The entry object
3495 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3500 elm_entry_cursor_next(Evas_Object *obj)
3502 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3503 Widget_Data *wd = elm_widget_data_get(obj);
3504 if (!wd) return EINA_FALSE;
3505 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3509 * This moves the cursor one place to the left within the entry.
3511 * @param obj The entry object
3512 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3517 elm_entry_cursor_prev(Evas_Object *obj)
3519 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3520 Widget_Data *wd = elm_widget_data_get(obj);
3521 if (!wd) return EINA_FALSE;
3522 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3526 * This moves the cursor one line up within the entry.
3528 * @param obj The entry object
3529 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3534 elm_entry_cursor_up(Evas_Object *obj)
3536 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3537 Widget_Data *wd = elm_widget_data_get(obj);
3538 if (!wd) return EINA_FALSE;
3539 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3543 * This moves the cursor one line down within the entry.
3545 * @param obj The entry object
3546 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3551 elm_entry_cursor_down(Evas_Object *obj)
3553 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3554 Widget_Data *wd = elm_widget_data_get(obj);
3555 if (!wd) return EINA_FALSE;
3556 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3560 * This moves the cursor to the beginning of the entry.
3562 * @param obj The entry object
3567 elm_entry_cursor_begin_set(Evas_Object *obj)
3569 ELM_CHECK_WIDTYPE(obj, widtype);
3570 Widget_Data *wd = elm_widget_data_get(obj);
3572 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3576 * This moves the cursor to the end of the entry.
3578 * @param obj The entry object
3583 elm_entry_cursor_end_set(Evas_Object *obj)
3585 ELM_CHECK_WIDTYPE(obj, widtype);
3586 Widget_Data *wd = elm_widget_data_get(obj);
3589 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3592 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3593 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3598 * This moves the cursor to the beginning of the current line.
3600 * @param obj The entry object
3605 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3607 ELM_CHECK_WIDTYPE(obj, widtype);
3608 Widget_Data *wd = elm_widget_data_get(obj);
3610 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3614 * This moves the cursor to the end of the current line.
3616 * @param obj The entry object
3621 elm_entry_cursor_line_end_set(Evas_Object *obj)
3623 ELM_CHECK_WIDTYPE(obj, widtype);
3624 Widget_Data *wd = elm_widget_data_get(obj);
3626 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3630 * This begins a selection within the entry as though
3631 * the user were holding down the mouse button to make a selection.
3633 * @param obj The entry object
3638 elm_entry_cursor_selection_begin(Evas_Object *obj)
3640 ELM_CHECK_WIDTYPE(obj, widtype);
3641 Widget_Data *wd = elm_widget_data_get(obj);
3643 edje_object_part_text_select_begin(wd->ent, "elm.text");
3647 * This ends a selection within the entry as though
3648 * the user had just released the mouse button while making a selection.
3650 * @param obj The entry object
3655 elm_entry_cursor_selection_end(Evas_Object *obj)
3657 ELM_CHECK_WIDTYPE(obj, widtype);
3658 Widget_Data *wd = elm_widget_data_get(obj);
3660 edje_object_part_text_select_extend(wd->ent, "elm.text");
3664 * TODO: fill this in
3666 * @param obj The entry object
3667 * @return TODO: fill this in
3672 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3674 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3675 Widget_Data *wd = elm_widget_data_get(obj);
3676 if (!wd) return EINA_FALSE;
3677 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3681 * This returns whether the cursor is visible.
3683 * @param obj The entry object
3684 * @return If true, the cursor is visible.
3689 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3691 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3692 Widget_Data *wd = elm_widget_data_get(obj);
3693 if (!wd) return EINA_FALSE;
3694 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3698 * TODO: fill this in
3700 * @param obj The entry object
3701 * @return TODO: fill this in
3706 elm_entry_cursor_content_get(const Evas_Object *obj)
3708 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3709 Widget_Data *wd = elm_widget_data_get(obj);
3710 if (!wd) return NULL;
3711 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3715 * Sets the cursor position in the entry to the given value
3717 * @param obj The entry object
3718 * @param pos The position of the cursor
3723 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3725 ELM_CHECK_WIDTYPE(obj, widtype);
3726 Widget_Data *wd = elm_widget_data_get(obj);
3728 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3729 edje_object_message_signal_process(wd->ent);
3733 * Retrieves the current position of the cursor in the entry
3735 * @param obj The entry object
3736 * @return The cursor position
3741 elm_entry_cursor_pos_get(const Evas_Object *obj)
3743 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3744 Widget_Data *wd = elm_widget_data_get(obj);
3746 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3750 * This executes a "cut" action on the selected text in the entry.
3752 * @param obj The entry object
3757 elm_entry_selection_cut(Evas_Object *obj)
3759 ELM_CHECK_WIDTYPE(obj, widtype);
3760 Widget_Data *wd = elm_widget_data_get(obj);
3762 _cut(obj, NULL, NULL);
3766 * This executes a "copy" action on the selected text in the entry.
3768 * @param obj The entry object
3773 elm_entry_selection_copy(Evas_Object *obj)
3775 ELM_CHECK_WIDTYPE(obj, widtype);
3776 Widget_Data *wd = elm_widget_data_get(obj);
3778 _copy(obj, NULL, NULL);
3782 * This executes a "paste" action in the entry.
3784 * @param obj The entry object
3789 elm_entry_selection_paste(Evas_Object *obj)
3791 ELM_CHECK_WIDTYPE(obj, widtype);
3792 Widget_Data *wd = elm_widget_data_get(obj);
3794 _paste(obj, NULL, NULL);
3798 * This clears and frees the items in a entry's contextual (right click) menu.
3800 * @param obj The entry object
3805 elm_entry_context_menu_clear(Evas_Object *obj)
3807 ELM_CHECK_WIDTYPE(obj, widtype);
3808 Widget_Data *wd = elm_widget_data_get(obj);
3809 Elm_Entry_Context_Menu_Item *it;
3811 EINA_LIST_FREE(wd->items, it)
3813 eina_stringshare_del(it->label);
3814 eina_stringshare_del(it->icon_file);
3815 eina_stringshare_del(it->icon_group);
3821 * This adds an item to the entry's contextual menu.
3823 * @param obj The entry object
3824 * @param label The item's text label
3825 * @param icon_file The item's icon file
3826 * @param icon_type The item's icon type
3827 * @param func The callback to execute when the item is clicked
3828 * @param data The data to associate with the item for related functions
3833 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)
3835 ELM_CHECK_WIDTYPE(obj, widtype);
3836 Widget_Data *wd = elm_widget_data_get(obj);
3837 Elm_Entry_Context_Menu_Item *it;
3839 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3841 wd->items = eina_list_append(wd->items, it);
3843 it->label = eina_stringshare_add(label);
3844 it->icon_file = eina_stringshare_add(icon_file);
3845 it->icon_type = icon_type;
3847 it->data = (void *)data;
3851 * This disables the entry's contextual (right click) menu.
3853 * @param obj The entry object
3854 * @param disabled If true, the menu is disabled
3859 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3861 ELM_CHECK_WIDTYPE(obj, widtype);
3862 Widget_Data *wd = elm_widget_data_get(obj);
3864 if (wd->context_menu == !disabled) return;
3865 wd->context_menu = !disabled;
3869 * This returns whether the entry's contextual (right click) menu is disabled.
3871 * @param obj The entry object
3872 * @return If true, the menu is disabled
3877 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3879 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3880 Widget_Data *wd = elm_widget_data_get(obj);
3881 if (!wd) return EINA_FALSE;
3882 return !wd->context_menu;
3886 * This appends a custom item provider to the list for that entry
3888 * This appends the given callback. The list is walked from beginning to end
3889 * with each function called given the item href string in the text. If the
3890 * function returns an object handle other than NULL (it should create an
3891 * and object to do this), then this object is used to replace that item. If
3892 * not the next provider is called until one provides an item object, or the
3893 * default provider in entry does.
3895 * @param obj The entry object
3896 * @param func The function called to provide the item object
3897 * @param data The data passed to @p func
3902 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3904 ELM_CHECK_WIDTYPE(obj, widtype);
3905 Widget_Data *wd = elm_widget_data_get(obj);
3907 EINA_SAFETY_ON_NULL_RETURN(func);
3908 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3912 wd->item_providers = eina_list_append(wd->item_providers, ip);
3916 * This prepends a custom item provider to the list for that entry
3918 * This prepends the given callback. See elm_entry_item_provider_append() for
3921 * @param obj The entry object
3922 * @param func The function called to provide the item object
3923 * @param data The data passed to @p func
3928 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3930 ELM_CHECK_WIDTYPE(obj, widtype);
3931 Widget_Data *wd = elm_widget_data_get(obj);
3933 EINA_SAFETY_ON_NULL_RETURN(func);
3934 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3938 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3942 * This removes a custom item provider to the list for that entry
3944 * This removes the given callback. See elm_entry_item_provider_append() for
3947 * @param obj The entry object
3948 * @param func The function called to provide the item object
3949 * @param data The data passed to @p func
3954 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3956 ELM_CHECK_WIDTYPE(obj, widtype);
3957 Widget_Data *wd = elm_widget_data_get(obj);
3959 Elm_Entry_Item_Provider *ip;
3961 EINA_SAFETY_ON_NULL_RETURN(func);
3962 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3964 if ((ip->func == func) && ((!data) || (ip->data == data)))
3966 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3974 * Append a filter function for text inserted in the entry
3976 * Append the given callback to the list. This functions will be called
3977 * whenever any text is inserted into the entry, with the text to be inserted
3978 * as a parameter. The callback function is free to alter the text in any way
3979 * it wants, but it must remember to free the given pointer and update it.
3980 * If the new text is to be discarded, the function can free it and set it text
3981 * parameter to NULL. This will also prevent any following filters from being
3984 * @param obj The entry object
3985 * @param func The function to use as text filter
3986 * @param data User data to pass to @p func
3991 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3994 Elm_Entry_Text_Filter *tf;
3995 ELM_CHECK_WIDTYPE(obj, widtype);
3997 wd = elm_widget_data_get(obj);
3999 EINA_SAFETY_ON_NULL_RETURN(func);
4001 tf = _filter_new(func, data);
4004 wd->text_filters = eina_list_append(wd->text_filters, tf);
4008 * Prepend a filter function for text insdrted in the entry
4010 * Prepend the given callback to the list. See elm_entry_text_filter_append()
4011 * for more information
4013 * @param obj The entry object
4014 * @param func The function to use as text filter
4015 * @param data User data to pass to @p func
4020 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4023 Elm_Entry_Text_Filter *tf;
4024 ELM_CHECK_WIDTYPE(obj, widtype);
4026 wd = elm_widget_data_get(obj);
4028 EINA_SAFETY_ON_NULL_RETURN(func);
4030 tf = _filter_new(func, data);
4033 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
4037 * Remove a filter from the list
4039 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
4040 * for more information.
4042 * @param obj The entry object
4043 * @param func The filter function to remove
4044 * @param data The user data passed when adding the function
4049 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
4053 Elm_Entry_Text_Filter *tf;
4054 ELM_CHECK_WIDTYPE(obj, widtype);
4056 wd = elm_widget_data_get(obj);
4058 EINA_SAFETY_ON_NULL_RETURN(func);
4060 EINA_LIST_FOREACH(wd->text_filters, l, tf)
4062 if ((tf->func == func) && ((!data) || (tf->data == data)))
4064 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
4072 * This converts a markup (HTML-like) string into UTF-8.
4073 * Returning string is obtained with malloc.
4074 * After use the returned string, it should be freed.
4076 * @param s The string (in markup) to be converted
4077 * @return The converted string (in UTF-8). It should be freed.
4082 elm_entry_markup_to_utf8(const char *s)
4084 char *ss = _elm_util_mkup_to_text(s);
4085 if (!ss) ss = strdup("");
4090 * This converts a UTF-8 string into markup (HTML-like).
4091 * Returning string is obtained with malloc.
4092 * After use the returned string, it should be freed.
4094 * @param s The string (in UTF-8) to be converted
4095 * @return The converted string (in markup). It should be freed.
4100 elm_entry_utf8_to_markup(const char *s)
4102 char *ss = _elm_util_text_to_mkup(s);
4103 if (!ss) ss = strdup("");
4108 * Filter inserted text based on user defined character and byte limits
4110 * Add this filter to an entry to limit the characters that it will accept
4111 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
4112 * The funtion works on the UTF-8 representation of the string, converting
4113 * it from the set markup, thus not accounting for any format in it.
4115 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
4116 * it as data when setting the filter. In it it's possible to set limits
4117 * by character count or bytes (any of them is disabled if 0), and both can
4118 * be set at the same time. In that case, it first checks for characters,
4121 * The function will cut the inserted text in order to allow only the first
4122 * number of characters that are still allowed. The cut is made in
4123 * characters, even when limiting by bytes, in order to always contain
4124 * valid ones and avoid half unicode characters making it in.
4129 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4131 Elm_Entry_Filter_Limit_Size *lim = data;
4134 const char *(*text_get)(const Evas_Object *);
4135 const char *widget_type;
4137 EINA_SAFETY_ON_NULL_RETURN(data);
4138 EINA_SAFETY_ON_NULL_RETURN(entry);
4139 EINA_SAFETY_ON_NULL_RETURN(text);
4141 /* hack. I don't want to copy the entire function to work with
4143 widget_type = elm_widget_type_get(entry);
4144 if (!strcmp(widget_type, "entry"))
4145 text_get = elm_entry_entry_get;
4149 current = elm_entry_markup_to_utf8(text_get(entry));
4151 if (lim->max_char_count > 0)
4153 len = evas_string_char_len_get(current);
4154 if (len >= lim->max_char_count)
4156 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4162 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4163 if ((len + newlen) > lim->max_char_count)
4164 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4166 else if (lim->max_byte_count > 0)
4168 len = strlen(current);
4169 if (len >= lim->max_byte_count)
4171 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4177 newlen = strlen(elm_entry_markup_to_utf8(*text));
4178 if ((len + newlen) > lim->max_byte_count)
4179 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4185 * Filter inserted text based on accepted or rejected sets of characters
4187 * Add this filter to an entry to restrict the set of accepted characters
4188 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4189 * This structure contains both accepted and rejected sets, but they are
4190 * mutually exclusive. If accepted is set, it will be used, otherwise it
4191 * goes on to the rejected set.
4194 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4196 Elm_Entry_Filter_Accept_Set *as = data;
4200 int read_idx, last_read_idx = 0, read_char;
4202 EINA_SAFETY_ON_NULL_RETURN(data);
4203 EINA_SAFETY_ON_NULL_RETURN(text);
4205 if ((!as->accepted) && (!as->rejected))
4211 goes_in = EINA_TRUE;
4216 goes_in = EINA_FALSE;
4220 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4223 int cmp_idx, cmp_char;
4224 Eina_Bool in_set = EINA_FALSE;
4226 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4229 if (read_char == cmp_char)
4234 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4236 if (in_set == goes_in)
4238 int size = read_idx - last_read_idx;
4239 const char *src = (*text) + last_read_idx;
4241 memcpy(insert, *text + last_read_idx, size);
4244 last_read_idx = read_idx;
4245 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4251 * This sets the file (and implicitly loads it) for the text to display and
4252 * then edit. All changes are written back to the file after a short delay if
4253 * the entry object is set to autosave.
4255 * @param obj The entry object
4256 * @param file The path to the file to load and save
4257 * @param format The file format
4262 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4264 ELM_CHECK_WIDTYPE(obj, widtype);
4265 Widget_Data *wd = elm_widget_data_get(obj);
4267 if (wd->delay_write)
4269 ecore_timer_del(wd->delay_write);
4270 wd->delay_write = NULL;
4272 if (wd->autosave) _save(obj);
4273 eina_stringshare_replace(&wd->file, file);
4274 wd->format = format;
4279 * Gets the file to load and save and the file format
4281 * @param obj The entry object
4282 * @param file The path to the file to load and save
4283 * @param format The file format
4288 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4290 ELM_CHECK_WIDTYPE(obj, widtype);
4291 Widget_Data *wd = elm_widget_data_get(obj);
4293 if (file) *file = wd->file;
4294 if (format) *format = wd->format;
4298 * This function writes any changes made to the file set with
4299 * elm_entry_file_set()
4301 * @param obj The entry object
4306 elm_entry_file_save(Evas_Object *obj)
4308 ELM_CHECK_WIDTYPE(obj, widtype);
4309 Widget_Data *wd = elm_widget_data_get(obj);
4311 if (wd->delay_write)
4313 ecore_timer_del(wd->delay_write);
4314 wd->delay_write = NULL;
4317 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4321 * This sets the entry object to 'autosave' the loaded text file or not.
4323 * @param obj The entry object
4324 * @param autosave Autosave the loaded file or not
4329 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4331 ELM_CHECK_WIDTYPE(obj, widtype);
4332 Widget_Data *wd = elm_widget_data_get(obj);
4334 wd->autosave = !!autosave;
4338 * This gets the entry object's 'autosave' status.
4340 * @param obj The entry object
4341 * @return Autosave the loaded file or not
4346 elm_entry_autosave_get(const Evas_Object *obj)
4348 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4349 Widget_Data *wd = elm_widget_data_get(obj);
4350 if (!wd) return EINA_FALSE;
4351 return wd->autosave;
4355 * Control pasting of text and images for the widget.
4357 * Normally the entry allows both text and images to be pasted. By setting
4358 * textonly to be true, this prevents images from being pasted.
4360 * Note this only changes the behaviour of text.
4362 * @param obj The entry object
4363 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4368 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4370 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4371 ELM_CHECK_WIDTYPE(obj, widtype);
4372 Widget_Data *wd = elm_widget_data_get(obj);
4374 textonly = !!textonly;
4375 if (wd->textonly == textonly) return;
4376 wd->textonly = !!textonly;
4377 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4378 #ifdef HAVE_ELEMENTARY_X
4379 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4384 * Getting elm_entry text paste/drop mode.
4386 * In textonly mode, only text may be pasted or dropped into the widget.
4388 * @param obj The entry object
4389 * @return If the widget only accepts text from pastes.
4394 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4396 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4397 Widget_Data *wd = elm_widget_data_get(obj);
4398 if (!wd) return EINA_FALSE;
4399 return wd->textonly;
4403 * Enable or disable scrolling in entry
4405 * Normally the entry is not scrollable unless you enable it with this call.
4407 * @param obj The entry object
4408 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4413 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4415 ELM_CHECK_WIDTYPE(obj, widtype);
4416 Widget_Data *wd = elm_widget_data_get(obj);
4419 if (wd->scroll == scroll) return;
4420 wd->scroll = scroll;
4423 elm_widget_sub_object_del(obj, wd->scroller);
4424 elm_widget_resize_object_set(obj, wd->scroller);
4425 elm_widget_sub_object_add(obj, wd->ent);
4426 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4427 evas_object_show(wd->scroller);
4428 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4429 if (wd->single_line)
4431 elm_smart_scroller_policy_set(wd->scroller,
4432 ELM_SMART_SCROLLER_POLICY_OFF,
4433 ELM_SMART_SCROLLER_POLICY_OFF);
4434 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4438 const Elm_Scroller_Policy map[3] =
4440 ELM_SMART_SCROLLER_POLICY_AUTO,
4441 ELM_SMART_SCROLLER_POLICY_ON,
4442 ELM_SMART_SCROLLER_POLICY_OFF
4444 elm_smart_scroller_policy_set(wd->scroller,
4447 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4452 elm_smart_scroller_child_set(wd->scroller, NULL);
4453 elm_widget_sub_object_del(obj, wd->ent);
4454 elm_widget_resize_object_set(obj, wd->ent);
4455 evas_object_smart_member_add(wd->scroller, obj);
4456 elm_widget_sub_object_add(obj, wd->scroller);
4457 evas_object_hide(wd->scroller);
4458 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4465 * Get the scrollable state of the entry
4467 * Normally the entry is not scrollable. This gets the scrollable state
4468 * of the entry. See elm_entry_scrollable_set() for more information.
4470 * @param obj The entry object
4471 * @return The scrollable state
4476 elm_entry_scrollable_get(const Evas_Object *obj)
4478 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4479 Widget_Data *wd = elm_widget_data_get(obj);
4480 if (!wd) return EINA_FALSE;
4485 * This sets a widget to be displayed to the left of a scrolled entry.
4487 * @param obj The scrolled entry object
4488 * @param icon The widget to display on the left side of the scrolled
4491 * @note A previously set widget will be destroyed.
4492 * @note If the object being set does not have minimum size hints set,
4493 * it won't get properly displayed.
4496 * @see elm_entry_end_set
4499 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4501 ELM_CHECK_WIDTYPE(obj, widtype);
4502 Widget_Data *wd = elm_widget_data_get(obj);
4505 EINA_SAFETY_ON_NULL_RETURN(icon);
4506 if (wd->icon == icon) return;
4507 if (wd->icon) evas_object_del(wd->icon);
4509 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4511 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4512 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4517 * Gets the leftmost widget of the scrolled entry. This object is
4518 * owned by the scrolled entry and should not be modified.
4520 * @param obj The scrolled entry object
4521 * @return the left widget inside the scroller
4526 elm_entry_icon_get(const Evas_Object *obj)
4528 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4529 Widget_Data *wd = elm_widget_data_get(obj);
4530 if (!wd) return NULL;
4535 * Unset the leftmost widget of the scrolled entry, unparenting and
4538 * @param obj The scrolled entry object
4539 * @return the previously set icon sub-object of this entry, on
4542 * @see elm_entry_icon_set()
4547 elm_entry_icon_unset(Evas_Object *obj)
4549 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4550 Widget_Data *wd = elm_widget_data_get(obj);
4551 Evas_Object *ret = NULL;
4552 if (!wd) return NULL;
4555 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4556 if (!edje) return NULL;
4558 edje_object_part_unswallow(edje, wd->icon);
4559 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4567 * Sets the visibility of the left-side widget of the scrolled entry,
4568 * set by @elm_entry_icon_set().
4570 * @param obj The scrolled entry object
4571 * @param setting EINA_TRUE if the object should be displayed,
4572 * EINA_FALSE if not.
4577 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4579 ELM_CHECK_WIDTYPE(obj, widtype);
4580 Widget_Data *wd = elm_widget_data_get(obj);
4581 if ((!wd) || (!wd->icon)) return;
4583 evas_object_hide(wd->icon);
4585 evas_object_show(wd->icon);
4590 * This sets a widget to be displayed to the end of a scrolled entry.
4592 * @param obj The scrolled entry object
4593 * @param end The widget to display on the right side of the scrolled
4596 * @note A previously set widget will be destroyed.
4597 * @note If the object being set does not have minimum size hints set,
4598 * it won't get properly displayed.
4601 * @see elm_entry_icon_set
4604 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4606 ELM_CHECK_WIDTYPE(obj, widtype);
4607 Widget_Data *wd = elm_widget_data_get(obj);
4610 EINA_SAFETY_ON_NULL_RETURN(end);
4611 if (wd->end == end) return;
4612 if (wd->end) evas_object_del(wd->end);
4614 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4616 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4617 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4622 * Gets the endmost widget of the scrolled entry. This object is owned
4623 * by the scrolled entry and should not be modified.
4625 * @param obj The scrolled entry object
4626 * @return the right widget inside the scroller
4631 elm_entry_end_get(const Evas_Object *obj)
4633 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4634 Widget_Data *wd = elm_widget_data_get(obj);
4635 if (!wd) return NULL;
4640 * Unset the endmost widget of the scrolled entry, unparenting and
4643 * @param obj The scrolled entry object
4644 * @return the previously set icon sub-object of this entry, on
4647 * @see elm_entry_icon_set()
4652 elm_entry_end_unset(Evas_Object *obj)
4654 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4655 Widget_Data *wd = elm_widget_data_get(obj);
4656 Evas_Object *ret = NULL;
4657 if (!wd) return NULL;
4660 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4661 if (!edje) return NULL;
4663 edje_object_part_unswallow(edje, wd->end);
4664 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4672 * Sets the visibility of the end widget of the scrolled entry, set by
4673 * @elm_entry_end_set().
4675 * @param obj The scrolled entry object
4676 * @param setting EINA_TRUE if the object should be displayed,
4677 * EINA_FALSE if not.
4682 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4684 ELM_CHECK_WIDTYPE(obj, widtype);
4685 Widget_Data *wd = elm_widget_data_get(obj);
4686 if ((!wd) || (!wd->end)) return;
4688 evas_object_hide(wd->end);
4690 evas_object_show(wd->end);
4695 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4697 * @param obj The scrolled entry object
4698 * @param h The horizontal scrollbar policy to apply
4699 * @param v The vertical scrollbar policy to apply
4704 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4706 ELM_CHECK_WIDTYPE(obj, widtype);
4707 Widget_Data *wd = elm_widget_data_get(obj);
4708 const Elm_Scroller_Policy map[3] =
4710 ELM_SMART_SCROLLER_POLICY_AUTO,
4711 ELM_SMART_SCROLLER_POLICY_ON,
4712 ELM_SMART_SCROLLER_POLICY_OFF
4717 elm_smart_scroller_policy_set(wd->scroller,
4723 * This enables/disables bouncing within the entry.
4725 * @param obj The scrolled entry object
4726 * @param h The horizontal bounce state
4727 * @param v The vertical bounce state
4732 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4734 ELM_CHECK_WIDTYPE(obj, widtype);
4735 Widget_Data *wd = elm_widget_data_get(obj);
4737 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4741 * Get the bounce mode
4743 * @param obj The Entry object
4744 * @param h_bounce Allow bounce horizontally
4745 * @param v_bounce Allow bounce vertically
4750 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4752 ELM_CHECK_WIDTYPE(obj, widtype);
4753 Widget_Data *wd = elm_widget_data_get(obj);
4755 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4759 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4761 ELM_CHECK_WIDTYPE(obj, widtype);
4762 Widget_Data *wd = elm_widget_data_get(obj);
4765 wd->input_panel_layout = layout;
4767 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
4770 EAPI Elm_Input_Panel_Layout
4771 elm_entry_input_panel_layout_get(Evas_Object *obj)
4773 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
4774 Widget_Data *wd = elm_widget_data_get(obj);
4775 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
4777 return wd->input_panel_layout;
4781 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
4783 ELM_CHECK_WIDTYPE(obj, widtype);
4784 Widget_Data *wd = elm_widget_data_get(obj);
4787 wd->autocapital_type = autocapital_type;
4788 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
4791 EAPI Elm_Autocapital_Type
4792 elm_entry_autocapital_type_get(Evas_Object *obj)
4794 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
4795 Widget_Data *wd = elm_widget_data_get(obj);
4796 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
4798 return wd->autocapital_type;
4802 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4804 ELM_CHECK_WIDTYPE(obj, widtype);
4805 Widget_Data *wd = elm_widget_data_get(obj);
4808 wd->input_panel_enable = enabled;
4809 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4812 EINA_DEPRECATED EAPI void
4813 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4815 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);
4819 * Set background color of the entry
4821 * @param obj The entry object
4822 * @param r Red property background color of The entry object
4823 * @param g Green property background color of The entry object
4824 * @param b Blue property background color of The entry object
4825 * @param a Alpha property background alpha of The entry object
4829 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4831 ELM_CHECK_WIDTYPE(obj, widtype);
4832 Widget_Data *wd = elm_widget_data_get(obj);
4833 evas_object_color_set(wd->bg, r, g, b, a);
4835 if (wd->bgcolor == EINA_FALSE)
4838 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4843 * Set whether entry should support auto capitalization
4845 * @param obj The entry object
4846 * @param on If true, entry suports auto capitalization.
4851 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4853 ELM_CHECK_WIDTYPE(obj, widtype);
4854 Widget_Data *wd = elm_widget_data_get(obj);
4858 wd->autocapital_type = ELM_AUTOCAPITAL_TYPE_SENTENCE;
4860 wd->autocapital_type = ELM_AUTOCAPITAL_TYPE_NONE;
4862 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4863 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4864 wd->autocapital_type = ELM_AUTOCAPITAL_TYPE_NONE;
4866 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
4870 * Set whether entry should support auto period
4872 * @param obj The entry object
4873 * @param on If true, entry suports auto period.
4878 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4880 ELM_CHECK_WIDTYPE(obj, widtype);
4881 Widget_Data *wd = elm_widget_data_get(obj);
4885 wd->autoperiod = EINA_FALSE;
4887 wd->autoperiod = autoperiod;
4889 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4890 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4891 wd->autoperiod = EINA_FALSE;
4893 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4897 * Set whether entry should enable the return key on soft keyboard automatically
4899 * @param obj The entry object
4900 * @param on If true, entry enables the return key on soft keyboard automatically.
4905 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
4907 ELM_CHECK_WIDTYPE(obj, widtype);
4908 Widget_Data *wd = elm_widget_data_get(obj);
4911 wd->autoreturnkey = on;
4912 _check_enable_returnkey(obj);
4916 * Get the input method context in the entry widget
4918 * @param obj The entry object
4919 * @return The input method context
4923 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
4925 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4926 Widget_Data *wd = elm_widget_data_get(obj);
4927 if (!wd || !wd->ent) return NULL;
4929 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4933 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
4935 Widget_Data *wd = elm_widget_data_get(obj);
4940 Evas_Coord max_w = 9999, max_h = 9999;
4941 const char* key_data = NULL;
4943 wd->matchlist_threshold = 1;
4944 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
4945 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
4946 elm_hover_target_set(wd->hover, obj);
4947 elm_object_style_set(wd->hover, "matchlist");
4949 wd->layout = elm_layout_add(wd->hover);
4950 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
4951 wd->list = elm_list_add(wd->layout);
4952 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
4953 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
4954 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
4955 elm_object_style_set(wd->list, "matchlist");
4957 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
4958 if (key_data) max_w = atoi(key_data);
4959 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
4960 if (key_data) max_h = atoi(key_data);
4962 elm_list_go(wd->list);
4963 evas_object_size_hint_max_set(wd->list, max_w, max_h);
4964 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
4965 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
4966 elm_hover_content_set(wd->hover, "bottom", wd->layout);
4968 wd->match_list = match_list;
4973 evas_object_del(wd->hover);
4975 wd->match_list = NULL;
4978 wd->matchlist_case_sensitive = case_sensitive;
4982 * Set the magnifier style of the entry
4984 * @param obj The entry object
4985 * @param type the magnifier style to set
4990 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4992 ELM_CHECK_WIDTYPE(obj, widtype);
4993 Widget_Data *wd = elm_widget_data_get(obj);
4996 wd->mgf_type = type;
4997 _magnifier_create(obj);
5001 * Set wrap width of the entry
5003 * @param obj The entry object
5004 * @param w The wrap width in pixels at a minimum where words need to wrap
5008 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
5010 Widget_Data *wd = elm_widget_data_get(obj);
5012 if (wd->wrap_w == w) return;
5018 * get wrap width of the entry
5020 * @param obj The entry object
5021 * @return The wrap width in pixels at a minimum where words need to wrap
5025 elm_entry_wrap_width_get(const Evas_Object *obj)
5027 Widget_Data *wd = elm_widget_data_get(obj);
5033 * Set the font size on the entry object
5035 * @param obj The entry object
5036 * @param size font size
5041 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
5043 ELM_CHECK_WIDTYPE(obj, widtype);
5044 Widget_Data *wd = elm_widget_data_get(obj);
5045 Eina_Strbuf *fontbuf = NULL;
5050 t = eina_stringshare_add(elm_entry_entry_get(obj));
5051 fontbuf = eina_strbuf_new();
5052 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
5054 if (fontsize == 0) removeflag = 1; // remove fontsize tag
5056 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
5058 elm_entry_entry_set(obj, t);
5062 eina_strbuf_free(fontbuf);
5063 eina_stringshare_del(t);
5067 * Set the text color on the entry object
5069 * @param obj The entry object
5070 * @param r Red property background color of The entry object
5071 * @param g Green property background color of The entry object
5072 * @param b Blue property background color of The entry object
5073 * @param a Alpha property background alpha of The entry object
5078 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
5080 ELM_CHECK_WIDTYPE(obj, widtype);
5081 Widget_Data *wd = elm_widget_data_get(obj);
5082 Eina_Strbuf *colorbuf = NULL;
5087 t = eina_stringshare_add(elm_entry_entry_get(obj));
5089 if (len <= 0) return;
5090 colorbuf = eina_strbuf_new();
5091 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
5093 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
5095 elm_entry_entry_set(obj, t);
5099 eina_strbuf_free(colorbuf);
5100 eina_stringshare_del(t);
5104 * Set the text align on the entry object
5106 * @param obj The entry object
5107 * @param align align mode
5112 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
5114 ELM_CHECK_WIDTYPE(obj, widtype);
5115 Widget_Data *wd = elm_widget_data_get(obj);
5120 t = eina_stringshare_add(elm_entry_entry_get(obj));
5122 if (len <= 0) return;
5124 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
5125 elm_entry_entry_set(obj, t);
5129 eina_stringshare_del(t);