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_Text_Filter Elm_Entry_Text_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;
45 Mod_Api *api; // module api if supplied
47 Elm_Scroller_Policy policy_h, policy_v;
48 Elm_Wrap_Type linewrap;
49 Elm_Input_Panel_Layout input_panel_layout;
50 Elm_Autocapital_Type autocapital_type;
51 Eina_Bool changed : 1;
52 Eina_Bool single_line : 1;
53 Eina_Bool password : 1;
54 Eina_Bool editable : 1;
55 Eina_Bool selection_asked : 1;
56 Eina_Bool have_selection : 1;
57 Eina_Bool selmode : 1;
58 Eina_Bool deferred_cur : 1;
59 Eina_Bool cur_changed : 1;
60 Eina_Bool disabled : 1;
61 Eina_Bool context_menu : 1;
62 Eina_Bool drag_selection_asked : 1;
63 Eina_Bool can_write : 1;
64 Eina_Bool autosave : 1;
65 Eina_Bool textonly : 1;
66 Eina_Bool usedown : 1;
68 Eina_Bool h_bounce : 1;
69 Eina_Bool v_bounce : 1;
70 Eina_Bool input_panel_enable : 1;
73 struct _Elm_Entry_Context_Menu_Item
77 const char *icon_file;
78 const char *icon_group;
79 Elm_Icon_Type icon_type;
84 struct _Elm_Entry_Item_Provider
86 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
90 struct _Elm_Entry_Text_Filter
92 Elm_Entry_Filter_Cb func;
96 typedef enum _Length_Unit
103 static const char *widtype = NULL;
105 #ifdef HAVE_ELEMENTARY_X
106 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
108 static void _del_hook(Evas_Object *obj);
109 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
110 static void _theme_hook(Evas_Object *obj);
111 static void _disable_hook(Evas_Object *obj);
112 static void _sizing_eval(Evas_Object *obj);
113 static void _on_focus_hook(void *data, Evas_Object *obj);
114 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
115 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
116 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
117 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
118 static const char *_getbase(Evas_Object *obj);
119 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
120 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
121 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
122 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
123 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
124 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
125 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
126 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
127 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
129 static const char SIG_CHANGED[] = "changed";
130 static const char SIG_CHANGED_USER[] = "changed,user";
131 static const char SIG_ACTIVATED[] = "activated";
132 static const char SIG_PRESS[] = "press";
133 static const char SIG_LONGPRESSED[] = "longpressed";
134 static const char SIG_CLICKED[] = "clicked";
135 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
136 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
137 static const char SIG_FOCUSED[] = "focused";
138 static const char SIG_UNFOCUSED[] = "unfocused";
139 static const char SIG_SELECTION_PASTE[] = "selection,paste";
140 static const char SIG_SELECTION_COPY[] = "selection,copy";
141 static const char SIG_SELECTION_CUT[] = "selection,cut";
142 static const char SIG_SELECTION_START[] = "selection,start";
143 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
144 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
145 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
146 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
147 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
148 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
149 static const char SIG_ANCHOR_UP[] = "anchor,up";
150 static const char SIG_ANCHOR_IN[] = "anchor,in";
151 static const char SIG_ANCHOR_OUT[] = "anchor,out";
152 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
153 static const char SIG_UNDO_REQUEST[] = "undo,request";
154 static const char SIG_REDO_REQUEST[] = "redo,request";
155 static const Evas_Smart_Cb_Description _signals[] = {
159 {SIG_LONGPRESSED, ""},
161 {SIG_CLICKED_DOUBLE, ""},
162 {SIG_CLICKED_TRIPLE, ""},
165 {SIG_SELECTION_PASTE, ""},
166 {SIG_SELECTION_COPY, ""},
167 {SIG_SELECTION_CUT, ""},
168 {SIG_SELECTION_START, ""},
169 {SIG_SELECTION_CHANGED, ""},
170 {SIG_SELECTION_CLEARED, ""},
171 {SIG_CURSOR_CHANGED, ""},
172 {SIG_CURSOR_CHANGED_MANUAL, ""},
173 {SIG_ANCHOR_CLICKED, ""},
174 {SIG_ANCHOR_DOWN, ""},
177 {SIG_ANCHOR_OUT, ""},
178 {SIG_PREEDIT_CHANGED, ""},
179 {SIG_CHANGED_USER, ""},
180 {SIG_UNDO_REQUEST, ""},
181 {SIG_REDO_REQUEST, ""},
185 static Eina_List *entries = NULL;
189 void (*obj_hook) (Evas_Object *obj);
190 void (*obj_unhook) (Evas_Object *obj);
191 void (*obj_longpress) (Evas_Object *obj);
195 _module(Evas_Object *obj __UNUSED__)
197 static Elm_Module *m = NULL;
198 if (m) goto ok; // already found - just use
199 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
201 m->api = malloc(sizeof(Mod_Api));
202 if (!m->api) return NULL;
203 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
204 _elm_module_symbol_get(m, "obj_hook");
205 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
206 _elm_module_symbol_get(m, "obj_unhook");
207 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
208 _elm_module_symbol_get(m, "obj_longpress");
209 ok: // ok - return api
214 _buf_append(char *buf, const char *str, int *len, int *alloc)
216 int len2 = strlen(str);
217 if ((*len + len2) >= *alloc)
219 char *buf2 = realloc(buf, *alloc + len2 + 512);
220 if (!buf2) return NULL;
222 *alloc += (512 + len2);
224 strcpy(buf + *len, str);
230 _load_file(const char *file)
234 int alloc = 0, len = 0;
235 char *text = NULL, buf[16384 + 1];
237 f = fopen(file, "rb");
239 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
243 tmp_text = _buf_append(text, buf, &len, &alloc);
244 if (!tmp_text) break;
252 _load_plain(const char *file)
256 text = _load_file(file);
261 text2 = elm_entry_utf8_to_markup(text);
269 _load(Evas_Object *obj)
271 Widget_Data *wd = elm_widget_data_get(obj);
276 elm_object_text_set(obj, "");
281 case ELM_TEXT_FORMAT_PLAIN_UTF8:
282 text = _load_plain(wd->file);
284 case ELM_TEXT_FORMAT_MARKUP_UTF8:
285 text = _load_file(wd->file);
293 elm_object_text_set(obj, text);
297 elm_object_text_set(obj, "");
301 _save_markup_utf8(const char *file, const char *text)
305 if ((!text) || (!text[0]))
307 ecore_file_unlink(file);
310 f = fopen(file, "wb");
313 // FIXME: report a write error
316 fputs(text, f); // FIXME: catch error
321 _save_plain_utf8(const char *file, const char *text)
325 text2 = elm_entry_markup_to_utf8(text);
328 _save_markup_utf8(file, text2);
333 _save(Evas_Object *obj)
335 Widget_Data *wd = elm_widget_data_get(obj);
337 if (!wd->file) return;
340 case ELM_TEXT_FORMAT_PLAIN_UTF8:
341 _save_plain_utf8(wd->file, elm_object_text_get(obj));
343 case ELM_TEXT_FORMAT_MARKUP_UTF8:
344 _save_markup_utf8(wd->file, elm_object_text_get(obj));
352 _delay_write(void *data)
354 Widget_Data *wd = elm_widget_data_get(data);
355 if (!wd) return ECORE_CALLBACK_CANCEL;
357 wd->delay_write = NULL;
358 return ECORE_CALLBACK_CANCEL;
361 static Elm_Entry_Text_Filter *
362 _filter_new(Elm_Entry_Filter_Cb func, void *data)
364 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
365 if (!tf) return NULL;
368 if (func == elm_entry_filter_limit_size)
370 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
377 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
383 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
386 else if (func == elm_entry_filter_accept_set)
388 Elm_Entry_Filter_Accept_Set *as = data, *as2;
395 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
402 as2->accepted = eina_stringshare_add(as->accepted);
404 as2->accepted = NULL;
406 as2->rejected = eina_stringshare_add(as->rejected);
408 as2->rejected = NULL;
417 _filter_free(Elm_Entry_Text_Filter *tf)
419 if (tf->func == elm_entry_filter_limit_size)
421 Elm_Entry_Filter_Limit_Size *lim = tf->data;
424 else if (tf->func == elm_entry_filter_accept_set)
426 Elm_Entry_Filter_Accept_Set *as = tf->data;
429 if (as->accepted) eina_stringshare_del(as->accepted);
430 if (as->rejected) eina_stringshare_del(as->rejected);
438 _del_pre_hook(Evas_Object *obj)
440 Widget_Data *wd = elm_widget_data_get(obj);
444 ecore_timer_del(wd->delay_write);
445 wd->delay_write = NULL;
446 if (wd->autosave) _save(obj);
451 _del_hook(Evas_Object *obj)
453 Widget_Data *wd = elm_widget_data_get(obj);
454 Elm_Entry_Context_Menu_Item *it;
455 Elm_Entry_Item_Provider *ip;
456 Elm_Entry_Text_Filter *tf;
458 evas_event_freeze(evas_object_evas_get(obj));
460 if (wd->file) eina_stringshare_del(wd->file);
462 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
463 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
465 entries = eina_list_remove(entries, obj);
466 #ifdef HAVE_ELEMENTARY_X
467 if (wd->sel_notify_handler)
468 ecore_event_handler_del(wd->sel_notify_handler);
469 if (wd->sel_clear_handler)
470 ecore_event_handler_del(wd->sel_clear_handler);
472 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
473 if (wd->text) eina_stringshare_del(wd->text);
474 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
475 if (wd->append_text_idler)
477 ecore_idler_del(wd->append_text_idler);
478 free(wd->append_text_left);
479 wd->append_text_left = NULL;
480 wd->append_text_idler = NULL;
482 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
483 EINA_LIST_FREE(wd->items, it)
485 eina_stringshare_del(it->label);
486 eina_stringshare_del(it->icon_file);
487 eina_stringshare_del(it->icon_group);
490 EINA_LIST_FREE(wd->item_providers, ip)
494 EINA_LIST_FREE(wd->text_filters, tf)
498 if (wd->delay_write) ecore_timer_del(wd->delay_write);
501 evas_event_thaw(evas_object_evas_get(obj));
502 evas_event_thaw_eval(evas_object_evas_get(obj));
506 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
508 Widget_Data *wd = elm_widget_data_get(obj);
509 edje_object_mirrored_set(wd->ent, rtl);
513 _theme_hook(Evas_Object *obj)
515 Widget_Data *wd = elm_widget_data_get(obj);
518 evas_event_freeze(evas_object_evas_get(obj));
519 _elm_widget_mirrored_reload(obj);
520 _mirrored_set(obj, elm_widget_mirrored_get(obj));
522 t = eina_stringshare_add(elm_object_text_get(obj));
523 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
524 if (_elm_config->desktop_entry)
525 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
526 elm_object_text_set(obj, t);
527 eina_stringshare_del(t);
528 if (elm_widget_disabled_get(obj))
529 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
530 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
531 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
532 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
533 if (wd->cursor_pos != 0)
534 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
535 if (elm_widget_focus_get(obj))
536 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
537 edje_object_message_signal_process(wd->ent);
538 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
544 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
545 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
546 elm_widget_style_get(obj));
547 edj = elm_smart_scroller_edje_object_get(wd->scroller);
548 str = edje_object_data_get(edj, "focus_highlight");
549 if ((str) && (!strcmp(str, "on")))
550 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
552 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
555 evas_event_thaw(evas_object_evas_get(obj));
556 evas_event_thaw_eval(evas_object_evas_get(obj));
560 _disable_hook(Evas_Object *obj)
562 Widget_Data *wd = elm_widget_data_get(obj);
564 if (elm_widget_disabled_get(obj))
566 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
567 wd->disabled = EINA_TRUE;
571 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
572 wd->disabled = EINA_FALSE;
577 _recalc_cursor_geometry(Evas_Object *obj)
579 Widget_Data *wd = elm_widget_data_get(obj);
581 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
582 if (!wd->deferred_recalc_job)
584 Evas_Coord cx, cy, cw, ch;
585 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
589 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
590 wd->cur_changed = EINA_FALSE;
594 wd->deferred_cur = EINA_TRUE;
598 _elm_deferred_recalc_job(void *data)
600 Widget_Data *wd = elm_widget_data_get(data);
601 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
603 wd->deferred_recalc_job = NULL;
605 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
606 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
607 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
608 /* This is a hack to workaround the way min size hints are treated.
609 * If the minimum width is smaller than the restricted width, it means
610 * the mininmum doesn't matter. */
613 Evas_Coord ominw = -1;
614 evas_object_size_hint_min_get(data, &ominw, NULL);
621 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
624 Evas_Coord vmw = 0, vmh = 0;
626 edje_object_size_min_calc
627 (elm_smart_scroller_edje_object_get(wd->scroller),
631 evas_object_size_hint_min_set(data, vmw, minh + vmh);
632 evas_object_size_hint_max_set(data, -1, minh + vmh);
636 evas_object_size_hint_min_set(data, vmw, vmh);
637 evas_object_size_hint_max_set(data, -1, -1);
644 evas_object_size_hint_min_set(data, minw, minh);
645 evas_object_size_hint_max_set(data, -1, minh);
649 evas_object_size_hint_min_set(data, fw, minh);
650 evas_object_size_hint_max_set(data, -1, -1);
654 if (wd->deferred_cur)
656 Evas_Coord cx, cy, cw, ch;
657 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
661 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
662 wd->cur_changed = EINA_FALSE;
668 _sizing_eval(Evas_Object *obj)
670 Widget_Data *wd = elm_widget_data_get(obj);
671 Evas_Coord minw = -1, minh = -1;
672 Evas_Coord resw, resh;
675 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
678 if ((resw == wd->lastw) && (!wd->changed)) return;
679 evas_event_freeze(evas_object_evas_get(obj));
680 wd->changed = EINA_FALSE;
684 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
686 evas_object_resize(wd->scroller, resw, resh);
687 edje_object_size_min_calc
688 (elm_smart_scroller_edje_object_get(wd->scroller),
690 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
691 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
692 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
693 /* This is a hack to workaround the way min size hints are treated.
694 * If the minimum width is smaller than the restricted width, it means
695 * the mininmum doesn't matter. */
698 Evas_Coord ominw = -1;
699 evas_object_size_hint_min_get(wd->ent, &ominw, NULL);
705 if ((minw > 0) && (vw < minw)) vw = minw;
706 if (minh > vh) vh = minh;
708 if (wd->single_line) h = vmh + minh;
710 evas_object_resize(wd->ent, vw, vh);
711 evas_object_size_hint_min_set(obj, w, h);
713 evas_object_size_hint_max_set(obj, -1, h);
715 evas_object_size_hint_max_set(obj, -1, -1);
719 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
720 wd->deferred_recalc_job = ecore_job_add(_elm_deferred_recalc_job, obj);
722 evas_event_thaw(evas_object_evas_get(obj));
723 evas_event_thaw_eval(evas_object_evas_get(obj));
727 if (!wd->changed) return;
728 evas_event_freeze(evas_object_evas_get(obj));
729 wd->changed = EINA_FALSE;
733 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
735 edje_object_size_min_calc(wd->ent, &minw, &minh);
738 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
740 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
742 if ((minw > 0) && (vw < minw)) vw = minw;
743 if (minh > 0) vh = minh;
745 evas_object_resize(wd->ent, vw, vh);
746 edje_object_size_min_calc
747 (elm_smart_scroller_edje_object_get(wd->scroller),
749 if (wd->single_line) h = vmh + minh;
751 evas_object_size_hint_min_set(obj, w, h);
753 evas_object_size_hint_max_set(obj, -1, h);
755 evas_object_size_hint_max_set(obj, -1, -1);
759 edje_object_size_min_calc(wd->ent, &minw, &minh);
762 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
763 evas_object_size_hint_min_set(obj, minw, minh);
765 evas_object_size_hint_max_set(obj, -1, minh);
767 evas_object_size_hint_max_set(obj, -1, -1);
769 evas_event_thaw(evas_object_evas_get(obj));
770 evas_event_thaw_eval(evas_object_evas_get(obj));
773 _recalc_cursor_geometry(obj);
777 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
779 Widget_Data *wd = elm_widget_data_get(obj);
780 Evas_Object *top = elm_widget_top_get(obj);
782 if (!wd->editable) return;
783 if (elm_widget_focus_get(obj))
785 evas_object_focus_set(wd->ent, EINA_TRUE);
786 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
787 if (top && wd->input_panel_enable)
788 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
789 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
793 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
794 evas_object_focus_set(wd->ent, EINA_FALSE);
795 if (top && wd->input_panel_enable)
796 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
797 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
802 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
804 Widget_Data *wd = elm_widget_data_get(obj);
806 if ((!wd) || (!content)) return;
809 edje = elm_smart_scroller_edje_object_get(wd->scroller);
813 /* Delete the currently swallowed object */
814 Evas_Object *cswallow;
816 if (!part || !strcmp(part, "icon"))
818 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon");
819 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
821 else if (!strcmp(part, "end"))
823 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end");
824 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
827 cswallow = edje_object_part_swallow_get(edje, part);
829 if (cswallow) evas_object_del(cswallow);
831 evas_event_freeze(evas_object_evas_get(obj));
832 elm_widget_sub_object_add(obj, content);
834 if (!part || !strcmp(part, "icon"))
835 edje_object_part_swallow(edje, "elm.swallow.icon", content);
836 else if (!strcmp(part, "end"))
837 edje_object_part_swallow(edje, "elm.swallow.end", content);
839 edje_object_part_swallow(edje, part, content);
842 evas_event_thaw(evas_object_evas_get(obj));
843 evas_event_thaw_eval(evas_object_evas_get(obj));
847 _content_unset_hook(Evas_Object *obj, const char *part)
849 Widget_Data *wd = elm_widget_data_get(obj);
850 Evas_Object *content, *edje;
851 if (!wd) return NULL;
854 edje = elm_smart_scroller_edje_object_get(wd->scroller);
858 if (!part || !strcmp(part, "icon"))
860 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
861 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
863 else if (!strcmp(part, "end"))
865 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
866 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
869 content = edje_object_part_swallow_get(edje, part);
871 edje_object_part_swallow(edje, part, NULL);
872 if (!content) return NULL;
873 evas_event_freeze(evas_object_evas_get(obj));
874 elm_widget_sub_object_del(obj, content);
875 edje_object_part_unswallow(wd->ent, content);
877 evas_event_thaw(evas_object_evas_get(obj));
878 evas_event_thaw_eval(evas_object_evas_get(obj));
884 _content_get_hook(const Evas_Object *obj, const char *part)
886 Widget_Data *wd = elm_widget_data_get(obj);
887 Evas_Object *content = NULL, *edje;
888 if (!wd) return NULL;
891 edje = elm_smart_scroller_edje_object_get(wd->scroller);
895 if (!edje) return NULL;
897 if (!part || !strcmp(part, "icon"))
898 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
899 else if (!strcmp(part, "end"))
900 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
902 content = edje_object_part_swallow_get(edje, part);
908 _translate_hook(Evas_Object *obj)
910 evas_object_smart_callback_call(obj, "language,changed", NULL);
914 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
916 Widget_Data *wd = elm_widget_data_get(obj);
918 edje_object_signal_emit(wd->ent, emission, source);
920 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
925 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
927 Widget_Data *wd = elm_widget_data_get(obj);
929 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
931 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
932 emission, source, func_cb, data);
936 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
938 Widget_Data *wd = elm_widget_data_get(obj);
939 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
942 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
943 emission, source, func_cb, data);
947 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
949 Widget_Data *wd = elm_widget_data_get(obj);
950 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
954 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
956 Widget_Data *wd = elm_widget_data_get(obj);
958 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
962 _show_region_hook(void *data, Evas_Object *obj)
964 Widget_Data *wd = elm_widget_data_get(data);
965 Evas_Coord x, y, w, h;
967 elm_widget_show_region_get(obj, &x, &y, &w, &h);
969 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
973 _sub_del(void *data, Evas_Object *obj, void *event_info)
975 Widget_Data *wd = data;
976 Evas_Object *sub = event_info;
980 edje = elm_smart_scroller_edje_object_get(wd->scroller);
984 if (sub == edje_object_part_swallow_get(edje, "elm.swallow.icon"))
986 edje_object_part_unswallow(edje, sub);
988 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
990 else if (sub == edje_object_part_swallow_get(edje, "elm.swallow.end"))
992 edje_object_part_unswallow(edje, sub);
994 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1000 _hoversel_position(Evas_Object *obj)
1002 Widget_Data *wd = elm_widget_data_get(obj);
1003 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1008 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1017 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1018 &cx, &cy, &cw, &ch);
1019 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1022 cx += (cw - mw) / 2;
1027 cy += (ch - mh) / 2;
1030 evas_object_move(wd->hoversel, x + cx, y + cy);
1031 evas_object_resize(wd->hoversel, cw, ch);
1035 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1037 Widget_Data *wd = elm_widget_data_get(data);
1039 if (wd->hoversel) _hoversel_position(data);
1043 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1052 else if (wd->scroll)
1054 Evas_Coord vw = 0, vh = 0;
1056 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1057 if (vw < wd->entmw) vw = wd->entmw;
1058 if (vh < wd->entmh) vh = wd->entmh;
1059 evas_object_resize(wd->ent, vw, vh);
1061 if (wd->hoversel) _hoversel_position(data);
1065 _hover_del(void *data)
1067 Widget_Data *wd = elm_widget_data_get(data);
1072 evas_object_del(wd->hoversel);
1073 wd->hoversel = NULL;
1075 wd->hovdeljob = NULL;
1079 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1081 Widget_Data *wd = elm_widget_data_get(data);
1084 if (wd->hoversel) evas_object_hide(wd->hoversel);
1087 if (!_elm_config->desktop_entry)
1090 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1093 elm_widget_scroll_freeze_pop(data);
1094 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1095 wd->hovdeljob = ecore_job_add(_hover_del, data);
1099 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1101 Widget_Data *wd = elm_widget_data_get(data);
1103 wd->selmode = EINA_TRUE;
1104 edje_object_part_text_select_none(wd->ent, "elm.text");
1105 if (!_elm_config->desktop_entry)
1108 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1110 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1111 if (!_elm_config->desktop_entry)
1112 elm_widget_scroll_hold_push(data);
1116 _elm_entry_entry_paste(Evas_Object *obj, const char *entry)
1118 Elm_Entry_Change_Info info;
1119 info.insert = EINA_TRUE;
1120 info.change.insert.pos = elm_entry_cursor_pos_get(obj);
1121 info.change.insert.content = eina_stringshare_add(entry);
1124 tmp = evas_textblock_text_markup_to_utf8(elm_entry_textblock_get(obj),
1125 info.change.insert.content);
1126 info.change.insert.plain_length = eina_unicode_utf8_get_len(tmp);
1130 elm_entry_entry_insert(obj, entry);
1131 evas_object_smart_callback_call(obj, SIG_CHANGED_USER, &info);
1133 eina_stringshare_del(info.change.insert.content);
1137 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1139 Widget_Data *wd = elm_widget_data_get(data);
1141 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1142 if (wd->sel_notify_handler)
1144 #ifdef HAVE_ELEMENTARY_X
1145 Elm_Sel_Format formats;
1146 wd->selection_asked = EINA_TRUE;
1147 formats = ELM_SEL_FORMAT_MARKUP;
1149 formats |= ELM_SEL_FORMAT_IMAGE;
1150 elm_cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, formats, data, NULL, NULL);
1156 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1158 Widget_Data *wd = elm_widget_data_get(obj);
1162 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1163 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1164 elm_cnp_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1165 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1166 eina_stringshare_replace(&wd->cut_sel, sel);
1170 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1172 Widget_Data *wd = elm_widget_data_get(data);
1175 wd->selmode = EINA_FALSE;
1176 if (!_elm_config->desktop_entry)
1177 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1178 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1179 if (!_elm_config->desktop_entry)
1180 elm_widget_scroll_hold_pop(data);
1181 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1182 edje_object_part_text_insert(wd->ent, "elm.text", "");
1183 edje_object_part_text_select_none(wd->ent, "elm.text");
1188 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1190 Widget_Data *wd = elm_widget_data_get(data);
1192 wd->selmode = EINA_FALSE;
1193 if (!_elm_config->desktop_entry)
1195 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1196 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1197 elm_widget_scroll_hold_pop(data);
1199 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1200 // edje_object_part_text_select_none(wd->ent, "elm.text");
1204 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1206 Widget_Data *wd = elm_widget_data_get(data);
1208 wd->selmode = EINA_FALSE;
1209 if (!_elm_config->desktop_entry)
1210 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1211 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1212 if (!_elm_config->desktop_entry)
1213 elm_widget_scroll_hold_pop(data);
1214 edje_object_part_text_select_none(wd->ent, "elm.text");
1218 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1220 Elm_Entry_Context_Menu_Item *it = data;
1221 Evas_Object *obj2 = it->obj;
1222 if (it->func) it->func(it->data, obj2, NULL);
1226 _menu_press(Evas_Object *obj)
1228 Widget_Data *wd = elm_widget_data_get(obj);
1231 const Elm_Entry_Context_Menu_Item *it;
1233 if ((wd->api) && (wd->api->obj_longpress))
1235 wd->api->obj_longpress(obj);
1237 else if (wd->context_menu)
1239 const char *context_menu_orientation;
1241 if (wd->hoversel) evas_object_del(wd->hoversel);
1242 else elm_widget_scroll_freeze_push(obj);
1243 wd->hoversel = elm_hoversel_add(obj);
1244 context_menu_orientation = edje_object_data_get
1245 (wd->ent, "context_menu_orientation");
1246 if ((context_menu_orientation) &&
1247 (!strcmp(context_menu_orientation, "horizontal")))
1248 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1249 elm_object_style_set(wd->hoversel, "entry");
1250 elm_widget_sub_object_add(obj, wd->hoversel);
1251 elm_object_text_set(wd->hoversel, "Text");
1252 top = elm_widget_top_get(obj);
1253 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1254 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1255 if (wd->have_selection)
1259 if (wd->have_selection)
1261 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1264 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1267 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1275 if (!_elm_config->desktop_entry)
1278 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1281 if (elm_selection_selection_has_owner())
1284 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1289 EINA_LIST_FOREACH(wd->items, l, it)
1291 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1292 it->icon_type, _item_clicked, it);
1296 _hoversel_position(obj);
1297 evas_object_show(wd->hoversel);
1298 elm_hoversel_hover_begin(wd->hoversel);
1300 if (!_elm_config->desktop_entry)
1302 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1303 edje_object_part_text_select_abort(wd->ent, "elm.text");
1309 _long_press(void *data)
1311 Widget_Data *wd = elm_widget_data_get(data);
1312 if (!wd) return ECORE_CALLBACK_CANCEL;
1314 wd->longpress_timer = NULL;
1315 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1316 return ECORE_CALLBACK_CANCEL;
1320 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1322 Widget_Data *wd = elm_widget_data_get(data);
1323 Evas_Event_Mouse_Down *ev = event_info;
1325 if (wd->disabled) return;
1326 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1327 wd->downx = ev->canvas.x;
1328 wd->downy = ev->canvas.y;
1329 if (ev->button == 1)
1331 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1332 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1337 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1339 Widget_Data *wd = elm_widget_data_get(data);
1340 Evas_Event_Mouse_Up *ev = event_info;
1342 if (wd->disabled) return;
1343 if (ev->button == 1)
1345 if (wd->longpress_timer)
1347 ecore_timer_del(wd->longpress_timer);
1348 wd->longpress_timer = NULL;
1351 else if (ev->button == 3)
1359 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1361 Widget_Data *wd = elm_widget_data_get(data);
1362 Evas_Event_Mouse_Move *ev = event_info;
1364 if (wd->disabled) return;
1367 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1369 if (wd->longpress_timer)
1371 ecore_timer_del(wd->longpress_timer);
1372 wd->longpress_timer = NULL;
1375 else if (wd->longpress_timer)
1379 dx = wd->downx - ev->cur.canvas.x;
1381 dy = wd->downy - ev->cur.canvas.y;
1384 ((_elm_config->finger_size / 2) *
1385 (_elm_config->finger_size / 2)))
1387 ecore_timer_del(wd->longpress_timer);
1388 wd->longpress_timer = NULL;
1392 else if (wd->longpress_timer)
1396 dx = wd->downx - ev->cur.canvas.x;
1398 dy = wd->downy - ev->cur.canvas.y;
1401 ((_elm_config->finger_size / 2) *
1402 (_elm_config->finger_size / 2)))
1404 ecore_timer_del(wd->longpress_timer);
1405 wd->longpress_timer = NULL;
1411 _getbase(Evas_Object *obj)
1413 Widget_Data *wd = elm_widget_data_get(obj);
1414 if (!wd) return "base";
1417 if (wd->password) return "base-password";
1420 if (wd->single_line) return "base-single";
1423 switch (wd->linewrap)
1426 return "base-charwrap";
1429 case ELM_WRAP_MIXED:
1430 return "base-mixedwrap";
1433 return "base-nowrap";
1440 if (wd->password) return "base-password";
1443 if (wd->single_line) return "base-single-noedit";
1446 switch (wd->linewrap)
1449 return "base-noedit-charwrap";
1451 return "base-noedit";
1452 case ELM_WRAP_MIXED:
1453 return "base-noedit-mixedwrap";
1456 return "base-nowrap-noedit";
1464 _entry_changed_common_handling(void *data, const char *event)
1466 Widget_Data *wd = elm_widget_data_get(data);
1469 evas_event_freeze(evas_object_evas_get(data));
1470 wd->changed = EINA_TRUE;
1471 /* Reset the size hints which are no more relevant.
1472 * Keep the height, this is a hack, but doesn't really matter
1473 * cause we'll re-eval in a moment. */
1474 evas_object_size_hint_min_get(data, NULL, &minh);
1475 evas_object_size_hint_min_set(data, -1, minh);
1477 if (wd->text) eina_stringshare_del(wd->text);
1479 if (wd->delay_write)
1481 ecore_timer_del(wd->delay_write);
1482 wd->delay_write = NULL;
1484 evas_event_thaw(evas_object_evas_get(data));
1485 evas_event_thaw_eval(evas_object_evas_get(data));
1486 if ((wd->autosave) && (wd->file))
1487 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1488 /* callback - this could call callbacks that delete the entry... thus...
1489 * any access to wd after this could be invalid */
1490 evas_object_smart_callback_call(data, event, NULL);
1494 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1496 _entry_changed_common_handling(data, SIG_CHANGED);
1500 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1502 Elm_Entry_Change_Info info;
1503 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
1504 edje_object_signal_callback_extra_data_get();
1507 memcpy(&info, edje_info, sizeof(info));
1508 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
1512 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
1517 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1519 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1523 _signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1525 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
1529 _signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1531 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
1535 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1537 Widget_Data *wd = elm_widget_data_get(data);
1541 EINA_LIST_FOREACH(entries, l, entry)
1543 if (entry != data) elm_entry_select_none(entry);
1545 wd->have_selection = EINA_TRUE;
1546 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1547 #ifdef HAVE_ELEMENTARY_X
1548 if (wd->sel_notify_handler)
1550 const char *txt = elm_entry_selection_get(data);
1553 top = elm_widget_top_get(data);
1554 if (txt && top && (elm_win_xwindow_get(top)))
1555 elm_cnp_selection_set(ELM_SEL_TYPE_PRIMARY, data,
1556 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
1562 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1564 Widget_Data *wd = elm_widget_data_get(data);
1566 elm_entry_select_all(data);
1570 _signal_selection_none(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1572 Widget_Data *wd = elm_widget_data_get(data);
1574 elm_entry_select_none(data);
1578 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1580 Widget_Data *wd = elm_widget_data_get(data);
1582 wd->have_selection = EINA_TRUE;
1583 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1584 _store_selection(ELM_SEL_TYPE_PRIMARY, data);
1588 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1590 Widget_Data *wd = elm_widget_data_get(data);
1592 if (!wd->have_selection) return;
1593 wd->have_selection = EINA_FALSE;
1594 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1595 if (wd->sel_notify_handler)
1599 #ifdef HAVE_ELEMENTARY_X
1602 top = elm_widget_top_get(data);
1603 if ((top) && (elm_win_xwindow_get(top)))
1604 elm_cnp_selection_set(ELM_SEL_TYPE_PRIMARY, data,
1605 ELM_SEL_FORMAT_MARKUP, wd->cut_sel,
1606 strlen(wd->cut_sel));
1608 eina_stringshare_del(wd->cut_sel);
1613 #ifdef HAVE_ELEMENTARY_X
1616 top = elm_widget_top_get(data);
1617 if ((top) && (elm_win_xwindow_get(top)))
1618 elm_cnp_selection_clear(ELM_SEL_TYPE_PRIMARY, data);
1625 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1627 Widget_Data *wd = elm_widget_data_get(data);
1628 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
1629 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
1631 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1632 if (wd->sel_notify_handler)
1634 #ifdef HAVE_ELEMENTARY_X
1637 top = elm_widget_top_get(data);
1638 if ((top) && (elm_win_xwindow_get(top)))
1640 wd->selection_asked = EINA_TRUE;
1641 elm_cnp_selection_get(type, ELM_SEL_FORMAT_MARKUP, data,
1649 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1651 _copy(data, NULL, NULL);
1655 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1657 _cut(data, NULL, NULL);
1661 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1663 Widget_Data *wd = elm_widget_data_get(data);
1665 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1666 wd->cur_changed = EINA_TRUE;
1667 _recalc_cursor_geometry(data);
1671 _signal_cursor_changed_manual(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1673 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
1678 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
1680 const Eina_List *geoms, *l;
1681 Evas_Textblock_Rectangle *r;
1682 Evas_Coord px, py, x, y;
1684 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
1688 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1689 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1690 EINA_LIST_FOREACH(geoms, l, r)
1692 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1693 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1705 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1707 Widget_Data *wd = elm_widget_data_get(data);
1708 Elm_Entry_Anchor_Info ei;
1712 p = emission + sizeof("nchor,mouse,down,");
1713 ei.button = strtol(p, &p2, 10);
1715 ei.x = ei.y = ei.w = ei.h = 0;
1717 _signal_anchor_geoms_do_things_with(wd, &ei);
1720 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
1724 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1726 Widget_Data *wd = elm_widget_data_get(data);
1727 Elm_Entry_Anchor_Info ei;
1731 p = emission + sizeof("nchor,mouse,up,");
1732 ei.button = strtol(p, &p2, 10);
1734 ei.x = ei.y = ei.w = ei.h = 0;
1736 _signal_anchor_geoms_do_things_with(wd, &ei);
1739 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
1743 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1745 Widget_Data *wd = elm_widget_data_get(data);
1746 Elm_Entry_Anchor_Info ei;
1750 p = emission + sizeof("nchor,mouse,clicked,");
1751 ei.button = strtol(p, &p2, 10);
1753 ei.x = ei.y = ei.w = ei.h = 0;
1755 _signal_anchor_geoms_do_things_with(wd, &ei);
1758 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1762 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1764 Widget_Data *wd = elm_widget_data_get(data);
1769 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1771 Widget_Data *wd = elm_widget_data_get(data);
1772 Elm_Entry_Anchor_Info ei;
1774 ei.name = emission + sizeof("nchor,mouse,in,");
1776 ei.x = ei.y = ei.w = ei.h = 0;
1778 _signal_anchor_geoms_do_things_with(wd, &ei);
1781 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
1785 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1787 Widget_Data *wd = elm_widget_data_get(data);
1788 Elm_Entry_Anchor_Info ei;
1790 ei.name = emission + sizeof("nchor,mouse,out,");
1792 ei.x = ei.y = ei.w = ei.h = 0;
1794 _signal_anchor_geoms_do_things_with(wd, &ei);
1797 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
1801 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1803 Widget_Data *wd = elm_widget_data_get(data);
1805 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1809 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1811 Widget_Data *wd = elm_widget_data_get(data);
1813 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1817 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1819 Widget_Data *wd = elm_widget_data_get(data);
1821 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1825 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1827 Widget_Data *wd = elm_widget_data_get(data);
1829 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1833 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1835 Widget_Data *wd = elm_widget_data_get(data);
1837 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
1840 #ifdef HAVE_ELEMENTARY_X
1842 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1844 Widget_Data *wd = elm_widget_data_get(data);
1845 Ecore_X_Event_Selection_Notify *ev = event;
1846 if (!wd) return ECORE_CALLBACK_PASS_ON;
1847 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1848 return ECORE_CALLBACK_PASS_ON;
1850 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1851 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1853 Ecore_X_Selection_Data_Text *text_data;
1855 text_data = ev->data;
1856 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1858 if (text_data->text)
1860 char *txt = _elm_util_text_to_mkup(text_data->text);
1864 elm_entry_entry_insert(data, txt);
1869 wd->selection_asked = EINA_FALSE;
1871 else if (ev->selection == ECORE_X_SELECTION_XDND)
1873 Ecore_X_Selection_Data_Text *text_data;
1875 text_data = ev->data;
1876 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1878 if (text_data->text)
1880 char *txt = _elm_util_text_to_mkup(text_data->text);
1884 /* Massive FIXME: this should be at the drag point */
1885 elm_entry_entry_insert(data, txt);
1890 wd->drag_selection_asked = EINA_FALSE;
1892 ecore_x_dnd_send_finished();
1895 return ECORE_CALLBACK_PASS_ON;
1899 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
1901 Widget_Data *wd = elm_widget_data_get(data);
1902 Ecore_X_Event_Selection_Clear *ev = event;
1903 if (!wd) return ECORE_CALLBACK_PASS_ON;
1904 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1905 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1906 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1908 elm_entry_select_none(data);
1910 return ECORE_CALLBACK_PASS_ON;
1914 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1919 wd = elm_widget_data_get(obj);
1920 if (!wd) return EINA_FALSE;
1921 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1923 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1924 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1925 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1926 EDJE_CURSOR_MAIN,drop->x,drop->y);
1927 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1928 elm_entry_entry_insert(obj, drop->data);
1929 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1930 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1936 static Evas_Object *
1937 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1939 Widget_Data *wd = elm_widget_data_get(data);
1942 Elm_Entry_Item_Provider *ip;
1944 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1946 o = ip->func(ip->data, data, item);
1949 if (!strncmp(item, "file://", 7))
1951 const char *fname = item + 7;
1953 o = evas_object_image_filled_add(evas_object_evas_get(data));
1954 evas_object_image_file_set(o, fname, NULL);
1955 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1957 evas_object_show(o);
1962 o = edje_object_add(evas_object_evas_get(data));
1963 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1967 o = edje_object_add(evas_object_evas_get(data));
1968 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1969 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1974 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
1976 Widget_Data *wd = elm_widget_data_get(data);
1978 Elm_Entry_Text_Filter *tf;
1980 if (type == EDJE_TEXT_FILTER_FORMAT)
1983 EINA_LIST_FOREACH(wd->text_filters, l, tf)
1985 tf->func(tf->data, data, text);
1991 /* This function is used to insert text by chunks in jobs */
1993 _text_append_idler(void *data)
1997 Evas_Object *obj = (Evas_Object *) data;
1998 Widget_Data *wd = elm_widget_data_get(obj);
1999 evas_event_freeze(evas_object_evas_get(obj));
2000 if (wd->text) eina_stringshare_del(wd->text);
2002 wd->changed = EINA_TRUE;
2004 start = wd->append_text_position;
2005 if (start + _CHUNK_SIZE < wd->append_text_len)
2008 int tag_start, esc_start;
2010 tag_start = esc_start = -1;
2011 /* Find proper markup cut place */
2012 while (pos - start < _CHUNK_SIZE)
2016 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2017 if (esc_start == -1)
2020 tag_start = prev_pos;
2021 else if (tmp == '>')
2024 if (tag_start == -1)
2027 esc_start = prev_pos;
2028 else if (tmp == ';')
2035 wd->append_text_position = tag_start;
2037 else if (esc_start >= 0)
2039 wd->append_text_position = esc_start;
2043 wd->append_text_position = pos;
2048 wd->append_text_position = wd->append_text_len;
2051 backup = wd->append_text_left[wd->append_text_position];
2052 wd->append_text_left[wd->append_text_position] = '\0';
2054 edje_object_part_text_append(wd->ent, "elm.text",
2055 wd->append_text_left + start);
2057 wd->append_text_left[wd->append_text_position] = backup;
2059 evas_event_thaw(evas_object_evas_get(obj));
2060 evas_event_thaw_eval(evas_object_evas_get(obj));
2062 /* If there's still more to go, renew the idler, else, cleanup */
2063 if (wd->append_text_position < wd->append_text_len)
2065 return ECORE_CALLBACK_RENEW;
2069 free(wd->append_text_left);
2070 wd->append_text_left = NULL;
2071 wd->append_text_idler = NULL;
2072 return ECORE_CALLBACK_CANCEL;
2077 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2079 int i = 0, current_len = 0;
2083 if (unit >= LENGTH_UNIT_LAST) return;
2085 current_len = strlen(*text);
2088 int idx = 0, unit_size = 0;
2089 char *markup, *utfstr;
2090 if (*new_text == '<')
2092 while (*(new_text + idx) != '>')
2095 if (!*(new_text + idx)) break;
2098 else if (*new_text == '&')
2100 while (*(new_text + idx) != ';')
2103 if (!*(new_text + idx)) break;
2106 idx = evas_string_char_next_get(new_text, idx, NULL);
2107 markup = malloc(idx + 1);
2110 strncpy(markup, new_text, idx);
2112 utfstr = elm_entry_markup_to_utf8(markup);
2115 if (unit == LENGTH_UNIT_BYTE)
2116 unit_size = strlen(utfstr);
2117 else if (unit == LENGTH_UNIT_CHAR)
2118 unit_size = evas_string_char_len_get(utfstr);
2125 if (can_add < unit_size)
2129 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2135 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2137 (*text)[current_len] = 0;
2142 can_add -= unit_size;
2146 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2150 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2153 ELM_CHECK_WIDTYPE(obj, widtype);
2154 Widget_Data *wd = elm_widget_data_get(obj);
2156 evas_event_freeze(evas_object_evas_get(obj));
2157 if (!entry) entry = "";
2158 if (item && strcmp(item, "default"))
2160 edje_object_part_text_set(wd->ent, item, entry);
2164 if (wd->text) eina_stringshare_del(wd->text);
2166 wd->changed = EINA_TRUE;
2168 /* Clear currently pending job if there is one */
2169 if (wd->append_text_idler)
2171 ecore_idler_del(wd->append_text_idler);
2172 free(wd->append_text_left);
2173 wd->append_text_left = NULL;
2174 wd->append_text_idler = NULL;
2177 len = strlen(entry);
2178 /* Split to ~_CHUNK_SIZE chunks */
2179 if (len > _CHUNK_SIZE)
2181 wd->append_text_left = (char *) malloc(len + 1);
2184 /* If we decided to use the idler */
2185 if (wd->append_text_left)
2187 /* Need to clear the entry first */
2188 edje_object_part_text_set(wd->ent, "elm.text", "");
2189 memcpy(wd->append_text_left, entry, len + 1);
2190 wd->append_text_position = 0;
2191 wd->append_text_len = len;
2192 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2196 edje_object_part_text_set(wd->ent, "elm.text", entry);
2198 evas_event_thaw(evas_object_evas_get(obj));
2199 evas_event_thaw_eval(evas_object_evas_get(obj));
2203 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2205 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2206 Widget_Data *wd = elm_widget_data_get(obj);
2207 if (item && strcmp(item, "default")) return NULL;
2209 if (!wd) return NULL;
2210 if (wd->text) return wd->text;
2211 text = edje_object_part_text_get(wd->ent, "elm.text");
2214 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2218 if (wd->append_text_len > 0)
2222 tlen = strlen(text);
2223 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2226 ERR("Failed to allocate memory for entry's text %p", obj);
2229 memcpy(tmpbuf, text, tlen);
2230 memcpy(tmpbuf + tlen, wd->append_text_left, wd->append_text_len);
2231 tmpbuf[tlen + wd->append_text_len] = '\0';
2232 eina_stringshare_replace(&wd->text, tmpbuf);
2237 eina_stringshare_replace(&wd->text, text);
2243 elm_entry_add(Evas_Object *parent)
2245 Evas_Object *obj, *top;
2249 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2251 ELM_SET_WIDTYPE(widtype, "entry");
2252 elm_widget_type_set(obj, "entry");
2253 elm_widget_sub_object_add(parent, obj);
2254 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2255 elm_widget_data_set(obj, wd);
2256 elm_widget_del_hook_set(obj, _del_hook);
2257 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2258 elm_widget_theme_hook_set(obj, _theme_hook);
2259 elm_widget_disable_hook_set(obj, _disable_hook);
2260 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2261 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2262 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2263 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2264 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2265 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2266 elm_widget_can_focus_set(obj, EINA_TRUE);
2267 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2268 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2269 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2270 elm_widget_content_set_hook_set(obj, _content_set_hook);
2271 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2272 elm_widget_content_get_hook_set(obj, _content_get_hook);
2273 elm_widget_translate_hook_set(obj, _translate_hook);
2275 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2277 wd->linewrap = ELM_WRAP_WORD;
2278 wd->editable = EINA_TRUE;
2279 wd->disabled = EINA_FALSE;
2280 wd->context_menu = EINA_TRUE;
2281 wd->autosave = EINA_TRUE;
2282 wd->textonly = EINA_FALSE;
2283 wd->scroll = EINA_FALSE;
2285 wd->ent = edje_object_add(e);
2286 edje_object_item_provider_set(wd->ent, _get_item, obj);
2287 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2288 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2289 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2291 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2293 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2295 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2297 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2298 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2299 _signal_entry_changed, obj);
2300 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
2301 _signal_entry_changed_user, obj);
2302 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2303 _signal_preedit_changed, obj);
2304 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2305 _signal_selection_start, obj);
2306 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2307 _signal_selection_changed, obj);
2308 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2309 _signal_selection_all, obj);
2310 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2311 _signal_selection_none, obj);
2312 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2313 _signal_selection_cleared, obj);
2314 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2315 _signal_entry_paste_request, obj);
2316 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2317 _signal_entry_copy_notify, obj);
2318 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2319 _signal_entry_cut_notify, obj);
2320 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2321 _signal_cursor_changed, obj);
2322 edje_object_signal_callback_add(wd->ent, "cursor,changed,manual", "elm.text",
2323 _signal_cursor_changed_manual, obj);
2324 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2325 _signal_anchor_down, obj);
2326 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2327 _signal_anchor_up, obj);
2328 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2329 _signal_anchor_clicked, obj);
2330 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2331 _signal_anchor_move, obj);
2332 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2333 _signal_anchor_in, obj);
2334 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2335 _signal_anchor_out, obj);
2336 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2337 _signal_key_enter, obj);
2338 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2339 _signal_mouse_down, obj);
2340 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2341 _signal_mouse_clicked, obj);
2342 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2343 _signal_mouse_double, obj);
2344 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
2345 _signal_mouse_triple, obj);
2346 edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
2347 _signal_undo_request, obj);
2348 edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
2349 _signal_redo_request, obj);
2350 edje_object_part_text_set(wd->ent, "elm.text", "");
2351 if (_elm_config->desktop_entry)
2352 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2353 elm_widget_resize_object_set(obj, wd->ent);
2356 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
2358 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2359 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
2361 #ifdef HAVE_ELEMENTARY_X
2362 top = elm_widget_top_get(obj);
2363 if ((top) && (elm_win_xwindow_get(top)))
2365 wd->sel_notify_handler =
2366 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2367 _event_selection_notify, obj);
2368 wd->sel_clear_handler =
2369 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2370 _event_selection_clear, obj);
2373 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2374 _drag_drop_cb, NULL);
2377 entries = eina_list_prepend(entries, obj);
2379 // module - find module for entry
2380 wd->api = _module(obj);
2381 // if found - hook in
2382 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2384 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2385 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2386 // TODO: and save some bytes, making descriptions per-class and not instance!
2387 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2392 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2394 ELM_CHECK_WIDTYPE(obj, widtype);
2395 Widget_Data *wd = elm_widget_data_get(obj);
2397 if (wd->single_line == single_line) return;
2398 wd->single_line = single_line;
2399 wd->linewrap = ELM_WRAP_NONE;
2400 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2404 if (wd->single_line)
2405 elm_smart_scroller_policy_set(wd->scroller,
2406 ELM_SMART_SCROLLER_POLICY_OFF,
2407 ELM_SMART_SCROLLER_POLICY_OFF);
2410 const Elm_Scroller_Policy map[3] =
2412 ELM_SMART_SCROLLER_POLICY_AUTO,
2413 ELM_SMART_SCROLLER_POLICY_ON,
2414 ELM_SMART_SCROLLER_POLICY_OFF
2416 elm_smart_scroller_policy_set(wd->scroller,
2425 elm_entry_single_line_get(const Evas_Object *obj)
2427 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2428 Widget_Data *wd = elm_widget_data_get(obj);
2429 if (!wd) return EINA_FALSE;
2430 return wd->single_line;
2434 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2436 ELM_CHECK_WIDTYPE(obj, widtype);
2437 Widget_Data *wd = elm_widget_data_get(obj);
2439 if (wd->password == password) return;
2440 wd->password = password;
2443 wd->single_line = EINA_TRUE;
2444 wd->linewrap = ELM_WRAP_NONE;
2445 #ifdef HAVE_ELEMENTARY_X
2446 elm_drop_target_del(obj);
2448 edje_object_signal_callback_del_full(wd->ent, "selection,start", "elm.text",
2449 _signal_selection_start, obj);
2450 edje_object_signal_callback_del_full(wd->ent, "selection,changed", "elm.text",
2451 _signal_selection_changed, obj);
2452 edje_object_signal_callback_del_full(wd->ent, "entry,selection,all,request", "elm.text",
2453 _signal_selection_all, obj);
2454 edje_object_signal_callback_del_full(wd->ent, "entry,selection,none,request", "elm.text",
2455 _signal_selection_none, obj);
2456 edje_object_signal_callback_del_full(wd->ent, "selection,cleared", "elm.text",
2457 _signal_selection_cleared, obj);
2458 edje_object_signal_callback_del_full(wd->ent, "entry,paste,request,*", "elm.text",
2459 _signal_entry_paste_request, obj);
2460 edje_object_signal_callback_del_full(wd->ent, "entry,copy,notify", "elm.text",
2461 _signal_entry_copy_notify, obj);
2462 edje_object_signal_callback_del_full(wd->ent, "entry,cut,notify", "elm.text",
2463 _signal_entry_cut_notify, obj);
2467 #ifdef HAVE_ELEMENTARY_X
2468 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2470 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2471 _signal_selection_start, obj);
2472 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2473 _signal_selection_changed, obj);
2474 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2475 _signal_selection_all, obj);
2476 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2477 _signal_selection_none, obj);
2478 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2479 _signal_selection_cleared, obj);
2480 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2481 _signal_entry_paste_request, obj);
2482 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2483 _signal_entry_copy_notify, obj);
2484 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2485 _signal_entry_cut_notify, obj);
2491 elm_entry_password_get(const Evas_Object *obj)
2493 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2494 Widget_Data *wd = elm_widget_data_get(obj);
2495 if (!wd) return EINA_FALSE;
2496 return wd->password;
2500 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2502 _elm_entry_text_set(obj, NULL, entry);
2506 elm_entry_entry_get(const Evas_Object *obj)
2508 return _elm_entry_text_get(obj, NULL);
2512 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2515 ELM_CHECK_WIDTYPE(obj, widtype);
2516 Widget_Data *wd = elm_widget_data_get(obj);
2518 if (!entry) entry = "";
2519 wd->changed = EINA_TRUE;
2521 len = strlen(entry);
2522 if (wd->append_text_left)
2525 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2531 wd->append_text_left = tmpbuf;
2532 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2533 wd->append_text_len += len;
2537 /* FIXME: Add chunked appending here (like in entry_set) */
2538 edje_object_part_text_append(wd->ent, "elm.text", entry);
2543 elm_entry_is_empty(const Evas_Object *obj)
2545 /* FIXME: until there's support for that in textblock, we just check
2546 * to see if the there is text or not. */
2547 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2548 Widget_Data *wd = elm_widget_data_get(obj);
2549 const Evas_Object *tb;
2550 Evas_Textblock_Cursor *cur;
2552 if (!wd) return EINA_TRUE;
2553 /* It's a hack until we get the support suggested above.
2554 * We just create a cursor, point it to the begining, and then
2555 * try to advance it, if it can advance, the tb is not empty,
2556 * otherwise it is. */
2557 tb = edje_object_part_object_get(wd->ent, "elm.text");
2558 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2559 actually, ok for the time being, thsese hackish stuff will be removed
2560 once evas 1.0 is out*/
2561 evas_textblock_cursor_pos_set(cur, 0);
2562 ret = evas_textblock_cursor_char_next(cur);
2563 evas_textblock_cursor_free(cur);
2569 elm_entry_textblock_get(Evas_Object *obj)
2571 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2572 Widget_Data *wd = elm_widget_data_get(obj);
2573 if (!wd) return NULL;
2575 return (Evas_Object *) edje_object_part_object_get(wd->ent, "elm.text");
2579 elm_entry_calc_force(Evas_Object *obj)
2581 ELM_CHECK_WIDTYPE(obj, widtype);
2582 Widget_Data *wd = elm_widget_data_get(obj);
2585 edje_object_calc_force(wd->ent);
2586 wd->changed = EINA_TRUE;
2592 elm_entry_selection_get(const Evas_Object *obj)
2594 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2595 Widget_Data *wd = elm_widget_data_get(obj);
2596 if ((!wd) || (wd->password)) return NULL;
2597 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2601 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2603 ELM_CHECK_WIDTYPE(obj, widtype);
2604 Widget_Data *wd = elm_widget_data_get(obj);
2606 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2607 wd->changed = EINA_TRUE;
2612 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2614 ELM_CHECK_WIDTYPE(obj, widtype);
2615 Widget_Data *wd = elm_widget_data_get(obj);
2617 if (wd->linewrap == wrap) return;
2619 wd->linewrap = wrap;
2624 elm_entry_line_wrap_get(const Evas_Object *obj)
2626 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2627 Widget_Data *wd = elm_widget_data_get(obj);
2628 if (!wd) return EINA_FALSE;
2629 return wd->linewrap;
2633 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2635 ELM_CHECK_WIDTYPE(obj, widtype);
2636 Widget_Data *wd = elm_widget_data_get(obj);
2638 if (wd->editable == editable) return;
2639 wd->editable = editable;
2642 #ifdef HAVE_ELEMENTARY_X
2644 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2646 elm_drop_target_del(obj);
2651 elm_entry_editable_get(const Evas_Object *obj)
2653 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2654 Widget_Data *wd = elm_widget_data_get(obj);
2655 if (!wd) return EINA_FALSE;
2656 return wd->editable;
2660 elm_entry_select_none(Evas_Object *obj)
2662 ELM_CHECK_WIDTYPE(obj, widtype);
2663 Widget_Data *wd = elm_widget_data_get(obj);
2664 if ((!wd) || (wd->password)) return;
2667 wd->selmode = EINA_FALSE;
2668 if (!_elm_config->desktop_entry)
2669 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2670 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2672 wd->have_selection = EINA_FALSE;
2673 edje_object_part_text_select_none(wd->ent, "elm.text");
2677 elm_entry_select_all(Evas_Object *obj)
2679 ELM_CHECK_WIDTYPE(obj, widtype);
2680 Widget_Data *wd = elm_widget_data_get(obj);
2681 if ((!wd) || (wd->password)) return;
2684 wd->selmode = EINA_FALSE;
2685 if (!_elm_config->desktop_entry)
2686 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2687 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2689 wd->have_selection = EINA_TRUE;
2690 edje_object_part_text_select_all(wd->ent, "elm.text");
2694 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2696 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2697 Widget_Data *wd = elm_widget_data_get(obj);
2698 if (!wd) return EINA_FALSE;
2699 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2704 elm_entry_cursor_next(Evas_Object *obj)
2706 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2707 Widget_Data *wd = elm_widget_data_get(obj);
2708 if (!wd) return EINA_FALSE;
2709 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2713 elm_entry_cursor_prev(Evas_Object *obj)
2715 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2716 Widget_Data *wd = elm_widget_data_get(obj);
2717 if (!wd) return EINA_FALSE;
2718 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2722 elm_entry_cursor_up(Evas_Object *obj)
2724 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2725 Widget_Data *wd = elm_widget_data_get(obj);
2726 if (!wd) return EINA_FALSE;
2727 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2731 elm_entry_cursor_down(Evas_Object *obj)
2733 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2734 Widget_Data *wd = elm_widget_data_get(obj);
2735 if (!wd) return EINA_FALSE;
2736 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2740 elm_entry_cursor_begin_set(Evas_Object *obj)
2742 ELM_CHECK_WIDTYPE(obj, widtype);
2743 Widget_Data *wd = elm_widget_data_get(obj);
2745 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2749 elm_entry_cursor_end_set(Evas_Object *obj)
2751 ELM_CHECK_WIDTYPE(obj, widtype);
2752 Widget_Data *wd = elm_widget_data_get(obj);
2756 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2759 elm_widget_show_region_get(obj, &x, &y, &w, &h);
2760 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
2765 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2767 ELM_CHECK_WIDTYPE(obj, widtype);
2768 Widget_Data *wd = elm_widget_data_get(obj);
2770 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2774 elm_entry_cursor_line_end_set(Evas_Object *obj)
2776 ELM_CHECK_WIDTYPE(obj, widtype);
2777 Widget_Data *wd = elm_widget_data_get(obj);
2779 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2783 elm_entry_cursor_selection_begin(Evas_Object *obj)
2785 ELM_CHECK_WIDTYPE(obj, widtype);
2786 Widget_Data *wd = elm_widget_data_get(obj);
2788 edje_object_part_text_select_begin(wd->ent, "elm.text");
2792 elm_entry_cursor_selection_end(Evas_Object *obj)
2794 ELM_CHECK_WIDTYPE(obj, widtype);
2795 Widget_Data *wd = elm_widget_data_get(obj);
2797 edje_object_part_text_select_extend(wd->ent, "elm.text");
2801 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2803 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2804 Widget_Data *wd = elm_widget_data_get(obj);
2805 if (!wd) return EINA_FALSE;
2806 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2810 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2812 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2813 Widget_Data *wd = elm_widget_data_get(obj);
2814 if (!wd) return EINA_FALSE;
2815 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2819 elm_entry_cursor_content_get(const Evas_Object *obj)
2821 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2822 Widget_Data *wd = elm_widget_data_get(obj);
2823 if (!wd) return NULL;
2824 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2828 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2830 ELM_CHECK_WIDTYPE(obj, widtype);
2831 Widget_Data *wd = elm_widget_data_get(obj);
2833 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2834 edje_object_message_signal_process(wd->ent);
2838 elm_entry_cursor_pos_get(const Evas_Object *obj)
2840 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2841 Widget_Data *wd = elm_widget_data_get(obj);
2843 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2847 elm_entry_selection_cut(Evas_Object *obj)
2849 ELM_CHECK_WIDTYPE(obj, widtype);
2850 Widget_Data *wd = elm_widget_data_get(obj);
2851 if ((!wd) || (wd->password)) return;
2852 _cut(obj, NULL, NULL);
2856 elm_entry_selection_copy(Evas_Object *obj)
2858 ELM_CHECK_WIDTYPE(obj, widtype);
2859 Widget_Data *wd = elm_widget_data_get(obj);
2860 if ((!wd) || (wd->password)) return;
2861 _copy(obj, NULL, NULL);
2865 elm_entry_selection_paste(Evas_Object *obj)
2867 ELM_CHECK_WIDTYPE(obj, widtype);
2868 Widget_Data *wd = elm_widget_data_get(obj);
2869 if ((!wd) || (wd->password)) return;
2870 _paste(obj, NULL, NULL);
2874 elm_entry_context_menu_clear(Evas_Object *obj)
2876 ELM_CHECK_WIDTYPE(obj, widtype);
2877 Widget_Data *wd = elm_widget_data_get(obj);
2878 Elm_Entry_Context_Menu_Item *it;
2880 EINA_LIST_FREE(wd->items, it)
2882 eina_stringshare_del(it->label);
2883 eina_stringshare_del(it->icon_file);
2884 eina_stringshare_del(it->icon_group);
2890 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)
2892 ELM_CHECK_WIDTYPE(obj, widtype);
2893 Widget_Data *wd = elm_widget_data_get(obj);
2894 Elm_Entry_Context_Menu_Item *it;
2896 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2898 wd->items = eina_list_append(wd->items, it);
2900 it->label = eina_stringshare_add(label);
2901 it->icon_file = eina_stringshare_add(icon_file);
2902 it->icon_type = icon_type;
2904 it->data = (void *)data;
2908 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2910 ELM_CHECK_WIDTYPE(obj, widtype);
2911 Widget_Data *wd = elm_widget_data_get(obj);
2913 if (wd->context_menu == !disabled) return;
2914 wd->context_menu = !disabled;
2918 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2920 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2921 Widget_Data *wd = elm_widget_data_get(obj);
2922 if (!wd) return EINA_FALSE;
2923 return !wd->context_menu;
2927 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2929 ELM_CHECK_WIDTYPE(obj, widtype);
2930 Widget_Data *wd = elm_widget_data_get(obj);
2932 EINA_SAFETY_ON_NULL_RETURN(func);
2933 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2937 wd->item_providers = eina_list_append(wd->item_providers, ip);
2941 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2943 ELM_CHECK_WIDTYPE(obj, widtype);
2944 Widget_Data *wd = elm_widget_data_get(obj);
2946 EINA_SAFETY_ON_NULL_RETURN(func);
2947 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2951 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2955 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2957 ELM_CHECK_WIDTYPE(obj, widtype);
2958 Widget_Data *wd = elm_widget_data_get(obj);
2960 Elm_Entry_Item_Provider *ip;
2962 EINA_SAFETY_ON_NULL_RETURN(func);
2963 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2965 if ((ip->func == func) && ((!data) || (ip->data == data)))
2967 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2975 elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2978 Elm_Entry_Text_Filter *tf;
2979 ELM_CHECK_WIDTYPE(obj, widtype);
2981 wd = elm_widget_data_get(obj);
2983 EINA_SAFETY_ON_NULL_RETURN(func);
2985 tf = _filter_new(func, data);
2988 wd->text_filters = eina_list_append(wd->text_filters, tf);
2992 elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2995 Elm_Entry_Text_Filter *tf;
2996 ELM_CHECK_WIDTYPE(obj, widtype);
2998 wd = elm_widget_data_get(obj);
3000 EINA_SAFETY_ON_NULL_RETURN(func);
3002 tf = _filter_new(func, data);
3005 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3009 elm_entry_text_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3013 Elm_Entry_Text_Filter *tf;
3014 ELM_CHECK_WIDTYPE(obj, widtype);
3016 wd = elm_widget_data_get(obj);
3018 EINA_SAFETY_ON_NULL_RETURN(func);
3020 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3022 if ((tf->func == func) && ((!data) || (tf->data == data)))
3024 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3032 elm_entry_markup_to_utf8(const char *s)
3034 char *ss = _elm_util_mkup_to_text(s);
3035 if (!ss) ss = strdup("");
3040 elm_entry_utf8_to_markup(const char *s)
3042 char *ss = _elm_util_text_to_mkup(s);
3043 if (!ss) ss = strdup("");
3048 _text_get(const Evas_Object *obj)
3050 return elm_object_text_get(obj);
3054 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3056 Elm_Entry_Filter_Limit_Size *lim = data;
3057 char *current, *utfstr;
3059 const char *(*text_get)(const Evas_Object *);
3061 EINA_SAFETY_ON_NULL_RETURN(data);
3062 EINA_SAFETY_ON_NULL_RETURN(entry);
3063 EINA_SAFETY_ON_NULL_RETURN(text);
3065 /* hack. I don't want to copy the entire function to work with
3067 text_get = _text_get;
3069 current = elm_entry_markup_to_utf8(text_get(entry));
3070 utfstr = elm_entry_markup_to_utf8(*text);
3072 if (lim->max_char_count > 0)
3074 len = evas_string_char_len_get(current);
3075 if (len >= lim->max_char_count)
3077 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3084 newlen = evas_string_char_len_get(utfstr);
3085 if ((len + newlen) > lim->max_char_count)
3086 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3088 else if (lim->max_byte_count > 0)
3090 len = strlen(current);
3091 if (len >= lim->max_byte_count)
3093 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3100 newlen = strlen(utfstr);
3101 if ((len + newlen) > lim->max_byte_count)
3102 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3109 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3111 Elm_Entry_Filter_Accept_Set *as = data;
3115 int read_idx, last_read_idx = 0, read_char;
3117 EINA_SAFETY_ON_NULL_RETURN(data);
3118 EINA_SAFETY_ON_NULL_RETURN(text);
3120 if ((!as->accepted) && (!as->rejected))
3126 goes_in = EINA_TRUE;
3131 goes_in = EINA_FALSE;
3135 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3138 int cmp_idx, cmp_char;
3139 Eina_Bool in_set = EINA_FALSE;
3141 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3144 if (read_char == cmp_char)
3149 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3151 if (in_set == goes_in)
3153 int size = read_idx - last_read_idx;
3154 const char *src = (*text) + last_read_idx;
3156 memcpy(insert, *text + last_read_idx, size);
3159 last_read_idx = read_idx;
3160 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3166 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3168 ELM_CHECK_WIDTYPE(obj, widtype);
3169 Widget_Data *wd = elm_widget_data_get(obj);
3171 if (wd->delay_write)
3173 ecore_timer_del(wd->delay_write);
3174 wd->delay_write = NULL;
3176 if (wd->autosave) _save(obj);
3177 eina_stringshare_replace(&wd->file, file);
3178 wd->format = format;
3183 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3185 ELM_CHECK_WIDTYPE(obj, widtype);
3186 Widget_Data *wd = elm_widget_data_get(obj);
3188 if (file) *file = wd->file;
3189 if (format) *format = wd->format;
3193 elm_entry_file_save(Evas_Object *obj)
3195 ELM_CHECK_WIDTYPE(obj, widtype);
3196 Widget_Data *wd = elm_widget_data_get(obj);
3198 if (wd->delay_write)
3200 ecore_timer_del(wd->delay_write);
3201 wd->delay_write = NULL;
3204 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3208 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3210 ELM_CHECK_WIDTYPE(obj, widtype);
3211 Widget_Data *wd = elm_widget_data_get(obj);
3213 wd->autosave = !!autosave;
3217 elm_entry_autosave_get(const Evas_Object *obj)
3219 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3220 Widget_Data *wd = elm_widget_data_get(obj);
3221 if (!wd) return EINA_FALSE;
3222 return wd->autosave;
3226 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3228 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3229 ELM_CHECK_WIDTYPE(obj, widtype);
3230 Widget_Data *wd = elm_widget_data_get(obj);
3232 textonly = !!textonly;
3233 if (wd->textonly == textonly) return;
3234 wd->textonly = !!textonly;
3235 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3236 #ifdef HAVE_ELEMENTARY_X
3237 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3242 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3244 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3245 Widget_Data *wd = elm_widget_data_get(obj);
3246 if (!wd) return EINA_FALSE;
3247 return wd->textonly;
3251 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3253 ELM_CHECK_WIDTYPE(obj, widtype);
3254 Widget_Data *wd = elm_widget_data_get(obj);
3255 const Elm_Scroller_Policy map[3] =
3257 ELM_SMART_SCROLLER_POLICY_AUTO,
3258 ELM_SMART_SCROLLER_POLICY_ON,
3259 ELM_SMART_SCROLLER_POLICY_OFF
3263 if (wd->scroll == scroll) return;
3264 wd->scroll = scroll;
3269 wd->scroller = elm_smart_scroller_add(evas_object_evas_get(obj));
3270 elm_widget_resize_object_set(obj, wd->scroller);
3271 elm_smart_scroller_widget_set(wd->scroller, obj);
3272 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
3273 elm_widget_style_get(obj));
3274 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3275 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
3276 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
3277 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(wd->scroller),
3280 elm_smart_scroller_bounce_allow_set(wd->scroller, wd->h_bounce, wd->v_bounce);
3281 if (wd->single_line)
3282 elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
3283 ELM_SMART_SCROLLER_POLICY_OFF);
3285 elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]);
3286 elm_widget_sub_object_add(obj, wd->ent);
3287 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3288 evas_object_show(wd->scroller);
3289 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3295 elm_smart_scroller_child_set(wd->scroller, NULL);
3296 evas_object_smart_member_add(wd->scroller, obj);
3297 elm_widget_sub_object_add(obj, wd->scroller);
3298 evas_object_hide(wd->scroller);
3300 elm_widget_sub_object_del(obj, wd->ent);
3301 elm_widget_resize_object_set(obj, wd->ent);
3302 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3309 elm_entry_scrollable_get(const Evas_Object *obj)
3311 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3312 Widget_Data *wd = elm_widget_data_get(obj);
3313 if (!wd) return EINA_FALSE;
3318 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3320 ELM_CHECK_WIDTYPE(obj, widtype);
3321 EINA_SAFETY_ON_NULL_RETURN(icon);
3322 _content_set_hook(obj, NULL, icon);
3326 elm_entry_icon_get(const Evas_Object *obj)
3328 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3329 return _content_get_hook(obj, NULL);
3333 elm_entry_icon_unset(Evas_Object *obj)
3335 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3336 return _content_unset_hook(obj, NULL);
3340 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3342 ELM_CHECK_WIDTYPE(obj, widtype);
3343 Widget_Data *wd = elm_widget_data_get(obj);
3347 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3351 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3353 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3355 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3360 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3362 ELM_CHECK_WIDTYPE(obj, widtype);
3363 EINA_SAFETY_ON_NULL_RETURN(end);
3364 _content_set_hook(obj, "end", end);
3368 elm_entry_end_get(const Evas_Object *obj)
3370 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3371 return _content_get_hook(obj, "end");
3375 elm_entry_end_unset(Evas_Object *obj)
3377 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3378 return _content_unset_hook(obj, "end");
3382 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3384 ELM_CHECK_WIDTYPE(obj, widtype);
3385 Widget_Data *wd = elm_widget_data_get(obj);
3389 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3393 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3395 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3397 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3402 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3404 ELM_CHECK_WIDTYPE(obj, widtype);
3405 Widget_Data *wd = elm_widget_data_get(obj);
3406 const Elm_Scroller_Policy map[3] =
3408 ELM_SMART_SCROLLER_POLICY_AUTO,
3409 ELM_SMART_SCROLLER_POLICY_ON,
3410 ELM_SMART_SCROLLER_POLICY_OFF
3415 elm_smart_scroller_policy_set(wd->scroller,
3421 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3423 ELM_CHECK_WIDTYPE(obj, widtype);
3424 Widget_Data *wd = elm_widget_data_get(obj);
3426 wd->h_bounce = h_bounce;
3427 wd->v_bounce = v_bounce;
3428 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3432 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3434 ELM_CHECK_WIDTYPE(obj, widtype);
3435 Widget_Data *wd = elm_widget_data_get(obj);
3437 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
3441 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3443 ELM_CHECK_WIDTYPE(obj, widtype);
3444 Widget_Data *wd = elm_widget_data_get(obj);
3447 wd->input_panel_layout = layout;
3449 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
3452 EAPI Elm_Input_Panel_Layout
3453 elm_entry_input_panel_layout_get(Evas_Object *obj)
3455 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
3456 Widget_Data *wd = elm_widget_data_get(obj);
3457 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
3459 return wd->input_panel_layout;
3463 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
3465 ELM_CHECK_WIDTYPE(obj, widtype);
3466 Widget_Data *wd = elm_widget_data_get(obj);
3469 wd->autocapital_type = autocapital_type;
3470 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
3473 EAPI Elm_Autocapital_Type
3474 elm_entry_autocapital_type_get(Evas_Object *obj)
3476 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
3477 Widget_Data *wd = elm_widget_data_get(obj);
3478 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
3480 return wd->autocapital_type;
3484 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3486 ELM_CHECK_WIDTYPE(obj, widtype);
3487 Widget_Data *wd = elm_widget_data_get(obj);
3490 wd->input_panel_enable = enabled;
3491 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);