1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "els_scroller.h"
7 /* Maximum chunk size to be inserted to the entry at once
8 * FIXME: This size is arbitrary, should probably choose a better size.
9 * Possibly also find a way to set it to a low value for weak computers,
10 * and to a big value for better computers. */
11 #define _CHUNK_SIZE 10000
13 typedef struct _Mod_Api Mod_Api;
15 typedef struct _Widget_Data Widget_Data;
16 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
17 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
18 typedef struct _Elm_Entry_Markup_Filter Elm_Entry_Markup_Filter;
22 Evas_Object *ent, *scroller;
23 Evas_Object *hoversel;
24 Ecore_Job *deferred_recalc_job;
25 Ecore_Event_Handler *sel_notify_handler;
26 Ecore_Event_Handler *sel_clear_handler;
27 Ecore_Timer *longpress_timer;
28 Ecore_Timer *delay_write;
29 /* for deferred appending */
30 Ecore_Idler *append_text_idler;
31 char *append_text_left;
32 int append_text_position;
34 /* Only for clipboard */
38 Elm_Text_Format format;
39 Evas_Coord lastw, entmw, entmh;
40 Evas_Coord downx, downy;
42 Eina_List *item_providers;
43 Eina_List *text_filters;
44 Eina_List *markup_filters;
46 Mod_Api *api; // module api if supplied
48 Elm_Scroller_Policy policy_h, policy_v;
49 Elm_Wrap_Type linewrap;
50 Elm_Input_Panel_Layout input_panel_layout;
51 Elm_Autocapital_Type autocapital_type;
52 Eina_Bool changed : 1;
53 Eina_Bool single_line : 1;
54 Eina_Bool password : 1;
55 Eina_Bool editable : 1;
56 Eina_Bool selection_asked : 1;
57 Eina_Bool have_selection : 1;
58 Eina_Bool selmode : 1;
59 Eina_Bool deferred_cur : 1;
60 Eina_Bool cur_changed : 1;
61 Eina_Bool disabled : 1;
62 Eina_Bool context_menu : 1;
63 Eina_Bool drag_selection_asked : 1;
64 Eina_Bool can_write : 1;
65 Eina_Bool autosave : 1;
66 Eina_Bool textonly : 1;
67 Eina_Bool usedown : 1;
69 Eina_Bool h_bounce : 1;
70 Eina_Bool v_bounce : 1;
71 Eina_Bool input_panel_enable : 1;
72 Eina_Bool prediction_allow : 1;
75 struct _Elm_Entry_Context_Menu_Item
79 const char *icon_file;
80 const char *icon_group;
81 Elm_Icon_Type icon_type;
86 struct _Elm_Entry_Item_Provider
88 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
92 struct _Elm_Entry_Markup_Filter
94 Elm_Entry_Filter_Cb func;
98 typedef enum _Length_Unit
105 static const char *widtype = NULL;
107 #ifdef HAVE_ELEMENTARY_X
108 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
110 static void _del_hook(Evas_Object *obj);
111 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
112 static void _theme_hook(Evas_Object *obj);
113 static void _disable_hook(Evas_Object *obj);
114 static void _sizing_eval(Evas_Object *obj);
115 static void _on_focus_hook(void *data, Evas_Object *obj);
116 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
117 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
118 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
119 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
120 static const char *_getbase(Evas_Object *obj);
121 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
122 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
123 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
124 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
125 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
126 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
127 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
128 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
129 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
131 static const char SIG_CHANGED[] = "changed";
132 static const char SIG_CHANGED_USER[] = "changed,user";
133 static const char SIG_ACTIVATED[] = "activated";
134 static const char SIG_PRESS[] = "press";
135 static const char SIG_LONGPRESSED[] = "longpressed";
136 static const char SIG_CLICKED[] = "clicked";
137 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
138 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
139 static const char SIG_FOCUSED[] = "focused";
140 static const char SIG_UNFOCUSED[] = "unfocused";
141 static const char SIG_SELECTION_PASTE[] = "selection,paste";
142 static const char SIG_SELECTION_COPY[] = "selection,copy";
143 static const char SIG_SELECTION_CUT[] = "selection,cut";
144 static const char SIG_SELECTION_START[] = "selection,start";
145 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
146 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
147 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
148 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
149 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
150 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
151 static const char SIG_ANCHOR_UP[] = "anchor,up";
152 static const char SIG_ANCHOR_IN[] = "anchor,in";
153 static const char SIG_ANCHOR_OUT[] = "anchor,out";
154 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
155 static const char SIG_UNDO_REQUEST[] = "undo,request";
156 static const char SIG_REDO_REQUEST[] = "redo,request";
157 static const Evas_Smart_Cb_Description _signals[] = {
161 {SIG_LONGPRESSED, ""},
163 {SIG_CLICKED_DOUBLE, ""},
164 {SIG_CLICKED_TRIPLE, ""},
167 {SIG_SELECTION_PASTE, ""},
168 {SIG_SELECTION_COPY, ""},
169 {SIG_SELECTION_CUT, ""},
170 {SIG_SELECTION_START, ""},
171 {SIG_SELECTION_CHANGED, ""},
172 {SIG_SELECTION_CLEARED, ""},
173 {SIG_CURSOR_CHANGED, ""},
174 {SIG_CURSOR_CHANGED_MANUAL, ""},
175 {SIG_ANCHOR_CLICKED, ""},
176 {SIG_ANCHOR_DOWN, ""},
179 {SIG_ANCHOR_OUT, ""},
180 {SIG_PREEDIT_CHANGED, ""},
181 {SIG_CHANGED_USER, ""},
182 {SIG_UNDO_REQUEST, ""},
183 {SIG_REDO_REQUEST, ""},
187 static Eina_List *entries = NULL;
191 void (*obj_hook) (Evas_Object *obj);
192 void (*obj_unhook) (Evas_Object *obj);
193 void (*obj_longpress) (Evas_Object *obj);
197 _module(Evas_Object *obj __UNUSED__)
199 static Elm_Module *m = NULL;
200 if (m) goto ok; // already found - just use
201 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
203 m->api = malloc(sizeof(Mod_Api));
204 if (!m->api) return NULL;
205 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
206 _elm_module_symbol_get(m, "obj_hook");
207 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
208 _elm_module_symbol_get(m, "obj_unhook");
209 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
210 _elm_module_symbol_get(m, "obj_longpress");
211 ok: // ok - return api
216 _buf_append(char *buf, const char *str, int *len, int *alloc)
218 int len2 = strlen(str);
219 if ((*len + len2) >= *alloc)
221 char *buf2 = realloc(buf, *alloc + len2 + 512);
222 if (!buf2) return NULL;
224 *alloc += (512 + len2);
226 strcpy(buf + *len, str);
232 _load_file(const char *file)
236 int alloc = 0, len = 0;
237 char *text = NULL, buf[16384 + 1];
239 f = fopen(file, "rb");
241 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
245 tmp_text = _buf_append(text, buf, &len, &alloc);
246 if (!tmp_text) break;
254 _load_plain(const char *file)
258 text = _load_file(file);
263 text2 = elm_entry_utf8_to_markup(text);
271 _load(Evas_Object *obj)
273 Widget_Data *wd = elm_widget_data_get(obj);
278 elm_object_text_set(obj, "");
283 case ELM_TEXT_FORMAT_PLAIN_UTF8:
284 text = _load_plain(wd->file);
286 case ELM_TEXT_FORMAT_MARKUP_UTF8:
287 text = _load_file(wd->file);
295 elm_object_text_set(obj, text);
299 elm_object_text_set(obj, "");
303 _save_markup_utf8(const char *file, const char *text)
307 if ((!text) || (!text[0]))
309 ecore_file_unlink(file);
312 f = fopen(file, "wb");
315 // FIXME: report a write error
318 fputs(text, f); // FIXME: catch error
323 _save_plain_utf8(const char *file, const char *text)
327 text2 = elm_entry_markup_to_utf8(text);
330 _save_markup_utf8(file, text2);
335 _save(Evas_Object *obj)
337 Widget_Data *wd = elm_widget_data_get(obj);
339 if (!wd->file) return;
342 case ELM_TEXT_FORMAT_PLAIN_UTF8:
343 _save_plain_utf8(wd->file, elm_object_text_get(obj));
345 case ELM_TEXT_FORMAT_MARKUP_UTF8:
346 _save_markup_utf8(wd->file, elm_object_text_get(obj));
354 _delay_write(void *data)
356 Widget_Data *wd = elm_widget_data_get(data);
357 if (!wd) return ECORE_CALLBACK_CANCEL;
359 wd->delay_write = NULL;
360 return ECORE_CALLBACK_CANCEL;
363 static Elm_Entry_Markup_Filter *
364 _filter_new(Elm_Entry_Filter_Cb func, void *data)
366 Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
367 if (!tf) return NULL;
370 if (func == elm_entry_filter_limit_size)
372 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
379 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
385 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
388 else if (func == elm_entry_filter_accept_set)
390 Elm_Entry_Filter_Accept_Set *as = data, *as2;
397 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
404 as2->accepted = eina_stringshare_add(as->accepted);
406 as2->accepted = NULL;
408 as2->rejected = eina_stringshare_add(as->rejected);
410 as2->rejected = NULL;
419 _filter_free(Elm_Entry_Markup_Filter *tf)
421 if (tf->func == elm_entry_filter_limit_size)
423 Elm_Entry_Filter_Limit_Size *lim = tf->data;
426 else if (tf->func == elm_entry_filter_accept_set)
428 Elm_Entry_Filter_Accept_Set *as = tf->data;
431 if (as->accepted) eina_stringshare_del(as->accepted);
432 if (as->rejected) eina_stringshare_del(as->rejected);
440 _del_pre_hook(Evas_Object *obj)
442 Widget_Data *wd = elm_widget_data_get(obj);
446 ecore_timer_del(wd->delay_write);
447 wd->delay_write = NULL;
448 if (wd->autosave) _save(obj);
453 _del_hook(Evas_Object *obj)
455 Widget_Data *wd = elm_widget_data_get(obj);
456 Elm_Entry_Context_Menu_Item *it;
457 Elm_Entry_Item_Provider *ip;
458 Elm_Entry_Markup_Filter *tf;
460 evas_event_freeze(evas_object_evas_get(obj));
462 if (wd->file) eina_stringshare_del(wd->file);
464 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
465 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
467 entries = eina_list_remove(entries, obj);
468 #ifdef HAVE_ELEMENTARY_X
469 if (wd->sel_notify_handler)
470 ecore_event_handler_del(wd->sel_notify_handler);
471 if (wd->sel_clear_handler)
472 ecore_event_handler_del(wd->sel_clear_handler);
474 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
475 if (wd->text) eina_stringshare_del(wd->text);
476 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
477 if (wd->append_text_idler)
479 ecore_idler_del(wd->append_text_idler);
480 free(wd->append_text_left);
481 wd->append_text_left = NULL;
482 wd->append_text_idler = NULL;
484 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
485 EINA_LIST_FREE(wd->items, it)
487 eina_stringshare_del(it->label);
488 eina_stringshare_del(it->icon_file);
489 eina_stringshare_del(it->icon_group);
492 EINA_LIST_FREE(wd->item_providers, ip)
496 EINA_LIST_FREE(wd->text_filters, tf)
500 EINA_LIST_FREE(wd->markup_filters, tf)
504 if (wd->delay_write) ecore_timer_del(wd->delay_write);
507 evas_event_thaw(evas_object_evas_get(obj));
508 evas_event_thaw_eval(evas_object_evas_get(obj));
512 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
514 Widget_Data *wd = elm_widget_data_get(obj);
515 edje_object_mirrored_set(wd->ent, rtl);
519 _theme_hook(Evas_Object *obj)
521 Widget_Data *wd = elm_widget_data_get(obj);
524 evas_event_freeze(evas_object_evas_get(obj));
525 _elm_widget_mirrored_reload(obj);
526 _mirrored_set(obj, elm_widget_mirrored_get(obj));
528 t = eina_stringshare_add(elm_object_text_get(obj));
529 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
530 if (_elm_config->desktop_entry)
531 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
532 elm_object_text_set(obj, t);
533 eina_stringshare_del(t);
534 if (elm_widget_disabled_get(obj))
535 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
536 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
537 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
538 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", wd->prediction_allow);
539 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
541 if (wd->cursor_pos != 0)
542 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
543 if (elm_widget_focus_get(obj))
544 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
545 edje_object_message_signal_process(wd->ent);
546 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
552 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
553 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
554 elm_widget_style_get(obj));
555 edj = elm_smart_scroller_edje_object_get(wd->scroller);
556 str = edje_object_data_get(edj, "focus_highlight");
557 if ((str) && (!strcmp(str, "on")))
558 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
560 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
563 evas_event_thaw(evas_object_evas_get(obj));
564 evas_event_thaw_eval(evas_object_evas_get(obj));
568 _disable_hook(Evas_Object *obj)
570 Widget_Data *wd = elm_widget_data_get(obj);
572 if (elm_widget_disabled_get(obj))
574 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
575 wd->disabled = EINA_TRUE;
579 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
580 wd->disabled = EINA_FALSE;
585 _recalc_cursor_geometry(Evas_Object *obj)
587 Widget_Data *wd = elm_widget_data_get(obj);
589 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
590 if (!wd->deferred_recalc_job)
592 Evas_Coord cx, cy, cw, ch;
593 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
597 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
598 wd->cur_changed = EINA_FALSE;
602 wd->deferred_cur = EINA_TRUE;
606 _elm_deferred_recalc_job(void *data)
608 Widget_Data *wd = elm_widget_data_get(data);
609 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
611 wd->deferred_recalc_job = NULL;
613 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
614 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
615 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
616 /* This is a hack to workaround the way min size hints are treated.
617 * If the minimum width is smaller than the restricted width, it means
618 * the mininmum doesn't matter. */
621 Evas_Coord ominw = -1;
622 evas_object_size_hint_min_get(data, &ominw, NULL);
629 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
632 Evas_Coord vmw = 0, vmh = 0;
634 edje_object_size_min_calc
635 (elm_smart_scroller_edje_object_get(wd->scroller),
639 evas_object_size_hint_min_set(data, vmw, minh + vmh);
640 evas_object_size_hint_max_set(data, -1, minh + vmh);
644 evas_object_size_hint_min_set(data, vmw, vmh);
645 evas_object_size_hint_max_set(data, -1, -1);
652 evas_object_size_hint_min_set(data, minw, minh);
653 evas_object_size_hint_max_set(data, -1, minh);
657 evas_object_size_hint_min_set(data, fw, minh);
658 evas_object_size_hint_max_set(data, -1, -1);
662 if (wd->deferred_cur)
664 Evas_Coord cx, cy, cw, ch;
665 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
669 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
670 wd->cur_changed = EINA_FALSE;
676 _sizing_eval(Evas_Object *obj)
678 Widget_Data *wd = elm_widget_data_get(obj);
679 Evas_Coord minw = -1, minh = -1;
680 Evas_Coord resw, resh;
683 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
686 if ((resw == wd->lastw) && (!wd->changed)) return;
687 evas_event_freeze(evas_object_evas_get(obj));
688 wd->changed = EINA_FALSE;
692 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
694 evas_object_resize(wd->scroller, resw, resh);
695 edje_object_size_min_calc
696 (elm_smart_scroller_edje_object_get(wd->scroller),
698 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
699 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
700 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
701 /* This is a hack to workaround the way min size hints are treated.
702 * If the minimum width is smaller than the restricted width, it means
703 * the mininmum doesn't matter. */
706 Evas_Coord ominw = -1;
707 evas_object_size_hint_min_get(wd->ent, &ominw, NULL);
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_deferred_recalc_job, obj);
730 evas_event_thaw(evas_object_evas_get(obj));
731 evas_event_thaw_eval(evas_object_evas_get(obj));
735 if (!wd->changed) return;
736 evas_event_freeze(evas_object_evas_get(obj));
737 wd->changed = EINA_FALSE;
741 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
743 edje_object_size_min_calc(wd->ent, &minw, &minh);
746 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
748 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
750 if (minw > vw) vw = minw;
751 if (minh > vh) vh = minh;
753 evas_object_resize(wd->ent, vw, vh);
754 edje_object_size_min_calc
755 (elm_smart_scroller_edje_object_get(wd->scroller),
757 if (wd->single_line) h = vmh + minh;
759 evas_object_size_hint_min_set(obj, w, h);
761 evas_object_size_hint_max_set(obj, -1, h);
763 evas_object_size_hint_max_set(obj, -1, -1);
767 edje_object_size_min_calc(wd->ent, &minw, &minh);
770 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
771 evas_object_size_hint_min_set(obj, minw, minh);
773 evas_object_size_hint_max_set(obj, -1, minh);
775 evas_object_size_hint_max_set(obj, -1, -1);
777 evas_event_thaw(evas_object_evas_get(obj));
778 evas_event_thaw_eval(evas_object_evas_get(obj));
781 _recalc_cursor_geometry(obj);
785 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
787 Widget_Data *wd = elm_widget_data_get(obj);
788 Evas_Object *top = elm_widget_top_get(obj);
790 if (!wd->editable) return;
791 if (elm_widget_focus_get(obj))
793 evas_object_focus_set(wd->ent, EINA_TRUE);
794 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
795 if (top && wd->input_panel_enable)
796 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
797 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
801 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
802 evas_object_focus_set(wd->ent, EINA_FALSE);
803 if (top && wd->input_panel_enable)
804 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
805 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
810 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
812 Widget_Data *wd = elm_widget_data_get(obj);
814 if ((!wd) || (!content)) return;
817 edje = elm_smart_scroller_edje_object_get(wd->scroller);
821 /* Delete the currently swallowed object */
822 Evas_Object *cswallow;
824 if (!part || !strcmp(part, "icon"))
826 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon");
827 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
829 else if (!strcmp(part, "end"))
831 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end");
832 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
835 cswallow = edje_object_part_swallow_get(edje, part);
837 if (cswallow) evas_object_del(cswallow);
839 evas_event_freeze(evas_object_evas_get(obj));
840 elm_widget_sub_object_add(obj, content);
842 if (!part || !strcmp(part, "icon"))
843 edje_object_part_swallow(edje, "elm.swallow.icon", content);
844 else if (!strcmp(part, "end"))
845 edje_object_part_swallow(edje, "elm.swallow.end", content);
847 edje_object_part_swallow(edje, part, content);
850 evas_event_thaw(evas_object_evas_get(obj));
851 evas_event_thaw_eval(evas_object_evas_get(obj));
855 _content_unset_hook(Evas_Object *obj, const char *part)
857 Widget_Data *wd = elm_widget_data_get(obj);
858 Evas_Object *content, *edje;
859 if (!wd) return NULL;
862 edje = elm_smart_scroller_edje_object_get(wd->scroller);
866 if (!part || !strcmp(part, "icon"))
868 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
869 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
871 else if (!strcmp(part, "end"))
873 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
874 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
877 content = edje_object_part_swallow_get(edje, part);
879 edje_object_part_swallow(edje, part, NULL);
880 if (!content) return NULL;
881 evas_event_freeze(evas_object_evas_get(obj));
882 elm_widget_sub_object_del(obj, content);
883 edje_object_part_unswallow(wd->ent, content);
885 evas_event_thaw(evas_object_evas_get(obj));
886 evas_event_thaw_eval(evas_object_evas_get(obj));
892 _content_get_hook(const Evas_Object *obj, const char *part)
894 Widget_Data *wd = elm_widget_data_get(obj);
895 Evas_Object *content = NULL, *edje;
896 if (!wd) return NULL;
899 edje = elm_smart_scroller_edje_object_get(wd->scroller);
903 if (!edje) return NULL;
905 if (!part || !strcmp(part, "icon"))
906 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
907 else if (!strcmp(part, "end"))
908 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
910 content = edje_object_part_swallow_get(edje, part);
916 _translate_hook(Evas_Object *obj)
918 evas_object_smart_callback_call(obj, "language,changed", NULL);
922 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
924 Widget_Data *wd = elm_widget_data_get(obj);
926 edje_object_signal_emit(wd->ent, emission, source);
928 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
933 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
935 Widget_Data *wd = elm_widget_data_get(obj);
937 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
939 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
940 emission, source, func_cb, data);
944 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
946 Widget_Data *wd = elm_widget_data_get(obj);
947 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
950 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
951 emission, source, func_cb, data);
955 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
957 Widget_Data *wd = elm_widget_data_get(obj);
958 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
962 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
964 Widget_Data *wd = elm_widget_data_get(obj);
966 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
970 _show_region_hook(void *data, Evas_Object *obj)
972 Widget_Data *wd = elm_widget_data_get(data);
973 Evas_Coord x, y, w, h;
975 elm_widget_show_region_get(obj, &x, &y, &w, &h);
977 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
981 _sub_del(void *data, Evas_Object *obj, void *event_info)
983 Widget_Data *wd = data;
984 Evas_Object *sub = event_info;
988 edje = elm_smart_scroller_edje_object_get(wd->scroller);
992 if (sub == edje_object_part_swallow_get(edje, "elm.swallow.icon"))
994 edje_object_part_unswallow(edje, sub);
996 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
998 else if (sub == edje_object_part_swallow_get(edje, "elm.swallow.end"))
1000 edje_object_part_unswallow(edje, sub);
1002 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1008 _hoversel_position(Evas_Object *obj)
1010 Widget_Data *wd = elm_widget_data_get(obj);
1011 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1016 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1025 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1026 &cx, &cy, &cw, &ch);
1027 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1030 cx += (cw - mw) / 2;
1035 cy += (ch - mh) / 2;
1038 evas_object_move(wd->hoversel, x + cx, y + cy);
1039 evas_object_resize(wd->hoversel, cw, ch);
1043 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1047 if (wd->hoversel) _hoversel_position(data);
1051 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1053 Widget_Data *wd = elm_widget_data_get(data);
1060 else if (wd->scroll)
1062 Evas_Coord vw = 0, vh = 0;
1064 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1065 if (vw < wd->entmw) vw = wd->entmw;
1066 if (vh < wd->entmh) vh = wd->entmh;
1067 evas_object_resize(wd->ent, vw, vh);
1069 if (wd->hoversel) _hoversel_position(data);
1073 _hover_del(void *data)
1075 Widget_Data *wd = elm_widget_data_get(data);
1080 evas_object_del(wd->hoversel);
1081 wd->hoversel = NULL;
1083 wd->hovdeljob = NULL;
1087 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1089 Widget_Data *wd = elm_widget_data_get(data);
1092 if (wd->hoversel) evas_object_hide(wd->hoversel);
1095 if (!_elm_config->desktop_entry)
1098 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1101 elm_widget_scroll_freeze_pop(data);
1102 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1103 wd->hovdeljob = ecore_job_add(_hover_del, data);
1107 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1109 Widget_Data *wd = elm_widget_data_get(data);
1111 wd->selmode = EINA_TRUE;
1112 edje_object_part_text_select_none(wd->ent, "elm.text");
1113 if (!_elm_config->desktop_entry)
1116 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1118 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1119 if (!_elm_config->desktop_entry)
1120 elm_widget_scroll_hold_push(data);
1124 _elm_entry_entry_paste(Evas_Object *obj, const char *entry)
1126 Elm_Entry_Change_Info info;
1127 info.merge = EINA_FALSE;
1128 info.insert = EINA_TRUE;
1129 info.change.insert.pos = elm_entry_cursor_pos_get(obj);
1130 info.change.insert.content = eina_stringshare_add(entry);
1133 tmp = evas_textblock_text_markup_to_utf8(elm_entry_textblock_get(obj),
1134 info.change.insert.content);
1135 info.change.insert.plain_length = eina_unicode_utf8_get_len(tmp);
1139 elm_entry_entry_insert(obj, entry);
1140 evas_object_smart_callback_call(obj, SIG_CHANGED_USER, &info);
1142 eina_stringshare_del(info.change.insert.content);
1146 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1148 Widget_Data *wd = elm_widget_data_get(data);
1150 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1151 if (wd->sel_notify_handler)
1153 #ifdef HAVE_ELEMENTARY_X
1154 Elm_Sel_Format formats;
1155 wd->selection_asked = EINA_TRUE;
1156 formats = ELM_SEL_FORMAT_MARKUP;
1158 formats |= ELM_SEL_FORMAT_IMAGE;
1159 elm_cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, formats, data, NULL, NULL);
1165 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1167 Widget_Data *wd = elm_widget_data_get(obj);
1171 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1172 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1173 elm_cnp_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1174 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1175 eina_stringshare_replace(&wd->cut_sel, sel);
1179 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1181 Widget_Data *wd = elm_widget_data_get(data);
1184 wd->selmode = EINA_FALSE;
1185 if (!_elm_config->desktop_entry)
1186 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1187 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1188 if (!_elm_config->desktop_entry)
1189 elm_widget_scroll_hold_pop(data);
1190 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1191 edje_object_part_text_insert(wd->ent, "elm.text", "");
1192 edje_object_part_text_select_none(wd->ent, "elm.text");
1197 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1199 Widget_Data *wd = elm_widget_data_get(data);
1201 wd->selmode = EINA_FALSE;
1202 if (!_elm_config->desktop_entry)
1204 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1205 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1206 elm_widget_scroll_hold_pop(data);
1208 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1209 // edje_object_part_text_select_none(wd->ent, "elm.text");
1213 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1215 Widget_Data *wd = elm_widget_data_get(data);
1217 wd->selmode = EINA_FALSE;
1218 if (!_elm_config->desktop_entry)
1219 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1220 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1221 if (!_elm_config->desktop_entry)
1222 elm_widget_scroll_hold_pop(data);
1223 edje_object_part_text_select_none(wd->ent, "elm.text");
1227 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1229 Elm_Entry_Context_Menu_Item *it = data;
1230 Evas_Object *obj2 = it->obj;
1231 if (it->func) it->func(it->data, obj2, NULL);
1235 _menu_press(Evas_Object *obj)
1237 Widget_Data *wd = elm_widget_data_get(obj);
1240 const Elm_Entry_Context_Menu_Item *it;
1242 if ((wd->api) && (wd->api->obj_longpress))
1244 wd->api->obj_longpress(obj);
1246 else if (wd->context_menu)
1248 const char *context_menu_orientation;
1250 if (wd->hoversel) evas_object_del(wd->hoversel);
1251 else elm_widget_scroll_freeze_push(obj);
1252 wd->hoversel = elm_hoversel_add(obj);
1253 context_menu_orientation = edje_object_data_get
1254 (wd->ent, "context_menu_orientation");
1255 if ((context_menu_orientation) &&
1256 (!strcmp(context_menu_orientation, "horizontal")))
1257 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1258 elm_object_style_set(wd->hoversel, "entry");
1259 elm_widget_sub_object_add(obj, wd->hoversel);
1260 elm_object_text_set(wd->hoversel, "Text");
1261 top = elm_widget_top_get(obj);
1262 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1263 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1264 if (wd->have_selection)
1268 if (wd->have_selection)
1270 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1273 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1276 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1284 if (!_elm_config->desktop_entry)
1287 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1290 if (elm_selection_selection_has_owner())
1293 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1298 EINA_LIST_FOREACH(wd->items, l, it)
1300 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1301 it->icon_type, _item_clicked, it);
1305 _hoversel_position(obj);
1306 evas_object_show(wd->hoversel);
1307 elm_hoversel_hover_begin(wd->hoversel);
1309 if (!_elm_config->desktop_entry)
1311 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1312 edje_object_part_text_select_abort(wd->ent, "elm.text");
1318 _long_press(void *data)
1320 Widget_Data *wd = elm_widget_data_get(data);
1321 if (!wd) return ECORE_CALLBACK_CANCEL;
1323 wd->longpress_timer = NULL;
1324 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1325 return ECORE_CALLBACK_CANCEL;
1329 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1331 Widget_Data *wd = elm_widget_data_get(data);
1332 Evas_Event_Mouse_Down *ev = event_info;
1334 if (wd->disabled) return;
1335 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1336 wd->downx = ev->canvas.x;
1337 wd->downy = ev->canvas.y;
1338 if (ev->button == 1)
1340 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1341 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1346 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1348 Widget_Data *wd = elm_widget_data_get(data);
1349 Evas_Event_Mouse_Up *ev = event_info;
1351 if (wd->disabled) return;
1352 if (ev->button == 1)
1354 if (wd->longpress_timer)
1356 ecore_timer_del(wd->longpress_timer);
1357 wd->longpress_timer = NULL;
1360 else if (ev->button == 3)
1368 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1370 Widget_Data *wd = elm_widget_data_get(data);
1371 Evas_Event_Mouse_Move *ev = event_info;
1373 if (wd->disabled) return;
1376 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1378 if (wd->longpress_timer)
1380 ecore_timer_del(wd->longpress_timer);
1381 wd->longpress_timer = NULL;
1384 else if (wd->longpress_timer)
1388 dx = wd->downx - ev->cur.canvas.x;
1390 dy = wd->downy - ev->cur.canvas.y;
1393 ((_elm_config->finger_size / 2) *
1394 (_elm_config->finger_size / 2)))
1396 ecore_timer_del(wd->longpress_timer);
1397 wd->longpress_timer = NULL;
1401 else if (wd->longpress_timer)
1405 dx = wd->downx - ev->cur.canvas.x;
1407 dy = wd->downy - ev->cur.canvas.y;
1410 ((_elm_config->finger_size / 2) *
1411 (_elm_config->finger_size / 2)))
1413 ecore_timer_del(wd->longpress_timer);
1414 wd->longpress_timer = NULL;
1420 _getbase(Evas_Object *obj)
1422 Widget_Data *wd = elm_widget_data_get(obj);
1423 if (!wd) return "base";
1426 if (wd->password) return "base-password";
1429 if (wd->single_line) return "base-single";
1432 switch (wd->linewrap)
1435 return "base-charwrap";
1438 case ELM_WRAP_MIXED:
1439 return "base-mixedwrap";
1442 return "base-nowrap";
1449 if (wd->password) return "base-password";
1452 if (wd->single_line) return "base-single-noedit";
1455 switch (wd->linewrap)
1458 return "base-noedit-charwrap";
1460 return "base-noedit";
1461 case ELM_WRAP_MIXED:
1462 return "base-noedit-mixedwrap";
1465 return "base-nowrap-noedit";
1473 _entry_changed_common_handling(void *data, const char *event)
1475 Widget_Data *wd = elm_widget_data_get(data);
1478 evas_event_freeze(evas_object_evas_get(data));
1479 wd->changed = EINA_TRUE;
1480 /* Reset the size hints which are no more relevant.
1481 * Keep the height, this is a hack, but doesn't really matter
1482 * cause we'll re-eval in a moment. */
1483 evas_object_size_hint_min_get(data, NULL, &minh);
1484 evas_object_size_hint_min_set(data, -1, minh);
1486 if (wd->text) eina_stringshare_del(wd->text);
1488 if (wd->delay_write)
1490 ecore_timer_del(wd->delay_write);
1491 wd->delay_write = NULL;
1493 evas_event_thaw(evas_object_evas_get(data));
1494 evas_event_thaw_eval(evas_object_evas_get(data));
1495 if ((wd->autosave) && (wd->file))
1496 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1497 /* callback - this could call callbacks that delete the entry... thus...
1498 * any access to wd after this could be invalid */
1499 evas_object_smart_callback_call(data, event, NULL);
1503 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1505 _entry_changed_common_handling(data, SIG_CHANGED);
1509 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1511 Elm_Entry_Change_Info info;
1512 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
1513 edje_object_signal_callback_extra_data_get();
1516 memcpy(&info, edje_info, sizeof(info));
1517 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
1521 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
1526 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1528 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1532 _signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1534 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
1538 _signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1540 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
1544 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1546 Widget_Data *wd = elm_widget_data_get(data);
1550 EINA_LIST_FOREACH(entries, l, entry)
1552 if (entry != data) elm_entry_select_none(entry);
1554 wd->have_selection = EINA_TRUE;
1555 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1556 #ifdef HAVE_ELEMENTARY_X
1557 if (wd->sel_notify_handler)
1559 const char *txt = elm_entry_selection_get(data);
1562 top = elm_widget_top_get(data);
1563 if (txt && top && (elm_win_xwindow_get(top)))
1564 elm_cnp_selection_set(ELM_SEL_TYPE_PRIMARY, data,
1565 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
1571 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1573 Widget_Data *wd = elm_widget_data_get(data);
1575 elm_entry_select_all(data);
1579 _signal_selection_none(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1581 Widget_Data *wd = elm_widget_data_get(data);
1583 elm_entry_select_none(data);
1587 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1589 Widget_Data *wd = elm_widget_data_get(data);
1591 wd->have_selection = EINA_TRUE;
1592 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1593 _store_selection(ELM_SEL_TYPE_PRIMARY, data);
1597 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1599 Widget_Data *wd = elm_widget_data_get(data);
1601 if (!wd->have_selection) return;
1602 wd->have_selection = EINA_FALSE;
1603 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1604 if (wd->sel_notify_handler)
1608 #ifdef HAVE_ELEMENTARY_X
1611 top = elm_widget_top_get(data);
1612 if ((top) && (elm_win_xwindow_get(top)))
1613 elm_cnp_selection_set(ELM_SEL_TYPE_PRIMARY, data,
1614 ELM_SEL_FORMAT_MARKUP, wd->cut_sel,
1615 strlen(wd->cut_sel));
1617 eina_stringshare_del(wd->cut_sel);
1622 #ifdef HAVE_ELEMENTARY_X
1625 top = elm_widget_top_get(data);
1626 if ((top) && (elm_win_xwindow_get(top)))
1627 elm_cnp_selection_clear(ELM_SEL_TYPE_PRIMARY, data);
1634 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1636 Widget_Data *wd = elm_widget_data_get(data);
1637 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
1638 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
1640 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1641 if (wd->sel_notify_handler)
1643 #ifdef HAVE_ELEMENTARY_X
1646 top = elm_widget_top_get(data);
1647 if ((top) && (elm_win_xwindow_get(top)))
1649 wd->selection_asked = EINA_TRUE;
1650 elm_cnp_selection_get(type, ELM_SEL_FORMAT_MARKUP, data,
1658 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1660 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1661 _copy(data, NULL, NULL);
1665 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1667 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1668 _cut(data, NULL, NULL);
1672 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1674 Widget_Data *wd = elm_widget_data_get(data);
1676 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1677 wd->cur_changed = EINA_TRUE;
1678 _recalc_cursor_geometry(data);
1682 _signal_cursor_changed_manual(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1684 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
1689 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
1691 const Eina_List *geoms, *l;
1692 Evas_Textblock_Rectangle *r;
1693 Evas_Coord px, py, x, y;
1695 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
1699 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1700 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1701 EINA_LIST_FOREACH(geoms, l, r)
1703 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1704 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1716 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1718 Widget_Data *wd = elm_widget_data_get(data);
1719 Elm_Entry_Anchor_Info ei;
1723 p = emission + sizeof("nchor,mouse,down,");
1724 ei.button = strtol(p, &p2, 10);
1726 ei.x = ei.y = ei.w = ei.h = 0;
1728 _signal_anchor_geoms_do_things_with(wd, &ei);
1731 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
1735 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1737 Widget_Data *wd = elm_widget_data_get(data);
1738 Elm_Entry_Anchor_Info ei;
1742 p = emission + sizeof("nchor,mouse,up,");
1743 ei.button = strtol(p, &p2, 10);
1745 ei.x = ei.y = ei.w = ei.h = 0;
1747 _signal_anchor_geoms_do_things_with(wd, &ei);
1750 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
1754 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1756 Widget_Data *wd = elm_widget_data_get(data);
1757 Elm_Entry_Anchor_Info ei;
1761 p = emission + sizeof("nchor,mouse,clicked,");
1762 ei.button = strtol(p, &p2, 10);
1764 ei.x = ei.y = ei.w = ei.h = 0;
1766 _signal_anchor_geoms_do_things_with(wd, &ei);
1769 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1773 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1775 Widget_Data *wd = elm_widget_data_get(data);
1780 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1782 Widget_Data *wd = elm_widget_data_get(data);
1783 Elm_Entry_Anchor_Info ei;
1785 ei.name = emission + sizeof("nchor,mouse,in,");
1787 ei.x = ei.y = ei.w = ei.h = 0;
1789 _signal_anchor_geoms_do_things_with(wd, &ei);
1792 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
1796 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1798 Widget_Data *wd = elm_widget_data_get(data);
1799 Elm_Entry_Anchor_Info ei;
1801 ei.name = emission + sizeof("nchor,mouse,out,");
1803 ei.x = ei.y = ei.w = ei.h = 0;
1805 _signal_anchor_geoms_do_things_with(wd, &ei);
1808 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
1812 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1814 Widget_Data *wd = elm_widget_data_get(data);
1816 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1820 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1822 Widget_Data *wd = elm_widget_data_get(data);
1824 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1828 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1830 Widget_Data *wd = elm_widget_data_get(data);
1832 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1836 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1838 Widget_Data *wd = elm_widget_data_get(data);
1840 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1844 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1846 Widget_Data *wd = elm_widget_data_get(data);
1848 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
1851 #ifdef HAVE_ELEMENTARY_X
1853 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1855 Widget_Data *wd = elm_widget_data_get(data);
1856 Ecore_X_Event_Selection_Notify *ev = event;
1857 if (!wd) return ECORE_CALLBACK_PASS_ON;
1858 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1859 return ECORE_CALLBACK_PASS_ON;
1861 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1862 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1864 Ecore_X_Selection_Data_Text *text_data;
1866 text_data = ev->data;
1867 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1869 if (text_data->text)
1871 char *txt = _elm_util_text_to_mkup(text_data->text);
1875 elm_entry_entry_insert(data, txt);
1880 wd->selection_asked = EINA_FALSE;
1882 else if (ev->selection == ECORE_X_SELECTION_XDND)
1884 Ecore_X_Selection_Data_Text *text_data;
1886 text_data = ev->data;
1887 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1889 if (text_data->text)
1891 char *txt = _elm_util_text_to_mkup(text_data->text);
1895 /* Massive FIXME: this should be at the drag point */
1896 elm_entry_entry_insert(data, txt);
1901 wd->drag_selection_asked = EINA_FALSE;
1903 ecore_x_dnd_send_finished();
1906 return ECORE_CALLBACK_PASS_ON;
1910 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
1912 Widget_Data *wd = elm_widget_data_get(data);
1913 Ecore_X_Event_Selection_Clear *ev = event;
1914 if (!wd) return ECORE_CALLBACK_PASS_ON;
1915 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1916 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1917 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1919 elm_entry_select_none(data);
1921 return ECORE_CALLBACK_PASS_ON;
1925 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1930 wd = elm_widget_data_get(obj);
1931 if (!wd) return EINA_FALSE;
1932 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1934 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1935 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1936 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1937 EDJE_CURSOR_MAIN,drop->x,drop->y);
1938 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1939 elm_entry_entry_insert(obj, drop->data);
1940 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1941 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1947 static Evas_Object *
1948 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1950 Widget_Data *wd = elm_widget_data_get(data);
1953 Elm_Entry_Item_Provider *ip;
1955 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1957 o = ip->func(ip->data, data, item);
1960 if (!strncmp(item, "file://", 7))
1962 const char *fname = item + 7;
1964 o = evas_object_image_filled_add(evas_object_evas_get(data));
1965 evas_object_image_file_set(o, fname, NULL);
1966 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1968 evas_object_show(o);
1973 o = edje_object_add(evas_object_evas_get(data));
1974 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1978 o = edje_object_add(evas_object_evas_get(data));
1979 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1980 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1985 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
1987 Widget_Data *wd = elm_widget_data_get(data);
1989 Elm_Entry_Markup_Filter *tf;
1991 if (type == EDJE_TEXT_FILTER_FORMAT)
1994 EINA_LIST_FOREACH(wd->text_filters, l, tf)
1996 tf->func(tf->data, data, text);
2003 _markup_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, char **text)
2005 Widget_Data *wd = elm_widget_data_get(data);
2007 Elm_Entry_Markup_Filter *tf;
2009 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
2011 tf->func(tf->data, data, text);
2017 /* This function is used to insert text by chunks in jobs */
2019 _text_append_idler(void *data)
2023 Evas_Object *obj = (Evas_Object *) data;
2024 Widget_Data *wd = elm_widget_data_get(obj);
2025 evas_event_freeze(evas_object_evas_get(obj));
2026 if (wd->text) eina_stringshare_del(wd->text);
2028 wd->changed = EINA_TRUE;
2030 start = wd->append_text_position;
2031 if (start + _CHUNK_SIZE < wd->append_text_len)
2034 int tag_start, esc_start;
2036 tag_start = esc_start = -1;
2037 /* Find proper markup cut place */
2038 while (pos - start < _CHUNK_SIZE)
2042 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2043 if (esc_start == -1)
2046 tag_start = prev_pos;
2047 else if (tmp == '>')
2050 if (tag_start == -1)
2053 esc_start = prev_pos;
2054 else if (tmp == ';')
2061 wd->append_text_position = tag_start;
2063 else if (esc_start >= 0)
2065 wd->append_text_position = esc_start;
2069 wd->append_text_position = pos;
2074 wd->append_text_position = wd->append_text_len;
2077 backup = wd->append_text_left[wd->append_text_position];
2078 wd->append_text_left[wd->append_text_position] = '\0';
2080 edje_object_part_text_append(wd->ent, "elm.text",
2081 wd->append_text_left + start);
2083 wd->append_text_left[wd->append_text_position] = backup;
2085 evas_event_thaw(evas_object_evas_get(obj));
2086 evas_event_thaw_eval(evas_object_evas_get(obj));
2088 /* If there's still more to go, renew the idler, else, cleanup */
2089 if (wd->append_text_position < wd->append_text_len)
2091 return ECORE_CALLBACK_RENEW;
2095 free(wd->append_text_left);
2096 wd->append_text_left = NULL;
2097 wd->append_text_idler = NULL;
2098 return ECORE_CALLBACK_CANCEL;
2103 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2105 int i = 0, current_len = 0;
2109 if (unit >= LENGTH_UNIT_LAST) return;
2111 current_len = strlen(*text);
2114 int idx = 0, unit_size = 0;
2115 char *markup, *utfstr;
2116 if (*new_text == '<')
2118 while (*(new_text + idx) != '>')
2121 if (!*(new_text + idx)) break;
2124 else if (*new_text == '&')
2126 while (*(new_text + idx) != ';')
2129 if (!*(new_text + idx)) break;
2132 idx = evas_string_char_next_get(new_text, idx, NULL);
2133 markup = malloc(idx + 1);
2136 strncpy(markup, new_text, idx);
2138 utfstr = elm_entry_markup_to_utf8(markup);
2141 if (unit == LENGTH_UNIT_BYTE)
2142 unit_size = strlen(utfstr);
2143 else if (unit == LENGTH_UNIT_CHAR)
2144 unit_size = evas_string_char_len_get(utfstr);
2151 if (can_add < unit_size)
2155 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2161 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2163 (*text)[current_len] = 0;
2168 can_add -= unit_size;
2172 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2176 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2179 ELM_CHECK_WIDTYPE(obj, widtype);
2180 Widget_Data *wd = elm_widget_data_get(obj);
2182 evas_event_freeze(evas_object_evas_get(obj));
2183 if (!entry) entry = "";
2184 if (item && strcmp(item, "default"))
2186 edje_object_part_text_set(wd->ent, item, entry);
2190 if (wd->text) eina_stringshare_del(wd->text);
2192 wd->changed = EINA_TRUE;
2194 /* Clear currently pending job if there is one */
2195 if (wd->append_text_idler)
2197 ecore_idler_del(wd->append_text_idler);
2198 free(wd->append_text_left);
2199 wd->append_text_left = NULL;
2200 wd->append_text_idler = NULL;
2203 len = strlen(entry);
2204 /* Split to ~_CHUNK_SIZE chunks */
2205 if (len > _CHUNK_SIZE)
2207 wd->append_text_left = (char *) malloc(len + 1);
2210 /* If we decided to use the idler */
2211 if (wd->append_text_left)
2213 /* Need to clear the entry first */
2214 edje_object_part_text_set(wd->ent, "elm.text", "");
2215 memcpy(wd->append_text_left, entry, len + 1);
2216 wd->append_text_position = 0;
2217 wd->append_text_len = len;
2218 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2222 edje_object_part_text_set(wd->ent, "elm.text", entry);
2224 evas_event_thaw(evas_object_evas_get(obj));
2225 evas_event_thaw_eval(evas_object_evas_get(obj));
2229 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2231 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2232 Widget_Data *wd = elm_widget_data_get(obj);
2233 if (item && strcmp(item, "default")) return NULL;
2235 if (!wd) return NULL;
2236 if (wd->text) return wd->text;
2237 text = edje_object_part_text_get(wd->ent, "elm.text");
2240 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2244 if (wd->append_text_len > 0)
2248 tlen = strlen(text);
2249 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2252 ERR("Failed to allocate memory for entry's text %p", obj);
2255 memcpy(tmpbuf, text, tlen);
2256 memcpy(tmpbuf + tlen, wd->append_text_left, wd->append_text_len);
2257 tmpbuf[tlen + wd->append_text_len] = '\0';
2258 eina_stringshare_replace(&wd->text, tmpbuf);
2263 eina_stringshare_replace(&wd->text, text);
2269 elm_entry_add(Evas_Object *parent)
2271 Evas_Object *obj, *top;
2275 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2277 ELM_SET_WIDTYPE(widtype, "entry");
2278 elm_widget_type_set(obj, "entry");
2279 elm_widget_sub_object_add(parent, obj);
2280 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2281 elm_widget_data_set(obj, wd);
2282 elm_widget_del_hook_set(obj, _del_hook);
2283 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2284 elm_widget_theme_hook_set(obj, _theme_hook);
2285 elm_widget_disable_hook_set(obj, _disable_hook);
2286 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2287 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2288 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2289 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2290 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2291 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2292 elm_widget_can_focus_set(obj, EINA_TRUE);
2293 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2294 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2295 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2296 elm_widget_content_set_hook_set(obj, _content_set_hook);
2297 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2298 elm_widget_content_get_hook_set(obj, _content_get_hook);
2299 elm_widget_translate_hook_set(obj, _translate_hook);
2301 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2303 wd->linewrap = ELM_WRAP_WORD;
2304 wd->editable = EINA_TRUE;
2305 wd->disabled = EINA_FALSE;
2306 wd->context_menu = EINA_TRUE;
2307 wd->autosave = EINA_TRUE;
2308 wd->textonly = EINA_FALSE;
2309 wd->scroll = EINA_FALSE;
2311 wd->ent = edje_object_add(e);
2312 edje_object_item_provider_set(wd->ent, _get_item, obj);
2313 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2314 edje_object_markup_filter_callback_add(wd->ent,"elm.text", _markup_filter, obj);
2315 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2316 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2318 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2320 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2322 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2324 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2325 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2326 _signal_entry_changed, obj);
2327 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
2328 _signal_entry_changed_user, obj);
2329 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2330 _signal_preedit_changed, obj);
2331 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2332 _signal_selection_start, obj);
2333 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2334 _signal_selection_changed, obj);
2335 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2336 _signal_selection_all, obj);
2337 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2338 _signal_selection_none, obj);
2339 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2340 _signal_selection_cleared, obj);
2341 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2342 _signal_entry_paste_request, obj);
2343 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2344 _signal_entry_copy_notify, obj);
2345 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2346 _signal_entry_cut_notify, obj);
2347 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2348 _signal_cursor_changed, obj);
2349 edje_object_signal_callback_add(wd->ent, "cursor,changed,manual", "elm.text",
2350 _signal_cursor_changed_manual, obj);
2351 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2352 _signal_anchor_down, obj);
2353 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2354 _signal_anchor_up, obj);
2355 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2356 _signal_anchor_clicked, obj);
2357 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2358 _signal_anchor_move, obj);
2359 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2360 _signal_anchor_in, obj);
2361 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2362 _signal_anchor_out, obj);
2363 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2364 _signal_key_enter, obj);
2365 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2366 _signal_mouse_down, obj);
2367 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2368 _signal_mouse_clicked, obj);
2369 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2370 _signal_mouse_double, obj);
2371 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
2372 _signal_mouse_triple, obj);
2373 edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
2374 _signal_undo_request, obj);
2375 edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
2376 _signal_redo_request, obj);
2377 edje_object_part_text_set(wd->ent, "elm.text", "");
2378 if (_elm_config->desktop_entry)
2379 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2380 elm_widget_resize_object_set(obj, wd->ent);
2383 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
2384 elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
2385 elm_entry_prediction_allow_set(obj, EINA_TRUE);
2387 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
2389 #ifdef HAVE_ELEMENTARY_X
2390 top = elm_widget_top_get(obj);
2391 if ((top) && (elm_win_xwindow_get(top)))
2393 wd->sel_notify_handler =
2394 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2395 _event_selection_notify, obj);
2396 wd->sel_clear_handler =
2397 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2398 _event_selection_clear, obj);
2401 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2402 _drag_drop_cb, NULL);
2405 entries = eina_list_prepend(entries, obj);
2407 // module - find module for entry
2408 wd->api = _module(obj);
2409 // if found - hook in
2410 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2412 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2413 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2414 // TODO: and save some bytes, making descriptions per-class and not instance!
2415 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2420 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2422 ELM_CHECK_WIDTYPE(obj, widtype);
2423 Widget_Data *wd = elm_widget_data_get(obj);
2425 if (wd->single_line == single_line) return;
2426 wd->single_line = single_line;
2427 wd->linewrap = ELM_WRAP_NONE;
2428 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2432 if (wd->single_line)
2433 elm_smart_scroller_policy_set(wd->scroller,
2434 ELM_SMART_SCROLLER_POLICY_OFF,
2435 ELM_SMART_SCROLLER_POLICY_OFF);
2438 const Elm_Scroller_Policy map[3] =
2440 ELM_SMART_SCROLLER_POLICY_AUTO,
2441 ELM_SMART_SCROLLER_POLICY_ON,
2442 ELM_SMART_SCROLLER_POLICY_OFF
2444 elm_smart_scroller_policy_set(wd->scroller,
2453 elm_entry_single_line_get(const Evas_Object *obj)
2455 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2456 Widget_Data *wd = elm_widget_data_get(obj);
2457 if (!wd) return EINA_FALSE;
2458 return wd->single_line;
2462 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2464 ELM_CHECK_WIDTYPE(obj, widtype);
2465 Widget_Data *wd = elm_widget_data_get(obj);
2467 if (wd->password == password) return;
2468 wd->password = password;
2471 wd->single_line = EINA_TRUE;
2472 wd->linewrap = ELM_WRAP_NONE;
2473 #ifdef HAVE_ELEMENTARY_X
2474 elm_drop_target_del(obj);
2476 edje_object_signal_callback_del_full(wd->ent, "selection,start", "elm.text",
2477 _signal_selection_start, obj);
2478 edje_object_signal_callback_del_full(wd->ent, "selection,changed", "elm.text",
2479 _signal_selection_changed, obj);
2480 edje_object_signal_callback_del_full(wd->ent, "entry,selection,all,request", "elm.text",
2481 _signal_selection_all, obj);
2482 edje_object_signal_callback_del_full(wd->ent, "entry,selection,none,request", "elm.text",
2483 _signal_selection_none, obj);
2484 edje_object_signal_callback_del_full(wd->ent, "selection,cleared", "elm.text",
2485 _signal_selection_cleared, obj);
2486 edje_object_signal_callback_del_full(wd->ent, "entry,paste,request,*", "elm.text",
2487 _signal_entry_paste_request, obj);
2488 edje_object_signal_callback_del_full(wd->ent, "entry,copy,notify", "elm.text",
2489 _signal_entry_copy_notify, obj);
2490 edje_object_signal_callback_del_full(wd->ent, "entry,cut,notify", "elm.text",
2491 _signal_entry_cut_notify, obj);
2495 #ifdef HAVE_ELEMENTARY_X
2496 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2498 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2499 _signal_selection_start, obj);
2500 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2501 _signal_selection_changed, obj);
2502 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2503 _signal_selection_all, obj);
2504 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2505 _signal_selection_none, obj);
2506 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2507 _signal_selection_cleared, obj);
2508 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2509 _signal_entry_paste_request, obj);
2510 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2511 _signal_entry_copy_notify, obj);
2512 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2513 _signal_entry_cut_notify, obj);
2519 elm_entry_password_get(const Evas_Object *obj)
2521 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2522 Widget_Data *wd = elm_widget_data_get(obj);
2523 if (!wd) return EINA_FALSE;
2524 return wd->password;
2528 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2530 _elm_entry_text_set(obj, NULL, entry);
2534 elm_entry_entry_get(const Evas_Object *obj)
2536 return _elm_entry_text_get(obj, NULL);
2540 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2543 ELM_CHECK_WIDTYPE(obj, widtype);
2544 Widget_Data *wd = elm_widget_data_get(obj);
2546 if (!entry) entry = "";
2547 wd->changed = EINA_TRUE;
2549 len = strlen(entry);
2550 if (wd->append_text_left)
2553 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2559 wd->append_text_left = tmpbuf;
2560 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2561 wd->append_text_len += len;
2565 /* FIXME: Add chunked appending here (like in entry_set) */
2566 edje_object_part_text_append(wd->ent, "elm.text", entry);
2571 elm_entry_is_empty(const Evas_Object *obj)
2573 /* FIXME: until there's support for that in textblock, we just check
2574 * to see if the there is text or not. */
2575 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2576 Widget_Data *wd = elm_widget_data_get(obj);
2577 const Evas_Object *tb;
2578 Evas_Textblock_Cursor *cur;
2580 if (!wd) return EINA_TRUE;
2581 /* It's a hack until we get the support suggested above.
2582 * We just create a cursor, point it to the begining, and then
2583 * try to advance it, if it can advance, the tb is not empty,
2584 * otherwise it is. */
2585 tb = edje_object_part_object_get(wd->ent, "elm.text");
2586 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2587 actually, ok for the time being, thsese hackish stuff will be removed
2588 once evas 1.0 is out*/
2589 evas_textblock_cursor_pos_set(cur, 0);
2590 ret = evas_textblock_cursor_char_next(cur);
2591 evas_textblock_cursor_free(cur);
2597 elm_entry_textblock_get(Evas_Object *obj)
2599 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2600 Widget_Data *wd = elm_widget_data_get(obj);
2601 if (!wd) return NULL;
2603 return (Evas_Object *) edje_object_part_object_get(wd->ent, "elm.text");
2607 elm_entry_calc_force(Evas_Object *obj)
2609 ELM_CHECK_WIDTYPE(obj, widtype);
2610 Widget_Data *wd = elm_widget_data_get(obj);
2613 edje_object_calc_force(wd->ent);
2614 wd->changed = EINA_TRUE;
2620 elm_entry_selection_get(const Evas_Object *obj)
2622 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2623 Widget_Data *wd = elm_widget_data_get(obj);
2624 if ((!wd) || (wd->password)) return NULL;
2625 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2629 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2631 ELM_CHECK_WIDTYPE(obj, widtype);
2632 Widget_Data *wd = elm_widget_data_get(obj);
2634 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2635 wd->changed = EINA_TRUE;
2640 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2642 ELM_CHECK_WIDTYPE(obj, widtype);
2643 Widget_Data *wd = elm_widget_data_get(obj);
2645 if (wd->linewrap == wrap) return;
2647 wd->linewrap = wrap;
2652 elm_entry_line_wrap_get(const Evas_Object *obj)
2654 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2655 Widget_Data *wd = elm_widget_data_get(obj);
2656 if (!wd) return EINA_FALSE;
2657 return wd->linewrap;
2661 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2663 ELM_CHECK_WIDTYPE(obj, widtype);
2664 Widget_Data *wd = elm_widget_data_get(obj);
2666 if (wd->editable == editable) return;
2667 wd->editable = editable;
2670 #ifdef HAVE_ELEMENTARY_X
2672 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2674 elm_drop_target_del(obj);
2679 elm_entry_editable_get(const Evas_Object *obj)
2681 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2682 Widget_Data *wd = elm_widget_data_get(obj);
2683 if (!wd) return EINA_FALSE;
2684 return wd->editable;
2688 elm_entry_select_none(Evas_Object *obj)
2690 ELM_CHECK_WIDTYPE(obj, widtype);
2691 Widget_Data *wd = elm_widget_data_get(obj);
2692 if ((!wd) || (wd->password)) return;
2695 wd->selmode = EINA_FALSE;
2696 if (!_elm_config->desktop_entry)
2697 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2698 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2700 wd->have_selection = EINA_FALSE;
2701 edje_object_part_text_select_none(wd->ent, "elm.text");
2705 elm_entry_select_all(Evas_Object *obj)
2707 ELM_CHECK_WIDTYPE(obj, widtype);
2708 Widget_Data *wd = elm_widget_data_get(obj);
2709 if ((!wd) || (wd->password)) return;
2712 wd->selmode = EINA_FALSE;
2713 if (!_elm_config->desktop_entry)
2714 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2715 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2717 wd->have_selection = EINA_TRUE;
2718 edje_object_part_text_select_all(wd->ent, "elm.text");
2722 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2724 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2725 Widget_Data *wd = elm_widget_data_get(obj);
2726 if (!wd) return EINA_FALSE;
2727 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2732 elm_entry_cursor_next(Evas_Object *obj)
2734 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2735 Widget_Data *wd = elm_widget_data_get(obj);
2736 if (!wd) return EINA_FALSE;
2737 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2741 elm_entry_cursor_prev(Evas_Object *obj)
2743 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2744 Widget_Data *wd = elm_widget_data_get(obj);
2745 if (!wd) return EINA_FALSE;
2746 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2750 elm_entry_cursor_up(Evas_Object *obj)
2752 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2753 Widget_Data *wd = elm_widget_data_get(obj);
2754 if (!wd) return EINA_FALSE;
2755 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2759 elm_entry_cursor_down(Evas_Object *obj)
2761 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2762 Widget_Data *wd = elm_widget_data_get(obj);
2763 if (!wd) return EINA_FALSE;
2764 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2768 elm_entry_cursor_begin_set(Evas_Object *obj)
2770 ELM_CHECK_WIDTYPE(obj, widtype);
2771 Widget_Data *wd = elm_widget_data_get(obj);
2773 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2777 elm_entry_cursor_end_set(Evas_Object *obj)
2779 ELM_CHECK_WIDTYPE(obj, widtype);
2780 Widget_Data *wd = elm_widget_data_get(obj);
2782 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2786 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2788 ELM_CHECK_WIDTYPE(obj, widtype);
2789 Widget_Data *wd = elm_widget_data_get(obj);
2791 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2795 elm_entry_cursor_line_end_set(Evas_Object *obj)
2797 ELM_CHECK_WIDTYPE(obj, widtype);
2798 Widget_Data *wd = elm_widget_data_get(obj);
2800 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2804 elm_entry_cursor_selection_begin(Evas_Object *obj)
2806 ELM_CHECK_WIDTYPE(obj, widtype);
2807 Widget_Data *wd = elm_widget_data_get(obj);
2809 edje_object_part_text_select_begin(wd->ent, "elm.text");
2813 elm_entry_cursor_selection_end(Evas_Object *obj)
2815 ELM_CHECK_WIDTYPE(obj, widtype);
2816 Widget_Data *wd = elm_widget_data_get(obj);
2818 edje_object_part_text_select_extend(wd->ent, "elm.text");
2822 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2824 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2825 Widget_Data *wd = elm_widget_data_get(obj);
2826 if (!wd) return EINA_FALSE;
2827 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2831 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2833 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2834 Widget_Data *wd = elm_widget_data_get(obj);
2835 if (!wd) return EINA_FALSE;
2836 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2840 elm_entry_cursor_content_get(const Evas_Object *obj)
2842 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2843 Widget_Data *wd = elm_widget_data_get(obj);
2844 if (!wd) return NULL;
2845 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2849 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2851 ELM_CHECK_WIDTYPE(obj, widtype);
2852 Widget_Data *wd = elm_widget_data_get(obj);
2854 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2855 edje_object_message_signal_process(wd->ent);
2859 elm_entry_cursor_pos_get(const Evas_Object *obj)
2861 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2862 Widget_Data *wd = elm_widget_data_get(obj);
2864 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2868 elm_entry_selection_cut(Evas_Object *obj)
2870 ELM_CHECK_WIDTYPE(obj, widtype);
2871 Widget_Data *wd = elm_widget_data_get(obj);
2872 if ((!wd) || (wd->password)) return;
2873 _cut(obj, NULL, NULL);
2877 elm_entry_selection_copy(Evas_Object *obj)
2879 ELM_CHECK_WIDTYPE(obj, widtype);
2880 Widget_Data *wd = elm_widget_data_get(obj);
2881 if ((!wd) || (wd->password)) return;
2882 _copy(obj, NULL, NULL);
2886 elm_entry_selection_paste(Evas_Object *obj)
2888 ELM_CHECK_WIDTYPE(obj, widtype);
2889 Widget_Data *wd = elm_widget_data_get(obj);
2890 if ((!wd) || (wd->password)) return;
2891 _paste(obj, NULL, NULL);
2895 elm_entry_context_menu_clear(Evas_Object *obj)
2897 ELM_CHECK_WIDTYPE(obj, widtype);
2898 Widget_Data *wd = elm_widget_data_get(obj);
2899 Elm_Entry_Context_Menu_Item *it;
2901 EINA_LIST_FREE(wd->items, it)
2903 eina_stringshare_del(it->label);
2904 eina_stringshare_del(it->icon_file);
2905 eina_stringshare_del(it->icon_group);
2911 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)
2913 ELM_CHECK_WIDTYPE(obj, widtype);
2914 Widget_Data *wd = elm_widget_data_get(obj);
2915 Elm_Entry_Context_Menu_Item *it;
2917 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2919 wd->items = eina_list_append(wd->items, it);
2921 it->label = eina_stringshare_add(label);
2922 it->icon_file = eina_stringshare_add(icon_file);
2923 it->icon_type = icon_type;
2925 it->data = (void *)data;
2929 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2931 ELM_CHECK_WIDTYPE(obj, widtype);
2932 Widget_Data *wd = elm_widget_data_get(obj);
2934 if (wd->context_menu == !disabled) return;
2935 wd->context_menu = !disabled;
2939 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2941 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2942 Widget_Data *wd = elm_widget_data_get(obj);
2943 if (!wd) return EINA_FALSE;
2944 return !wd->context_menu;
2948 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2950 ELM_CHECK_WIDTYPE(obj, widtype);
2951 Widget_Data *wd = elm_widget_data_get(obj);
2953 EINA_SAFETY_ON_NULL_RETURN(func);
2954 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2958 wd->item_providers = eina_list_append(wd->item_providers, ip);
2962 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2964 ELM_CHECK_WIDTYPE(obj, widtype);
2965 Widget_Data *wd = elm_widget_data_get(obj);
2967 EINA_SAFETY_ON_NULL_RETURN(func);
2968 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2972 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2976 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2978 ELM_CHECK_WIDTYPE(obj, widtype);
2979 Widget_Data *wd = elm_widget_data_get(obj);
2981 Elm_Entry_Item_Provider *ip;
2983 EINA_SAFETY_ON_NULL_RETURN(func);
2984 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2986 if ((ip->func == func) && ((!data) || (ip->data == data)))
2988 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2996 elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2999 Elm_Entry_Markup_Filter *tf;
3000 ELM_CHECK_WIDTYPE(obj, widtype);
3002 wd = elm_widget_data_get(obj);
3004 EINA_SAFETY_ON_NULL_RETURN(func);
3006 tf = _filter_new(func, data);
3009 wd->text_filters = eina_list_append(wd->text_filters, tf);
3013 elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3016 Elm_Entry_Markup_Filter *tf;
3017 ELM_CHECK_WIDTYPE(obj, widtype);
3019 wd = elm_widget_data_get(obj);
3021 EINA_SAFETY_ON_NULL_RETURN(func);
3023 tf = _filter_new(func, data);
3026 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3030 elm_entry_text_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3034 Elm_Entry_Markup_Filter *tf;
3035 ELM_CHECK_WIDTYPE(obj, widtype);
3037 wd = elm_widget_data_get(obj);
3039 EINA_SAFETY_ON_NULL_RETURN(func);
3041 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3043 if ((tf->func == func) && ((!data) || (tf->data == data)))
3045 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3053 elm_entry_markup_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3056 Elm_Entry_Markup_Filter *tf;
3057 ELM_CHECK_WIDTYPE(obj, widtype);
3059 wd = elm_widget_data_get(obj);
3061 EINA_SAFETY_ON_NULL_RETURN(func);
3063 tf = _filter_new(func, data);
3066 wd->markup_filters = eina_list_append(wd->markup_filters, tf);
3070 elm_entry_markup_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3073 Elm_Entry_Markup_Filter *tf;
3074 ELM_CHECK_WIDTYPE(obj, widtype);
3076 wd = elm_widget_data_get(obj);
3078 EINA_SAFETY_ON_NULL_RETURN(func);
3080 tf = _filter_new(func, data);
3083 wd->markup_filters = eina_list_prepend(wd->markup_filters, tf);
3087 elm_entry_markup_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3091 Elm_Entry_Markup_Filter *tf;
3092 ELM_CHECK_WIDTYPE(obj, widtype);
3094 wd = elm_widget_data_get(obj);
3096 EINA_SAFETY_ON_NULL_RETURN(func);
3098 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
3100 if ((tf->func == func) && ((!data) || (tf->data == data)))
3102 wd->markup_filters = eina_list_remove_list(wd->markup_filters, l);
3110 elm_entry_markup_to_utf8(const char *s)
3112 char *ss = _elm_util_mkup_to_text(s);
3113 if (!ss) ss = strdup("");
3118 elm_entry_utf8_to_markup(const char *s)
3120 char *ss = _elm_util_text_to_mkup(s);
3121 if (!ss) ss = strdup("");
3126 _text_get(const Evas_Object *obj)
3128 return elm_object_text_get(obj);
3132 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3134 Elm_Entry_Filter_Limit_Size *lim = data;
3135 char *current, *utfstr;
3137 const char *(*text_get)(const Evas_Object *);
3139 EINA_SAFETY_ON_NULL_RETURN(data);
3140 EINA_SAFETY_ON_NULL_RETURN(entry);
3141 EINA_SAFETY_ON_NULL_RETURN(text);
3143 /* hack. I don't want to copy the entire function to work with
3145 text_get = _text_get;
3147 current = elm_entry_markup_to_utf8(text_get(entry));
3148 utfstr = elm_entry_markup_to_utf8(*text);
3150 if (lim->max_char_count > 0)
3152 len = evas_string_char_len_get(current);
3153 if (len >= lim->max_char_count)
3155 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3162 newlen = evas_string_char_len_get(utfstr);
3163 if ((len + newlen) > lim->max_char_count)
3164 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3166 else if (lim->max_byte_count > 0)
3168 len = strlen(current);
3169 if (len >= lim->max_byte_count)
3171 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3178 newlen = strlen(utfstr);
3179 if ((len + newlen) > lim->max_byte_count)
3180 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3187 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3189 Elm_Entry_Filter_Accept_Set *as = data;
3193 int read_idx, last_read_idx = 0, read_char;
3195 EINA_SAFETY_ON_NULL_RETURN(data);
3196 EINA_SAFETY_ON_NULL_RETURN(text);
3198 if ((!as->accepted) && (!as->rejected))
3204 goes_in = EINA_TRUE;
3209 goes_in = EINA_FALSE;
3213 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3216 int cmp_idx, cmp_char;
3217 Eina_Bool in_set = EINA_FALSE;
3219 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3222 if (read_char == cmp_char)
3227 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3229 if (in_set == goes_in)
3231 int size = read_idx - last_read_idx;
3232 const char *src = (*text) + last_read_idx;
3234 memcpy(insert, *text + last_read_idx, size);
3237 last_read_idx = read_idx;
3238 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3244 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3246 ELM_CHECK_WIDTYPE(obj, widtype);
3247 Widget_Data *wd = elm_widget_data_get(obj);
3249 if (wd->delay_write)
3251 ecore_timer_del(wd->delay_write);
3252 wd->delay_write = NULL;
3254 if (wd->autosave) _save(obj);
3255 eina_stringshare_replace(&wd->file, file);
3256 wd->format = format;
3261 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3263 ELM_CHECK_WIDTYPE(obj, widtype);
3264 Widget_Data *wd = elm_widget_data_get(obj);
3266 if (file) *file = wd->file;
3267 if (format) *format = wd->format;
3271 elm_entry_file_save(Evas_Object *obj)
3273 ELM_CHECK_WIDTYPE(obj, widtype);
3274 Widget_Data *wd = elm_widget_data_get(obj);
3276 if (wd->delay_write)
3278 ecore_timer_del(wd->delay_write);
3279 wd->delay_write = NULL;
3282 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3286 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3288 ELM_CHECK_WIDTYPE(obj, widtype);
3289 Widget_Data *wd = elm_widget_data_get(obj);
3291 wd->autosave = !!autosave;
3295 elm_entry_autosave_get(const Evas_Object *obj)
3297 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3298 Widget_Data *wd = elm_widget_data_get(obj);
3299 if (!wd) return EINA_FALSE;
3300 return wd->autosave;
3304 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3306 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3307 ELM_CHECK_WIDTYPE(obj, widtype);
3308 Widget_Data *wd = elm_widget_data_get(obj);
3310 textonly = !!textonly;
3311 if (wd->textonly == textonly) return;
3312 wd->textonly = !!textonly;
3313 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3314 #ifdef HAVE_ELEMENTARY_X
3315 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3320 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3322 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3323 Widget_Data *wd = elm_widget_data_get(obj);
3324 if (!wd) return EINA_FALSE;
3325 return wd->textonly;
3329 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3331 ELM_CHECK_WIDTYPE(obj, widtype);
3332 Widget_Data *wd = elm_widget_data_get(obj);
3333 const Elm_Scroller_Policy map[3] =
3335 ELM_SMART_SCROLLER_POLICY_AUTO,
3336 ELM_SMART_SCROLLER_POLICY_ON,
3337 ELM_SMART_SCROLLER_POLICY_OFF
3341 if (wd->scroll == scroll) return;
3342 wd->scroll = scroll;
3347 wd->scroller = elm_smart_scroller_add(evas_object_evas_get(obj));
3348 elm_widget_resize_object_set(obj, wd->scroller);
3349 elm_smart_scroller_widget_set(wd->scroller, obj);
3350 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
3351 elm_widget_style_get(obj));
3352 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3353 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
3354 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
3355 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(wd->scroller),
3358 elm_smart_scroller_bounce_allow_set(wd->scroller, wd->h_bounce, wd->v_bounce);
3359 if (wd->single_line)
3360 elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
3361 ELM_SMART_SCROLLER_POLICY_OFF);
3363 elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]);
3364 elm_widget_sub_object_add(obj, wd->ent);
3365 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3366 evas_object_show(wd->scroller);
3367 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3373 elm_smart_scroller_child_set(wd->scroller, NULL);
3374 evas_object_smart_member_add(wd->scroller, obj);
3375 elm_widget_sub_object_add(obj, wd->scroller);
3376 evas_object_hide(wd->scroller);
3378 elm_widget_sub_object_del(obj, wd->ent);
3379 elm_widget_resize_object_set(obj, wd->ent);
3380 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3387 elm_entry_scrollable_get(const Evas_Object *obj)
3389 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3390 Widget_Data *wd = elm_widget_data_get(obj);
3391 if (!wd) return EINA_FALSE;
3396 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3398 ELM_CHECK_WIDTYPE(obj, widtype);
3399 EINA_SAFETY_ON_NULL_RETURN(icon);
3400 _content_set_hook(obj, NULL, icon);
3404 elm_entry_icon_get(const Evas_Object *obj)
3406 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3407 return _content_get_hook(obj, NULL);
3411 elm_entry_icon_unset(Evas_Object *obj)
3413 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3414 return _content_unset_hook(obj, NULL);
3418 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3420 ELM_CHECK_WIDTYPE(obj, widtype);
3421 Widget_Data *wd = elm_widget_data_get(obj);
3425 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3429 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3431 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3433 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3438 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3440 ELM_CHECK_WIDTYPE(obj, widtype);
3441 EINA_SAFETY_ON_NULL_RETURN(end);
3442 _content_set_hook(obj, "end", end);
3446 elm_entry_end_get(const Evas_Object *obj)
3448 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3449 return _content_get_hook(obj, "end");
3453 elm_entry_end_unset(Evas_Object *obj)
3455 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3456 return _content_unset_hook(obj, "end");
3460 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3462 ELM_CHECK_WIDTYPE(obj, widtype);
3463 Widget_Data *wd = elm_widget_data_get(obj);
3467 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3471 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3473 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3475 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3480 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3482 ELM_CHECK_WIDTYPE(obj, widtype);
3483 Widget_Data *wd = elm_widget_data_get(obj);
3484 const Elm_Scroller_Policy map[3] =
3486 ELM_SMART_SCROLLER_POLICY_AUTO,
3487 ELM_SMART_SCROLLER_POLICY_ON,
3488 ELM_SMART_SCROLLER_POLICY_OFF
3493 elm_smart_scroller_policy_set(wd->scroller,
3499 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3501 ELM_CHECK_WIDTYPE(obj, widtype);
3502 Widget_Data *wd = elm_widget_data_get(obj);
3504 wd->h_bounce = h_bounce;
3505 wd->v_bounce = v_bounce;
3506 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3510 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3512 ELM_CHECK_WIDTYPE(obj, widtype);
3513 Widget_Data *wd = elm_widget_data_get(obj);
3515 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
3519 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3521 ELM_CHECK_WIDTYPE(obj, widtype);
3522 Widget_Data *wd = elm_widget_data_get(obj);
3525 wd->input_panel_layout = layout;
3527 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
3530 EAPI Elm_Input_Panel_Layout
3531 elm_entry_input_panel_layout_get(Evas_Object *obj)
3533 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
3534 Widget_Data *wd = elm_widget_data_get(obj);
3535 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
3537 return wd->input_panel_layout;
3541 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
3543 ELM_CHECK_WIDTYPE(obj, widtype);
3544 Widget_Data *wd = elm_widget_data_get(obj);
3547 wd->autocapital_type = autocapital_type;
3548 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
3551 EAPI Elm_Autocapital_Type
3552 elm_entry_autocapital_type_get(Evas_Object *obj)
3554 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
3555 Widget_Data *wd = elm_widget_data_get(obj);
3556 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
3558 return wd->autocapital_type;
3562 elm_entry_prediction_allow_set(Evas_Object *obj, Eina_Bool prediction)
3564 ELM_CHECK_WIDTYPE(obj, widtype);
3565 Widget_Data *wd = elm_widget_data_get(obj);
3568 wd->prediction_allow = prediction;
3569 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", prediction);
3573 elm_entry_prediction_allow_get(Evas_Object *obj)
3575 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3576 Widget_Data *wd = elm_widget_data_get(obj);
3577 if (!wd) return EINA_TRUE;
3579 return wd->prediction_allow;
3583 elm_entry_imf_context_reset(Evas_Object *obj)
3585 ELM_CHECK_WIDTYPE(obj, widtype);
3586 Widget_Data *wd = elm_widget_data_get(obj);
3589 edje_object_part_text_imf_context_reset(wd->ent, "elm.text");
3593 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3595 ELM_CHECK_WIDTYPE(obj, widtype);
3596 Widget_Data *wd = elm_widget_data_get(obj);
3599 wd->input_panel_enable = enabled;
3600 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3604 elm_entry_input_panel_enabled_get(Evas_Object *obj)
3606 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3607 Widget_Data *wd = elm_widget_data_get(obj);
3608 if (!wd) return EINA_TRUE;
3610 return wd->input_panel_enable;
3614 elm_entry_input_panel_show(Evas_Object *obj)
3616 ELM_CHECK_WIDTYPE(obj, widtype);
3617 Widget_Data *wd = elm_widget_data_get(obj);
3620 edje_object_part_text_input_panel_show(wd->ent, "elm.text");
3624 elm_entry_input_panel_hide(Evas_Object *obj)
3626 ELM_CHECK_WIDTYPE(obj, widtype);
3627 Widget_Data *wd = elm_widget_data_get(obj);
3630 edje_object_part_text_input_panel_hide(wd->ent, "elm.text");