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)
626 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
628 Widget_Data *wd = elm_widget_data_get(obj);
629 edje_object_mirrored_set(wd->ent, rtl);
633 _theme_hook(Evas_Object *obj)
635 Widget_Data *wd = elm_widget_data_get(obj);
637 Ecore_IMF_Context *ic;
638 _elm_widget_mirrored_reload(obj);
639 _mirrored_set(obj, elm_widget_mirrored_get(obj));
641 t = eina_stringshare_add(elm_entry_entry_get(obj));
642 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
643 if (_elm_config->desktop_entry)
644 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
645 elm_entry_entry_set(obj, t);
646 eina_stringshare_del(t);
647 if (elm_widget_disabled_get(obj))
648 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
649 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
650 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
651 if (elm_widget_focus_get(obj))
652 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
653 edje_object_message_signal_process(wd->ent);
654 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
655 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
656 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
657 elm_widget_style_get(obj));
663 edj = elm_smart_scroller_edje_object_get(wd->scroller);
664 str = edje_object_data_get(edj, "focus_highlight");
665 if ((str) && (!strcmp(str, "on")))
666 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
668 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
673 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", EINA_FALSE);
674 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", EINA_FALSE);
678 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
679 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
682 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
685 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
692 _disable_hook(Evas_Object *obj)
694 Widget_Data *wd = elm_widget_data_get(obj);
696 if (elm_widget_disabled_get(obj))
698 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
699 wd->disabled = EINA_TRUE;
703 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
704 wd->disabled = EINA_FALSE;
709 _recalc_cursor_geometry(Evas_Object *obj)
711 Widget_Data *wd = elm_widget_data_get(obj);
713 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
714 if (!elm_object_focus_get(obj)) return;
715 if (!wd->deferred_recalc_job)
717 Evas_Coord cx, cy, cw, ch;
718 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
722 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
723 wd->cur_changed = EINA_FALSE;
727 wd->deferred_cur = EINA_TRUE;
731 _elm_win_recalc_job(void *data)
733 Widget_Data *wd = elm_widget_data_get(data);
734 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
736 wd->deferred_recalc_job = NULL;
738 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
739 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
740 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
743 /* This is a hack to workaround the way min size hints are treated.
744 * If the minimum width is smaller than the restricted width, it means
745 * the mininmum doesn't matter. */
748 Evas_Coord ominw = -1;
749 evas_object_size_hint_min_get(data, &ominw, NULL);
753 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
756 Evas_Coord vmw = 0, vmh = 0;
758 edje_object_size_min_calc
759 (elm_smart_scroller_edje_object_get(wd->scroller),
763 evas_object_size_hint_min_set(data, vmw, minh + vmh);
764 evas_object_size_hint_max_set(data, -1, minh + vmh);
768 evas_object_size_hint_min_set(data, vmw, vmh);
769 evas_object_size_hint_max_set(data, -1, -1);
776 evas_object_size_hint_min_set(data, minw, minh);
777 evas_object_size_hint_max_set(data, -1, minh);
781 evas_object_size_hint_min_set(data, fw, minh);
782 evas_object_size_hint_max_set(data, -1, -1);
786 if ((wd->deferred_cur) && (elm_object_focus_get(data)))
788 Evas_Coord cx, cy, cw, ch;
789 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
793 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
794 wd->cur_changed = EINA_FALSE;
800 _sizing_eval(Evas_Object *obj)
802 Widget_Data *wd = elm_widget_data_get(obj);
803 Evas_Coord minw = -1, minh = -1;
804 Evas_Coord resw, resh;
807 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
810 if ((resw == wd->lastw) && (!wd->changed)) return;
811 wd->changed = EINA_FALSE;
815 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
817 evas_object_resize(wd->scroller, resw, resh);
818 edje_object_size_min_calc
819 (elm_smart_scroller_edje_object_get(wd->scroller),
821 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
822 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
825 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
827 if ((minw > 0) && (vw < minw)) vw = minw;
828 if (minh > vh) vh = minh;
830 if (wd->single_line) h = vmh + minh;
832 evas_object_resize(wd->ent, vw, vh);
833 evas_object_size_hint_min_get(obj, &w, NULL);
834 evas_object_size_hint_min_set(obj, w, h);
836 evas_object_size_hint_max_set(obj, -1, h);
838 evas_object_size_hint_max_set(obj, -1, -1);
842 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
843 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
848 if (!wd->changed) return;
849 wd->changed = EINA_FALSE;
853 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
855 edje_object_size_min_calc(wd->ent, &minw, &minh);
858 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
860 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
862 if ((minw > 0) && (vw < minw)) vw = minw;
863 if (minh > 0) vh = minh;
865 evas_object_resize(wd->ent, vw, vh);
866 edje_object_size_min_calc
867 (elm_smart_scroller_edje_object_get(wd->scroller),
869 if (wd->single_line) h = vmh + minh;
871 evas_object_size_hint_min_get(obj, &w, NULL);
872 evas_object_size_hint_min_set(obj, w, h);
874 evas_object_size_hint_max_set(obj, -1, h);
876 evas_object_size_hint_max_set(obj, -1, -1);
880 edje_object_size_min_calc(wd->ent, &minw, &minh);
883 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
884 evas_object_size_hint_min_set(obj, minw, minh);
886 evas_object_size_hint_max_set(obj, -1, minh);
888 evas_object_size_hint_max_set(obj, -1, -1);
892 _recalc_cursor_geometry(obj);
896 _check_enable_returnkey(Evas_Object *obj)
898 Widget_Data *wd = elm_widget_data_get(obj);
901 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
904 if (!wd->autoreturnkey) return;
906 if (_entry_length_get(obj) == 0)
908 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
912 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
917 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
919 Widget_Data *wd = elm_widget_data_get(obj);
920 Evas_Object *top = elm_widget_top_get(obj);
922 if (elm_widget_focus_get(obj))
924 printf("[Elm_entry::Focused] obj : %p\n", obj);
925 evas_object_focus_set(wd->ent, EINA_TRUE);
926 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
927 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
928 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
929 _check_enable_returnkey(obj);
930 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
934 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
935 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
936 evas_object_focus_set(wd->ent, EINA_FALSE);
937 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
938 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
940 if ((wd->api) && (wd->api->obj_hidemenu))
942 wd->api->obj_hidemenu(obj);
948 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
950 Widget_Data *wd = elm_widget_data_get(obj);
952 edje_object_signal_emit(wd->ent, emission, source);
954 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
959 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
961 Widget_Data *wd = elm_widget_data_get(obj);
963 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
965 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
966 emission, source, func_cb, data);
970 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
972 Widget_Data *wd = elm_widget_data_get(obj);
973 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
976 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
977 emission, source, func_cb, data);
981 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
983 Widget_Data *wd = elm_widget_data_get(obj);
984 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
988 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
990 Widget_Data *wd = elm_widget_data_get(obj);
992 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
996 _show_region_hook(void *data, Evas_Object *obj)
998 Widget_Data *wd = elm_widget_data_get(data);
999 Evas_Coord x, y, w, h;
1001 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1003 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1007 _hoversel_position(Evas_Object *obj)
1009 Widget_Data *wd = elm_widget_data_get(obj);
1010 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1015 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1024 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1025 &cx, &cy, &cw, &ch);
1026 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1029 cx += (cw - mw) / 2;
1034 cy += (ch - mh) / 2;
1037 evas_object_move(wd->hoversel, x + cx, y + cy);
1038 evas_object_resize(wd->hoversel, cw, ch);
1042 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1044 Widget_Data *wd = elm_widget_data_get(data);
1046 if (wd->hoversel) _hoversel_position(data);
1050 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1052 Widget_Data *wd = elm_widget_data_get(data);
1059 else if (wd->scroll)
1061 Evas_Coord vw = 0, vh = 0;
1063 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1064 if (vw < wd->entmw) vw = wd->entmw;
1065 if (vh < wd->entmh) vh = wd->entmh;
1066 evas_object_resize(wd->ent, vw, vh);
1068 if (wd->hoversel) _hoversel_position(data);
1072 _hover_del(void *data)
1074 Widget_Data *wd = elm_widget_data_get(data);
1079 evas_object_del(wd->hoversel);
1080 wd->hoversel = NULL;
1082 wd->hovdeljob = NULL;
1086 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1088 Widget_Data *wd = elm_widget_data_get(data);
1091 if (wd->hoversel) evas_object_hide(wd->hoversel);
1094 if (!_elm_config->desktop_entry)
1097 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1100 elm_widget_scroll_freeze_pop(data);
1101 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1102 wd->hovdeljob = ecore_job_add(_hover_del, data);
1106 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1108 Widget_Data *wd = elm_widget_data_get(data);
1110 wd->selmode = EINA_TRUE;
1111 edje_object_part_text_select_none(wd->ent, "elm.text");
1112 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1113 edje_object_part_text_select_all(wd->ent, "elm.text");
1114 elm_object_scroll_freeze_pop(data);
1118 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1120 Widget_Data *wd = elm_widget_data_get(data);
1122 wd->selmode = EINA_TRUE;
1123 edje_object_part_text_select_none(wd->ent, "elm.text");
1124 if (!_elm_config->desktop_entry)
1127 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1129 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1130 if (!_elm_config->desktop_entry)
1131 elm_object_scroll_freeze_pop(data);
1132 //elm_widget_scroll_hold_push(data);
1136 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1138 Widget_Data *wd = elm_widget_data_get(data);
1140 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1141 if (wd->sel_notify_handler)
1143 #ifdef HAVE_ELEMENTARY_X
1144 Elm_Sel_Format formats;
1145 wd->selection_asked = EINA_TRUE;
1146 formats = ELM_SEL_FORMAT_MARKUP;
1148 formats |= ELM_SEL_FORMAT_IMAGE;
1149 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1155 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1157 Widget_Data *wd = elm_widget_data_get(obj);
1162 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1163 sel_str = strdup(sel);
1170 char *startTag = NULL;
1171 char *endTag = NULL;
1173 startTag = strstr(sel_str, "<item");
1175 startTag = strstr(sel_str, "</item");
1177 endTag = strstr(startTag, ">");
1180 if (!endTag || startTag > endTag)
1183 size_t sindex = startTag - sel_str;
1184 size_t eindex = endTag - sel_str + 1;
1186 Eina_Strbuf *buf = eina_strbuf_new();
1189 eina_strbuf_append(buf, sel_str);
1190 eina_strbuf_remove(buf, sindex, eindex);
1191 sel_str = eina_strbuf_string_steal(buf);
1192 eina_strbuf_free(buf);
1196 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str);
1197 if (seltype == ELM_SEL_CLIPBOARD)
1198 eina_stringshare_replace(&wd->cut_sel, sel_str);
1203 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1205 Widget_Data *wd = elm_widget_data_get(data);
1208 wd->selmode = EINA_FALSE;
1209 if (!_elm_config->desktop_entry)
1210 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1211 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1212 if (!_elm_config->desktop_entry)
1213 elm_widget_scroll_hold_pop(data);
1214 _store_selection(ELM_SEL_CLIPBOARD, data);
1215 edje_object_part_text_insert(wd->ent, "elm.text", "");
1216 edje_object_part_text_select_none(wd->ent, "elm.text");
1220 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1222 Widget_Data *wd = elm_widget_data_get(data);
1224 wd->selmode = EINA_TRUE;
1225 if (!_elm_config->desktop_entry)
1227 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1228 elm_widget_scroll_hold_pop(data);
1230 _store_selection(ELM_SEL_CLIPBOARD, data);
1234 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1236 Widget_Data *wd = elm_widget_data_get(data);
1238 wd->selmode = EINA_FALSE;
1239 if (!_elm_config->desktop_entry)
1240 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1241 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1242 if (!_elm_config->desktop_entry)
1243 elm_widget_scroll_hold_pop(data);
1244 edje_object_part_text_select_none(wd->ent, "elm.text");
1248 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1250 Widget_Data *wd = elm_widget_data_get(data);
1254 #ifdef HAVE_ELEMENTARY_X
1255 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1257 cnpwidgetdata = data;
1258 elm_cbhm_helper_init(obj);
1259 if (elm_entry_cnp_textonly_get(obj))
1260 elm_cbhm_send_raw_data("show0");
1262 elm_cbhm_send_raw_data("show1");
1268 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1270 Widget_Data *wd = elm_widget_data_get(data);
1272 cnpwidgetdata = data;
1278 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1280 Elm_Entry_Context_Menu_Item *it = data;
1281 Evas_Object *obj2 = it->obj;
1282 if (it->func) it->func(it->data, obj2, NULL);
1286 _menu_press(Evas_Object *obj)
1288 Widget_Data *wd = elm_widget_data_get(obj);
1291 const Elm_Entry_Context_Menu_Item *it;
1293 if ((wd->api) && (wd->api->obj_longpress))
1295 wd->api->obj_longpress(obj);
1297 else if (wd->context_menu)
1299 const char *context_menu_orientation;
1301 if (wd->hoversel) evas_object_del(wd->hoversel);
1302 else elm_widget_scroll_freeze_push(obj);
1303 wd->hoversel = elm_hoversel_add(obj);
1304 context_menu_orientation = edje_object_data_get
1305 (wd->ent, "context_menu_orientation");
1306 if ((context_menu_orientation) &&
1307 (!strcmp(context_menu_orientation, "horizontal")))
1308 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1309 elm_object_style_set(wd->hoversel, "entry");
1310 elm_widget_sub_object_add(obj, wd->hoversel);
1311 elm_object_text_set(wd->hoversel, "Text");
1312 top = elm_widget_top_get(obj);
1313 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1314 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1318 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1320 if (1) // need way to detect if someone has a selection
1323 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1327 if ((!wd->password) && (wd->editable))
1328 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1329 _clipboard_menu, obj);
1336 if (wd->have_selection)
1338 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1341 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1344 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1348 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1349 _clipboard_menu, obj);
1353 EINA_LIST_FOREACH(wd->items, l, it)
1355 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1356 it->icon_type, _item_clicked, it);
1360 _hoversel_position(obj);
1361 evas_object_show(wd->hoversel);
1362 elm_hoversel_hover_begin(wd->hoversel);
1364 if (!_elm_config->desktop_entry)
1366 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1367 edje_object_part_text_select_abort(wd->ent, "elm.text");
1373 _magnifier_hide(void *data)
1375 Widget_Data *wd = elm_widget_data_get(data);
1378 evas_object_hide(wd->mgf_bg);
1379 evas_object_hide(wd->mgf_clip);
1382 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1386 _magnifier_show(void *data)
1388 Widget_Data *wd = elm_widget_data_get(data);
1391 evas_object_show(wd->mgf_bg);
1392 evas_object_show(wd->mgf_clip);
1396 _magnifier_move(void *data)
1398 Widget_Data *wd = elm_widget_data_get(data);
1401 Evas_Coord x, y, w, h, fs;
1402 Evas_Coord cx, cy, cw, ch, ox, oy;
1404 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1408 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1409 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1414 evas_object_geometry_get(data, &x, &y, &w, &h);
1417 fs = elm_finger_size_get();
1419 if ((cy + y) - wd->mgf_height - fs < 0)
1420 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1422 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1423 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1424 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1425 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1429 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);
1433 _magnifier_create(void *data)
1435 Widget_Data *wd = elm_widget_data_get(data);
1436 Evas_Coord x, y, w, h, mw, mh;
1437 const char* key_data = NULL;
1443 evas_object_image_source_unset(wd->mgf_proxy);
1444 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1445 evas_object_hide(wd->mgf_proxy);
1446 evas_object_clip_unset(wd->mgf_proxy);
1447 evas_object_del(wd->mgf_proxy);
1449 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1450 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1453 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1455 evas_object_geometry_get(data, &x, &y, &w, &h);
1457 if ((w <= 0) || (h <= 0))
1460 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1462 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1463 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1464 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1465 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1469 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1470 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1471 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1473 key_data = edje_object_data_get(wd->mgf_bg, "height");
1474 if (key_data) wd->mgf_height = atoi(key_data);
1475 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1476 if (key_data) wd->mgf_scale = atof(key_data);
1478 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1479 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1483 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1484 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1485 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1489 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1490 evas_object_image_source_set(wd->mgf_proxy, data);
1493 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1494 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1495 if ((mw <= 0) || (mh <= 0))
1498 evas_object_resize(wd->mgf_proxy, mw, mh);
1499 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1500 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1501 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1502 evas_object_show(wd->mgf_proxy);
1503 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1505 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1506 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1510 _signal_long_pressed(void *data)
1512 Widget_Data *wd = elm_widget_data_get(data);
1513 if (!wd) return ECORE_CALLBACK_CANCEL;
1515 wd->long_pressed = EINA_TRUE;
1517 _cancel(data, NULL, NULL);
1519 _magnifier_create(data);
1520 _magnifier_move(data);
1521 _magnifier_show(data);
1522 elm_object_scroll_freeze_push(data);
1524 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1525 return ECORE_CALLBACK_CANCEL;
1529 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1531 Widget_Data *wd = elm_widget_data_get(data);
1532 Evas_Event_Mouse_Down *ev = event_info;
1534 if (wd->disabled) return;
1535 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1536 wd->downx = ev->canvas.x;
1537 wd->downy = ev->canvas.y;
1538 wd->long_pressed = EINA_FALSE;
1542 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1544 Widget_Data *wd = elm_widget_data_get(data);
1545 Evas_Event_Mouse_Up *ev = event_info;
1547 if (wd->disabled) return;
1548 if (ev->button == 1)
1550 if (!wd->double_clicked)
1552 if ((wd->api) && (wd->api->obj_mouseup))
1553 wd->api->obj_mouseup(data);
1555 _magnifier_hide(data);
1556 elm_object_scroll_freeze_pop(data);
1558 if (wd->long_pressed)
1561 else if (ev->button == 3)
1569 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1571 Widget_Data *wd = elm_widget_data_get(data);
1572 Evas_Event_Mouse_Move *ev = event_info;
1574 if (wd->disabled) return;
1576 if (ev->buttons == 1)
1578 if (wd->long_pressed)
1580 _magnifier_show(data);
1581 _magnifier_move(data);
1587 _getbase(Evas_Object *obj)
1589 Widget_Data *wd = elm_widget_data_get(obj);
1590 if (!wd) return "base";
1593 if (wd->password) return "base-password";
1596 if (wd->single_line) return "base-single";
1599 switch (wd->linewrap)
1602 return "base-charwrap";
1605 case ELM_WRAP_MIXED:
1606 return "base-mixedwrap";
1609 return "base-nowrap";
1616 if (wd->password) return "base-password";
1619 if (wd->single_line) return "base-single-noedit";
1622 switch (wd->linewrap)
1625 return "base-noedit-charwrap";
1627 return "base-noedit";
1628 case ELM_WRAP_MIXED:
1629 return "base-noedit-mixedwrap";
1632 return "base-nowrap-noedit";
1642 _entry_length_get(Evas_Object *obj)
1645 const char *str = elm_entry_entry_get(obj);
1648 char *plain_str = _elm_util_mkup_to_text(str);
1649 if (!plain_str) return 0;
1651 len = strlen(plain_str);
1657 #ifndef HAVE_STRCASESTR
1658 char* _strcasestr(const char *s, const char *find)
1663 if ((c = *find++) != 0) {
1664 c = tolower((unsigned char) c);
1668 if( (sc = *s++) == 0)
1670 } while ((char)tolower((unsigned char)sc) != c);
1671 } while (strncasecmp(s, find, len) != 0);
1679 _matchlist_show(void *data)
1681 Widget_Data *wd = elm_widget_data_get(data);
1682 const char *text = NULL;
1684 char *str_list = NULL, *str_result = NULL;
1685 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1688 Eina_Bool textfound = EINA_FALSE;
1691 if (elm_widget_disabled_get(data)) return;
1693 wd->matchlist_job = NULL;
1695 if (wd->matchlist_list_clicked)
1697 evas_object_hide(wd->hover);
1698 wd->matchlist_list_clicked = EINA_FALSE;
1701 text = elm_entry_entry_get(data);
1704 textlen = strlen(text);
1706 if (textlen < wd->matchlist_threshold)
1708 evas_object_hide(wd->hover);
1712 evas_object_hide(wd->hover);
1716 elm_list_clear(wd->list);
1717 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1719 if (wd->matchlist_case_sensitive)
1720 str_result = strstr(str_list, text);
1722 #ifdef HAVE_STRCASESTR
1723 str_result = strcasestr(str_list, text);
1725 str_result = _strcasestr(str_list, text);
1730 str_mkup = malloc(strlen(str_list) + 16);
1731 if (str_mkup == NULL) return;
1733 textlen = strlen(str_list) - strlen(str_result);
1734 str_front = malloc(textlen + 1);
1735 if (str_front == NULL) return;
1737 memset(str_front, 0, textlen + 1);
1738 strncpy(str_front, str_list, textlen);
1740 textlen = strlen(text);
1741 str_mid = malloc(textlen + 1);
1742 if (str_mid == NULL) return;
1744 memset(str_mid, 0, textlen + 1);
1745 strncpy(str_mid, str_list + strlen(str_front), textlen);
1747 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1749 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1751 if (str_mkup) free(str_mkup);
1752 if (str_front) free(str_front);
1753 if (str_mid) free(str_mid);
1755 textfound=EINA_TRUE;
1764 elm_list_go(wd->list);
1765 evas_object_show(wd->hover);
1766 evas_object_raise(wd->hover);
1770 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1772 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1773 Widget_Data *wd = elm_widget_data_get(data);
1774 if ((it == NULL) || (wd == NULL))
1777 const char *text = elm_list_item_label_get(it);
1778 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1783 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1784 elm_entry_cursor_end_set(data);
1785 wd->matchlist_list_clicked = EINA_TRUE;
1787 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1790 elm_widget_focus_set(data, EINA_TRUE);
1794 _entry_changed_common_handling(void *data, const char *event)
1796 Widget_Data *wd = elm_widget_data_get(data);
1797 Evas_Coord minw, minh;
1799 wd->changed = EINA_TRUE;
1800 /* Reset the size hints which are no more relevant.
1801 * Keep the height, this is a hack, but doesn't really matter
1802 * cause we'll re-eval in a moment. */
1805 evas_object_size_hint_min_get(data, &minw, &minh);
1806 evas_object_size_hint_min_set(data, minw, minh);
1810 evas_object_size_hint_min_get(data, NULL, &minh);
1811 evas_object_size_hint_min_set(data, -1, minh);
1815 if (wd->text) eina_stringshare_del(wd->text);
1817 if (wd->password_text) eina_stringshare_del(wd->password_text);
1818 wd->password_text = NULL;
1819 _check_enable_returnkey(data);
1820 evas_object_smart_callback_call(data, event, NULL);
1821 if (wd->delay_write)
1823 ecore_timer_del(wd->delay_write);
1824 wd->delay_write = NULL;
1827 if ((wd->single_line) && (wd->match_list))
1829 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1830 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1832 if ((!wd->autosave) || (!wd->file)) return;
1833 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1837 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1839 Widget_Data *wd = elm_widget_data_get(data);
1842 _entry_changed_common_handling(data, SIG_CHANGED);
1844 if ((wd->api) && (wd->api->obj_hidemenu))
1845 wd->api->obj_hidemenu(data);
1849 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1851 Widget_Data *wd = elm_widget_data_get(data);
1854 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1856 if ((wd->api) && (wd->api->obj_hidemenu))
1857 wd->api->obj_hidemenu(data);
1861 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1863 Widget_Data *wd = elm_widget_data_get(data);
1866 elm_object_scroll_freeze_push(data);
1868 if ((wd->api) && (wd->api->obj_hidemenu))
1869 wd->api->obj_hidemenu(data);
1871 _magnifier_create(data);
1872 _magnifier_move(data);
1873 _magnifier_show(data);
1877 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1879 Widget_Data *wd = elm_widget_data_get(data);
1882 elm_object_scroll_freeze_pop(data);
1884 if (wd->have_selection)
1886 _magnifier_hide(data);
1892 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1894 _magnifier_move(data);
1895 _magnifier_show(data);
1898 static Evas_Object *
1899 _viewport_obj_get(Evas_Object *data)
1901 Widget_Data *wd = elm_widget_data_get(data);
1902 if (!wd) return NULL;
1904 if(!data || !strlen(elm_widget_type_get(data)))
1907 Evas_Coord x, y, w, h;
1912 //evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1913 //printf(">>> wd->scroller (%d, %d, %d, %d) \n", x, y, w, h);
1914 return wd->scroller;
1917 Evas_Object *parent_obj = data;
1919 while(parent_obj = elm_widget_parent_get(parent_obj))
1921 //evas_object_geometry_get(parent_obj, &x, &y, &w, &h);
1922 //printf(">>> %s (%d, %d, %d, %d) \n", elm_widget_type_get(parent_obj), x, y, w, h);
1923 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
1924 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
1932 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1934 _magnifier_hide(data);
1939 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1941 Widget_Data *wd = elm_widget_data_get(data);
1945 EINA_LIST_FOREACH(entries, l, entry)
1947 if (entry != data) elm_entry_select_none(entry);
1949 wd->have_selection = EINA_TRUE;
1950 wd->selmode = EINA_TRUE;
1951 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1952 #ifdef HAVE_ELEMENTARY_X
1953 if (wd->sel_notify_handler)
1955 const char *txt = elm_entry_selection_get(data);
1958 top = elm_widget_top_get(data);
1959 if ((top) && (elm_win_xwindow_get(top)))
1960 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1964 if (!_elm_config->desktop_entry)
1965 edje_object_part_text_viewport_object_set(wd->ent, "elm.text", _viewport_obj_get(data));
1969 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1971 Evas_Coord cx, cy, cw, ch;
1972 Widget_Data *wd = elm_widget_data_get(data);
1975 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1976 if (!wd->deferred_recalc_job)
1977 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1980 wd->deferred_cur = EINA_TRUE;
1984 wd->ch = ch + elm_finger_size_get();
1989 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1991 Evas_Coord cx, cy, cw, ch;
1992 Widget_Data *wd = elm_widget_data_get(data);
1994 wd->have_selection = EINA_TRUE;
1995 wd->selmode = EINA_TRUE;
1996 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1997 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1998 elm_entry_selection_get(data));
2000 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2001 if (!wd->deferred_recalc_job)
2002 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE);
2005 wd->deferred_cur = EINA_TRUE;
2009 wd->ch = ch + elm_finger_size_get();
2014 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2016 Widget_Data *wd = elm_widget_data_get(data);
2018 if (!wd->have_selection) return;
2019 wd->have_selection = EINA_FALSE;
2020 wd->selmode = EINA_FALSE;
2021 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2022 if (wd->sel_notify_handler)
2026 #ifdef HAVE_ELEMENTARY_X
2029 top = elm_widget_top_get(data);
2030 if ((top) && (elm_win_xwindow_get(top)))
2031 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2034 eina_stringshare_del(wd->cut_sel);
2039 #ifdef HAVE_ELEMENTARY_X
2042 top = elm_widget_top_get(data);
2043 if ((top) && (elm_win_xwindow_get(top)))
2044 elm_selection_clear(ELM_SEL_PRIMARY, data);
2049 if ((wd->api) && (wd->api->obj_hidemenu))
2051 wd->api->obj_hidemenu(data);
2056 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2058 Widget_Data *wd = elm_widget_data_get(data);
2060 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2061 if (wd->sel_notify_handler)
2063 #ifdef HAVE_ELEMENTARY_X
2066 top = elm_widget_top_get(data);
2067 if ((top) && (elm_win_xwindow_get(top)))
2069 wd->selection_asked = EINA_TRUE;
2070 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2078 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2080 Widget_Data *wd = elm_widget_data_get(data);
2082 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2083 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2084 elm_entry_selection_get(data));
2088 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2090 Widget_Data *wd = elm_widget_data_get(data);
2092 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2093 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2094 elm_entry_selection_get(data));
2095 edje_object_part_text_insert(wd->ent, "elm.text", "");
2096 wd->changed = EINA_TRUE;
2101 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2103 Widget_Data *wd = elm_widget_data_get(data);
2105 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2106 wd->cur_changed = EINA_TRUE;
2107 _recalc_cursor_geometry(data);
2111 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2113 Widget_Data *wd = elm_widget_data_get(data);
2118 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2120 Widget_Data *wd = elm_widget_data_get(data);
2125 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2127 Widget_Data *wd = elm_widget_data_get(data);
2128 Elm_Entry_Anchor_Info ei;
2129 char *buf2, *p, *p2, *n;
2131 p = strrchr(emission, ',');
2134 const Eina_List *geoms;
2138 while (p2 >= emission)
2140 if (*p2 == ',') break;
2144 buf2 = alloca(5 + p - p2);
2145 strncpy(buf2, p2, p - p2);
2148 ei.button = atoi(buf2);
2149 ei.x = ei.y = ei.w = ei.h = 0;
2151 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2154 Evas_Textblock_Rectangle *r;
2156 Evas_Coord px, py, x, y;
2158 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2159 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2160 EINA_LIST_FOREACH(geoms, l, r)
2162 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2163 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2174 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2179 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2181 Widget_Data *wd = elm_widget_data_get(data);
2186 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2188 Widget_Data *wd = elm_widget_data_get(data);
2193 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2195 Widget_Data *wd = elm_widget_data_get(data);
2200 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2202 Widget_Data *wd = elm_widget_data_get(data);
2204 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2208 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2210 Widget_Data *wd = elm_widget_data_get(data);
2212 wd->double_clicked = EINA_FALSE;
2213 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2215 if ((wd->api) && (wd->api->obj_hidemenu))
2216 wd->api->obj_hidemenu(data);
2220 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2222 Widget_Data *wd = elm_widget_data_get(data);
2224 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2226 if (!_elm_config->desktop_entry && !wd->double_clicked)
2227 _cancel(data, NULL, NULL);
2231 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2233 Widget_Data *wd = elm_widget_data_get(data);
2235 wd->double_clicked = EINA_TRUE;
2236 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2239 #ifdef HAVE_ELEMENTARY_X
2241 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2243 Widget_Data *wd = elm_widget_data_get(data);
2244 Ecore_X_Event_Selection_Notify *ev = event;
2245 if (!wd) return ECORE_CALLBACK_PASS_ON;
2246 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2247 return ECORE_CALLBACK_PASS_ON;
2249 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2250 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2252 Ecore_X_Selection_Data_Text *text_data;
2254 text_data = ev->data;
2255 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2257 if (text_data->text)
2259 char *txt = _elm_util_text_to_mkup(text_data->text);
2263 elm_entry_entry_insert(data, txt);
2268 wd->selection_asked = EINA_FALSE;
2270 else if (ev->selection == ECORE_X_SELECTION_XDND)
2272 Ecore_X_Selection_Data_Text *text_data;
2274 text_data = ev->data;
2275 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2277 if (text_data->text)
2279 char *txt = _elm_util_text_to_mkup(text_data->text);
2283 /* Massive FIXME: this should be at the drag point */
2284 elm_entry_entry_insert(data, txt);
2289 wd->drag_selection_asked = EINA_FALSE;
2291 ecore_x_dnd_send_finished();
2294 return ECORE_CALLBACK_PASS_ON;
2298 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2301 Widget_Data *wd = elm_widget_data_get(data);
2302 Ecore_X_Event_Selection_Clear *ev = event;
2303 if (!wd) return ECORE_CALLBACK_PASS_ON;
2304 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2305 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2306 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2308 elm_entry_select_none(data);
2313 Evas_Object *top = elm_widget_top_get(data);
2314 Ecore_X_Event_Selection_Clear *ev = event;
2317 return ECORE_CALLBACK_PASS_ON;
2319 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2321 return ECORE_CALLBACK_PASS_ON;
2324 if (cnpwidgetdata == data)
2326 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2330 return ECORE_CALLBACK_PASS_ON;
2334 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2339 wd = elm_widget_data_get(obj);
2340 if (!wd) return EINA_FALSE;
2341 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2343 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2344 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2345 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2346 EDJE_CURSOR_MAIN,drop->x,drop->y);
2347 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2348 elm_entry_entry_insert(obj, drop->data);
2349 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2350 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2356 static Evas_Object *
2357 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2359 Widget_Data *wd = elm_widget_data_get(data);
2362 Elm_Entry_Item_Provider *ip;
2364 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2366 o = ip->func(ip->data, data, item);
2369 if (!strncmp(item, "file://", 7))
2371 const char *fname = item + 7;
2373 o = evas_object_image_filled_add(evas_object_evas_get(data));
2374 evas_object_image_file_set(o, fname, NULL);
2375 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2377 evas_object_show(o);
2382 o = edje_object_add(evas_object_evas_get(data));
2383 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2387 o = edje_object_add(evas_object_evas_get(data));
2388 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2389 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2394 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2396 const char *srcstring = NULL;
2397 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2398 char *curlocater, *replocater;
2399 char *starttag, *endtag;
2400 int tagtxtlen = 0, insertflag = 0;
2402 srcstring = eina_strbuf_string_get(srcbuf);
2403 curlocater = strstr(srcstring, key);
2405 if (!curlocater || !srcstring)
2413 starttag = strchr(srcstring, '<');
2414 endtag = strchr(srcstring, '>');
2415 tagtxtlen = endtag - starttag;
2416 if (tagtxtlen <= 0) tagtxtlen = 0;
2417 if (starttag < curlocater && curlocater < endtag) break;
2418 if (endtag != NULL && endtag+1 != NULL)
2419 srcstring = endtag+1;
2422 } while (strlen(srcstring) > 1);
2424 if (starttag && endtag && tagtxtlen > strlen(key))
2426 repbuf = eina_strbuf_new();
2427 diffbuf = eina_strbuf_new();
2428 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2429 srcstring = eina_strbuf_string_get(repbuf);
2430 curlocater = strstr(srcstring, key);
2432 if (curlocater != NULL)
2434 replocater = curlocater + strlen(key) + 1;
2436 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2439 if (replocater-curlocater > strlen(key)+1)
2441 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2450 eina_strbuf_reset(repbuf);
2458 if (repbuf == NULL) repbuf = eina_strbuf_new();
2459 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2463 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2464 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2470 eina_strbuf_prepend(diffbuf, "<");
2471 eina_strbuf_append(diffbuf, ">");
2472 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2476 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2477 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2481 if (repbuf) eina_strbuf_free(repbuf);
2482 if (diffbuf) eina_strbuf_free(diffbuf);
2488 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2490 Eina_Strbuf *sharebuf = NULL;
2492 sharebuf = eina_strbuf_new();
2493 eina_strbuf_append(sharebuf, *srcstring);
2494 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2495 eina_stringshare_del(*srcstring);
2496 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2497 eina_strbuf_free(sharebuf);
2503 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2505 Widget_Data *wd = elm_widget_data_get(data);
2507 Elm_Entry_Text_Filter *tf;
2509 if (type == EDJE_TEXT_FILTER_FORMAT)
2512 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2514 tf->func(tf->data, data, text);
2520 /* This function is used to insert text by chunks in jobs */
2522 _text_append_idler(void *data)
2526 Evas_Object *obj = (Evas_Object *) data;
2527 Widget_Data *wd = elm_widget_data_get(obj);
2528 if (wd->text) eina_stringshare_del(wd->text);
2530 if (wd->password_text) eina_stringshare_del(wd->password_text);
2531 wd->password_text = NULL;
2532 wd->changed = EINA_TRUE;
2534 start = wd->append_text_position;
2535 if (start + _CHUNK_SIZE < wd->append_text_len)
2538 int tag_start, esc_start;
2540 tag_start = esc_start = -1;
2541 /* Find proper markup cut place */
2542 while (pos - start < _CHUNK_SIZE)
2546 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2547 if (esc_start == -1)
2550 tag_start = prev_pos;
2551 else if (tmp == '>')
2554 else if (tag_start == -1)
2557 esc_start = prev_pos;
2558 else if (tmp == ';')
2565 wd->append_text_position = tag_start;
2567 else if (esc_start >= 0)
2569 wd->append_text_position = esc_start;
2573 wd->append_text_position = pos;
2578 wd->append_text_position = wd->append_text_len;
2581 backup = wd->append_text_left[wd->append_text_position];
2582 wd->append_text_left[wd->append_text_position] = '\0';
2584 edje_object_part_text_append(wd->ent, "elm.text",
2585 wd->append_text_left + start);
2587 wd->append_text_left[wd->append_text_position] = backup;
2589 /* If there's still more to go, renew the idler, else, cleanup */
2590 if (wd->append_text_position < wd->append_text_len)
2592 return ECORE_CALLBACK_RENEW;
2596 free(wd->append_text_left);
2597 wd->append_text_left = NULL;
2598 wd->append_text_idler = NULL;
2599 return ECORE_CALLBACK_CANCEL;
2604 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2606 int i = 0, unit_size;
2607 int current_len = strlen(*text);
2608 char *new_text = *text;
2609 if (unit >= LENGTH_UNIT_LAST) return;
2612 if (*new_text == '<')
2614 while (*new_text != '>')
2617 if (!*new_text) break;
2624 if (*new_text == '&')
2626 while (*(new_text + index) != ';')
2629 if (!*(new_text + index)) break;
2633 index = evas_string_char_next_get(new_text, index, NULL);
2634 markup = malloc(index + 1);
2635 strncpy(markup, new_text, index);
2637 if (unit == LENGTH_UNIT_BYTE)
2638 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2639 else if (unit == LENGTH_UNIT_CHAR)
2640 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2646 if (can_add < unit_size)
2650 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2656 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2657 current_len -= index;
2658 (*text)[current_len] = 0;
2663 can_add -= unit_size;
2668 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2672 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2675 ELM_CHECK_WIDTYPE(obj, widtype);
2676 if (item && strcmp(item, "default")) return;
2677 Widget_Data *wd = elm_widget_data_get(obj);
2679 if (!entry) entry = "";
2680 if (wd->text) eina_stringshare_del(wd->text);
2682 if (wd->password_text) eina_stringshare_del(wd->password_text);
2683 wd->password_text = NULL;
2684 wd->changed = EINA_TRUE;
2686 /* Clear currently pending job if there is one */
2687 if (wd->append_text_idler)
2689 ecore_idler_del(wd->append_text_idler);
2690 free(wd->append_text_left);
2691 wd->append_text_left = NULL;
2692 wd->append_text_idler = NULL;
2695 len = strlen(entry);
2696 /* Split to ~_CHUNK_SIZE chunks */
2697 if (len > _CHUNK_SIZE)
2699 wd->append_text_left = (char *) malloc(len + 1);
2702 /* If we decided to use the idler */
2703 if (wd->append_text_left)
2705 /* Need to clear the entry first */
2706 edje_object_part_text_set(wd->ent, "elm.text", "");
2707 memcpy(wd->append_text_left, entry, len + 1);
2708 wd->append_text_position = 0;
2709 wd->append_text_len = len;
2710 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2714 edje_object_part_text_set(wd->ent, "elm.text", entry);
2719 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2721 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2722 Widget_Data *wd = elm_widget_data_get(obj);
2723 if (item && strcmp(item, "default")) return NULL;
2725 if (!wd) return NULL;
2728 if(wd->password_text) return wd->password_text;
2734 text = edje_object_part_text_get(wd->ent, "elm.text");
2737 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2740 eina_stringshare_replace(&wd->text, text);
2743 const char *pw_text;
2744 pw_text = elm_entry_markup_to_utf8(wd->text);
2747 eina_stringshare_replace(&wd->password_text, pw_text);
2749 return wd->password_text;
2756 * This adds an entry to @p parent object.
2758 * @param parent The parent object
2759 * @return The new object or NULL if it cannot be created
2764 elm_entry_add(Evas_Object *parent)
2766 Evas_Object *obj, *top;
2770 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2772 ELM_SET_WIDTYPE(widtype, "entry");
2773 elm_widget_type_set(obj, "entry");
2774 elm_widget_sub_object_add(parent, obj);
2775 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2776 elm_widget_data_set(obj, wd);
2777 elm_widget_del_hook_set(obj, _del_hook);
2778 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2779 elm_widget_theme_hook_set(obj, _theme_hook);
2780 elm_widget_disable_hook_set(obj, _disable_hook);
2781 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2782 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2783 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2784 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2785 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2786 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2787 elm_widget_can_focus_set(obj, EINA_TRUE);
2788 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2789 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2790 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2792 wd->scroller = elm_smart_scroller_add(e);
2793 elm_widget_sub_object_add(obj, wd->scroller);
2794 elm_smart_scroller_widget_set(wd->scroller, obj);
2795 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2796 elm_widget_style_get(obj));
2797 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2798 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2799 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2800 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2802 wd->linewrap = ELM_WRAP_WORD;
2803 wd->editable = EINA_TRUE;
2804 wd->disabled = EINA_FALSE;
2805 wd->context_menu = EINA_TRUE;
2806 wd->autosave = EINA_TRUE;
2807 wd->textonly = EINA_FALSE;
2808 wd->autoperiod = EINA_TRUE;
2810 wd->ent = edje_object_add(e);
2811 elm_widget_sub_object_add(obj, wd->ent);
2812 edje_object_item_provider_set(wd->ent, _get_item, obj);
2813 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2814 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2815 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2817 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2819 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2821 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2823 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2824 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2825 _signal_entry_changed, obj);
2826 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2827 _signal_preedit_changed, obj);
2828 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2829 _signal_handler_move_start, obj);
2830 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2831 _signal_handler_move_end, obj);
2832 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2833 _signal_handler_moving, obj);
2834 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2835 _signal_selection_start, obj);
2836 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2837 _signal_selection_end, obj);
2838 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
2839 _signal_long_pressed, obj);
2840 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2841 _signal_magnifier_changed, obj);
2842 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2843 _signal_selection_changed, obj);
2844 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2845 _signal_selection_cleared, obj);
2846 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2847 _signal_entry_paste_request, obj);
2848 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2849 _signal_entry_copy_notify, obj);
2850 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2851 _signal_entry_cut_notify, obj);
2852 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2853 _signal_cursor_changed, obj);
2854 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2855 _signal_anchor_down, obj);
2856 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2857 _signal_anchor_up, obj);
2858 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2859 _signal_anchor_clicked, obj);
2860 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2861 _signal_anchor_move, obj);
2862 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2863 _signal_anchor_in, obj);
2864 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2865 _signal_anchor_out, obj);
2866 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2867 _signal_key_enter, obj);
2868 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2869 _signal_mouse_down, obj);
2870 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2871 _signal_mouse_clicked, obj);
2872 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2873 _signal_mouse_double, obj);
2874 edje_object_part_text_set(wd->ent, "elm.text", "");
2875 if (_elm_config->desktop_entry)
2876 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2877 elm_widget_resize_object_set(obj, wd->ent);
2880 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2882 #ifdef HAVE_ELEMENTARY_X
2883 top = elm_widget_top_get(obj);
2884 if ((top) && (elm_win_xwindow_get(top)))
2886 wd->sel_notify_handler =
2887 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2888 _event_selection_notify, obj);
2889 wd->sel_clear_handler =
2890 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2891 _event_selection_clear, obj);
2894 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2895 _drag_drop_cb, NULL);
2898 entries = eina_list_prepend(entries, obj);
2900 // module - find module for entry
2901 wd->api = _module(obj);
2902 // if found - hook in
2903 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2905 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2906 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2907 // TODO: and save some bytes, making descriptions per-class and not instance!
2908 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2912 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2914 ELM_CHECK_WIDTYPE(obj, widtype);
2915 Widget_Data *wd = elm_widget_data_get(obj);
2917 ext_mod->cancel = _cancel;
2918 ext_mod->copy = _copy;
2919 ext_mod->cut = _cut;
2920 ext_mod->paste = _paste;
2921 ext_mod->select = _select;
2922 ext_mod->selectall = _selectall;
2923 ext_mod->ent = wd->ent;
2924 ext_mod->viewport_obj = _viewport_obj_get(obj);
2925 ext_mod->items = wd->items;
2926 ext_mod->editable = wd->editable;
2927 ext_mod->have_selection = wd->have_selection;
2928 ext_mod->password = wd->password;
2929 ext_mod->selmode = wd->selmode;
2930 ext_mod->cnpinit = _cnpinit;
2931 ext_mod->context_menu = wd->context_menu;
2932 ext_mod->textonly = wd->textonly;
2936 * This sets the entry object not to line wrap. All input will
2937 * be on a single line, and the entry box will extend with user input.
2939 * @param obj The entry object
2940 * @param single_line If true, the text in the entry
2941 * will be on a single line.
2946 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2948 ELM_CHECK_WIDTYPE(obj, widtype);
2949 Widget_Data *wd = elm_widget_data_get(obj);
2951 if (wd->single_line == single_line) return;
2952 wd->single_line = single_line;
2953 wd->linewrap = ELM_WRAP_NONE;
2954 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2958 if (wd->single_line)
2960 elm_smart_scroller_policy_set(wd->scroller,
2961 ELM_SMART_SCROLLER_POLICY_OFF,
2962 ELM_SMART_SCROLLER_POLICY_OFF);
2963 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2967 const Elm_Scroller_Policy map[3] =
2969 ELM_SMART_SCROLLER_POLICY_AUTO,
2970 ELM_SMART_SCROLLER_POLICY_ON,
2971 ELM_SMART_SCROLLER_POLICY_OFF
2973 elm_smart_scroller_policy_set(wd->scroller,
2976 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2983 * This returns true if the entry has been set to single line mode.
2984 * See also elm_entry_single_line_set().
2986 * @param obj The entry object
2987 * @return single_line If true, the text in the entry is set to display
2993 elm_entry_single_line_get(const Evas_Object *obj)
2995 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2996 Widget_Data *wd = elm_widget_data_get(obj);
2997 if (!wd) return EINA_FALSE;
2998 return wd->single_line;
3002 * This sets the entry object to password mode. All text entered
3003 * and/or displayed within the widget will be replaced with asterisks (*).
3005 * @param obj The entry object
3006 * @param password If true, password mode is enabled.
3011 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3013 ELM_CHECK_WIDTYPE(obj, widtype);
3014 Widget_Data *wd = elm_widget_data_get(obj);
3016 if (wd->password == password) return;
3017 wd->password = password;
3018 wd->single_line = EINA_TRUE;
3019 wd->linewrap = ELM_WRAP_NONE;
3024 * This returns whether password mode is enabled.
3025 * See also elm_entry_password_set().
3027 * @param obj The entry object
3028 * @return If true, the entry is set to display all characters
3034 elm_entry_password_get(const Evas_Object *obj)
3036 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3037 Widget_Data *wd = elm_widget_data_get(obj);
3038 if (!wd) return EINA_FALSE;
3039 return wd->password;
3043 * This sets the text displayed within the entry to @p entry.
3045 * @param obj The entry object
3046 * @param entry The text to be displayed
3051 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3053 _elm_entry_text_set(obj, NULL, entry);
3057 * This appends @p entry to the text of the entry.
3059 * @param obj The entry object
3060 * @param entry The text to be displayed
3065 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3068 ELM_CHECK_WIDTYPE(obj, widtype);
3069 Widget_Data *wd = elm_widget_data_get(obj);
3071 if (!entry) entry = "";
3072 wd->changed = EINA_TRUE;
3074 len = strlen(entry);
3075 if (wd->append_text_left)
3078 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3084 wd->append_text_left = tmpbuf;
3085 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3086 wd->append_text_len += len;
3090 /* FIXME: Add chunked appending here (like in entry_set) */
3091 edje_object_part_text_append(wd->ent, "elm.text", entry);
3096 * This returns the text currently shown in object @p entry.
3097 * See also elm_entry_entry_set().
3099 * @param obj The entry object
3100 * @return The currently displayed text or NULL on failure
3105 elm_entry_entry_get(const Evas_Object *obj)
3107 return _elm_entry_text_get(obj, NULL);
3111 * This returns EINA_TRUE if the entry is empty/there was an error
3112 * and EINA_FALSE if it is not empty.
3114 * @param obj The entry object
3115 * @return If the entry is empty or not.
3120 elm_entry_is_empty(const Evas_Object *obj)
3122 /* FIXME: until there's support for that in textblock, we just check
3123 * to see if the there is text or not. */
3124 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3125 Widget_Data *wd = elm_widget_data_get(obj);
3126 const Evas_Object *tb;
3127 //Evas_Textblock_Cursor *cur;
3129 if (!wd) return EINA_TRUE;
3132 /* It's a hack until we get the support suggested above.
3133 * We just create a cursor, point it to the begining, and then
3134 * try to advance it, if it can advance, the tb is not empty,
3135 * otherwise it is. */
3136 tb = edje_object_part_object_get(wd->ent, "elm.text");
3137 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3138 actually, ok for the time being, thsese hackish stuff will be removed
3139 once evas 1.0 is out*/
3140 evas_textblock_cursor_pos_set(cur, 0);
3141 ret = evas_textblock_cursor_char_next(cur);
3142 evas_textblock_cursor_free(cur);
3147 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3148 if (!str) return EINA_TRUE;
3150 ret = (strlen(str) == 0);
3156 * This returns all selected text within the entry.
3158 * @param obj The entry object
3159 * @return The selected text within the entry or NULL on failure
3164 elm_entry_selection_get(const Evas_Object *obj)
3166 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3167 Widget_Data *wd = elm_widget_data_get(obj);
3168 if (!wd) return NULL;
3169 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3173 * This inserts text in @p entry where the current cursor position.
3175 * This inserts text at the cursor position is as if it was typed
3176 * by the user (note this also allows markup which a user
3177 * can't just "type" as it would be converted to escaped text, so this
3178 * call can be used to insert things like emoticon items or bold push/pop
3179 * tags, other font and color change tags etc.)
3181 * @param obj The entry object
3182 * @param entry The text to insert
3187 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3189 ELM_CHECK_WIDTYPE(obj, widtype);
3190 Widget_Data *wd = elm_widget_data_get(obj);
3192 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3194 #ifdef HAVE_ELEMENTARY_X
3195 if (cnpwidgetdata == obj)
3196 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3199 wd->changed = EINA_TRUE;
3204 * This enables word line wrapping in the entry object. It is the opposite
3205 * of elm_entry_single_line_set(). Additionally, setting this disables
3206 * character line wrapping.
3208 * @param obj The entry object
3209 * @param wrap If true, the entry will be wrapped once it reaches the end
3210 * of the object. Wrapping will occur at the end of the word before the end of the
3216 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3218 ELM_CHECK_WIDTYPE(obj, widtype);
3219 Widget_Data *wd = elm_widget_data_get(obj);
3221 if (wd->linewrap == wrap) return;
3223 wd->linewrap = wrap;
3228 * Get the wrapping behavior of the entry.
3229 * See also elm_entry_line_wrap_set().
3231 * @param obj The entry object
3237 elm_entry_line_wrap_get(const Evas_Object *obj)
3239 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3240 Widget_Data *wd = elm_widget_data_get(obj);
3241 if (!wd) return EINA_FALSE;
3242 return wd->linewrap;
3246 * This sets the editable attribute of the entry.
3248 * @param obj The entry object
3249 * @param editable If true, the entry will be editable by the user.
3250 * If false, it will be set to the disabled state.
3255 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3257 ELM_CHECK_WIDTYPE(obj, widtype);
3258 Widget_Data *wd = elm_widget_data_get(obj);
3260 if (wd->editable == editable) return;
3261 wd->editable = editable;
3264 #ifdef HAVE_ELEMENTARY_X
3266 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3268 elm_drop_target_del(obj);
3273 * This gets the editable attribute of the entry.
3274 * See also elm_entry_editable_set().
3276 * @param obj The entry object
3277 * @return If true, the entry is editable by the user.
3278 * If false, it is not editable by the user
3283 elm_entry_editable_get(const Evas_Object *obj)
3285 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3286 Widget_Data *wd = elm_widget_data_get(obj);
3287 if (!wd) return EINA_FALSE;
3288 return wd->editable;
3292 * This drops any existing text selection within the entry.
3294 * @param obj The entry object
3299 elm_entry_select_none(Evas_Object *obj)
3301 ELM_CHECK_WIDTYPE(obj, widtype);
3302 Widget_Data *wd = elm_widget_data_get(obj);
3306 wd->selmode = EINA_FALSE;
3307 if (!_elm_config->desktop_entry)
3308 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3309 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3311 wd->have_selection = EINA_FALSE;
3312 edje_object_part_text_select_none(wd->ent, "elm.text");
3316 * This selects all text within the entry.
3318 * @param obj The entry object
3323 elm_entry_select_all(Evas_Object *obj)
3325 ELM_CHECK_WIDTYPE(obj, widtype);
3326 Widget_Data *wd = elm_widget_data_get(obj);
3330 wd->selmode = EINA_FALSE;
3331 if (!_elm_config->desktop_entry)
3332 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3333 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3335 wd->have_selection = EINA_TRUE;
3336 edje_object_part_text_select_all(wd->ent, "elm.text");
3340 * This function returns the geometry of the cursor.
3342 * It's useful if you want to draw something on the cursor (or where it is),
3343 * or for example in the case of scrolled entry where you want to show the
3346 * @param obj The entry object
3347 * @param x returned geometry
3348 * @param y returned geometry
3349 * @param w returned geometry
3350 * @param h returned geometry
3351 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3356 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3358 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3359 Widget_Data *wd = elm_widget_data_get(obj);
3360 if (!wd) return EINA_FALSE;
3361 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3366 * This moves the cursor one place to the right within the entry.
3368 * @param obj The entry object
3369 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3374 elm_entry_cursor_next(Evas_Object *obj)
3376 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3377 Widget_Data *wd = elm_widget_data_get(obj);
3378 if (!wd) return EINA_FALSE;
3379 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3383 * This moves the cursor one place to the left within the entry.
3385 * @param obj The entry object
3386 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3391 elm_entry_cursor_prev(Evas_Object *obj)
3393 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3394 Widget_Data *wd = elm_widget_data_get(obj);
3395 if (!wd) return EINA_FALSE;
3396 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3400 * This moves the cursor one line up within the entry.
3402 * @param obj The entry object
3403 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3408 elm_entry_cursor_up(Evas_Object *obj)
3410 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3411 Widget_Data *wd = elm_widget_data_get(obj);
3412 if (!wd) return EINA_FALSE;
3413 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3417 * This moves the cursor one line down within the entry.
3419 * @param obj The entry object
3420 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3425 elm_entry_cursor_down(Evas_Object *obj)
3427 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3428 Widget_Data *wd = elm_widget_data_get(obj);
3429 if (!wd) return EINA_FALSE;
3430 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3434 * This moves the cursor to the beginning of the entry.
3436 * @param obj The entry object
3441 elm_entry_cursor_begin_set(Evas_Object *obj)
3443 ELM_CHECK_WIDTYPE(obj, widtype);
3444 Widget_Data *wd = elm_widget_data_get(obj);
3446 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3450 * This moves the cursor to the end of the entry.
3452 * @param obj The entry object
3457 elm_entry_cursor_end_set(Evas_Object *obj)
3459 ELM_CHECK_WIDTYPE(obj, widtype);
3460 Widget_Data *wd = elm_widget_data_get(obj);
3463 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3466 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3467 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3472 * This moves the cursor to the beginning of the current line.
3474 * @param obj The entry object
3479 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3481 ELM_CHECK_WIDTYPE(obj, widtype);
3482 Widget_Data *wd = elm_widget_data_get(obj);
3484 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3488 * This moves the cursor to the end of the current line.
3490 * @param obj The entry object
3495 elm_entry_cursor_line_end_set(Evas_Object *obj)
3497 ELM_CHECK_WIDTYPE(obj, widtype);
3498 Widget_Data *wd = elm_widget_data_get(obj);
3500 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3504 * This begins a selection within the entry as though
3505 * the user were holding down the mouse button to make a selection.
3507 * @param obj The entry object
3512 elm_entry_cursor_selection_begin(Evas_Object *obj)
3514 ELM_CHECK_WIDTYPE(obj, widtype);
3515 Widget_Data *wd = elm_widget_data_get(obj);
3517 edje_object_part_text_select_begin(wd->ent, "elm.text");
3521 * This ends a selection within the entry as though
3522 * the user had just released the mouse button while making a selection.
3524 * @param obj The entry object
3529 elm_entry_cursor_selection_end(Evas_Object *obj)
3531 ELM_CHECK_WIDTYPE(obj, widtype);
3532 Widget_Data *wd = elm_widget_data_get(obj);
3534 edje_object_part_text_select_extend(wd->ent, "elm.text");
3538 * TODO: fill this in
3540 * @param obj The entry object
3541 * @return TODO: fill this in
3546 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3548 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3549 Widget_Data *wd = elm_widget_data_get(obj);
3550 if (!wd) return EINA_FALSE;
3551 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3555 * This returns whether the cursor is visible.
3557 * @param obj The entry object
3558 * @return If true, the cursor is visible.
3563 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3565 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3566 Widget_Data *wd = elm_widget_data_get(obj);
3567 if (!wd) return EINA_FALSE;
3568 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3572 * TODO: fill this in
3574 * @param obj The entry object
3575 * @return TODO: fill this in
3580 elm_entry_cursor_content_get(const Evas_Object *obj)
3582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3583 Widget_Data *wd = elm_widget_data_get(obj);
3584 if (!wd) return NULL;
3585 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3589 * Sets the cursor position in the entry to the given value
3591 * @param obj The entry object
3592 * @param pos The position of the cursor
3597 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3599 ELM_CHECK_WIDTYPE(obj, widtype);
3600 Widget_Data *wd = elm_widget_data_get(obj);
3602 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3603 edje_object_message_signal_process(wd->ent);
3607 * Retrieves the current position of the cursor in the entry
3609 * @param obj The entry object
3610 * @return The cursor position
3615 elm_entry_cursor_pos_get(const Evas_Object *obj)
3617 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3618 Widget_Data *wd = elm_widget_data_get(obj);
3620 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3624 * This executes a "cut" action on the selected text in the entry.
3626 * @param obj The entry object
3631 elm_entry_selection_cut(Evas_Object *obj)
3633 ELM_CHECK_WIDTYPE(obj, widtype);
3634 Widget_Data *wd = elm_widget_data_get(obj);
3636 _cut(obj, NULL, NULL);
3640 * This executes a "copy" action on the selected text in the entry.
3642 * @param obj The entry object
3647 elm_entry_selection_copy(Evas_Object *obj)
3649 ELM_CHECK_WIDTYPE(obj, widtype);
3650 Widget_Data *wd = elm_widget_data_get(obj);
3652 _copy(obj, NULL, NULL);
3656 * This executes a "paste" action in the entry.
3658 * @param obj The entry object
3663 elm_entry_selection_paste(Evas_Object *obj)
3665 ELM_CHECK_WIDTYPE(obj, widtype);
3666 Widget_Data *wd = elm_widget_data_get(obj);
3668 _paste(obj, NULL, NULL);
3672 * This clears and frees the items in a entry's contextual (right click) menu.
3674 * @param obj The entry object
3679 elm_entry_context_menu_clear(Evas_Object *obj)
3681 ELM_CHECK_WIDTYPE(obj, widtype);
3682 Widget_Data *wd = elm_widget_data_get(obj);
3683 Elm_Entry_Context_Menu_Item *it;
3685 EINA_LIST_FREE(wd->items, it)
3687 eina_stringshare_del(it->label);
3688 eina_stringshare_del(it->icon_file);
3689 eina_stringshare_del(it->icon_group);
3695 * This adds an item to the entry's contextual menu.
3697 * @param obj The entry object
3698 * @param label The item's text label
3699 * @param icon_file The item's icon file
3700 * @param icon_type The item's icon type
3701 * @param func The callback to execute when the item is clicked
3702 * @param data The data to associate with the item for related functions
3707 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)
3709 ELM_CHECK_WIDTYPE(obj, widtype);
3710 Widget_Data *wd = elm_widget_data_get(obj);
3711 Elm_Entry_Context_Menu_Item *it;
3713 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3715 wd->items = eina_list_append(wd->items, it);
3717 it->label = eina_stringshare_add(label);
3718 it->icon_file = eina_stringshare_add(icon_file);
3719 it->icon_type = icon_type;
3721 it->data = (void *)data;
3725 * This disables the entry's contextual (right click) menu.
3727 * @param obj The entry object
3728 * @param disabled If true, the menu is disabled
3733 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3735 ELM_CHECK_WIDTYPE(obj, widtype);
3736 Widget_Data *wd = elm_widget_data_get(obj);
3738 if (wd->context_menu == !disabled) return;
3739 wd->context_menu = !disabled;
3743 * This returns whether the entry's contextual (right click) menu is disabled.
3745 * @param obj The entry object
3746 * @return If true, the menu is disabled
3751 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3753 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3754 Widget_Data *wd = elm_widget_data_get(obj);
3755 if (!wd) return EINA_FALSE;
3756 return !wd->context_menu;
3760 * This appends a custom item provider to the list for that entry
3762 * This appends the given callback. The list is walked from beginning to end
3763 * with each function called given the item href string in the text. If the
3764 * function returns an object handle other than NULL (it should create an
3765 * and object to do this), then this object is used to replace that item. If
3766 * not the next provider is called until one provides an item object, or the
3767 * default provider in entry does.
3769 * @param obj The entry object
3770 * @param func The function called to provide the item object
3771 * @param data The data passed to @p func
3776 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3778 ELM_CHECK_WIDTYPE(obj, widtype);
3779 Widget_Data *wd = elm_widget_data_get(obj);
3781 EINA_SAFETY_ON_NULL_RETURN(func);
3782 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3786 wd->item_providers = eina_list_append(wd->item_providers, ip);
3790 * This prepends a custom item provider to the list for that entry
3792 * This prepends the given callback. See elm_entry_item_provider_append() for
3795 * @param obj The entry object
3796 * @param func The function called to provide the item object
3797 * @param data The data passed to @p func
3802 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3804 ELM_CHECK_WIDTYPE(obj, widtype);
3805 Widget_Data *wd = elm_widget_data_get(obj);
3807 EINA_SAFETY_ON_NULL_RETURN(func);
3808 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3812 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3816 * This removes a custom item provider to the list for that entry
3818 * This removes the given callback. See elm_entry_item_provider_append() for
3821 * @param obj The entry object
3822 * @param func The function called to provide the item object
3823 * @param data The data passed to @p func
3828 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3830 ELM_CHECK_WIDTYPE(obj, widtype);
3831 Widget_Data *wd = elm_widget_data_get(obj);
3833 Elm_Entry_Item_Provider *ip;
3835 EINA_SAFETY_ON_NULL_RETURN(func);
3836 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3838 if ((ip->func == func) && ((!data) || (ip->data == data)))
3840 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3848 * Append a filter function for text inserted in the entry
3850 * Append the given callback to the list. This functions will be called
3851 * whenever any text is inserted into the entry, with the text to be inserted
3852 * as a parameter. The callback function is free to alter the text in any way
3853 * it wants, but it must remember to free the given pointer and update it.
3854 * If the new text is to be discarded, the function can free it and set it text
3855 * parameter to NULL. This will also prevent any following filters from being
3858 * @param obj The entry object
3859 * @param func The function to use as text filter
3860 * @param data User data to pass to @p func
3865 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3868 Elm_Entry_Text_Filter *tf;
3869 ELM_CHECK_WIDTYPE(obj, widtype);
3871 wd = elm_widget_data_get(obj);
3873 EINA_SAFETY_ON_NULL_RETURN(func);
3875 tf = _filter_new(func, data);
3878 wd->text_filters = eina_list_append(wd->text_filters, tf);
3882 * Prepend a filter function for text insdrted in the entry
3884 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3885 * for more information
3887 * @param obj The entry object
3888 * @param func The function to use as text filter
3889 * @param data User data to pass to @p func
3894 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3897 Elm_Entry_Text_Filter *tf;
3898 ELM_CHECK_WIDTYPE(obj, widtype);
3900 wd = elm_widget_data_get(obj);
3902 EINA_SAFETY_ON_NULL_RETURN(func);
3904 tf = _filter_new(func, data);
3907 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3911 * Remove a filter from the list
3913 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3914 * for more information.
3916 * @param obj The entry object
3917 * @param func The filter function to remove
3918 * @param data The user data passed when adding the function
3923 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3927 Elm_Entry_Text_Filter *tf;
3928 ELM_CHECK_WIDTYPE(obj, widtype);
3930 wd = elm_widget_data_get(obj);
3932 EINA_SAFETY_ON_NULL_RETURN(func);
3934 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3936 if ((tf->func == func) && ((!data) || (tf->data == data)))
3938 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3946 * This converts a markup (HTML-like) string into UTF-8.
3947 * Returning string is obtained with malloc.
3948 * After use the returned string, it should be freed.
3950 * @param s The string (in markup) to be converted
3951 * @return The converted string (in UTF-8). It should be freed.
3956 elm_entry_markup_to_utf8(const char *s)
3958 char *ss = _elm_util_mkup_to_text(s);
3959 if (!ss) ss = strdup("");
3964 * This converts a UTF-8 string into markup (HTML-like).
3965 * Returning string is obtained with malloc.
3966 * After use the returned string, it should be freed.
3968 * @param s The string (in UTF-8) to be converted
3969 * @return The converted string (in markup). It should be freed.
3974 elm_entry_utf8_to_markup(const char *s)
3976 char *ss = _elm_util_text_to_mkup(s);
3977 if (!ss) ss = strdup("");
3982 * Filter inserted text based on user defined character and byte limits
3984 * Add this filter to an entry to limit the characters that it will accept
3985 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
3986 * The funtion works on the UTF-8 representation of the string, converting
3987 * it from the set markup, thus not accounting for any format in it.
3989 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
3990 * it as data when setting the filter. In it it's possible to set limits
3991 * by character count or bytes (any of them is disabled if 0), and both can
3992 * be set at the same time. In that case, it first checks for characters,
3995 * The function will cut the inserted text in order to allow only the first
3996 * number of characters that are still allowed. The cut is made in
3997 * characters, even when limiting by bytes, in order to always contain
3998 * valid ones and avoid half unicode characters making it in.
4003 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4005 Elm_Entry_Filter_Limit_Size *lim = data;
4008 const char *(*text_get)(const Evas_Object *);
4009 const char *widget_type;
4011 EINA_SAFETY_ON_NULL_RETURN(data);
4012 EINA_SAFETY_ON_NULL_RETURN(entry);
4013 EINA_SAFETY_ON_NULL_RETURN(text);
4015 /* hack. I don't want to copy the entire function to work with
4017 widget_type = elm_widget_type_get(entry);
4018 if (!strcmp(widget_type, "entry"))
4019 text_get = elm_entry_entry_get;
4023 current = elm_entry_markup_to_utf8(text_get(entry));
4025 if (lim->max_char_count > 0)
4027 len = evas_string_char_len_get(current);
4028 if (len >= lim->max_char_count)
4030 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4036 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4037 if ((len + newlen) > lim->max_char_count)
4038 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4040 else if (lim->max_byte_count > 0)
4042 len = strlen(current);
4043 if (len >= lim->max_byte_count)
4045 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4051 newlen = strlen(elm_entry_markup_to_utf8(*text));
4052 if ((len + newlen) > lim->max_byte_count)
4053 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4059 * Filter inserted text based on accepted or rejected sets of characters
4061 * Add this filter to an entry to restrict the set of accepted characters
4062 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4063 * This structure contains both accepted and rejected sets, but they are
4064 * mutually exclusive. If accepted is set, it will be used, otherwise it
4065 * goes on to the rejected set.
4068 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4070 Elm_Entry_Filter_Accept_Set *as = data;
4074 int read_idx, last_read_idx = 0, read_char;
4076 EINA_SAFETY_ON_NULL_RETURN(data);
4077 EINA_SAFETY_ON_NULL_RETURN(text);
4079 if ((!as->accepted) && (!as->rejected))
4085 goes_in = EINA_TRUE;
4090 goes_in = EINA_FALSE;
4094 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4097 int cmp_idx, cmp_char;
4098 Eina_Bool in_set = EINA_FALSE;
4100 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4103 if (read_char == cmp_char)
4108 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4110 if (in_set == goes_in)
4112 int size = read_idx - last_read_idx;
4113 const char *src = (*text) + last_read_idx;
4115 memcpy(insert, *text + last_read_idx, size);
4118 last_read_idx = read_idx;
4119 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4125 * This sets the file (and implicitly loads it) for the text to display and
4126 * then edit. All changes are written back to the file after a short delay if
4127 * the entry object is set to autosave.
4129 * @param obj The entry object
4130 * @param file The path to the file to load and save
4131 * @param format The file format
4136 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4138 ELM_CHECK_WIDTYPE(obj, widtype);
4139 Widget_Data *wd = elm_widget_data_get(obj);
4141 if (wd->delay_write)
4143 ecore_timer_del(wd->delay_write);
4144 wd->delay_write = NULL;
4146 if (wd->autosave) _save(obj);
4147 eina_stringshare_replace(&wd->file, file);
4148 wd->format = format;
4153 * Gets the file to load and save and the file format
4155 * @param obj The entry object
4156 * @param file The path to the file to load and save
4157 * @param format The file format
4162 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4164 ELM_CHECK_WIDTYPE(obj, widtype);
4165 Widget_Data *wd = elm_widget_data_get(obj);
4167 if (file) *file = wd->file;
4168 if (format) *format = wd->format;
4172 * This function writes any changes made to the file set with
4173 * elm_entry_file_set()
4175 * @param obj The entry object
4180 elm_entry_file_save(Evas_Object *obj)
4182 ELM_CHECK_WIDTYPE(obj, widtype);
4183 Widget_Data *wd = elm_widget_data_get(obj);
4185 if (wd->delay_write)
4187 ecore_timer_del(wd->delay_write);
4188 wd->delay_write = NULL;
4191 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4195 * This sets the entry object to 'autosave' the loaded text file or not.
4197 * @param obj The entry object
4198 * @param autosave Autosave the loaded file or not
4203 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4205 ELM_CHECK_WIDTYPE(obj, widtype);
4206 Widget_Data *wd = elm_widget_data_get(obj);
4208 wd->autosave = !!autosave;
4212 * This gets the entry object's 'autosave' status.
4214 * @param obj The entry object
4215 * @return Autosave the loaded file or not
4220 elm_entry_autosave_get(const Evas_Object *obj)
4222 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4223 Widget_Data *wd = elm_widget_data_get(obj);
4224 if (!wd) return EINA_FALSE;
4225 return wd->autosave;
4229 * Control pasting of text and images for the widget.
4231 * Normally the entry allows both text and images to be pasted. By setting
4232 * textonly to be true, this prevents images from being pasted.
4234 * Note this only changes the behaviour of text.
4236 * @param obj The entry object
4237 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4242 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4244 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4245 ELM_CHECK_WIDTYPE(obj, widtype);
4246 Widget_Data *wd = elm_widget_data_get(obj);
4248 textonly = !!textonly;
4249 if (wd->textonly == textonly) return;
4250 wd->textonly = !!textonly;
4251 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4252 #ifdef HAVE_ELEMENTARY_X
4253 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4258 * Getting elm_entry text paste/drop mode.
4260 * In textonly mode, only text may be pasted or dropped into the widget.
4262 * @param obj The entry object
4263 * @return If the widget only accepts text from pastes.
4268 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4270 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4271 Widget_Data *wd = elm_widget_data_get(obj);
4272 if (!wd) return EINA_FALSE;
4273 return wd->textonly;
4277 * Enable or disable scrolling in entry
4279 * Normally the entry is not scrollable unless you enable it with this call.
4281 * @param obj The entry object
4282 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4287 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4289 ELM_CHECK_WIDTYPE(obj, widtype);
4290 Widget_Data *wd = elm_widget_data_get(obj);
4293 if (wd->scroll == scroll) return;
4294 wd->scroll = scroll;
4297 elm_widget_sub_object_del(obj, wd->scroller);
4298 elm_widget_resize_object_set(obj, wd->scroller);
4299 elm_widget_sub_object_add(obj, wd->ent);
4300 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4301 evas_object_show(wd->scroller);
4302 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4303 if (wd->single_line)
4305 elm_smart_scroller_policy_set(wd->scroller,
4306 ELM_SMART_SCROLLER_POLICY_OFF,
4307 ELM_SMART_SCROLLER_POLICY_OFF);
4308 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4312 const Elm_Scroller_Policy map[3] =
4314 ELM_SMART_SCROLLER_POLICY_AUTO,
4315 ELM_SMART_SCROLLER_POLICY_ON,
4316 ELM_SMART_SCROLLER_POLICY_OFF
4318 elm_smart_scroller_policy_set(wd->scroller,
4321 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
4326 elm_smart_scroller_child_set(wd->scroller, NULL);
4327 elm_widget_sub_object_del(obj, wd->ent);
4328 elm_widget_resize_object_set(obj, wd->ent);
4329 evas_object_smart_member_add(wd->scroller, obj);
4330 elm_widget_sub_object_add(obj, wd->scroller);
4331 evas_object_hide(wd->scroller);
4332 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4339 * Get the scrollable state of the entry
4341 * Normally the entry is not scrollable. This gets the scrollable state
4342 * of the entry. See elm_entry_scrollable_set() for more information.
4344 * @param obj The entry object
4345 * @return The scrollable state
4350 elm_entry_scrollable_get(const Evas_Object *obj)
4352 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4353 Widget_Data *wd = elm_widget_data_get(obj);
4354 if (!wd) return EINA_FALSE;
4359 * This sets a widget to be displayed to the left of a scrolled entry.
4361 * @param obj The scrolled entry object
4362 * @param icon The widget to display on the left side of the scrolled
4365 * @note A previously set widget will be destroyed.
4366 * @note If the object being set does not have minimum size hints set,
4367 * it won't get properly displayed.
4370 * @see elm_entry_end_set
4373 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4375 ELM_CHECK_WIDTYPE(obj, widtype);
4376 Widget_Data *wd = elm_widget_data_get(obj);
4379 EINA_SAFETY_ON_NULL_RETURN(icon);
4380 if (wd->icon == icon) return;
4381 if (wd->icon) evas_object_del(wd->icon);
4383 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4385 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4386 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4391 * Gets the leftmost widget of the scrolled entry. This object is
4392 * owned by the scrolled entry and should not be modified.
4394 * @param obj The scrolled entry object
4395 * @return the left widget inside the scroller
4400 elm_entry_icon_get(const Evas_Object *obj)
4402 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4403 Widget_Data *wd = elm_widget_data_get(obj);
4404 if (!wd) return NULL;
4409 * Unset the leftmost widget of the scrolled entry, unparenting and
4412 * @param obj The scrolled entry object
4413 * @return the previously set icon sub-object of this entry, on
4416 * @see elm_entry_icon_set()
4421 elm_entry_icon_unset(Evas_Object *obj)
4423 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4424 Widget_Data *wd = elm_widget_data_get(obj);
4425 Evas_Object *ret = NULL;
4426 if (!wd) return NULL;
4429 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4430 if (!edje) return NULL;
4432 edje_object_part_unswallow(edje, wd->icon);
4433 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4441 * Sets the visibility of the left-side widget of the scrolled entry,
4442 * set by @elm_entry_icon_set().
4444 * @param obj The scrolled entry object
4445 * @param setting EINA_TRUE if the object should be displayed,
4446 * EINA_FALSE if not.
4451 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4453 ELM_CHECK_WIDTYPE(obj, widtype);
4454 Widget_Data *wd = elm_widget_data_get(obj);
4455 if ((!wd) || (!wd->icon)) return;
4457 evas_object_hide(wd->icon);
4459 evas_object_show(wd->icon);
4464 * This sets a widget to be displayed to the end of a scrolled entry.
4466 * @param obj The scrolled entry object
4467 * @param end The widget to display on the right side of the scrolled
4470 * @note A previously set widget will be destroyed.
4471 * @note If the object being set does not have minimum size hints set,
4472 * it won't get properly displayed.
4475 * @see elm_entry_icon_set
4478 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4480 ELM_CHECK_WIDTYPE(obj, widtype);
4481 Widget_Data *wd = elm_widget_data_get(obj);
4484 EINA_SAFETY_ON_NULL_RETURN(end);
4485 if (wd->end == end) return;
4486 if (wd->end) evas_object_del(wd->end);
4488 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4490 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4491 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4496 * Gets the endmost widget of the scrolled entry. This object is owned
4497 * by the scrolled entry and should not be modified.
4499 * @param obj The scrolled entry object
4500 * @return the right widget inside the scroller
4505 elm_entry_end_get(const Evas_Object *obj)
4507 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4508 Widget_Data *wd = elm_widget_data_get(obj);
4509 if (!wd) return NULL;
4514 * Unset the endmost widget of the scrolled entry, unparenting and
4517 * @param obj The scrolled entry object
4518 * @return the previously set icon sub-object of this entry, on
4521 * @see elm_entry_icon_set()
4526 elm_entry_end_unset(Evas_Object *obj)
4528 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4529 Widget_Data *wd = elm_widget_data_get(obj);
4530 Evas_Object *ret = NULL;
4531 if (!wd) return NULL;
4534 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4535 if (!edje) return NULL;
4537 edje_object_part_unswallow(edje, wd->end);
4538 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4546 * Sets the visibility of the end widget of the scrolled entry, set by
4547 * @elm_entry_end_set().
4549 * @param obj The scrolled entry object
4550 * @param setting EINA_TRUE if the object should be displayed,
4551 * EINA_FALSE if not.
4556 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4558 ELM_CHECK_WIDTYPE(obj, widtype);
4559 Widget_Data *wd = elm_widget_data_get(obj);
4560 if ((!wd) || (!wd->end)) return;
4562 evas_object_hide(wd->end);
4564 evas_object_show(wd->end);
4569 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4571 * @param obj The scrolled entry object
4572 * @param h The horizontal scrollbar policy to apply
4573 * @param v The vertical scrollbar policy to apply
4578 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4580 ELM_CHECK_WIDTYPE(obj, widtype);
4581 Widget_Data *wd = elm_widget_data_get(obj);
4582 const Elm_Scroller_Policy map[3] =
4584 ELM_SMART_SCROLLER_POLICY_AUTO,
4585 ELM_SMART_SCROLLER_POLICY_ON,
4586 ELM_SMART_SCROLLER_POLICY_OFF
4591 elm_smart_scroller_policy_set(wd->scroller,
4597 * This enables/disables bouncing within the entry.
4599 * @param obj The scrolled entry object
4600 * @param h The horizontal bounce state
4601 * @param v The vertical bounce state
4606 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4608 ELM_CHECK_WIDTYPE(obj, widtype);
4609 Widget_Data *wd = elm_widget_data_get(obj);
4611 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4615 * Get the bounce mode
4617 * @param obj The Entry object
4618 * @param h_bounce Allow bounce horizontally
4619 * @param v_bounce Allow bounce vertically
4624 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4626 ELM_CHECK_WIDTYPE(obj, widtype);
4627 Widget_Data *wd = elm_widget_data_get(obj);
4629 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4632 EINA_DEPRECATED EAPI void
4633 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4635 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);
4639 * Set background color of the entry
4641 * @param obj The entry object
4642 * @param r Red property background color of The entry object
4643 * @param g Green property background color of The entry object
4644 * @param b Blue property background color of The entry object
4645 * @param a Alpha property background alpha of The entry object
4649 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4651 ELM_CHECK_WIDTYPE(obj, widtype);
4652 Widget_Data *wd = elm_widget_data_get(obj);
4653 evas_object_color_set(wd->bg, r, g, b, a);
4655 if (wd->bgcolor == EINA_FALSE)
4658 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4663 * Set whether entry should support auto capitalization
4665 * @param obj The entry object
4666 * @param on If true, entry suports auto capitalization.
4671 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4673 ELM_CHECK_WIDTYPE(obj, widtype);
4674 Widget_Data *wd = elm_widget_data_get(obj);
4678 wd->autocapital = EINA_FALSE;
4680 wd->autocapital = autocap;
4682 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4683 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4684 wd->autocapital = EINA_FALSE;
4686 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
4690 * Set whether entry should support auto period
4692 * @param obj The entry object
4693 * @param on If true, entry suports auto period.
4698 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4700 ELM_CHECK_WIDTYPE(obj, widtype);
4701 Widget_Data *wd = elm_widget_data_get(obj);
4705 wd->autoperiod = EINA_FALSE;
4707 wd->autoperiod = autoperiod;
4709 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4710 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4711 wd->autoperiod = EINA_FALSE;
4713 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4717 * Set whether entry should enable the return key on soft keyboard automatically
4719 * @param obj The entry object
4720 * @param on If true, entry enables the return key on soft keyboard automatically.
4725 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
4727 ELM_CHECK_WIDTYPE(obj, widtype);
4728 Widget_Data *wd = elm_widget_data_get(obj);
4731 wd->autoreturnkey = on;
4732 _check_enable_returnkey(obj);
4736 * This sets the attribute to show the input panel automatically.
4738 * @param obj The entry object
4739 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4744 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4746 ELM_CHECK_WIDTYPE(obj, widtype);
4747 Widget_Data *wd = elm_widget_data_get(obj);
4750 wd->input_panel_enable = enabled;
4751 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4755 * Set the input panel layout of the entry
4757 * @param obj The entry object
4758 * @param layout the layout to set
4763 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4765 ELM_CHECK_WIDTYPE(obj, widtype);
4766 Widget_Data *wd = elm_widget_data_get(obj);
4769 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4772 wd->input_panel_layout = layout;
4774 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4778 * Get the input method context in the entry widget
4780 * @param obj The entry object
4781 * @return The input method context
4785 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
4787 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4788 Widget_Data *wd = elm_widget_data_get(obj);
4789 if (!wd || !wd->ent) return NULL;
4791 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4795 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
4797 Widget_Data *wd = elm_widget_data_get(obj);
4802 Evas_Coord max_w = 9999, max_h = 9999;
4803 const char* key_data = NULL;
4805 wd->matchlist_threshold = 1;
4806 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
4807 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
4808 elm_hover_target_set(wd->hover, obj);
4809 elm_object_style_set(wd->hover, "matchlist");
4811 wd->layout = elm_layout_add(wd->hover);
4812 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
4813 wd->list = elm_list_add(wd->layout);
4814 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
4815 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
4816 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
4817 elm_object_style_set(wd->list, "matchlist");
4819 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
4820 if (key_data) max_w = atoi(key_data);
4821 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
4822 if (key_data) max_h = atoi(key_data);
4824 elm_list_go(wd->list);
4825 evas_object_size_hint_max_set(wd->list, max_w, max_h);
4826 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
4827 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
4828 elm_hover_content_set(wd->hover, "bottom", wd->layout);
4830 wd->match_list = match_list;
4835 evas_object_del(wd->hover);
4837 wd->match_list = NULL;
4840 wd->matchlist_case_sensitive = case_sensitive;
4844 * Set the magnifier style of the entry
4846 * @param obj The entry object
4847 * @param type the magnifier style to set
4852 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4854 ELM_CHECK_WIDTYPE(obj, widtype);
4855 Widget_Data *wd = elm_widget_data_get(obj);
4858 wd->mgf_type = type;
4859 _magnifier_create(obj);
4863 * Set wrap width of the entry
4865 * @param obj The entry object
4866 * @param w The wrap width in pixels at a minimum where words need to wrap
4870 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
4872 Widget_Data *wd = elm_widget_data_get(obj);
4873 if (wd->wrap_w == w) return;
4879 * get wrap width of the entry
4881 * @param obj The entry object
4882 * @return The wrap width in pixels at a minimum where words need to wrap
4886 elm_entry_wrap_width_get(const Evas_Object *obj)
4888 Widget_Data *wd = elm_widget_data_get(obj);
4893 * Set the font size on the entry object
4895 * @param obj The entry object
4896 * @param size font size
4901 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
4903 ELM_CHECK_WIDTYPE(obj, widtype);
4904 Widget_Data *wd = elm_widget_data_get(obj);
4905 Eina_Strbuf *fontbuf = NULL;
4910 t = eina_stringshare_add(elm_entry_entry_get(obj));
4911 fontbuf = eina_strbuf_new();
4912 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
4914 if (fontsize == 0) removeflag = 1; // remove fontsize tag
4916 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
4918 elm_entry_entry_set(obj, t);
4922 eina_strbuf_free(fontbuf);
4923 eina_stringshare_del(t);
4927 * Set the text color on the entry object
4929 * @param obj The entry object
4930 * @param r Red property background color of The entry object
4931 * @param g Green property background color of The entry object
4932 * @param b Blue property background color of The entry object
4933 * @param a Alpha property background alpha of The entry object
4938 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4940 ELM_CHECK_WIDTYPE(obj, widtype);
4941 Widget_Data *wd = elm_widget_data_get(obj);
4942 Eina_Strbuf *colorbuf = NULL;
4947 t = eina_stringshare_add(elm_entry_entry_get(obj));
4949 if (len <= 0) return;
4950 colorbuf = eina_strbuf_new();
4951 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
4953 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
4955 elm_entry_entry_set(obj, t);
4959 eina_strbuf_free(colorbuf);
4960 eina_stringshare_del(t);
4964 * Set the text align on the entry object
4966 * @param obj The entry object
4967 * @param align align mode
4972 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
4974 ELM_CHECK_WIDTYPE(obj, widtype);
4975 Widget_Data *wd = elm_widget_data_get(obj);
4980 t = eina_stringshare_add(elm_entry_entry_get(obj));
4982 if (len <= 0) return;
4984 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
4985 elm_entry_entry_set(obj, t);
4989 eina_stringshare_del(t);