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 > vw) vw = minw;
743 if (minh > vh) 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.merge = EINA_FALSE;
1120 info.insert = EINA_TRUE;
1121 info.change.insert.pos = elm_entry_cursor_pos_get(obj);
1122 info.change.insert.content = eina_stringshare_add(entry);
1125 tmp = evas_textblock_text_markup_to_utf8(elm_entry_textblock_get(obj),
1126 info.change.insert.content);
1127 info.change.insert.plain_length = eina_unicode_utf8_get_len(tmp);
1131 elm_entry_entry_insert(obj, entry);
1132 evas_object_smart_callback_call(obj, SIG_CHANGED_USER, &info);
1134 eina_stringshare_del(info.change.insert.content);
1138 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1140 Widget_Data *wd = elm_widget_data_get(data);
1142 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1143 if (wd->sel_notify_handler)
1145 #ifdef HAVE_ELEMENTARY_X
1146 Elm_Sel_Format formats;
1147 wd->selection_asked = EINA_TRUE;
1148 formats = ELM_SEL_FORMAT_MARKUP;
1150 formats |= ELM_SEL_FORMAT_IMAGE;
1151 elm_cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, formats, data, NULL, NULL);
1157 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1159 Widget_Data *wd = elm_widget_data_get(obj);
1163 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1164 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1165 elm_cnp_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1166 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1167 eina_stringshare_replace(&wd->cut_sel, sel);
1171 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1173 Widget_Data *wd = elm_widget_data_get(data);
1176 wd->selmode = EINA_FALSE;
1177 if (!_elm_config->desktop_entry)
1178 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1179 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1180 if (!_elm_config->desktop_entry)
1181 elm_widget_scroll_hold_pop(data);
1182 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1183 edje_object_part_text_insert(wd->ent, "elm.text", "");
1184 edje_object_part_text_select_none(wd->ent, "elm.text");
1189 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1191 Widget_Data *wd = elm_widget_data_get(data);
1193 wd->selmode = EINA_FALSE;
1194 if (!_elm_config->desktop_entry)
1196 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1197 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1198 elm_widget_scroll_hold_pop(data);
1200 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1201 // edje_object_part_text_select_none(wd->ent, "elm.text");
1205 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1207 Widget_Data *wd = elm_widget_data_get(data);
1209 wd->selmode = EINA_FALSE;
1210 if (!_elm_config->desktop_entry)
1211 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1212 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1213 if (!_elm_config->desktop_entry)
1214 elm_widget_scroll_hold_pop(data);
1215 edje_object_part_text_select_none(wd->ent, "elm.text");
1219 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1221 Elm_Entry_Context_Menu_Item *it = data;
1222 Evas_Object *obj2 = it->obj;
1223 if (it->func) it->func(it->data, obj2, NULL);
1227 _menu_press(Evas_Object *obj)
1229 Widget_Data *wd = elm_widget_data_get(obj);
1232 const Elm_Entry_Context_Menu_Item *it;
1234 if ((wd->api) && (wd->api->obj_longpress))
1236 wd->api->obj_longpress(obj);
1238 else if (wd->context_menu)
1240 const char *context_menu_orientation;
1242 if (wd->hoversel) evas_object_del(wd->hoversel);
1243 else elm_widget_scroll_freeze_push(obj);
1244 wd->hoversel = elm_hoversel_add(obj);
1245 context_menu_orientation = edje_object_data_get
1246 (wd->ent, "context_menu_orientation");
1247 if ((context_menu_orientation) &&
1248 (!strcmp(context_menu_orientation, "horizontal")))
1249 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1250 elm_object_style_set(wd->hoversel, "entry");
1251 elm_widget_sub_object_add(obj, wd->hoversel);
1252 elm_object_text_set(wd->hoversel, "Text");
1253 top = elm_widget_top_get(obj);
1254 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1255 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1256 if (wd->have_selection)
1260 if (wd->have_selection)
1262 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1265 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1268 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1276 if (!_elm_config->desktop_entry)
1279 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1282 if (elm_selection_selection_has_owner())
1285 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1290 EINA_LIST_FOREACH(wd->items, l, it)
1292 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1293 it->icon_type, _item_clicked, it);
1297 _hoversel_position(obj);
1298 evas_object_show(wd->hoversel);
1299 elm_hoversel_hover_begin(wd->hoversel);
1301 if (!_elm_config->desktop_entry)
1303 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1304 edje_object_part_text_select_abort(wd->ent, "elm.text");
1310 _long_press(void *data)
1312 Widget_Data *wd = elm_widget_data_get(data);
1313 if (!wd) return ECORE_CALLBACK_CANCEL;
1315 wd->longpress_timer = NULL;
1316 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1317 return ECORE_CALLBACK_CANCEL;
1321 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1323 Widget_Data *wd = elm_widget_data_get(data);
1324 Evas_Event_Mouse_Down *ev = event_info;
1326 if (wd->disabled) return;
1327 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1328 wd->downx = ev->canvas.x;
1329 wd->downy = ev->canvas.y;
1330 if (ev->button == 1)
1332 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1333 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1338 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1340 Widget_Data *wd = elm_widget_data_get(data);
1341 Evas_Event_Mouse_Up *ev = event_info;
1343 if (wd->disabled) return;
1344 if (ev->button == 1)
1346 if (wd->longpress_timer)
1348 ecore_timer_del(wd->longpress_timer);
1349 wd->longpress_timer = NULL;
1352 else if (ev->button == 3)
1360 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1362 Widget_Data *wd = elm_widget_data_get(data);
1363 Evas_Event_Mouse_Move *ev = event_info;
1365 if (wd->disabled) return;
1368 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1370 if (wd->longpress_timer)
1372 ecore_timer_del(wd->longpress_timer);
1373 wd->longpress_timer = NULL;
1376 else if (wd->longpress_timer)
1380 dx = wd->downx - ev->cur.canvas.x;
1382 dy = wd->downy - ev->cur.canvas.y;
1385 ((_elm_config->finger_size / 2) *
1386 (_elm_config->finger_size / 2)))
1388 ecore_timer_del(wd->longpress_timer);
1389 wd->longpress_timer = NULL;
1393 else if (wd->longpress_timer)
1397 dx = wd->downx - ev->cur.canvas.x;
1399 dy = wd->downy - ev->cur.canvas.y;
1402 ((_elm_config->finger_size / 2) *
1403 (_elm_config->finger_size / 2)))
1405 ecore_timer_del(wd->longpress_timer);
1406 wd->longpress_timer = NULL;
1412 _getbase(Evas_Object *obj)
1414 Widget_Data *wd = elm_widget_data_get(obj);
1415 if (!wd) return "base";
1418 if (wd->password) return "base-password";
1421 if (wd->single_line) return "base-single";
1424 switch (wd->linewrap)
1427 return "base-charwrap";
1430 case ELM_WRAP_MIXED:
1431 return "base-mixedwrap";
1434 return "base-nowrap";
1441 if (wd->password) return "base-password";
1444 if (wd->single_line) return "base-single-noedit";
1447 switch (wd->linewrap)
1450 return "base-noedit-charwrap";
1452 return "base-noedit";
1453 case ELM_WRAP_MIXED:
1454 return "base-noedit-mixedwrap";
1457 return "base-nowrap-noedit";
1465 _entry_changed_common_handling(void *data, const char *event)
1467 Widget_Data *wd = elm_widget_data_get(data);
1470 evas_event_freeze(evas_object_evas_get(data));
1471 wd->changed = EINA_TRUE;
1472 /* Reset the size hints which are no more relevant.
1473 * Keep the height, this is a hack, but doesn't really matter
1474 * cause we'll re-eval in a moment. */
1475 evas_object_size_hint_min_get(data, NULL, &minh);
1476 evas_object_size_hint_min_set(data, -1, minh);
1478 if (wd->text) eina_stringshare_del(wd->text);
1480 if (wd->delay_write)
1482 ecore_timer_del(wd->delay_write);
1483 wd->delay_write = NULL;
1485 evas_event_thaw(evas_object_evas_get(data));
1486 evas_event_thaw_eval(evas_object_evas_get(data));
1487 if ((wd->autosave) && (wd->file))
1488 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1489 /* callback - this could call callbacks that delete the entry... thus...
1490 * any access to wd after this could be invalid */
1491 evas_object_smart_callback_call(data, event, NULL);
1495 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1497 _entry_changed_common_handling(data, SIG_CHANGED);
1501 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1503 Elm_Entry_Change_Info info;
1504 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
1505 edje_object_signal_callback_extra_data_get();
1508 memcpy(&info, edje_info, sizeof(info));
1509 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
1513 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
1518 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1520 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1524 _signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1526 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
1530 _signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1532 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
1536 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1538 Widget_Data *wd = elm_widget_data_get(data);
1542 EINA_LIST_FOREACH(entries, l, entry)
1544 if (entry != data) elm_entry_select_none(entry);
1546 wd->have_selection = EINA_TRUE;
1547 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1548 #ifdef HAVE_ELEMENTARY_X
1549 if (wd->sel_notify_handler)
1551 const char *txt = elm_entry_selection_get(data);
1554 top = elm_widget_top_get(data);
1555 if (txt && top && (elm_win_xwindow_get(top)))
1556 elm_cnp_selection_set(ELM_SEL_TYPE_PRIMARY, data,
1557 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
1563 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1565 Widget_Data *wd = elm_widget_data_get(data);
1567 elm_entry_select_all(data);
1571 _signal_selection_none(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_none(data);
1579 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1581 Widget_Data *wd = elm_widget_data_get(data);
1583 wd->have_selection = EINA_TRUE;
1584 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1585 _store_selection(ELM_SEL_TYPE_PRIMARY, data);
1589 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1591 Widget_Data *wd = elm_widget_data_get(data);
1593 if (!wd->have_selection) return;
1594 wd->have_selection = EINA_FALSE;
1595 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1596 if (wd->sel_notify_handler)
1600 #ifdef HAVE_ELEMENTARY_X
1603 top = elm_widget_top_get(data);
1604 if ((top) && (elm_win_xwindow_get(top)))
1605 elm_cnp_selection_set(ELM_SEL_TYPE_PRIMARY, data,
1606 ELM_SEL_FORMAT_MARKUP, wd->cut_sel,
1607 strlen(wd->cut_sel));
1609 eina_stringshare_del(wd->cut_sel);
1614 #ifdef HAVE_ELEMENTARY_X
1617 top = elm_widget_top_get(data);
1618 if ((top) && (elm_win_xwindow_get(top)))
1619 elm_cnp_selection_clear(ELM_SEL_TYPE_PRIMARY, data);
1626 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1628 Widget_Data *wd = elm_widget_data_get(data);
1629 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
1630 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
1632 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1633 if (wd->sel_notify_handler)
1635 #ifdef HAVE_ELEMENTARY_X
1638 top = elm_widget_top_get(data);
1639 if ((top) && (elm_win_xwindow_get(top)))
1641 wd->selection_asked = EINA_TRUE;
1642 elm_cnp_selection_get(type, ELM_SEL_FORMAT_MARKUP, data,
1650 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1652 _copy(data, NULL, NULL);
1656 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1658 _cut(data, NULL, NULL);
1662 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1664 Widget_Data *wd = elm_widget_data_get(data);
1666 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1667 wd->cur_changed = EINA_TRUE;
1668 _recalc_cursor_geometry(data);
1672 _signal_cursor_changed_manual(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1674 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
1679 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
1681 const Eina_List *geoms, *l;
1682 Evas_Textblock_Rectangle *r;
1683 Evas_Coord px, py, x, y;
1685 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
1689 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1690 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1691 EINA_LIST_FOREACH(geoms, l, r)
1693 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1694 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1706 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1708 Widget_Data *wd = elm_widget_data_get(data);
1709 Elm_Entry_Anchor_Info ei;
1713 p = emission + sizeof("nchor,mouse,down,");
1714 ei.button = strtol(p, &p2, 10);
1716 ei.x = ei.y = ei.w = ei.h = 0;
1718 _signal_anchor_geoms_do_things_with(wd, &ei);
1721 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
1725 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1727 Widget_Data *wd = elm_widget_data_get(data);
1728 Elm_Entry_Anchor_Info ei;
1732 p = emission + sizeof("nchor,mouse,up,");
1733 ei.button = strtol(p, &p2, 10);
1735 ei.x = ei.y = ei.w = ei.h = 0;
1737 _signal_anchor_geoms_do_things_with(wd, &ei);
1740 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
1744 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1746 Widget_Data *wd = elm_widget_data_get(data);
1747 Elm_Entry_Anchor_Info ei;
1751 p = emission + sizeof("nchor,mouse,clicked,");
1752 ei.button = strtol(p, &p2, 10);
1754 ei.x = ei.y = ei.w = ei.h = 0;
1756 _signal_anchor_geoms_do_things_with(wd, &ei);
1759 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1763 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1765 Widget_Data *wd = elm_widget_data_get(data);
1770 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1772 Widget_Data *wd = elm_widget_data_get(data);
1773 Elm_Entry_Anchor_Info ei;
1775 ei.name = emission + sizeof("nchor,mouse,in,");
1777 ei.x = ei.y = ei.w = ei.h = 0;
1779 _signal_anchor_geoms_do_things_with(wd, &ei);
1782 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
1786 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1788 Widget_Data *wd = elm_widget_data_get(data);
1789 Elm_Entry_Anchor_Info ei;
1791 ei.name = emission + sizeof("nchor,mouse,out,");
1793 ei.x = ei.y = ei.w = ei.h = 0;
1795 _signal_anchor_geoms_do_things_with(wd, &ei);
1798 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
1802 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1804 Widget_Data *wd = elm_widget_data_get(data);
1806 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1810 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1812 Widget_Data *wd = elm_widget_data_get(data);
1814 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1818 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1820 Widget_Data *wd = elm_widget_data_get(data);
1822 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1826 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1828 Widget_Data *wd = elm_widget_data_get(data);
1830 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1834 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1836 Widget_Data *wd = elm_widget_data_get(data);
1838 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
1841 #ifdef HAVE_ELEMENTARY_X
1843 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1845 Widget_Data *wd = elm_widget_data_get(data);
1846 Ecore_X_Event_Selection_Notify *ev = event;
1847 if (!wd) return ECORE_CALLBACK_PASS_ON;
1848 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1849 return ECORE_CALLBACK_PASS_ON;
1851 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1852 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1854 Ecore_X_Selection_Data_Text *text_data;
1856 text_data = ev->data;
1857 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1859 if (text_data->text)
1861 char *txt = _elm_util_text_to_mkup(text_data->text);
1865 elm_entry_entry_insert(data, txt);
1870 wd->selection_asked = EINA_FALSE;
1872 else if (ev->selection == ECORE_X_SELECTION_XDND)
1874 Ecore_X_Selection_Data_Text *text_data;
1876 text_data = ev->data;
1877 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1879 if (text_data->text)
1881 char *txt = _elm_util_text_to_mkup(text_data->text);
1885 /* Massive FIXME: this should be at the drag point */
1886 elm_entry_entry_insert(data, txt);
1891 wd->drag_selection_asked = EINA_FALSE;
1893 ecore_x_dnd_send_finished();
1896 return ECORE_CALLBACK_PASS_ON;
1900 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
1902 Widget_Data *wd = elm_widget_data_get(data);
1903 Ecore_X_Event_Selection_Clear *ev = event;
1904 if (!wd) return ECORE_CALLBACK_PASS_ON;
1905 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1906 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1907 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1909 elm_entry_select_none(data);
1911 return ECORE_CALLBACK_PASS_ON;
1915 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1920 wd = elm_widget_data_get(obj);
1921 if (!wd) return EINA_FALSE;
1922 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1924 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1925 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1926 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1927 EDJE_CURSOR_MAIN,drop->x,drop->y);
1928 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1929 elm_entry_entry_insert(obj, drop->data);
1930 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1931 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1937 static Evas_Object *
1938 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1940 Widget_Data *wd = elm_widget_data_get(data);
1943 Elm_Entry_Item_Provider *ip;
1945 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1947 o = ip->func(ip->data, data, item);
1950 if (!strncmp(item, "file://", 7))
1952 const char *fname = item + 7;
1954 o = evas_object_image_filled_add(evas_object_evas_get(data));
1955 evas_object_image_file_set(o, fname, NULL);
1956 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1958 evas_object_show(o);
1963 o = edje_object_add(evas_object_evas_get(data));
1964 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1968 o = edje_object_add(evas_object_evas_get(data));
1969 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1970 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1975 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
1977 Widget_Data *wd = elm_widget_data_get(data);
1979 Elm_Entry_Text_Filter *tf;
1981 if (type == EDJE_TEXT_FILTER_FORMAT)
1984 EINA_LIST_FOREACH(wd->text_filters, l, tf)
1986 tf->func(tf->data, data, text);
1992 /* This function is used to insert text by chunks in jobs */
1994 _text_append_idler(void *data)
1998 Evas_Object *obj = (Evas_Object *) data;
1999 Widget_Data *wd = elm_widget_data_get(obj);
2000 evas_event_freeze(evas_object_evas_get(obj));
2001 if (wd->text) eina_stringshare_del(wd->text);
2003 wd->changed = EINA_TRUE;
2005 start = wd->append_text_position;
2006 if (start + _CHUNK_SIZE < wd->append_text_len)
2009 int tag_start, esc_start;
2011 tag_start = esc_start = -1;
2012 /* Find proper markup cut place */
2013 while (pos - start < _CHUNK_SIZE)
2017 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2018 if (esc_start == -1)
2021 tag_start = prev_pos;
2022 else if (tmp == '>')
2025 if (tag_start == -1)
2028 esc_start = prev_pos;
2029 else if (tmp == ';')
2036 wd->append_text_position = tag_start;
2038 else if (esc_start >= 0)
2040 wd->append_text_position = esc_start;
2044 wd->append_text_position = pos;
2049 wd->append_text_position = wd->append_text_len;
2052 backup = wd->append_text_left[wd->append_text_position];
2053 wd->append_text_left[wd->append_text_position] = '\0';
2055 edje_object_part_text_append(wd->ent, "elm.text",
2056 wd->append_text_left + start);
2058 wd->append_text_left[wd->append_text_position] = backup;
2060 evas_event_thaw(evas_object_evas_get(obj));
2061 evas_event_thaw_eval(evas_object_evas_get(obj));
2063 /* If there's still more to go, renew the idler, else, cleanup */
2064 if (wd->append_text_position < wd->append_text_len)
2066 return ECORE_CALLBACK_RENEW;
2070 free(wd->append_text_left);
2071 wd->append_text_left = NULL;
2072 wd->append_text_idler = NULL;
2073 return ECORE_CALLBACK_CANCEL;
2078 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2080 int i = 0, current_len = 0;
2084 if (unit >= LENGTH_UNIT_LAST) return;
2086 current_len = strlen(*text);
2089 int idx = 0, unit_size = 0;
2090 char *markup, *utfstr;
2091 if (*new_text == '<')
2093 while (*(new_text + idx) != '>')
2096 if (!*(new_text + idx)) break;
2099 else if (*new_text == '&')
2101 while (*(new_text + idx) != ';')
2104 if (!*(new_text + idx)) break;
2107 idx = evas_string_char_next_get(new_text, idx, NULL);
2108 markup = malloc(idx + 1);
2111 strncpy(markup, new_text, idx);
2113 utfstr = elm_entry_markup_to_utf8(markup);
2116 if (unit == LENGTH_UNIT_BYTE)
2117 unit_size = strlen(utfstr);
2118 else if (unit == LENGTH_UNIT_CHAR)
2119 unit_size = evas_string_char_len_get(utfstr);
2126 if (can_add < unit_size)
2130 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2136 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2138 (*text)[current_len] = 0;
2143 can_add -= unit_size;
2147 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2151 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2154 ELM_CHECK_WIDTYPE(obj, widtype);
2155 Widget_Data *wd = elm_widget_data_get(obj);
2157 evas_event_freeze(evas_object_evas_get(obj));
2158 if (!entry) entry = "";
2159 if (item && strcmp(item, "default"))
2161 edje_object_part_text_set(wd->ent, item, entry);
2165 if (wd->text) eina_stringshare_del(wd->text);
2167 wd->changed = EINA_TRUE;
2169 /* Clear currently pending job if there is one */
2170 if (wd->append_text_idler)
2172 ecore_idler_del(wd->append_text_idler);
2173 free(wd->append_text_left);
2174 wd->append_text_left = NULL;
2175 wd->append_text_idler = NULL;
2178 len = strlen(entry);
2179 /* Split to ~_CHUNK_SIZE chunks */
2180 if (len > _CHUNK_SIZE)
2182 wd->append_text_left = (char *) malloc(len + 1);
2185 /* If we decided to use the idler */
2186 if (wd->append_text_left)
2188 /* Need to clear the entry first */
2189 edje_object_part_text_set(wd->ent, "elm.text", "");
2190 memcpy(wd->append_text_left, entry, len + 1);
2191 wd->append_text_position = 0;
2192 wd->append_text_len = len;
2193 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2197 edje_object_part_text_set(wd->ent, "elm.text", entry);
2199 evas_event_thaw(evas_object_evas_get(obj));
2200 evas_event_thaw_eval(evas_object_evas_get(obj));
2204 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2206 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2207 Widget_Data *wd = elm_widget_data_get(obj);
2208 if (item && strcmp(item, "default")) return NULL;
2210 if (!wd) return NULL;
2211 if (wd->text) return wd->text;
2212 text = edje_object_part_text_get(wd->ent, "elm.text");
2215 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2219 if (wd->append_text_len > 0)
2223 tlen = strlen(text);
2224 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2227 ERR("Failed to allocate memory for entry's text %p", obj);
2230 memcpy(tmpbuf, text, tlen);
2231 memcpy(tmpbuf + tlen, wd->append_text_left, wd->append_text_len);
2232 tmpbuf[tlen + wd->append_text_len] = '\0';
2233 eina_stringshare_replace(&wd->text, tmpbuf);
2238 eina_stringshare_replace(&wd->text, text);
2244 elm_entry_add(Evas_Object *parent)
2246 Evas_Object *obj, *top;
2250 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2252 ELM_SET_WIDTYPE(widtype, "entry");
2253 elm_widget_type_set(obj, "entry");
2254 elm_widget_sub_object_add(parent, obj);
2255 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2256 elm_widget_data_set(obj, wd);
2257 elm_widget_del_hook_set(obj, _del_hook);
2258 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2259 elm_widget_theme_hook_set(obj, _theme_hook);
2260 elm_widget_disable_hook_set(obj, _disable_hook);
2261 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2262 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2263 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2264 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2265 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2266 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2267 elm_widget_can_focus_set(obj, EINA_TRUE);
2268 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2269 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2270 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2271 elm_widget_content_set_hook_set(obj, _content_set_hook);
2272 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2273 elm_widget_content_get_hook_set(obj, _content_get_hook);
2274 elm_widget_translate_hook_set(obj, _translate_hook);
2276 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2278 wd->linewrap = ELM_WRAP_WORD;
2279 wd->editable = EINA_TRUE;
2280 wd->disabled = EINA_FALSE;
2281 wd->context_menu = EINA_TRUE;
2282 wd->autosave = EINA_TRUE;
2283 wd->textonly = EINA_FALSE;
2284 wd->scroll = EINA_FALSE;
2286 wd->ent = edje_object_add(e);
2287 edje_object_item_provider_set(wd->ent, _get_item, obj);
2288 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2289 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2290 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2292 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2294 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2296 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2298 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2299 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2300 _signal_entry_changed, obj);
2301 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
2302 _signal_entry_changed_user, obj);
2303 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2304 _signal_preedit_changed, obj);
2305 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2306 _signal_selection_start, obj);
2307 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2308 _signal_selection_changed, obj);
2309 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2310 _signal_selection_all, obj);
2311 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2312 _signal_selection_none, obj);
2313 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2314 _signal_selection_cleared, obj);
2315 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2316 _signal_entry_paste_request, obj);
2317 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2318 _signal_entry_copy_notify, obj);
2319 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2320 _signal_entry_cut_notify, obj);
2321 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2322 _signal_cursor_changed, obj);
2323 edje_object_signal_callback_add(wd->ent, "cursor,changed,manual", "elm.text",
2324 _signal_cursor_changed_manual, obj);
2325 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2326 _signal_anchor_down, obj);
2327 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2328 _signal_anchor_up, obj);
2329 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2330 _signal_anchor_clicked, obj);
2331 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2332 _signal_anchor_move, obj);
2333 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2334 _signal_anchor_in, obj);
2335 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2336 _signal_anchor_out, obj);
2337 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2338 _signal_key_enter, obj);
2339 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2340 _signal_mouse_down, obj);
2341 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2342 _signal_mouse_clicked, obj);
2343 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2344 _signal_mouse_double, obj);
2345 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
2346 _signal_mouse_triple, obj);
2347 edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
2348 _signal_undo_request, obj);
2349 edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
2350 _signal_redo_request, obj);
2351 edje_object_part_text_set(wd->ent, "elm.text", "");
2352 if (_elm_config->desktop_entry)
2353 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2354 elm_widget_resize_object_set(obj, wd->ent);
2357 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
2359 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2360 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
2362 #ifdef HAVE_ELEMENTARY_X
2363 top = elm_widget_top_get(obj);
2364 if ((top) && (elm_win_xwindow_get(top)))
2366 wd->sel_notify_handler =
2367 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2368 _event_selection_notify, obj);
2369 wd->sel_clear_handler =
2370 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2371 _event_selection_clear, obj);
2374 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2375 _drag_drop_cb, NULL);
2378 entries = eina_list_prepend(entries, obj);
2380 // module - find module for entry
2381 wd->api = _module(obj);
2382 // if found - hook in
2383 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2385 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2386 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2387 // TODO: and save some bytes, making descriptions per-class and not instance!
2388 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2393 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2395 ELM_CHECK_WIDTYPE(obj, widtype);
2396 Widget_Data *wd = elm_widget_data_get(obj);
2398 if (wd->single_line == single_line) return;
2399 wd->single_line = single_line;
2400 wd->linewrap = ELM_WRAP_NONE;
2401 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2405 if (wd->single_line)
2406 elm_smart_scroller_policy_set(wd->scroller,
2407 ELM_SMART_SCROLLER_POLICY_OFF,
2408 ELM_SMART_SCROLLER_POLICY_OFF);
2411 const Elm_Scroller_Policy map[3] =
2413 ELM_SMART_SCROLLER_POLICY_AUTO,
2414 ELM_SMART_SCROLLER_POLICY_ON,
2415 ELM_SMART_SCROLLER_POLICY_OFF
2417 elm_smart_scroller_policy_set(wd->scroller,
2426 elm_entry_single_line_get(const Evas_Object *obj)
2428 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2429 Widget_Data *wd = elm_widget_data_get(obj);
2430 if (!wd) return EINA_FALSE;
2431 return wd->single_line;
2435 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2437 ELM_CHECK_WIDTYPE(obj, widtype);
2438 Widget_Data *wd = elm_widget_data_get(obj);
2440 if (wd->password == password) return;
2441 wd->password = password;
2444 wd->single_line = EINA_TRUE;
2445 wd->linewrap = ELM_WRAP_NONE;
2446 #ifdef HAVE_ELEMENTARY_X
2447 elm_drop_target_del(obj);
2449 edje_object_signal_callback_del_full(wd->ent, "selection,start", "elm.text",
2450 _signal_selection_start, obj);
2451 edje_object_signal_callback_del_full(wd->ent, "selection,changed", "elm.text",
2452 _signal_selection_changed, obj);
2453 edje_object_signal_callback_del_full(wd->ent, "entry,selection,all,request", "elm.text",
2454 _signal_selection_all, obj);
2455 edje_object_signal_callback_del_full(wd->ent, "entry,selection,none,request", "elm.text",
2456 _signal_selection_none, obj);
2457 edje_object_signal_callback_del_full(wd->ent, "selection,cleared", "elm.text",
2458 _signal_selection_cleared, obj);
2459 edje_object_signal_callback_del_full(wd->ent, "entry,paste,request,*", "elm.text",
2460 _signal_entry_paste_request, obj);
2461 edje_object_signal_callback_del_full(wd->ent, "entry,copy,notify", "elm.text",
2462 _signal_entry_copy_notify, obj);
2463 edje_object_signal_callback_del_full(wd->ent, "entry,cut,notify", "elm.text",
2464 _signal_entry_cut_notify, obj);
2468 #ifdef HAVE_ELEMENTARY_X
2469 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2471 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2472 _signal_selection_start, obj);
2473 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2474 _signal_selection_changed, obj);
2475 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2476 _signal_selection_all, obj);
2477 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2478 _signal_selection_none, obj);
2479 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2480 _signal_selection_cleared, obj);
2481 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2482 _signal_entry_paste_request, obj);
2483 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2484 _signal_entry_copy_notify, obj);
2485 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2486 _signal_entry_cut_notify, obj);
2492 elm_entry_password_get(const Evas_Object *obj)
2494 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2495 Widget_Data *wd = elm_widget_data_get(obj);
2496 if (!wd) return EINA_FALSE;
2497 return wd->password;
2501 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2503 _elm_entry_text_set(obj, NULL, entry);
2507 elm_entry_entry_get(const Evas_Object *obj)
2509 return _elm_entry_text_get(obj, NULL);
2513 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2516 ELM_CHECK_WIDTYPE(obj, widtype);
2517 Widget_Data *wd = elm_widget_data_get(obj);
2519 if (!entry) entry = "";
2520 wd->changed = EINA_TRUE;
2522 len = strlen(entry);
2523 if (wd->append_text_left)
2526 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2532 wd->append_text_left = tmpbuf;
2533 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2534 wd->append_text_len += len;
2538 /* FIXME: Add chunked appending here (like in entry_set) */
2539 edje_object_part_text_append(wd->ent, "elm.text", entry);
2544 elm_entry_is_empty(const Evas_Object *obj)
2546 /* FIXME: until there's support for that in textblock, we just check
2547 * to see if the there is text or not. */
2548 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2549 Widget_Data *wd = elm_widget_data_get(obj);
2550 const Evas_Object *tb;
2551 Evas_Textblock_Cursor *cur;
2553 if (!wd) return EINA_TRUE;
2554 /* It's a hack until we get the support suggested above.
2555 * We just create a cursor, point it to the begining, and then
2556 * try to advance it, if it can advance, the tb is not empty,
2557 * otherwise it is. */
2558 tb = edje_object_part_object_get(wd->ent, "elm.text");
2559 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2560 actually, ok for the time being, thsese hackish stuff will be removed
2561 once evas 1.0 is out*/
2562 evas_textblock_cursor_pos_set(cur, 0);
2563 ret = evas_textblock_cursor_char_next(cur);
2564 evas_textblock_cursor_free(cur);
2570 elm_entry_textblock_get(Evas_Object *obj)
2572 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2573 Widget_Data *wd = elm_widget_data_get(obj);
2574 if (!wd) return NULL;
2576 return (Evas_Object *) edje_object_part_object_get(wd->ent, "elm.text");
2580 elm_entry_calc_force(Evas_Object *obj)
2582 ELM_CHECK_WIDTYPE(obj, widtype);
2583 Widget_Data *wd = elm_widget_data_get(obj);
2586 edje_object_calc_force(wd->ent);
2587 wd->changed = EINA_TRUE;
2593 elm_entry_selection_get(const Evas_Object *obj)
2595 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2596 Widget_Data *wd = elm_widget_data_get(obj);
2597 if ((!wd) || (wd->password)) return NULL;
2598 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2602 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2604 ELM_CHECK_WIDTYPE(obj, widtype);
2605 Widget_Data *wd = elm_widget_data_get(obj);
2607 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2608 wd->changed = EINA_TRUE;
2613 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2615 ELM_CHECK_WIDTYPE(obj, widtype);
2616 Widget_Data *wd = elm_widget_data_get(obj);
2618 if (wd->linewrap == wrap) return;
2620 wd->linewrap = wrap;
2625 elm_entry_line_wrap_get(const Evas_Object *obj)
2627 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2628 Widget_Data *wd = elm_widget_data_get(obj);
2629 if (!wd) return EINA_FALSE;
2630 return wd->linewrap;
2634 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2636 ELM_CHECK_WIDTYPE(obj, widtype);
2637 Widget_Data *wd = elm_widget_data_get(obj);
2639 if (wd->editable == editable) return;
2640 wd->editable = editable;
2643 #ifdef HAVE_ELEMENTARY_X
2645 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2647 elm_drop_target_del(obj);
2652 elm_entry_editable_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->editable;
2661 elm_entry_select_none(Evas_Object *obj)
2663 ELM_CHECK_WIDTYPE(obj, widtype);
2664 Widget_Data *wd = elm_widget_data_get(obj);
2665 if ((!wd) || (wd->password)) return;
2668 wd->selmode = EINA_FALSE;
2669 if (!_elm_config->desktop_entry)
2670 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2671 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2673 wd->have_selection = EINA_FALSE;
2674 edje_object_part_text_select_none(wd->ent, "elm.text");
2678 elm_entry_select_all(Evas_Object *obj)
2680 ELM_CHECK_WIDTYPE(obj, widtype);
2681 Widget_Data *wd = elm_widget_data_get(obj);
2682 if ((!wd) || (wd->password)) return;
2685 wd->selmode = EINA_FALSE;
2686 if (!_elm_config->desktop_entry)
2687 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2688 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2690 wd->have_selection = EINA_TRUE;
2691 edje_object_part_text_select_all(wd->ent, "elm.text");
2695 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2697 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2698 Widget_Data *wd = elm_widget_data_get(obj);
2699 if (!wd) return EINA_FALSE;
2700 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2705 elm_entry_cursor_next(Evas_Object *obj)
2707 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2708 Widget_Data *wd = elm_widget_data_get(obj);
2709 if (!wd) return EINA_FALSE;
2710 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2714 elm_entry_cursor_prev(Evas_Object *obj)
2716 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2717 Widget_Data *wd = elm_widget_data_get(obj);
2718 if (!wd) return EINA_FALSE;
2719 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2723 elm_entry_cursor_up(Evas_Object *obj)
2725 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2726 Widget_Data *wd = elm_widget_data_get(obj);
2727 if (!wd) return EINA_FALSE;
2728 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2732 elm_entry_cursor_down(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_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2741 elm_entry_cursor_begin_set(Evas_Object *obj)
2743 ELM_CHECK_WIDTYPE(obj, widtype);
2744 Widget_Data *wd = elm_widget_data_get(obj);
2746 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2750 elm_entry_cursor_end_set(Evas_Object *obj)
2752 ELM_CHECK_WIDTYPE(obj, widtype);
2753 Widget_Data *wd = elm_widget_data_get(obj);
2757 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2760 elm_widget_show_region_get(obj, &x, &y, &w, &h);
2761 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
2766 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2768 ELM_CHECK_WIDTYPE(obj, widtype);
2769 Widget_Data *wd = elm_widget_data_get(obj);
2771 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2775 elm_entry_cursor_line_end_set(Evas_Object *obj)
2777 ELM_CHECK_WIDTYPE(obj, widtype);
2778 Widget_Data *wd = elm_widget_data_get(obj);
2780 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2784 elm_entry_cursor_selection_begin(Evas_Object *obj)
2786 ELM_CHECK_WIDTYPE(obj, widtype);
2787 Widget_Data *wd = elm_widget_data_get(obj);
2789 edje_object_part_text_select_begin(wd->ent, "elm.text");
2793 elm_entry_cursor_selection_end(Evas_Object *obj)
2795 ELM_CHECK_WIDTYPE(obj, widtype);
2796 Widget_Data *wd = elm_widget_data_get(obj);
2798 edje_object_part_text_select_extend(wd->ent, "elm.text");
2802 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2804 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2805 Widget_Data *wd = elm_widget_data_get(obj);
2806 if (!wd) return EINA_FALSE;
2807 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2811 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2813 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2814 Widget_Data *wd = elm_widget_data_get(obj);
2815 if (!wd) return EINA_FALSE;
2816 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2820 elm_entry_cursor_content_get(const Evas_Object *obj)
2822 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2823 Widget_Data *wd = elm_widget_data_get(obj);
2824 if (!wd) return NULL;
2825 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2829 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2831 ELM_CHECK_WIDTYPE(obj, widtype);
2832 Widget_Data *wd = elm_widget_data_get(obj);
2834 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2835 edje_object_message_signal_process(wd->ent);
2839 elm_entry_cursor_pos_get(const Evas_Object *obj)
2841 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2842 Widget_Data *wd = elm_widget_data_get(obj);
2844 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2848 elm_entry_selection_cut(Evas_Object *obj)
2850 ELM_CHECK_WIDTYPE(obj, widtype);
2851 Widget_Data *wd = elm_widget_data_get(obj);
2852 if ((!wd) || (wd->password)) return;
2853 _cut(obj, NULL, NULL);
2857 elm_entry_selection_copy(Evas_Object *obj)
2859 ELM_CHECK_WIDTYPE(obj, widtype);
2860 Widget_Data *wd = elm_widget_data_get(obj);
2861 if ((!wd) || (wd->password)) return;
2862 _copy(obj, NULL, NULL);
2866 elm_entry_selection_paste(Evas_Object *obj)
2868 ELM_CHECK_WIDTYPE(obj, widtype);
2869 Widget_Data *wd = elm_widget_data_get(obj);
2870 if ((!wd) || (wd->password)) return;
2871 _paste(obj, NULL, NULL);
2875 elm_entry_context_menu_clear(Evas_Object *obj)
2877 ELM_CHECK_WIDTYPE(obj, widtype);
2878 Widget_Data *wd = elm_widget_data_get(obj);
2879 Elm_Entry_Context_Menu_Item *it;
2881 EINA_LIST_FREE(wd->items, it)
2883 eina_stringshare_del(it->label);
2884 eina_stringshare_del(it->icon_file);
2885 eina_stringshare_del(it->icon_group);
2891 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)
2893 ELM_CHECK_WIDTYPE(obj, widtype);
2894 Widget_Data *wd = elm_widget_data_get(obj);
2895 Elm_Entry_Context_Menu_Item *it;
2897 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2899 wd->items = eina_list_append(wd->items, it);
2901 it->label = eina_stringshare_add(label);
2902 it->icon_file = eina_stringshare_add(icon_file);
2903 it->icon_type = icon_type;
2905 it->data = (void *)data;
2909 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2911 ELM_CHECK_WIDTYPE(obj, widtype);
2912 Widget_Data *wd = elm_widget_data_get(obj);
2914 if (wd->context_menu == !disabled) return;
2915 wd->context_menu = !disabled;
2919 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2921 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2922 Widget_Data *wd = elm_widget_data_get(obj);
2923 if (!wd) return EINA_FALSE;
2924 return !wd->context_menu;
2928 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2930 ELM_CHECK_WIDTYPE(obj, widtype);
2931 Widget_Data *wd = elm_widget_data_get(obj);
2933 EINA_SAFETY_ON_NULL_RETURN(func);
2934 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2938 wd->item_providers = eina_list_append(wd->item_providers, ip);
2942 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2944 ELM_CHECK_WIDTYPE(obj, widtype);
2945 Widget_Data *wd = elm_widget_data_get(obj);
2947 EINA_SAFETY_ON_NULL_RETURN(func);
2948 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2952 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2956 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2958 ELM_CHECK_WIDTYPE(obj, widtype);
2959 Widget_Data *wd = elm_widget_data_get(obj);
2961 Elm_Entry_Item_Provider *ip;
2963 EINA_SAFETY_ON_NULL_RETURN(func);
2964 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2966 if ((ip->func == func) && ((!data) || (ip->data == data)))
2968 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2976 elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2979 Elm_Entry_Text_Filter *tf;
2980 ELM_CHECK_WIDTYPE(obj, widtype);
2982 wd = elm_widget_data_get(obj);
2984 EINA_SAFETY_ON_NULL_RETURN(func);
2986 tf = _filter_new(func, data);
2989 wd->text_filters = eina_list_append(wd->text_filters, tf);
2993 elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2996 Elm_Entry_Text_Filter *tf;
2997 ELM_CHECK_WIDTYPE(obj, widtype);
2999 wd = elm_widget_data_get(obj);
3001 EINA_SAFETY_ON_NULL_RETURN(func);
3003 tf = _filter_new(func, data);
3006 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3010 elm_entry_text_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3014 Elm_Entry_Text_Filter *tf;
3015 ELM_CHECK_WIDTYPE(obj, widtype);
3017 wd = elm_widget_data_get(obj);
3019 EINA_SAFETY_ON_NULL_RETURN(func);
3021 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3023 if ((tf->func == func) && ((!data) || (tf->data == data)))
3025 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3033 elm_entry_markup_to_utf8(const char *s)
3035 char *ss = _elm_util_mkup_to_text(s);
3036 if (!ss) ss = strdup("");
3041 elm_entry_utf8_to_markup(const char *s)
3043 char *ss = _elm_util_text_to_mkup(s);
3044 if (!ss) ss = strdup("");
3049 _text_get(const Evas_Object *obj)
3051 return elm_object_text_get(obj);
3055 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3057 Elm_Entry_Filter_Limit_Size *lim = data;
3058 char *current, *utfstr;
3060 const char *(*text_get)(const Evas_Object *);
3062 EINA_SAFETY_ON_NULL_RETURN(data);
3063 EINA_SAFETY_ON_NULL_RETURN(entry);
3064 EINA_SAFETY_ON_NULL_RETURN(text);
3066 /* hack. I don't want to copy the entire function to work with
3068 text_get = _text_get;
3070 current = elm_entry_markup_to_utf8(text_get(entry));
3071 utfstr = elm_entry_markup_to_utf8(*text);
3073 if (lim->max_char_count > 0)
3075 len = evas_string_char_len_get(current);
3076 if (len >= lim->max_char_count)
3078 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3085 newlen = evas_string_char_len_get(utfstr);
3086 if ((len + newlen) > lim->max_char_count)
3087 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3089 else if (lim->max_byte_count > 0)
3091 len = strlen(current);
3092 if (len >= lim->max_byte_count)
3094 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3101 newlen = strlen(utfstr);
3102 if ((len + newlen) > lim->max_byte_count)
3103 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3110 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3112 Elm_Entry_Filter_Accept_Set *as = data;
3116 int read_idx, last_read_idx = 0, read_char;
3118 EINA_SAFETY_ON_NULL_RETURN(data);
3119 EINA_SAFETY_ON_NULL_RETURN(text);
3121 if ((!as->accepted) && (!as->rejected))
3127 goes_in = EINA_TRUE;
3132 goes_in = EINA_FALSE;
3136 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3139 int cmp_idx, cmp_char;
3140 Eina_Bool in_set = EINA_FALSE;
3142 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3145 if (read_char == cmp_char)
3150 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3152 if (in_set == goes_in)
3154 int size = read_idx - last_read_idx;
3155 const char *src = (*text) + last_read_idx;
3157 memcpy(insert, *text + last_read_idx, size);
3160 last_read_idx = read_idx;
3161 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3167 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3169 ELM_CHECK_WIDTYPE(obj, widtype);
3170 Widget_Data *wd = elm_widget_data_get(obj);
3172 if (wd->delay_write)
3174 ecore_timer_del(wd->delay_write);
3175 wd->delay_write = NULL;
3177 if (wd->autosave) _save(obj);
3178 eina_stringshare_replace(&wd->file, file);
3179 wd->format = format;
3184 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3186 ELM_CHECK_WIDTYPE(obj, widtype);
3187 Widget_Data *wd = elm_widget_data_get(obj);
3189 if (file) *file = wd->file;
3190 if (format) *format = wd->format;
3194 elm_entry_file_save(Evas_Object *obj)
3196 ELM_CHECK_WIDTYPE(obj, widtype);
3197 Widget_Data *wd = elm_widget_data_get(obj);
3199 if (wd->delay_write)
3201 ecore_timer_del(wd->delay_write);
3202 wd->delay_write = NULL;
3205 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3209 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3211 ELM_CHECK_WIDTYPE(obj, widtype);
3212 Widget_Data *wd = elm_widget_data_get(obj);
3214 wd->autosave = !!autosave;
3218 elm_entry_autosave_get(const Evas_Object *obj)
3220 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3221 Widget_Data *wd = elm_widget_data_get(obj);
3222 if (!wd) return EINA_FALSE;
3223 return wd->autosave;
3227 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3229 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3230 ELM_CHECK_WIDTYPE(obj, widtype);
3231 Widget_Data *wd = elm_widget_data_get(obj);
3233 textonly = !!textonly;
3234 if (wd->textonly == textonly) return;
3235 wd->textonly = !!textonly;
3236 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3237 #ifdef HAVE_ELEMENTARY_X
3238 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3243 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3245 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3246 Widget_Data *wd = elm_widget_data_get(obj);
3247 if (!wd) return EINA_FALSE;
3248 return wd->textonly;
3252 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3254 ELM_CHECK_WIDTYPE(obj, widtype);
3255 Widget_Data *wd = elm_widget_data_get(obj);
3256 const Elm_Scroller_Policy map[3] =
3258 ELM_SMART_SCROLLER_POLICY_AUTO,
3259 ELM_SMART_SCROLLER_POLICY_ON,
3260 ELM_SMART_SCROLLER_POLICY_OFF
3264 if (wd->scroll == scroll) return;
3265 wd->scroll = scroll;
3270 wd->scroller = elm_smart_scroller_add(evas_object_evas_get(obj));
3271 elm_widget_resize_object_set(obj, wd->scroller);
3272 elm_smart_scroller_widget_set(wd->scroller, obj);
3273 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
3274 elm_widget_style_get(obj));
3275 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3276 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
3277 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
3278 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(wd->scroller),
3281 elm_smart_scroller_bounce_allow_set(wd->scroller, wd->h_bounce, wd->v_bounce);
3282 if (wd->single_line)
3283 elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
3284 ELM_SMART_SCROLLER_POLICY_OFF);
3286 elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]);
3287 elm_widget_sub_object_add(obj, wd->ent);
3288 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3289 evas_object_show(wd->scroller);
3290 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3296 elm_smart_scroller_child_set(wd->scroller, NULL);
3297 evas_object_smart_member_add(wd->scroller, obj);
3298 elm_widget_sub_object_add(obj, wd->scroller);
3299 evas_object_hide(wd->scroller);
3301 elm_widget_sub_object_del(obj, wd->ent);
3302 elm_widget_resize_object_set(obj, wd->ent);
3303 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3310 elm_entry_scrollable_get(const Evas_Object *obj)
3312 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3313 Widget_Data *wd = elm_widget_data_get(obj);
3314 if (!wd) return EINA_FALSE;
3319 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3321 ELM_CHECK_WIDTYPE(obj, widtype);
3322 EINA_SAFETY_ON_NULL_RETURN(icon);
3323 _content_set_hook(obj, NULL, icon);
3327 elm_entry_icon_get(const Evas_Object *obj)
3329 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3330 return _content_get_hook(obj, NULL);
3334 elm_entry_icon_unset(Evas_Object *obj)
3336 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3337 return _content_unset_hook(obj, NULL);
3341 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3343 ELM_CHECK_WIDTYPE(obj, widtype);
3344 Widget_Data *wd = elm_widget_data_get(obj);
3348 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3352 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3354 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3356 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3361 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3363 ELM_CHECK_WIDTYPE(obj, widtype);
3364 EINA_SAFETY_ON_NULL_RETURN(end);
3365 _content_set_hook(obj, "end", end);
3369 elm_entry_end_get(const Evas_Object *obj)
3371 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3372 return _content_get_hook(obj, "end");
3376 elm_entry_end_unset(Evas_Object *obj)
3378 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3379 return _content_unset_hook(obj, "end");
3383 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3385 ELM_CHECK_WIDTYPE(obj, widtype);
3386 Widget_Data *wd = elm_widget_data_get(obj);
3390 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3394 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3396 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3398 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3403 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3405 ELM_CHECK_WIDTYPE(obj, widtype);
3406 Widget_Data *wd = elm_widget_data_get(obj);
3407 const Elm_Scroller_Policy map[3] =
3409 ELM_SMART_SCROLLER_POLICY_AUTO,
3410 ELM_SMART_SCROLLER_POLICY_ON,
3411 ELM_SMART_SCROLLER_POLICY_OFF
3416 elm_smart_scroller_policy_set(wd->scroller,
3422 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3424 ELM_CHECK_WIDTYPE(obj, widtype);
3425 Widget_Data *wd = elm_widget_data_get(obj);
3427 wd->h_bounce = h_bounce;
3428 wd->v_bounce = v_bounce;
3429 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3433 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3435 ELM_CHECK_WIDTYPE(obj, widtype);
3436 Widget_Data *wd = elm_widget_data_get(obj);
3438 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
3442 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3444 ELM_CHECK_WIDTYPE(obj, widtype);
3445 Widget_Data *wd = elm_widget_data_get(obj);
3448 wd->input_panel_layout = layout;
3450 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
3453 EAPI Elm_Input_Panel_Layout
3454 elm_entry_input_panel_layout_get(Evas_Object *obj)
3456 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
3457 Widget_Data *wd = elm_widget_data_get(obj);
3458 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
3460 return wd->input_panel_layout;
3464 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
3466 ELM_CHECK_WIDTYPE(obj, widtype);
3467 Widget_Data *wd = elm_widget_data_get(obj);
3470 wd->autocapital_type = autocapital_type;
3471 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
3474 EAPI Elm_Autocapital_Type
3475 elm_entry_autocapital_type_get(Evas_Object *obj)
3477 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
3478 Widget_Data *wd = elm_widget_data_get(obj);
3479 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
3481 return wd->autocapital_type;
3485 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3487 ELM_CHECK_WIDTYPE(obj, widtype);
3488 Widget_Data *wd = elm_widget_data_get(obj);
3491 wd->input_panel_enable = enabled;
3492 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);