1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 * @defgroup Entry Entry
8 * An entry is a convenience widget which shows
9 * a box that the user can enter text into. Unlike a
10 * @ref Scrolled_Entry widget, entries DO NOT scroll with user
11 * input. Entry widgets are capable of expanding past the
12 * boundaries of the window, thus resizing the window to its
15 * You can also insert "items" in the entry with:
17 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
19 * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
20 * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
21 * supports a list of emoticon names by default. These are:
24 * - emoticon/angry-shout
25 * - emoticon/crazy-laugh
26 * - emoticon/evil-laugh
28 * - emoticon/goggle-smile
30 * - emoticon/grumpy-smile
32 * - emoticon/guilty-smile
34 * - emoticon/half-smile
35 * - emoticon/happy-panting
37 * - emoticon/indifferent
39 * - emoticon/knowing-grin
41 * - emoticon/little-bit-sorry
42 * - emoticon/love-lots
44 * - emoticon/minimal-smile
45 * - emoticon/not-happy
46 * - emoticon/not-impressed
48 * - emoticon/opensmile
51 * - emoticon/squint-laugh
52 * - emoticon/surprised
53 * - emoticon/suspicious
54 * - emoticon/tongue-dangling
55 * - emoticon/tongue-poke
58 * - emoticon/very-sorry
64 * These are built-in currently, but you can add your own item provieer that
65 * can create inlined objects in the text and fill the space allocated to the
66 * item with a custom object of your own.
68 * See the entry test for some more examples of use of this.
70 * Entries have functions to load a text file, display it,
71 * allowing editing of it and saving of changes back to the file loaded.
72 * Changes are written back to the original file after a short delay.
73 * The file to load and save to is specified by elm_entry_file_set().
75 * Signals that you can add callbacks for are:
77 * "changed" - The text within the entry was changed
78 * "activated" - The entry has had editing finished and changes are to be committed
79 (generally when enter key is pressed)
80 * "press" - The entry has been clicked
81 * "longpressed" - The entry has been clicked for a couple seconds
82 * "clicked" - The entry has been clicked
83 * "clicked,double" - The entry has been double clicked
84 * "focused" - The entry has received focus
85 * "unfocused" - The entry has lost focus
86 * "selection,paste" - A paste action has occurred
87 * "selection,copy" - A copy action has occurred
88 * "selection,cut" - A cut action has occurred
89 * "selection,start" - A selection has begun
90 * "selection,changed" - The selection has changed
91 * "selection,cleared" - The selection has been cleared
92 * "cursor,changed" - The cursor has changed
93 * "anchor,clicked" - The anchor has been clicked
96 /* Maximum chunk size to be inserted to the entry at once
97 * FIXME: This size is arbitrary, should probably choose a better size.
98 * Possibly also find a way to set it to a low value for weak computers,
99 * and to a big value for better computers. */
100 #define _CHUNK_SIZE 10000
102 typedef struct _Mod_Api Mod_Api;
104 typedef struct _Widget_Data Widget_Data;
105 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
106 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
107 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
111 Evas_Object *ent, *scroller, *end, *icon;
112 Evas_Object *hoversel;
113 Ecore_Job *deferred_recalc_job;
114 Ecore_Event_Handler *sel_notify_handler;
115 Ecore_Event_Handler *sel_clear_handler;
116 Ecore_Timer *longpress_timer;
117 Ecore_Timer *delay_write;
118 /* for deferred appending */
119 Ecore_Idler *append_text_idler;
120 char *append_text_left;
121 int append_text_position;
123 /* Only for clipboard */
127 Elm_Text_Format format;
128 Evas_Coord lastw, entmw, entmh;
129 Evas_Coord downx, downy;
131 Eina_List *item_providers;
132 Eina_List *text_filters;
133 Ecore_Job *hovdeljob;
134 Mod_Api *api; // module api if supplied
136 Elm_Scroller_Policy policy_h, policy_v;
137 Elm_Wrap_Type linewrap;
138 Eina_Bool changed : 1;
139 Eina_Bool single_line : 1;
140 Eina_Bool password : 1;
141 Eina_Bool editable : 1;
142 Eina_Bool selection_asked : 1;
143 Eina_Bool have_selection : 1;
144 Eina_Bool selmode : 1;
145 Eina_Bool deferred_cur : 1;
146 Eina_Bool cur_changed : 1;
147 Eina_Bool disabled : 1;
148 Eina_Bool context_menu : 1;
149 Eina_Bool drag_selection_asked : 1;
150 Eina_Bool can_write : 1;
151 Eina_Bool autosave : 1;
152 Eina_Bool textonly : 1;
153 Eina_Bool usedown : 1;
154 Eina_Bool scroll : 1;
157 struct _Elm_Entry_Context_Menu_Item
161 const char *icon_file;
162 const char *icon_group;
163 Elm_Icon_Type icon_type;
168 struct _Elm_Entry_Item_Provider
170 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
174 struct _Elm_Entry_Text_Filter
176 void (*func) (void *data, Evas_Object *entry, char **text);
180 typedef enum _Length_Unit
187 static const char *widtype = NULL;
189 #ifdef HAVE_ELEMENTARY_X
190 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
192 static void _del_hook(Evas_Object *obj);
193 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
194 static void _theme_hook(Evas_Object *obj);
195 static void _disable_hook(Evas_Object *obj);
196 static void _sizing_eval(Evas_Object *obj);
197 static void _on_focus_hook(void *data, Evas_Object *obj);
198 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
199 static const char *_getbase(Evas_Object *obj);
200 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
201 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
202 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
203 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
204 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
205 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
206 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
207 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
208 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
210 static const char SIG_CHANGED[] = "changed";
211 static const char SIG_ACTIVATED[] = "activated";
212 static const char SIG_PRESS[] = "press";
213 static const char SIG_LONGPRESSED[] = "longpressed";
214 static const char SIG_CLICKED[] = "clicked";
215 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
216 static const char SIG_FOCUSED[] = "focused";
217 static const char SIG_UNFOCUSED[] = "unfocused";
218 static const char SIG_SELECTION_PASTE[] = "selection,paste";
219 static const char SIG_SELECTION_COPY[] = "selection,copy";
220 static const char SIG_SELECTION_CUT[] = "selection,cut";
221 static const char SIG_SELECTION_START[] = "selection,start";
222 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
223 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
224 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
225 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
226 static const Evas_Smart_Cb_Description _signals[] = {
230 {SIG_LONGPRESSED, ""},
232 {SIG_CLICKED_DOUBLE, ""},
235 {SIG_SELECTION_PASTE, ""},
236 {SIG_SELECTION_COPY, ""},
237 {SIG_SELECTION_CUT, ""},
238 {SIG_SELECTION_START, ""},
239 {SIG_SELECTION_CHANGED, ""},
240 {SIG_SELECTION_CLEARED, ""},
241 {SIG_CURSOR_CHANGED, ""},
242 {SIG_ANCHOR_CLICKED, ""},
246 static Eina_List *entries = NULL;
250 void (*obj_hook) (Evas_Object *obj);
251 void (*obj_unhook) (Evas_Object *obj);
252 void (*obj_longpress) (Evas_Object *obj);
256 _module(Evas_Object *obj __UNUSED__)
258 static Elm_Module *m = NULL;
259 if (m) goto ok; // already found - just use
260 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
262 m->api = malloc(sizeof(Mod_Api));
263 if (!m->api) return NULL;
264 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
265 _elm_module_symbol_get(m, "obj_hook");
266 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
267 _elm_module_symbol_get(m, "obj_unhook");
268 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
269 _elm_module_symbol_get(m, "obj_longpress");
270 ok: // ok - return api
275 _buf_append(char *buf, const char *str, int *len, int *alloc)
277 int len2 = strlen(str);
278 if ((*len + len2) >= *alloc)
280 char *buf2 = realloc(buf, *alloc + len2 + 512);
281 if (!buf2) return NULL;
283 *alloc += (512 + len2);
285 strcpy(buf + *len, str);
291 _load_file(const char *file)
295 int alloc = 0, len = 0;
296 char *text = NULL, buf[16384 + 1];
298 f = fopen(file, "rb");
300 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
304 tmp_text = _buf_append(text, buf, &len, &alloc);
305 if (!tmp_text) break;
313 _load_plain(const char *file)
317 text = _load_file(file);
322 text2 = elm_entry_utf8_to_markup(text);
330 _load(Evas_Object *obj)
332 Widget_Data *wd = elm_widget_data_get(obj);
337 elm_entry_entry_set(obj, "");
342 case ELM_TEXT_FORMAT_PLAIN_UTF8:
343 text = _load_plain(wd->file);
345 case ELM_TEXT_FORMAT_MARKUP_UTF8:
346 text = _load_file(wd->file);
354 elm_entry_entry_set(obj, text);
358 elm_entry_entry_set(obj, "");
362 _save_markup_utf8(const char *file, const char *text)
366 if ((!text) || (!text[0]))
368 ecore_file_unlink(file);
371 f = fopen(file, "wb");
374 // FIXME: report a write error
377 fputs(text, f); // FIXME: catch error
382 _save_plain_utf8(const char *file, const char *text)
386 text2 = elm_entry_markup_to_utf8(text);
389 _save_markup_utf8(file, text2);
394 _save(Evas_Object *obj)
396 Widget_Data *wd = elm_widget_data_get(obj);
398 if (!wd->file) return;
401 case ELM_TEXT_FORMAT_PLAIN_UTF8:
402 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
404 case ELM_TEXT_FORMAT_MARKUP_UTF8:
405 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
413 _delay_write(void *data)
415 Widget_Data *wd = elm_widget_data_get(data);
416 if (!wd) return ECORE_CALLBACK_CANCEL;
418 wd->delay_write = NULL;
419 return ECORE_CALLBACK_CANCEL;
422 static Elm_Entry_Text_Filter *
423 _filter_new(void (*func) (void *data, Evas_Object *entry, char **text), void *data)
425 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
426 if (!tf) return NULL;
429 if (func == elm_entry_filter_limit_size)
431 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
438 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
444 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
447 else if (func == elm_entry_filter_accept_set)
449 Elm_Entry_Filter_Accept_Set *as = data, *as2;
456 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
463 as2->accepted = eina_stringshare_add(as->accepted);
465 as2->accepted = NULL;
467 as2->rejected = eina_stringshare_add(as->rejected);
469 as2->rejected = NULL;
478 _filter_free(Elm_Entry_Text_Filter *tf)
480 if (tf->func == elm_entry_filter_limit_size)
482 Elm_Entry_Filter_Limit_Size *lim = tf->data;
485 else if (tf->func == elm_entry_filter_accept_set)
487 Elm_Entry_Filter_Accept_Set *as = tf->data;
490 if (as->accepted) eina_stringshare_del(as->accepted);
491 if (as->rejected) eina_stringshare_del(as->rejected);
499 _del_pre_hook(Evas_Object *obj)
501 Widget_Data *wd = elm_widget_data_get(obj);
505 ecore_timer_del(wd->delay_write);
506 wd->delay_write = NULL;
507 if (wd->autosave) _save(obj);
512 _del_hook(Evas_Object *obj)
514 Widget_Data *wd = elm_widget_data_get(obj);
515 Elm_Entry_Context_Menu_Item *it;
516 Elm_Entry_Item_Provider *ip;
517 Elm_Entry_Text_Filter *tf;
519 if (wd->file) eina_stringshare_del(wd->file);
521 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
522 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
524 entries = eina_list_remove(entries, obj);
525 #ifdef HAVE_ELEMENTARY_X
526 if (wd->sel_notify_handler)
527 ecore_event_handler_del(wd->sel_notify_handler);
528 if (wd->sel_clear_handler)
529 ecore_event_handler_del(wd->sel_clear_handler);
531 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
532 if (wd->text) eina_stringshare_del(wd->text);
533 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
534 if (wd->append_text_idler)
536 ecore_idler_del(wd->append_text_idler);
537 free(wd->append_text_left);
538 wd->append_text_left = NULL;
539 wd->append_text_idler = NULL;
541 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
542 EINA_LIST_FREE(wd->items, it)
544 eina_stringshare_del(it->label);
545 eina_stringshare_del(it->icon_file);
546 eina_stringshare_del(it->icon_group);
549 EINA_LIST_FREE(wd->item_providers, ip)
553 EINA_LIST_FREE(wd->text_filters, tf)
561 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
563 Widget_Data *wd = elm_widget_data_get(obj);
564 edje_object_mirrored_set(wd->ent, rtl);
568 _theme_hook(Evas_Object *obj)
570 Widget_Data *wd = elm_widget_data_get(obj);
572 _elm_widget_mirrored_reload(obj);
573 _mirrored_set(obj, elm_widget_mirrored_get(obj));
575 t = eina_stringshare_add(elm_entry_entry_get(obj));
576 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
577 if (_elm_config->desktop_entry)
578 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
579 elm_entry_entry_set(obj, t);
580 eina_stringshare_del(t);
581 if (elm_widget_disabled_get(obj))
582 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
583 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
584 if (elm_widget_focus_get(obj))
585 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
586 edje_object_message_signal_process(wd->ent);
587 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
588 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
589 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
590 elm_widget_style_get(obj));
596 edj = elm_smart_scroller_edje_object_get(wd->scroller);
597 str = edje_object_data_get(edj, "focus_highlight");
598 if ((str) && (!strcmp(str, "on")))
599 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
601 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
607 _disable_hook(Evas_Object *obj)
609 Widget_Data *wd = elm_widget_data_get(obj);
611 if (elm_widget_disabled_get(obj))
613 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
614 wd->disabled = EINA_TRUE;
618 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
619 wd->disabled = EINA_FALSE;
624 _recalc_cursor_geometry(Evas_Object *obj)
626 Widget_Data *wd = elm_widget_data_get(obj);
628 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
629 if (!wd->deferred_recalc_job)
631 Evas_Coord cx, cy, cw, ch;
632 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
636 elm_widget_show_region_set(obj, cx, cy, cw, ch);
637 wd->cur_changed = EINA_FALSE;
641 wd->deferred_cur = EINA_TRUE;
645 _elm_win_recalc_job(void *data)
647 Widget_Data *wd = elm_widget_data_get(data);
648 Evas_Coord minh = -1, resw = -1, minw = -1;
650 wd->deferred_recalc_job = NULL;
652 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
653 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
654 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
657 /* This is a hack to workaround the way min size hints are treated.
658 * If the minimum width is smaller than the restricted width, it means
659 * the mininmum doesn't matter. */
662 Evas_Coord ominw = -1;
663 evas_object_size_hint_min_get(data, &ominw, NULL);
666 evas_object_size_hint_min_set(data, minw, minh);
668 evas_object_size_hint_max_set(data, -1, minh);
670 evas_object_size_hint_max_set(data, -1, -1);
672 if (wd->deferred_cur)
674 Evas_Coord cx, cy, cw, ch;
675 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
679 elm_widget_show_region_set(data, cx, cy, cw, ch);
680 wd->cur_changed = EINA_FALSE;
686 _sizing_eval(Evas_Object *obj)
688 Widget_Data *wd = elm_widget_data_get(obj);
689 Evas_Coord minw = -1, minh = -1;
690 Evas_Coord resw, resh;
693 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
696 if ((resw == wd->lastw) && (!wd->changed)) return;
697 wd->changed = EINA_FALSE;
701 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
703 evas_object_resize(wd->scroller, resw, resh);
704 edje_object_size_min_calc
705 (elm_smart_scroller_edje_object_get(wd->scroller),
707 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
708 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
711 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
713 if ((minw > 0) && (vw < minw)) vw = minw;
714 if (minh > vh) vh = minh;
716 if (wd->single_line) h = vmh + minh;
718 evas_object_resize(wd->ent, vw, vh);
719 evas_object_size_hint_min_set(obj, w, h);
721 evas_object_size_hint_max_set(obj, -1, h);
723 evas_object_size_hint_max_set(obj, -1, -1);
727 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
728 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
733 if (!wd->changed) return;
734 wd->changed = EINA_FALSE;
738 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
740 edje_object_size_min_calc(wd->ent, &minw, &minh);
743 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
745 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
747 if ((minw > 0) && (vw < minw)) vw = minw;
748 if (minh > 0) vh = minh;
750 evas_object_resize(wd->ent, vw, vh);
751 edje_object_size_min_calc
752 (elm_smart_scroller_edje_object_get(wd->scroller),
754 if (wd->single_line) h = vmh + minh;
756 evas_object_size_hint_min_set(obj, w, h);
758 evas_object_size_hint_max_set(obj, -1, h);
760 evas_object_size_hint_max_set(obj, -1, -1);
764 edje_object_size_min_calc(wd->ent, &minw, &minh);
767 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
768 evas_object_size_hint_min_set(obj, minw, minh);
770 evas_object_size_hint_max_set(obj, -1, minh);
772 evas_object_size_hint_max_set(obj, -1, -1);
776 _recalc_cursor_geometry(obj);
780 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
782 Widget_Data *wd = elm_widget_data_get(obj);
783 Evas_Object *top = elm_widget_top_get(obj);
785 if (!wd->editable) return;
786 if (elm_widget_focus_get(obj))
788 evas_object_focus_set(wd->ent, EINA_TRUE);
789 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
790 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
791 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
795 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
796 evas_object_focus_set(wd->ent, EINA_FALSE);
797 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
798 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
803 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
805 Widget_Data *wd = elm_widget_data_get(obj);
807 edje_object_signal_emit(wd->ent, emission, source);
809 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
814 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
816 Widget_Data *wd = elm_widget_data_get(obj);
818 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
820 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
821 emission, source, func_cb, data);
825 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
827 Widget_Data *wd = elm_widget_data_get(obj);
828 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
831 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
832 emission, source, func_cb, data);
836 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
838 Widget_Data *wd = elm_widget_data_get(obj);
839 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
843 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
845 Widget_Data *wd = elm_widget_data_get(obj);
847 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
851 _show_region_hook(void *data, Evas_Object *obj)
853 Widget_Data *wd = elm_widget_data_get(data);
854 Evas_Coord x, y, w, h;
856 elm_widget_show_region_get(obj, &x, &y, &w, &h);
858 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
862 _hoversel_position(Evas_Object *obj)
864 Widget_Data *wd = elm_widget_data_get(obj);
865 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
870 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
879 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
881 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
892 evas_object_move(wd->hoversel, x + cx, y + cy);
893 evas_object_resize(wd->hoversel, cw, ch);
897 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
899 Widget_Data *wd = elm_widget_data_get(data);
901 if (wd->hoversel) _hoversel_position(data);
905 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
907 Widget_Data *wd = elm_widget_data_get(data);
916 Evas_Coord vw = 0, vh = 0;
918 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
919 if (vw < wd->entmw) vw = wd->entmw;
920 if (vh < wd->entmh) vh = wd->entmh;
921 evas_object_resize(wd->ent, vw, vh);
923 if (wd->hoversel) _hoversel_position(data);
927 _hover_del(void *data)
929 Widget_Data *wd = elm_widget_data_get(data);
934 evas_object_del(wd->hoversel);
937 wd->hovdeljob = NULL;
941 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
943 Widget_Data *wd = elm_widget_data_get(data);
946 if (wd->hoversel) evas_object_hide(wd->hoversel);
949 if (!_elm_config->desktop_entry)
952 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
955 elm_widget_scroll_freeze_pop(data);
956 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
957 wd->hovdeljob = ecore_job_add(_hover_del, data);
961 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
963 Widget_Data *wd = elm_widget_data_get(data);
965 wd->selmode = EINA_TRUE;
966 edje_object_part_text_select_none(wd->ent, "elm.text");
967 if (!_elm_config->desktop_entry)
970 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
972 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
973 if (!_elm_config->desktop_entry)
974 elm_widget_scroll_hold_push(data);
978 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
980 Widget_Data *wd = elm_widget_data_get(data);
982 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
983 if (wd->sel_notify_handler)
985 #ifdef HAVE_ELEMENTARY_X
986 Elm_Sel_Format formats;
987 wd->selection_asked = EINA_TRUE;
988 formats = ELM_SEL_FORMAT_MARKUP;
990 formats |= ELM_SEL_FORMAT_IMAGE;
991 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
997 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
999 Widget_Data *wd = elm_widget_data_get(obj);
1003 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1004 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
1005 if (seltype == ELM_SEL_CLIPBOARD)
1006 eina_stringshare_replace(&wd->cut_sel, sel);
1010 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1012 Widget_Data *wd = elm_widget_data_get(data);
1015 wd->selmode = EINA_FALSE;
1016 if (!_elm_config->desktop_entry)
1017 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1018 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1019 if (!_elm_config->desktop_entry)
1020 elm_widget_scroll_hold_pop(data);
1021 _store_selection(ELM_SEL_CLIPBOARD, data);
1022 edje_object_part_text_insert(wd->ent, "elm.text", "");
1023 edje_object_part_text_select_none(wd->ent, "elm.text");
1027 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1029 Widget_Data *wd = elm_widget_data_get(data);
1031 wd->selmode = EINA_FALSE;
1032 if (!_elm_config->desktop_entry)
1034 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1035 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1036 elm_widget_scroll_hold_pop(data);
1038 _store_selection(ELM_SEL_CLIPBOARD, data);
1039 // edje_object_part_text_select_none(wd->ent, "elm.text");
1043 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1047 wd->selmode = EINA_FALSE;
1048 if (!_elm_config->desktop_entry)
1049 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1050 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1051 if (!_elm_config->desktop_entry)
1052 elm_widget_scroll_hold_pop(data);
1053 edje_object_part_text_select_none(wd->ent, "elm.text");
1057 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1059 Elm_Entry_Context_Menu_Item *it = data;
1060 Evas_Object *obj2 = it->obj;
1061 if (it->func) it->func(it->data, obj2, NULL);
1065 _menu_press(Evas_Object *obj)
1067 Widget_Data *wd = elm_widget_data_get(obj);
1070 const Elm_Entry_Context_Menu_Item *it;
1072 if ((wd->api) && (wd->api->obj_longpress))
1074 wd->api->obj_longpress(obj);
1076 else if (wd->context_menu)
1078 const char *context_menu_orientation;
1080 if (wd->hoversel) evas_object_del(wd->hoversel);
1081 else elm_widget_scroll_freeze_push(obj);
1082 wd->hoversel = elm_hoversel_add(obj);
1083 context_menu_orientation = edje_object_data_get
1084 (wd->ent, "context_menu_orientation");
1085 if ((context_menu_orientation) &&
1086 (!strcmp(context_menu_orientation, "horizontal")))
1087 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1088 elm_object_style_set(wd->hoversel, "entry");
1089 elm_widget_sub_object_add(obj, wd->hoversel);
1090 elm_hoversel_label_set(wd->hoversel, "Text");
1091 top = elm_widget_top_get(obj);
1092 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1093 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1094 if (wd->have_selection)
1098 if (wd->have_selection)
1100 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1103 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1106 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1114 if (!_elm_config->desktop_entry)
1117 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1120 if (1) // need way to detect if someone has a selection
1123 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1128 EINA_LIST_FOREACH(wd->items, l, it)
1130 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1131 it->icon_type, _item_clicked, it);
1135 _hoversel_position(obj);
1136 evas_object_show(wd->hoversel);
1137 elm_hoversel_hover_begin(wd->hoversel);
1139 if (!_elm_config->desktop_entry)
1141 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1142 edje_object_part_text_select_abort(wd->ent, "elm.text");
1148 _long_press(void *data)
1150 Widget_Data *wd = elm_widget_data_get(data);
1151 if (!wd) return ECORE_CALLBACK_CANCEL;
1153 wd->longpress_timer = NULL;
1154 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1155 return ECORE_CALLBACK_CANCEL;
1159 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1161 Widget_Data *wd = elm_widget_data_get(data);
1162 Evas_Event_Mouse_Down *ev = event_info;
1164 if (wd->disabled) return;
1165 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1166 wd->downx = ev->canvas.x;
1167 wd->downy = ev->canvas.y;
1168 if (ev->button == 1)
1170 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1171 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1176 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1178 Widget_Data *wd = elm_widget_data_get(data);
1179 Evas_Event_Mouse_Up *ev = event_info;
1181 if (wd->disabled) return;
1182 if (ev->button == 1)
1184 if (wd->longpress_timer)
1186 ecore_timer_del(wd->longpress_timer);
1187 wd->longpress_timer = NULL;
1190 else if (ev->button == 3)
1198 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1200 Widget_Data *wd = elm_widget_data_get(data);
1201 Evas_Event_Mouse_Move *ev = event_info;
1203 if (wd->disabled) return;
1206 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1208 if (wd->longpress_timer)
1210 ecore_timer_del(wd->longpress_timer);
1211 wd->longpress_timer = NULL;
1214 else if (wd->longpress_timer)
1218 dx = wd->downx - ev->cur.canvas.x;
1220 dy = wd->downy - ev->cur.canvas.y;
1223 ((_elm_config->finger_size / 2) *
1224 (_elm_config->finger_size / 2)))
1226 ecore_timer_del(wd->longpress_timer);
1227 wd->longpress_timer = NULL;
1231 else if (wd->longpress_timer)
1235 dx = wd->downx - ev->cur.canvas.x;
1237 dy = wd->downy - ev->cur.canvas.y;
1240 ((_elm_config->finger_size / 2) *
1241 (_elm_config->finger_size / 2)))
1243 ecore_timer_del(wd->longpress_timer);
1244 wd->longpress_timer = NULL;
1250 _getbase(Evas_Object *obj)
1252 Widget_Data *wd = elm_widget_data_get(obj);
1253 if (!wd) return "base";
1256 if (wd->password) return "base-password";
1259 if (wd->single_line) return "base-single";
1262 switch (wd->linewrap)
1265 return "base-charwrap";
1268 case ELM_WRAP_MIXED:
1269 return "base-mixedwrap";
1272 return "base-nowrap";
1279 if (wd->password) return "base-password";
1282 if (wd->single_line) return "base-single-noedit";
1285 switch (wd->linewrap)
1288 return "base-noedit-charwrap";
1290 return "base-noedit";
1291 case ELM_WRAP_MIXED:
1292 return "base-noedit-mixedwrap";
1295 return "base-nowrap-noedit";
1304 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1306 Widget_Data *wd = elm_widget_data_get(data);
1309 wd->changed = EINA_TRUE;
1310 /* Reset the size hints which are no more relevant.
1311 * Keep the height, this is a hack, but doesn't really matter
1312 * cause we'll re-eval in a moment. */
1313 evas_object_size_hint_min_get(data, NULL, &minh);
1314 evas_object_size_hint_min_set(data, -1, minh);
1316 if (wd->text) eina_stringshare_del(wd->text);
1318 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1319 if (wd->delay_write)
1321 ecore_timer_del(wd->delay_write);
1322 wd->delay_write = NULL;
1324 if ((!wd->autosave) || (!wd->file)) return;
1325 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1329 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1331 Widget_Data *wd = elm_widget_data_get(data);
1335 EINA_LIST_FOREACH(entries, l, entry)
1337 if (entry != data) elm_entry_select_none(entry);
1339 wd->have_selection = EINA_TRUE;
1340 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1341 #ifdef HAVE_ELEMENTARY_X
1342 if (wd->sel_notify_handler)
1344 const char *txt = elm_entry_selection_get(data);
1347 top = elm_widget_top_get(data);
1348 if ((top) && (elm_win_xwindow_get(top)))
1349 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1355 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1357 Widget_Data *wd = elm_widget_data_get(data);
1359 wd->have_selection = EINA_TRUE;
1360 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1361 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1362 elm_entry_selection_get(data));
1366 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1368 Widget_Data *wd = elm_widget_data_get(data);
1370 if (!wd->have_selection) return;
1371 wd->have_selection = EINA_FALSE;
1372 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1373 if (wd->sel_notify_handler)
1377 #ifdef HAVE_ELEMENTARY_X
1380 top = elm_widget_top_get(data);
1381 if ((top) && (elm_win_xwindow_get(top)))
1382 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1385 eina_stringshare_del(wd->cut_sel);
1390 #ifdef HAVE_ELEMENTARY_X
1393 top = elm_widget_top_get(data);
1394 if ((top) && (elm_win_xwindow_get(top)))
1395 elm_selection_clear(ELM_SEL_PRIMARY, data);
1402 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1404 Widget_Data *wd = elm_widget_data_get(data);
1406 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1407 if (wd->sel_notify_handler)
1409 #ifdef HAVE_ELEMENTARY_X
1412 top = elm_widget_top_get(data);
1413 if ((top) && (elm_win_xwindow_get(top)))
1415 wd->selection_asked = EINA_TRUE;
1416 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
1424 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1426 Widget_Data *wd = elm_widget_data_get(data);
1428 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1429 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1430 elm_entry_selection_get(data));
1434 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1436 Widget_Data *wd = elm_widget_data_get(data);
1438 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1439 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1440 elm_entry_selection_get(data));
1441 edje_object_part_text_insert(wd->ent, "elm.text", "");
1442 wd->changed = EINA_TRUE;
1447 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1449 Widget_Data *wd = elm_widget_data_get(data);
1451 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1452 wd->cur_changed = EINA_TRUE;
1453 _recalc_cursor_geometry(data);
1457 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1459 Widget_Data *wd = elm_widget_data_get(data);
1464 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1466 Widget_Data *wd = elm_widget_data_get(data);
1471 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1473 Widget_Data *wd = elm_widget_data_get(data);
1474 Elm_Entry_Anchor_Info ei;
1475 char *buf2, *p, *p2, *n;
1477 p = strrchr(emission, ',');
1480 const Eina_List *geoms;
1484 while (p2 >= emission)
1486 if (*p2 == ',') break;
1490 buf2 = alloca(5 + p - p2);
1491 strncpy(buf2, p2, p - p2);
1494 ei.button = atoi(buf2);
1495 ei.x = ei.y = ei.w = ei.h = 0;
1497 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1500 Evas_Textblock_Rectangle *r;
1502 Evas_Coord px, py, x, y;
1504 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1505 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1506 EINA_LIST_FOREACH(geoms, l, r)
1508 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1509 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1520 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1525 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1527 Widget_Data *wd = elm_widget_data_get(data);
1532 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1534 Widget_Data *wd = elm_widget_data_get(data);
1539 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1541 Widget_Data *wd = elm_widget_data_get(data);
1546 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1548 Widget_Data *wd = elm_widget_data_get(data);
1550 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1554 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1556 Widget_Data *wd = elm_widget_data_get(data);
1558 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1562 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1564 Widget_Data *wd = elm_widget_data_get(data);
1566 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1570 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1572 Widget_Data *wd = elm_widget_data_get(data);
1574 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1577 #ifdef HAVE_ELEMENTARY_X
1579 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1581 Widget_Data *wd = elm_widget_data_get(data);
1582 Ecore_X_Event_Selection_Notify *ev = event;
1583 if (!wd) return ECORE_CALLBACK_PASS_ON;
1584 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1585 return ECORE_CALLBACK_PASS_ON;
1587 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1588 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1590 Ecore_X_Selection_Data_Text *text_data;
1592 text_data = ev->data;
1593 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1595 if (text_data->text)
1597 char *txt = _elm_util_text_to_mkup(text_data->text);
1601 elm_entry_entry_insert(data, txt);
1606 wd->selection_asked = EINA_FALSE;
1608 else if (ev->selection == ECORE_X_SELECTION_XDND)
1610 Ecore_X_Selection_Data_Text *text_data;
1612 text_data = ev->data;
1613 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1615 if (text_data->text)
1617 char *txt = _elm_util_text_to_mkup(text_data->text);
1621 /* Massive FIXME: this should be at the drag point */
1622 elm_entry_entry_insert(data, txt);
1627 wd->drag_selection_asked = EINA_FALSE;
1629 ecore_x_dnd_send_finished();
1632 return ECORE_CALLBACK_PASS_ON;
1636 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
1638 Widget_Data *wd = elm_widget_data_get(data);
1639 Ecore_X_Event_Selection_Clear *ev = event;
1640 if (!wd) return ECORE_CALLBACK_PASS_ON;
1641 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1642 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1643 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1645 elm_entry_select_none(data);
1647 return ECORE_CALLBACK_PASS_ON;
1651 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1656 wd = elm_widget_data_get(obj);
1657 if (!wd) return EINA_FALSE;
1658 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1660 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1661 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1662 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1663 EDJE_CURSOR_MAIN,drop->x,drop->y);
1664 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1665 elm_entry_entry_insert(obj, drop->data);
1666 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1667 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1673 static Evas_Object *
1674 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1676 Widget_Data *wd = elm_widget_data_get(data);
1679 Elm_Entry_Item_Provider *ip;
1681 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1683 o = ip->func(ip->data, data, item);
1686 if (!strncmp(item, "file://", 7))
1688 const char *fname = item + 7;
1690 o = evas_object_image_filled_add(evas_object_evas_get(data));
1691 evas_object_image_file_set(o, fname, NULL);
1692 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1694 evas_object_show(o);
1699 o = edje_object_add(evas_object_evas_get(data));
1700 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1704 o = edje_object_add(evas_object_evas_get(data));
1705 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1706 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1711 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
1713 Widget_Data *wd = elm_widget_data_get(data);
1715 Elm_Entry_Text_Filter *tf;
1717 if (type == EDJE_TEXT_FILTER_FORMAT)
1720 EINA_LIST_FOREACH(wd->text_filters, l, tf)
1722 tf->func(tf->data, data, text);
1728 /* This function is used to insert text by chunks in jobs */
1730 _text_append_idler(void *data)
1734 Evas_Object *obj = (Evas_Object *) data;
1735 Widget_Data *wd = elm_widget_data_get(obj);
1736 if (wd->text) eina_stringshare_del(wd->text);
1738 wd->changed = EINA_TRUE;
1740 start = wd->append_text_position;
1741 if(start + _CHUNK_SIZE < wd->append_text_len)
1743 wd->append_text_position = (start + _CHUNK_SIZE);
1744 /* Go to the start of the nearest codepoint, because we don't want
1745 * to cut it in the middle */
1746 eina_unicode_utf8_get_prev(wd->append_text_left,
1747 &wd->append_text_position);
1751 wd->append_text_position = wd->append_text_len;
1754 backup = wd->append_text_left[wd->append_text_position];
1755 wd->append_text_left[wd->append_text_position] = '\0';
1757 edje_object_part_text_append(wd->ent, "elm.text",
1758 wd->append_text_left + start);
1760 wd->append_text_left[wd->append_text_position] = backup;
1762 /* If there's still more to go, renew the idler, else, cleanup */
1763 if (wd->append_text_position < wd->append_text_len)
1765 return ECORE_CALLBACK_RENEW;
1769 free(wd->append_text_left);
1770 wd->append_text_left = NULL;
1771 wd->append_text_idler = NULL;
1772 return ECORE_CALLBACK_CANCEL;
1777 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
1779 int i = 0, unit_size;
1780 int current_len = strlen(*text);
1781 char *new_text = *text;
1782 if (unit >= LENGTH_UNIT_LAST) return;
1785 if (*new_text == '<')
1787 while (*new_text != '>')
1790 if (!*new_text) break;
1797 if (*new_text == '&')
1799 while (*(new_text + index) != ';')
1802 if (!*(new_text + index)) break;
1806 index = evas_string_char_next_get(new_text, index, NULL);
1807 markup = malloc(index + 1);
1808 strncpy(markup, new_text, index);
1810 if (unit == LENGTH_UNIT_BYTE)
1811 unit_size = strlen(elm_entry_markup_to_utf8(markup));
1812 else if (unit == LENGTH_UNIT_CHAR)
1813 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
1819 if (can_add < unit_size)
1823 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
1829 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
1830 current_len -= index;
1831 (*text)[current_len] = 0;
1836 can_add -= unit_size;
1841 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
1845 * This adds an entry to @p parent object.
1847 * @param parent The parent object
1848 * @return The new object or NULL if it cannot be created
1853 elm_entry_add(Evas_Object *parent)
1855 Evas_Object *obj, *top;
1859 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1861 ELM_SET_WIDTYPE(widtype, "entry");
1862 elm_widget_type_set(obj, "entry");
1863 elm_widget_sub_object_add(parent, obj);
1864 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1865 elm_widget_data_set(obj, wd);
1866 elm_widget_del_hook_set(obj, _del_hook);
1867 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1868 elm_widget_theme_hook_set(obj, _theme_hook);
1869 elm_widget_disable_hook_set(obj, _disable_hook);
1870 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1871 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
1872 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
1873 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1874 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1875 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
1876 elm_widget_can_focus_set(obj, EINA_TRUE);
1877 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
1879 wd->scroller = elm_smart_scroller_add(e);
1880 elm_widget_sub_object_add(obj, wd->scroller);
1881 elm_smart_scroller_widget_set(wd->scroller, obj);
1882 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
1883 elm_widget_style_get(obj));
1884 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1885 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
1886 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
1887 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
1889 wd->linewrap = ELM_WRAP_WORD;
1890 wd->editable = EINA_TRUE;
1891 wd->disabled = EINA_FALSE;
1892 wd->context_menu = EINA_TRUE;
1893 wd->autosave = EINA_TRUE;
1894 wd->textonly = EINA_FALSE;
1896 wd->ent = edje_object_add(e);
1897 elm_widget_sub_object_add(obj, wd->ent);
1898 edje_object_item_provider_set(wd->ent, _get_item, obj);
1899 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
1900 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
1901 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
1903 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
1905 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
1907 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1909 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
1910 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
1911 _signal_entry_changed, obj);
1912 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
1913 _signal_selection_start, obj);
1914 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
1915 _signal_selection_changed, obj);
1916 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
1917 _signal_selection_cleared, obj);
1918 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
1919 _signal_entry_paste_request, obj);
1920 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
1921 _signal_entry_copy_notify, obj);
1922 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
1923 _signal_entry_cut_notify, obj);
1924 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
1925 _signal_cursor_changed, obj);
1926 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
1927 _signal_anchor_down, obj);
1928 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
1929 _signal_anchor_up, obj);
1930 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
1931 _signal_anchor_clicked, obj);
1932 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
1933 _signal_anchor_move, obj);
1934 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
1935 _signal_anchor_in, obj);
1936 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
1937 _signal_anchor_out, obj);
1938 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
1939 _signal_key_enter, obj);
1940 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
1941 _signal_mouse_down, obj);
1942 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
1943 _signal_mouse_clicked, obj);
1944 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
1945 _signal_mouse_double, obj);
1946 edje_object_part_text_set(wd->ent, "elm.text", "");
1947 if (_elm_config->desktop_entry)
1948 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1949 elm_widget_resize_object_set(obj, wd->ent);
1952 #ifdef HAVE_ELEMENTARY_X
1953 top = elm_widget_top_get(obj);
1954 if ((top) && (elm_win_xwindow_get(top)))
1956 wd->sel_notify_handler =
1957 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
1958 _event_selection_notify, obj);
1959 wd->sel_clear_handler =
1960 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
1961 _event_selection_clear, obj);
1964 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
1965 _drag_drop_cb, NULL);
1968 entries = eina_list_prepend(entries, obj);
1970 // module - find module for entry
1971 wd->api = _module(obj);
1972 // if found - hook in
1973 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
1975 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1976 // TODO: convert Elementary to subclassing of Evas_Smart_Class
1977 // TODO: and save some bytes, making descriptions per-class and not instance!
1978 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1983 * This sets the entry object not to line wrap. All input will
1984 * be on a single line, and the entry box will extend with user input.
1986 * @param obj The entry object
1987 * @param single_line If true, the text in the entry
1988 * will be on a single line.
1993 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
1995 ELM_CHECK_WIDTYPE(obj, widtype);
1996 Widget_Data *wd = elm_widget_data_get(obj);
1998 if (wd->single_line == single_line) return;
1999 wd->single_line = single_line;
2000 wd->linewrap = ELM_WRAP_NONE;
2001 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2005 if (wd->single_line)
2006 elm_smart_scroller_policy_set(wd->scroller,
2007 ELM_SMART_SCROLLER_POLICY_OFF,
2008 ELM_SMART_SCROLLER_POLICY_OFF);
2011 const Elm_Scroller_Policy map[3] =
2013 ELM_SMART_SCROLLER_POLICY_AUTO,
2014 ELM_SMART_SCROLLER_POLICY_ON,
2015 ELM_SMART_SCROLLER_POLICY_OFF
2017 elm_smart_scroller_policy_set(wd->scroller,
2026 * This returns true if the entry has been set to single line mode.
2027 * See also elm_entry_single_line_set().
2029 * @param obj The entry object
2030 * @return single_line If true, the text in the entry is set to display
2036 elm_entry_single_line_get(const Evas_Object *obj)
2038 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2039 Widget_Data *wd = elm_widget_data_get(obj);
2040 if (!wd) return EINA_FALSE;
2041 return wd->single_line;
2045 * This sets the entry object to password mode. All text entered
2046 * and/or displayed within the widget will be replaced with asterisks (*).
2048 * @param obj The entry object
2049 * @param password If true, password mode is enabled.
2054 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2056 ELM_CHECK_WIDTYPE(obj, widtype);
2057 Widget_Data *wd = elm_widget_data_get(obj);
2059 if (wd->password == password) return;
2060 wd->password = password;
2061 wd->single_line = EINA_TRUE;
2062 wd->linewrap = ELM_WRAP_NONE;
2067 * This returns whether password mode is enabled.
2068 * See also elm_entry_password_set().
2070 * @param obj The entry object
2071 * @return If true, the entry is set to display all characters
2077 elm_entry_password_get(const Evas_Object *obj)
2079 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2080 Widget_Data *wd = elm_widget_data_get(obj);
2081 if (!wd) return EINA_FALSE;
2082 return wd->password;
2086 * This sets the text displayed within the entry to @p entry.
2088 * @param obj The entry object
2089 * @param entry The text to be displayed
2094 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2097 ELM_CHECK_WIDTYPE(obj, widtype);
2098 Widget_Data *wd = elm_widget_data_get(obj);
2100 if (!entry) entry = "";
2101 if (wd->text) eina_stringshare_del(wd->text);
2103 wd->changed = EINA_TRUE;
2105 /* Clear currently pending job if there is one */
2106 if (wd->append_text_idler)
2108 ecore_idler_del(wd->append_text_idler);
2109 free(wd->append_text_left);
2110 wd->append_text_left = NULL;
2111 wd->append_text_idler = NULL;
2114 len = strlen(entry);
2115 /* Split to ~_CHUNK_SIZE chunks */
2116 if (len > _CHUNK_SIZE)
2118 wd->append_text_left = (char *) malloc(len + 1);
2121 /* If we decided to use the idler */
2122 if (wd->append_text_left)
2124 /* Need to clear the entry first */
2125 edje_object_part_text_set(wd->ent, "elm.text", "");
2126 memcpy(wd->append_text_left, entry, len + 1);
2127 wd->append_text_position = 0;
2128 wd->append_text_len = len;
2129 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2133 edje_object_part_text_set(wd->ent, "elm.text", entry);
2138 * This appends @p entry to the text of the entry.
2140 * @param obj The entry object
2141 * @param entry The text to be displayed
2146 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2149 ELM_CHECK_WIDTYPE(obj, widtype);
2150 Widget_Data *wd = elm_widget_data_get(obj);
2152 if (!entry) entry = "";
2153 wd->changed = EINA_TRUE;
2155 len = strlen(entry);
2156 if (wd->append_text_left)
2159 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2165 wd->append_text_left = tmpbuf;
2166 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2167 wd->append_text_len += len;
2171 /* FIXME: Add chunked appending here (like in entry_set) */
2172 edje_object_part_text_append(wd->ent, "elm.text", entry);
2177 * This returns the text currently shown in object @p entry.
2178 * See also elm_entry_entry_set().
2180 * @param obj The entry object
2181 * @return The currently displayed text or NULL on failure
2186 elm_entry_entry_get(const Evas_Object *obj)
2188 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2189 Widget_Data *wd = elm_widget_data_get(obj);
2191 if (!wd) return NULL;
2192 if (wd->text) return wd->text;
2193 text = edje_object_part_text_get(wd->ent, "elm.text");
2196 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2199 eina_stringshare_replace(&wd->text, text);
2204 * This returns EINA_TRUE if the entry is empty/there was an error
2205 * and EINA_FALSE if it is not empty.
2207 * @param obj The entry object
2208 * @return If the entry is empty or not.
2213 elm_entry_is_empty(const Evas_Object *obj)
2215 /* FIXME: until there's support for that in textblock, we just check
2216 * to see if the there is text or not. */
2217 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2218 Widget_Data *wd = elm_widget_data_get(obj);
2219 const Evas_Object *tb;
2220 Evas_Textblock_Cursor *cur;
2222 if (!wd) return EINA_TRUE;
2223 /* It's a hack until we get the support suggested above.
2224 * We just create a cursor, point it to the begining, and then
2225 * try to advance it, if it can advance, the tb is not empty,
2226 * otherwise it is. */
2227 tb = edje_object_part_object_get(wd->ent, "elm.text");
2228 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2229 actually, ok for the time being, thsese hackish stuff will be removed
2230 once evas 1.0 is out*/
2231 evas_textblock_cursor_pos_set(cur, 0);
2232 ret = evas_textblock_cursor_char_next(cur);
2233 evas_textblock_cursor_free(cur);
2239 * This returns all selected text within the entry.
2241 * @param obj The entry object
2242 * @return The selected text within the entry or NULL on failure
2247 elm_entry_selection_get(const Evas_Object *obj)
2249 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2250 Widget_Data *wd = elm_widget_data_get(obj);
2251 if (!wd) return NULL;
2252 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2256 * This inserts text in @p entry where the current cursor position.
2258 * This inserts text at the cursor position is as if it was typed
2259 * by the user (note this also allows markup which a user
2260 * can't just "type" as it would be converted to escaped text, so this
2261 * call can be used to insert things like emoticon items or bold push/pop
2262 * tags, other font and color change tags etc.)
2264 * @param obj The entry object
2265 * @param entry The text to insert
2270 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2272 ELM_CHECK_WIDTYPE(obj, widtype);
2273 Widget_Data *wd = elm_widget_data_get(obj);
2275 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2276 wd->changed = EINA_TRUE;
2281 * This enables word line wrapping in the entry object. It is the opposite
2282 * of elm_entry_single_line_set(). Additionally, setting this disables
2283 * character line wrapping.
2285 * @param obj The entry object
2286 * @param wrap If true, the entry will be wrapped once it reaches the end
2287 * of the object. Wrapping will occur at the end of the word before the end of the
2293 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2295 ELM_CHECK_WIDTYPE(obj, widtype);
2296 Widget_Data *wd = elm_widget_data_get(obj);
2298 if (wd->linewrap == wrap) return;
2300 wd->linewrap = wrap;
2305 * This sets the editable attribute of the entry.
2307 * @param obj The entry object
2308 * @param editable If true, the entry will be editable by the user.
2309 * If false, it will be set to the disabled state.
2314 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2316 ELM_CHECK_WIDTYPE(obj, widtype);
2317 Widget_Data *wd = elm_widget_data_get(obj);
2319 if (wd->editable == editable) return;
2320 wd->editable = editable;
2323 #ifdef HAVE_ELEMENTARY_X
2325 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2327 elm_drop_target_del(obj);
2332 * This gets the editable attribute of the entry.
2333 * See also elm_entry_editable_set().
2335 * @param obj The entry object
2336 * @return If true, the entry is editable by the user.
2337 * If false, it is not editable by the user
2342 elm_entry_editable_get(const Evas_Object *obj)
2344 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2345 Widget_Data *wd = elm_widget_data_get(obj);
2346 if (!wd) return EINA_FALSE;
2347 return wd->editable;
2351 * This drops any existing text selection within the entry.
2353 * @param obj The entry object
2358 elm_entry_select_none(Evas_Object *obj)
2360 ELM_CHECK_WIDTYPE(obj, widtype);
2361 Widget_Data *wd = elm_widget_data_get(obj);
2365 wd->selmode = EINA_FALSE;
2366 if (!_elm_config->desktop_entry)
2367 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2368 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2370 wd->have_selection = EINA_FALSE;
2371 edje_object_part_text_select_none(wd->ent, "elm.text");
2375 * This selects all text within the entry.
2377 * @param obj The entry object
2382 elm_entry_select_all(Evas_Object *obj)
2384 ELM_CHECK_WIDTYPE(obj, widtype);
2385 Widget_Data *wd = elm_widget_data_get(obj);
2389 wd->selmode = EINA_FALSE;
2390 if (!_elm_config->desktop_entry)
2391 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2392 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2394 wd->have_selection = EINA_TRUE;
2395 edje_object_part_text_select_all(wd->ent, "elm.text");
2399 * This function returns the geometry of the cursor.
2401 * It's useful if you want to draw something on the cursor (or where it is),
2402 * or for example in the case of scrolled entry where you want to show the
2405 * @param obj The entry object
2406 * @param x returned geometry
2407 * @param y returned geometry
2408 * @param w returned geometry
2409 * @param h returned geometry
2410 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2415 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2417 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2418 Widget_Data *wd = elm_widget_data_get(obj);
2419 if (!wd) return EINA_FALSE;
2420 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2425 * This moves the cursor one place to the right within the entry.
2427 * @param obj The entry object
2428 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2433 elm_entry_cursor_next(Evas_Object *obj)
2435 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2436 Widget_Data *wd = elm_widget_data_get(obj);
2437 if (!wd) return EINA_FALSE;
2438 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2442 * This moves the cursor one place to the left within the entry.
2444 * @param obj The entry object
2445 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2450 elm_entry_cursor_prev(Evas_Object *obj)
2452 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2453 Widget_Data *wd = elm_widget_data_get(obj);
2454 if (!wd) return EINA_FALSE;
2455 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2459 * This moves the cursor one line up within the entry.
2461 * @param obj The entry object
2462 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2467 elm_entry_cursor_up(Evas_Object *obj)
2469 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2470 Widget_Data *wd = elm_widget_data_get(obj);
2471 if (!wd) return EINA_FALSE;
2472 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2476 * This moves the cursor one line down within the entry.
2478 * @param obj The entry object
2479 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2484 elm_entry_cursor_down(Evas_Object *obj)
2486 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2487 Widget_Data *wd = elm_widget_data_get(obj);
2488 if (!wd) return EINA_FALSE;
2489 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2493 * This moves the cursor to the beginning of the entry.
2495 * @param obj The entry object
2500 elm_entry_cursor_begin_set(Evas_Object *obj)
2502 ELM_CHECK_WIDTYPE(obj, widtype);
2503 Widget_Data *wd = elm_widget_data_get(obj);
2505 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2509 * This moves the cursor to the end of the entry.
2511 * @param obj The entry object
2516 elm_entry_cursor_end_set(Evas_Object *obj)
2518 ELM_CHECK_WIDTYPE(obj, widtype);
2519 Widget_Data *wd = elm_widget_data_get(obj);
2522 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2525 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
2526 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
2531 * This moves the cursor to the beginning of the current line.
2533 * @param obj The entry object
2538 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2540 ELM_CHECK_WIDTYPE(obj, widtype);
2541 Widget_Data *wd = elm_widget_data_get(obj);
2543 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2547 * This moves the cursor to the end of the current line.
2549 * @param obj The entry object
2554 elm_entry_cursor_line_end_set(Evas_Object *obj)
2556 ELM_CHECK_WIDTYPE(obj, widtype);
2557 Widget_Data *wd = elm_widget_data_get(obj);
2559 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2563 * This begins a selection within the entry as though
2564 * the user were holding down the mouse button to make a selection.
2566 * @param obj The entry object
2571 elm_entry_cursor_selection_begin(Evas_Object *obj)
2573 ELM_CHECK_WIDTYPE(obj, widtype);
2574 Widget_Data *wd = elm_widget_data_get(obj);
2576 edje_object_part_text_select_begin(wd->ent, "elm.text");
2580 * This ends a selection within the entry as though
2581 * the user had just released the mouse button while making a selection.
2583 * @param obj The entry object
2588 elm_entry_cursor_selection_end(Evas_Object *obj)
2590 ELM_CHECK_WIDTYPE(obj, widtype);
2591 Widget_Data *wd = elm_widget_data_get(obj);
2593 edje_object_part_text_select_extend(wd->ent, "elm.text");
2597 * TODO: fill this in
2599 * @param obj The entry object
2600 * @return TODO: fill this in
2605 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2607 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2608 Widget_Data *wd = elm_widget_data_get(obj);
2609 if (!wd) return EINA_FALSE;
2610 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2614 * This returns whether the cursor is visible.
2616 * @param obj The entry object
2617 * @return If true, the cursor is visible.
2622 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2624 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2625 Widget_Data *wd = elm_widget_data_get(obj);
2626 if (!wd) return EINA_FALSE;
2627 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2631 * TODO: fill this in
2633 * @param obj The entry object
2634 * @return TODO: fill this in
2639 elm_entry_cursor_content_get(const Evas_Object *obj)
2641 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2642 Widget_Data *wd = elm_widget_data_get(obj);
2643 if (!wd) return NULL;
2644 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2648 * Sets the cursor position in the entry to the given value
2650 * @param obj The entry object
2651 * @param pos The position of the cursor
2656 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2658 ELM_CHECK_WIDTYPE(obj, widtype);
2659 Widget_Data *wd = elm_widget_data_get(obj);
2661 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2662 edje_object_message_signal_process(wd->ent);
2666 * Retrieves the current position of the cursor in the entry
2668 * @param obj The entry object
2669 * @return The cursor position
2674 elm_entry_cursor_pos_get(const Evas_Object *obj)
2676 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2677 Widget_Data *wd = elm_widget_data_get(obj);
2679 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2683 * This executes a "cut" action on the selected text in the entry.
2685 * @param obj The entry object
2690 elm_entry_selection_cut(Evas_Object *obj)
2692 ELM_CHECK_WIDTYPE(obj, widtype);
2693 Widget_Data *wd = elm_widget_data_get(obj);
2695 _cut(obj, NULL, NULL);
2699 * This executes a "copy" action on the selected text in the entry.
2701 * @param obj The entry object
2706 elm_entry_selection_copy(Evas_Object *obj)
2708 ELM_CHECK_WIDTYPE(obj, widtype);
2709 Widget_Data *wd = elm_widget_data_get(obj);
2711 _copy(obj, NULL, NULL);
2715 * This executes a "paste" action in the entry.
2717 * @param obj The entry object
2722 elm_entry_selection_paste(Evas_Object *obj)
2724 ELM_CHECK_WIDTYPE(obj, widtype);
2725 Widget_Data *wd = elm_widget_data_get(obj);
2727 _paste(obj, NULL, NULL);
2731 * This clears and frees the items in a entry's contextual (right click) menu.
2733 * @param obj The entry object
2738 elm_entry_context_menu_clear(Evas_Object *obj)
2740 ELM_CHECK_WIDTYPE(obj, widtype);
2741 Widget_Data *wd = elm_widget_data_get(obj);
2742 Elm_Entry_Context_Menu_Item *it;
2744 EINA_LIST_FREE(wd->items, it)
2746 eina_stringshare_del(it->label);
2747 eina_stringshare_del(it->icon_file);
2748 eina_stringshare_del(it->icon_group);
2754 * This adds an item to the entry's contextual menu.
2756 * @param obj The entry object
2757 * @param label The item's text label
2758 * @param icon_file The item's icon file
2759 * @param icon_type The item's icon type
2760 * @param func The callback to execute when the item is clicked
2761 * @param data The data to associate with the item for related functions
2766 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)
2768 ELM_CHECK_WIDTYPE(obj, widtype);
2769 Widget_Data *wd = elm_widget_data_get(obj);
2770 Elm_Entry_Context_Menu_Item *it;
2772 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2774 wd->items = eina_list_append(wd->items, it);
2776 it->label = eina_stringshare_add(label);
2777 it->icon_file = eina_stringshare_add(icon_file);
2778 it->icon_type = icon_type;
2780 it->data = (void *)data;
2784 * This disables the entry's contextual (right click) menu.
2786 * @param obj The entry object
2787 * @param disabled If true, the menu is disabled
2792 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2794 ELM_CHECK_WIDTYPE(obj, widtype);
2795 Widget_Data *wd = elm_widget_data_get(obj);
2797 if (wd->context_menu == !disabled) return;
2798 wd->context_menu = !disabled;
2802 * This returns whether the entry's contextual (right click) menu is disabled.
2804 * @param obj The entry object
2805 * @return If true, the menu is disabled
2810 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2812 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2813 Widget_Data *wd = elm_widget_data_get(obj);
2814 if (!wd) return EINA_FALSE;
2815 return !wd->context_menu;
2819 * This appends a custom item provider to the list for that entry
2821 * This appends the given callback. The list is walked from beginning to end
2822 * with each function called given the item href string in the text. If the
2823 * function returns an object handle other than NULL (it should create an
2824 * and object to do this), then this object is used to replace that item. If
2825 * not the next provider is called until one provides an item object, or the
2826 * default provider in entry does.
2828 * @param obj The entry object
2829 * @param func The function called to provide the item object
2830 * @param data The data passed to @p func
2835 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2837 ELM_CHECK_WIDTYPE(obj, widtype);
2838 Widget_Data *wd = elm_widget_data_get(obj);
2840 EINA_SAFETY_ON_NULL_RETURN(func);
2841 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2845 wd->item_providers = eina_list_append(wd->item_providers, ip);
2849 * This prepends a custom item provider to the list for that entry
2851 * This prepends the given callback. See elm_entry_item_provider_append() for
2854 * @param obj The entry object
2855 * @param func The function called to provide the item object
2856 * @param data The data passed to @p func
2861 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2863 ELM_CHECK_WIDTYPE(obj, widtype);
2864 Widget_Data *wd = elm_widget_data_get(obj);
2866 EINA_SAFETY_ON_NULL_RETURN(func);
2867 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2871 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2875 * This removes a custom item provider to the list for that entry
2877 * This removes the given callback. See elm_entry_item_provider_append() for
2880 * @param obj The entry object
2881 * @param func The function called to provide the item object
2882 * @param data The data passed to @p func
2887 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2889 ELM_CHECK_WIDTYPE(obj, widtype);
2890 Widget_Data *wd = elm_widget_data_get(obj);
2892 Elm_Entry_Item_Provider *ip;
2894 EINA_SAFETY_ON_NULL_RETURN(func);
2895 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2897 if ((ip->func == func) && ((!data) || (ip->data == data)))
2899 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2907 * Append a filter function for text inserted in the entry
2909 * Append the given callback to the list. This functions will be called
2910 * whenever any text is inserted into the entry, with the text to be inserted
2911 * as a parameter. The callback function is free to alter the text in any way
2912 * it wants, but it must remember to free the given pointer and update it.
2913 * If the new text is to be discarded, the function can free it and set it text
2914 * parameter to NULL. This will also prevent any following filters from being
2917 * @param obj The entry object
2918 * @param func The function to use as text filter
2919 * @param data User data to pass to @p func
2924 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
2927 Elm_Entry_Text_Filter *tf;
2928 ELM_CHECK_WIDTYPE(obj, widtype);
2930 wd = elm_widget_data_get(obj);
2932 EINA_SAFETY_ON_NULL_RETURN(func);
2934 tf = _filter_new(func, data);
2937 wd->text_filters = eina_list_append(wd->text_filters, tf);
2941 * Prepend a filter function for text insdrted in the entry
2943 * Prepend the given callback to the list. See elm_entry_text_filter_append()
2944 * for more information
2946 * @param obj The entry object
2947 * @param func The function to use as text filter
2948 * @param data User data to pass to @p func
2953 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
2956 Elm_Entry_Text_Filter *tf;
2957 ELM_CHECK_WIDTYPE(obj, widtype);
2959 wd = elm_widget_data_get(obj);
2961 EINA_SAFETY_ON_NULL_RETURN(func);
2963 tf = _filter_new(func, data);
2966 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
2970 * Remove a filter from the list
2972 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
2973 * for more information.
2975 * @param obj The entry object
2976 * @param func The filter function to remove
2977 * @param data The user data passed when adding the function
2982 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
2986 Elm_Entry_Text_Filter *tf;
2987 ELM_CHECK_WIDTYPE(obj, widtype);
2989 wd = elm_widget_data_get(obj);
2991 EINA_SAFETY_ON_NULL_RETURN(func);
2993 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2995 if ((tf->func == func) && ((!data) || (tf->data == data)))
2997 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3005 * This converts a markup (HTML-like) string into UTF-8.
3006 * Returning string is obtained with malloc.
3007 * After use the returned string, it should be freed.
3009 * @param s The string (in markup) to be converted
3010 * @return The converted string (in UTF-8). It should be freed.
3015 elm_entry_markup_to_utf8(const char *s)
3017 char *ss = _elm_util_mkup_to_text(s);
3018 if (!ss) ss = strdup("");
3023 * This converts a UTF-8 string into markup (HTML-like).
3024 * Returning string is obtained with malloc.
3025 * After use the returned string, it should be freed.
3027 * @param s The string (in UTF-8) to be converted
3028 * @return The converted string (in markup). It should be freed.
3033 elm_entry_utf8_to_markup(const char *s)
3035 char *ss = _elm_util_text_to_mkup(s);
3036 if (!ss) ss = strdup("");
3041 * Filter inserted text based on user defined character and byte limits
3043 * Add this filter to an entry to limit the characters that it will accept
3044 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
3045 * The funtion works on the UTF-8 representation of the string, converting
3046 * it from the set markup, thus not accounting for any format in it.
3048 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
3049 * it as data when setting the filter. In it it's possible to set limits
3050 * by character count or bytes (any of them is disabled if 0), and both can
3051 * be set at the same time. In that case, it first checks for characters,
3054 * The function will cut the inserted text in order to allow only the first
3055 * number of characters that are still allowed. The cut is made in
3056 * characters, even when limiting by bytes, in order to always contain
3057 * valid ones and avoid half unicode characters making it in.
3062 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3064 Elm_Entry_Filter_Limit_Size *lim = data;
3067 const char *(*text_get)(const Evas_Object *);
3068 const char *widget_type;
3070 EINA_SAFETY_ON_NULL_RETURN(data);
3071 EINA_SAFETY_ON_NULL_RETURN(entry);
3072 EINA_SAFETY_ON_NULL_RETURN(text);
3074 /* hack. I don't want to copy the entire function to work with
3076 widget_type = elm_widget_type_get(entry);
3077 if (!strcmp(widget_type, "entry"))
3078 text_get = elm_entry_entry_get;
3082 current = elm_entry_markup_to_utf8(text_get(entry));
3084 if (lim->max_char_count > 0)
3086 len = evas_string_char_len_get(current);
3087 if (len >= lim->max_char_count)
3089 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3095 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
3096 if ((len + newlen) > lim->max_char_count)
3097 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3099 else if (lim->max_byte_count > 0)
3101 len = strlen(current);
3102 if (len >= lim->max_byte_count)
3104 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3110 newlen = strlen(elm_entry_markup_to_utf8(*text));
3111 if ((len + newlen) > lim->max_byte_count)
3112 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3118 * Filter inserted text based on accepted or rejected sets of characters
3120 * Add this filter to an entry to restrict the set of accepted characters
3121 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
3122 * This structure contains both accepted and rejected sets, but they are
3123 * mutually exclusive. If accepted is set, it will be used, otherwise it
3124 * goes on to the rejected set.
3127 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3129 Elm_Entry_Filter_Accept_Set *as = data;
3133 int read_idx, last_read_idx = 0, read_char;
3135 EINA_SAFETY_ON_NULL_RETURN(data);
3136 EINA_SAFETY_ON_NULL_RETURN(text);
3138 if ((!as->accepted) && (!as->rejected))
3144 goes_in = EINA_TRUE;
3149 goes_in = EINA_FALSE;
3153 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3156 int cmp_idx, cmp_char;
3157 Eina_Bool in_set = EINA_FALSE;
3159 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3162 if (read_char == cmp_char)
3167 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3169 if (in_set == goes_in)
3171 int size = read_idx - last_read_idx;
3172 const char *src = (*text) + last_read_idx;
3174 memcpy(insert, *text + last_read_idx, size);
3177 last_read_idx = read_idx;
3178 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3184 * This sets the file (and implicitly loads it) for the text to display and
3185 * then edit. All changes are written back to the file after a short delay if
3186 * the entry object is set to autosave.
3188 * @param obj The entry object
3189 * @param file The path to the file to load and save
3190 * @param format The file format
3195 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3197 ELM_CHECK_WIDTYPE(obj, widtype);
3198 Widget_Data *wd = elm_widget_data_get(obj);
3200 if (wd->delay_write)
3202 ecore_timer_del(wd->delay_write);
3203 wd->delay_write = NULL;
3205 if (wd->autosave) _save(obj);
3206 eina_stringshare_replace(&wd->file, file);
3207 wd->format = format;
3212 * Gets the file to load and save and the file format
3214 * @param obj The entry object
3215 * @param file The path to the file to load and save
3216 * @param format The file format
3221 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3223 ELM_CHECK_WIDTYPE(obj, widtype);
3224 Widget_Data *wd = elm_widget_data_get(obj);
3226 if (file) *file = wd->file;
3227 if (format) *format = wd->format;
3231 * This function writes any changes made to the file set with
3232 * elm_entry_file_set()
3234 * @param obj The entry object
3239 elm_entry_file_save(Evas_Object *obj)
3241 ELM_CHECK_WIDTYPE(obj, widtype);
3242 Widget_Data *wd = elm_widget_data_get(obj);
3244 if (wd->delay_write)
3246 ecore_timer_del(wd->delay_write);
3247 wd->delay_write = NULL;
3250 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3254 * This sets the entry object to 'autosave' the loaded text file or not.
3256 * @param obj The entry object
3257 * @param autosave Autosave the loaded file or not
3262 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3264 ELM_CHECK_WIDTYPE(obj, widtype);
3265 Widget_Data *wd = elm_widget_data_get(obj);
3267 wd->autosave = !!autosave;
3271 * This gets the entry object's 'autosave' status.
3273 * @param obj The entry object
3274 * @return Autosave the loaded file or not
3279 elm_entry_autosave_get(const Evas_Object *obj)
3281 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3282 Widget_Data *wd = elm_widget_data_get(obj);
3283 if (!wd) return EINA_FALSE;
3284 return wd->autosave;
3288 * Control pasting of text and images for the widget.
3290 * Normally the entry allows both text and images to be pasted. By setting
3291 * textonly to be true, this prevents images from being pasted.
3293 * Note this only changes the behaviour of text.
3295 * @param obj The entry object
3296 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
3301 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3303 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3304 ELM_CHECK_WIDTYPE(obj, widtype);
3305 Widget_Data *wd = elm_widget_data_get(obj);
3307 textonly = !!textonly;
3308 if (wd->textonly == textonly) return;
3309 wd->textonly = !!textonly;
3310 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3311 #ifdef HAVE_ELEMENTARY_X
3312 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3317 * Getting elm_entry text paste/drop mode.
3319 * In textonly mode, only text may be pasted or dropped into the widget.
3321 * @param obj The entry object
3322 * @return If the widget only accepts text from pastes.
3327 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3329 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3330 Widget_Data *wd = elm_widget_data_get(obj);
3331 if (!wd) return EINA_FALSE;
3332 return wd->textonly;
3336 * Enable or disable scrolling in entry
3338 * Normally the entry is not scrollable unless you enable it with this call.
3340 * @param obj The entry object
3341 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
3346 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3348 ELM_CHECK_WIDTYPE(obj, widtype);
3349 Widget_Data *wd = elm_widget_data_get(obj);
3352 if (wd->scroll == scroll) return;
3353 wd->scroll = scroll;
3356 elm_widget_sub_object_del(obj, wd->scroller);
3357 elm_widget_resize_object_set(obj, wd->scroller);
3358 elm_widget_sub_object_add(obj, wd->ent);
3359 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3360 evas_object_show(wd->scroller);
3361 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3365 elm_smart_scroller_child_set(wd->scroller, NULL);
3366 elm_widget_sub_object_del(obj, wd->ent);
3367 elm_widget_resize_object_set(obj, wd->ent);
3368 evas_object_smart_member_add(wd->scroller, obj);
3369 elm_widget_sub_object_add(obj, wd->scroller);
3370 evas_object_hide(wd->scroller);
3371 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3378 * Get the scrollable state of the entry
3380 * Normally the entry is not scrollable. This gets the scrollable state
3381 * of the entry. See elm_entry_scrollable_set() for more information.
3383 * @param obj The entry object
3384 * @return The scrollable state
3389 elm_entry_scrollable_get(const Evas_Object *obj)
3391 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3392 Widget_Data *wd = elm_widget_data_get(obj);
3393 if (!wd) return EINA_FALSE;
3398 * This sets a widget to be displayed to the left of a scrolled entry.
3400 * @param obj The scrolled entry object
3401 * @param icon The widget to display on the left side of the scrolled
3404 * @note A previously set widget will be destroyed.
3405 * @note If the object being set does not have minimum size hints set,
3406 * it won't get properly displayed.
3409 * @see elm_entry_end_set
3412 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3414 ELM_CHECK_WIDTYPE(obj, widtype);
3415 Widget_Data *wd = elm_widget_data_get(obj);
3418 EINA_SAFETY_ON_NULL_RETURN(icon);
3419 if (wd->icon == icon) return;
3420 if (wd->icon) evas_object_del(wd->icon);
3422 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3424 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
3425 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3430 * Gets the leftmost widget of the scrolled entry. This object is
3431 * owned by the scrolled entry and should not be modified.
3433 * @param obj The scrolled entry object
3434 * @return the left widget inside the scroller
3439 elm_entry_icon_get(const Evas_Object *obj)
3441 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3442 Widget_Data *wd = elm_widget_data_get(obj);
3443 if (!wd) return NULL;
3448 * Unset the leftmost widget of the scrolled entry, unparenting and
3451 * @param obj The scrolled entry object
3452 * @return the previously set icon sub-object of this entry, on
3455 * @see elm_entry_icon_set()
3460 elm_entry_icon_unset(Evas_Object *obj)
3462 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3463 Widget_Data *wd = elm_widget_data_get(obj);
3464 Evas_Object *ret = NULL;
3465 if (!wd) return NULL;
3468 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
3469 if (!edje) return NULL;
3471 edje_object_part_unswallow(edje, wd->icon);
3472 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3480 * Sets the visibility of the left-side widget of the scrolled entry,
3481 * set by @elm_entry_icon_set().
3483 * @param obj The scrolled entry object
3484 * @param setting EINA_TRUE if the object should be displayed,
3485 * EINA_FALSE if not.
3490 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3492 ELM_CHECK_WIDTYPE(obj, widtype);
3493 Widget_Data *wd = elm_widget_data_get(obj);
3494 if ((!wd) || (!wd->icon)) return;
3496 evas_object_hide(wd->icon);
3498 evas_object_show(wd->icon);
3503 * This sets a widget to be displayed to the end of a scrolled entry.
3505 * @param obj The scrolled entry object
3506 * @param end The widget to display on the right side of the scrolled
3509 * @note A previously set widget will be destroyed.
3510 * @note If the object being set does not have minimum size hints set,
3511 * it won't get properly displayed.
3514 * @see elm_entry_icon_set
3517 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3519 ELM_CHECK_WIDTYPE(obj, widtype);
3520 Widget_Data *wd = elm_widget_data_get(obj);
3523 EINA_SAFETY_ON_NULL_RETURN(end);
3524 if (wd->end == end) return;
3525 if (wd->end) evas_object_del(wd->end);
3527 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3529 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
3530 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3535 * Gets the endmost widget of the scrolled entry. This object is owned
3536 * by the scrolled entry and should not be modified.
3538 * @param obj The scrolled entry object
3539 * @return the right widget inside the scroller
3544 elm_entry_end_get(const Evas_Object *obj)
3546 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3547 Widget_Data *wd = elm_widget_data_get(obj);
3548 if (!wd) return NULL;
3553 * Unset the endmost widget of the scrolled entry, unparenting and
3556 * @param obj The scrolled entry object
3557 * @return the previously set icon sub-object of this entry, on
3560 * @see elm_entry_icon_set()
3565 elm_entry_end_unset(Evas_Object *obj)
3567 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3568 Widget_Data *wd = elm_widget_data_get(obj);
3569 Evas_Object *ret = NULL;
3570 if (!wd) return NULL;
3573 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
3574 if (!edje) return NULL;
3576 edje_object_part_unswallow(edje, wd->end);
3577 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3585 * Sets the visibility of the end widget of the scrolled entry, set by
3586 * @elm_entry_end_set().
3588 * @param obj The scrolled entry object
3589 * @param setting EINA_TRUE if the object should be displayed,
3590 * EINA_FALSE if not.
3595 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3597 ELM_CHECK_WIDTYPE(obj, widtype);
3598 Widget_Data *wd = elm_widget_data_get(obj);
3599 if ((!wd) || (!wd->end)) return;
3601 evas_object_hide(wd->end);
3603 evas_object_show(wd->end);
3608 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
3610 * @param obj The scrolled entry object
3611 * @param h The horizontal scrollbar policy to apply
3612 * @param v The vertical scrollbar policy to apply
3617 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3619 ELM_CHECK_WIDTYPE(obj, widtype);
3620 Widget_Data *wd = elm_widget_data_get(obj);
3621 const Elm_Scroller_Policy map[3] =
3623 ELM_SMART_SCROLLER_POLICY_AUTO,
3624 ELM_SMART_SCROLLER_POLICY_ON,
3625 ELM_SMART_SCROLLER_POLICY_OFF
3630 elm_smart_scroller_policy_set(wd->scroller,
3636 * This enables/disables bouncing within the entry.
3638 * @param obj The scrolled entry object
3639 * @param h The horizontal bounce state
3640 * @param v The vertical bounce state
3645 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3647 ELM_CHECK_WIDTYPE(obj, widtype);
3648 Widget_Data *wd = elm_widget_data_get(obj);
3650 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3654 * Get the bounce mode
3656 * @param obj The Entry object
3657 * @param h_bounce Allow bounce horizontally
3658 * @param v_bounce Allow bounce vertically
3663 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3665 ELM_CHECK_WIDTYPE(obj, widtype);
3666 Widget_Data *wd = elm_widget_data_get(obj);
3668 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);