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, *end, *icon;
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 Eina_Bool changed : 1;
51 Eina_Bool single_line : 1;
52 Eina_Bool password : 1;
53 Eina_Bool editable : 1;
54 Eina_Bool selection_asked : 1;
55 Eina_Bool have_selection : 1;
56 Eina_Bool selmode : 1;
57 Eina_Bool deferred_cur : 1;
58 Eina_Bool cur_changed : 1;
59 Eina_Bool disabled : 1;
60 Eina_Bool context_menu : 1;
61 Eina_Bool drag_selection_asked : 1;
62 Eina_Bool can_write : 1;
63 Eina_Bool autosave : 1;
64 Eina_Bool textonly : 1;
65 Eina_Bool usedown : 1;
69 struct _Elm_Entry_Context_Menu_Item
73 const char *icon_file;
74 const char *icon_group;
75 Elm_Icon_Type icon_type;
80 struct _Elm_Entry_Item_Provider
82 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
86 struct _Elm_Entry_Text_Filter
88 Elm_Entry_Filter_Cb func;
92 typedef enum _Length_Unit
99 static const char *widtype = NULL;
101 #ifdef HAVE_ELEMENTARY_X
102 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
104 static void _del_hook(Evas_Object *obj);
105 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
106 static void _theme_hook(Evas_Object *obj);
107 static void _disable_hook(Evas_Object *obj);
108 static void _sizing_eval(Evas_Object *obj);
109 static void _on_focus_hook(void *data, Evas_Object *obj);
110 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
111 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
112 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
113 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
114 static const char *_getbase(Evas_Object *obj);
115 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
116 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
117 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
118 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
119 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
120 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
121 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
122 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
123 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
125 static const char SIG_CHANGED[] = "changed";
126 static const char SIG_CHANGED_USER[] = "changed,user";
127 static const char SIG_ACTIVATED[] = "activated";
128 static const char SIG_PRESS[] = "press";
129 static const char SIG_LONGPRESSED[] = "longpressed";
130 static const char SIG_CLICKED[] = "clicked";
131 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
132 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
133 static const char SIG_FOCUSED[] = "focused";
134 static const char SIG_UNFOCUSED[] = "unfocused";
135 static const char SIG_SELECTION_PASTE[] = "selection,paste";
136 static const char SIG_SELECTION_COPY[] = "selection,copy";
137 static const char SIG_SELECTION_CUT[] = "selection,cut";
138 static const char SIG_SELECTION_START[] = "selection,start";
139 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
140 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
141 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
142 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
143 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
144 static const char SIG_ANCHOR_UP[] = "anchor,up";
145 static const char SIG_ANCHOR_IN[] = "anchor,in";
146 static const char SIG_ANCHOR_OUT[] = "anchor,out";
147 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
148 static const Evas_Smart_Cb_Description _signals[] = {
152 {SIG_LONGPRESSED, ""},
154 {SIG_CLICKED_DOUBLE, ""},
155 {SIG_CLICKED_TRIPLE, ""},
158 {SIG_SELECTION_PASTE, ""},
159 {SIG_SELECTION_COPY, ""},
160 {SIG_SELECTION_CUT, ""},
161 {SIG_SELECTION_START, ""},
162 {SIG_SELECTION_CHANGED, ""},
163 {SIG_SELECTION_CLEARED, ""},
164 {SIG_CURSOR_CHANGED, ""},
165 {SIG_ANCHOR_CLICKED, ""},
166 {SIG_ANCHOR_DOWN, ""},
169 {SIG_ANCHOR_OUT, ""},
170 {SIG_PREEDIT_CHANGED, ""},
171 {SIG_CHANGED_USER, ""},
175 static Eina_List *entries = NULL;
179 void (*obj_hook) (Evas_Object *obj);
180 void (*obj_unhook) (Evas_Object *obj);
181 void (*obj_longpress) (Evas_Object *obj);
185 _module(Evas_Object *obj __UNUSED__)
187 static Elm_Module *m = NULL;
188 if (m) goto ok; // already found - just use
189 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
191 m->api = malloc(sizeof(Mod_Api));
192 if (!m->api) return NULL;
193 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
194 _elm_module_symbol_get(m, "obj_hook");
195 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
196 _elm_module_symbol_get(m, "obj_unhook");
197 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
198 _elm_module_symbol_get(m, "obj_longpress");
199 ok: // ok - return api
204 _buf_append(char *buf, const char *str, int *len, int *alloc)
206 int len2 = strlen(str);
207 if ((*len + len2) >= *alloc)
209 char *buf2 = realloc(buf, *alloc + len2 + 512);
210 if (!buf2) return NULL;
212 *alloc += (512 + len2);
214 strcpy(buf + *len, str);
220 _load_file(const char *file)
224 int alloc = 0, len = 0;
225 char *text = NULL, buf[16384 + 1];
227 f = fopen(file, "rb");
229 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
233 tmp_text = _buf_append(text, buf, &len, &alloc);
234 if (!tmp_text) break;
242 _load_plain(const char *file)
246 text = _load_file(file);
251 text2 = elm_entry_utf8_to_markup(text);
259 _load(Evas_Object *obj)
261 Widget_Data *wd = elm_widget_data_get(obj);
266 elm_entry_entry_set(obj, "");
271 case ELM_TEXT_FORMAT_PLAIN_UTF8:
272 text = _load_plain(wd->file);
274 case ELM_TEXT_FORMAT_MARKUP_UTF8:
275 text = _load_file(wd->file);
283 elm_entry_entry_set(obj, text);
287 elm_entry_entry_set(obj, "");
291 _save_markup_utf8(const char *file, const char *text)
295 if ((!text) || (!text[0]))
297 ecore_file_unlink(file);
300 f = fopen(file, "wb");
303 // FIXME: report a write error
306 fputs(text, f); // FIXME: catch error
311 _save_plain_utf8(const char *file, const char *text)
315 text2 = elm_entry_markup_to_utf8(text);
318 _save_markup_utf8(file, text2);
323 _save(Evas_Object *obj)
325 Widget_Data *wd = elm_widget_data_get(obj);
327 if (!wd->file) return;
330 case ELM_TEXT_FORMAT_PLAIN_UTF8:
331 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
333 case ELM_TEXT_FORMAT_MARKUP_UTF8:
334 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
342 _delay_write(void *data)
344 Widget_Data *wd = elm_widget_data_get(data);
345 if (!wd) return ECORE_CALLBACK_CANCEL;
347 wd->delay_write = NULL;
348 return ECORE_CALLBACK_CANCEL;
351 static Elm_Entry_Text_Filter *
352 _filter_new(Elm_Entry_Filter_Cb func, void *data)
354 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
355 if (!tf) return NULL;
358 if (func == elm_entry_filter_limit_size)
360 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
367 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
373 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
376 else if (func == elm_entry_filter_accept_set)
378 Elm_Entry_Filter_Accept_Set *as = data, *as2;
385 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
392 as2->accepted = eina_stringshare_add(as->accepted);
394 as2->accepted = NULL;
396 as2->rejected = eina_stringshare_add(as->rejected);
398 as2->rejected = NULL;
407 _filter_free(Elm_Entry_Text_Filter *tf)
409 if (tf->func == elm_entry_filter_limit_size)
411 Elm_Entry_Filter_Limit_Size *lim = tf->data;
414 else if (tf->func == elm_entry_filter_accept_set)
416 Elm_Entry_Filter_Accept_Set *as = tf->data;
419 if (as->accepted) eina_stringshare_del(as->accepted);
420 if (as->rejected) eina_stringshare_del(as->rejected);
428 _del_pre_hook(Evas_Object *obj)
430 Widget_Data *wd = elm_widget_data_get(obj);
434 ecore_timer_del(wd->delay_write);
435 wd->delay_write = NULL;
436 if (wd->autosave) _save(obj);
441 _del_hook(Evas_Object *obj)
443 Widget_Data *wd = elm_widget_data_get(obj);
444 Elm_Entry_Context_Menu_Item *it;
445 Elm_Entry_Item_Provider *ip;
446 Elm_Entry_Text_Filter *tf;
448 evas_event_freeze(evas_object_evas_get(obj));
450 if (wd->file) eina_stringshare_del(wd->file);
452 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
453 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
455 entries = eina_list_remove(entries, obj);
456 #ifdef HAVE_ELEMENTARY_X
457 if (wd->sel_notify_handler)
458 ecore_event_handler_del(wd->sel_notify_handler);
459 if (wd->sel_clear_handler)
460 ecore_event_handler_del(wd->sel_clear_handler);
462 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
463 if (wd->text) eina_stringshare_del(wd->text);
464 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
465 if (wd->append_text_idler)
467 ecore_idler_del(wd->append_text_idler);
468 free(wd->append_text_left);
469 wd->append_text_left = NULL;
470 wd->append_text_idler = NULL;
472 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
473 EINA_LIST_FREE(wd->items, it)
475 eina_stringshare_del(it->label);
476 eina_stringshare_del(it->icon_file);
477 eina_stringshare_del(it->icon_group);
480 EINA_LIST_FREE(wd->item_providers, ip)
484 EINA_LIST_FREE(wd->text_filters, tf)
488 if (wd->delay_write) ecore_timer_del(wd->delay_write);
491 evas_event_thaw(evas_object_evas_get(obj));
492 evas_event_thaw_eval(evas_object_evas_get(obj));
496 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
498 Widget_Data *wd = elm_widget_data_get(obj);
499 edje_object_mirrored_set(wd->ent, rtl);
503 _theme_hook(Evas_Object *obj)
505 Widget_Data *wd = elm_widget_data_get(obj);
508 evas_event_freeze(evas_object_evas_get(obj));
509 _elm_widget_mirrored_reload(obj);
510 _mirrored_set(obj, elm_widget_mirrored_get(obj));
512 t = eina_stringshare_add(elm_entry_entry_get(obj));
513 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
514 if (_elm_config->desktop_entry)
515 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
516 elm_entry_entry_set(obj, t);
517 eina_stringshare_del(t);
518 if (elm_widget_disabled_get(obj))
519 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
520 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
521 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
522 if (elm_widget_focus_get(obj))
523 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
524 edje_object_message_signal_process(wd->ent);
525 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
526 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
527 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
528 elm_widget_style_get(obj));
534 edj = elm_smart_scroller_edje_object_get(wd->scroller);
535 str = edje_object_data_get(edj, "focus_highlight");
536 if ((str) && (!strcmp(str, "on")))
537 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
539 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
542 evas_event_thaw(evas_object_evas_get(obj));
543 evas_event_thaw_eval(evas_object_evas_get(obj));
547 _disable_hook(Evas_Object *obj)
549 Widget_Data *wd = elm_widget_data_get(obj);
551 if (elm_widget_disabled_get(obj))
553 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
554 wd->disabled = EINA_TRUE;
558 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
559 wd->disabled = EINA_FALSE;
564 _recalc_cursor_geometry(Evas_Object *obj)
566 Widget_Data *wd = elm_widget_data_get(obj);
568 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
569 if (!wd->deferred_recalc_job)
571 Evas_Coord cx, cy, cw, ch;
572 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
576 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
577 wd->cur_changed = EINA_FALSE;
581 wd->deferred_cur = EINA_TRUE;
585 _elm_deferred_recalc_job(void *data)
587 Widget_Data *wd = elm_widget_data_get(data);
588 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
590 wd->deferred_recalc_job = NULL;
592 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
593 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
594 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
597 /* This is a hack to workaround the way min size hints are treated.
598 * If the minimum width is smaller than the restricted width, it means
599 * the mininmum doesn't matter. */
602 Evas_Coord ominw = -1;
603 evas_object_size_hint_min_get(data, &ominw, NULL);
607 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
610 Evas_Coord vmw = 0, vmh = 0;
612 edje_object_size_min_calc
613 (elm_smart_scroller_edje_object_get(wd->scroller),
617 evas_object_size_hint_min_set(data, vmw, minh + vmh);
618 evas_object_size_hint_max_set(data, -1, minh + vmh);
622 evas_object_size_hint_min_set(data, vmw, vmh);
623 evas_object_size_hint_max_set(data, -1, -1);
630 evas_object_size_hint_min_set(data, minw, minh);
631 evas_object_size_hint_max_set(data, -1, minh);
635 evas_object_size_hint_min_set(data, fw, minh);
636 evas_object_size_hint_max_set(data, -1, -1);
640 if (wd->deferred_cur)
642 Evas_Coord cx, cy, cw, ch;
643 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
647 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
648 wd->cur_changed = EINA_FALSE;
654 _sizing_eval(Evas_Object *obj)
656 Widget_Data *wd = elm_widget_data_get(obj);
657 Evas_Coord minw = -1, minh = -1;
658 Evas_Coord resw, resh;
661 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
664 if ((resw == wd->lastw) && (!wd->changed)) return;
665 evas_event_freeze(evas_object_evas_get(obj));
666 wd->changed = EINA_FALSE;
670 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
672 evas_object_resize(wd->scroller, resw, resh);
673 edje_object_size_min_calc
674 (elm_smart_scroller_edje_object_get(wd->scroller),
676 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
677 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
680 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
682 if ((minw > 0) && (vw < minw)) vw = minw;
683 if (minh > vh) vh = minh;
685 if (wd->single_line) h = vmh + minh;
687 evas_object_resize(wd->ent, vw, vh);
688 evas_object_size_hint_min_set(obj, w, h);
690 evas_object_size_hint_max_set(obj, -1, h);
692 evas_object_size_hint_max_set(obj, -1, -1);
696 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
697 wd->deferred_recalc_job = ecore_job_add(_elm_deferred_recalc_job, obj);
699 evas_event_thaw(evas_object_evas_get(obj));
700 evas_event_thaw_eval(evas_object_evas_get(obj));
704 if (!wd->changed) return;
705 evas_event_freeze(evas_object_evas_get(obj));
706 wd->changed = EINA_FALSE;
710 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
712 edje_object_size_min_calc(wd->ent, &minw, &minh);
715 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
717 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
719 if ((minw > 0) && (vw < minw)) vw = minw;
720 if (minh > 0) vh = minh;
722 evas_object_resize(wd->ent, vw, vh);
723 edje_object_size_min_calc
724 (elm_smart_scroller_edje_object_get(wd->scroller),
726 if (wd->single_line) h = vmh + minh;
728 evas_object_size_hint_min_set(obj, w, h);
730 evas_object_size_hint_max_set(obj, -1, h);
732 evas_object_size_hint_max_set(obj, -1, -1);
736 edje_object_size_min_calc(wd->ent, &minw, &minh);
739 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
740 evas_object_size_hint_min_set(obj, minw, minh);
742 evas_object_size_hint_max_set(obj, -1, minh);
744 evas_object_size_hint_max_set(obj, -1, -1);
746 evas_event_thaw(evas_object_evas_get(obj));
747 evas_event_thaw_eval(evas_object_evas_get(obj));
750 _recalc_cursor_geometry(obj);
754 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
756 Widget_Data *wd = elm_widget_data_get(obj);
757 Evas_Object *top = elm_widget_top_get(obj);
759 if (!wd->editable) return;
760 if (elm_widget_focus_get(obj))
762 evas_object_focus_set(wd->ent, EINA_TRUE);
763 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
764 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
765 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
769 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
770 evas_object_focus_set(wd->ent, EINA_FALSE);
771 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
772 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
777 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
779 Widget_Data *wd = elm_widget_data_get(obj);
781 if ((!wd) || (!content)) return;
783 edje = elm_smart_scroller_edje_object_get(wd->scroller);
784 if (!strcmp(part, "elm.swallow.icon"))
787 evas_object_del(wd->icon);
789 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
791 else if (!strcmp(part, "elm.swallow.end"))
794 evas_object_del(wd->end);
796 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
798 evas_event_freeze(evas_object_evas_get(obj));
799 elm_widget_sub_object_add(obj, content);
800 edje_object_part_swallow(edje, part, content);
802 evas_event_thaw(evas_object_evas_get(obj));
803 evas_event_thaw_eval(evas_object_evas_get(obj));
807 _content_unset_hook(Evas_Object *obj, const char *part)
809 Widget_Data *wd = elm_widget_data_get(obj);
810 Evas_Object *content, *edje;
811 if (!wd) return NULL;
813 edje = elm_smart_scroller_edje_object_get(wd->scroller);
814 if (!strcmp(part, "elm.swallow.icon"))
817 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
819 else if (!strcmp(part, "elm.swallow.end"))
822 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
825 content = edje_object_part_swallow_get(edje, part);
826 edje_object_part_swallow(edje, part, NULL);
827 if (!content) return NULL;
828 evas_event_freeze(evas_object_evas_get(obj));
829 elm_widget_sub_object_del(obj, content);
830 edje_object_part_unswallow(wd->ent, content);
832 evas_event_thaw(evas_object_evas_get(obj));
833 evas_event_thaw_eval(evas_object_evas_get(obj));
839 _content_get_hook(const Evas_Object *obj, const char *part)
841 Widget_Data *wd = elm_widget_data_get(obj);
842 Evas_Object *content = NULL, *edje;
843 if (!wd) return NULL;
845 if (!strcmp(part, "elm.swallow.icon"))
847 if (!strcmp(part, "elm.swallow.end"))
850 edje = elm_smart_scroller_edje_object_get(wd->scroller);
852 content = edje_object_part_swallow_get(edje, part);
857 _translate_hook(Evas_Object *obj)
859 evas_object_smart_callback_call(obj, "language,changed", NULL);
863 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
865 Widget_Data *wd = elm_widget_data_get(obj);
867 edje_object_signal_emit(wd->ent, emission, source);
869 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
874 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
876 Widget_Data *wd = elm_widget_data_get(obj);
878 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
880 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
881 emission, source, func_cb, data);
885 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
887 Widget_Data *wd = elm_widget_data_get(obj);
888 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
891 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
892 emission, source, func_cb, data);
896 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
898 Widget_Data *wd = elm_widget_data_get(obj);
899 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
903 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
905 Widget_Data *wd = elm_widget_data_get(obj);
907 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
911 _show_region_hook(void *data, Evas_Object *obj)
913 Widget_Data *wd = elm_widget_data_get(data);
914 Evas_Coord x, y, w, h;
916 elm_widget_show_region_get(obj, &x, &y, &w, &h);
918 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
922 _sub_del(void *data, Evas_Object *obj, void *event_info)
924 Widget_Data *wd = data;
925 Evas_Object *sub = event_info;
928 edje = elm_smart_scroller_edje_object_get(wd->scroller);
933 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
935 else if (sub == wd->end)
939 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
945 _hoversel_position(Evas_Object *obj)
947 Widget_Data *wd = elm_widget_data_get(obj);
948 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
953 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
962 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
964 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
975 evas_object_move(wd->hoversel, x + cx, y + cy);
976 evas_object_resize(wd->hoversel, cw, ch);
980 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
982 Widget_Data *wd = elm_widget_data_get(data);
984 if (wd->hoversel) _hoversel_position(data);
988 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
990 Widget_Data *wd = elm_widget_data_get(data);
999 Evas_Coord vw = 0, vh = 0;
1001 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1002 if (vw < wd->entmw) vw = wd->entmw;
1003 if (vh < wd->entmh) vh = wd->entmh;
1004 evas_object_resize(wd->ent, vw, vh);
1006 if (wd->hoversel) _hoversel_position(data);
1010 _hover_del(void *data)
1012 Widget_Data *wd = elm_widget_data_get(data);
1017 evas_object_del(wd->hoversel);
1018 wd->hoversel = NULL;
1020 wd->hovdeljob = NULL;
1024 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1026 Widget_Data *wd = elm_widget_data_get(data);
1029 if (wd->hoversel) evas_object_hide(wd->hoversel);
1032 if (!_elm_config->desktop_entry)
1035 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1038 elm_widget_scroll_freeze_pop(data);
1039 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1040 wd->hovdeljob = ecore_job_add(_hover_del, data);
1044 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1046 Widget_Data *wd = elm_widget_data_get(data);
1048 wd->selmode = EINA_TRUE;
1049 edje_object_part_text_select_none(wd->ent, "elm.text");
1050 if (!_elm_config->desktop_entry)
1053 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1055 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1056 if (!_elm_config->desktop_entry)
1057 elm_widget_scroll_hold_push(data);
1061 _elm_entry_entry_paste(Evas_Object *obj, const char *entry)
1063 elm_entry_entry_insert(obj, entry);
1064 evas_object_smart_callback_call(obj, SIG_CHANGED_USER, NULL);
1068 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1070 Widget_Data *wd = elm_widget_data_get(data);
1072 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1073 if (wd->sel_notify_handler)
1075 #ifdef HAVE_ELEMENTARY_X
1076 Elm_Sel_Format formats;
1077 wd->selection_asked = EINA_TRUE;
1078 formats = ELM_SEL_FORMAT_MARKUP;
1080 formats |= ELM_SEL_FORMAT_IMAGE;
1081 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1087 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1089 Widget_Data *wd = elm_widget_data_get(obj);
1093 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1094 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1095 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
1096 if (seltype == ELM_SEL_CLIPBOARD)
1097 eina_stringshare_replace(&wd->cut_sel, sel);
1101 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1103 Widget_Data *wd = elm_widget_data_get(data);
1106 wd->selmode = EINA_FALSE;
1107 if (!_elm_config->desktop_entry)
1108 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1109 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1110 if (!_elm_config->desktop_entry)
1111 elm_widget_scroll_hold_pop(data);
1112 _store_selection(ELM_SEL_CLIPBOARD, data);
1113 edje_object_part_text_insert(wd->ent, "elm.text", "");
1114 edje_object_part_text_select_none(wd->ent, "elm.text");
1119 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1121 Widget_Data *wd = elm_widget_data_get(data);
1123 wd->selmode = EINA_FALSE;
1124 if (!_elm_config->desktop_entry)
1126 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1127 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1128 elm_widget_scroll_hold_pop(data);
1130 _store_selection(ELM_SEL_CLIPBOARD, data);
1131 // edje_object_part_text_select_none(wd->ent, "elm.text");
1135 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1137 Widget_Data *wd = elm_widget_data_get(data);
1139 wd->selmode = EINA_FALSE;
1140 if (!_elm_config->desktop_entry)
1141 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1142 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1143 if (!_elm_config->desktop_entry)
1144 elm_widget_scroll_hold_pop(data);
1145 edje_object_part_text_select_none(wd->ent, "elm.text");
1149 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1151 Elm_Entry_Context_Menu_Item *it = data;
1152 Evas_Object *obj2 = it->obj;
1153 if (it->func) it->func(it->data, obj2, NULL);
1157 _menu_press(Evas_Object *obj)
1159 Widget_Data *wd = elm_widget_data_get(obj);
1162 const Elm_Entry_Context_Menu_Item *it;
1164 if ((wd->api) && (wd->api->obj_longpress))
1166 wd->api->obj_longpress(obj);
1168 else if (wd->context_menu)
1170 const char *context_menu_orientation;
1172 if (wd->hoversel) evas_object_del(wd->hoversel);
1173 else elm_widget_scroll_freeze_push(obj);
1174 wd->hoversel = elm_hoversel_add(obj);
1175 context_menu_orientation = edje_object_data_get
1176 (wd->ent, "context_menu_orientation");
1177 if ((context_menu_orientation) &&
1178 (!strcmp(context_menu_orientation, "horizontal")))
1179 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1180 elm_object_style_set(wd->hoversel, "entry");
1181 elm_widget_sub_object_add(obj, wd->hoversel);
1182 elm_object_text_set(wd->hoversel, "Text");
1183 top = elm_widget_top_get(obj);
1184 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1185 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1186 if (wd->have_selection)
1190 if (wd->have_selection)
1192 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1195 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1198 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1206 if (!_elm_config->desktop_entry)
1209 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1212 if (elm_selection_selection_has_owner())
1215 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1220 EINA_LIST_FOREACH(wd->items, l, it)
1222 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1223 it->icon_type, _item_clicked, it);
1227 _hoversel_position(obj);
1228 evas_object_show(wd->hoversel);
1229 elm_hoversel_hover_begin(wd->hoversel);
1231 if (!_elm_config->desktop_entry)
1233 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1234 edje_object_part_text_select_abort(wd->ent, "elm.text");
1240 _long_press(void *data)
1242 Widget_Data *wd = elm_widget_data_get(data);
1243 if (!wd) return ECORE_CALLBACK_CANCEL;
1245 wd->longpress_timer = NULL;
1246 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1247 return ECORE_CALLBACK_CANCEL;
1251 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1253 Widget_Data *wd = elm_widget_data_get(data);
1254 Evas_Event_Mouse_Down *ev = event_info;
1256 if (wd->disabled) return;
1257 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1258 wd->downx = ev->canvas.x;
1259 wd->downy = ev->canvas.y;
1260 if (ev->button == 1)
1262 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1263 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1268 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1270 Widget_Data *wd = elm_widget_data_get(data);
1271 Evas_Event_Mouse_Up *ev = event_info;
1273 if (wd->disabled) return;
1274 if (ev->button == 1)
1276 if (wd->longpress_timer)
1278 ecore_timer_del(wd->longpress_timer);
1279 wd->longpress_timer = NULL;
1282 else if (ev->button == 3)
1290 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1292 Widget_Data *wd = elm_widget_data_get(data);
1293 Evas_Event_Mouse_Move *ev = event_info;
1295 if (wd->disabled) return;
1298 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1300 if (wd->longpress_timer)
1302 ecore_timer_del(wd->longpress_timer);
1303 wd->longpress_timer = NULL;
1306 else if (wd->longpress_timer)
1310 dx = wd->downx - ev->cur.canvas.x;
1312 dy = wd->downy - ev->cur.canvas.y;
1315 ((_elm_config->finger_size / 2) *
1316 (_elm_config->finger_size / 2)))
1318 ecore_timer_del(wd->longpress_timer);
1319 wd->longpress_timer = NULL;
1323 else if (wd->longpress_timer)
1327 dx = wd->downx - ev->cur.canvas.x;
1329 dy = wd->downy - ev->cur.canvas.y;
1332 ((_elm_config->finger_size / 2) *
1333 (_elm_config->finger_size / 2)))
1335 ecore_timer_del(wd->longpress_timer);
1336 wd->longpress_timer = NULL;
1342 _getbase(Evas_Object *obj)
1344 Widget_Data *wd = elm_widget_data_get(obj);
1345 if (!wd) return "base";
1348 if (wd->password) return "base-password";
1351 if (wd->single_line) return "base-single";
1354 switch (wd->linewrap)
1357 return "base-charwrap";
1360 case ELM_WRAP_MIXED:
1361 return "base-mixedwrap";
1364 return "base-nowrap";
1371 if (wd->password) return "base-password";
1374 if (wd->single_line) return "base-single-noedit";
1377 switch (wd->linewrap)
1380 return "base-noedit-charwrap";
1382 return "base-noedit";
1383 case ELM_WRAP_MIXED:
1384 return "base-noedit-mixedwrap";
1387 return "base-nowrap-noedit";
1395 _entry_changed_common_handling(void *data, const char *event)
1397 Widget_Data *wd = elm_widget_data_get(data);
1400 evas_event_freeze(evas_object_evas_get(data));
1401 wd->changed = EINA_TRUE;
1402 /* Reset the size hints which are no more relevant.
1403 * Keep the height, this is a hack, but doesn't really matter
1404 * cause we'll re-eval in a moment. */
1405 evas_object_size_hint_min_get(data, NULL, &minh);
1406 evas_object_size_hint_min_set(data, -1, minh);
1408 if (wd->text) eina_stringshare_del(wd->text);
1410 if (wd->delay_write)
1412 ecore_timer_del(wd->delay_write);
1413 wd->delay_write = NULL;
1415 evas_event_thaw(evas_object_evas_get(data));
1416 evas_event_thaw_eval(evas_object_evas_get(data));
1417 if ((!wd->autosave) || (!wd->file)) return;
1418 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1419 /* callback - this could call callbacks that delete the entry... thus...
1420 * any access to wd after this could be invalid */
1421 evas_object_smart_callback_call(data, event, NULL);
1425 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1427 _entry_changed_common_handling(data, SIG_CHANGED);
1431 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1433 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
1437 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1439 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1443 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1445 Widget_Data *wd = elm_widget_data_get(data);
1449 EINA_LIST_FOREACH(entries, l, entry)
1451 if (entry != data) elm_entry_select_none(entry);
1453 wd->have_selection = EINA_TRUE;
1454 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1455 #ifdef HAVE_ELEMENTARY_X
1456 if (wd->sel_notify_handler)
1458 const char *txt = elm_entry_selection_get(data);
1461 top = elm_widget_top_get(data);
1462 if ((top) && (elm_win_xwindow_get(top)))
1463 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1469 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1471 Widget_Data *wd = elm_widget_data_get(data);
1473 elm_entry_select_all(data);
1477 _signal_selection_none(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1479 Widget_Data *wd = elm_widget_data_get(data);
1481 elm_entry_select_none(data);
1485 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1487 Widget_Data *wd = elm_widget_data_get(data);
1489 wd->have_selection = EINA_TRUE;
1490 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1491 _store_selection(ELM_SEL_PRIMARY, data);
1495 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1497 Widget_Data *wd = elm_widget_data_get(data);
1499 if (!wd->have_selection) return;
1500 wd->have_selection = EINA_FALSE;
1501 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1502 if (wd->sel_notify_handler)
1506 #ifdef HAVE_ELEMENTARY_X
1509 top = elm_widget_top_get(data);
1510 if ((top) && (elm_win_xwindow_get(top)))
1511 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1514 eina_stringshare_del(wd->cut_sel);
1519 #ifdef HAVE_ELEMENTARY_X
1522 top = elm_widget_top_get(data);
1523 if ((top) && (elm_win_xwindow_get(top)))
1524 elm_selection_clear(ELM_SEL_PRIMARY, data);
1531 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1533 Widget_Data *wd = elm_widget_data_get(data);
1534 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ? ELM_SEL_PRIMARY : ELM_SEL_CLIPBOARD;
1536 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1537 if (wd->sel_notify_handler)
1539 #ifdef HAVE_ELEMENTARY_X
1542 top = elm_widget_top_get(data);
1543 if ((top) && (elm_win_xwindow_get(top)))
1545 wd->selection_asked = EINA_TRUE;
1546 elm_selection_get(type, ELM_SEL_FORMAT_MARKUP, data,
1554 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1556 _copy(data, NULL, NULL);
1560 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1562 _cut(data, NULL, NULL);
1566 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1568 Widget_Data *wd = elm_widget_data_get(data);
1570 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1571 wd->cur_changed = EINA_TRUE;
1572 _recalc_cursor_geometry(data);
1576 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
1578 const Eina_List *geoms, *l;
1579 Evas_Textblock_Rectangle *r;
1580 Evas_Coord px, py, x, y;
1582 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
1586 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1587 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1588 EINA_LIST_FOREACH(geoms, l, r)
1590 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1591 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1603 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1605 Widget_Data *wd = elm_widget_data_get(data);
1606 Elm_Entry_Anchor_Info ei;
1610 p = emission + sizeof("nchor,mouse,down,");
1611 ei.button = strtol(p, &p2, 10);
1613 ei.x = ei.y = ei.w = ei.h = 0;
1615 _signal_anchor_geoms_do_things_with(wd, &ei);
1618 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
1622 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1624 Widget_Data *wd = elm_widget_data_get(data);
1625 Elm_Entry_Anchor_Info ei;
1629 p = emission + sizeof("nchor,mouse,up,");
1630 ei.button = strtol(p, &p2, 10);
1632 ei.x = ei.y = ei.w = ei.h = 0;
1634 _signal_anchor_geoms_do_things_with(wd, &ei);
1637 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
1641 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1643 Widget_Data *wd = elm_widget_data_get(data);
1644 Elm_Entry_Anchor_Info ei;
1648 p = emission + sizeof("nchor,mouse,clicked,");
1649 ei.button = strtol(p, &p2, 10);
1651 ei.x = ei.y = ei.w = ei.h = 0;
1653 _signal_anchor_geoms_do_things_with(wd, &ei);
1656 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1660 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1662 Widget_Data *wd = elm_widget_data_get(data);
1667 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1669 Widget_Data *wd = elm_widget_data_get(data);
1670 Elm_Entry_Anchor_Info ei;
1672 ei.name = emission + sizeof("nchor,mouse,in,");
1674 ei.x = ei.y = ei.w = ei.h = 0;
1676 _signal_anchor_geoms_do_things_with(wd, &ei);
1679 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
1683 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1685 Widget_Data *wd = elm_widget_data_get(data);
1686 Elm_Entry_Anchor_Info ei;
1688 ei.name = emission + sizeof("nchor,mouse,out,");
1690 ei.x = ei.y = ei.w = ei.h = 0;
1692 _signal_anchor_geoms_do_things_with(wd, &ei);
1695 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
1699 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1701 Widget_Data *wd = elm_widget_data_get(data);
1703 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1707 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1709 Widget_Data *wd = elm_widget_data_get(data);
1711 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1715 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1717 Widget_Data *wd = elm_widget_data_get(data);
1719 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1723 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1725 Widget_Data *wd = elm_widget_data_get(data);
1727 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1731 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1733 Widget_Data *wd = elm_widget_data_get(data);
1735 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
1738 #ifdef HAVE_ELEMENTARY_X
1740 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1742 Widget_Data *wd = elm_widget_data_get(data);
1743 Ecore_X_Event_Selection_Notify *ev = event;
1744 if (!wd) return ECORE_CALLBACK_PASS_ON;
1745 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1746 return ECORE_CALLBACK_PASS_ON;
1748 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1749 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1751 Ecore_X_Selection_Data_Text *text_data;
1753 text_data = ev->data;
1754 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1756 if (text_data->text)
1758 char *txt = _elm_util_text_to_mkup(text_data->text);
1762 elm_entry_entry_insert(data, txt);
1767 wd->selection_asked = EINA_FALSE;
1769 else if (ev->selection == ECORE_X_SELECTION_XDND)
1771 Ecore_X_Selection_Data_Text *text_data;
1773 text_data = ev->data;
1774 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1776 if (text_data->text)
1778 char *txt = _elm_util_text_to_mkup(text_data->text);
1782 /* Massive FIXME: this should be at the drag point */
1783 elm_entry_entry_insert(data, txt);
1788 wd->drag_selection_asked = EINA_FALSE;
1790 ecore_x_dnd_send_finished();
1793 return ECORE_CALLBACK_PASS_ON;
1797 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
1799 Widget_Data *wd = elm_widget_data_get(data);
1800 Ecore_X_Event_Selection_Clear *ev = event;
1801 if (!wd) return ECORE_CALLBACK_PASS_ON;
1802 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1803 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1804 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1806 elm_entry_select_none(data);
1808 return ECORE_CALLBACK_PASS_ON;
1812 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1817 wd = elm_widget_data_get(obj);
1818 if (!wd) return EINA_FALSE;
1819 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1821 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1822 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1823 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1824 EDJE_CURSOR_MAIN,drop->x,drop->y);
1825 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1826 elm_entry_entry_insert(obj, drop->data);
1827 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1828 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1834 static Evas_Object *
1835 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1837 Widget_Data *wd = elm_widget_data_get(data);
1840 Elm_Entry_Item_Provider *ip;
1842 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1844 o = ip->func(ip->data, data, item);
1847 if (!strncmp(item, "file://", 7))
1849 const char *fname = item + 7;
1851 o = evas_object_image_filled_add(evas_object_evas_get(data));
1852 evas_object_image_file_set(o, fname, NULL);
1853 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1855 evas_object_show(o);
1860 o = edje_object_add(evas_object_evas_get(data));
1861 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1865 o = edje_object_add(evas_object_evas_get(data));
1866 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1867 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1872 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
1874 Widget_Data *wd = elm_widget_data_get(data);
1876 Elm_Entry_Text_Filter *tf;
1878 if (type == EDJE_TEXT_FILTER_FORMAT)
1881 EINA_LIST_FOREACH(wd->text_filters, l, tf)
1883 tf->func(tf->data, data, text);
1889 /* This function is used to insert text by chunks in jobs */
1891 _text_append_idler(void *data)
1895 Evas_Object *obj = (Evas_Object *) data;
1896 Widget_Data *wd = elm_widget_data_get(obj);
1897 evas_event_freeze(evas_object_evas_get(obj));
1898 if (wd->text) eina_stringshare_del(wd->text);
1900 wd->changed = EINA_TRUE;
1902 start = wd->append_text_position;
1903 if (start + _CHUNK_SIZE < wd->append_text_len)
1906 int tag_start, esc_start;
1908 tag_start = esc_start = -1;
1909 /* Find proper markup cut place */
1910 while (pos - start < _CHUNK_SIZE)
1914 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
1915 if (esc_start == -1)
1918 tag_start = prev_pos;
1919 else if (tmp == '>')
1922 if (tag_start == -1)
1925 esc_start = prev_pos;
1926 else if (tmp == ';')
1933 wd->append_text_position = tag_start;
1935 else if (esc_start >= 0)
1937 wd->append_text_position = esc_start;
1941 wd->append_text_position = pos;
1946 wd->append_text_position = wd->append_text_len;
1949 backup = wd->append_text_left[wd->append_text_position];
1950 wd->append_text_left[wd->append_text_position] = '\0';
1952 edje_object_part_text_append(wd->ent, "elm.text",
1953 wd->append_text_left + start);
1955 wd->append_text_left[wd->append_text_position] = backup;
1957 evas_event_thaw(evas_object_evas_get(obj));
1958 evas_event_thaw_eval(evas_object_evas_get(obj));
1960 /* If there's still more to go, renew the idler, else, cleanup */
1961 if (wd->append_text_position < wd->append_text_len)
1963 return ECORE_CALLBACK_RENEW;
1967 free(wd->append_text_left);
1968 wd->append_text_left = NULL;
1969 wd->append_text_idler = NULL;
1970 return ECORE_CALLBACK_CANCEL;
1975 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
1977 int i = 0, current_len = 0;
1981 if (unit >= LENGTH_UNIT_LAST) return;
1983 current_len = strlen(*text);
1986 if (*new_text == '<')
1988 while (*new_text != '>')
1991 if (!*new_text) break;
1997 int idx = 0, unit_size = 0;
1998 char *markup, *utfstr;
1999 if (*new_text == '&')
2001 while (*(new_text + idx) != ';')
2004 if (!*(new_text + idx)) break;
2007 idx = evas_string_char_next_get(new_text, idx, NULL);
2008 markup = malloc(idx + 1);
2011 strncpy(markup, new_text, idx);
2013 utfstr = elm_entry_markup_to_utf8(markup);
2016 if (unit == LENGTH_UNIT_BYTE)
2017 unit_size = strlen(utfstr);
2018 else if (unit == LENGTH_UNIT_CHAR)
2019 unit_size = evas_string_char_len_get(utfstr);
2026 if (can_add < unit_size)
2030 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2036 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2038 (*text)[current_len] = 0;
2043 can_add -= unit_size;
2048 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2052 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2055 ELM_CHECK_WIDTYPE(obj, widtype);
2056 if (item && strcmp(item, "default")) return;
2057 Widget_Data *wd = elm_widget_data_get(obj);
2059 evas_event_freeze(evas_object_evas_get(obj));
2060 if (!entry) entry = "";
2061 if (wd->text) eina_stringshare_del(wd->text);
2063 wd->changed = EINA_TRUE;
2065 /* Clear currently pending job if there is one */
2066 if (wd->append_text_idler)
2068 ecore_idler_del(wd->append_text_idler);
2069 free(wd->append_text_left);
2070 wd->append_text_left = NULL;
2071 wd->append_text_idler = NULL;
2074 len = strlen(entry);
2075 /* Split to ~_CHUNK_SIZE chunks */
2076 if (len > _CHUNK_SIZE)
2078 wd->append_text_left = (char *) malloc(len + 1);
2081 /* If we decided to use the idler */
2082 if (wd->append_text_left)
2084 /* Need to clear the entry first */
2085 edje_object_part_text_set(wd->ent, "elm.text", "");
2086 memcpy(wd->append_text_left, entry, len + 1);
2087 wd->append_text_position = 0;
2088 wd->append_text_len = len;
2089 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2093 edje_object_part_text_set(wd->ent, "elm.text", entry);
2095 evas_event_thaw(evas_object_evas_get(obj));
2096 evas_event_thaw_eval(evas_object_evas_get(obj));
2100 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2102 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2103 Widget_Data *wd = elm_widget_data_get(obj);
2104 if (item && strcmp(item, "default")) return NULL;
2106 if (!wd) return NULL;
2107 if (wd->text) return wd->text;
2108 text = edje_object_part_text_get(wd->ent, "elm.text");
2111 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2115 if (wd->append_text_len > 0)
2119 tlen = strlen(text);
2120 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2123 ERR("Failed to allocate memory for entry's text %p", obj);
2126 memcpy(tmpbuf, text, tlen);
2127 memcpy(tmpbuf + tlen, wd->append_text_left, wd->append_text_len);
2128 tmpbuf[tlen + wd->append_text_len] = '\0';
2129 eina_stringshare_replace(&wd->text, tmpbuf);
2134 eina_stringshare_replace(&wd->text, text);
2140 elm_entry_add(Evas_Object *parent)
2142 Evas_Object *obj, *top;
2146 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2148 ELM_SET_WIDTYPE(widtype, "entry");
2149 elm_widget_type_set(obj, "entry");
2150 elm_widget_sub_object_add(parent, obj);
2151 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2152 elm_widget_data_set(obj, wd);
2153 elm_widget_del_hook_set(obj, _del_hook);
2154 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2155 elm_widget_theme_hook_set(obj, _theme_hook);
2156 elm_widget_disable_hook_set(obj, _disable_hook);
2157 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2158 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2159 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2160 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2161 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2162 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2163 elm_widget_can_focus_set(obj, EINA_TRUE);
2164 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2165 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2166 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2167 elm_widget_content_set_hook_set(obj, _content_set_hook);
2168 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2169 elm_widget_content_get_hook_set(obj, _content_get_hook);
2170 elm_widget_translate_hook_set(obj, _translate_hook);
2172 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2174 wd->scroller = elm_smart_scroller_add(e);
2175 elm_widget_sub_object_add(obj, wd->scroller);
2176 evas_object_smart_member_add(wd->scroller, obj);
2177 elm_smart_scroller_widget_set(wd->scroller, obj);
2178 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2179 elm_widget_style_get(obj));
2180 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2181 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2182 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2183 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
2184 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(
2185 wd->scroller), EINA_TRUE);
2187 wd->linewrap = ELM_WRAP_WORD;
2188 wd->editable = EINA_TRUE;
2189 wd->disabled = EINA_FALSE;
2190 wd->context_menu = EINA_TRUE;
2191 wd->autosave = EINA_TRUE;
2192 wd->textonly = EINA_FALSE;
2194 wd->ent = edje_object_add(e);
2195 elm_widget_sub_object_add(obj, wd->ent);
2196 edje_object_item_provider_set(wd->ent, _get_item, obj);
2197 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2198 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2199 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2201 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2203 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2205 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2207 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2208 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2209 _signal_entry_changed, obj);
2210 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
2211 _signal_entry_changed_user, obj);
2212 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2213 _signal_preedit_changed, obj);
2214 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2215 _signal_selection_start, obj);
2216 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2217 _signal_selection_changed, obj);
2218 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2219 _signal_selection_all, obj);
2220 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2221 _signal_selection_none, obj);
2222 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2223 _signal_selection_cleared, obj);
2224 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2225 _signal_entry_paste_request, obj);
2226 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2227 _signal_entry_copy_notify, obj);
2228 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2229 _signal_entry_cut_notify, obj);
2230 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2231 _signal_cursor_changed, obj);
2232 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2233 _signal_anchor_down, obj);
2234 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2235 _signal_anchor_up, obj);
2236 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2237 _signal_anchor_clicked, obj);
2238 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2239 _signal_anchor_move, obj);
2240 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2241 _signal_anchor_in, obj);
2242 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2243 _signal_anchor_out, obj);
2244 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2245 _signal_key_enter, obj);
2246 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2247 _signal_mouse_down, obj);
2248 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2249 _signal_mouse_clicked, obj);
2250 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2251 _signal_mouse_double, obj);
2252 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
2253 _signal_mouse_triple, obj);
2254 edje_object_part_text_set(wd->ent, "elm.text", "");
2255 if (_elm_config->desktop_entry)
2256 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2257 elm_widget_resize_object_set(obj, wd->ent);
2260 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
2262 #ifdef HAVE_ELEMENTARY_X
2263 top = elm_widget_top_get(obj);
2264 if ((top) && (elm_win_xwindow_get(top)))
2266 wd->sel_notify_handler =
2267 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2268 _event_selection_notify, obj);
2269 wd->sel_clear_handler =
2270 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2271 _event_selection_clear, obj);
2274 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2275 _drag_drop_cb, NULL);
2278 entries = eina_list_prepend(entries, obj);
2280 // module - find module for entry
2281 wd->api = _module(obj);
2282 // if found - hook in
2283 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2285 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2286 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2287 // TODO: and save some bytes, making descriptions per-class and not instance!
2288 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2293 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2295 ELM_CHECK_WIDTYPE(obj, widtype);
2296 Widget_Data *wd = elm_widget_data_get(obj);
2298 if (wd->single_line == single_line) return;
2299 wd->single_line = single_line;
2300 wd->linewrap = ELM_WRAP_NONE;
2301 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2305 if (wd->single_line)
2306 elm_smart_scroller_policy_set(wd->scroller,
2307 ELM_SMART_SCROLLER_POLICY_OFF,
2308 ELM_SMART_SCROLLER_POLICY_OFF);
2311 const Elm_Scroller_Policy map[3] =
2313 ELM_SMART_SCROLLER_POLICY_AUTO,
2314 ELM_SMART_SCROLLER_POLICY_ON,
2315 ELM_SMART_SCROLLER_POLICY_OFF
2317 elm_smart_scroller_policy_set(wd->scroller,
2326 elm_entry_single_line_get(const Evas_Object *obj)
2328 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2329 Widget_Data *wd = elm_widget_data_get(obj);
2330 if (!wd) return EINA_FALSE;
2331 return wd->single_line;
2335 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2337 ELM_CHECK_WIDTYPE(obj, widtype);
2338 Widget_Data *wd = elm_widget_data_get(obj);
2340 if (wd->password == password) return;
2341 wd->password = password;
2342 wd->single_line = EINA_TRUE;
2343 wd->linewrap = ELM_WRAP_NONE;
2348 elm_entry_password_get(const Evas_Object *obj)
2350 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2351 Widget_Data *wd = elm_widget_data_get(obj);
2352 if (!wd) return EINA_FALSE;
2353 return wd->password;
2357 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2359 _elm_entry_text_set(obj, NULL, entry);
2363 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2366 ELM_CHECK_WIDTYPE(obj, widtype);
2367 Widget_Data *wd = elm_widget_data_get(obj);
2369 if (!entry) entry = "";
2370 wd->changed = EINA_TRUE;
2372 len = strlen(entry);
2373 if (wd->append_text_left)
2376 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2382 wd->append_text_left = tmpbuf;
2383 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2384 wd->append_text_len += len;
2388 /* FIXME: Add chunked appending here (like in entry_set) */
2389 edje_object_part_text_append(wd->ent, "elm.text", entry);
2394 elm_entry_entry_get(const Evas_Object *obj)
2396 return _elm_entry_text_get(obj, NULL);
2400 elm_entry_is_empty(const Evas_Object *obj)
2402 /* FIXME: until there's support for that in textblock, we just check
2403 * to see if the there is text or not. */
2404 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2405 Widget_Data *wd = elm_widget_data_get(obj);
2406 const Evas_Object *tb;
2407 Evas_Textblock_Cursor *cur;
2409 if (!wd) return EINA_TRUE;
2410 /* It's a hack until we get the support suggested above.
2411 * We just create a cursor, point it to the begining, and then
2412 * try to advance it, if it can advance, the tb is not empty,
2413 * otherwise it is. */
2414 tb = edje_object_part_object_get(wd->ent, "elm.text");
2415 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2416 actually, ok for the time being, thsese hackish stuff will be removed
2417 once evas 1.0 is out*/
2418 evas_textblock_cursor_pos_set(cur, 0);
2419 ret = evas_textblock_cursor_char_next(cur);
2420 evas_textblock_cursor_free(cur);
2426 elm_entry_selection_get(const Evas_Object *obj)
2428 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2429 Widget_Data *wd = elm_widget_data_get(obj);
2430 if (!wd) return NULL;
2431 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2435 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2437 ELM_CHECK_WIDTYPE(obj, widtype);
2438 Widget_Data *wd = elm_widget_data_get(obj);
2440 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2441 wd->changed = EINA_TRUE;
2446 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2448 ELM_CHECK_WIDTYPE(obj, widtype);
2449 Widget_Data *wd = elm_widget_data_get(obj);
2451 if (wd->linewrap == wrap) return;
2453 wd->linewrap = wrap;
2458 elm_entry_line_wrap_get(const Evas_Object *obj)
2460 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2461 Widget_Data *wd = elm_widget_data_get(obj);
2462 if (!wd) return EINA_FALSE;
2463 return wd->linewrap;
2467 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2469 ELM_CHECK_WIDTYPE(obj, widtype);
2470 Widget_Data *wd = elm_widget_data_get(obj);
2472 if (wd->editable == editable) return;
2473 wd->editable = editable;
2476 #ifdef HAVE_ELEMENTARY_X
2478 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2480 elm_drop_target_del(obj);
2485 elm_entry_editable_get(const Evas_Object *obj)
2487 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2488 Widget_Data *wd = elm_widget_data_get(obj);
2489 if (!wd) return EINA_FALSE;
2490 return wd->editable;
2494 elm_entry_select_none(Evas_Object *obj)
2496 ELM_CHECK_WIDTYPE(obj, widtype);
2497 Widget_Data *wd = elm_widget_data_get(obj);
2501 wd->selmode = EINA_FALSE;
2502 if (!_elm_config->desktop_entry)
2503 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2504 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2506 wd->have_selection = EINA_FALSE;
2507 edje_object_part_text_select_none(wd->ent, "elm.text");
2511 elm_entry_select_all(Evas_Object *obj)
2513 ELM_CHECK_WIDTYPE(obj, widtype);
2514 Widget_Data *wd = elm_widget_data_get(obj);
2518 wd->selmode = EINA_FALSE;
2519 if (!_elm_config->desktop_entry)
2520 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2521 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2523 wd->have_selection = EINA_TRUE;
2524 edje_object_part_text_select_all(wd->ent, "elm.text");
2528 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2530 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2531 Widget_Data *wd = elm_widget_data_get(obj);
2532 if (!wd) return EINA_FALSE;
2533 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2538 elm_entry_cursor_next(Evas_Object *obj)
2540 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2541 Widget_Data *wd = elm_widget_data_get(obj);
2542 if (!wd) return EINA_FALSE;
2543 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2547 elm_entry_cursor_prev(Evas_Object *obj)
2549 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2550 Widget_Data *wd = elm_widget_data_get(obj);
2551 if (!wd) return EINA_FALSE;
2552 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2556 elm_entry_cursor_up(Evas_Object *obj)
2558 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2559 Widget_Data *wd = elm_widget_data_get(obj);
2560 if (!wd) return EINA_FALSE;
2561 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2565 elm_entry_cursor_down(Evas_Object *obj)
2567 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2568 Widget_Data *wd = elm_widget_data_get(obj);
2569 if (!wd) return EINA_FALSE;
2570 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2574 elm_entry_cursor_begin_set(Evas_Object *obj)
2576 ELM_CHECK_WIDTYPE(obj, widtype);
2577 Widget_Data *wd = elm_widget_data_get(obj);
2579 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2583 elm_entry_cursor_end_set(Evas_Object *obj)
2585 ELM_CHECK_WIDTYPE(obj, widtype);
2586 Widget_Data *wd = elm_widget_data_get(obj);
2590 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2593 elm_widget_show_region_get(obj, &x, &y, &w, &h);
2594 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
2599 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2601 ELM_CHECK_WIDTYPE(obj, widtype);
2602 Widget_Data *wd = elm_widget_data_get(obj);
2604 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2608 elm_entry_cursor_line_end_set(Evas_Object *obj)
2610 ELM_CHECK_WIDTYPE(obj, widtype);
2611 Widget_Data *wd = elm_widget_data_get(obj);
2613 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2617 elm_entry_cursor_selection_begin(Evas_Object *obj)
2619 ELM_CHECK_WIDTYPE(obj, widtype);
2620 Widget_Data *wd = elm_widget_data_get(obj);
2622 edje_object_part_text_select_begin(wd->ent, "elm.text");
2626 elm_entry_cursor_selection_end(Evas_Object *obj)
2628 ELM_CHECK_WIDTYPE(obj, widtype);
2629 Widget_Data *wd = elm_widget_data_get(obj);
2631 edje_object_part_text_select_extend(wd->ent, "elm.text");
2635 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2637 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2638 Widget_Data *wd = elm_widget_data_get(obj);
2639 if (!wd) return EINA_FALSE;
2640 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2644 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2646 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2647 Widget_Data *wd = elm_widget_data_get(obj);
2648 if (!wd) return EINA_FALSE;
2649 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2653 elm_entry_cursor_content_get(const Evas_Object *obj)
2655 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2656 Widget_Data *wd = elm_widget_data_get(obj);
2657 if (!wd) return NULL;
2658 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2662 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2664 ELM_CHECK_WIDTYPE(obj, widtype);
2665 Widget_Data *wd = elm_widget_data_get(obj);
2667 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2668 edje_object_message_signal_process(wd->ent);
2672 elm_entry_cursor_pos_get(const Evas_Object *obj)
2674 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2675 Widget_Data *wd = elm_widget_data_get(obj);
2677 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2681 elm_entry_selection_cut(Evas_Object *obj)
2683 ELM_CHECK_WIDTYPE(obj, widtype);
2684 Widget_Data *wd = elm_widget_data_get(obj);
2686 _cut(obj, NULL, NULL);
2690 elm_entry_selection_copy(Evas_Object *obj)
2692 ELM_CHECK_WIDTYPE(obj, widtype);
2693 Widget_Data *wd = elm_widget_data_get(obj);
2695 _copy(obj, NULL, NULL);
2699 elm_entry_selection_paste(Evas_Object *obj)
2701 ELM_CHECK_WIDTYPE(obj, widtype);
2702 Widget_Data *wd = elm_widget_data_get(obj);
2704 _paste(obj, NULL, NULL);
2708 elm_entry_context_menu_clear(Evas_Object *obj)
2710 ELM_CHECK_WIDTYPE(obj, widtype);
2711 Widget_Data *wd = elm_widget_data_get(obj);
2712 Elm_Entry_Context_Menu_Item *it;
2714 EINA_LIST_FREE(wd->items, it)
2716 eina_stringshare_del(it->label);
2717 eina_stringshare_del(it->icon_file);
2718 eina_stringshare_del(it->icon_group);
2724 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)
2726 ELM_CHECK_WIDTYPE(obj, widtype);
2727 Widget_Data *wd = elm_widget_data_get(obj);
2728 Elm_Entry_Context_Menu_Item *it;
2730 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2732 wd->items = eina_list_append(wd->items, it);
2734 it->label = eina_stringshare_add(label);
2735 it->icon_file = eina_stringshare_add(icon_file);
2736 it->icon_type = icon_type;
2738 it->data = (void *)data;
2742 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2744 ELM_CHECK_WIDTYPE(obj, widtype);
2745 Widget_Data *wd = elm_widget_data_get(obj);
2747 if (wd->context_menu == !disabled) return;
2748 wd->context_menu = !disabled;
2752 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2754 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2755 Widget_Data *wd = elm_widget_data_get(obj);
2756 if (!wd) return EINA_FALSE;
2757 return !wd->context_menu;
2761 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2763 ELM_CHECK_WIDTYPE(obj, widtype);
2764 Widget_Data *wd = elm_widget_data_get(obj);
2766 EINA_SAFETY_ON_NULL_RETURN(func);
2767 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2771 wd->item_providers = eina_list_append(wd->item_providers, ip);
2775 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2777 ELM_CHECK_WIDTYPE(obj, widtype);
2778 Widget_Data *wd = elm_widget_data_get(obj);
2780 EINA_SAFETY_ON_NULL_RETURN(func);
2781 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2785 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
2789 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2791 ELM_CHECK_WIDTYPE(obj, widtype);
2792 Widget_Data *wd = elm_widget_data_get(obj);
2794 Elm_Entry_Item_Provider *ip;
2796 EINA_SAFETY_ON_NULL_RETURN(func);
2797 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2799 if ((ip->func == func) && ((!data) || (ip->data == data)))
2801 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
2809 elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2812 Elm_Entry_Text_Filter *tf;
2813 ELM_CHECK_WIDTYPE(obj, widtype);
2815 wd = elm_widget_data_get(obj);
2817 EINA_SAFETY_ON_NULL_RETURN(func);
2819 tf = _filter_new(func, data);
2822 wd->text_filters = eina_list_append(wd->text_filters, tf);
2826 elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2829 Elm_Entry_Text_Filter *tf;
2830 ELM_CHECK_WIDTYPE(obj, widtype);
2832 wd = elm_widget_data_get(obj);
2834 EINA_SAFETY_ON_NULL_RETURN(func);
2836 tf = _filter_new(func, data);
2839 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
2843 elm_entry_text_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
2847 Elm_Entry_Text_Filter *tf;
2848 ELM_CHECK_WIDTYPE(obj, widtype);
2850 wd = elm_widget_data_get(obj);
2852 EINA_SAFETY_ON_NULL_RETURN(func);
2854 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2856 if ((tf->func == func) && ((!data) || (tf->data == data)))
2858 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
2866 elm_entry_markup_to_utf8(const char *s)
2868 char *ss = _elm_util_mkup_to_text(s);
2869 if (!ss) ss = strdup("");
2874 elm_entry_utf8_to_markup(const char *s)
2876 char *ss = _elm_util_text_to_mkup(s);
2877 if (!ss) ss = strdup("");
2882 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
2884 Elm_Entry_Filter_Limit_Size *lim = data;
2885 char *current, *utfstr;
2887 const char *(*text_get)(const Evas_Object *);
2888 const char *widget_type;
2890 EINA_SAFETY_ON_NULL_RETURN(data);
2891 EINA_SAFETY_ON_NULL_RETURN(entry);
2892 EINA_SAFETY_ON_NULL_RETURN(text);
2894 /* hack. I don't want to copy the entire function to work with
2896 widget_type = elm_widget_type_get(entry);
2897 if (!strcmp(widget_type, "entry"))
2898 text_get = elm_entry_entry_get;
2902 current = elm_entry_markup_to_utf8(text_get(entry));
2903 utfstr = elm_entry_markup_to_utf8(*text);
2905 if (lim->max_char_count > 0)
2907 len = evas_string_char_len_get(current);
2908 if (len >= lim->max_char_count)
2910 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2917 newlen = evas_string_char_len_get(utfstr);
2918 if ((len + newlen) > lim->max_char_count)
2919 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
2921 else if (lim->max_byte_count > 0)
2923 len = strlen(current);
2924 if (len >= lim->max_byte_count)
2926 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2933 newlen = strlen(utfstr);
2934 if ((len + newlen) > lim->max_byte_count)
2935 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
2942 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
2944 Elm_Entry_Filter_Accept_Set *as = data;
2948 int read_idx, last_read_idx = 0, read_char;
2950 EINA_SAFETY_ON_NULL_RETURN(data);
2951 EINA_SAFETY_ON_NULL_RETURN(text);
2953 if ((!as->accepted) && (!as->rejected))
2959 goes_in = EINA_TRUE;
2964 goes_in = EINA_FALSE;
2968 read_idx = evas_string_char_next_get(*text, 0, &read_char);
2971 int cmp_idx, cmp_char;
2972 Eina_Bool in_set = EINA_FALSE;
2974 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
2977 if (read_char == cmp_char)
2982 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
2984 if (in_set == goes_in)
2986 int size = read_idx - last_read_idx;
2987 const char *src = (*text) + last_read_idx;
2989 memcpy(insert, *text + last_read_idx, size);
2992 last_read_idx = read_idx;
2993 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
2999 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3001 ELM_CHECK_WIDTYPE(obj, widtype);
3002 Widget_Data *wd = elm_widget_data_get(obj);
3004 if (wd->delay_write)
3006 ecore_timer_del(wd->delay_write);
3007 wd->delay_write = NULL;
3009 if (wd->autosave) _save(obj);
3010 eina_stringshare_replace(&wd->file, file);
3011 wd->format = format;
3016 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3018 ELM_CHECK_WIDTYPE(obj, widtype);
3019 Widget_Data *wd = elm_widget_data_get(obj);
3021 if (file) *file = wd->file;
3022 if (format) *format = wd->format;
3026 elm_entry_file_save(Evas_Object *obj)
3028 ELM_CHECK_WIDTYPE(obj, widtype);
3029 Widget_Data *wd = elm_widget_data_get(obj);
3031 if (wd->delay_write)
3033 ecore_timer_del(wd->delay_write);
3034 wd->delay_write = NULL;
3037 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3041 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3043 ELM_CHECK_WIDTYPE(obj, widtype);
3044 Widget_Data *wd = elm_widget_data_get(obj);
3046 wd->autosave = !!autosave;
3050 elm_entry_autosave_get(const Evas_Object *obj)
3052 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3053 Widget_Data *wd = elm_widget_data_get(obj);
3054 if (!wd) return EINA_FALSE;
3055 return wd->autosave;
3059 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3061 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3062 ELM_CHECK_WIDTYPE(obj, widtype);
3063 Widget_Data *wd = elm_widget_data_get(obj);
3065 textonly = !!textonly;
3066 if (wd->textonly == textonly) return;
3067 wd->textonly = !!textonly;
3068 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3069 #ifdef HAVE_ELEMENTARY_X
3070 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3075 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3077 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3078 Widget_Data *wd = elm_widget_data_get(obj);
3079 if (!wd) return EINA_FALSE;
3080 return wd->textonly;
3084 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3086 ELM_CHECK_WIDTYPE(obj, widtype);
3087 Widget_Data *wd = elm_widget_data_get(obj);
3090 if (wd->scroll == scroll) return;
3091 wd->scroll = scroll;
3094 elm_widget_sub_object_del(obj, wd->scroller);
3095 elm_widget_resize_object_set(obj, wd->scroller);
3096 elm_widget_sub_object_add(obj, wd->ent);
3097 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3098 evas_object_show(wd->scroller);
3099 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3103 elm_smart_scroller_child_set(wd->scroller, NULL);
3104 elm_widget_sub_object_del(obj, wd->ent);
3105 elm_widget_resize_object_set(obj, wd->ent);
3106 evas_object_smart_member_add(wd->scroller, obj);
3107 elm_widget_sub_object_add(obj, wd->scroller);
3108 evas_object_hide(wd->scroller);
3109 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3116 elm_entry_scrollable_get(const Evas_Object *obj)
3118 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3119 Widget_Data *wd = elm_widget_data_get(obj);
3120 if (!wd) return EINA_FALSE;
3125 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3127 ELM_CHECK_WIDTYPE(obj, widtype);
3128 EINA_SAFETY_ON_NULL_RETURN(icon);
3129 _content_set_hook(obj, "elm.swallow.icon", icon);
3133 elm_entry_icon_get(const Evas_Object *obj)
3135 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3136 return _content_get_hook(obj, "elm.swallow.icon");
3140 elm_entry_icon_unset(Evas_Object *obj)
3142 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3143 return _content_unset_hook(obj, "elm.swallow.icon");
3147 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3149 ELM_CHECK_WIDTYPE(obj, widtype);
3150 Widget_Data *wd = elm_widget_data_get(obj);
3152 if ((!wd) || (!wd->icon)) return;
3153 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3156 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3158 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3163 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3165 ELM_CHECK_WIDTYPE(obj, widtype);
3166 EINA_SAFETY_ON_NULL_RETURN(end);
3167 _content_set_hook(obj, "elm.swallow.end", end);
3171 elm_entry_end_get(const Evas_Object *obj)
3173 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3174 return _content_get_hook(obj, "elm.swallow.end");
3178 elm_entry_end_unset(Evas_Object *obj)
3180 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3181 return _content_unset_hook(obj, "elm.swallow.end");
3185 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3187 ELM_CHECK_WIDTYPE(obj, widtype);
3188 Widget_Data *wd = elm_widget_data_get(obj);
3190 if ((!wd) || (!wd->end)) return;
3191 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3194 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3196 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3201 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3203 ELM_CHECK_WIDTYPE(obj, widtype);
3204 Widget_Data *wd = elm_widget_data_get(obj);
3205 const Elm_Scroller_Policy map[3] =
3207 ELM_SMART_SCROLLER_POLICY_AUTO,
3208 ELM_SMART_SCROLLER_POLICY_ON,
3209 ELM_SMART_SCROLLER_POLICY_OFF
3214 elm_smart_scroller_policy_set(wd->scroller,
3220 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3222 ELM_CHECK_WIDTYPE(obj, widtype);
3223 Widget_Data *wd = elm_widget_data_get(obj);
3225 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3229 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3231 ELM_CHECK_WIDTYPE(obj, widtype);
3232 Widget_Data *wd = elm_widget_data_get(obj);
3234 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
3238 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3240 ELM_CHECK_WIDTYPE(obj, widtype);
3241 Widget_Data *wd = elm_widget_data_get(obj);
3244 wd->input_panel_layout = layout;
3246 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
3249 EAPI Elm_Input_Panel_Layout
3250 elm_entry_input_panel_layout_get(Evas_Object *obj)
3252 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
3253 Widget_Data *wd = elm_widget_data_get(obj);
3254 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
3256 return wd->input_panel_layout;