1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "elm_module_priv.h"
7 * @defgroup Entry Entry
9 * An entry is a convenience widget which shows
10 * a box that the user can enter text into. Unlike a
11 * @ref Scrolled_Entry widget, entries DO NOT scroll with user
12 * input. Entry widgets are capable of expanding past the
13 * boundaries of the window, thus resizing the window to its
16 * You can also insert "items" in the entry with:
18 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
20 * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
21 * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
22 * supports a list of emoticon names by default. These are:
25 * - emoticon/angry-shout
26 * - emoticon/crazy-laugh
27 * - emoticon/evil-laugh
29 * - emoticon/goggle-smile
31 * - emoticon/grumpy-smile
33 * - emoticon/guilty-smile
35 * - emoticon/half-smile
36 * - emoticon/happy-panting
38 * - emoticon/indifferent
40 * - emoticon/knowing-grin
42 * - emoticon/little-bit-sorry
43 * - emoticon/love-lots
45 * - emoticon/minimal-smile
46 * - emoticon/not-happy
47 * - emoticon/not-impressed
49 * - emoticon/opensmile
52 * - emoticon/squint-laugh
53 * - emoticon/surprised
54 * - emoticon/suspicious
55 * - emoticon/tongue-dangling
56 * - emoticon/tongue-poke
59 * - emoticon/very-sorry
65 * These are built-in currently, but you can add your own item provieer that
66 * can create inlined objects in the text and fill the space allocated to the
67 * item with a custom object of your own.
69 * See the entry test for some more examples of use of this.
71 * Entries have functions to load a text file, display it,
72 * allowing editing of it and saving of changes back to the file loaded.
73 * Changes are written back to the original file after a short delay.
74 * The file to load and save to is specified by elm_entry_file_set().
76 * Signals that you can add callbacks for are:
78 * "changed" - The text within the entry was changed
79 * "activated" - The entry has had editing finished and changes are to be committed
80 (generally when enter key is pressed)
81 * "press" - The entry has been clicked
82 * "longpressed" - The entry has been clicked for a couple seconds
83 * "clicked" - The entry has been clicked
84 * "clicked,double" - The entry has been double clicked
85 * "focused" - The entry has received focus
86 * "unfocused" - The entry has lost focus
87 * "selection,paste" - A paste action has occurred
88 * "selection,copy" - A copy action has occurred
89 * "selection,cut" - A cut action has occurred
90 * "selection,start" - A selection has begun
91 * "selection,changed" - The selection has changed
92 * "selection,cleared" - The selection has been cleared
93 * "cursor,changed" - The cursor has changed
94 * "anchor,clicked" - The anchor has been clicked
95 * "preedit,changed" - The preedit string has changed
98 /* Maximum chunk size to be inserted to the entry at once
99 * FIXME: This size is arbitrary, should probably choose a better size.
100 * Possibly also find a way to set it to a low value for weak computers,
101 * and to a big value for better computers. */
102 #define _CHUNK_SIZE 10000
104 typedef struct _Mod_Api Mod_Api;
106 typedef struct _Widget_Data Widget_Data;
107 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
108 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
109 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
113 Evas_Object *ent, *scroller, *end, *icon;
115 Evas_Object *hoversel;
119 Evas_Object *mgf_proxy;
120 Evas_Object *mgf_clip;
122 Evas_Coord mgf_height;
125 Ecore_Job *deferred_recalc_job;
126 Ecore_Event_Handler *sel_notify_handler;
127 Ecore_Event_Handler *sel_clear_handler;
128 Ecore_Timer *delay_write;
129 /* for deferred appending */
130 Ecore_Idler *append_text_idler;
131 char *append_text_left;
132 int append_text_position;
134 /* Only for clipboard */
137 const char *password_text;
140 Elm_Text_Format format;
141 Evas_Coord lastw, entmw, entmh;
142 Evas_Coord downx, downy;
143 Evas_Coord cx, cy, cw, ch;
145 Eina_List *item_providers;
146 Eina_List *text_filters;
147 Eina_List *match_list;
148 Ecore_Job *matchlist_job;
149 int matchlist_threshold;
150 Ecore_Job *hovdeljob;
151 Mod_Api *api; // module api if supplied
153 Elm_Scroller_Policy policy_h, policy_v;
154 Elm_Wrap_Type linewrap;
155 Elm_Input_Panel_Layout input_panel_layout;
156 Eina_Bool changed : 1;
157 Eina_Bool single_line : 1;
158 Eina_Bool password : 1;
159 Eina_Bool editable : 1;
160 Eina_Bool selection_asked : 1;
161 Eina_Bool have_selection : 1;
162 Eina_Bool selmode : 1;
163 Eina_Bool deferred_cur : 1;
164 Eina_Bool cur_changed : 1;
165 Eina_Bool disabled : 1;
166 Eina_Bool double_clicked : 1;
167 Eina_Bool long_pressed : 1;
168 Eina_Bool context_menu : 1;
169 Eina_Bool drag_selection_asked : 1;
170 Eina_Bool bgcolor : 1;
171 Eina_Bool can_write : 1;
172 Eina_Bool autosave : 1;
173 Eina_Bool textonly : 1;
174 Eina_Bool usedown : 1;
175 Eina_Bool scroll : 1;
176 Eina_Bool autoreturnkey : 1;
177 Eina_Bool input_panel_enable : 1;
178 Eina_Bool autocapital : 1;
179 Eina_Bool autoperiod : 1;
180 Eina_Bool matchlist_list_clicked : 1;
181 Eina_Bool matchlist_case_sensitive : 1;
184 struct _Elm_Entry_Context_Menu_Item
188 const char *icon_file;
189 const char *icon_group;
190 Elm_Icon_Type icon_type;
195 struct _Elm_Entry_Item_Provider
197 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
201 struct _Elm_Entry_Text_Filter
203 void (*func) (void *data, Evas_Object *entry, char **text);
207 typedef enum _Length_Unit
214 static const char *widtype = NULL;
216 static Evas_Object *cnpwidgetdata = NULL;
219 #ifdef HAVE_ELEMENTARY_X
220 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
222 static void _del_hook(Evas_Object *obj);
223 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
224 static void _theme_hook(Evas_Object *obj);
225 static void _disable_hook(Evas_Object *obj);
226 static void _sizing_eval(Evas_Object *obj);
227 static void _on_focus_hook(void *data, Evas_Object *obj);
228 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
229 static const char *_getbase(Evas_Object *obj);
230 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
231 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
232 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
233 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
234 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
235 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
236 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
237 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
238 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
239 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
240 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
241 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
242 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
243 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
244 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
245 static int _entry_length_get(Evas_Object *obj);
246 static void _magnifier_create(void *data);
247 static void _magnifier_show(void *data);
248 static void _magnifier_hide(void *data);
249 static void _magnifier_move(void *data);
251 static const char SIG_CHANGED[] = "changed";
252 static const char SIG_ACTIVATED[] = "activated";
253 static const char SIG_PRESS[] = "press";
254 static const char SIG_LONGPRESSED[] = "longpressed";
255 static const char SIG_CLICKED[] = "clicked";
256 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
257 static const char SIG_FOCUSED[] = "focused";
258 static const char SIG_UNFOCUSED[] = "unfocused";
259 static const char SIG_SELECTION_PASTE[] = "selection,paste";
260 static const char SIG_SELECTION_COPY[] = "selection,copy";
261 static const char SIG_SELECTION_CUT[] = "selection,cut";
262 static const char SIG_SELECTION_START[] = "selection,start";
263 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
264 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
265 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
266 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
267 static const char SIG_MATCHLIST_CLICKED[] = "matchlist,clicked";
268 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
269 static const Evas_Smart_Cb_Description _signals[] = {
273 {SIG_LONGPRESSED, ""},
275 {SIG_CLICKED_DOUBLE, ""},
278 {SIG_SELECTION_PASTE, ""},
279 {SIG_SELECTION_COPY, ""},
280 {SIG_SELECTION_CUT, ""},
281 {SIG_SELECTION_START, ""},
282 {SIG_SELECTION_CHANGED, ""},
283 {SIG_SELECTION_CLEARED, ""},
284 {SIG_CURSOR_CHANGED, ""},
285 {SIG_ANCHOR_CLICKED, ""},
286 {SIG_PREEDIT_CHANGED, ""},
287 {SIG_MATCHLIST_CLICKED, ""},
291 typedef enum _Elm_Entry_Magnifier_Type
293 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
294 _ENTRY_MAGNIFIER_FILLWIDTH,
295 _ENTRY_MAGNIFIER_CIRCULAR,
296 } Elm_Entry_Magnifier_Type;
299 static Eina_List *entries = NULL;
303 void (*obj_hook) (Evas_Object *obj);
304 void (*obj_unhook) (Evas_Object *obj);
305 void (*obj_longpress) (Evas_Object *obj);
306 void (*obj_hidemenu) (Evas_Object *obj);
307 void (*obj_mouseup) (Evas_Object *obj);
311 _module(Evas_Object *obj __UNUSED__)
313 static Elm_Module *m = NULL;
314 if (m) goto ok; // already found - just use
315 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
317 m->api = malloc(sizeof(Mod_Api));
318 if (!m->api) return NULL;
319 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
320 _elm_module_symbol_get(m, "obj_hook");
321 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
322 _elm_module_symbol_get(m, "obj_unhook");
323 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
324 _elm_module_symbol_get(m, "obj_longpress");
325 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
326 _elm_module_symbol_get(m, "obj_hidemenu");
327 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
328 _elm_module_symbol_get(m, "obj_mouseup");
329 ok: // ok - return api
334 _buf_append(char *buf, const char *str, int *len, int *alloc)
336 int len2 = strlen(str);
337 if ((*len + len2) >= *alloc)
339 char *buf2 = realloc(buf, *alloc + len2 + 512);
340 if (!buf2) return NULL;
342 *alloc += (512 + len2);
344 strcpy(buf + *len, str);
350 _load_file(const char *file)
354 int alloc = 0, len = 0;
355 char *text = NULL, buf[16384 + 1];
357 f = fopen(file, "rb");
359 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
363 tmp_text = _buf_append(text, buf, &len, &alloc);
364 if (!tmp_text) break;
372 _load_plain(const char *file)
376 text = _load_file(file);
381 text2 = elm_entry_utf8_to_markup(text);
389 _load(Evas_Object *obj)
391 Widget_Data *wd = elm_widget_data_get(obj);
396 elm_entry_entry_set(obj, "");
401 case ELM_TEXT_FORMAT_PLAIN_UTF8:
402 text = _load_plain(wd->file);
404 case ELM_TEXT_FORMAT_MARKUP_UTF8:
405 text = _load_file(wd->file);
413 elm_entry_entry_set(obj, text);
417 elm_entry_entry_set(obj, "");
421 _save_markup_utf8(const char *file, const char *text)
425 if ((!text) || (!text[0]))
427 ecore_file_unlink(file);
430 f = fopen(file, "wb");
433 // FIXME: report a write error
436 fputs(text, f); // FIXME: catch error
441 _save_plain_utf8(const char *file, const char *text)
445 text2 = elm_entry_markup_to_utf8(text);
448 _save_markup_utf8(file, text2);
453 _save(Evas_Object *obj)
455 Widget_Data *wd = elm_widget_data_get(obj);
457 if (!wd->file) return;
460 case ELM_TEXT_FORMAT_PLAIN_UTF8:
461 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
463 case ELM_TEXT_FORMAT_MARKUP_UTF8:
464 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
472 _delay_write(void *data)
474 Widget_Data *wd = elm_widget_data_get(data);
475 if (!wd) return ECORE_CALLBACK_CANCEL;
477 wd->delay_write = NULL;
478 return ECORE_CALLBACK_CANCEL;
481 static Elm_Entry_Text_Filter *
482 _filter_new(void (*func) (void *data, Evas_Object *entry, char **text), void *data)
484 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
485 if (!tf) return NULL;
488 if (func == elm_entry_filter_limit_size)
490 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
497 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
503 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
506 else if (func == elm_entry_filter_accept_set)
508 Elm_Entry_Filter_Accept_Set *as = data, *as2;
515 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
522 as2->accepted = eina_stringshare_add(as->accepted);
524 as2->accepted = NULL;
526 as2->rejected = eina_stringshare_add(as->rejected);
528 as2->rejected = NULL;
537 _filter_free(Elm_Entry_Text_Filter *tf)
539 if (tf->func == elm_entry_filter_limit_size)
541 Elm_Entry_Filter_Limit_Size *lim = tf->data;
544 else if (tf->func == elm_entry_filter_accept_set)
546 Elm_Entry_Filter_Accept_Set *as = tf->data;
549 if (as->accepted) eina_stringshare_del(as->accepted);
550 if (as->rejected) eina_stringshare_del(as->rejected);
558 _del_pre_hook(Evas_Object *obj)
560 Widget_Data *wd = elm_widget_data_get(obj);
564 ecore_timer_del(wd->delay_write);
565 wd->delay_write = NULL;
566 if (wd->autosave) _save(obj);
571 _del_hook(Evas_Object *obj)
573 Widget_Data *wd = elm_widget_data_get(obj);
574 Elm_Entry_Context_Menu_Item *it;
575 Elm_Entry_Item_Provider *ip;
576 Elm_Entry_Text_Filter *tf;
578 if (wd->file) eina_stringshare_del(wd->file);
580 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
581 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
583 entries = eina_list_remove(entries, obj);
584 #ifdef HAVE_ELEMENTARY_X
585 if (wd->sel_notify_handler)
586 ecore_event_handler_del(wd->sel_notify_handler);
587 if (wd->sel_clear_handler)
588 ecore_event_handler_del(wd->sel_clear_handler);
590 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
591 if (wd->text) eina_stringshare_del(wd->text);
592 if (wd->password_text) eina_stringshare_del(wd->password_text);
593 if (wd->bg) evas_object_del(wd->bg);
594 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
595 if (wd->append_text_idler)
597 ecore_idler_del(wd->append_text_idler);
598 free(wd->append_text_left);
599 wd->append_text_left = NULL;
600 wd->append_text_idler = NULL;
602 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
603 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
604 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
605 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
607 EINA_LIST_FREE(wd->items, it)
609 eina_stringshare_del(it->label);
610 eina_stringshare_del(it->icon_file);
611 eina_stringshare_del(it->icon_group);
614 EINA_LIST_FREE(wd->item_providers, ip)
618 EINA_LIST_FREE(wd->text_filters, tf)
622 if (wd->delay_write) ecore_timer_del(wd->delay_write);
627 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
629 Widget_Data *wd = elm_widget_data_get(obj);
630 edje_object_mirrored_set(wd->ent, rtl);
634 _theme_hook(Evas_Object *obj)
636 Widget_Data *wd = elm_widget_data_get(obj);
638 Ecore_IMF_Context *ic;
639 _elm_widget_mirrored_reload(obj);
640 _mirrored_set(obj, elm_widget_mirrored_get(obj));
642 t = eina_stringshare_add(elm_entry_entry_get(obj));
643 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
644 if (_elm_config->desktop_entry)
645 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
646 elm_entry_entry_set(obj, t);
647 eina_stringshare_del(t);
648 if (elm_widget_disabled_get(obj))
649 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
650 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
651 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
652 if (elm_widget_focus_get(obj))
653 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
654 edje_object_message_signal_process(wd->ent);
655 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
656 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
657 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
658 elm_widget_style_get(obj));
664 edj = elm_smart_scroller_edje_object_get(wd->scroller);
665 str = edje_object_data_get(edj, "focus_highlight");
666 if ((str) && (!strcmp(str, "on")))
667 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
669 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
674 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", EINA_FALSE);
675 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", EINA_FALSE);
679 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
680 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
683 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
686 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
693 _disable_hook(Evas_Object *obj)
695 Widget_Data *wd = elm_widget_data_get(obj);
697 if (elm_widget_disabled_get(obj))
699 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
700 wd->disabled = EINA_TRUE;
704 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
705 wd->disabled = EINA_FALSE;
710 _recalc_cursor_geometry(Evas_Object *obj)
712 Widget_Data *wd = elm_widget_data_get(obj);
714 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
715 if (!elm_object_focus_get(obj)) return;
716 if (!wd->deferred_recalc_job)
718 Evas_Coord cx, cy, cw, ch;
719 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
723 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
724 wd->cur_changed = EINA_FALSE;
728 wd->deferred_cur = EINA_TRUE;
732 _elm_win_recalc_job(void *data)
734 Widget_Data *wd = elm_widget_data_get(data);
735 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
737 wd->deferred_recalc_job = NULL;
739 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
740 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
741 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
744 /* This is a hack to workaround the way min size hints are treated.
745 * If the minimum width is smaller than the restricted width, it means
746 * the mininmum doesn't matter. */
749 Evas_Coord ominw = -1;
750 evas_object_size_hint_min_get(data, &ominw, NULL);
754 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
757 Evas_Coord vmw = 0, vmh = 0;
759 edje_object_size_min_calc
760 (elm_smart_scroller_edje_object_get(wd->scroller),
764 evas_object_size_hint_min_set(data, vmw, minh + vmh);
765 evas_object_size_hint_max_set(data, -1, minh + vmh);
769 evas_object_size_hint_min_set(data, vmw, vmh);
770 evas_object_size_hint_max_set(data, -1, -1);
777 evas_object_size_hint_min_set(data, minw, minh);
778 evas_object_size_hint_max_set(data, -1, minh);
782 evas_object_size_hint_min_set(data, fw, minh);
783 evas_object_size_hint_max_set(data, -1, -1);
787 if ((wd->deferred_cur) && (elm_object_focus_get(data)))
789 Evas_Coord cx, cy, cw, ch;
790 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
794 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
795 wd->cur_changed = EINA_FALSE;
801 _sizing_eval(Evas_Object *obj)
803 Widget_Data *wd = elm_widget_data_get(obj);
804 Evas_Coord minw = -1, minh = -1;
805 Evas_Coord resw, resh;
808 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
811 if ((resw == wd->lastw) && (!wd->changed)) return;
812 wd->changed = EINA_FALSE;
816 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
818 evas_object_resize(wd->scroller, resw, resh);
819 edje_object_size_min_calc
820 (elm_smart_scroller_edje_object_get(wd->scroller),
822 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
823 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
826 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
828 if ((minw > 0) && (vw < minw)) vw = minw;
829 if (minh > vh) vh = minh;
831 if (wd->single_line) h = vmh + minh;
833 evas_object_resize(wd->ent, vw, vh);
834 evas_object_size_hint_min_get(obj, &w, NULL);
835 evas_object_size_hint_min_set(obj, w, h);
837 evas_object_size_hint_max_set(obj, -1, h);
839 evas_object_size_hint_max_set(obj, -1, -1);
843 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
844 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
849 if (!wd->changed) return;
850 wd->changed = EINA_FALSE;
854 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
856 edje_object_size_min_calc(wd->ent, &minw, &minh);
859 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
861 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
863 if ((minw > 0) && (vw < minw)) vw = minw;
864 if (minh > 0) vh = minh;
866 evas_object_resize(wd->ent, vw, vh);
867 edje_object_size_min_calc
868 (elm_smart_scroller_edje_object_get(wd->scroller),
870 if (wd->single_line) h = vmh + minh;
872 evas_object_size_hint_min_get(obj, &w, NULL);
873 evas_object_size_hint_min_set(obj, w, h);
875 evas_object_size_hint_max_set(obj, -1, h);
877 evas_object_size_hint_max_set(obj, -1, -1);
881 edje_object_size_min_calc(wd->ent, &minw, &minh);
884 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
885 evas_object_size_hint_min_set(obj, minw, minh);
887 evas_object_size_hint_max_set(obj, -1, minh);
889 evas_object_size_hint_max_set(obj, -1, -1);
893 _recalc_cursor_geometry(obj);
897 _check_enable_returnkey(Evas_Object *obj)
899 Widget_Data *wd = elm_widget_data_get(obj);
902 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
905 if (!wd->autoreturnkey) return;
907 if (_entry_length_get(obj) == 0)
909 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
913 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
918 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
920 Widget_Data *wd = elm_widget_data_get(obj);
921 Evas_Object *top = elm_widget_top_get(obj);
923 if (elm_widget_focus_get(obj))
925 printf("[Elm_entry::Focused] obj : %p\n", obj);
926 evas_object_focus_set(wd->ent, EINA_TRUE);
927 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
928 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
929 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
930 _check_enable_returnkey(obj);
931 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
935 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
936 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
937 evas_object_focus_set(wd->ent, EINA_FALSE);
938 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
939 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
941 if ((wd->api) && (wd->api->obj_hidemenu))
943 wd->api->obj_hidemenu(obj);
949 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
951 Widget_Data *wd = elm_widget_data_get(obj);
953 edje_object_signal_emit(wd->ent, emission, source);
955 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
960 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
962 Widget_Data *wd = elm_widget_data_get(obj);
964 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
966 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
967 emission, source, func_cb, data);
971 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
973 Widget_Data *wd = elm_widget_data_get(obj);
974 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
977 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
978 emission, source, func_cb, data);
982 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
984 Widget_Data *wd = elm_widget_data_get(obj);
985 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
989 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
991 Widget_Data *wd = elm_widget_data_get(obj);
993 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
997 _show_region_hook(void *data, Evas_Object *obj)
999 Widget_Data *wd = elm_widget_data_get(data);
1000 Evas_Coord x, y, w, h;
1002 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1004 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1008 _hoversel_position(Evas_Object *obj)
1010 Widget_Data *wd = elm_widget_data_get(obj);
1011 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1016 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1025 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1026 &cx, &cy, &cw, &ch);
1027 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1030 cx += (cw - mw) / 2;
1035 cy += (ch - mh) / 2;
1038 evas_object_move(wd->hoversel, x + cx, y + cy);
1039 evas_object_resize(wd->hoversel, cw, ch);
1043 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1047 if (wd->hoversel) _hoversel_position(data);
1051 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1053 Widget_Data *wd = elm_widget_data_get(data);
1060 else if (wd->scroll)
1062 Evas_Coord vw = 0, vh = 0;
1064 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1065 if (vw < wd->entmw) vw = wd->entmw;
1066 if (vh < wd->entmh) vh = wd->entmh;
1067 evas_object_resize(wd->ent, vw, vh);
1069 if (wd->hoversel) _hoversel_position(data);
1073 _hover_del(void *data)
1075 Widget_Data *wd = elm_widget_data_get(data);
1080 evas_object_del(wd->hoversel);
1081 wd->hoversel = NULL;
1083 wd->hovdeljob = NULL;
1087 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1089 Widget_Data *wd = elm_widget_data_get(data);
1092 if (wd->hoversel) evas_object_hide(wd->hoversel);
1095 if (!_elm_config->desktop_entry)
1098 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1101 elm_widget_scroll_freeze_pop(data);
1102 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1103 wd->hovdeljob = ecore_job_add(_hover_del, data);
1107 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1109 Widget_Data *wd = elm_widget_data_get(data);
1111 wd->selmode = EINA_TRUE;
1112 edje_object_part_text_select_none(wd->ent, "elm.text");
1113 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1114 edje_object_part_text_select_all(wd->ent, "elm.text");
1115 elm_object_scroll_freeze_pop(data);
1119 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1121 Widget_Data *wd = elm_widget_data_get(data);
1123 wd->selmode = EINA_TRUE;
1124 edje_object_part_text_select_none(wd->ent, "elm.text");
1125 if (!_elm_config->desktop_entry)
1128 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1130 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1131 if (!_elm_config->desktop_entry)
1132 elm_object_scroll_freeze_pop(data);
1133 //elm_widget_scroll_hold_push(data);
1137 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1139 Widget_Data *wd = elm_widget_data_get(data);
1141 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1142 if (wd->sel_notify_handler)
1144 #ifdef HAVE_ELEMENTARY_X
1145 Elm_Sel_Format formats;
1146 wd->selection_asked = EINA_TRUE;
1147 formats = ELM_SEL_FORMAT_MARKUP;
1149 formats |= ELM_SEL_FORMAT_IMAGE;
1150 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1156 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1158 Widget_Data *wd = elm_widget_data_get(obj);
1163 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1164 sel_str = strdup(sel);
1171 char *startTag = NULL;
1172 char *endTag = NULL;
1174 startTag = strstr(sel_str, "<item");
1176 startTag = strstr(sel_str, "</item");
1178 endTag = strstr(startTag, ">");
1181 if (!endTag || startTag > endTag)
1184 size_t sindex = startTag - sel_str;
1185 size_t eindex = endTag - sel_str + 1;
1187 Eina_Strbuf *buf = eina_strbuf_new();
1190 eina_strbuf_append(buf, sel_str);
1191 eina_strbuf_remove(buf, sindex, eindex);
1192 sel_str = eina_strbuf_string_steal(buf);
1193 eina_strbuf_free(buf);
1197 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str);
1198 if (seltype == ELM_SEL_CLIPBOARD)
1199 eina_stringshare_replace(&wd->cut_sel, sel_str);
1204 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1206 Widget_Data *wd = elm_widget_data_get(data);
1209 wd->selmode = EINA_FALSE;
1210 if (!_elm_config->desktop_entry)
1211 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1212 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1213 if (!_elm_config->desktop_entry)
1214 elm_widget_scroll_hold_pop(data);
1215 _store_selection(ELM_SEL_CLIPBOARD, data);
1216 edje_object_part_text_insert(wd->ent, "elm.text", "");
1217 edje_object_part_text_select_none(wd->ent, "elm.text");
1221 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1223 Widget_Data *wd = elm_widget_data_get(data);
1225 wd->selmode = EINA_TRUE;
1226 if (!_elm_config->desktop_entry)
1228 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1229 elm_widget_scroll_hold_pop(data);
1231 _store_selection(ELM_SEL_CLIPBOARD, data);
1235 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1237 Widget_Data *wd = elm_widget_data_get(data);
1239 wd->selmode = EINA_FALSE;
1240 if (!_elm_config->desktop_entry)
1241 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1242 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1243 if (!_elm_config->desktop_entry)
1244 elm_widget_scroll_hold_pop(data);
1245 edje_object_part_text_select_none(wd->ent, "elm.text");
1249 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1251 Widget_Data *wd = elm_widget_data_get(data);
1255 #ifdef HAVE_ELEMENTARY_X
1256 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1258 cnpwidgetdata = data;
1259 elm_cbhm_helper_init(obj);
1260 if (elm_entry_cnp_textonly_get(obj))
1261 elm_cbhm_send_raw_data("show0");
1263 elm_cbhm_send_raw_data("show1");
1269 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1271 Widget_Data *wd = elm_widget_data_get(data);
1273 cnpwidgetdata = data;
1279 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1281 Elm_Entry_Context_Menu_Item *it = data;
1282 Evas_Object *obj2 = it->obj;
1283 if (it->func) it->func(it->data, obj2, NULL);
1287 _menu_press(Evas_Object *obj)
1289 Widget_Data *wd = elm_widget_data_get(obj);
1292 const Elm_Entry_Context_Menu_Item *it;
1294 if ((wd->api) && (wd->api->obj_longpress))
1296 wd->api->obj_longpress(obj);
1298 else if (wd->context_menu)
1300 const char *context_menu_orientation;
1302 if (wd->hoversel) evas_object_del(wd->hoversel);
1303 else elm_widget_scroll_freeze_push(obj);
1304 wd->hoversel = elm_hoversel_add(obj);
1305 context_menu_orientation = edje_object_data_get
1306 (wd->ent, "context_menu_orientation");
1307 if ((context_menu_orientation) &&
1308 (!strcmp(context_menu_orientation, "horizontal")))
1309 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1310 elm_object_style_set(wd->hoversel, "entry");
1311 elm_widget_sub_object_add(obj, wd->hoversel);
1312 elm_object_text_set(wd->hoversel, "Text");
1313 top = elm_widget_top_get(obj);
1314 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1315 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1319 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1321 if (1) // need way to detect if someone has a selection
1324 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1328 if ((!wd->password) && (wd->editable))
1329 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1330 _clipboard_menu, obj);
1337 if (wd->have_selection)
1339 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1342 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1345 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1349 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1350 _clipboard_menu, obj);
1354 EINA_LIST_FOREACH(wd->items, l, it)
1356 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1357 it->icon_type, _item_clicked, it);
1361 _hoversel_position(obj);
1362 evas_object_show(wd->hoversel);
1363 elm_hoversel_hover_begin(wd->hoversel);
1365 if (!_elm_config->desktop_entry)
1367 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1368 edje_object_part_text_select_abort(wd->ent, "elm.text");
1374 _magnifier_hide(void *data)
1376 Widget_Data *wd = elm_widget_data_get(data);
1379 evas_object_hide(wd->mgf_bg);
1380 evas_object_hide(wd->mgf_clip);
1383 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1387 _magnifier_show(void *data)
1389 Widget_Data *wd = elm_widget_data_get(data);
1392 evas_object_show(wd->mgf_bg);
1393 evas_object_show(wd->mgf_clip);
1397 _magnifier_move(void *data)
1399 Widget_Data *wd = elm_widget_data_get(data);
1402 Evas_Coord x, y, w, h, fs;
1403 Evas_Coord cx, cy, cw, ch, ox, oy;
1405 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1409 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1410 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1415 evas_object_geometry_get(data, &x, &y, &w, &h);
1418 fs = elm_finger_size_get();
1420 if ((cy + y) - wd->mgf_height - fs < 0)
1421 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1423 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1424 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1425 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1426 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1430 evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 - fs + oy);
1434 _magnifier_create(void *data)
1436 Widget_Data *wd = elm_widget_data_get(data);
1437 Evas_Coord x, y, w, h, mw, mh;
1438 const char* key_data = NULL;
1444 evas_object_image_source_unset(wd->mgf_proxy);
1445 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1446 evas_object_hide(wd->mgf_proxy);
1447 evas_object_clip_unset(wd->mgf_proxy);
1448 evas_object_del(wd->mgf_proxy);
1450 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1451 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1454 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1456 evas_object_geometry_get(data, &x, &y, &w, &h);
1458 if ((w <= 0) || (h <= 0))
1461 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1463 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1464 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1465 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1466 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1470 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1471 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1472 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1474 key_data = edje_object_data_get(wd->mgf_bg, "height");
1475 if (key_data) wd->mgf_height = atoi(key_data);
1476 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1477 if (key_data) wd->mgf_scale = atof(key_data);
1479 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1480 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1484 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1485 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1486 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1490 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1491 evas_object_image_source_set(wd->mgf_proxy, data);
1494 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1495 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1496 if ((mw <= 0) || (mh <= 0))
1499 evas_object_resize(wd->mgf_proxy, mw, mh);
1500 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1501 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1502 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1503 evas_object_show(wd->mgf_proxy);
1504 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1506 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1507 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1511 _signal_long_pressed(void *data)
1513 Widget_Data *wd = elm_widget_data_get(data);
1514 if (!wd) return ECORE_CALLBACK_CANCEL;
1516 wd->long_pressed = EINA_TRUE;
1518 _cancel(data, NULL, NULL);
1520 _magnifier_create(data);
1521 _magnifier_move(data);
1522 _magnifier_show(data);
1523 elm_object_scroll_freeze_push(data);
1525 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1526 return ECORE_CALLBACK_CANCEL;
1530 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1532 Widget_Data *wd = elm_widget_data_get(data);
1533 Evas_Event_Mouse_Down *ev = event_info;
1535 if (wd->disabled) return;
1536 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1537 wd->downx = ev->canvas.x;
1538 wd->downy = ev->canvas.y;
1539 wd->long_pressed = EINA_FALSE;
1543 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1545 Widget_Data *wd = elm_widget_data_get(data);
1546 Evas_Event_Mouse_Up *ev = event_info;
1548 if (wd->disabled) return;
1549 if (ev->button == 1)
1551 if (!wd->double_clicked)
1553 if ((wd->api) && (wd->api->obj_mouseup))
1554 wd->api->obj_mouseup(data);
1556 _magnifier_hide(data);
1557 elm_object_scroll_freeze_pop(data);
1559 if (wd->long_pressed)
1562 else if (ev->button == 3)
1570 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1572 Widget_Data *wd = elm_widget_data_get(data);
1573 Evas_Event_Mouse_Move *ev = event_info;
1575 if (wd->disabled) return;
1577 if (ev->buttons == 1)
1579 if (wd->long_pressed)
1581 _magnifier_show(data);
1582 _magnifier_move(data);
1588 _getbase(Evas_Object *obj)
1590 Widget_Data *wd = elm_widget_data_get(obj);
1591 if (!wd) return "base";
1594 if (wd->password) return "base-password";
1597 if (wd->single_line) return "base-single";
1600 switch (wd->linewrap)
1603 return "base-charwrap";
1606 case ELM_WRAP_MIXED:
1607 return "base-mixedwrap";
1610 return "base-nowrap";
1617 if (wd->password) return "base-password";
1620 if (wd->single_line) return "base-single-noedit";
1623 switch (wd->linewrap)
1626 return "base-noedit-charwrap";
1628 return "base-noedit";
1629 case ELM_WRAP_MIXED:
1630 return "base-noedit-mixedwrap";
1633 return "base-nowrap-noedit";
1643 _entry_length_get(Evas_Object *obj)
1646 const char *str = elm_entry_entry_get(obj);
1649 char *plain_str = _elm_util_mkup_to_text(str);
1650 if (!plain_str) return 0;
1652 len = strlen(plain_str);
1658 #ifndef HAVE_STRCASESTR
1659 char* _strcasestr(const char *s, const char *find)
1664 if ((c = *find++) != 0) {
1665 c = tolower((unsigned char) c);
1669 if( (sc = *s++) == 0)
1671 } while ((char)tolower((unsigned char)sc) != c);
1672 } while (strncasecmp(s, find, len) != 0);
1680 _matchlist_show(void *data)
1682 Widget_Data *wd = elm_widget_data_get(data);
1683 const char *text = NULL;
1685 char *str_list = NULL, *str_result = NULL;
1686 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1689 Eina_Bool textfound = EINA_FALSE;
1692 if (elm_widget_disabled_get(data)) return;
1694 wd->matchlist_job = NULL;
1696 if (wd->matchlist_list_clicked)
1698 evas_object_hide(wd->hover);
1699 wd->matchlist_list_clicked = EINA_FALSE;
1702 text = elm_entry_entry_get(data);
1705 textlen = strlen(text);
1707 if (textlen < wd->matchlist_threshold)
1709 evas_object_hide(wd->hover);
1713 evas_object_hide(wd->hover);
1717 elm_list_clear(wd->list);
1718 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1720 if (wd->matchlist_case_sensitive)
1721 str_result = strstr(str_list, text);
1723 #ifdef HAVE_STRCASESTR
1724 str_result = strcasestr(str_list, text);
1726 str_result = _strcasestr(str_list, text);
1731 str_mkup = malloc(strlen(str_list) + 16);
1732 if (str_mkup == NULL) return;
1734 textlen = strlen(str_list) - strlen(str_result);
1735 str_front = malloc(textlen + 1);
1736 if (str_front == NULL) return;
1738 memset(str_front, 0, textlen + 1);
1739 strncpy(str_front, str_list, textlen);
1741 textlen = strlen(text);
1742 str_mid = malloc(textlen + 1);
1743 if (str_mid == NULL) return;
1745 memset(str_mid, 0, textlen + 1);
1746 strncpy(str_mid, str_list + strlen(str_front), textlen);
1748 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1750 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1752 if (str_mkup) free(str_mkup);
1753 if (str_front) free(str_front);
1754 if (str_mid) free(str_mid);
1756 textfound=EINA_TRUE;
1765 elm_list_go(wd->list);
1766 evas_object_show(wd->hover);
1767 evas_object_raise(wd->hover);
1771 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1773 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1774 Widget_Data *wd = elm_widget_data_get(data);
1775 if ((it == NULL) || (wd == NULL))
1778 const char *text = elm_list_item_label_get(it);
1779 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1784 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1785 elm_entry_cursor_end_set(data);
1786 wd->matchlist_list_clicked = EINA_TRUE;
1788 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1791 elm_widget_focus_set(data, EINA_TRUE);
1795 _entry_changed_common_handling(void *data, const char *event)
1797 Widget_Data *wd = elm_widget_data_get(data);
1798 Evas_Coord minw, minh;
1800 wd->changed = EINA_TRUE;
1801 /* Reset the size hints which are no more relevant.
1802 * Keep the height, this is a hack, but doesn't really matter
1803 * cause we'll re-eval in a moment. */
1806 evas_object_size_hint_min_get(data, &minw, &minh);
1807 evas_object_size_hint_min_set(data, minw, minh);
1811 evas_object_size_hint_min_get(data, NULL, &minh);
1812 evas_object_size_hint_min_set(data, -1, minh);
1816 if (wd->text) eina_stringshare_del(wd->text);
1818 if (wd->password_text) eina_stringshare_del(wd->password_text);
1819 wd->password_text = NULL;
1820 _check_enable_returnkey(data);
1821 evas_object_smart_callback_call(data, event, NULL);
1822 if (wd->delay_write)
1824 ecore_timer_del(wd->delay_write);
1825 wd->delay_write = NULL;
1828 if ((wd->single_line) && (wd->match_list))
1830 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1831 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1833 if ((!wd->autosave) || (!wd->file)) return;
1834 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1838 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1840 Widget_Data *wd = elm_widget_data_get(data);
1843 _entry_changed_common_handling(data, SIG_CHANGED);
1845 if ((wd->api) && (wd->api->obj_hidemenu))
1846 wd->api->obj_hidemenu(data);
1850 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1852 Widget_Data *wd = elm_widget_data_get(data);
1855 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1857 if ((wd->api) && (wd->api->obj_hidemenu))
1858 wd->api->obj_hidemenu(data);
1862 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1864 Widget_Data *wd = elm_widget_data_get(data);
1867 elm_object_scroll_freeze_push(data);
1869 if ((wd->api) && (wd->api->obj_hidemenu))
1870 wd->api->obj_hidemenu(data);
1872 _magnifier_create(data);
1873 _magnifier_move(data);
1874 _magnifier_show(data);
1878 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1880 Widget_Data *wd = elm_widget_data_get(data);
1883 elm_object_scroll_freeze_pop(data);
1885 if (wd->have_selection)
1887 _magnifier_hide(data);
1893 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1895 _magnifier_move(data);
1896 _magnifier_show(data);
1899 static Evas_Object *
1900 _viewport_obj_get(Evas_Object *data)
1902 Widget_Data *wd = elm_widget_data_get(data);
1903 if (!wd) return NULL;
1905 if(!data || !strlen(elm_widget_type_get(data)))
1908 Evas_Coord x, y, w, h;
1913 //evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1914 //printf(">>> wd->scroller (%d, %d, %d, %d) \n", x, y, w, h);
1915 return wd->scroller;
1918 Evas_Object *parent_obj = data;
1920 while(parent_obj = elm_widget_parent_get(parent_obj))
1922 //evas_object_geometry_get(parent_obj, &x, &y, &w, &h);
1923 //printf(">>> %s (%d, %d, %d, %d) \n", elm_widget_type_get(parent_obj), x, y, w, h);
1924 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
1925 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
1933 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1935 _magnifier_hide(data);
1940 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1942 Widget_Data *wd = elm_widget_data_get(data);
1946 EINA_LIST_FOREACH(entries, l, entry)
1948 if (entry != data) elm_entry_select_none(entry);
1950 wd->have_selection = EINA_TRUE;
1951 wd->selmode = EINA_TRUE;
1952 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1953 #ifdef HAVE_ELEMENTARY_X
1954 if (wd->sel_notify_handler)
1956 const char *txt = elm_entry_selection_get(data);
1959 top = elm_widget_top_get(data);
1960 if ((top) && (elm_win_xwindow_get(top)))
1961 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1965 if (!_elm_config->desktop_entry)
1966 edje_object_part_text_viewport_object_set(wd->ent, "elm.text", _viewport_obj_get(data));
1970 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1972 Evas_Coord cx, cy, cw, ch;
1973 Widget_Data *wd = elm_widget_data_get(data);
1976 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1977 if (!wd->deferred_recalc_job)
1978 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1981 wd->deferred_cur = EINA_TRUE;
1985 wd->ch = ch + elm_finger_size_get();
1990 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1992 Evas_Coord cx, cy, cw, ch;
1993 Widget_Data *wd = elm_widget_data_get(data);
1995 wd->have_selection = EINA_TRUE;
1996 wd->selmode = EINA_TRUE;
1997 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1998 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1999 elm_entry_selection_get(data));
2001 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2002 if (!wd->deferred_recalc_job)
2003 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE);
2006 wd->deferred_cur = EINA_TRUE;
2010 wd->ch = ch + elm_finger_size_get();
2015 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2017 Widget_Data *wd = elm_widget_data_get(data);
2019 if (!wd->have_selection) return;
2020 wd->have_selection = EINA_FALSE;
2021 wd->selmode = EINA_FALSE;
2022 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2023 if (wd->sel_notify_handler)
2027 #ifdef HAVE_ELEMENTARY_X
2030 top = elm_widget_top_get(data);
2031 if ((top) && (elm_win_xwindow_get(top)))
2032 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2035 eina_stringshare_del(wd->cut_sel);
2040 #ifdef HAVE_ELEMENTARY_X
2043 top = elm_widget_top_get(data);
2044 if ((top) && (elm_win_xwindow_get(top)))
2045 elm_selection_clear(ELM_SEL_PRIMARY, data);
2050 if ((wd->api) && (wd->api->obj_hidemenu))
2052 wd->api->obj_hidemenu(data);
2057 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2059 Widget_Data *wd = elm_widget_data_get(data);
2061 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2062 if (wd->sel_notify_handler)
2064 #ifdef HAVE_ELEMENTARY_X
2067 top = elm_widget_top_get(data);
2068 if ((top) && (elm_win_xwindow_get(top)))
2070 wd->selection_asked = EINA_TRUE;
2071 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2079 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2081 Widget_Data *wd = elm_widget_data_get(data);
2083 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2084 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2085 elm_entry_selection_get(data));
2089 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2091 Widget_Data *wd = elm_widget_data_get(data);
2093 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2094 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2095 elm_entry_selection_get(data));
2096 edje_object_part_text_insert(wd->ent, "elm.text", "");
2097 wd->changed = EINA_TRUE;
2102 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2104 Widget_Data *wd = elm_widget_data_get(data);
2106 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2107 wd->cur_changed = EINA_TRUE;
2108 _recalc_cursor_geometry(data);
2112 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2114 Widget_Data *wd = elm_widget_data_get(data);
2119 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2121 Widget_Data *wd = elm_widget_data_get(data);
2126 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2128 Widget_Data *wd = elm_widget_data_get(data);
2129 Elm_Entry_Anchor_Info ei;
2130 char *buf2, *p, *p2, *n;
2132 p = strrchr(emission, ',');
2135 const Eina_List *geoms;
2139 while (p2 >= emission)
2141 if (*p2 == ',') break;
2145 buf2 = alloca(5 + p - p2);
2146 strncpy(buf2, p2, p - p2);
2149 ei.button = atoi(buf2);
2150 ei.x = ei.y = ei.w = ei.h = 0;
2152 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2155 Evas_Textblock_Rectangle *r;
2157 Evas_Coord px, py, x, y;
2159 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2160 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2161 EINA_LIST_FOREACH(geoms, l, r)
2163 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2164 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2175 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2180 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2182 Widget_Data *wd = elm_widget_data_get(data);
2187 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2189 Widget_Data *wd = elm_widget_data_get(data);
2194 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2196 Widget_Data *wd = elm_widget_data_get(data);
2201 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2203 Widget_Data *wd = elm_widget_data_get(data);
2205 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2209 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2211 Widget_Data *wd = elm_widget_data_get(data);
2213 wd->double_clicked = EINA_FALSE;
2214 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2216 if ((wd->api) && (wd->api->obj_hidemenu))
2217 wd->api->obj_hidemenu(data);
2221 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2223 Widget_Data *wd = elm_widget_data_get(data);
2225 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2227 if (!_elm_config->desktop_entry && !wd->double_clicked)
2228 _cancel(data, NULL, NULL);
2232 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2234 Widget_Data *wd = elm_widget_data_get(data);
2236 wd->double_clicked = EINA_TRUE;
2237 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2240 #ifdef HAVE_ELEMENTARY_X
2242 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2244 Widget_Data *wd = elm_widget_data_get(data);
2245 Ecore_X_Event_Selection_Notify *ev = event;
2246 if (!wd) return ECORE_CALLBACK_PASS_ON;
2247 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2248 return ECORE_CALLBACK_PASS_ON;
2250 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2251 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2253 Ecore_X_Selection_Data_Text *text_data;
2255 text_data = ev->data;
2256 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2258 if (text_data->text)
2260 char *txt = _elm_util_text_to_mkup(text_data->text);
2264 elm_entry_entry_insert(data, txt);
2269 wd->selection_asked = EINA_FALSE;
2271 else if (ev->selection == ECORE_X_SELECTION_XDND)
2273 Ecore_X_Selection_Data_Text *text_data;
2275 text_data = ev->data;
2276 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2278 if (text_data->text)
2280 char *txt = _elm_util_text_to_mkup(text_data->text);
2284 /* Massive FIXME: this should be at the drag point */
2285 elm_entry_entry_insert(data, txt);
2290 wd->drag_selection_asked = EINA_FALSE;
2292 ecore_x_dnd_send_finished();
2295 return ECORE_CALLBACK_PASS_ON;
2299 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2302 Widget_Data *wd = elm_widget_data_get(data);
2303 Ecore_X_Event_Selection_Clear *ev = event;
2304 if (!wd) return ECORE_CALLBACK_PASS_ON;
2305 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2306 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2307 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2309 elm_entry_select_none(data);
2314 Evas_Object *top = elm_widget_top_get(data);
2315 Ecore_X_Event_Selection_Clear *ev = event;
2318 return ECORE_CALLBACK_PASS_ON;
2320 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2322 return ECORE_CALLBACK_PASS_ON;
2325 if (cnpwidgetdata == data)
2327 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2328 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2332 return ECORE_CALLBACK_PASS_ON;
2336 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2341 wd = elm_widget_data_get(obj);
2342 if (!wd) return EINA_FALSE;
2343 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2345 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2346 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2347 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2348 EDJE_CURSOR_MAIN,drop->x,drop->y);
2349 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2350 elm_entry_entry_insert(obj, drop->data);
2351 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2352 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2358 static Evas_Object *
2359 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2361 Widget_Data *wd = elm_widget_data_get(data);
2364 Elm_Entry_Item_Provider *ip;
2366 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2368 o = ip->func(ip->data, data, item);
2371 if (!strncmp(item, "file://", 7))
2373 const char *fname = item + 7;
2375 o = evas_object_image_filled_add(evas_object_evas_get(data));
2376 evas_object_image_file_set(o, fname, NULL);
2377 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2379 evas_object_show(o);
2384 o = edje_object_add(evas_object_evas_get(data));
2385 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2389 o = edje_object_add(evas_object_evas_get(data));
2390 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2391 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2396 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2398 const char *srcstring = NULL;
2399 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2400 char *curlocater, *replocater;
2401 char *starttag, *endtag;
2402 int tagtxtlen = 0, insertflag = 0;
2404 srcstring = eina_strbuf_string_get(srcbuf);
2405 curlocater = strstr(srcstring, key);
2407 if (!curlocater || !srcstring)
2415 starttag = strchr(srcstring, '<');
2416 endtag = strchr(srcstring, '>');
2417 tagtxtlen = endtag - starttag;
2418 if (tagtxtlen <= 0) tagtxtlen = 0;
2419 if (starttag < curlocater && curlocater < endtag) break;
2420 if (endtag != NULL && endtag+1 != NULL)
2421 srcstring = endtag+1;
2424 } while (strlen(srcstring) > 1);
2426 if (starttag && endtag && tagtxtlen > strlen(key))
2428 repbuf = eina_strbuf_new();
2429 diffbuf = eina_strbuf_new();
2430 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2431 srcstring = eina_strbuf_string_get(repbuf);
2432 curlocater = strstr(srcstring, key);
2434 if (curlocater != NULL)
2436 replocater = curlocater + strlen(key) + 1;
2438 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2441 if (replocater-curlocater > strlen(key)+1)
2443 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2452 eina_strbuf_reset(repbuf);
2460 if (repbuf == NULL) repbuf = eina_strbuf_new();
2461 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2465 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2466 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2472 eina_strbuf_prepend(diffbuf, "<");
2473 eina_strbuf_append(diffbuf, ">");
2474 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2478 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2479 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2483 if (repbuf) eina_strbuf_free(repbuf);
2484 if (diffbuf) eina_strbuf_free(diffbuf);
2490 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2492 Eina_Strbuf *sharebuf = NULL;
2494 sharebuf = eina_strbuf_new();
2495 eina_strbuf_append(sharebuf, *srcstring);
2496 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2497 eina_stringshare_del(*srcstring);
2498 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2499 eina_strbuf_free(sharebuf);
2505 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2507 Widget_Data *wd = elm_widget_data_get(data);
2509 Elm_Entry_Text_Filter *tf;
2511 if (type == EDJE_TEXT_FILTER_FORMAT)
2514 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2516 tf->func(tf->data, data, text);
2522 /* This function is used to insert text by chunks in jobs */
2524 _text_append_idler(void *data)
2528 Evas_Object *obj = (Evas_Object *) data;
2529 Widget_Data *wd = elm_widget_data_get(obj);
2530 if (wd->text) eina_stringshare_del(wd->text);
2532 if (wd->password_text) eina_stringshare_del(wd->password_text);
2533 wd->password_text = NULL;
2534 wd->changed = EINA_TRUE;
2536 start = wd->append_text_position;
2537 if (start + _CHUNK_SIZE < wd->append_text_len)
2540 int tag_start, esc_start;
2542 tag_start = esc_start = -1;
2543 /* Find proper markup cut place */
2544 while (pos - start < _CHUNK_SIZE)
2548 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2549 if (esc_start == -1)
2552 tag_start = prev_pos;
2553 else if (tmp == '>')
2556 else if (tag_start == -1)
2559 esc_start = prev_pos;
2560 else if (tmp == ';')
2567 wd->append_text_position = tag_start;
2569 else if (esc_start >= 0)
2571 wd->append_text_position = esc_start;
2575 wd->append_text_position = pos;
2580 wd->append_text_position = wd->append_text_len;
2583 backup = wd->append_text_left[wd->append_text_position];
2584 wd->append_text_left[wd->append_text_position] = '\0';
2586 edje_object_part_text_append(wd->ent, "elm.text",
2587 wd->append_text_left + start);
2589 wd->append_text_left[wd->append_text_position] = backup;
2591 /* If there's still more to go, renew the idler, else, cleanup */
2592 if (wd->append_text_position < wd->append_text_len)
2594 return ECORE_CALLBACK_RENEW;
2598 free(wd->append_text_left);
2599 wd->append_text_left = NULL;
2600 wd->append_text_idler = NULL;
2601 return ECORE_CALLBACK_CANCEL;
2606 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2608 int i = 0, unit_size;
2609 int current_len = strlen(*text);
2610 char *new_text = *text;
2611 if (unit >= LENGTH_UNIT_LAST) return;
2614 if (*new_text == '<')
2616 while (*new_text != '>')
2619 if (!*new_text) break;
2626 if (*new_text == '&')
2628 while (*(new_text + index) != ';')
2631 if (!*(new_text + index)) break;
2635 index = evas_string_char_next_get(new_text, index, NULL);
2636 markup = malloc(index + 1);
2637 strncpy(markup, new_text, index);
2639 if (unit == LENGTH_UNIT_BYTE)
2640 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2641 else if (unit == LENGTH_UNIT_CHAR)
2642 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2648 if (can_add < unit_size)
2652 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2658 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2659 current_len -= index;
2660 (*text)[current_len] = 0;
2665 can_add -= unit_size;
2670 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2674 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2677 ELM_CHECK_WIDTYPE(obj, widtype);
2678 if (item && strcmp(item, "default")) return;
2679 Widget_Data *wd = elm_widget_data_get(obj);
2681 if (!entry) entry = "";
2682 if (wd->text) eina_stringshare_del(wd->text);
2684 if (wd->password_text) eina_stringshare_del(wd->password_text);
2685 wd->password_text = NULL;
2686 wd->changed = EINA_TRUE;
2688 /* Clear currently pending job if there is one */
2689 if (wd->append_text_idler)
2691 ecore_idler_del(wd->append_text_idler);
2692 free(wd->append_text_left);
2693 wd->append_text_left = NULL;
2694 wd->append_text_idler = NULL;
2697 len = strlen(entry);
2698 /* Split to ~_CHUNK_SIZE chunks */
2699 if (len > _CHUNK_SIZE)
2701 wd->append_text_left = (char *) malloc(len + 1);
2704 /* If we decided to use the idler */
2705 if (wd->append_text_left)
2707 /* Need to clear the entry first */
2708 edje_object_part_text_set(wd->ent, "elm.text", "");
2709 memcpy(wd->append_text_left, entry, len + 1);
2710 wd->append_text_position = 0;
2711 wd->append_text_len = len;
2712 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2716 edje_object_part_text_set(wd->ent, "elm.text", entry);
2721 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2723 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2724 Widget_Data *wd = elm_widget_data_get(obj);
2725 if (item && strcmp(item, "default")) return NULL;
2727 if (!wd) return NULL;
2730 if(wd->password_text) return wd->password_text;
2736 text = edje_object_part_text_get(wd->ent, "elm.text");
2739 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2742 eina_stringshare_replace(&wd->text, text);
2745 const char *pw_text;
2746 pw_text = elm_entry_markup_to_utf8(wd->text);
2749 eina_stringshare_replace(&wd->password_text, pw_text);
2751 return wd->password_text;
2758 * This adds an entry to @p parent object.
2760 * @param parent The parent object
2761 * @return The new object or NULL if it cannot be created
2766 elm_entry_add(Evas_Object *parent)
2768 Evas_Object *obj, *top;
2772 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2774 ELM_SET_WIDTYPE(widtype, "entry");
2775 elm_widget_type_set(obj, "entry");
2776 elm_widget_sub_object_add(parent, obj);
2777 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2778 elm_widget_data_set(obj, wd);
2779 elm_widget_del_hook_set(obj, _del_hook);
2780 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2781 elm_widget_theme_hook_set(obj, _theme_hook);
2782 elm_widget_disable_hook_set(obj, _disable_hook);
2783 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2784 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2785 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2786 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2787 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2788 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2789 elm_widget_can_focus_set(obj, EINA_TRUE);
2790 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2791 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2792 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2794 wd->scroller = elm_smart_scroller_add(e);
2795 elm_widget_sub_object_add(obj, wd->scroller);
2796 elm_smart_scroller_widget_set(wd->scroller, obj);
2797 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2798 elm_widget_style_get(obj));
2799 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2800 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2801 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2802 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2804 wd->linewrap = ELM_WRAP_WORD;
2805 wd->editable = EINA_TRUE;
2806 wd->disabled = EINA_FALSE;
2807 wd->context_menu = EINA_TRUE;
2808 wd->autosave = EINA_TRUE;
2809 wd->textonly = EINA_FALSE;
2810 wd->autoperiod = EINA_TRUE;
2812 wd->ent = edje_object_add(e);
2813 elm_widget_sub_object_add(obj, wd->ent);
2814 edje_object_item_provider_set(wd->ent, _get_item, obj);
2815 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2816 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2817 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2819 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2821 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2823 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2825 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2826 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2827 _signal_entry_changed, obj);
2828 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2829 _signal_preedit_changed, obj);
2830 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2831 _signal_handler_move_start, obj);
2832 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2833 _signal_handler_move_end, obj);
2834 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2835 _signal_handler_moving, obj);
2836 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2837 _signal_selection_start, obj);
2838 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2839 _signal_selection_end, obj);
2840 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
2841 _signal_long_pressed, obj);
2842 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2843 _signal_magnifier_changed, obj);
2844 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2845 _signal_selection_changed, obj);
2846 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2847 _signal_selection_cleared, obj);
2848 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2849 _signal_entry_paste_request, obj);
2850 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2851 _signal_entry_copy_notify, obj);
2852 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2853 _signal_entry_cut_notify, obj);
2854 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2855 _signal_cursor_changed, obj);
2856 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2857 _signal_anchor_down, obj);
2858 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2859 _signal_anchor_up, obj);
2860 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2861 _signal_anchor_clicked, obj);
2862 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2863 _signal_anchor_move, obj);
2864 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2865 _signal_anchor_in, obj);
2866 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2867 _signal_anchor_out, obj);
2868 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2869 _signal_key_enter, obj);
2870 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2871 _signal_mouse_down, obj);
2872 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2873 _signal_mouse_clicked, obj);
2874 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2875 _signal_mouse_double, obj);
2876 edje_object_part_text_set(wd->ent, "elm.text", "");
2877 if (_elm_config->desktop_entry)
2878 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2879 elm_widget_resize_object_set(obj, wd->ent);
2882 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2884 #ifdef HAVE_ELEMENTARY_X
2885 top = elm_widget_top_get(obj);
2886 if ((top) && (elm_win_xwindow_get(top)))
2888 wd->sel_notify_handler =
2889 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2890 _event_selection_notify, obj);
2891 wd->sel_clear_handler =
2892 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2893 _event_selection_clear, obj);
2896 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2897 _drag_drop_cb, NULL);
2900 entries = eina_list_prepend(entries, obj);
2902 // module - find module for entry
2903 wd->api = _module(obj);
2904 // if found - hook in
2905 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2907 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2908 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2909 // TODO: and save some bytes, making descriptions per-class and not instance!
2910 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2914 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2916 ELM_CHECK_WIDTYPE(obj, widtype);
2917 Widget_Data *wd = elm_widget_data_get(obj);
2919 ext_mod->cancel = _cancel;
2920 ext_mod->copy = _copy;
2921 ext_mod->cut = _cut;
2922 ext_mod->paste = _paste;
2923 ext_mod->select = _select;
2924 ext_mod->selectall = _selectall;
2925 ext_mod->ent = wd->ent;
2926 ext_mod->viewport_obj = _viewport_obj_get(obj);
2927 ext_mod->items = wd->items;
2928 ext_mod->editable = wd->editable;
2929 ext_mod->have_selection = wd->have_selection;
2930 ext_mod->password = wd->password;
2931 ext_mod->selmode = wd->selmode;
2932 ext_mod->cnpinit = _cnpinit;
2933 ext_mod->context_menu = wd->context_menu;
2934 ext_mod->textonly = wd->textonly;
2938 * This sets the entry object not to line wrap. All input will
2939 * be on a single line, and the entry box will extend with user input.
2941 * @param obj The entry object
2942 * @param single_line If true, the text in the entry
2943 * will be on a single line.
2948 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2950 ELM_CHECK_WIDTYPE(obj, widtype);
2951 Widget_Data *wd = elm_widget_data_get(obj);
2953 if (wd->single_line == single_line) return;
2954 wd->single_line = single_line;
2955 wd->linewrap = ELM_WRAP_NONE;
2956 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2960 if (wd->single_line)
2962 elm_smart_scroller_policy_set(wd->scroller,
2963 ELM_SMART_SCROLLER_POLICY_OFF,
2964 ELM_SMART_SCROLLER_POLICY_OFF);
2965 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2969 const Elm_Scroller_Policy map[3] =
2971 ELM_SMART_SCROLLER_POLICY_AUTO,
2972 ELM_SMART_SCROLLER_POLICY_ON,
2973 ELM_SMART_SCROLLER_POLICY_OFF
2975 elm_smart_scroller_policy_set(wd->scroller,
2978 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2985 * This returns true if the entry has been set to single line mode.
2986 * See also elm_entry_single_line_set().
2988 * @param obj The entry object
2989 * @return single_line If true, the text in the entry is set to display
2995 elm_entry_single_line_get(const Evas_Object *obj)
2997 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2998 Widget_Data *wd = elm_widget_data_get(obj);
2999 if (!wd) return EINA_FALSE;
3000 return wd->single_line;
3004 * This sets the entry object to password mode. All text entered
3005 * and/or displayed within the widget will be replaced with asterisks (*).
3007 * @param obj The entry object
3008 * @param password If true, password mode is enabled.
3013 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3015 ELM_CHECK_WIDTYPE(obj, widtype);
3016 Widget_Data *wd = elm_widget_data_get(obj);
3018 if (wd->password == password) return;
3019 wd->password = password;
3020 wd->single_line = EINA_TRUE;
3021 wd->linewrap = ELM_WRAP_NONE;
3026 * This returns whether password mode is enabled.
3027 * See also elm_entry_password_set().
3029 * @param obj The entry object
3030 * @return If true, the entry is set to display all characters
3036 elm_entry_password_get(const Evas_Object *obj)
3038 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3039 Widget_Data *wd = elm_widget_data_get(obj);
3040 if (!wd) return EINA_FALSE;
3041 return wd->password;
3045 * This sets the text displayed within the entry to @p entry.
3047 * @param obj The entry object
3048 * @param entry The text to be displayed
3053 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3055 _elm_entry_text_set(obj, NULL, entry);
3059 * This appends @p entry to the text of the entry.
3061 * @param obj The entry object
3062 * @param entry The text to be displayed
3067 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3070 ELM_CHECK_WIDTYPE(obj, widtype);
3071 Widget_Data *wd = elm_widget_data_get(obj);
3073 if (!entry) entry = "";
3074 wd->changed = EINA_TRUE;
3076 len = strlen(entry);
3077 if (wd->append_text_left)
3080 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3086 wd->append_text_left = tmpbuf;
3087 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3088 wd->append_text_len += len;
3092 /* FIXME: Add chunked appending here (like in entry_set) */
3093 edje_object_part_text_append(wd->ent, "elm.text", entry);
3098 * This returns the text currently shown in object @p entry.
3099 * See also elm_entry_entry_set().
3101 * @param obj The entry object
3102 * @return The currently displayed text or NULL on failure
3107 elm_entry_entry_get(const Evas_Object *obj)
3109 return _elm_entry_text_get(obj, NULL);
3113 * This returns EINA_TRUE if the entry is empty/there was an error
3114 * and EINA_FALSE if it is not empty.
3116 * @param obj The entry object
3117 * @return If the entry is empty or not.
3122 elm_entry_is_empty(const Evas_Object *obj)
3124 /* FIXME: until there's support for that in textblock, we just check
3125 * to see if the there is text or not. */
3126 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3127 Widget_Data *wd = elm_widget_data_get(obj);
3128 const Evas_Object *tb;
3129 //Evas_Textblock_Cursor *cur;
3131 if (!wd) return EINA_TRUE;
3134 /* It's a hack until we get the support suggested above.
3135 * We just create a cursor, point it to the begining, and then
3136 * try to advance it, if it can advance, the tb is not empty,
3137 * otherwise it is. */
3138 tb = edje_object_part_object_get(wd->ent, "elm.text");
3139 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3140 actually, ok for the time being, thsese hackish stuff will be removed
3141 once evas 1.0 is out*/
3142 evas_textblock_cursor_pos_set(cur, 0);
3143 ret = evas_textblock_cursor_char_next(cur);
3144 evas_textblock_cursor_free(cur);
3149 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3150 if (!str) return EINA_TRUE;
3152 ret = (strlen(str) == 0);
3158 * This returns all selected text within the entry.
3160 * @param obj The entry object
3161 * @return The selected text within the entry or NULL on failure
3166 elm_entry_selection_get(const Evas_Object *obj)
3168 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3169 Widget_Data *wd = elm_widget_data_get(obj);
3170 if (!wd) return NULL;
3171 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3175 * This inserts text in @p entry where the current cursor position.
3177 * This inserts text at the cursor position is as if it was typed
3178 * by the user (note this also allows markup which a user
3179 * can't just "type" as it would be converted to escaped text, so this
3180 * call can be used to insert things like emoticon items or bold push/pop
3181 * tags, other font and color change tags etc.)
3183 * @param obj The entry object
3184 * @param entry The text to insert
3189 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3191 ELM_CHECK_WIDTYPE(obj, widtype);
3192 Widget_Data *wd = elm_widget_data_get(obj);
3194 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3196 #ifdef HAVE_ELEMENTARY_X
3197 if (cnpwidgetdata == obj)
3198 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3201 wd->changed = EINA_TRUE;
3206 * This enables word line wrapping in the entry object. It is the opposite
3207 * of elm_entry_single_line_set(). Additionally, setting this disables
3208 * character line wrapping.
3210 * @param obj The entry object
3211 * @param wrap If true, the entry will be wrapped once it reaches the end
3212 * of the object. Wrapping will occur at the end of the word before the end of the
3218 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3220 ELM_CHECK_WIDTYPE(obj, widtype);
3221 Widget_Data *wd = elm_widget_data_get(obj);
3223 if (wd->linewrap == wrap) return;
3225 wd->linewrap = wrap;
3230 * Get the wrapping behavior of the entry.
3231 * See also elm_entry_line_wrap_set().
3233 * @param obj The entry object
3239 elm_entry_line_wrap_get(const Evas_Object *obj)
3241 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3242 Widget_Data *wd = elm_widget_data_get(obj);
3243 if (!wd) return EINA_FALSE;
3244 return wd->linewrap;
3248 * This sets the editable attribute of the entry.
3250 * @param obj The entry object
3251 * @param editable If true, the entry will be editable by the user.
3252 * If false, it will be set to the disabled state.
3257 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3259 ELM_CHECK_WIDTYPE(obj, widtype);
3260 Widget_Data *wd = elm_widget_data_get(obj);
3262 if (wd->editable == editable) return;
3263 wd->editable = editable;
3266 #ifdef HAVE_ELEMENTARY_X
3268 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3270 elm_drop_target_del(obj);
3275 * This gets the editable attribute of the entry.
3276 * See also elm_entry_editable_set().
3278 * @param obj The entry object
3279 * @return If true, the entry is editable by the user.
3280 * If false, it is not editable by the user
3285 elm_entry_editable_get(const Evas_Object *obj)
3287 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3288 Widget_Data *wd = elm_widget_data_get(obj);
3289 if (!wd) return EINA_FALSE;
3290 return wd->editable;
3294 * This drops any existing text selection within the entry.
3296 * @param obj The entry object
3301 elm_entry_select_none(Evas_Object *obj)
3303 ELM_CHECK_WIDTYPE(obj, widtype);
3304 Widget_Data *wd = elm_widget_data_get(obj);
3308 wd->selmode = EINA_FALSE;
3309 if (!_elm_config->desktop_entry)
3310 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3311 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3313 wd->have_selection = EINA_FALSE;
3314 edje_object_part_text_select_none(wd->ent, "elm.text");
3318 * This selects all text within the entry.
3320 * @param obj The entry object
3325 elm_entry_select_all(Evas_Object *obj)
3327 ELM_CHECK_WIDTYPE(obj, widtype);
3328 Widget_Data *wd = elm_widget_data_get(obj);
3332 wd->selmode = EINA_FALSE;
3333 if (!_elm_config->desktop_entry)
3334 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3335 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3337 wd->have_selection = EINA_TRUE;
3338 edje_object_part_text_select_all(wd->ent, "elm.text");
3342 * This function returns the geometry of the cursor.
3344 * It's useful if you want to draw something on the cursor (or where it is),
3345 * or for example in the case of scrolled entry where you want to show the
3348 * @param obj The entry object
3349 * @param x returned geometry
3350 * @param y returned geometry
3351 * @param w returned geometry
3352 * @param h returned geometry
3353 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3358 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3360 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3361 Widget_Data *wd = elm_widget_data_get(obj);
3362 if (!wd) return EINA_FALSE;
3363 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3368 * This moves the cursor one place to the right within the entry.
3370 * @param obj The entry object
3371 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3376 elm_entry_cursor_next(Evas_Object *obj)
3378 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3379 Widget_Data *wd = elm_widget_data_get(obj);
3380 if (!wd) return EINA_FALSE;
3381 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3385 * This moves the cursor one place to the left within the entry.
3387 * @param obj The entry object
3388 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3393 elm_entry_cursor_prev(Evas_Object *obj)
3395 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3396 Widget_Data *wd = elm_widget_data_get(obj);
3397 if (!wd) return EINA_FALSE;
3398 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3402 * This moves the cursor one line up within the entry.
3404 * @param obj The entry object
3405 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3410 elm_entry_cursor_up(Evas_Object *obj)
3412 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3413 Widget_Data *wd = elm_widget_data_get(obj);
3414 if (!wd) return EINA_FALSE;
3415 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3419 * This moves the cursor one line down within the entry.
3421 * @param obj The entry object
3422 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3427 elm_entry_cursor_down(Evas_Object *obj)
3429 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3430 Widget_Data *wd = elm_widget_data_get(obj);
3431 if (!wd) return EINA_FALSE;
3432 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3436 * This moves the cursor to the beginning of the entry.
3438 * @param obj The entry object
3443 elm_entry_cursor_begin_set(Evas_Object *obj)
3445 ELM_CHECK_WIDTYPE(obj, widtype);
3446 Widget_Data *wd = elm_widget_data_get(obj);
3448 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3452 * This moves the cursor to the end of the entry.
3454 * @param obj The entry object
3459 elm_entry_cursor_end_set(Evas_Object *obj)
3461 ELM_CHECK_WIDTYPE(obj, widtype);
3462 Widget_Data *wd = elm_widget_data_get(obj);
3465 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3468 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3469 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3474 * This moves the cursor to the beginning of the current line.
3476 * @param obj The entry object
3481 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3483 ELM_CHECK_WIDTYPE(obj, widtype);
3484 Widget_Data *wd = elm_widget_data_get(obj);
3486 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3490 * This moves the cursor to the end of the current line.
3492 * @param obj The entry object
3497 elm_entry_cursor_line_end_set(Evas_Object *obj)
3499 ELM_CHECK_WIDTYPE(obj, widtype);
3500 Widget_Data *wd = elm_widget_data_get(obj);
3502 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3506 * This begins a selection within the entry as though
3507 * the user were holding down the mouse button to make a selection.
3509 * @param obj The entry object
3514 elm_entry_cursor_selection_begin(Evas_Object *obj)
3516 ELM_CHECK_WIDTYPE(obj, widtype);
3517 Widget_Data *wd = elm_widget_data_get(obj);
3519 edje_object_part_text_select_begin(wd->ent, "elm.text");
3523 * This ends a selection within the entry as though
3524 * the user had just released the mouse button while making a selection.
3526 * @param obj The entry object
3531 elm_entry_cursor_selection_end(Evas_Object *obj)
3533 ELM_CHECK_WIDTYPE(obj, widtype);
3534 Widget_Data *wd = elm_widget_data_get(obj);
3536 edje_object_part_text_select_extend(wd->ent, "elm.text");
3540 * TODO: fill this in
3542 * @param obj The entry object
3543 * @return TODO: fill this in
3548 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3550 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3551 Widget_Data *wd = elm_widget_data_get(obj);
3552 if (!wd) return EINA_FALSE;
3553 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3557 * This returns whether the cursor is visible.
3559 * @param obj The entry object
3560 * @return If true, the cursor is visible.
3565 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3567 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3568 Widget_Data *wd = elm_widget_data_get(obj);
3569 if (!wd) return EINA_FALSE;
3570 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3574 * TODO: fill this in
3576 * @param obj The entry object
3577 * @return TODO: fill this in
3582 elm_entry_cursor_content_get(const Evas_Object *obj)
3584 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3585 Widget_Data *wd = elm_widget_data_get(obj);
3586 if (!wd) return NULL;
3587 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3591 * Sets the cursor position in the entry to the given value
3593 * @param obj The entry object
3594 * @param pos The position of the cursor
3599 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3601 ELM_CHECK_WIDTYPE(obj, widtype);
3602 Widget_Data *wd = elm_widget_data_get(obj);
3604 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3605 edje_object_message_signal_process(wd->ent);
3609 * Retrieves the current position of the cursor in the entry
3611 * @param obj The entry object
3612 * @return The cursor position
3617 elm_entry_cursor_pos_get(const Evas_Object *obj)
3619 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3620 Widget_Data *wd = elm_widget_data_get(obj);
3622 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3626 * This executes a "cut" action on the selected text in the entry.
3628 * @param obj The entry object
3633 elm_entry_selection_cut(Evas_Object *obj)
3635 ELM_CHECK_WIDTYPE(obj, widtype);
3636 Widget_Data *wd = elm_widget_data_get(obj);
3638 _cut(obj, NULL, NULL);
3642 * This executes a "copy" action on the selected text in the entry.
3644 * @param obj The entry object
3649 elm_entry_selection_copy(Evas_Object *obj)
3651 ELM_CHECK_WIDTYPE(obj, widtype);
3652 Widget_Data *wd = elm_widget_data_get(obj);
3654 _copy(obj, NULL, NULL);
3658 * This executes a "paste" action in the entry.
3660 * @param obj The entry object
3665 elm_entry_selection_paste(Evas_Object *obj)
3667 ELM_CHECK_WIDTYPE(obj, widtype);
3668 Widget_Data *wd = elm_widget_data_get(obj);
3670 _paste(obj, NULL, NULL);
3674 * This clears and frees the items in a entry's contextual (right click) menu.
3676 * @param obj The entry object
3681 elm_entry_context_menu_clear(Evas_Object *obj)
3683 ELM_CHECK_WIDTYPE(obj, widtype);
3684 Widget_Data *wd = elm_widget_data_get(obj);
3685 Elm_Entry_Context_Menu_Item *it;
3687 EINA_LIST_FREE(wd->items, it)
3689 eina_stringshare_del(it->label);
3690 eina_stringshare_del(it->icon_file);
3691 eina_stringshare_del(it->icon_group);
3697 * This adds an item to the entry's contextual menu.
3699 * @param obj The entry object
3700 * @param label The item's text label
3701 * @param icon_file The item's icon file
3702 * @param icon_type The item's icon type
3703 * @param func The callback to execute when the item is clicked
3704 * @param data The data to associate with the item for related functions
3709 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)
3711 ELM_CHECK_WIDTYPE(obj, widtype);
3712 Widget_Data *wd = elm_widget_data_get(obj);
3713 Elm_Entry_Context_Menu_Item *it;
3715 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3717 wd->items = eina_list_append(wd->items, it);
3719 it->label = eina_stringshare_add(label);
3720 it->icon_file = eina_stringshare_add(icon_file);
3721 it->icon_type = icon_type;
3723 it->data = (void *)data;
3727 * This disables the entry's contextual (right click) menu.
3729 * @param obj The entry object
3730 * @param disabled If true, the menu is disabled
3735 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3737 ELM_CHECK_WIDTYPE(obj, widtype);
3738 Widget_Data *wd = elm_widget_data_get(obj);
3740 if (wd->context_menu == !disabled) return;
3741 wd->context_menu = !disabled;
3745 * This returns whether the entry's contextual (right click) menu is disabled.
3747 * @param obj The entry object
3748 * @return If true, the menu is disabled
3753 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3755 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3756 Widget_Data *wd = elm_widget_data_get(obj);
3757 if (!wd) return EINA_FALSE;
3758 return !wd->context_menu;
3762 * This appends a custom item provider to the list for that entry
3764 * This appends the given callback. The list is walked from beginning to end
3765 * with each function called given the item href string in the text. If the
3766 * function returns an object handle other than NULL (it should create an
3767 * and object to do this), then this object is used to replace that item. If
3768 * not the next provider is called until one provides an item object, or the
3769 * default provider in entry does.
3771 * @param obj The entry object
3772 * @param func The function called to provide the item object
3773 * @param data The data passed to @p func
3778 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3780 ELM_CHECK_WIDTYPE(obj, widtype);
3781 Widget_Data *wd = elm_widget_data_get(obj);
3783 EINA_SAFETY_ON_NULL_RETURN(func);
3784 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3788 wd->item_providers = eina_list_append(wd->item_providers, ip);
3792 * This prepends a custom item provider to the list for that entry
3794 * This prepends the given callback. See elm_entry_item_provider_append() for
3797 * @param obj The entry object
3798 * @param func The function called to provide the item object
3799 * @param data The data passed to @p func
3804 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3806 ELM_CHECK_WIDTYPE(obj, widtype);
3807 Widget_Data *wd = elm_widget_data_get(obj);
3809 EINA_SAFETY_ON_NULL_RETURN(func);
3810 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3814 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3818 * This removes a custom item provider to the list for that entry
3820 * This removes the given callback. See elm_entry_item_provider_append() for
3823 * @param obj The entry object
3824 * @param func The function called to provide the item object
3825 * @param data The data passed to @p func
3830 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3832 ELM_CHECK_WIDTYPE(obj, widtype);
3833 Widget_Data *wd = elm_widget_data_get(obj);
3835 Elm_Entry_Item_Provider *ip;
3837 EINA_SAFETY_ON_NULL_RETURN(func);
3838 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3840 if ((ip->func == func) && ((!data) || (ip->data == data)))
3842 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3850 * Append a filter function for text inserted in the entry
3852 * Append the given callback to the list. This functions will be called
3853 * whenever any text is inserted into the entry, with the text to be inserted
3854 * as a parameter. The callback function is free to alter the text in any way
3855 * it wants, but it must remember to free the given pointer and update it.
3856 * If the new text is to be discarded, the function can free it and set it text
3857 * parameter to NULL. This will also prevent any following filters from being
3860 * @param obj The entry object
3861 * @param func The function to use as text filter
3862 * @param data User data to pass to @p func
3867 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3870 Elm_Entry_Text_Filter *tf;
3871 ELM_CHECK_WIDTYPE(obj, widtype);
3873 wd = elm_widget_data_get(obj);
3875 EINA_SAFETY_ON_NULL_RETURN(func);
3877 tf = _filter_new(func, data);
3880 wd->text_filters = eina_list_append(wd->text_filters, tf);
3884 * Prepend a filter function for text insdrted in the entry
3886 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3887 * for more information
3889 * @param obj The entry object
3890 * @param func The function to use as text filter
3891 * @param data User data to pass to @p func
3896 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3899 Elm_Entry_Text_Filter *tf;
3900 ELM_CHECK_WIDTYPE(obj, widtype);
3902 wd = elm_widget_data_get(obj);
3904 EINA_SAFETY_ON_NULL_RETURN(func);
3906 tf = _filter_new(func, data);
3909 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3913 * Remove a filter from the list
3915 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3916 * for more information.
3918 * @param obj The entry object
3919 * @param func The filter function to remove
3920 * @param data The user data passed when adding the function
3925 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3929 Elm_Entry_Text_Filter *tf;
3930 ELM_CHECK_WIDTYPE(obj, widtype);
3932 wd = elm_widget_data_get(obj);
3934 EINA_SAFETY_ON_NULL_RETURN(func);
3936 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3938 if ((tf->func == func) && ((!data) || (tf->data == data)))
3940 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3948 * This converts a markup (HTML-like) string into UTF-8.
3949 * Returning string is obtained with malloc.
3950 * After use the returned string, it should be freed.
3952 * @param s The string (in markup) to be converted
3953 * @return The converted string (in UTF-8). It should be freed.
3958 elm_entry_markup_to_utf8(const char *s)
3960 char *ss = _elm_util_mkup_to_text(s);
3961 if (!ss) ss = strdup("");
3966 * This converts a UTF-8 string into markup (HTML-like).
3967 * Returning string is obtained with malloc.
3968 * After use the returned string, it should be freed.
3970 * @param s The string (in UTF-8) to be converted
3971 * @return The converted string (in markup). It should be freed.
3976 elm_entry_utf8_to_markup(const char *s)
3978 char *ss = _elm_util_text_to_mkup(s);
3979 if (!ss) ss = strdup("");
3984 * Filter inserted text based on user defined character and byte limits
3986 * Add this filter to an entry to limit the characters that it will accept
3987 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
3988 * The funtion works on the UTF-8 representation of the string, converting
3989 * it from the set markup, thus not accounting for any format in it.
3991 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
3992 * it as data when setting the filter. In it it's possible to set limits
3993 * by character count or bytes (any of them is disabled if 0), and both can
3994 * be set at the same time. In that case, it first checks for characters,
3997 * The function will cut the inserted text in order to allow only the first
3998 * number of characters that are still allowed. The cut is made in
3999 * characters, even when limiting by bytes, in order to always contain
4000 * valid ones and avoid half unicode characters making it in.
4005 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4007 Elm_Entry_Filter_Limit_Size *lim = data;
4010 const char *(*text_get)(const Evas_Object *);
4011 const char *widget_type;
4013 EINA_SAFETY_ON_NULL_RETURN(data);
4014 EINA_SAFETY_ON_NULL_RETURN(entry);
4015 EINA_SAFETY_ON_NULL_RETURN(text);
4017 /* hack. I don't want to copy the entire function to work with
4019 widget_type = elm_widget_type_get(entry);
4020 if (!strcmp(widget_type, "entry"))
4021 text_get = elm_entry_entry_get;
4025 current = elm_entry_markup_to_utf8(text_get(entry));
4027 if (lim->max_char_count > 0)
4029 len = evas_string_char_len_get(current);
4030 if (len >= lim->max_char_count)
4032 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4038 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4039 if ((len + newlen) > lim->max_char_count)
4040 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4042 else if (lim->max_byte_count > 0)
4044 len = strlen(current);
4045 if (len >= lim->max_byte_count)
4047 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4053 newlen = strlen(elm_entry_markup_to_utf8(*text));
4054 if ((len + newlen) > lim->max_byte_count)
4055 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4061 * Filter inserted text based on accepted or rejected sets of characters
4063 * Add this filter to an entry to restrict the set of accepted characters
4064 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4065 * This structure contains both accepted and rejected sets, but they are
4066 * mutually exclusive. If accepted is set, it will be used, otherwise it
4067 * goes on to the rejected set.
4070 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4072 Elm_Entry_Filter_Accept_Set *as = data;
4076 int read_idx, last_read_idx = 0, read_char;
4078 EINA_SAFETY_ON_NULL_RETURN(data);
4079 EINA_SAFETY_ON_NULL_RETURN(text);
4081 if ((!as->accepted) && (!as->rejected))
4087 goes_in = EINA_TRUE;
4092 goes_in = EINA_FALSE;
4096 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4099 int cmp_idx, cmp_char;
4100 Eina_Bool in_set = EINA_FALSE;
4102 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4105 if (read_char == cmp_char)
4110 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4112 if (in_set == goes_in)
4114 int size = read_idx - last_read_idx;
4115 const char *src = (*text) + last_read_idx;
4117 memcpy(insert, *text + last_read_idx, size);
4120 last_read_idx = read_idx;
4121 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4127 * This sets the file (and implicitly loads it) for the text to display and
4128 * then edit. All changes are written back to the file after a short delay if
4129 * the entry object is set to autosave.
4131 * @param obj The entry object
4132 * @param file The path to the file to load and save
4133 * @param format The file format
4138 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4140 ELM_CHECK_WIDTYPE(obj, widtype);
4141 Widget_Data *wd = elm_widget_data_get(obj);
4143 if (wd->delay_write)
4145 ecore_timer_del(wd->delay_write);
4146 wd->delay_write = NULL;
4148 if (wd->autosave) _save(obj);
4149 eina_stringshare_replace(&wd->file, file);
4150 wd->format = format;
4155 * Gets the file to load and save and the file format
4157 * @param obj The entry object
4158 * @param file The path to the file to load and save
4159 * @param format The file format
4164 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4166 ELM_CHECK_WIDTYPE(obj, widtype);
4167 Widget_Data *wd = elm_widget_data_get(obj);
4169 if (file) *file = wd->file;
4170 if (format) *format = wd->format;
4174 * This function writes any changes made to the file set with
4175 * elm_entry_file_set()
4177 * @param obj The entry object
4182 elm_entry_file_save(Evas_Object *obj)
4184 ELM_CHECK_WIDTYPE(obj, widtype);
4185 Widget_Data *wd = elm_widget_data_get(obj);
4187 if (wd->delay_write)
4189 ecore_timer_del(wd->delay_write);
4190 wd->delay_write = NULL;
4193 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4197 * This sets the entry object to 'autosave' the loaded text file or not.
4199 * @param obj The entry object
4200 * @param autosave Autosave the loaded file or not
4205 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4207 ELM_CHECK_WIDTYPE(obj, widtype);
4208 Widget_Data *wd = elm_widget_data_get(obj);
4210 wd->autosave = !!autosave;
4214 * This gets the entry object's 'autosave' status.
4216 * @param obj The entry object
4217 * @return Autosave the loaded file or not
4222 elm_entry_autosave_get(const Evas_Object *obj)
4224 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4225 Widget_Data *wd = elm_widget_data_get(obj);
4226 if (!wd) return EINA_FALSE;
4227 return wd->autosave;
4231 * Control pasting of text and images for the widget.
4233 * Normally the entry allows both text and images to be pasted. By setting
4234 * textonly to be true, this prevents images from being pasted.
4236 * Note this only changes the behaviour of text.
4238 * @param obj The entry object
4239 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4244 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4246 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4247 ELM_CHECK_WIDTYPE(obj, widtype);
4248 Widget_Data *wd = elm_widget_data_get(obj);
4250 textonly = !!textonly;
4251 if (wd->textonly == textonly) return;
4252 wd->textonly = !!textonly;
4253 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4254 #ifdef HAVE_ELEMENTARY_X
4255 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4260 * Getting elm_entry text paste/drop mode.
4262 * In textonly mode, only text may be pasted or dropped into the widget.
4264 * @param obj The entry object
4265 * @return If the widget only accepts text from pastes.
4270 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4272 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4273 Widget_Data *wd = elm_widget_data_get(obj);
4274 if (!wd) return EINA_FALSE;
4275 return wd->textonly;
4279 * Enable or disable scrolling in entry
4281 * Normally the entry is not scrollable unless you enable it with this call.
4283 * @param obj The entry object
4284 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4289 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4291 ELM_CHECK_WIDTYPE(obj, widtype);
4292 Widget_Data *wd = elm_widget_data_get(obj);
4295 if (wd->scroll == scroll) return;
4296 wd->scroll = scroll;
4299 elm_widget_sub_object_del(obj, wd->scroller);
4300 elm_widget_resize_object_set(obj, wd->scroller);
4301 elm_widget_sub_object_add(obj, wd->ent);
4302 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4303 evas_object_show(wd->scroller);
4304 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4305 if (wd->single_line)
4307 elm_smart_scroller_policy_set(wd->scroller,
4308 ELM_SMART_SCROLLER_POLICY_OFF,
4309 ELM_SMART_SCROLLER_POLICY_OFF);
4310 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4314 const Elm_Scroller_Policy map[3] =
4316 ELM_SMART_SCROLLER_POLICY_AUTO,
4317 ELM_SMART_SCROLLER_POLICY_ON,
4318 ELM_SMART_SCROLLER_POLICY_OFF
4320 elm_smart_scroller_policy_set(wd->scroller,
4323 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4328 elm_smart_scroller_child_set(wd->scroller, NULL);
4329 elm_widget_sub_object_del(obj, wd->ent);
4330 elm_widget_resize_object_set(obj, wd->ent);
4331 evas_object_smart_member_add(wd->scroller, obj);
4332 elm_widget_sub_object_add(obj, wd->scroller);
4333 evas_object_hide(wd->scroller);
4334 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4341 * Get the scrollable state of the entry
4343 * Normally the entry is not scrollable. This gets the scrollable state
4344 * of the entry. See elm_entry_scrollable_set() for more information.
4346 * @param obj The entry object
4347 * @return The scrollable state
4352 elm_entry_scrollable_get(const Evas_Object *obj)
4354 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4355 Widget_Data *wd = elm_widget_data_get(obj);
4356 if (!wd) return EINA_FALSE;
4361 * This sets a widget to be displayed to the left of a scrolled entry.
4363 * @param obj The scrolled entry object
4364 * @param icon The widget to display on the left side of the scrolled
4367 * @note A previously set widget will be destroyed.
4368 * @note If the object being set does not have minimum size hints set,
4369 * it won't get properly displayed.
4372 * @see elm_entry_end_set
4375 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4377 ELM_CHECK_WIDTYPE(obj, widtype);
4378 Widget_Data *wd = elm_widget_data_get(obj);
4381 EINA_SAFETY_ON_NULL_RETURN(icon);
4382 if (wd->icon == icon) return;
4383 if (wd->icon) evas_object_del(wd->icon);
4385 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4387 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4388 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4393 * Gets the leftmost widget of the scrolled entry. This object is
4394 * owned by the scrolled entry and should not be modified.
4396 * @param obj The scrolled entry object
4397 * @return the left widget inside the scroller
4402 elm_entry_icon_get(const Evas_Object *obj)
4404 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4405 Widget_Data *wd = elm_widget_data_get(obj);
4406 if (!wd) return NULL;
4411 * Unset the leftmost widget of the scrolled entry, unparenting and
4414 * @param obj The scrolled entry object
4415 * @return the previously set icon sub-object of this entry, on
4418 * @see elm_entry_icon_set()
4423 elm_entry_icon_unset(Evas_Object *obj)
4425 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4426 Widget_Data *wd = elm_widget_data_get(obj);
4427 Evas_Object *ret = NULL;
4428 if (!wd) return NULL;
4431 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4432 if (!edje) return NULL;
4434 edje_object_part_unswallow(edje, wd->icon);
4435 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4443 * Sets the visibility of the left-side widget of the scrolled entry,
4444 * set by @elm_entry_icon_set().
4446 * @param obj The scrolled entry object
4447 * @param setting EINA_TRUE if the object should be displayed,
4448 * EINA_FALSE if not.
4453 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4455 ELM_CHECK_WIDTYPE(obj, widtype);
4456 Widget_Data *wd = elm_widget_data_get(obj);
4457 if ((!wd) || (!wd->icon)) return;
4459 evas_object_hide(wd->icon);
4461 evas_object_show(wd->icon);
4466 * This sets a widget to be displayed to the end of a scrolled entry.
4468 * @param obj The scrolled entry object
4469 * @param end The widget to display on the right side of the scrolled
4472 * @note A previously set widget will be destroyed.
4473 * @note If the object being set does not have minimum size hints set,
4474 * it won't get properly displayed.
4477 * @see elm_entry_icon_set
4480 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4482 ELM_CHECK_WIDTYPE(obj, widtype);
4483 Widget_Data *wd = elm_widget_data_get(obj);
4486 EINA_SAFETY_ON_NULL_RETURN(end);
4487 if (wd->end == end) return;
4488 if (wd->end) evas_object_del(wd->end);
4490 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4492 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4493 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4498 * Gets the endmost widget of the scrolled entry. This object is owned
4499 * by the scrolled entry and should not be modified.
4501 * @param obj The scrolled entry object
4502 * @return the right widget inside the scroller
4507 elm_entry_end_get(const Evas_Object *obj)
4509 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4510 Widget_Data *wd = elm_widget_data_get(obj);
4511 if (!wd) return NULL;
4516 * Unset the endmost widget of the scrolled entry, unparenting and
4519 * @param obj The scrolled entry object
4520 * @return the previously set icon sub-object of this entry, on
4523 * @see elm_entry_icon_set()
4528 elm_entry_end_unset(Evas_Object *obj)
4530 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4531 Widget_Data *wd = elm_widget_data_get(obj);
4532 Evas_Object *ret = NULL;
4533 if (!wd) return NULL;
4536 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4537 if (!edje) return NULL;
4539 edje_object_part_unswallow(edje, wd->end);
4540 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4548 * Sets the visibility of the end widget of the scrolled entry, set by
4549 * @elm_entry_end_set().
4551 * @param obj The scrolled entry object
4552 * @param setting EINA_TRUE if the object should be displayed,
4553 * EINA_FALSE if not.
4558 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4560 ELM_CHECK_WIDTYPE(obj, widtype);
4561 Widget_Data *wd = elm_widget_data_get(obj);
4562 if ((!wd) || (!wd->end)) return;
4564 evas_object_hide(wd->end);
4566 evas_object_show(wd->end);
4571 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4573 * @param obj The scrolled entry object
4574 * @param h The horizontal scrollbar policy to apply
4575 * @param v The vertical scrollbar policy to apply
4580 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4582 ELM_CHECK_WIDTYPE(obj, widtype);
4583 Widget_Data *wd = elm_widget_data_get(obj);
4584 const Elm_Scroller_Policy map[3] =
4586 ELM_SMART_SCROLLER_POLICY_AUTO,
4587 ELM_SMART_SCROLLER_POLICY_ON,
4588 ELM_SMART_SCROLLER_POLICY_OFF
4593 elm_smart_scroller_policy_set(wd->scroller,
4599 * This enables/disables bouncing within the entry.
4601 * @param obj The scrolled entry object
4602 * @param h The horizontal bounce state
4603 * @param v The vertical bounce state
4608 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4610 ELM_CHECK_WIDTYPE(obj, widtype);
4611 Widget_Data *wd = elm_widget_data_get(obj);
4613 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4617 * Get the bounce mode
4619 * @param obj The Entry object
4620 * @param h_bounce Allow bounce horizontally
4621 * @param v_bounce Allow bounce vertically
4626 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4628 ELM_CHECK_WIDTYPE(obj, widtype);
4629 Widget_Data *wd = elm_widget_data_get(obj);
4631 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4634 EINA_DEPRECATED EAPI void
4635 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4637 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);
4641 * Set background color of the entry
4643 * @param obj The entry object
4644 * @param r Red property background color of The entry object
4645 * @param g Green property background color of The entry object
4646 * @param b Blue property background color of The entry object
4647 * @param a Alpha property background alpha of The entry object
4651 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4653 ELM_CHECK_WIDTYPE(obj, widtype);
4654 Widget_Data *wd = elm_widget_data_get(obj);
4655 evas_object_color_set(wd->bg, r, g, b, a);
4657 if (wd->bgcolor == EINA_FALSE)
4660 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4665 * Set whether entry should support auto capitalization
4667 * @param obj The entry object
4668 * @param on If true, entry suports auto capitalization.
4673 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4675 ELM_CHECK_WIDTYPE(obj, widtype);
4676 Widget_Data *wd = elm_widget_data_get(obj);
4680 wd->autocapital = EINA_FALSE;
4682 wd->autocapital = autocap;
4684 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4685 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4686 wd->autocapital = EINA_FALSE;
4688 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
4692 * Set whether entry should support auto period
4694 * @param obj The entry object
4695 * @param on If true, entry suports auto period.
4700 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4702 ELM_CHECK_WIDTYPE(obj, widtype);
4703 Widget_Data *wd = elm_widget_data_get(obj);
4707 wd->autoperiod = EINA_FALSE;
4709 wd->autoperiod = autoperiod;
4711 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4712 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4713 wd->autoperiod = EINA_FALSE;
4715 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4719 * Set whether entry should enable the return key on soft keyboard automatically
4721 * @param obj The entry object
4722 * @param on If true, entry enables the return key on soft keyboard automatically.
4727 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
4729 ELM_CHECK_WIDTYPE(obj, widtype);
4730 Widget_Data *wd = elm_widget_data_get(obj);
4733 wd->autoreturnkey = on;
4734 _check_enable_returnkey(obj);
4738 * This sets the attribute to show the input panel automatically.
4740 * @param obj The entry object
4741 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4746 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4748 ELM_CHECK_WIDTYPE(obj, widtype);
4749 Widget_Data *wd = elm_widget_data_get(obj);
4752 wd->input_panel_enable = enabled;
4753 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4757 * Set the input panel layout of the entry
4759 * @param obj The entry object
4760 * @param layout the layout to set
4765 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4767 ELM_CHECK_WIDTYPE(obj, widtype);
4768 Widget_Data *wd = elm_widget_data_get(obj);
4771 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4774 wd->input_panel_layout = layout;
4776 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4780 * Get the input method context in the entry widget
4782 * @param obj The entry object
4783 * @return The input method context
4787 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
4789 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4790 Widget_Data *wd = elm_widget_data_get(obj);
4791 if (!wd || !wd->ent) return NULL;
4793 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4797 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
4799 Widget_Data *wd = elm_widget_data_get(obj);
4804 Evas_Coord max_w = 9999, max_h = 9999;
4805 const char* key_data = NULL;
4807 wd->matchlist_threshold = 1;
4808 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
4809 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
4810 elm_hover_target_set(wd->hover, obj);
4811 elm_object_style_set(wd->hover, "matchlist");
4813 wd->layout = elm_layout_add(wd->hover);
4814 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
4815 wd->list = elm_list_add(wd->layout);
4816 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
4817 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
4818 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
4819 elm_object_style_set(wd->list, "matchlist");
4821 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
4822 if (key_data) max_w = atoi(key_data);
4823 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
4824 if (key_data) max_h = atoi(key_data);
4826 elm_list_go(wd->list);
4827 evas_object_size_hint_max_set(wd->list, max_w, max_h);
4828 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
4829 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
4830 elm_hover_content_set(wd->hover, "bottom", wd->layout);
4832 wd->match_list = match_list;
4837 evas_object_del(wd->hover);
4839 wd->match_list = NULL;
4842 wd->matchlist_case_sensitive = case_sensitive;
4846 * Set the magnifier style of the entry
4848 * @param obj The entry object
4849 * @param type the magnifier style to set
4854 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4856 ELM_CHECK_WIDTYPE(obj, widtype);
4857 Widget_Data *wd = elm_widget_data_get(obj);
4860 wd->mgf_type = type;
4861 _magnifier_create(obj);
4865 * Set wrap width of the entry
4867 * @param obj The entry object
4868 * @param w The wrap width in pixels at a minimum where words need to wrap
4872 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
4874 Widget_Data *wd = elm_widget_data_get(obj);
4876 if (wd->wrap_w == w) return;
4882 * get wrap width of the entry
4884 * @param obj The entry object
4885 * @return The wrap width in pixels at a minimum where words need to wrap
4889 elm_entry_wrap_width_get(const Evas_Object *obj)
4891 Widget_Data *wd = elm_widget_data_get(obj);
4897 * Set the font size on the entry object
4899 * @param obj The entry object
4900 * @param size font size
4905 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
4907 ELM_CHECK_WIDTYPE(obj, widtype);
4908 Widget_Data *wd = elm_widget_data_get(obj);
4909 Eina_Strbuf *fontbuf = NULL;
4914 t = eina_stringshare_add(elm_entry_entry_get(obj));
4915 fontbuf = eina_strbuf_new();
4916 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
4918 if (fontsize == 0) removeflag = 1; // remove fontsize tag
4920 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
4922 elm_entry_entry_set(obj, t);
4926 eina_strbuf_free(fontbuf);
4927 eina_stringshare_del(t);
4931 * Set the text color on the entry object
4933 * @param obj The entry object
4934 * @param r Red property background color of The entry object
4935 * @param g Green property background color of The entry object
4936 * @param b Blue property background color of The entry object
4937 * @param a Alpha property background alpha of The entry object
4942 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4944 ELM_CHECK_WIDTYPE(obj, widtype);
4945 Widget_Data *wd = elm_widget_data_get(obj);
4946 Eina_Strbuf *colorbuf = NULL;
4951 t = eina_stringshare_add(elm_entry_entry_get(obj));
4953 if (len <= 0) return;
4954 colorbuf = eina_strbuf_new();
4955 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
4957 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
4959 elm_entry_entry_set(obj, t);
4963 eina_strbuf_free(colorbuf);
4964 eina_stringshare_del(t);
4968 * Set the text align on the entry object
4970 * @param obj The entry object
4971 * @param align align mode
4976 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
4978 ELM_CHECK_WIDTYPE(obj, widtype);
4979 Widget_Data *wd = elm_widget_data_get(obj);
4984 t = eina_stringshare_add(elm_entry_entry_get(obj));
4986 if (len <= 0) return;
4988 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
4989 elm_entry_entry_set(obj, t);
4993 eina_stringshare_del(t);