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
94 * "preedit,changed" - The preedit string has changed
97 /* Maximum chunk size to be inserted to the entry at once
98 * FIXME: This size is arbitrary, should probably choose a better size.
99 * Possibly also find a way to set it to a low value for weak computers,
100 * and to a big value for better computers. */
101 #define _CHUNK_SIZE 10000
103 typedef struct _Mod_Api Mod_Api;
105 typedef struct _Widget_Data Widget_Data;
106 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
107 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
108 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
112 Evas_Object *ent, *scroller, *end, *icon;
113 Evas_Object *hoversel;
114 Ecore_Job *deferred_recalc_job;
115 Ecore_Event_Handler *sel_notify_handler;
116 Ecore_Event_Handler *sel_clear_handler;
117 Ecore_Timer *longpress_timer;
118 Ecore_Timer *delay_write;
119 /* for deferred appending */
120 Ecore_Idler *append_text_idler;
121 char *append_text_left;
122 int append_text_position;
124 /* Only for clipboard */
128 Elm_Text_Format format;
129 Evas_Coord lastw, entmw, entmh;
130 Evas_Coord downx, downy;
132 Eina_List *item_providers;
133 Eina_List *text_filters;
134 Ecore_Job *hovdeljob;
135 Mod_Api *api; // module api if supplied
137 Elm_Scroller_Policy policy_h, policy_v;
138 Elm_Wrap_Type linewrap;
139 Eina_Bool changed : 1;
140 Eina_Bool single_line : 1;
141 Eina_Bool password : 1;
142 Eina_Bool editable : 1;
143 Eina_Bool selection_asked : 1;
144 Eina_Bool have_selection : 1;
145 Eina_Bool selmode : 1;
146 Eina_Bool deferred_cur : 1;
147 Eina_Bool cur_changed : 1;
148 Eina_Bool disabled : 1;
149 Eina_Bool context_menu : 1;
150 Eina_Bool drag_selection_asked : 1;
151 Eina_Bool can_write : 1;
152 Eina_Bool autosave : 1;
153 Eina_Bool textonly : 1;
154 Eina_Bool usedown : 1;
155 Eina_Bool scroll : 1;
158 struct _Elm_Entry_Context_Menu_Item
162 const char *icon_file;
163 const char *icon_group;
164 Elm_Icon_Type icon_type;
169 struct _Elm_Entry_Item_Provider
171 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
175 struct _Elm_Entry_Text_Filter
177 void (*func) (void *data, Evas_Object *entry, char **text);
181 typedef enum _Length_Unit
188 static const char *widtype = NULL;
190 #ifdef HAVE_ELEMENTARY_X
191 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
193 static void _del_hook(Evas_Object *obj);
194 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
195 static void _theme_hook(Evas_Object *obj);
196 static void _disable_hook(Evas_Object *obj);
197 static void _sizing_eval(Evas_Object *obj);
198 static void _on_focus_hook(void *data, Evas_Object *obj);
199 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
200 static const char *_getbase(Evas_Object *obj);
201 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
202 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
203 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
204 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
205 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
206 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
207 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
208 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
209 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
211 static const char SIG_CHANGED[] = "changed";
212 static const char SIG_ACTIVATED[] = "activated";
213 static const char SIG_PRESS[] = "press";
214 static const char SIG_LONGPRESSED[] = "longpressed";
215 static const char SIG_CLICKED[] = "clicked";
216 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
217 static const char SIG_FOCUSED[] = "focused";
218 static const char SIG_UNFOCUSED[] = "unfocused";
219 static const char SIG_SELECTION_PASTE[] = "selection,paste";
220 static const char SIG_SELECTION_COPY[] = "selection,copy";
221 static const char SIG_SELECTION_CUT[] = "selection,cut";
222 static const char SIG_SELECTION_START[] = "selection,start";
223 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
224 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
225 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
226 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
227 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
228 static const Evas_Smart_Cb_Description _signals[] = {
232 {SIG_LONGPRESSED, ""},
234 {SIG_CLICKED_DOUBLE, ""},
237 {SIG_SELECTION_PASTE, ""},
238 {SIG_SELECTION_COPY, ""},
239 {SIG_SELECTION_CUT, ""},
240 {SIG_SELECTION_START, ""},
241 {SIG_SELECTION_CHANGED, ""},
242 {SIG_SELECTION_CLEARED, ""},
243 {SIG_CURSOR_CHANGED, ""},
244 {SIG_ANCHOR_CLICKED, ""},
245 {SIG_PREEDIT_CHANGED, ""},
249 static Eina_List *entries = NULL;
253 void (*obj_hook) (Evas_Object *obj);
254 void (*obj_unhook) (Evas_Object *obj);
255 void (*obj_longpress) (Evas_Object *obj);
259 _module(Evas_Object *obj __UNUSED__)
261 static Elm_Module *m = NULL;
262 if (m) goto ok; // already found - just use
263 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
265 m->api = malloc(sizeof(Mod_Api));
266 if (!m->api) return NULL;
267 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
268 _elm_module_symbol_get(m, "obj_hook");
269 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
270 _elm_module_symbol_get(m, "obj_unhook");
271 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
272 _elm_module_symbol_get(m, "obj_longpress");
273 ok: // ok - return api
278 _buf_append(char *buf, const char *str, int *len, int *alloc)
280 int len2 = strlen(str);
281 if ((*len + len2) >= *alloc)
283 char *buf2 = realloc(buf, *alloc + len2 + 512);
284 if (!buf2) return NULL;
286 *alloc += (512 + len2);
288 strcpy(buf + *len, str);
294 _load_file(const char *file)
298 int alloc = 0, len = 0;
299 char *text = NULL, buf[16384 + 1];
301 f = fopen(file, "rb");
303 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
307 tmp_text = _buf_append(text, buf, &len, &alloc);
308 if (!tmp_text) break;
316 _load_plain(const char *file)
320 text = _load_file(file);
325 text2 = elm_entry_utf8_to_markup(text);
333 _load(Evas_Object *obj)
335 Widget_Data *wd = elm_widget_data_get(obj);
340 elm_entry_entry_set(obj, "");
345 case ELM_TEXT_FORMAT_PLAIN_UTF8:
346 text = _load_plain(wd->file);
348 case ELM_TEXT_FORMAT_MARKUP_UTF8:
349 text = _load_file(wd->file);
357 elm_entry_entry_set(obj, text);
361 elm_entry_entry_set(obj, "");
365 _save_markup_utf8(const char *file, const char *text)
369 if ((!text) || (!text[0]))
371 ecore_file_unlink(file);
374 f = fopen(file, "wb");
377 // FIXME: report a write error
380 fputs(text, f); // FIXME: catch error
385 _save_plain_utf8(const char *file, const char *text)
389 text2 = elm_entry_markup_to_utf8(text);
392 _save_markup_utf8(file, text2);
397 _save(Evas_Object *obj)
399 Widget_Data *wd = elm_widget_data_get(obj);
401 if (!wd->file) return;
404 case ELM_TEXT_FORMAT_PLAIN_UTF8:
405 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
407 case ELM_TEXT_FORMAT_MARKUP_UTF8:
408 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
416 _delay_write(void *data)
418 Widget_Data *wd = elm_widget_data_get(data);
419 if (!wd) return ECORE_CALLBACK_CANCEL;
421 wd->delay_write = NULL;
422 return ECORE_CALLBACK_CANCEL;
425 static Elm_Entry_Text_Filter *
426 _filter_new(void (*func) (void *data, Evas_Object *entry, char **text), void *data)
428 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
429 if (!tf) return NULL;
432 if (func == elm_entry_filter_limit_size)
434 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
441 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
447 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
450 else if (func == elm_entry_filter_accept_set)
452 Elm_Entry_Filter_Accept_Set *as = data, *as2;
459 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
466 as2->accepted = eina_stringshare_add(as->accepted);
468 as2->accepted = NULL;
470 as2->rejected = eina_stringshare_add(as->rejected);
472 as2->rejected = NULL;
481 _filter_free(Elm_Entry_Text_Filter *tf)
483 if (tf->func == elm_entry_filter_limit_size)
485 Elm_Entry_Filter_Limit_Size *lim = tf->data;
488 else if (tf->func == elm_entry_filter_accept_set)
490 Elm_Entry_Filter_Accept_Set *as = tf->data;
493 if (as->accepted) eina_stringshare_del(as->accepted);
494 if (as->rejected) eina_stringshare_del(as->rejected);
502 _del_pre_hook(Evas_Object *obj)
504 Widget_Data *wd = elm_widget_data_get(obj);
508 ecore_timer_del(wd->delay_write);
509 wd->delay_write = NULL;
510 if (wd->autosave) _save(obj);
515 _del_hook(Evas_Object *obj)
517 Widget_Data *wd = elm_widget_data_get(obj);
518 Elm_Entry_Context_Menu_Item *it;
519 Elm_Entry_Item_Provider *ip;
520 Elm_Entry_Text_Filter *tf;
522 if (wd->file) eina_stringshare_del(wd->file);
524 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
525 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
527 entries = eina_list_remove(entries, obj);
528 #ifdef HAVE_ELEMENTARY_X
529 if (wd->sel_notify_handler)
530 ecore_event_handler_del(wd->sel_notify_handler);
531 if (wd->sel_clear_handler)
532 ecore_event_handler_del(wd->sel_clear_handler);
534 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
535 if (wd->text) eina_stringshare_del(wd->text);
536 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
537 if (wd->append_text_idler)
539 ecore_idler_del(wd->append_text_idler);
540 free(wd->append_text_left);
541 wd->append_text_left = NULL;
542 wd->append_text_idler = NULL;
544 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
545 EINA_LIST_FREE(wd->items, it)
547 eina_stringshare_del(it->label);
548 eina_stringshare_del(it->icon_file);
549 eina_stringshare_del(it->icon_group);
552 EINA_LIST_FREE(wd->item_providers, ip)
556 EINA_LIST_FREE(wd->text_filters, tf)
564 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
566 Widget_Data *wd = elm_widget_data_get(obj);
567 edje_object_mirrored_set(wd->ent, rtl);
571 _theme_hook(Evas_Object *obj)
573 Widget_Data *wd = elm_widget_data_get(obj);
575 _elm_widget_mirrored_reload(obj);
576 _mirrored_set(obj, elm_widget_mirrored_get(obj));
578 t = eina_stringshare_add(elm_entry_entry_get(obj));
579 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
580 if (_elm_config->desktop_entry)
581 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
582 elm_entry_entry_set(obj, t);
583 eina_stringshare_del(t);
584 if (elm_widget_disabled_get(obj))
585 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
586 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
587 if (elm_widget_focus_get(obj))
588 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
589 edje_object_message_signal_process(wd->ent);
590 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
591 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
592 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
593 elm_widget_style_get(obj));
599 edj = elm_smart_scroller_edje_object_get(wd->scroller);
600 str = edje_object_data_get(edj, "focus_highlight");
601 if ((str) && (!strcmp(str, "on")))
602 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
604 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
610 _disable_hook(Evas_Object *obj)
612 Widget_Data *wd = elm_widget_data_get(obj);
614 if (elm_widget_disabled_get(obj))
616 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
617 wd->disabled = EINA_TRUE;
621 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
622 wd->disabled = EINA_FALSE;
627 _recalc_cursor_geometry(Evas_Object *obj)
629 Widget_Data *wd = elm_widget_data_get(obj);
631 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
632 if (!wd->deferred_recalc_job)
634 Evas_Coord cx, cy, cw, ch;
635 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
639 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
640 wd->cur_changed = EINA_FALSE;
644 wd->deferred_cur = EINA_TRUE;
648 _elm_win_recalc_job(void *data)
650 Widget_Data *wd = elm_widget_data_get(data);
651 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
653 wd->deferred_recalc_job = NULL;
655 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
656 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
657 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
660 /* This is a hack to workaround the way min size hints are treated.
661 * If the minimum width is smaller than the restricted width, it means
662 * the mininmum doesn't matter. */
665 Evas_Coord ominw = -1;
666 evas_object_size_hint_min_get(data, &ominw, NULL);
670 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
673 Evas_Coord vmw = 0, vmh = 0;
675 edje_object_size_min_calc
676 (elm_smart_scroller_edje_object_get(wd->scroller),
680 evas_object_size_hint_min_set(data, vmw, minh + vmh);
681 evas_object_size_hint_max_set(data, -1, minh + vmh);
685 evas_object_size_hint_min_set(data, vmw, vmh);
686 evas_object_size_hint_max_set(data, -1, -1);
693 evas_object_size_hint_min_set(data, minw, minh);
694 evas_object_size_hint_max_set(data, -1, minh);
698 evas_object_size_hint_min_set(data, fw, minh);
699 evas_object_size_hint_max_set(data, -1, -1);
703 if (wd->deferred_cur)
705 Evas_Coord cx, cy, cw, ch;
706 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
710 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
711 wd->cur_changed = EINA_FALSE;
717 _sizing_eval(Evas_Object *obj)
719 Widget_Data *wd = elm_widget_data_get(obj);
720 Evas_Coord minw = -1, minh = -1;
721 Evas_Coord resw, resh;
724 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
727 if ((resw == wd->lastw) && (!wd->changed)) return;
728 wd->changed = EINA_FALSE;
732 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
734 evas_object_resize(wd->scroller, resw, resh);
735 edje_object_size_min_calc
736 (elm_smart_scroller_edje_object_get(wd->scroller),
738 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
739 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
742 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
744 if ((minw > 0) && (vw < minw)) vw = minw;
745 if (minh > vh) vh = minh;
747 if (wd->single_line) h = vmh + minh;
749 evas_object_resize(wd->ent, vw, vh);
750 evas_object_size_hint_min_set(obj, w, h);
752 evas_object_size_hint_max_set(obj, -1, h);
754 evas_object_size_hint_max_set(obj, -1, -1);
758 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
759 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
764 if (!wd->changed) return;
765 wd->changed = EINA_FALSE;
769 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
771 edje_object_size_min_calc(wd->ent, &minw, &minh);
774 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
776 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
778 if ((minw > 0) && (vw < minw)) vw = minw;
779 if (minh > 0) vh = minh;
781 evas_object_resize(wd->ent, vw, vh);
782 edje_object_size_min_calc
783 (elm_smart_scroller_edje_object_get(wd->scroller),
785 if (wd->single_line) h = vmh + minh;
787 evas_object_size_hint_min_set(obj, w, h);
789 evas_object_size_hint_max_set(obj, -1, h);
791 evas_object_size_hint_max_set(obj, -1, -1);
795 edje_object_size_min_calc(wd->ent, &minw, &minh);
798 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
799 evas_object_size_hint_min_set(obj, minw, minh);
801 evas_object_size_hint_max_set(obj, -1, minh);
803 evas_object_size_hint_max_set(obj, -1, -1);
807 _recalc_cursor_geometry(obj);
811 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
813 Widget_Data *wd = elm_widget_data_get(obj);
814 Evas_Object *top = elm_widget_top_get(obj);
816 if (!wd->editable) return;
817 if (elm_widget_focus_get(obj))
819 evas_object_focus_set(wd->ent, EINA_TRUE);
820 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
821 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
822 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
826 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
827 evas_object_focus_set(wd->ent, EINA_FALSE);
828 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
829 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
834 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
836 Widget_Data *wd = elm_widget_data_get(obj);
838 edje_object_signal_emit(wd->ent, emission, source);
840 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
845 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
847 Widget_Data *wd = elm_widget_data_get(obj);
849 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
851 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
852 emission, source, func_cb, data);
856 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
858 Widget_Data *wd = elm_widget_data_get(obj);
859 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
862 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
863 emission, source, func_cb, data);
867 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
869 Widget_Data *wd = elm_widget_data_get(obj);
870 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
874 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
876 Widget_Data *wd = elm_widget_data_get(obj);
878 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
882 _show_region_hook(void *data, Evas_Object *obj)
884 Widget_Data *wd = elm_widget_data_get(data);
885 Evas_Coord x, y, w, h;
887 elm_widget_show_region_get(obj, &x, &y, &w, &h);
889 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
893 _hoversel_position(Evas_Object *obj)
895 Widget_Data *wd = elm_widget_data_get(obj);
896 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
901 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
910 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
912 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
923 evas_object_move(wd->hoversel, x + cx, y + cy);
924 evas_object_resize(wd->hoversel, cw, ch);
928 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
930 Widget_Data *wd = elm_widget_data_get(data);
932 if (wd->hoversel) _hoversel_position(data);
936 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
938 Widget_Data *wd = elm_widget_data_get(data);
947 Evas_Coord vw = 0, vh = 0;
949 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
950 if (vw < wd->entmw) vw = wd->entmw;
951 if (vh < wd->entmh) vh = wd->entmh;
952 evas_object_resize(wd->ent, vw, vh);
954 if (wd->hoversel) _hoversel_position(data);
958 _hover_del(void *data)
960 Widget_Data *wd = elm_widget_data_get(data);
965 evas_object_del(wd->hoversel);
968 wd->hovdeljob = NULL;
972 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
974 Widget_Data *wd = elm_widget_data_get(data);
977 if (wd->hoversel) evas_object_hide(wd->hoversel);
980 if (!_elm_config->desktop_entry)
983 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
986 elm_widget_scroll_freeze_pop(data);
987 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
988 wd->hovdeljob = ecore_job_add(_hover_del, data);
992 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
994 Widget_Data *wd = elm_widget_data_get(data);
996 wd->selmode = EINA_TRUE;
997 edje_object_part_text_select_none(wd->ent, "elm.text");
998 if (!_elm_config->desktop_entry)
1001 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1003 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1004 if (!_elm_config->desktop_entry)
1005 elm_widget_scroll_hold_push(data);
1009 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1011 Widget_Data *wd = elm_widget_data_get(data);
1013 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1014 if (wd->sel_notify_handler)
1016 #ifdef HAVE_ELEMENTARY_X
1017 Elm_Sel_Format formats;
1018 wd->selection_asked = EINA_TRUE;
1019 formats = ELM_SEL_FORMAT_MARKUP;
1021 formats |= ELM_SEL_FORMAT_IMAGE;
1022 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1028 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1030 Widget_Data *wd = elm_widget_data_get(obj);
1034 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1035 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
1036 if (seltype == ELM_SEL_CLIPBOARD)
1037 eina_stringshare_replace(&wd->cut_sel, sel);
1041 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1043 Widget_Data *wd = elm_widget_data_get(data);
1046 wd->selmode = EINA_FALSE;
1047 if (!_elm_config->desktop_entry)
1048 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1049 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1050 if (!_elm_config->desktop_entry)
1051 elm_widget_scroll_hold_pop(data);
1052 _store_selection(ELM_SEL_CLIPBOARD, data);
1053 edje_object_part_text_insert(wd->ent, "elm.text", "");
1054 edje_object_part_text_select_none(wd->ent, "elm.text");
1058 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1060 Widget_Data *wd = elm_widget_data_get(data);
1062 wd->selmode = EINA_FALSE;
1063 if (!_elm_config->desktop_entry)
1065 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1066 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1067 elm_widget_scroll_hold_pop(data);
1069 _store_selection(ELM_SEL_CLIPBOARD, data);
1070 // edje_object_part_text_select_none(wd->ent, "elm.text");
1074 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1076 Widget_Data *wd = elm_widget_data_get(data);
1078 wd->selmode = EINA_FALSE;
1079 if (!_elm_config->desktop_entry)
1080 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1081 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1082 if (!_elm_config->desktop_entry)
1083 elm_widget_scroll_hold_pop(data);
1084 edje_object_part_text_select_none(wd->ent, "elm.text");
1088 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1090 Elm_Entry_Context_Menu_Item *it = data;
1091 Evas_Object *obj2 = it->obj;
1092 if (it->func) it->func(it->data, obj2, NULL);
1096 _menu_press(Evas_Object *obj)
1098 Widget_Data *wd = elm_widget_data_get(obj);
1101 const Elm_Entry_Context_Menu_Item *it;
1103 if ((wd->api) && (wd->api->obj_longpress))
1105 wd->api->obj_longpress(obj);
1107 else if (wd->context_menu)
1109 const char *context_menu_orientation;
1111 if (wd->hoversel) evas_object_del(wd->hoversel);
1112 else elm_widget_scroll_freeze_push(obj);
1113 wd->hoversel = elm_hoversel_add(obj);
1114 context_menu_orientation = edje_object_data_get
1115 (wd->ent, "context_menu_orientation");
1116 if ((context_menu_orientation) &&
1117 (!strcmp(context_menu_orientation, "horizontal")))
1118 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1119 elm_object_style_set(wd->hoversel, "entry");
1120 elm_widget_sub_object_add(obj, wd->hoversel);
1121 elm_object_text_set(wd->hoversel, "Text");
1122 top = elm_widget_top_get(obj);
1123 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1124 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1125 if (wd->have_selection)
1129 if (wd->have_selection)
1131 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1134 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1137 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1145 if (!_elm_config->desktop_entry)
1148 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1151 if (1) // need way to detect if someone has a selection
1154 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1159 EINA_LIST_FOREACH(wd->items, l, it)
1161 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1162 it->icon_type, _item_clicked, it);
1166 _hoversel_position(obj);
1167 evas_object_show(wd->hoversel);
1168 elm_hoversel_hover_begin(wd->hoversel);
1170 if (!_elm_config->desktop_entry)
1172 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1173 edje_object_part_text_select_abort(wd->ent, "elm.text");
1179 _long_press(void *data)
1181 Widget_Data *wd = elm_widget_data_get(data);
1182 if (!wd) return ECORE_CALLBACK_CANCEL;
1184 wd->longpress_timer = NULL;
1185 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1186 return ECORE_CALLBACK_CANCEL;
1190 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1192 Widget_Data *wd = elm_widget_data_get(data);
1193 Evas_Event_Mouse_Down *ev = event_info;
1195 if (wd->disabled) return;
1196 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1197 wd->downx = ev->canvas.x;
1198 wd->downy = ev->canvas.y;
1199 if (ev->button == 1)
1201 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1202 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1207 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1209 Widget_Data *wd = elm_widget_data_get(data);
1210 Evas_Event_Mouse_Up *ev = event_info;
1212 if (wd->disabled) return;
1213 if (ev->button == 1)
1215 if (wd->longpress_timer)
1217 ecore_timer_del(wd->longpress_timer);
1218 wd->longpress_timer = NULL;
1221 else if (ev->button == 3)
1229 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1231 Widget_Data *wd = elm_widget_data_get(data);
1232 Evas_Event_Mouse_Move *ev = event_info;
1234 if (wd->disabled) return;
1237 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1239 if (wd->longpress_timer)
1241 ecore_timer_del(wd->longpress_timer);
1242 wd->longpress_timer = NULL;
1245 else if (wd->longpress_timer)
1249 dx = wd->downx - ev->cur.canvas.x;
1251 dy = wd->downy - ev->cur.canvas.y;
1254 ((_elm_config->finger_size / 2) *
1255 (_elm_config->finger_size / 2)))
1257 ecore_timer_del(wd->longpress_timer);
1258 wd->longpress_timer = NULL;
1262 else if (wd->longpress_timer)
1266 dx = wd->downx - ev->cur.canvas.x;
1268 dy = wd->downy - ev->cur.canvas.y;
1271 ((_elm_config->finger_size / 2) *
1272 (_elm_config->finger_size / 2)))
1274 ecore_timer_del(wd->longpress_timer);
1275 wd->longpress_timer = NULL;
1281 _getbase(Evas_Object *obj)
1283 Widget_Data *wd = elm_widget_data_get(obj);
1284 if (!wd) return "base";
1287 if (wd->password) return "base-password";
1290 if (wd->single_line) return "base-single";
1293 switch (wd->linewrap)
1296 return "base-charwrap";
1299 case ELM_WRAP_MIXED:
1300 return "base-mixedwrap";
1303 return "base-nowrap";
1310 if (wd->password) return "base-password";
1313 if (wd->single_line) return "base-single-noedit";
1316 switch (wd->linewrap)
1319 return "base-noedit-charwrap";
1321 return "base-noedit";
1322 case ELM_WRAP_MIXED:
1323 return "base-noedit-mixedwrap";
1326 return "base-nowrap-noedit";
1335 _entry_changed_common_handling(void *data, const char *event)
1337 Widget_Data *wd = elm_widget_data_get(data);
1340 wd->changed = EINA_TRUE;
1341 /* Reset the size hints which are no more relevant.
1342 * Keep the height, this is a hack, but doesn't really matter
1343 * cause we'll re-eval in a moment. */
1344 evas_object_size_hint_min_get(data, NULL, &minh);
1345 evas_object_size_hint_min_set(data, -1, minh);
1347 if (wd->text) eina_stringshare_del(wd->text);
1349 evas_object_smart_callback_call(data, event, NULL);
1350 if (wd->delay_write)
1352 ecore_timer_del(wd->delay_write);
1353 wd->delay_write = NULL;
1355 if ((!wd->autosave) || (!wd->file)) return;
1356 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1360 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1362 _entry_changed_common_handling(data, SIG_CHANGED);
1366 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1368 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1372 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1374 Widget_Data *wd = elm_widget_data_get(data);
1378 EINA_LIST_FOREACH(entries, l, entry)
1380 if (entry != data) elm_entry_select_none(entry);
1382 wd->have_selection = EINA_TRUE;
1383 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1384 #ifdef HAVE_ELEMENTARY_X
1385 if (wd->sel_notify_handler)
1387 const char *txt = elm_entry_selection_get(data);
1390 top = elm_widget_top_get(data);
1391 if ((top) && (elm_win_xwindow_get(top)))
1392 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1398 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1400 Widget_Data *wd = elm_widget_data_get(data);
1402 wd->have_selection = EINA_TRUE;
1403 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1404 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1405 elm_entry_selection_get(data));
1409 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1411 Widget_Data *wd = elm_widget_data_get(data);
1413 if (!wd->have_selection) return;
1414 wd->have_selection = EINA_FALSE;
1415 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1416 if (wd->sel_notify_handler)
1420 #ifdef HAVE_ELEMENTARY_X
1423 top = elm_widget_top_get(data);
1424 if ((top) && (elm_win_xwindow_get(top)))
1425 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1428 eina_stringshare_del(wd->cut_sel);
1433 #ifdef HAVE_ELEMENTARY_X
1436 top = elm_widget_top_get(data);
1437 if ((top) && (elm_win_xwindow_get(top)))
1438 elm_selection_clear(ELM_SEL_PRIMARY, data);
1445 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1447 Widget_Data *wd = elm_widget_data_get(data);
1449 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1450 if (wd->sel_notify_handler)
1452 #ifdef HAVE_ELEMENTARY_X
1455 top = elm_widget_top_get(data);
1456 if ((top) && (elm_win_xwindow_get(top)))
1458 wd->selection_asked = EINA_TRUE;
1459 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
1467 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1469 Widget_Data *wd = elm_widget_data_get(data);
1471 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1472 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1473 elm_entry_selection_get(data));
1477 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1479 Widget_Data *wd = elm_widget_data_get(data);
1481 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1482 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1483 elm_entry_selection_get(data));
1484 edje_object_part_text_insert(wd->ent, "elm.text", "");
1485 wd->changed = EINA_TRUE;
1490 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1492 Widget_Data *wd = elm_widget_data_get(data);
1494 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1495 wd->cur_changed = EINA_TRUE;
1496 _recalc_cursor_geometry(data);
1500 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1502 Widget_Data *wd = elm_widget_data_get(data);
1507 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1509 Widget_Data *wd = elm_widget_data_get(data);
1514 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1516 Widget_Data *wd = elm_widget_data_get(data);
1517 Elm_Entry_Anchor_Info ei;
1518 char *buf2, *p, *p2, *n;
1520 p = strrchr(emission, ',');
1523 const Eina_List *geoms;
1527 while (p2 >= emission)
1529 if (*p2 == ',') break;
1533 buf2 = alloca(5 + p - p2);
1534 strncpy(buf2, p2, p - p2);
1537 ei.button = atoi(buf2);
1538 ei.x = ei.y = ei.w = ei.h = 0;
1540 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1543 Evas_Textblock_Rectangle *r;
1545 Evas_Coord px, py, x, y;
1547 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1548 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1549 EINA_LIST_FOREACH(geoms, l, r)
1551 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1552 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1563 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1568 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1570 Widget_Data *wd = elm_widget_data_get(data);
1575 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1577 Widget_Data *wd = elm_widget_data_get(data);
1582 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1584 Widget_Data *wd = elm_widget_data_get(data);
1589 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1591 Widget_Data *wd = elm_widget_data_get(data);
1593 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1597 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1599 Widget_Data *wd = elm_widget_data_get(data);
1601 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1605 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1607 Widget_Data *wd = elm_widget_data_get(data);
1609 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1613 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1615 Widget_Data *wd = elm_widget_data_get(data);
1617 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1620 #ifdef HAVE_ELEMENTARY_X
1622 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1624 Widget_Data *wd = elm_widget_data_get(data);
1625 Ecore_X_Event_Selection_Notify *ev = event;
1626 if (!wd) return ECORE_CALLBACK_PASS_ON;
1627 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1628 return ECORE_CALLBACK_PASS_ON;
1630 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1631 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1633 Ecore_X_Selection_Data_Text *text_data;
1635 text_data = ev->data;
1636 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1638 if (text_data->text)
1640 char *txt = _elm_util_text_to_mkup(text_data->text);
1644 elm_entry_entry_insert(data, txt);
1649 wd->selection_asked = EINA_FALSE;
1651 else if (ev->selection == ECORE_X_SELECTION_XDND)
1653 Ecore_X_Selection_Data_Text *text_data;
1655 text_data = ev->data;
1656 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1658 if (text_data->text)
1660 char *txt = _elm_util_text_to_mkup(text_data->text);
1664 /* Massive FIXME: this should be at the drag point */
1665 elm_entry_entry_insert(data, txt);
1670 wd->drag_selection_asked = EINA_FALSE;
1672 ecore_x_dnd_send_finished();
1675 return ECORE_CALLBACK_PASS_ON;
1679 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
1681 Widget_Data *wd = elm_widget_data_get(data);
1682 Ecore_X_Event_Selection_Clear *ev = event;
1683 if (!wd) return ECORE_CALLBACK_PASS_ON;
1684 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1685 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1686 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1688 elm_entry_select_none(data);
1690 return ECORE_CALLBACK_PASS_ON;
1694 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1699 wd = elm_widget_data_get(obj);
1700 if (!wd) return EINA_FALSE;
1701 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1703 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1704 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1705 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1706 EDJE_CURSOR_MAIN,drop->x,drop->y);
1707 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1708 elm_entry_entry_insert(obj, drop->data);
1709 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1710 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1716 static Evas_Object *
1717 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1719 Widget_Data *wd = elm_widget_data_get(data);
1722 Elm_Entry_Item_Provider *ip;
1724 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1726 o = ip->func(ip->data, data, item);
1729 if (!strncmp(item, "file://", 7))
1731 const char *fname = item + 7;
1733 o = evas_object_image_filled_add(evas_object_evas_get(data));
1734 evas_object_image_file_set(o, fname, NULL);
1735 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1737 evas_object_show(o);
1742 o = edje_object_add(evas_object_evas_get(data));
1743 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1747 o = edje_object_add(evas_object_evas_get(data));
1748 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1749 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1754 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
1756 Widget_Data *wd = elm_widget_data_get(data);
1758 Elm_Entry_Text_Filter *tf;
1760 if (type == EDJE_TEXT_FILTER_FORMAT)
1763 EINA_LIST_FOREACH(wd->text_filters, l, tf)
1765 tf->func(tf->data, data, text);
1771 /* This function is used to insert text by chunks in jobs */
1773 _text_append_idler(void *data)
1777 Evas_Object *obj = (Evas_Object *) data;
1778 Widget_Data *wd = elm_widget_data_get(obj);
1779 if (wd->text) eina_stringshare_del(wd->text);
1781 wd->changed = EINA_TRUE;
1783 start = wd->append_text_position;
1784 if(start + _CHUNK_SIZE < wd->append_text_len)
1786 wd->append_text_position = (start + _CHUNK_SIZE);
1787 /* Go to the start of the nearest codepoint, because we don't want
1788 * to cut it in the middle */
1789 eina_unicode_utf8_get_prev(wd->append_text_left,
1790 &wd->append_text_position);
1794 wd->append_text_position = wd->append_text_len;
1797 backup = wd->append_text_left[wd->append_text_position];
1798 wd->append_text_left[wd->append_text_position] = '\0';
1800 edje_object_part_text_append(wd->ent, "elm.text",
1801 wd->append_text_left + start);
1803 wd->append_text_left[wd->append_text_position] = backup;
1805 /* If there's still more to go, renew the idler, else, cleanup */
1806 if (wd->append_text_position < wd->append_text_len)
1808 return ECORE_CALLBACK_RENEW;
1812 free(wd->append_text_left);
1813 wd->append_text_left = NULL;
1814 wd->append_text_idler = NULL;
1815 return ECORE_CALLBACK_CANCEL;
1820 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
1822 int i = 0, unit_size;
1823 int current_len = strlen(*text);
1824 char *new_text = *text;
1825 if (unit >= LENGTH_UNIT_LAST) return;
1828 if (*new_text == '<')
1830 while (*new_text != '>')
1833 if (!*new_text) break;
1840 if (*new_text == '&')
1842 while (*(new_text + index) != ';')
1845 if (!*(new_text + index)) break;
1849 index = evas_string_char_next_get(new_text, index, NULL);
1850 markup = malloc(index + 1);
1851 strncpy(markup, new_text, index);
1853 if (unit == LENGTH_UNIT_BYTE)
1854 unit_size = strlen(elm_entry_markup_to_utf8(markup));
1855 else if (unit == LENGTH_UNIT_CHAR)
1856 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
1862 if (can_add < unit_size)
1866 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
1872 strncpy(new_text, new_text + index, current_len - ((new_text + index) - *text));
1873 current_len -= index;
1874 (*text)[current_len] = 0;
1879 can_add -= unit_size;
1884 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
1888 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
1891 ELM_CHECK_WIDTYPE(obj, widtype);
1892 if (item && strcmp(item, "default")) return;
1893 Widget_Data *wd = elm_widget_data_get(obj);
1895 if (!entry) entry = "";
1896 if (wd->text) eina_stringshare_del(wd->text);
1898 wd->changed = EINA_TRUE;
1900 /* Clear currently pending job if there is one */
1901 if (wd->append_text_idler)
1903 ecore_idler_del(wd->append_text_idler);
1904 free(wd->append_text_left);
1905 wd->append_text_left = NULL;
1906 wd->append_text_idler = NULL;
1909 len = strlen(entry);
1910 /* Split to ~_CHUNK_SIZE chunks */
1911 if (len > _CHUNK_SIZE)
1913 wd->append_text_left = (char *) malloc(len + 1);
1916 /* If we decided to use the idler */
1917 if (wd->append_text_left)
1919 /* Need to clear the entry first */
1920 edje_object_part_text_set(wd->ent, "elm.text", "");
1921 memcpy(wd->append_text_left, entry, len + 1);
1922 wd->append_text_position = 0;
1923 wd->append_text_len = len;
1924 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
1928 edje_object_part_text_set(wd->ent, "elm.text", entry);
1933 _elm_entry_text_get(const Evas_Object *obj, const char *item)
1935 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1936 Widget_Data *wd = elm_widget_data_get(obj);
1937 if (item && strcmp(item, "default")) return NULL;
1939 if (!wd) return NULL;
1940 if (wd->text) return wd->text;
1941 text = edje_object_part_text_get(wd->ent, "elm.text");
1944 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
1947 eina_stringshare_replace(&wd->text, text);
1952 * This adds an entry to @p parent object.
1954 * @param parent The parent object
1955 * @return The new object or NULL if it cannot be created
1960 elm_entry_add(Evas_Object *parent)
1962 Evas_Object *obj, *top;
1966 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1968 ELM_SET_WIDTYPE(widtype, "entry");
1969 elm_widget_type_set(obj, "entry");
1970 elm_widget_sub_object_add(parent, obj);
1971 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1972 elm_widget_data_set(obj, wd);
1973 elm_widget_del_hook_set(obj, _del_hook);
1974 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1975 elm_widget_theme_hook_set(obj, _theme_hook);
1976 elm_widget_disable_hook_set(obj, _disable_hook);
1977 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1978 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
1979 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
1980 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1981 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1982 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
1983 elm_widget_can_focus_set(obj, EINA_TRUE);
1984 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
1985 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
1986 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
1988 wd->scroller = elm_smart_scroller_add(e);
1989 elm_widget_sub_object_add(obj, wd->scroller);
1990 elm_smart_scroller_widget_set(wd->scroller, obj);
1991 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
1992 elm_widget_style_get(obj));
1993 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1994 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
1995 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
1996 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
1998 wd->linewrap = ELM_WRAP_WORD;
1999 wd->editable = EINA_TRUE;
2000 wd->disabled = EINA_FALSE;
2001 wd->context_menu = EINA_TRUE;
2002 wd->autosave = EINA_TRUE;
2003 wd->textonly = EINA_FALSE;
2005 wd->ent = edje_object_add(e);
2006 elm_widget_sub_object_add(obj, wd->ent);
2007 edje_object_item_provider_set(wd->ent, _get_item, obj);
2008 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2009 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2010 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2012 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2014 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2016 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2018 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2019 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2020 _signal_entry_changed, obj);
2021 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2022 _signal_preedit_changed, obj);
2023 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2024 _signal_selection_start, obj);
2025 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2026 _signal_selection_changed, obj);
2027 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2028 _signal_selection_cleared, obj);
2029 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2030 _signal_entry_paste_request, obj);
2031 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2032 _signal_entry_copy_notify, obj);
2033 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2034 _signal_entry_cut_notify, obj);
2035 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2036 _signal_cursor_changed, obj);
2037 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2038 _signal_anchor_down, obj);
2039 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2040 _signal_anchor_up, obj);
2041 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2042 _signal_anchor_clicked, obj);
2043 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2044 _signal_anchor_move, obj);
2045 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2046 _signal_anchor_in, obj);
2047 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2048 _signal_anchor_out, obj);
2049 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2050 _signal_key_enter, obj);
2051 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2052 _signal_mouse_down, obj);
2053 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2054 _signal_mouse_clicked, obj);
2055 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2056 _signal_mouse_double, obj);
2057 edje_object_part_text_set(wd->ent, "elm.text", "");
2058 if (_elm_config->desktop_entry)
2059 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2060 elm_widget_resize_object_set(obj, wd->ent);
2063 #ifdef HAVE_ELEMENTARY_X
2064 top = elm_widget_top_get(obj);
2065 if ((top) && (elm_win_xwindow_get(top)))
2067 wd->sel_notify_handler =
2068 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2069 _event_selection_notify, obj);
2070 wd->sel_clear_handler =
2071 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2072 _event_selection_clear, obj);
2075 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2076 _drag_drop_cb, NULL);
2079 entries = eina_list_prepend(entries, obj);
2081 // module - find module for entry
2082 wd->api = _module(obj);
2083 // if found - hook in
2084 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2086 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2087 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2088 // TODO: and save some bytes, making descriptions per-class and not instance!
2089 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2094 * This sets the entry object not to line wrap. All input will
2095 * be on a single line, and the entry box will extend with user input.
2097 * @param obj The entry object
2098 * @param single_line If true, the text in the entry
2099 * will be on a single line.
2104 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2106 ELM_CHECK_WIDTYPE(obj, widtype);
2107 Widget_Data *wd = elm_widget_data_get(obj);
2109 if (wd->single_line == single_line) return;
2110 wd->single_line = single_line;
2111 wd->linewrap = ELM_WRAP_NONE;
2112 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2116 if (wd->single_line)
2117 elm_smart_scroller_policy_set(wd->scroller,
2118 ELM_SMART_SCROLLER_POLICY_OFF,
2119 ELM_SMART_SCROLLER_POLICY_OFF);
2122 const Elm_Scroller_Policy map[3] =
2124 ELM_SMART_SCROLLER_POLICY_AUTO,
2125 ELM_SMART_SCROLLER_POLICY_ON,
2126 ELM_SMART_SCROLLER_POLICY_OFF
2128 elm_smart_scroller_policy_set(wd->scroller,
2137 * This returns true if the entry has been set to single line mode.
2138 * See also elm_entry_single_line_set().
2140 * @param obj The entry object
2141 * @return single_line If true, the text in the entry is set to display
2147 elm_entry_single_line_get(const Evas_Object *obj)
2149 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2150 Widget_Data *wd = elm_widget_data_get(obj);
2151 if (!wd) return EINA_FALSE;
2152 return wd->single_line;
2156 * This sets the entry object to password mode. All text entered
2157 * and/or displayed within the widget will be replaced with asterisks (*).
2159 * @param obj The entry object
2160 * @param password If true, password mode is enabled.
2165 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2167 ELM_CHECK_WIDTYPE(obj, widtype);
2168 Widget_Data *wd = elm_widget_data_get(obj);
2170 if (wd->password == password) return;
2171 wd->password = password;
2172 wd->single_line = EINA_TRUE;
2173 wd->linewrap = ELM_WRAP_NONE;
2178 * This returns whether password mode is enabled.
2179 * See also elm_entry_password_set().
2181 * @param obj The entry object
2182 * @return If true, the entry is set to display all characters
2188 elm_entry_password_get(const Evas_Object *obj)
2190 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2191 Widget_Data *wd = elm_widget_data_get(obj);
2192 if (!wd) return EINA_FALSE;
2193 return wd->password;
2197 * This sets the text displayed within the entry to @p entry.
2199 * @param obj The entry object
2200 * @param entry The text to be displayed
2205 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2207 _elm_entry_text_set(obj, NULL, entry);
2211 * This appends @p entry to the text of the entry.
2213 * @param obj The entry object
2214 * @param entry The text to be displayed
2219 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2222 ELM_CHECK_WIDTYPE(obj, widtype);
2223 Widget_Data *wd = elm_widget_data_get(obj);
2225 if (!entry) entry = "";
2226 wd->changed = EINA_TRUE;
2228 len = strlen(entry);
2229 if (wd->append_text_left)
2232 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2238 wd->append_text_left = tmpbuf;
2239 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2240 wd->append_text_len += len;
2244 /* FIXME: Add chunked appending here (like in entry_set) */
2245 edje_object_part_text_append(wd->ent, "elm.text", entry);
2250 * This returns the text currently shown in object @p entry.
2251 * See also elm_entry_entry_set().
2253 * @param obj The entry object
2254 * @return The currently displayed text or NULL on failure
2259 elm_entry_entry_get(const Evas_Object *obj)
2261 return _elm_entry_text_get(obj, NULL);
2265 * This returns EINA_TRUE if the entry is empty/there was an error
2266 * and EINA_FALSE if it is not empty.
2268 * @param obj The entry object
2269 * @return If the entry is empty or not.
2274 elm_entry_is_empty(const Evas_Object *obj)
2276 /* FIXME: until there's support for that in textblock, we just check
2277 * to see if the there is text or not. */
2278 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2279 Widget_Data *wd = elm_widget_data_get(obj);
2280 const Evas_Object *tb;
2281 Evas_Textblock_Cursor *cur;
2283 if (!wd) return EINA_TRUE;
2284 /* It's a hack until we get the support suggested above.
2285 * We just create a cursor, point it to the begining, and then
2286 * try to advance it, if it can advance, the tb is not empty,
2287 * otherwise it is. */
2288 tb = edje_object_part_object_get(wd->ent, "elm.text");
2289 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2290 actually, ok for the time being, thsese hackish stuff will be removed
2291 once evas 1.0 is out*/
2292 evas_textblock_cursor_pos_set(cur, 0);
2293 ret = evas_textblock_cursor_char_next(cur);
2294 evas_textblock_cursor_free(cur);
2300 * This returns all selected text within the entry.
2302 * @param obj The entry object
2303 * @return The selected text within the entry or NULL on failure
2308 elm_entry_selection_get(const Evas_Object *obj)
2310 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2311 Widget_Data *wd = elm_widget_data_get(obj);
2312 if (!wd) return NULL;
2313 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2317 * This inserts text in @p entry where the current cursor position.
2319 * This inserts text at the cursor position is as if it was typed
2320 * by the user (note this also allows markup which a user
2321 * can't just "type" as it would be converted to escaped text, so this
2322 * call can be used to insert things like emoticon items or bold push/pop
2323 * tags, other font and color change tags etc.)
2325 * @param obj The entry object
2326 * @param entry The text to insert
2331 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2333 ELM_CHECK_WIDTYPE(obj, widtype);
2334 Widget_Data *wd = elm_widget_data_get(obj);
2336 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2337 wd->changed = EINA_TRUE;
2342 * This enables word line wrapping in the entry object. It is the opposite
2343 * of elm_entry_single_line_set(). Additionally, setting this disables
2344 * character line wrapping.
2346 * @param obj The entry object
2347 * @param wrap If true, the entry will be wrapped once it reaches the end
2348 * of the object. Wrapping will occur at the end of the word before the end of the
2354 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2356 ELM_CHECK_WIDTYPE(obj, widtype);
2357 Widget_Data *wd = elm_widget_data_get(obj);
2359 if (wd->linewrap == wrap) return;
2361 wd->linewrap = wrap;
2366 * Get the wrapping behavior of the entry.
2367 * See also elm_entry_line_wrap_set().
2369 * @param obj The entry object
2375 elm_entry_line_wrap_get(const Evas_Object *obj)
2377 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2378 Widget_Data *wd = elm_widget_data_get(obj);
2379 if (!wd) return EINA_FALSE;
2380 return wd->linewrap;
2384 * This sets the editable attribute of the entry.
2386 * @param obj The entry object
2387 * @param editable If true, the entry will be editable by the user.
2388 * If false, it will be set to the disabled state.
2393 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2395 ELM_CHECK_WIDTYPE(obj, widtype);
2396 Widget_Data *wd = elm_widget_data_get(obj);
2398 if (wd->editable == editable) return;
2399 wd->editable = editable;
2402 #ifdef HAVE_ELEMENTARY_X
2404 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2406 elm_drop_target_del(obj);
2411 * This gets the editable attribute of the entry.
2412 * See also elm_entry_editable_set().
2414 * @param obj The entry object
2415 * @return If true, the entry is editable by the user.
2416 * If false, it is not editable by the user
2421 elm_entry_editable_get(const Evas_Object *obj)
2423 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2424 Widget_Data *wd = elm_widget_data_get(obj);
2425 if (!wd) return EINA_FALSE;
2426 return wd->editable;
2430 * This drops any existing text selection within the entry.
2432 * @param obj The entry object
2437 elm_entry_select_none(Evas_Object *obj)
2439 ELM_CHECK_WIDTYPE(obj, widtype);
2440 Widget_Data *wd = elm_widget_data_get(obj);
2444 wd->selmode = EINA_FALSE;
2445 if (!_elm_config->desktop_entry)
2446 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2447 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2449 wd->have_selection = EINA_FALSE;
2450 edje_object_part_text_select_none(wd->ent, "elm.text");
2454 * This selects all text within the entry.
2456 * @param obj The entry object
2461 elm_entry_select_all(Evas_Object *obj)
2463 ELM_CHECK_WIDTYPE(obj, widtype);
2464 Widget_Data *wd = elm_widget_data_get(obj);
2468 wd->selmode = EINA_FALSE;
2469 if (!_elm_config->desktop_entry)
2470 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2471 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2473 wd->have_selection = EINA_TRUE;
2474 edje_object_part_text_select_all(wd->ent, "elm.text");
2478 * This function returns the geometry of the cursor.
2480 * It's useful if you want to draw something on the cursor (or where it is),
2481 * or for example in the case of scrolled entry where you want to show the
2484 * @param obj The entry object
2485 * @param x returned geometry
2486 * @param y returned geometry
2487 * @param w returned geometry
2488 * @param h returned geometry
2489 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2494 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2496 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2497 Widget_Data *wd = elm_widget_data_get(obj);
2498 if (!wd) return EINA_FALSE;
2499 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2504 * This moves the cursor one place to the right within the entry.
2506 * @param obj The entry object
2507 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2512 elm_entry_cursor_next(Evas_Object *obj)
2514 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2515 Widget_Data *wd = elm_widget_data_get(obj);
2516 if (!wd) return EINA_FALSE;
2517 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2521 * This moves the cursor one place to the left within the entry.
2523 * @param obj The entry object
2524 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2529 elm_entry_cursor_prev(Evas_Object *obj)
2531 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2532 Widget_Data *wd = elm_widget_data_get(obj);
2533 if (!wd) return EINA_FALSE;
2534 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2538 * This moves the cursor one line up within the entry.
2540 * @param obj The entry object
2541 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2546 elm_entry_cursor_up(Evas_Object *obj)
2548 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2549 Widget_Data *wd = elm_widget_data_get(obj);
2550 if (!wd) return EINA_FALSE;
2551 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2555 * This moves the cursor one line down within the entry.
2557 * @param obj The entry object
2558 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2563 elm_entry_cursor_down(Evas_Object *obj)
2565 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2566 Widget_Data *wd = elm_widget_data_get(obj);
2567 if (!wd) return EINA_FALSE;
2568 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2572 * This moves the cursor to the beginning of the entry.
2574 * @param obj The entry object
2579 elm_entry_cursor_begin_set(Evas_Object *obj)
2581 ELM_CHECK_WIDTYPE(obj, widtype);
2582 Widget_Data *wd = elm_widget_data_get(obj);
2584 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2588 * This moves the cursor to the end of the entry.
2590 * @param obj The entry object
2595 elm_entry_cursor_end_set(Evas_Object *obj)
2597 ELM_CHECK_WIDTYPE(obj, widtype);
2598 Widget_Data *wd = elm_widget_data_get(obj);
2601 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2604 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
2605 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
2610 * This moves the cursor to the beginning of the current line.
2612 * @param obj The entry object
2617 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2619 ELM_CHECK_WIDTYPE(obj, widtype);
2620 Widget_Data *wd = elm_widget_data_get(obj);
2622 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2626 * This moves the cursor to the end of the current line.
2628 * @param obj The entry object
2633 elm_entry_cursor_line_end_set(Evas_Object *obj)
2635 ELM_CHECK_WIDTYPE(obj, widtype);
2636 Widget_Data *wd = elm_widget_data_get(obj);
2638 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2642 * This begins a selection within the entry as though
2643 * the user were holding down the mouse button to make a selection.
2645 * @param obj The entry object
2650 elm_entry_cursor_selection_begin(Evas_Object *obj)
2652 ELM_CHECK_WIDTYPE(obj, widtype);
2653 Widget_Data *wd = elm_widget_data_get(obj);
2655 edje_object_part_text_select_begin(wd->ent, "elm.text");
2659 * This ends a selection within the entry as though
2660 * the user had just released the mouse button while making a selection.
2662 * @param obj The entry object
2667 elm_entry_cursor_selection_end(Evas_Object *obj)
2669 ELM_CHECK_WIDTYPE(obj, widtype);
2670 Widget_Data *wd = elm_widget_data_get(obj);
2672 edje_object_part_text_select_extend(wd->ent, "elm.text");
2676 * TODO: fill this in
2678 * @param obj The entry object
2679 * @return TODO: fill this in
2684 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2686 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2687 Widget_Data *wd = elm_widget_data_get(obj);
2688 if (!wd) return EINA_FALSE;
2689 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2693 * This returns whether the cursor is visible.
2695 * @param obj The entry object
2696 * @return If true, the cursor is visible.
2701 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2703 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2704 Widget_Data *wd = elm_widget_data_get(obj);
2705 if (!wd) return EINA_FALSE;
2706 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2710 * TODO: fill this in
2712 * @param obj The entry object
2713 * @return TODO: fill this in
2718 elm_entry_cursor_content_get(const Evas_Object *obj)
2720 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2721 Widget_Data *wd = elm_widget_data_get(obj);
2722 if (!wd) return NULL;
2723 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2727 * Sets the cursor position in the entry to the given value
2729 * @param obj The entry object
2730 * @param pos The position of the cursor
2735 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2737 ELM_CHECK_WIDTYPE(obj, widtype);
2738 Widget_Data *wd = elm_widget_data_get(obj);
2740 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2741 edje_object_message_signal_process(wd->ent);
2745 * Retrieves the current position of the cursor in the entry
2747 * @param obj The entry object
2748 * @return The cursor position
2753 elm_entry_cursor_pos_get(const Evas_Object *obj)
2755 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2756 Widget_Data *wd = elm_widget_data_get(obj);
2758 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2762 * This executes a "cut" action on the selected text in the entry.
2764 * @param obj The entry object
2769 elm_entry_selection_cut(Evas_Object *obj)
2771 ELM_CHECK_WIDTYPE(obj, widtype);
2772 Widget_Data *wd = elm_widget_data_get(obj);
2774 _cut(obj, NULL, NULL);
2778 * This executes a "copy" action on the selected text in the entry.
2780 * @param obj The entry object
2785 elm_entry_selection_copy(Evas_Object *obj)
2787 ELM_CHECK_WIDTYPE(obj, widtype);
2788 Widget_Data *wd = elm_widget_data_get(obj);
2790 _copy(obj, NULL, NULL);
2794 * This executes a "paste" action in the entry.
2796 * @param obj The entry object
2801 elm_entry_selection_paste(Evas_Object *obj)
2803 ELM_CHECK_WIDTYPE(obj, widtype);
2804 Widget_Data *wd = elm_widget_data_get(obj);
2806 _paste(obj, NULL, NULL);
2810 * This clears and frees the items in a entry's contextual (right click) menu.
2812 * @param obj The entry object
2817 elm_entry_context_menu_clear(Evas_Object *obj)
2819 ELM_CHECK_WIDTYPE(obj, widtype);
2820 Widget_Data *wd = elm_widget_data_get(obj);
2821 Elm_Entry_Context_Menu_Item *it;
2823 EINA_LIST_FREE(wd->items, it)
2825 eina_stringshare_del(it->label);
2826 eina_stringshare_del(it->icon_file);
2827 eina_stringshare_del(it->icon_group);
2833 * This adds an item to the entry's contextual menu.
2835 * @param obj The entry object
2836 * @param label The item's text label
2837 * @param icon_file The item's icon file
2838 * @param icon_type The item's icon type
2839 * @param func The callback to execute when the item is clicked
2840 * @param data The data to associate with the item for related functions
2845 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)
2847 ELM_CHECK_WIDTYPE(obj, widtype);
2848 Widget_Data *wd = elm_widget_data_get(obj);
2849 Elm_Entry_Context_Menu_Item *it;
2851 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2853 wd->items = eina_list_append(wd->items, it);
2855 it->label = eina_stringshare_add(label);
2856 it->icon_file = eina_stringshare_add(icon_file);
2857 it->icon_type = icon_type;
2859 it->data = (void *)data;
2863 * This disables the entry's contextual (right click) menu.
2865 * @param obj The entry object
2866 * @param disabled If true, the menu is disabled
2871 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2873 ELM_CHECK_WIDTYPE(obj, widtype);
2874 Widget_Data *wd = elm_widget_data_get(obj);
2876 if (wd->context_menu == !disabled) return;
2877 wd->context_menu = !disabled;
2881 * This returns whether the entry's contextual (right click) menu is disabled.
2883 * @param obj The entry object
2884 * @return If true, the menu is disabled
2889 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2891 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2892 Widget_Data *wd = elm_widget_data_get(obj);
2893 if (!wd) return EINA_FALSE;
2894 return !wd->context_menu;
2898 * This appends a custom item provider to the list for that entry
2900 * This appends the given callback. The list is walked from beginning to end
2901 * with each function called given the item href string in the text. If the
2902 * function returns an object handle other than NULL (it should create an
2903 * and object to do this), then this object is used to replace that item. If
2904 * not the next provider is called until one provides an item object, or the
2905 * default provider in entry does.
2907 * @param obj The entry object
2908 * @param func The function called to provide the item object
2909 * @param data The data passed to @p func
2914 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2916 ELM_CHECK_WIDTYPE(obj, widtype);
2917 Widget_Data *wd = elm_widget_data_get(obj);
2919 EINA_SAFETY_ON_NULL_RETURN(func);
2920 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2924 wd->item_providers = eina_list_append(wd->item_providers, ip);
2928 * This prepends a custom item provider to the list for that entry
2930 * This prepends the given callback. See elm_entry_item_provider_append() for
2933 * @param obj The entry object
2934 * @param func The function called to provide the item object
2935 * @param data The data passed to @p func
2940 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2942 ELM_CHECK_WIDTYPE(obj, widtype);
2943 Widget_Data *wd = elm_widget_data_get(obj);
2945 EINA_SAFETY_ON_NULL_RETURN(func);
2946 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2950 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2954 * This removes a custom item provider to the list for that entry
2956 * This removes the given callback. See elm_entry_item_provider_append() for
2959 * @param obj The entry object
2960 * @param func The function called to provide the item object
2961 * @param data The data passed to @p func
2966 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2968 ELM_CHECK_WIDTYPE(obj, widtype);
2969 Widget_Data *wd = elm_widget_data_get(obj);
2971 Elm_Entry_Item_Provider *ip;
2973 EINA_SAFETY_ON_NULL_RETURN(func);
2974 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2976 if ((ip->func == func) && ((!data) || (ip->data == data)))
2978 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2986 * Append a filter function for text inserted in the entry
2988 * Append the given callback to the list. This functions will be called
2989 * whenever any text is inserted into the entry, with the text to be inserted
2990 * as a parameter. The callback function is free to alter the text in any way
2991 * it wants, but it must remember to free the given pointer and update it.
2992 * If the new text is to be discarded, the function can free it and set it text
2993 * parameter to NULL. This will also prevent any following filters from being
2996 * @param obj The entry object
2997 * @param func The function to use as text filter
2998 * @param data User data to pass to @p func
3003 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3006 Elm_Entry_Text_Filter *tf;
3007 ELM_CHECK_WIDTYPE(obj, widtype);
3009 wd = elm_widget_data_get(obj);
3011 EINA_SAFETY_ON_NULL_RETURN(func);
3013 tf = _filter_new(func, data);
3016 wd->text_filters = eina_list_append(wd->text_filters, tf);
3020 * Prepend a filter function for text insdrted in the entry
3022 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3023 * for more information
3025 * @param obj The entry object
3026 * @param func The function to use as text filter
3027 * @param data User data to pass to @p func
3032 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3035 Elm_Entry_Text_Filter *tf;
3036 ELM_CHECK_WIDTYPE(obj, widtype);
3038 wd = elm_widget_data_get(obj);
3040 EINA_SAFETY_ON_NULL_RETURN(func);
3042 tf = _filter_new(func, data);
3045 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3049 * Remove a filter from the list
3051 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3052 * for more information.
3054 * @param obj The entry object
3055 * @param func The filter function to remove
3056 * @param data The user data passed when adding the function
3061 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3065 Elm_Entry_Text_Filter *tf;
3066 ELM_CHECK_WIDTYPE(obj, widtype);
3068 wd = elm_widget_data_get(obj);
3070 EINA_SAFETY_ON_NULL_RETURN(func);
3072 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3074 if ((tf->func == func) && ((!data) || (tf->data == data)))
3076 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3084 * This converts a markup (HTML-like) string into UTF-8.
3085 * Returning string is obtained with malloc.
3086 * After use the returned string, it should be freed.
3088 * @param s The string (in markup) to be converted
3089 * @return The converted string (in UTF-8). It should be freed.
3094 elm_entry_markup_to_utf8(const char *s)
3096 char *ss = _elm_util_mkup_to_text(s);
3097 if (!ss) ss = strdup("");
3102 * This converts a UTF-8 string into markup (HTML-like).
3103 * Returning string is obtained with malloc.
3104 * After use the returned string, it should be freed.
3106 * @param s The string (in UTF-8) to be converted
3107 * @return The converted string (in markup). It should be freed.
3112 elm_entry_utf8_to_markup(const char *s)
3114 char *ss = _elm_util_text_to_mkup(s);
3115 if (!ss) ss = strdup("");
3120 * Filter inserted text based on user defined character and byte limits
3122 * Add this filter to an entry to limit the characters that it will accept
3123 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
3124 * The funtion works on the UTF-8 representation of the string, converting
3125 * it from the set markup, thus not accounting for any format in it.
3127 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
3128 * it as data when setting the filter. In it it's possible to set limits
3129 * by character count or bytes (any of them is disabled if 0), and both can
3130 * be set at the same time. In that case, it first checks for characters,
3133 * The function will cut the inserted text in order to allow only the first
3134 * number of characters that are still allowed. The cut is made in
3135 * characters, even when limiting by bytes, in order to always contain
3136 * valid ones and avoid half unicode characters making it in.
3141 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3143 Elm_Entry_Filter_Limit_Size *lim = data;
3146 const char *(*text_get)(const Evas_Object *);
3147 const char *widget_type;
3149 EINA_SAFETY_ON_NULL_RETURN(data);
3150 EINA_SAFETY_ON_NULL_RETURN(entry);
3151 EINA_SAFETY_ON_NULL_RETURN(text);
3153 /* hack. I don't want to copy the entire function to work with
3155 widget_type = elm_widget_type_get(entry);
3156 if (!strcmp(widget_type, "entry"))
3157 text_get = elm_entry_entry_get;
3161 current = elm_entry_markup_to_utf8(text_get(entry));
3163 if (lim->max_char_count > 0)
3165 len = evas_string_char_len_get(current);
3166 if (len >= lim->max_char_count)
3168 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3174 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
3175 if ((len + newlen) > lim->max_char_count)
3176 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3178 else if (lim->max_byte_count > 0)
3180 len = strlen(current);
3181 if (len >= lim->max_byte_count)
3183 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3189 newlen = strlen(elm_entry_markup_to_utf8(*text));
3190 if ((len + newlen) > lim->max_byte_count)
3191 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3197 * Filter inserted text based on accepted or rejected sets of characters
3199 * Add this filter to an entry to restrict the set of accepted characters
3200 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
3201 * This structure contains both accepted and rejected sets, but they are
3202 * mutually exclusive. If accepted is set, it will be used, otherwise it
3203 * goes on to the rejected set.
3206 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3208 Elm_Entry_Filter_Accept_Set *as = data;
3212 int read_idx, last_read_idx = 0, read_char;
3214 EINA_SAFETY_ON_NULL_RETURN(data);
3215 EINA_SAFETY_ON_NULL_RETURN(text);
3217 if ((!as->accepted) && (!as->rejected))
3223 goes_in = EINA_TRUE;
3228 goes_in = EINA_FALSE;
3232 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3235 int cmp_idx, cmp_char;
3236 Eina_Bool in_set = EINA_FALSE;
3238 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3241 if (read_char == cmp_char)
3246 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3248 if (in_set == goes_in)
3250 int size = read_idx - last_read_idx;
3251 const char *src = (*text) + last_read_idx;
3253 memcpy(insert, *text + last_read_idx, size);
3256 last_read_idx = read_idx;
3257 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3263 * This sets the file (and implicitly loads it) for the text to display and
3264 * then edit. All changes are written back to the file after a short delay if
3265 * the entry object is set to autosave.
3267 * @param obj The entry object
3268 * @param file The path to the file to load and save
3269 * @param format The file format
3274 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3276 ELM_CHECK_WIDTYPE(obj, widtype);
3277 Widget_Data *wd = elm_widget_data_get(obj);
3279 if (wd->delay_write)
3281 ecore_timer_del(wd->delay_write);
3282 wd->delay_write = NULL;
3284 if (wd->autosave) _save(obj);
3285 eina_stringshare_replace(&wd->file, file);
3286 wd->format = format;
3291 * Gets the file to load and save and the file format
3293 * @param obj The entry object
3294 * @param file The path to the file to load and save
3295 * @param format The file format
3300 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3302 ELM_CHECK_WIDTYPE(obj, widtype);
3303 Widget_Data *wd = elm_widget_data_get(obj);
3305 if (file) *file = wd->file;
3306 if (format) *format = wd->format;
3310 * This function writes any changes made to the file set with
3311 * elm_entry_file_set()
3313 * @param obj The entry object
3318 elm_entry_file_save(Evas_Object *obj)
3320 ELM_CHECK_WIDTYPE(obj, widtype);
3321 Widget_Data *wd = elm_widget_data_get(obj);
3323 if (wd->delay_write)
3325 ecore_timer_del(wd->delay_write);
3326 wd->delay_write = NULL;
3329 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3333 * This sets the entry object to 'autosave' the loaded text file or not.
3335 * @param obj The entry object
3336 * @param autosave Autosave the loaded file or not
3341 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3343 ELM_CHECK_WIDTYPE(obj, widtype);
3344 Widget_Data *wd = elm_widget_data_get(obj);
3346 wd->autosave = !!autosave;
3350 * This gets the entry object's 'autosave' status.
3352 * @param obj The entry object
3353 * @return Autosave the loaded file or not
3358 elm_entry_autosave_get(const Evas_Object *obj)
3360 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3361 Widget_Data *wd = elm_widget_data_get(obj);
3362 if (!wd) return EINA_FALSE;
3363 return wd->autosave;
3367 * Control pasting of text and images for the widget.
3369 * Normally the entry allows both text and images to be pasted. By setting
3370 * textonly to be true, this prevents images from being pasted.
3372 * Note this only changes the behaviour of text.
3374 * @param obj The entry object
3375 * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
3380 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3382 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3383 ELM_CHECK_WIDTYPE(obj, widtype);
3384 Widget_Data *wd = elm_widget_data_get(obj);
3386 textonly = !!textonly;
3387 if (wd->textonly == textonly) return;
3388 wd->textonly = !!textonly;
3389 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3390 #ifdef HAVE_ELEMENTARY_X
3391 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3396 * Getting elm_entry text paste/drop mode.
3398 * In textonly mode, only text may be pasted or dropped into the widget.
3400 * @param obj The entry object
3401 * @return If the widget only accepts text from pastes.
3406 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3408 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3409 Widget_Data *wd = elm_widget_data_get(obj);
3410 if (!wd) return EINA_FALSE;
3411 return wd->textonly;
3415 * Enable or disable scrolling in entry
3417 * Normally the entry is not scrollable unless you enable it with this call.
3419 * @param obj The entry object
3420 * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
3425 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3427 ELM_CHECK_WIDTYPE(obj, widtype);
3428 Widget_Data *wd = elm_widget_data_get(obj);
3431 if (wd->scroll == scroll) return;
3432 wd->scroll = scroll;
3435 elm_widget_sub_object_del(obj, wd->scroller);
3436 elm_widget_resize_object_set(obj, wd->scroller);
3437 elm_widget_sub_object_add(obj, wd->ent);
3438 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3439 evas_object_show(wd->scroller);
3440 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3444 elm_smart_scroller_child_set(wd->scroller, NULL);
3445 elm_widget_sub_object_del(obj, wd->ent);
3446 elm_widget_resize_object_set(obj, wd->ent);
3447 evas_object_smart_member_add(wd->scroller, obj);
3448 elm_widget_sub_object_add(obj, wd->scroller);
3449 evas_object_hide(wd->scroller);
3450 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3457 * Get the scrollable state of the entry
3459 * Normally the entry is not scrollable. This gets the scrollable state
3460 * of the entry. See elm_entry_scrollable_set() for more information.
3462 * @param obj The entry object
3463 * @return The scrollable state
3468 elm_entry_scrollable_get(const Evas_Object *obj)
3470 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3471 Widget_Data *wd = elm_widget_data_get(obj);
3472 if (!wd) return EINA_FALSE;
3477 * This sets a widget to be displayed to the left of a scrolled entry.
3479 * @param obj The scrolled entry object
3480 * @param icon The widget to display on the left side of the scrolled
3483 * @note A previously set widget will be destroyed.
3484 * @note If the object being set does not have minimum size hints set,
3485 * it won't get properly displayed.
3488 * @see elm_entry_end_set
3491 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3493 ELM_CHECK_WIDTYPE(obj, widtype);
3494 Widget_Data *wd = elm_widget_data_get(obj);
3497 EINA_SAFETY_ON_NULL_RETURN(icon);
3498 if (wd->icon == icon) return;
3499 if (wd->icon) evas_object_del(wd->icon);
3501 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3503 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
3504 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3509 * Gets the leftmost widget of the scrolled entry. This object is
3510 * owned by the scrolled entry and should not be modified.
3512 * @param obj The scrolled entry object
3513 * @return the left widget inside the scroller
3518 elm_entry_icon_get(const Evas_Object *obj)
3520 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3521 Widget_Data *wd = elm_widget_data_get(obj);
3522 if (!wd) return NULL;
3527 * Unset the leftmost widget of the scrolled entry, unparenting and
3530 * @param obj The scrolled entry object
3531 * @return the previously set icon sub-object of this entry, on
3534 * @see elm_entry_icon_set()
3539 elm_entry_icon_unset(Evas_Object *obj)
3541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3542 Widget_Data *wd = elm_widget_data_get(obj);
3543 Evas_Object *ret = NULL;
3544 if (!wd) return NULL;
3547 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
3548 if (!edje) return NULL;
3550 edje_object_part_unswallow(edje, wd->icon);
3551 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3559 * Sets the visibility of the left-side widget of the scrolled entry,
3560 * set by @elm_entry_icon_set().
3562 * @param obj The scrolled entry object
3563 * @param setting EINA_TRUE if the object should be displayed,
3564 * EINA_FALSE if not.
3569 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3571 ELM_CHECK_WIDTYPE(obj, widtype);
3572 Widget_Data *wd = elm_widget_data_get(obj);
3573 if ((!wd) || (!wd->icon)) return;
3575 evas_object_hide(wd->icon);
3577 evas_object_show(wd->icon);
3582 * This sets a widget to be displayed to the end of a scrolled entry.
3584 * @param obj The scrolled entry object
3585 * @param end The widget to display on the right side of the scrolled
3588 * @note A previously set widget will be destroyed.
3589 * @note If the object being set does not have minimum size hints set,
3590 * it won't get properly displayed.
3593 * @see elm_entry_icon_set
3596 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3598 ELM_CHECK_WIDTYPE(obj, widtype);
3599 Widget_Data *wd = elm_widget_data_get(obj);
3602 EINA_SAFETY_ON_NULL_RETURN(end);
3603 if (wd->end == end) return;
3604 if (wd->end) evas_object_del(wd->end);
3606 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3608 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
3609 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3614 * Gets the endmost widget of the scrolled entry. This object is owned
3615 * by the scrolled entry and should not be modified.
3617 * @param obj The scrolled entry object
3618 * @return the right widget inside the scroller
3623 elm_entry_end_get(const Evas_Object *obj)
3625 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3626 Widget_Data *wd = elm_widget_data_get(obj);
3627 if (!wd) return NULL;
3632 * Unset the endmost widget of the scrolled entry, unparenting and
3635 * @param obj The scrolled entry object
3636 * @return the previously set icon sub-object of this entry, on
3639 * @see elm_entry_icon_set()
3644 elm_entry_end_unset(Evas_Object *obj)
3646 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3647 Widget_Data *wd = elm_widget_data_get(obj);
3648 Evas_Object *ret = NULL;
3649 if (!wd) return NULL;
3652 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
3653 if (!edje) return NULL;
3655 edje_object_part_unswallow(edje, wd->end);
3656 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3664 * Sets the visibility of the end widget of the scrolled entry, set by
3665 * @elm_entry_end_set().
3667 * @param obj The scrolled entry object
3668 * @param setting EINA_TRUE if the object should be displayed,
3669 * EINA_FALSE if not.
3674 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3676 ELM_CHECK_WIDTYPE(obj, widtype);
3677 Widget_Data *wd = elm_widget_data_get(obj);
3678 if ((!wd) || (!wd->end)) return;
3680 evas_object_hide(wd->end);
3682 evas_object_show(wd->end);
3687 * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
3689 * @param obj The scrolled entry object
3690 * @param h The horizontal scrollbar policy to apply
3691 * @param v The vertical scrollbar policy to apply
3696 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3698 ELM_CHECK_WIDTYPE(obj, widtype);
3699 Widget_Data *wd = elm_widget_data_get(obj);
3700 const Elm_Scroller_Policy map[3] =
3702 ELM_SMART_SCROLLER_POLICY_AUTO,
3703 ELM_SMART_SCROLLER_POLICY_ON,
3704 ELM_SMART_SCROLLER_POLICY_OFF
3709 elm_smart_scroller_policy_set(wd->scroller,
3715 * This enables/disables bouncing within the entry.
3717 * @param obj The scrolled entry object
3718 * @param h The horizontal bounce state
3719 * @param v The vertical bounce state
3724 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3726 ELM_CHECK_WIDTYPE(obj, widtype);
3727 Widget_Data *wd = elm_widget_data_get(obj);
3729 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3733 * Get the bounce mode
3735 * @param obj The Entry object
3736 * @param h_bounce Allow bounce horizontally
3737 * @param v_bounce Allow bounce vertically
3742 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3744 ELM_CHECK_WIDTYPE(obj, widtype);
3745 Widget_Data *wd = elm_widget_data_get(obj);
3747 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);