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 *longpress_timer;
129 Ecore_Timer *delay_write;
130 /* for deferred appending */
131 Ecore_Idler *append_text_idler;
132 char *append_text_left;
133 int append_text_position;
135 /* Only for clipboard */
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 Ecore_Job *hovdeljob;
150 Mod_Api *api; // module api if supplied
152 Elm_Scroller_Policy policy_h, policy_v;
153 Elm_Wrap_Type linewrap;
154 Eina_Bool changed : 1;
155 Eina_Bool single_line : 1;
156 Eina_Bool password : 1;
157 Eina_Bool editable : 1;
158 Eina_Bool selection_asked : 1;
159 Eina_Bool have_selection : 1;
160 Eina_Bool selmode : 1;
161 Eina_Bool deferred_cur : 1;
162 Eina_Bool cur_changed : 1;
163 Eina_Bool disabled : 1;
164 Eina_Bool double_clicked : 1;
165 Eina_Bool long_pressed : 1;
166 Eina_Bool context_menu : 1;
167 Eina_Bool drag_selection_asked : 1;
168 Eina_Bool bgcolor : 1;
169 Eina_Bool can_write : 1;
170 Eina_Bool autosave : 1;
171 Eina_Bool textonly : 1;
172 Eina_Bool usedown : 1;
173 Eina_Bool scroll : 1;
174 Eina_Bool autoreturnkey : 1;
175 Eina_Bool input_panel_enable : 1;
176 Eina_Bool autocapital : 1;
177 Elm_Input_Panel_Layout input_panel_layout;
178 Eina_Bool autoperiod : 1;
179 Eina_Bool matchlist_list_clicked : 1;
180 Eina_Bool matchlist_case_sensitive : 1;
181 int matchlist_threshold;
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->bg) evas_object_del(wd->bg);
593 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
594 if (wd->append_text_idler)
596 ecore_idler_del(wd->append_text_idler);
597 free(wd->append_text_left);
598 wd->append_text_left = NULL;
599 wd->append_text_idler = NULL;
601 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
602 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
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 (!wd->deferred_recalc_job)
716 Evas_Coord cx, cy, cw, ch;
717 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
721 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
722 wd->cur_changed = EINA_FALSE;
726 wd->deferred_cur = EINA_TRUE;
730 _elm_win_recalc_job(void *data)
732 Widget_Data *wd = elm_widget_data_get(data);
733 Evas_Coord minh = -1, resw = -1, minw = -1;
735 wd->deferred_recalc_job = NULL;
737 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
738 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
739 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
742 /* This is a hack to workaround the way min size hints are treated.
743 * If the minimum width is smaller than the restricted width, it means
744 * the mininmum doesn't matter. */
747 Evas_Coord ominw = -1;
748 evas_object_size_hint_min_get(data, &ominw, NULL);
751 evas_object_size_hint_min_set(data, minw, minh);
753 evas_object_size_hint_max_set(data, -1, minh);
755 evas_object_size_hint_max_set(data, -1, -1);
757 if (wd->deferred_cur)
759 Evas_Coord cx, cy, cw, ch;
760 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
764 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
765 wd->cur_changed = EINA_FALSE;
771 _sizing_eval(Evas_Object *obj)
773 Widget_Data *wd = elm_widget_data_get(obj);
774 Evas_Coord minw = -1, minh = -1;
775 Evas_Coord resw, resh;
778 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
781 if ((resw == wd->lastw) && (!wd->changed)) return;
782 wd->changed = EINA_FALSE;
786 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
788 evas_object_resize(wd->scroller, resw, resh);
789 edje_object_size_min_calc
790 (elm_smart_scroller_edje_object_get(wd->scroller),
792 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
793 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
796 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
798 if ((minw > 0) && (vw < minw)) vw = minw;
799 if (minh > vh) vh = minh;
801 if (wd->single_line) h = vmh + minh;
803 evas_object_resize(wd->ent, vw, vh);
804 evas_object_size_hint_min_set(obj, w, h);
806 evas_object_size_hint_max_set(obj, -1, h);
808 evas_object_size_hint_max_set(obj, -1, -1);
812 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
813 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
818 if (!wd->changed) return;
819 wd->changed = EINA_FALSE;
823 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
825 edje_object_size_min_calc(wd->ent, &minw, &minh);
828 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
830 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
832 if ((minw > 0) && (vw < minw)) vw = minw;
833 if (minh > 0) vh = minh;
835 evas_object_resize(wd->ent, vw, vh);
836 edje_object_size_min_calc
837 (elm_smart_scroller_edje_object_get(wd->scroller),
839 if (wd->single_line) h = vmh + minh;
841 evas_object_size_hint_min_set(obj, w, h);
843 evas_object_size_hint_max_set(obj, -1, h);
845 evas_object_size_hint_max_set(obj, -1, -1);
849 edje_object_size_min_calc(wd->ent, &minw, &minh);
852 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
853 evas_object_size_hint_min_set(obj, minw, minh);
855 evas_object_size_hint_max_set(obj, -1, minh);
857 evas_object_size_hint_max_set(obj, -1, -1);
861 _recalc_cursor_geometry(obj);
865 _check_enable_returnkey(Evas_Object *obj)
867 Widget_Data *wd = elm_widget_data_get(obj);
870 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
873 if (!wd->autoreturnkey) return;
875 if (_entry_length_get(obj) == 0)
877 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
881 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
886 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
888 Widget_Data *wd = elm_widget_data_get(obj);
889 Evas_Object *top = elm_widget_top_get(obj);
891 if (!wd->editable) return;
892 if (elm_widget_focus_get(obj))
894 printf("[Elm_entry::Focused] obj : %p\n", obj);
895 evas_object_focus_set(wd->ent, EINA_TRUE);
896 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
897 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
898 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
899 _check_enable_returnkey(obj);
900 wd->mgf_type = _ENTRY_MAGNIFIER_FILLWIDTH;
901 _magnifier_create(obj);
905 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
906 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
907 evas_object_focus_set(wd->ent, EINA_FALSE);
908 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
909 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
911 if ((wd->api) && (wd->api->obj_hidemenu))
913 wd->api->obj_hidemenu(obj);
919 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
921 Widget_Data *wd = elm_widget_data_get(obj);
923 edje_object_signal_emit(wd->ent, emission, source);
925 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
930 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
932 Widget_Data *wd = elm_widget_data_get(obj);
934 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
936 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
937 emission, source, func_cb, data);
941 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
943 Widget_Data *wd = elm_widget_data_get(obj);
944 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
947 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
948 emission, source, func_cb, data);
952 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
954 Widget_Data *wd = elm_widget_data_get(obj);
955 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
959 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
961 Widget_Data *wd = elm_widget_data_get(obj);
963 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
967 _show_region_hook(void *data, Evas_Object *obj)
969 Widget_Data *wd = elm_widget_data_get(data);
970 Evas_Coord x, y, w, h;
972 elm_widget_show_region_get(obj, &x, &y, &w, &h);
974 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
978 _hoversel_position(Evas_Object *obj)
980 Widget_Data *wd = elm_widget_data_get(obj);
981 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
986 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
995 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
997 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1000 cx += (cw - mw) / 2;
1005 cy += (ch - mh) / 2;
1008 evas_object_move(wd->hoversel, x + cx, y + cy);
1009 evas_object_resize(wd->hoversel, cw, ch);
1013 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1015 Widget_Data *wd = elm_widget_data_get(data);
1017 if (wd->hoversel) _hoversel_position(data);
1021 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1023 Widget_Data *wd = elm_widget_data_get(data);
1030 else if (wd->scroll)
1032 Evas_Coord vw = 0, vh = 0;
1034 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1035 if (vw < wd->entmw) vw = wd->entmw;
1036 if (vh < wd->entmh) vh = wd->entmh;
1037 evas_object_resize(wd->ent, vw, vh);
1039 if (wd->hoversel) _hoversel_position(data);
1043 _hover_del(void *data)
1045 Widget_Data *wd = elm_widget_data_get(data);
1050 evas_object_del(wd->hoversel);
1051 wd->hoversel = NULL;
1053 wd->hovdeljob = NULL;
1057 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1059 Widget_Data *wd = elm_widget_data_get(data);
1062 if (wd->hoversel) evas_object_hide(wd->hoversel);
1065 if (!_elm_config->desktop_entry)
1068 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1071 elm_widget_scroll_freeze_pop(data);
1072 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1073 wd->hovdeljob = ecore_job_add(_hover_del, data);
1077 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1079 Widget_Data *wd = elm_widget_data_get(data);
1081 wd->selmode = EINA_TRUE;
1082 edje_object_part_text_select_none(wd->ent, "elm.text");
1083 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1084 edje_object_part_text_select_all(wd->ent, "elm.text");
1085 elm_object_scroll_freeze_pop(data);
1089 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1091 Widget_Data *wd = elm_widget_data_get(data);
1093 wd->selmode = EINA_TRUE;
1094 edje_object_part_text_select_none(wd->ent, "elm.text");
1095 if (!_elm_config->desktop_entry)
1098 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1100 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1101 if (!_elm_config->desktop_entry)
1102 elm_object_scroll_freeze_pop(data);
1103 //elm_widget_scroll_hold_push(data);
1107 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1109 Widget_Data *wd = elm_widget_data_get(data);
1111 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1112 if (wd->sel_notify_handler)
1114 #ifdef HAVE_ELEMENTARY_X
1115 Elm_Sel_Format formats;
1116 wd->selection_asked = EINA_TRUE;
1117 formats = ELM_SEL_FORMAT_MARKUP;
1119 formats |= ELM_SEL_FORMAT_IMAGE;
1120 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1126 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1128 Widget_Data *wd = elm_widget_data_get(obj);
1132 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1133 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
1134 if (seltype == ELM_SEL_CLIPBOARD)
1135 eina_stringshare_replace(&wd->cut_sel, sel);
1139 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1141 Widget_Data *wd = elm_widget_data_get(data);
1144 wd->selmode = EINA_FALSE;
1145 if (!_elm_config->desktop_entry)
1146 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1147 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1148 if (!_elm_config->desktop_entry)
1149 elm_widget_scroll_hold_pop(data);
1150 _store_selection(ELM_SEL_CLIPBOARD, data);
1151 edje_object_part_text_insert(wd->ent, "elm.text", "");
1152 edje_object_part_text_select_none(wd->ent, "elm.text");
1156 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1158 Widget_Data *wd = elm_widget_data_get(data);
1160 wd->selmode = EINA_FALSE;
1161 if (!_elm_config->desktop_entry)
1163 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1164 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1165 elm_widget_scroll_hold_pop(data);
1167 _store_selection(ELM_SEL_CLIPBOARD, data);
1168 // edje_object_part_text_select_none(wd->ent, "elm.text");
1172 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1174 Widget_Data *wd = elm_widget_data_get(data);
1176 wd->selmode = EINA_FALSE;
1177 if (!_elm_config->desktop_entry)
1178 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1179 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1180 if (!_elm_config->desktop_entry)
1181 elm_widget_scroll_hold_pop(data);
1182 edje_object_part_text_select_none(wd->ent, "elm.text");
1186 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1188 Widget_Data *wd = elm_widget_data_get(data);
1192 #ifdef HAVE_ELEMENTARY_X
1193 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1195 cnpwidgetdata = data;
1196 elm_cbhm_helper_init(obj);
1197 if (elm_entry_cnp_textonly_get(obj))
1198 elm_cbhm_send_raw_data("show0");
1200 elm_cbhm_send_raw_data("show1");
1206 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1208 Widget_Data *wd = elm_widget_data_get(data);
1210 cnpwidgetdata = data;
1216 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1218 Elm_Entry_Context_Menu_Item *it = data;
1219 Evas_Object *obj2 = it->obj;
1220 if (it->func) it->func(it->data, obj2, NULL);
1224 _menu_press(Evas_Object *obj)
1226 Widget_Data *wd = elm_widget_data_get(obj);
1229 const Elm_Entry_Context_Menu_Item *it;
1231 if ((wd->api) && (wd->api->obj_longpress))
1233 wd->api->obj_longpress(obj);
1235 else if (wd->context_menu)
1237 const char *context_menu_orientation;
1239 if (wd->hoversel) evas_object_del(wd->hoversel);
1240 else elm_widget_scroll_freeze_push(obj);
1241 wd->hoversel = elm_hoversel_add(obj);
1242 context_menu_orientation = edje_object_data_get
1243 (wd->ent, "context_menu_orientation");
1244 if ((context_menu_orientation) &&
1245 (!strcmp(context_menu_orientation, "horizontal")))
1246 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1247 elm_object_style_set(wd->hoversel, "entry");
1248 elm_widget_sub_object_add(obj, wd->hoversel);
1249 elm_object_text_set(wd->hoversel, "Text");
1250 top = elm_widget_top_get(obj);
1251 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1252 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1256 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1258 if (1) // need way to detect if someone has a selection
1261 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1265 if ((!wd->password) && (wd->editable))
1266 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1267 _clipboard_menu, obj);
1274 if (wd->have_selection)
1276 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1279 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1282 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1286 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1287 _clipboard_menu, obj);
1291 EINA_LIST_FOREACH(wd->items, l, it)
1293 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1294 it->icon_type, _item_clicked, it);
1298 _hoversel_position(obj);
1299 evas_object_show(wd->hoversel);
1300 elm_hoversel_hover_begin(wd->hoversel);
1302 if (!_elm_config->desktop_entry)
1304 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1305 edje_object_part_text_select_abort(wd->ent, "elm.text");
1311 _magnifier_hide(void *data)
1313 Widget_Data *wd = elm_widget_data_get(data);
1316 evas_object_hide(wd->mgf_bg);
1317 evas_object_hide(wd->mgf_clip);
1321 _magnifier_show(void *data)
1323 Widget_Data *wd = elm_widget_data_get(data);
1326 evas_object_show(wd->mgf_bg);
1327 evas_object_show(wd->mgf_clip);
1331 _magnifier_move(void *data)
1333 Widget_Data *wd = elm_widget_data_get(data);
1336 Evas_Coord x, y, w, h, fs;
1337 Evas_Coord cx, cy, cw, ch, ox, oy;
1339 evas_object_geometry_get(data, &x, &y, &w, &h);
1340 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1343 fs = elm_finger_size_get();
1345 if ((cy + y) - wd->mgf_height - fs < 0)
1346 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1348 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1349 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1350 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1351 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1355 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);
1359 _magnifier_create(void *data)
1361 Widget_Data *wd = elm_widget_data_get(data);
1362 Evas_Coord x, y, w, h;
1363 const char* key_data = NULL;
1369 evas_object_image_source_unset(wd->mgf_proxy);
1370 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1371 evas_object_hide(wd->mgf_proxy);
1372 evas_object_clip_unset(wd->mgf_proxy);
1373 evas_object_del(wd->mgf_proxy);
1375 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1376 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1378 evas_object_geometry_get(data, &x, &y, &w, &h);
1379 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1381 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1382 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1383 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1384 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1388 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1389 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1390 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1392 key_data = edje_object_data_get(wd->mgf_bg, "height");
1393 if (key_data) wd->mgf_height = atoi(key_data);
1394 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1395 if (key_data) wd->mgf_scale = atof(key_data);
1397 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1398 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1400 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1401 evas_object_image_source_set(wd->mgf_proxy, data);
1402 evas_object_resize(wd->mgf_proxy, w * wd->mgf_scale, h * wd->mgf_scale);
1403 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, w * wd->mgf_scale, h * wd->mgf_scale);
1404 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1405 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1406 evas_object_show(wd->mgf_proxy);
1407 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1409 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1410 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1414 _long_press(void *data)
1416 Widget_Data *wd = elm_widget_data_get(data);
1417 if (!wd) return ECORE_CALLBACK_CANCEL;
1419 wd->long_pressed = EINA_TRUE;
1421 if (wd->longpress_timer)
1423 ecore_timer_del(wd->longpress_timer);
1424 wd->longpress_timer = NULL;
1427 _cancel(data, NULL, NULL);
1429 _magnifier_create(data);
1430 _magnifier_move(data);
1431 _magnifier_show(data);
1432 elm_object_scroll_freeze_push(data);
1434 wd->longpress_timer = NULL;
1435 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1436 return ECORE_CALLBACK_CANCEL;
1440 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1442 Widget_Data *wd = elm_widget_data_get(data);
1443 Evas_Event_Mouse_Down *ev = event_info;
1445 if (wd->disabled) return;
1446 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1447 wd->downx = ev->canvas.x;
1448 wd->downy = ev->canvas.y;
1449 wd->long_pressed = EINA_FALSE;
1450 if (ev->button == 1)
1452 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1453 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1458 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1460 Widget_Data *wd = elm_widget_data_get(data);
1461 Evas_Event_Mouse_Up *ev = event_info;
1463 if (wd->disabled) return;
1464 if (ev->button == 1)
1466 if (wd->longpress_timer)
1468 ecore_timer_del(wd->longpress_timer);
1469 wd->longpress_timer = NULL;
1472 if (!wd->double_clicked)
1474 if ((wd->api) && (wd->api->obj_mouseup))
1476 wd->api->obj_mouseup(data);
1480 _magnifier_hide(data);
1481 elm_object_scroll_freeze_pop(data);
1483 if (wd->long_pressed)
1489 else if (ev->button == 3)
1497 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1499 Widget_Data *wd = elm_widget_data_get(data);
1500 Evas_Event_Mouse_Move *ev = event_info;
1502 if (wd->disabled) return;
1505 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1507 if (wd->longpress_timer)
1509 ecore_timer_del(wd->longpress_timer);
1510 wd->longpress_timer = NULL;
1513 else if (wd->longpress_timer)
1517 dx = wd->downx - ev->cur.canvas.x;
1519 dy = wd->downy - ev->cur.canvas.y;
1522 ((_elm_config->finger_size / 2) *
1523 (_elm_config->finger_size / 2)))
1525 ecore_timer_del(wd->longpress_timer);
1526 wd->longpress_timer = NULL;
1530 else if (wd->longpress_timer)
1534 dx = wd->downx - ev->cur.canvas.x;
1536 dy = wd->downy - ev->cur.canvas.y;
1539 ((_elm_config->finger_size / 2) *
1540 (_elm_config->finger_size / 2)))
1542 ecore_timer_del(wd->longpress_timer);
1543 wd->longpress_timer = NULL;
1547 if (ev->buttons == 1)
1549 if (wd->long_pressed)
1551 _magnifier_show(data);
1552 _magnifier_move(data);
1558 _getbase(Evas_Object *obj)
1560 Widget_Data *wd = elm_widget_data_get(obj);
1561 if (!wd) return "base";
1564 if (wd->password) return "base-password";
1567 if (wd->single_line) return "base-single";
1570 switch (wd->linewrap)
1573 return "base-charwrap";
1576 case ELM_WRAP_MIXED:
1577 return "base-mixedwrap";
1580 return "base-nowrap";
1587 if (wd->password) return "base-password";
1590 if (wd->single_line) return "base-single-noedit";
1593 switch (wd->linewrap)
1596 return "base-noedit-charwrap";
1598 return "base-noedit";
1599 case ELM_WRAP_MIXED:
1600 return "base-noedit-mixedwrap";
1603 return "base-nowrap-noedit";
1613 _entry_length_get(Evas_Object *obj)
1616 const char *str = elm_entry_entry_get(obj);
1619 char *plain_str = _elm_util_mkup_to_text(str);
1620 if (!plain_str) return 0;
1622 len = strlen(plain_str);
1629 _matchlist_show(void *data)
1631 Widget_Data *wd = elm_widget_data_get(data);
1632 const char *text = NULL;
1634 char *str_list = NULL, *str_result = NULL;
1635 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1638 Eina_Bool textfound = EINA_FALSE;
1641 if (elm_widget_disabled_get(data)) return;
1643 wd->matchlist_job = NULL;
1645 if (wd->matchlist_list_clicked)
1647 evas_object_hide(wd->hover);
1648 wd->matchlist_list_clicked = EINA_FALSE;
1651 text = elm_entry_entry_get(data);
1654 textlen = strlen(text);
1656 if (textlen < wd->matchlist_threshold)
1658 evas_object_hide(wd->hover);
1662 evas_object_hide(wd->hover);
1666 elm_list_clear(wd->list);
1667 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1669 if (wd->matchlist_case_sensitive)
1670 str_result = strstr(str_list, text);
1672 str_result = strcasestr(str_list, text);
1676 str_mkup = malloc(strlen(str_list) + 16);
1677 if (str_mkup == NULL) return;
1679 textlen = strlen(str_list) - strlen(str_result);
1680 str_front = malloc(textlen + 1);
1681 if (str_front == NULL) return;
1683 memset(str_front, 0, textlen + 1);
1684 strncpy(str_front, str_list, textlen);
1686 textlen = strlen(text);
1687 str_mid = malloc(textlen + 1);
1688 if (str_mid == NULL) return;
1690 memset(str_mid, 0, textlen + 1);
1691 strncpy(str_mid, str_list + strlen(str_front), textlen);
1693 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1695 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1697 if (str_mkup) free(str_mkup);
1698 if (str_front) free(str_front);
1699 if (str_mid) free(str_mid);
1701 textfound=EINA_TRUE;
1710 elm_list_go(wd->list);
1711 evas_object_show(wd->hover);
1712 evas_object_raise(wd->hover);
1716 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1718 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1719 Widget_Data *wd = elm_widget_data_get(data);
1720 if ((it == NULL) || (wd == NULL))
1723 const char *text = elm_list_item_label_get(it);
1724 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1729 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1730 elm_entry_cursor_end_set(data);
1731 wd->matchlist_list_clicked = EINA_TRUE;
1733 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1736 elm_widget_focus_set(data, EINA_TRUE);
1740 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
1742 Widget_Data *wd = elm_widget_data_get(obj);
1747 Evas_Coord max_w = 9999, max_h = 9999;
1748 const char* key_data = NULL;
1750 wd->matchlist_threshold = 1;
1751 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
1752 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
1753 elm_hover_target_set(wd->hover, obj);
1754 elm_object_style_set(wd->hover, "matchlist");
1756 wd->layout = elm_layout_add(wd->hover);
1757 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
1758 wd->list = elm_list_add(wd->layout);
1759 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
1760 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1761 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
1762 elm_object_style_set(wd->list, "matchlist");
1764 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
1765 if (key_data) max_w = atoi(key_data);
1766 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
1767 if (key_data) max_h = atoi(key_data);
1769 elm_list_go(wd->list);
1770 evas_object_size_hint_max_set(wd->list, max_w, max_h);
1771 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
1772 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
1773 elm_hover_content_set(wd->hover, "bottom", wd->layout);
1775 wd->match_list = match_list;
1780 evas_object_del(wd->hover);
1782 wd->match_list = NULL;
1785 wd->matchlist_case_sensitive = case_sensitive;
1789 _entry_changed_common_handling(void *data, const char *event)
1791 Widget_Data *wd = elm_widget_data_get(data);
1794 wd->changed = EINA_TRUE;
1795 /* Reset the size hints which are no more relevant.
1796 * Keep the height, this is a hack, but doesn't really matter
1797 * cause we'll re-eval in a moment. */
1798 evas_object_size_hint_min_get(data, NULL, &minh);
1799 evas_object_size_hint_min_set(data, -1, minh);
1801 if (wd->text) eina_stringshare_del(wd->text);
1803 _check_enable_returnkey(data);
1804 evas_object_smart_callback_call(data, event, NULL);
1805 if (wd->delay_write)
1807 ecore_timer_del(wd->delay_write);
1808 wd->delay_write = NULL;
1811 if ((wd->single_line) && (wd->match_list))
1813 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1814 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1816 if ((!wd->autosave) || (!wd->file)) return;
1817 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1821 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1823 _entry_changed_common_handling(data, SIG_CHANGED);
1827 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1829 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1834 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1836 Widget_Data *wd = elm_widget_data_get(data);
1837 elm_object_scroll_freeze_push(data);
1839 if ((wd->api) && (wd->api->obj_hidemenu))
1841 wd->api->obj_hidemenu(data);
1844 _magnifier_create(data);
1845 _magnifier_move(data);
1846 _magnifier_show(data);
1850 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1852 Widget_Data *wd = elm_widget_data_get(data);
1853 elm_object_scroll_freeze_pop(data);
1855 if (wd->have_selection)
1857 _magnifier_hide(data);
1863 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1865 _magnifier_move(data);
1866 _magnifier_show(data);
1870 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1872 _magnifier_hide(data);
1877 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1879 Widget_Data *wd = elm_widget_data_get(data);
1883 EINA_LIST_FOREACH(entries, l, entry)
1885 if (entry != data) elm_entry_select_none(entry);
1887 wd->have_selection = EINA_TRUE;
1888 wd->selmode = EINA_TRUE;
1889 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1890 #ifdef HAVE_ELEMENTARY_X
1891 if (wd->sel_notify_handler)
1893 const char *txt = elm_entry_selection_get(data);
1896 top = elm_widget_top_get(data);
1897 if ((top) && (elm_win_xwindow_get(top)))
1898 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1904 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1906 Evas_Coord cx, cy, cw, ch;
1907 Widget_Data *wd = elm_widget_data_get(data);
1910 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1911 if (!wd->deferred_recalc_job)
1912 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1915 wd->deferred_cur = EINA_TRUE;
1919 wd->ch = ch + elm_finger_size_get();
1924 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1926 Evas_Coord cx, cy, cw, ch;
1927 Widget_Data *wd = elm_widget_data_get(data);
1929 wd->have_selection = EINA_TRUE;
1930 wd->selmode = EINA_TRUE;
1931 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1932 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1933 elm_entry_selection_get(data));
1935 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1936 if (!wd->deferred_recalc_job)
1937 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE);
1940 wd->deferred_cur = EINA_TRUE;
1944 wd->ch = ch + elm_finger_size_get();
1949 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1951 Widget_Data *wd = elm_widget_data_get(data);
1953 if (!wd->have_selection) return;
1954 wd->have_selection = EINA_FALSE;
1955 wd->selmode = EINA_FALSE;
1956 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1957 if (wd->sel_notify_handler)
1961 #ifdef HAVE_ELEMENTARY_X
1964 top = elm_widget_top_get(data);
1965 if ((top) && (elm_win_xwindow_get(top)))
1966 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1969 eina_stringshare_del(wd->cut_sel);
1974 #ifdef HAVE_ELEMENTARY_X
1977 top = elm_widget_top_get(data);
1978 if ((top) && (elm_win_xwindow_get(top)))
1979 elm_selection_clear(ELM_SEL_PRIMARY, data);
1984 if ((wd->api) && (wd->api->obj_hidemenu))
1986 wd->api->obj_hidemenu(data);
1991 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1993 Widget_Data *wd = elm_widget_data_get(data);
1995 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1996 if (wd->sel_notify_handler)
1998 #ifdef HAVE_ELEMENTARY_X
2001 top = elm_widget_top_get(data);
2002 if ((top) && (elm_win_xwindow_get(top)))
2004 wd->selection_asked = EINA_TRUE;
2005 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2013 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2015 Widget_Data *wd = elm_widget_data_get(data);
2017 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2018 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2019 elm_entry_selection_get(data));
2023 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2025 Widget_Data *wd = elm_widget_data_get(data);
2027 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2028 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2029 elm_entry_selection_get(data));
2030 edje_object_part_text_insert(wd->ent, "elm.text", "");
2031 wd->changed = EINA_TRUE;
2036 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2038 Widget_Data *wd = elm_widget_data_get(data);
2040 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2041 wd->cur_changed = EINA_TRUE;
2042 _recalc_cursor_geometry(data);
2046 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2048 Widget_Data *wd = elm_widget_data_get(data);
2053 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2055 Widget_Data *wd = elm_widget_data_get(data);
2060 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2062 Widget_Data *wd = elm_widget_data_get(data);
2063 Elm_Entry_Anchor_Info ei;
2064 char *buf2, *p, *p2, *n;
2066 p = strrchr(emission, ',');
2069 const Eina_List *geoms;
2073 while (p2 >= emission)
2075 if (*p2 == ',') break;
2079 buf2 = alloca(5 + p - p2);
2080 strncpy(buf2, p2, p - p2);
2083 ei.button = atoi(buf2);
2084 ei.x = ei.y = ei.w = ei.h = 0;
2086 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2089 Evas_Textblock_Rectangle *r;
2091 Evas_Coord px, py, x, y;
2093 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2094 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2095 EINA_LIST_FOREACH(geoms, l, r)
2097 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2098 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2109 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2114 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2116 Widget_Data *wd = elm_widget_data_get(data);
2121 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2123 Widget_Data *wd = elm_widget_data_get(data);
2128 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2130 Widget_Data *wd = elm_widget_data_get(data);
2135 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2137 Widget_Data *wd = elm_widget_data_get(data);
2139 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2143 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2145 Widget_Data *wd = elm_widget_data_get(data);
2147 wd->double_clicked = EINA_FALSE;
2148 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2150 if ((wd->api) && (wd->api->obj_hidemenu))
2152 wd->api->obj_hidemenu(data);
2157 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2159 Widget_Data *wd = elm_widget_data_get(data);
2161 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2165 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2167 Widget_Data *wd = elm_widget_data_get(data);
2169 wd->double_clicked = EINA_TRUE;
2170 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2173 #ifdef HAVE_ELEMENTARY_X
2175 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2177 Widget_Data *wd = elm_widget_data_get(data);
2178 Ecore_X_Event_Selection_Notify *ev = event;
2179 if (!wd) return ECORE_CALLBACK_PASS_ON;
2180 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2181 return ECORE_CALLBACK_PASS_ON;
2183 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2184 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2186 Ecore_X_Selection_Data_Text *text_data;
2188 text_data = ev->data;
2189 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2191 if (text_data->text)
2193 char *txt = _elm_util_text_to_mkup(text_data->text);
2197 elm_entry_entry_insert(data, txt);
2202 wd->selection_asked = EINA_FALSE;
2204 else if (ev->selection == ECORE_X_SELECTION_XDND)
2206 Ecore_X_Selection_Data_Text *text_data;
2208 text_data = ev->data;
2209 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2211 if (text_data->text)
2213 char *txt = _elm_util_text_to_mkup(text_data->text);
2217 /* Massive FIXME: this should be at the drag point */
2218 elm_entry_entry_insert(data, txt);
2223 wd->drag_selection_asked = EINA_FALSE;
2225 ecore_x_dnd_send_finished();
2228 return ECORE_CALLBACK_PASS_ON;
2232 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2235 Widget_Data *wd = elm_widget_data_get(data);
2236 Ecore_X_Event_Selection_Clear *ev = event;
2237 if (!wd) return ECORE_CALLBACK_PASS_ON;
2238 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2239 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2240 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2242 elm_entry_select_none(data);
2247 Evas_Object *top = elm_widget_top_get(data);
2248 Ecore_X_Event_Selection_Clear *ev = event;
2251 return ECORE_CALLBACK_PASS_ON;
2253 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2255 return ECORE_CALLBACK_PASS_ON;
2258 if (cnpwidgetdata == data)
2260 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2264 return ECORE_CALLBACK_PASS_ON;
2268 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2273 wd = elm_widget_data_get(obj);
2274 if (!wd) return EINA_FALSE;
2275 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2277 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2278 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2279 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2280 EDJE_CURSOR_MAIN,drop->x,drop->y);
2281 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2282 elm_entry_entry_insert(obj, drop->data);
2283 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2284 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2290 static Evas_Object *
2291 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2293 Widget_Data *wd = elm_widget_data_get(data);
2296 Elm_Entry_Item_Provider *ip;
2298 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2300 o = ip->func(ip->data, data, item);
2303 if (!strncmp(item, "file://", 7))
2305 const char *fname = item + 7;
2307 o = evas_object_image_filled_add(evas_object_evas_get(data));
2308 evas_object_image_file_set(o, fname, NULL);
2309 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2311 evas_object_show(o);
2316 o = edje_object_add(evas_object_evas_get(data));
2317 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2321 o = edje_object_add(evas_object_evas_get(data));
2322 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2323 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2328 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2330 const char *srcstring = NULL;
2331 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2332 char *curlocater, *replocater;
2333 char *starttag, *endtag;
2334 int tagtxtlen = 0, insertflag = 0;
2336 srcstring = eina_strbuf_string_get(srcbuf);
2337 curlocater = strstr(srcstring, key);
2339 if (!curlocater || !srcstring)
2347 starttag = strchr(srcstring, '<');
2348 endtag = strchr(srcstring, '>');
2349 tagtxtlen = endtag - starttag;
2350 if (tagtxtlen <= 0) tagtxtlen = 0;
2351 if (starttag < curlocater && curlocater < endtag) break;
2352 if (endtag != NULL && endtag+1 != NULL)
2353 srcstring = endtag+1;
2356 } while (strlen(srcstring) > 1);
2358 if (starttag && endtag && tagtxtlen > strlen(key))
2360 repbuf = eina_strbuf_new();
2361 diffbuf = eina_strbuf_new();
2362 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2363 srcstring = eina_strbuf_string_get(repbuf);
2364 curlocater = strstr(srcstring, key);
2366 if (curlocater != NULL)
2368 replocater = curlocater + strlen(key) + 1;
2370 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2373 if (replocater-curlocater > strlen(key)+1)
2375 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2384 eina_strbuf_reset(repbuf);
2392 if (repbuf == NULL) repbuf = eina_strbuf_new();
2393 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2397 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2398 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2404 eina_strbuf_prepend(diffbuf, "<");
2405 eina_strbuf_append(diffbuf, ">");
2406 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2410 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2411 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2415 if (repbuf) eina_strbuf_free(repbuf);
2416 if (diffbuf) eina_strbuf_free(diffbuf);
2422 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2424 Eina_Strbuf *sharebuf = NULL;
2426 sharebuf = eina_strbuf_new();
2427 eina_strbuf_append(sharebuf, *srcstring);
2428 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2429 eina_stringshare_del(*srcstring);
2430 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2431 eina_strbuf_free(sharebuf);
2437 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2439 Widget_Data *wd = elm_widget_data_get(data);
2441 Elm_Entry_Text_Filter *tf;
2443 if (type == EDJE_TEXT_FILTER_FORMAT)
2446 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2448 tf->func(tf->data, data, text);
2454 /* This function is used to insert text by chunks in jobs */
2456 _text_append_idler(void *data)
2460 Evas_Object *obj = (Evas_Object *) data;
2461 Widget_Data *wd = elm_widget_data_get(obj);
2462 if (wd->text) eina_stringshare_del(wd->text);
2464 wd->changed = EINA_TRUE;
2466 start = wd->append_text_position;
2467 if(start + _CHUNK_SIZE < wd->append_text_len)
2469 wd->append_text_position = (start + _CHUNK_SIZE);
2470 /* Go to the start of the nearest codepoint, because we don't want
2471 * to cut it in the middle */
2472 eina_unicode_utf8_get_prev(wd->append_text_left,
2473 &wd->append_text_position);
2477 wd->append_text_position = wd->append_text_len;
2480 backup = wd->append_text_left[wd->append_text_position];
2481 wd->append_text_left[wd->append_text_position] = '\0';
2483 edje_object_part_text_append(wd->ent, "elm.text",
2484 wd->append_text_left + start);
2486 wd->append_text_left[wd->append_text_position] = backup;
2488 /* If there's still more to go, renew the idler, else, cleanup */
2489 if (wd->append_text_position < wd->append_text_len)
2491 return ECORE_CALLBACK_RENEW;
2495 free(wd->append_text_left);
2496 wd->append_text_left = NULL;
2497 wd->append_text_idler = NULL;
2498 return ECORE_CALLBACK_CANCEL;
2503 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2505 int i = 0, unit_size;
2506 int current_len = strlen(*text);
2507 char *new_text = *text;
2508 if (unit >= LENGTH_UNIT_LAST) return;
2511 if (*new_text == '<')
2513 while (*new_text != '>')
2516 if (!*new_text) break;
2523 if (*new_text == '&')
2525 while (*(new_text + index) != ';')
2528 if (!*(new_text + index)) break;
2532 index = evas_string_char_next_get(new_text, index, NULL);
2533 markup = malloc(index + 1);
2534 strncpy(markup, new_text, index);
2536 if (unit == LENGTH_UNIT_BYTE)
2537 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2538 else if (unit == LENGTH_UNIT_CHAR)
2539 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2545 if (can_add < unit_size)
2549 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2555 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
2556 current_len -= index;
2557 (*text)[current_len] = 0;
2562 can_add -= unit_size;
2567 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2571 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2574 ELM_CHECK_WIDTYPE(obj, widtype);
2575 if (item && strcmp(item, "default")) return;
2576 Widget_Data *wd = elm_widget_data_get(obj);
2578 if (!entry) entry = "";
2579 if (wd->text) eina_stringshare_del(wd->text);
2581 wd->changed = EINA_TRUE;
2583 /* Clear currently pending job if there is one */
2584 if (wd->append_text_idler)
2586 ecore_idler_del(wd->append_text_idler);
2587 free(wd->append_text_left);
2588 wd->append_text_left = NULL;
2589 wd->append_text_idler = NULL;
2592 len = strlen(entry);
2593 /* Split to ~_CHUNK_SIZE chunks */
2594 if (len > _CHUNK_SIZE)
2596 wd->append_text_left = (char *) malloc(len + 1);
2599 /* If we decided to use the idler */
2600 if (wd->append_text_left)
2602 /* Need to clear the entry first */
2603 edje_object_part_text_set(wd->ent, "elm.text", "");
2604 memcpy(wd->append_text_left, entry, len + 1);
2605 wd->append_text_position = 0;
2606 wd->append_text_len = len;
2607 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2611 edje_object_part_text_set(wd->ent, "elm.text", entry);
2616 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2618 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2619 Widget_Data *wd = elm_widget_data_get(obj);
2620 if (item && strcmp(item, "default")) return NULL;
2622 if (!wd) return NULL;
2626 return elm_entry_markup_to_utf8(wd->text);
2630 text = edje_object_part_text_get(wd->ent, "elm.text");
2633 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2636 eina_stringshare_replace(&wd->text, text);
2637 if (wd->password) return elm_entry_markup_to_utf8(wd->text);
2642 * This adds an entry to @p parent object.
2644 * @param parent The parent object
2645 * @return The new object or NULL if it cannot be created
2650 elm_entry_add(Evas_Object *parent)
2652 Evas_Object *obj, *top;
2656 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2658 ELM_SET_WIDTYPE(widtype, "entry");
2659 elm_widget_type_set(obj, "entry");
2660 elm_widget_sub_object_add(parent, obj);
2661 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2662 elm_widget_data_set(obj, wd);
2663 elm_widget_del_hook_set(obj, _del_hook);
2664 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2665 elm_widget_theme_hook_set(obj, _theme_hook);
2666 elm_widget_disable_hook_set(obj, _disable_hook);
2667 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2668 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2669 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2670 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2671 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2672 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2673 elm_widget_can_focus_set(obj, EINA_TRUE);
2674 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2675 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2676 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2678 wd->scroller = elm_smart_scroller_add(e);
2679 elm_widget_sub_object_add(obj, wd->scroller);
2680 elm_smart_scroller_widget_set(wd->scroller, obj);
2681 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2682 elm_widget_style_get(obj));
2683 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2684 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2685 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2686 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
2688 wd->linewrap = ELM_WRAP_WORD;
2689 wd->editable = EINA_TRUE;
2690 wd->disabled = EINA_FALSE;
2691 wd->context_menu = EINA_TRUE;
2692 wd->autosave = EINA_TRUE;
2693 wd->textonly = EINA_FALSE;
2694 wd->autoperiod = EINA_TRUE;
2696 wd->ent = edje_object_add(e);
2697 elm_widget_sub_object_add(obj, wd->ent);
2698 edje_object_item_provider_set(wd->ent, _get_item, obj);
2699 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2700 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2701 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2703 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2705 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2707 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2709 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2710 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2711 _signal_entry_changed, obj);
2712 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2713 _signal_preedit_changed, obj);
2714 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2715 _signal_handler_move_start, obj);
2716 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2717 _signal_handler_move_end, obj);
2718 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2719 _signal_handler_moving, obj);
2720 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2721 _signal_selection_start, obj);
2722 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2723 _signal_selection_end, obj);
2724 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2725 _signal_magnifier_changed, obj);
2726 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2727 _signal_selection_changed, obj);
2728 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2729 _signal_selection_cleared, obj);
2730 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2731 _signal_entry_paste_request, obj);
2732 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2733 _signal_entry_copy_notify, obj);
2734 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2735 _signal_entry_cut_notify, obj);
2736 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2737 _signal_cursor_changed, obj);
2738 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2739 _signal_anchor_down, obj);
2740 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2741 _signal_anchor_up, obj);
2742 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2743 _signal_anchor_clicked, obj);
2744 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2745 _signal_anchor_move, obj);
2746 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2747 _signal_anchor_in, obj);
2748 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2749 _signal_anchor_out, obj);
2750 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2751 _signal_key_enter, obj);
2752 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2753 _signal_mouse_down, obj);
2754 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2755 _signal_mouse_clicked, obj);
2756 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2757 _signal_mouse_double, obj);
2758 edje_object_part_text_set(wd->ent, "elm.text", "");
2759 if (_elm_config->desktop_entry)
2760 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2761 elm_widget_resize_object_set(obj, wd->ent);
2764 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2766 #ifdef HAVE_ELEMENTARY_X
2767 top = elm_widget_top_get(obj);
2768 if ((top) && (elm_win_xwindow_get(top)))
2770 wd->sel_notify_handler =
2771 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2772 _event_selection_notify, obj);
2773 wd->sel_clear_handler =
2774 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2775 _event_selection_clear, obj);
2778 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2779 _drag_drop_cb, NULL);
2782 entries = eina_list_prepend(entries, obj);
2784 // module - find module for entry
2785 wd->api = _module(obj);
2786 // if found - hook in
2787 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2789 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2790 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2791 // TODO: and save some bytes, making descriptions per-class and not instance!
2792 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2796 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2798 ELM_CHECK_WIDTYPE(obj, widtype);
2799 Widget_Data *wd = elm_widget_data_get(obj);
2801 ext_mod->cancel = _cancel;
2802 ext_mod->copy = _copy;
2803 ext_mod->cut = _cut;
2804 ext_mod->paste = _paste;
2805 ext_mod->select = _select;
2806 ext_mod->selectall = _selectall;
2807 ext_mod->ent = wd->ent;
2808 ext_mod->items = wd->items;
2809 ext_mod->longpress_timer = wd->longpress_timer;
2810 ext_mod->editable = wd->editable;
2811 ext_mod->have_selection = wd->have_selection;
2812 ext_mod->password = wd->password;
2813 ext_mod->selmode = wd->selmode;
2814 ext_mod->cnpinit = _cnpinit;
2815 ext_mod->context_menu = wd->context_menu;
2816 ext_mod->textonly = wd->textonly;
2820 * This sets the entry object not to line wrap. All input will
2821 * be on a single line, and the entry box will extend with user input.
2823 * @param obj The entry object
2824 * @param single_line If true, the text in the entry
2825 * will be on a single line.
2830 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2832 ELM_CHECK_WIDTYPE(obj, widtype);
2833 Widget_Data *wd = elm_widget_data_get(obj);
2835 if (wd->single_line == single_line) return;
2836 wd->single_line = single_line;
2837 wd->linewrap = ELM_WRAP_NONE;
2838 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2842 if (wd->single_line)
2843 elm_smart_scroller_policy_set(wd->scroller,
2844 ELM_SMART_SCROLLER_POLICY_OFF,
2845 ELM_SMART_SCROLLER_POLICY_OFF);
2848 const Elm_Scroller_Policy map[3] =
2850 ELM_SMART_SCROLLER_POLICY_AUTO,
2851 ELM_SMART_SCROLLER_POLICY_ON,
2852 ELM_SMART_SCROLLER_POLICY_OFF
2854 elm_smart_scroller_policy_set(wd->scroller,
2863 * This returns true if the entry has been set to single line mode.
2864 * See also elm_entry_single_line_set().
2866 * @param obj The entry object
2867 * @return single_line If true, the text in the entry is set to display
2873 elm_entry_single_line_get(const Evas_Object *obj)
2875 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2876 Widget_Data *wd = elm_widget_data_get(obj);
2877 if (!wd) return EINA_FALSE;
2878 return wd->single_line;
2882 * This sets the entry object to password mode. All text entered
2883 * and/or displayed within the widget will be replaced with asterisks (*).
2885 * @param obj The entry object
2886 * @param password If true, password mode is enabled.
2891 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2893 ELM_CHECK_WIDTYPE(obj, widtype);
2894 Widget_Data *wd = elm_widget_data_get(obj);
2896 if (wd->password == password) return;
2897 wd->password = password;
2898 wd->single_line = EINA_TRUE;
2899 wd->linewrap = ELM_WRAP_NONE;
2904 * This returns whether password mode is enabled.
2905 * See also elm_entry_password_set().
2907 * @param obj The entry object
2908 * @return If true, the entry is set to display all characters
2914 elm_entry_password_get(const Evas_Object *obj)
2916 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2917 Widget_Data *wd = elm_widget_data_get(obj);
2918 if (!wd) return EINA_FALSE;
2919 return wd->password;
2923 * This sets the text displayed within the entry to @p entry.
2925 * @param obj The entry object
2926 * @param entry The text to be displayed
2931 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2933 _elm_entry_text_set(obj, NULL, entry);
2937 * This appends @p entry to the text of the entry.
2939 * @param obj The entry object
2940 * @param entry The text to be displayed
2945 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2948 ELM_CHECK_WIDTYPE(obj, widtype);
2949 Widget_Data *wd = elm_widget_data_get(obj);
2951 if (!entry) entry = "";
2952 wd->changed = EINA_TRUE;
2954 len = strlen(entry);
2955 if (wd->append_text_left)
2958 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2964 wd->append_text_left = tmpbuf;
2965 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2966 wd->append_text_len += len;
2970 /* FIXME: Add chunked appending here (like in entry_set) */
2971 edje_object_part_text_append(wd->ent, "elm.text", entry);
2976 * This returns the text currently shown in object @p entry.
2977 * See also elm_entry_entry_set().
2979 * @param obj The entry object
2980 * @return The currently displayed text or NULL on failure
2985 elm_entry_entry_get(const Evas_Object *obj)
2987 return _elm_entry_text_get(obj, NULL);
2991 * This returns EINA_TRUE if the entry is empty/there was an error
2992 * and EINA_FALSE if it is not empty.
2994 * @param obj The entry object
2995 * @return If the entry is empty or not.
3000 elm_entry_is_empty(const Evas_Object *obj)
3002 /* FIXME: until there's support for that in textblock, we just check
3003 * to see if the there is text or not. */
3004 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3005 Widget_Data *wd = elm_widget_data_get(obj);
3006 const Evas_Object *tb;
3007 //Evas_Textblock_Cursor *cur;
3009 if (!wd) return EINA_TRUE;
3012 /* It's a hack until we get the support suggested above.
3013 * We just create a cursor, point it to the begining, and then
3014 * try to advance it, if it can advance, the tb is not empty,
3015 * otherwise it is. */
3016 tb = edje_object_part_object_get(wd->ent, "elm.text");
3017 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3018 actually, ok for the time being, thsese hackish stuff will be removed
3019 once evas 1.0 is out*/
3020 evas_textblock_cursor_pos_set(cur, 0);
3021 ret = evas_textblock_cursor_char_next(cur);
3022 evas_textblock_cursor_free(cur);
3027 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3028 if (!str) return EINA_TRUE;
3030 ret = (strlen(str) == 0);
3036 * This returns all selected text within the entry.
3038 * @param obj The entry object
3039 * @return The selected text within the entry or NULL on failure
3044 elm_entry_selection_get(const Evas_Object *obj)
3046 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3047 Widget_Data *wd = elm_widget_data_get(obj);
3048 if (!wd) return NULL;
3049 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3053 * This inserts text in @p entry where the current cursor position.
3055 * This inserts text at the cursor position is as if it was typed
3056 * by the user (note this also allows markup which a user
3057 * can't just "type" as it would be converted to escaped text, so this
3058 * call can be used to insert things like emoticon items or bold push/pop
3059 * tags, other font and color change tags etc.)
3061 * @param obj The entry object
3062 * @param entry The text to insert
3067 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3069 ELM_CHECK_WIDTYPE(obj, widtype);
3070 Widget_Data *wd = elm_widget_data_get(obj);
3072 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3074 #ifdef HAVE_ELEMENTARY_X
3075 if (cnpwidgetdata == obj)
3076 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3079 wd->changed = EINA_TRUE;
3084 * This enables word line wrapping in the entry object. It is the opposite
3085 * of elm_entry_single_line_set(). Additionally, setting this disables
3086 * character line wrapping.
3088 * @param obj The entry object
3089 * @param wrap If true, the entry will be wrapped once it reaches the end
3090 * of the object. Wrapping will occur at the end of the word before the end of the
3096 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3098 ELM_CHECK_WIDTYPE(obj, widtype);
3099 Widget_Data *wd = elm_widget_data_get(obj);
3101 if (wd->linewrap == wrap) return;
3103 wd->linewrap = wrap;
3108 * Set wrap width of the entry
3110 * @param obj The entry object
3111 * @param w The wrap width in pixels at a minimum where words need to wrap
3115 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
3117 Widget_Data *wd = elm_widget_data_get(obj);
3118 if (wd->wrap_w == w) return;
3124 * get wrap width of the entry
3126 * @param obj The entry object
3127 * @return The wrap width in pixels at a minimum where words need to wrap
3131 elm_entry_wrap_width_get(const Evas_Object *obj)
3133 Widget_Data *wd = elm_widget_data_get(obj);
3138 * Get the wrapping behavior of the entry.
3139 * See also elm_entry_line_wrap_set().
3141 * @param obj The entry object
3147 elm_entry_line_wrap_get(const Evas_Object *obj)
3149 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3150 Widget_Data *wd = elm_widget_data_get(obj);
3151 if (!wd) return EINA_FALSE;
3152 return wd->linewrap;
3156 * This sets the editable attribute of the entry.
3158 * @param obj The entry object
3159 * @param editable If true, the entry will be editable by the user.
3160 * If false, it will be set to the disabled state.
3165 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3167 ELM_CHECK_WIDTYPE(obj, widtype);
3168 Widget_Data *wd = elm_widget_data_get(obj);
3170 if (wd->editable == editable) return;
3171 wd->editable = editable;
3174 #ifdef HAVE_ELEMENTARY_X
3176 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3178 elm_drop_target_del(obj);
3183 * This gets the editable attribute of the entry.
3184 * See also elm_entry_editable_set().
3186 * @param obj The entry object
3187 * @return If true, the entry is editable by the user.
3188 * If false, it is not editable by the user
3193 elm_entry_editable_get(const Evas_Object *obj)
3195 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3196 Widget_Data *wd = elm_widget_data_get(obj);
3197 if (!wd) return EINA_FALSE;
3198 return wd->editable;
3202 * This drops any existing text selection within the entry.
3204 * @param obj The entry object
3209 elm_entry_select_none(Evas_Object *obj)
3211 ELM_CHECK_WIDTYPE(obj, widtype);
3212 Widget_Data *wd = elm_widget_data_get(obj);
3216 wd->selmode = EINA_FALSE;
3217 if (!_elm_config->desktop_entry)
3218 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3219 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3221 wd->have_selection = EINA_FALSE;
3222 edje_object_part_text_select_none(wd->ent, "elm.text");
3226 * This selects all text within the entry.
3228 * @param obj The entry object
3233 elm_entry_select_all(Evas_Object *obj)
3235 ELM_CHECK_WIDTYPE(obj, widtype);
3236 Widget_Data *wd = elm_widget_data_get(obj);
3240 wd->selmode = EINA_FALSE;
3241 if (!_elm_config->desktop_entry)
3242 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3243 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3245 wd->have_selection = EINA_TRUE;
3246 edje_object_part_text_select_all(wd->ent, "elm.text");
3250 * This function returns the geometry of the cursor.
3252 * It's useful if you want to draw something on the cursor (or where it is),
3253 * or for example in the case of scrolled entry where you want to show the
3256 * @param obj The entry object
3257 * @param x returned geometry
3258 * @param y returned geometry
3259 * @param w returned geometry
3260 * @param h returned geometry
3261 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3266 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3268 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3269 Widget_Data *wd = elm_widget_data_get(obj);
3270 if (!wd) return EINA_FALSE;
3271 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3276 * This moves the cursor one place to the right within the entry.
3278 * @param obj The entry object
3279 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3284 elm_entry_cursor_next(Evas_Object *obj)
3286 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3287 Widget_Data *wd = elm_widget_data_get(obj);
3288 if (!wd) return EINA_FALSE;
3289 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3293 * This moves the cursor one place to the left within the entry.
3295 * @param obj The entry object
3296 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3301 elm_entry_cursor_prev(Evas_Object *obj)
3303 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3304 Widget_Data *wd = elm_widget_data_get(obj);
3305 if (!wd) return EINA_FALSE;
3306 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3310 * This moves the cursor one line up within the entry.
3312 * @param obj The entry object
3313 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3318 elm_entry_cursor_up(Evas_Object *obj)
3320 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3321 Widget_Data *wd = elm_widget_data_get(obj);
3322 if (!wd) return EINA_FALSE;
3323 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3327 * This moves the cursor one line down within the entry.
3329 * @param obj The entry object
3330 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3335 elm_entry_cursor_down(Evas_Object *obj)
3337 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3338 Widget_Data *wd = elm_widget_data_get(obj);
3339 if (!wd) return EINA_FALSE;
3340 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3344 * This moves the cursor to the beginning of the entry.
3346 * @param obj The entry object
3351 elm_entry_cursor_begin_set(Evas_Object *obj)
3353 ELM_CHECK_WIDTYPE(obj, widtype);
3354 Widget_Data *wd = elm_widget_data_get(obj);
3356 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3360 * This moves the cursor to the end of the entry.
3362 * @param obj The entry object
3367 elm_entry_cursor_end_set(Evas_Object *obj)
3369 ELM_CHECK_WIDTYPE(obj, widtype);
3370 Widget_Data *wd = elm_widget_data_get(obj);
3373 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3376 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3377 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3382 * This moves the cursor to the beginning of the current line.
3384 * @param obj The entry object
3389 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3391 ELM_CHECK_WIDTYPE(obj, widtype);
3392 Widget_Data *wd = elm_widget_data_get(obj);
3394 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3398 * This moves the cursor to the end of the current line.
3400 * @param obj The entry object
3405 elm_entry_cursor_line_end_set(Evas_Object *obj)
3407 ELM_CHECK_WIDTYPE(obj, widtype);
3408 Widget_Data *wd = elm_widget_data_get(obj);
3410 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3414 * This begins a selection within the entry as though
3415 * the user were holding down the mouse button to make a selection.
3417 * @param obj The entry object
3422 elm_entry_cursor_selection_begin(Evas_Object *obj)
3424 ELM_CHECK_WIDTYPE(obj, widtype);
3425 Widget_Data *wd = elm_widget_data_get(obj);
3427 edje_object_part_text_select_begin(wd->ent, "elm.text");
3431 * This ends a selection within the entry as though
3432 * the user had just released the mouse button while making a selection.
3434 * @param obj The entry object
3439 elm_entry_cursor_selection_end(Evas_Object *obj)
3441 ELM_CHECK_WIDTYPE(obj, widtype);
3442 Widget_Data *wd = elm_widget_data_get(obj);
3444 edje_object_part_text_select_extend(wd->ent, "elm.text");
3448 * TODO: fill this in
3450 * @param obj The entry object
3451 * @return TODO: fill this in
3456 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3458 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3459 Widget_Data *wd = elm_widget_data_get(obj);
3460 if (!wd) return EINA_FALSE;
3461 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3465 * This returns whether the cursor is visible.
3467 * @param obj The entry object
3468 * @return If true, the cursor is visible.
3473 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3475 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3476 Widget_Data *wd = elm_widget_data_get(obj);
3477 if (!wd) return EINA_FALSE;
3478 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3482 * TODO: fill this in
3484 * @param obj The entry object
3485 * @return TODO: fill this in
3490 elm_entry_cursor_content_get(const Evas_Object *obj)
3492 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3493 Widget_Data *wd = elm_widget_data_get(obj);
3494 if (!wd) return NULL;
3495 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3499 * Sets the cursor position in the entry to the given value
3501 * @param obj The entry object
3502 * @param pos The position of the cursor
3507 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3509 ELM_CHECK_WIDTYPE(obj, widtype);
3510 Widget_Data *wd = elm_widget_data_get(obj);
3512 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3513 edje_object_message_signal_process(wd->ent);
3517 * Retrieves the current position of the cursor in the entry
3519 * @param obj The entry object
3520 * @return The cursor position
3525 elm_entry_cursor_pos_get(const Evas_Object *obj)
3527 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3528 Widget_Data *wd = elm_widget_data_get(obj);
3530 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3534 * This executes a "cut" action on the selected text in the entry.
3536 * @param obj The entry object
3541 elm_entry_selection_cut(Evas_Object *obj)
3543 ELM_CHECK_WIDTYPE(obj, widtype);
3544 Widget_Data *wd = elm_widget_data_get(obj);
3546 _cut(obj, NULL, NULL);
3550 * This executes a "copy" action on the selected text in the entry.
3552 * @param obj The entry object
3557 elm_entry_selection_copy(Evas_Object *obj)
3559 ELM_CHECK_WIDTYPE(obj, widtype);
3560 Widget_Data *wd = elm_widget_data_get(obj);
3562 _copy(obj, NULL, NULL);
3566 * This executes a "paste" action in the entry.
3568 * @param obj The entry object
3573 elm_entry_selection_paste(Evas_Object *obj)
3575 ELM_CHECK_WIDTYPE(obj, widtype);
3576 Widget_Data *wd = elm_widget_data_get(obj);
3578 _paste(obj, NULL, NULL);
3582 * This clears and frees the items in a entry's contextual (right click) menu.
3584 * @param obj The entry object
3589 elm_entry_context_menu_clear(Evas_Object *obj)
3591 ELM_CHECK_WIDTYPE(obj, widtype);
3592 Widget_Data *wd = elm_widget_data_get(obj);
3593 Elm_Entry_Context_Menu_Item *it;
3595 EINA_LIST_FREE(wd->items, it)
3597 eina_stringshare_del(it->label);
3598 eina_stringshare_del(it->icon_file);
3599 eina_stringshare_del(it->icon_group);
3605 * This adds an item to the entry's contextual menu.
3607 * @param obj The entry object
3608 * @param label The item's text label
3609 * @param icon_file The item's icon file
3610 * @param icon_type The item's icon type
3611 * @param func The callback to execute when the item is clicked
3612 * @param data The data to associate with the item for related functions
3617 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)
3619 ELM_CHECK_WIDTYPE(obj, widtype);
3620 Widget_Data *wd = elm_widget_data_get(obj);
3621 Elm_Entry_Context_Menu_Item *it;
3623 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3625 wd->items = eina_list_append(wd->items, it);
3627 it->label = eina_stringshare_add(label);
3628 it->icon_file = eina_stringshare_add(icon_file);
3629 it->icon_type = icon_type;
3631 it->data = (void *)data;
3635 * This disables the entry's contextual (right click) menu.
3637 * @param obj The entry object
3638 * @param disabled If true, the menu is disabled
3643 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3645 ELM_CHECK_WIDTYPE(obj, widtype);
3646 Widget_Data *wd = elm_widget_data_get(obj);
3648 if (wd->context_menu == !disabled) return;
3649 wd->context_menu = !disabled;
3653 * This returns whether the entry's contextual (right click) menu is disabled.
3655 * @param obj The entry object
3656 * @return If true, the menu is disabled
3661 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3663 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3664 Widget_Data *wd = elm_widget_data_get(obj);
3665 if (!wd) return EINA_FALSE;
3666 return !wd->context_menu;
3670 * This appends a custom item provider to the list for that entry
3672 * This appends the given callback. The list is walked from beginning to end
3673 * with each function called given the item href string in the text. If the
3674 * function returns an object handle other than NULL (it should create an
3675 * and object to do this), then this object is used to replace that item. If
3676 * not the next provider is called until one provides an item object, or the
3677 * default provider in entry does.
3679 * @param obj The entry object
3680 * @param func The function called to provide the item object
3681 * @param data The data passed to @p func
3686 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3688 ELM_CHECK_WIDTYPE(obj, widtype);
3689 Widget_Data *wd = elm_widget_data_get(obj);
3691 EINA_SAFETY_ON_NULL_RETURN(func);
3692 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3696 wd->item_providers = eina_list_append(wd->item_providers, ip);
3700 * This prepends a custom item provider to the list for that entry
3702 * This prepends the given callback. See elm_entry_item_provider_append() for
3705 * @param obj The entry object
3706 * @param func The function called to provide the item object
3707 * @param data The data passed to @p func
3712 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3714 ELM_CHECK_WIDTYPE(obj, widtype);
3715 Widget_Data *wd = elm_widget_data_get(obj);
3717 EINA_SAFETY_ON_NULL_RETURN(func);
3718 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3722 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3726 * This removes a custom item provider to the list for that entry
3728 * This removes the given callback. See elm_entry_item_provider_append() for
3731 * @param obj The entry object
3732 * @param func The function called to provide the item object
3733 * @param data The data passed to @p func
3738 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3740 ELM_CHECK_WIDTYPE(obj, widtype);
3741 Widget_Data *wd = elm_widget_data_get(obj);
3743 Elm_Entry_Item_Provider *ip;
3745 EINA_SAFETY_ON_NULL_RETURN(func);
3746 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3748 if ((ip->func == func) && ((!data) || (ip->data == data)))
3750 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3758 * Append a filter function for text inserted in the entry
3760 * Append the given callback to the list. This functions will be called
3761 * whenever any text is inserted into the entry, with the text to be inserted
3762 * as a parameter. The callback function is free to alter the text in any way
3763 * it wants, but it must remember to free the given pointer and update it.
3764 * If the new text is to be discarded, the function can free it and set it text
3765 * parameter to NULL. This will also prevent any following filters from being
3768 * @param obj The entry object
3769 * @param func The function to use as text filter
3770 * @param data User data to pass to @p func
3775 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3778 Elm_Entry_Text_Filter *tf;
3779 ELM_CHECK_WIDTYPE(obj, widtype);
3781 wd = elm_widget_data_get(obj);
3783 EINA_SAFETY_ON_NULL_RETURN(func);
3785 tf = _filter_new(func, data);
3788 wd->text_filters = eina_list_append(wd->text_filters, tf);
3792 * Prepend a filter function for text insdrted in the entry
3794 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3795 * for more information
3797 * @param obj The entry object
3798 * @param func The function to use as text filter
3799 * @param data User data to pass to @p func
3804 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3807 Elm_Entry_Text_Filter *tf;
3808 ELM_CHECK_WIDTYPE(obj, widtype);
3810 wd = elm_widget_data_get(obj);
3812 EINA_SAFETY_ON_NULL_RETURN(func);
3814 tf = _filter_new(func, data);
3817 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3821 * Remove a filter from the list
3823 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3824 * for more information.
3826 * @param obj The entry object
3827 * @param func The filter function to remove
3828 * @param data The user data passed when adding the function
3833 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3837 Elm_Entry_Text_Filter *tf;
3838 ELM_CHECK_WIDTYPE(obj, widtype);
3840 wd = elm_widget_data_get(obj);
3842 EINA_SAFETY_ON_NULL_RETURN(func);
3844 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3846 if ((tf->func == func) && ((!data) || (tf->data == data)))
3848 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3856 * This converts a markup (HTML-like) string into UTF-8.
3857 * Returning string is obtained with malloc.
3858 * After use the returned string, it should be freed.
3860 * @param s The string (in markup) to be converted
3861 * @return The converted string (in UTF-8). It should be freed.
3866 elm_entry_markup_to_utf8(const char *s)
3868 char *ss = _elm_util_mkup_to_text(s);
3869 if (!ss) ss = strdup("");
3874 * This converts a UTF-8 string into markup (HTML-like).
3875 * Returning string is obtained with malloc.
3876 * After use the returned string, it should be freed.
3878 * @param s The string (in UTF-8) to be converted
3879 * @return The converted string (in markup). It should be freed.
3884 elm_entry_utf8_to_markup(const char *s)
3886 char *ss = _elm_util_text_to_mkup(s);
3887 if (!ss) ss = strdup("");
3892 * Get the input method context in the entry widget
3894 * @param obj The entry object
3895 * @return The input method context
3899 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3901 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3902 Widget_Data *wd = elm_widget_data_get(obj);
3903 if (!wd || !wd->ent) return NULL;
3905 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3909 * Set whether entry should enable the return key on soft keyboard automatically
3911 * @param obj The entry object
3912 * @param on If true, entry enables the return key on soft keyboard automatically.
3917 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3919 ELM_CHECK_WIDTYPE(obj, widtype);
3920 Widget_Data *wd = elm_widget_data_get(obj);
3923 wd->autoreturnkey = on;
3924 _check_enable_returnkey(obj);
3928 * Set whether entry should support auto capitalization
3930 * @param obj The entry object
3931 * @param on If true, entry suports auto capitalization.
3936 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3938 ELM_CHECK_WIDTYPE(obj, widtype);
3939 Widget_Data *wd = elm_widget_data_get(obj);
3943 wd->autocapital = EINA_FALSE;
3945 wd->autocapital = autocap;
3947 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3948 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3949 wd->autocapital = EINA_FALSE;
3951 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3955 * Set whether entry should support auto period
3957 * @param obj The entry object
3958 * @param on If true, entry suports auto period.
3963 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3965 ELM_CHECK_WIDTYPE(obj, widtype);
3966 Widget_Data *wd = elm_widget_data_get(obj);
3970 wd->autoperiod = EINA_FALSE;
3972 wd->autoperiod = autoperiod;
3974 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3975 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3976 wd->autoperiod = EINA_FALSE;
3978 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3982 * Set the font size on the entry object
3984 * @param obj The entry object
3985 * @param size font size
3990 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3992 ELM_CHECK_WIDTYPE(obj, widtype);
3993 Widget_Data *wd = elm_widget_data_get(obj);
3994 Eina_Strbuf *fontbuf = NULL;
3999 t = eina_stringshare_add(elm_entry_entry_get(obj));
4000 fontbuf = eina_strbuf_new();
4001 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
4003 if (fontsize == 0) removeflag = 1; // remove fontsize tag
4005 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
4007 elm_entry_entry_set(obj, t);
4011 eina_strbuf_free(fontbuf);
4012 eina_stringshare_del(t);
4016 * Set the text align on the entry object
4018 * @param obj The entry object
4019 * @param align align mode
4024 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
4026 ELM_CHECK_WIDTYPE(obj, widtype);
4027 Widget_Data *wd = elm_widget_data_get(obj);
4032 t = eina_stringshare_add(elm_entry_entry_get(obj));
4034 if (len <= 0) return;
4036 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
4037 elm_entry_entry_set(obj, t);
4041 eina_stringshare_del(t);
4045 * Set the text color on the entry object
4047 * @param obj The entry object
4048 * @param r Red property background color of The entry object
4049 * @param g Green property background color of The entry object
4050 * @param b Blue property background color of The entry object
4051 * @param a Alpha property background alpha of The entry object
4056 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4058 ELM_CHECK_WIDTYPE(obj, widtype);
4059 Widget_Data *wd = elm_widget_data_get(obj);
4060 Eina_Strbuf *colorbuf = NULL;
4065 t = eina_stringshare_add(elm_entry_entry_get(obj));
4067 if (len <= 0) return;
4068 colorbuf = eina_strbuf_new();
4069 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
4071 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
4073 elm_entry_entry_set(obj, t);
4077 eina_strbuf_free(colorbuf);
4078 eina_stringshare_del(t);
4082 * Set background color of the entry
4084 * @param obj The entry object
4085 * @param r Red property background color of The entry object
4086 * @param g Green property background color of The entry object
4087 * @param b Blue property background color of The entry object
4088 * @param a Alpha property background alpha of The entry object
4092 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4094 ELM_CHECK_WIDTYPE(obj, widtype);
4095 Widget_Data *wd = elm_widget_data_get(obj);
4096 evas_object_color_set(wd->bg, r, g, b, a);
4098 if (wd->bgcolor == EINA_FALSE)
4101 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4106 * Filter inserted text based on user defined character and byte limits
4108 * Add this filter to an entry to limit the characters that it will accept
4109 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
4110 * The funtion works on the UTF-8 representation of the string, converting
4111 * it from the set markup, thus not accounting for any format in it.
4113 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
4114 * it as data when setting the filter. In it it's possible to set limits
4115 * by character count or bytes (any of them is disabled if 0), and both can
4116 * be set at the same time. In that case, it first checks for characters,
4119 * The function will cut the inserted text in order to allow only the first
4120 * number of characters that are still allowed. The cut is made in
4121 * characters, even when limiting by bytes, in order to always contain
4122 * valid ones and avoid half unicode characters making it in.
4127 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
4129 Elm_Entry_Filter_Limit_Size *lim = data;
4132 const char *(*text_get)(const Evas_Object *);
4133 const char *widget_type;
4135 EINA_SAFETY_ON_NULL_RETURN(data);
4136 EINA_SAFETY_ON_NULL_RETURN(entry);
4137 EINA_SAFETY_ON_NULL_RETURN(text);
4139 /* hack. I don't want to copy the entire function to work with
4141 widget_type = elm_widget_type_get(entry);
4142 if (!strcmp(widget_type, "entry"))
4143 text_get = elm_entry_entry_get;
4147 current = elm_entry_markup_to_utf8(text_get(entry));
4149 if (lim->max_char_count > 0)
4151 len = evas_string_char_len_get(current);
4152 if (len >= lim->max_char_count)
4154 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4160 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
4161 if ((len + newlen) > lim->max_char_count)
4162 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4164 else if (lim->max_byte_count > 0)
4166 len = strlen(current);
4167 if (len >= lim->max_byte_count)
4169 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
4175 newlen = strlen(elm_entry_markup_to_utf8(*text));
4176 if ((len + newlen) > lim->max_byte_count)
4177 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4183 * Filter inserted text based on accepted or rejected sets of characters
4185 * Add this filter to an entry to restrict the set of accepted characters
4186 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
4187 * This structure contains both accepted and rejected sets, but they are
4188 * mutually exclusive. If accepted is set, it will be used, otherwise it
4189 * goes on to the rejected set.
4192 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
4194 Elm_Entry_Filter_Accept_Set *as = data;
4198 int read_idx, last_read_idx = 0, read_char;
4200 EINA_SAFETY_ON_NULL_RETURN(data);
4201 EINA_SAFETY_ON_NULL_RETURN(text);
4203 if ((!as->accepted) && (!as->rejected))
4209 goes_in = EINA_TRUE;
4214 goes_in = EINA_FALSE;
4218 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4221 int cmp_idx, cmp_char;
4222 Eina_Bool in_set = EINA_FALSE;
4224 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4227 if (read_char == cmp_char)
4232 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4234 if (in_set == goes_in)
4236 int size = read_idx - last_read_idx;
4237 const char *src = (*text) + last_read_idx;
4239 memcpy(insert, *text + last_read_idx, size);
4242 last_read_idx = read_idx;
4243 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4249 * This sets the file (and implicitly loads it) for the text to display and
4250 * then edit. All changes are written back to the file after a short delay if
4251 * the entry object is set to autosave.
4253 * @param obj The entry object
4254 * @param file The path to the file to load and save
4255 * @param format The file format
4260 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4262 ELM_CHECK_WIDTYPE(obj, widtype);
4263 Widget_Data *wd = elm_widget_data_get(obj);
4265 if (wd->delay_write)
4267 ecore_timer_del(wd->delay_write);
4268 wd->delay_write = NULL;
4270 if (wd->autosave) _save(obj);
4271 eina_stringshare_replace(&wd->file, file);
4272 wd->format = format;
4277 * Gets the file to load and save and the file format
4279 * @param obj The entry object
4280 * @param file The path to the file to load and save
4281 * @param format The file format
4286 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4288 ELM_CHECK_WIDTYPE(obj, widtype);
4289 Widget_Data *wd = elm_widget_data_get(obj);
4291 if (file) *file = wd->file;
4292 if (format) *format = wd->format;
4296 * This function writes any changes made to the file set with
4297 * elm_entry_file_set()
4299 * @param obj The entry object
4304 elm_entry_file_save(Evas_Object *obj)
4306 ELM_CHECK_WIDTYPE(obj, widtype);
4307 Widget_Data *wd = elm_widget_data_get(obj);
4309 if (wd->delay_write)
4311 ecore_timer_del(wd->delay_write);
4312 wd->delay_write = NULL;
4315 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4319 * This sets the entry object to 'autosave' the loaded text file or not.
4321 * @param obj The entry object
4322 * @param autosave Autosave the loaded file or not
4327 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4329 ELM_CHECK_WIDTYPE(obj, widtype);
4330 Widget_Data *wd = elm_widget_data_get(obj);
4332 wd->autosave = !!autosave;
4336 * This gets the entry object's 'autosave' status.
4338 * @param obj The entry object
4339 * @return Autosave the loaded file or not
4344 elm_entry_autosave_get(const Evas_Object *obj)
4346 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4347 Widget_Data *wd = elm_widget_data_get(obj);
4348 if (!wd) return EINA_FALSE;
4349 return wd->autosave;
4353 * Control pasting of text and images for the widget.
4355 * Normally the entry allows both text and images to be pasted. By setting
4356 * textonly to be true, this prevents images from being pasted.
4358 * Note this only changes the behaviour of text.
4360 * @param obj The entry object
4361 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
4366 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4368 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4369 ELM_CHECK_WIDTYPE(obj, widtype);
4370 Widget_Data *wd = elm_widget_data_get(obj);
4372 textonly = !!textonly;
4373 if (wd->textonly == textonly) return;
4374 wd->textonly = !!textonly;
4375 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
4376 #ifdef HAVE_ELEMENTARY_X
4377 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4382 * Getting elm_entry text paste/drop mode.
4384 * In textonly mode, only text may be pasted or dropped into the widget.
4386 * @param obj The entry object
4387 * @return If the widget only accepts text from pastes.
4392 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4394 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4395 Widget_Data *wd = elm_widget_data_get(obj);
4396 if (!wd) return EINA_FALSE;
4397 return wd->textonly;
4401 * Enable or disable scrolling in entry
4403 * Normally the entry is not scrollable unless you enable it with this call.
4405 * @param obj The entry object
4406 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
4411 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4413 ELM_CHECK_WIDTYPE(obj, widtype);
4414 Widget_Data *wd = elm_widget_data_get(obj);
4417 if (wd->scroll == scroll) return;
4418 wd->scroll = scroll;
4421 elm_widget_sub_object_del(obj, wd->scroller);
4422 elm_widget_resize_object_set(obj, wd->scroller);
4423 elm_widget_sub_object_add(obj, wd->ent);
4424 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4425 evas_object_show(wd->scroller);
4426 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4430 elm_smart_scroller_child_set(wd->scroller, NULL);
4431 elm_widget_sub_object_del(obj, wd->ent);
4432 elm_widget_resize_object_set(obj, wd->ent);
4433 evas_object_smart_member_add(wd->scroller, obj);
4434 elm_widget_sub_object_add(obj, wd->scroller);
4435 evas_object_hide(wd->scroller);
4436 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4443 * Get the scrollable state of the entry
4445 * Normally the entry is not scrollable. This gets the scrollable state
4446 * of the entry. See elm_entry_scrollable_set() for more information.
4448 * @param obj The entry object
4449 * @return The scrollable state
4454 elm_entry_scrollable_get(const Evas_Object *obj)
4456 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4457 Widget_Data *wd = elm_widget_data_get(obj);
4458 if (!wd) return EINA_FALSE;
4463 * This sets a widget to be displayed to the left of a scrolled entry.
4465 * @param obj The scrolled entry object
4466 * @param icon The widget to display on the left side of the scrolled
4469 * @note A previously set widget will be destroyed.
4470 * @note If the object being set does not have minimum size hints set,
4471 * it won't get properly displayed.
4474 * @see elm_entry_end_set
4477 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4479 ELM_CHECK_WIDTYPE(obj, widtype);
4480 Widget_Data *wd = elm_widget_data_get(obj);
4483 EINA_SAFETY_ON_NULL_RETURN(icon);
4484 if (wd->icon == icon) return;
4485 if (wd->icon) evas_object_del(wd->icon);
4487 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4489 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
4490 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4495 * Gets the leftmost widget of the scrolled entry. This object is
4496 * owned by the scrolled entry and should not be modified.
4498 * @param obj The scrolled entry object
4499 * @return the left widget inside the scroller
4504 elm_entry_icon_get(const Evas_Object *obj)
4506 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4507 Widget_Data *wd = elm_widget_data_get(obj);
4508 if (!wd) return NULL;
4513 * Unset the leftmost widget of the scrolled entry, unparenting and
4516 * @param obj The scrolled entry object
4517 * @return the previously set icon sub-object of this entry, on
4520 * @see elm_entry_icon_set()
4525 elm_entry_icon_unset(Evas_Object *obj)
4527 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4528 Widget_Data *wd = elm_widget_data_get(obj);
4529 Evas_Object *ret = NULL;
4530 if (!wd) return NULL;
4533 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4534 if (!edje) return NULL;
4536 edje_object_part_unswallow(edje, wd->icon);
4537 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4545 * Sets the visibility of the left-side widget of the scrolled entry,
4546 * set by @elm_entry_icon_set().
4548 * @param obj The scrolled entry object
4549 * @param setting EINA_TRUE if the object should be displayed,
4550 * EINA_FALSE if not.
4555 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4557 ELM_CHECK_WIDTYPE(obj, widtype);
4558 Widget_Data *wd = elm_widget_data_get(obj);
4559 if ((!wd) || (!wd->icon)) return;
4561 evas_object_hide(wd->icon);
4563 evas_object_show(wd->icon);
4568 * This sets a widget to be displayed to the end of a scrolled entry.
4570 * @param obj The scrolled entry object
4571 * @param end The widget to display on the right side of the scrolled
4574 * @note A previously set widget will be destroyed.
4575 * @note If the object being set does not have minimum size hints set,
4576 * it won't get properly displayed.
4579 * @see elm_entry_icon_set
4582 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4584 ELM_CHECK_WIDTYPE(obj, widtype);
4585 Widget_Data *wd = elm_widget_data_get(obj);
4588 EINA_SAFETY_ON_NULL_RETURN(end);
4589 if (wd->end == end) return;
4590 if (wd->end) evas_object_del(wd->end);
4592 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4594 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
4595 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4600 * Gets the endmost widget of the scrolled entry. This object is owned
4601 * by the scrolled entry and should not be modified.
4603 * @param obj The scrolled entry object
4604 * @return the right widget inside the scroller
4609 elm_entry_end_get(const Evas_Object *obj)
4611 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4612 Widget_Data *wd = elm_widget_data_get(obj);
4613 if (!wd) return NULL;
4618 * Unset the endmost widget of the scrolled entry, unparenting and
4621 * @param obj The scrolled entry object
4622 * @return the previously set icon sub-object of this entry, on
4625 * @see elm_entry_icon_set()
4630 elm_entry_end_unset(Evas_Object *obj)
4632 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4633 Widget_Data *wd = elm_widget_data_get(obj);
4634 Evas_Object *ret = NULL;
4635 if (!wd) return NULL;
4638 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
4639 if (!edje) return NULL;
4641 edje_object_part_unswallow(edje, wd->end);
4642 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4650 * Sets the visibility of the end widget of the scrolled entry, set by
4651 * @elm_entry_end_set().
4653 * @param obj The scrolled entry object
4654 * @param setting EINA_TRUE if the object should be displayed,
4655 * EINA_FALSE if not.
4660 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4662 ELM_CHECK_WIDTYPE(obj, widtype);
4663 Widget_Data *wd = elm_widget_data_get(obj);
4664 if ((!wd) || (!wd->end)) return;
4666 evas_object_hide(wd->end);
4668 evas_object_show(wd->end);
4673 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
4675 * @param obj The scrolled entry object
4676 * @param h The horizontal scrollbar policy to apply
4677 * @param v The vertical scrollbar policy to apply
4682 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4684 ELM_CHECK_WIDTYPE(obj, widtype);
4685 Widget_Data *wd = elm_widget_data_get(obj);
4686 const Elm_Scroller_Policy map[3] =
4688 ELM_SMART_SCROLLER_POLICY_AUTO,
4689 ELM_SMART_SCROLLER_POLICY_ON,
4690 ELM_SMART_SCROLLER_POLICY_OFF
4695 elm_smart_scroller_policy_set(wd->scroller,
4701 * This enables/disables bouncing within the entry.
4703 * @param obj The scrolled entry object
4704 * @param h The horizontal bounce state
4705 * @param v The vertical bounce state
4710 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4712 ELM_CHECK_WIDTYPE(obj, widtype);
4713 Widget_Data *wd = elm_widget_data_get(obj);
4715 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4719 * Get the bounce mode
4721 * @param obj The Entry object
4722 * @param h_bounce Allow bounce horizontally
4723 * @param v_bounce Allow bounce vertically
4728 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4730 ELM_CHECK_WIDTYPE(obj, widtype);
4731 Widget_Data *wd = elm_widget_data_get(obj);
4733 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4737 * This sets the attribute to show the input panel automatically.
4739 * @param obj The entry object
4740 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4745 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4747 ELM_CHECK_WIDTYPE(obj, widtype);
4748 Widget_Data *wd = elm_widget_data_get(obj);
4751 wd->input_panel_enable = enabled;
4752 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4756 * Set the input panel layout of the entry
4758 * @param obj The entry object
4759 * @param layout the layout to set
4764 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4766 ELM_CHECK_WIDTYPE(obj, widtype);
4767 Widget_Data *wd = elm_widget_data_get(obj);
4770 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4773 wd->input_panel_layout = layout;
4775 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4779 * Set the magnifier style of the entry
4781 * @param obj The entry object
4782 * @param type the magnifier style to set
4787 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4789 ELM_CHECK_WIDTYPE(obj, widtype);
4790 Widget_Data *wd = elm_widget_data_get(obj);
4793 wd->mgf_type = type;
4794 _magnifier_create(obj);
4797 EINA_DEPRECATED EAPI void
4798 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4800 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);