1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "els_scroller.h"
7 /* Maximum chunk size to be inserted to the entry at once
8 * FIXME: This size is arbitrary, should probably choose a better size.
9 * Possibly also find a way to set it to a low value for weak computers,
10 * and to a big value for better computers. */
11 #define _CHUNK_SIZE 10000
13 typedef struct _Mod_Api Mod_Api;
15 typedef struct _Widget_Data Widget_Data;
16 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
17 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
18 typedef struct _Elm_Entry_Markup_Filter Elm_Entry_Markup_Filter;
22 Evas_Object *ent, *scroller;
23 Evas_Object *hoversel;
24 Ecore_Job *deferred_recalc_job;
25 Ecore_Event_Handler *sel_notify_handler;
26 Ecore_Event_Handler *sel_clear_handler;
27 Ecore_Timer *longpress_timer;
28 Ecore_Timer *delay_write;
29 /* for deferred appending */
30 Ecore_Idler *append_text_idler;
31 char *append_text_left;
32 int append_text_position;
34 /* Only for clipboard */
38 Elm_Text_Format format;
39 Evas_Coord lastw, entmw, entmh;
40 Evas_Coord downx, downy;
42 Eina_List *item_providers;
43 Eina_List *text_filters;
44 Eina_List *markup_filters;
46 Mod_Api *api; // module api if supplied
48 Elm_Scroller_Policy policy_h, policy_v;
49 Elm_Wrap_Type linewrap;
50 Elm_Input_Panel_Layout input_panel_layout;
51 Elm_Autocapital_Type autocapital_type;
52 Elm_Input_Panel_Lang input_panel_lang;
53 Elm_Input_Panel_Return_Key_Type input_panel_return_key_type;
54 void *input_panel_imdata;
55 int input_panel_imdata_len;
57 Evas_Object *hover_parent;
58 Evas_Object *pop, *hover;
59 const char *hover_style;
61 Eina_Bool changed : 1;
62 Eina_Bool single_line : 1;
63 Eina_Bool password : 1;
64 Eina_Bool editable : 1;
65 Eina_Bool selection_asked : 1;
66 Eina_Bool have_selection : 1;
67 Eina_Bool selmode : 1;
68 Eina_Bool deferred_cur : 1;
69 Eina_Bool cur_changed : 1;
70 Eina_Bool disabled : 1;
71 Eina_Bool context_menu : 1;
72 Eina_Bool drag_selection_asked : 1;
73 Eina_Bool can_write : 1;
74 Eina_Bool autosave : 1;
75 Eina_Bool usedown : 1;
77 Eina_Bool h_bounce : 1;
78 Eina_Bool v_bounce : 1;
79 Eina_Bool input_panel_enable : 1;
80 Eina_Bool prediction_allow : 1;
81 Eina_Bool input_panel_return_key_disabled : 1;
82 Eina_Bool autoreturnkey : 1;
83 Elm_Cnp_Mode cnp_mode : 2;
86 struct _Elm_Entry_Context_Menu_Item
90 const char *icon_file;
91 const char *icon_group;
92 Elm_Icon_Type icon_type;
97 struct _Elm_Entry_Item_Provider
99 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
103 struct _Elm_Entry_Markup_Filter
105 Elm_Entry_Filter_Cb func;
109 typedef enum _Length_Unit
116 static const char *widtype = NULL;
118 #ifdef HAVE_ELEMENTARY_X
119 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
121 static void _del_hook(Evas_Object *obj);
122 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
123 static void _theme_hook(Evas_Object *obj);
124 static void _disable_hook(Evas_Object *obj);
125 static void _sizing_eval(Evas_Object *obj);
126 static void _on_focus_hook(void *data, Evas_Object *obj);
127 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
128 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
129 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
130 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
131 static const char *_getbase(Evas_Object *obj);
132 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
133 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
134 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
135 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
136 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
137 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
138 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
139 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
140 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
141 static void _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info);
143 static const char SIG_CHANGED[] = "changed";
144 static const char SIG_CHANGED_USER[] = "changed,user";
145 static const char SIG_ACTIVATED[] = "activated";
146 static const char SIG_PRESS[] = "press";
147 static const char SIG_LONGPRESSED[] = "longpressed";
148 static const char SIG_CLICKED[] = "clicked";
149 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
150 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
151 static const char SIG_FOCUSED[] = "focused";
152 static const char SIG_UNFOCUSED[] = "unfocused";
153 static const char SIG_SELECTION_PASTE[] = "selection,paste";
154 static const char SIG_SELECTION_COPY[] = "selection,copy";
155 static const char SIG_SELECTION_CUT[] = "selection,cut";
156 static const char SIG_SELECTION_START[] = "selection,start";
157 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
158 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
159 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
160 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
161 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
162 static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened";
163 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
164 static const char SIG_ANCHOR_UP[] = "anchor,up";
165 static const char SIG_ANCHOR_IN[] = "anchor,in";
166 static const char SIG_ANCHOR_OUT[] = "anchor,out";
167 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
168 static const char SIG_UNDO_REQUEST[] = "undo,request";
169 static const char SIG_REDO_REQUEST[] = "redo,request";
170 static const Evas_Smart_Cb_Description _signals[] = {
174 {SIG_LONGPRESSED, ""},
176 {SIG_CLICKED_DOUBLE, ""},
177 {SIG_CLICKED_TRIPLE, ""},
180 {SIG_SELECTION_PASTE, ""},
181 {SIG_SELECTION_COPY, ""},
182 {SIG_SELECTION_CUT, ""},
183 {SIG_SELECTION_START, ""},
184 {SIG_SELECTION_CHANGED, ""},
185 {SIG_SELECTION_CLEARED, ""},
186 {SIG_CURSOR_CHANGED, ""},
187 {SIG_CURSOR_CHANGED_MANUAL, ""},
188 {SIG_ANCHOR_CLICKED, ""},
189 {SIG_ANCHOR_HOVER_OPENED, ""},
190 {SIG_ANCHOR_DOWN, ""},
193 {SIG_ANCHOR_OUT, ""},
194 {SIG_PREEDIT_CHANGED, ""},
195 {SIG_CHANGED_USER, ""},
196 {SIG_UNDO_REQUEST, ""},
197 {SIG_REDO_REQUEST, ""},
201 static Eina_List *entries = NULL;
205 void (*obj_hook) (Evas_Object *obj);
206 void (*obj_unhook) (Evas_Object *obj);
207 void (*obj_longpress) (Evas_Object *obj);
211 _module(Evas_Object *obj __UNUSED__)
213 static Elm_Module *m = NULL;
214 if (m) goto ok; // already found - just use
215 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
217 m->api = malloc(sizeof(Mod_Api));
218 if (!m->api) return NULL;
219 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
220 _elm_module_symbol_get(m, "obj_hook");
221 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
222 _elm_module_symbol_get(m, "obj_unhook");
223 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
224 _elm_module_symbol_get(m, "obj_longpress");
225 ok: // ok - return api
230 _buf_append(char *buf, const char *str, int *len, int *alloc)
232 int len2 = strlen(str);
233 if ((*len + len2) >= *alloc)
235 char *buf2 = realloc(buf, *alloc + len2 + 512);
236 if (!buf2) return NULL;
238 *alloc += (512 + len2);
240 strcpy(buf + *len, str);
246 _load_file(const char *file)
250 int alloc = 0, len = 0;
251 char *text = NULL, buf[16384 + 1];
253 f = fopen(file, "rb");
255 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
259 tmp_text = _buf_append(text, buf, &len, &alloc);
260 if (!tmp_text) break;
268 _load_plain(const char *file)
272 text = _load_file(file);
277 text2 = elm_entry_utf8_to_markup(text);
285 _load(Evas_Object *obj)
287 Widget_Data *wd = elm_widget_data_get(obj);
289 if (!wd) return EINA_FALSE;
292 elm_object_text_set(obj, "");
297 case ELM_TEXT_FORMAT_PLAIN_UTF8:
298 text = _load_plain(wd->file);
300 case ELM_TEXT_FORMAT_MARKUP_UTF8:
301 text = _load_file(wd->file);
309 elm_object_text_set(obj, text);
315 elm_object_text_set(obj, "");
321 _save_markup_utf8(const char *file, const char *text)
325 if ((!text) || (!text[0]))
327 ecore_file_unlink(file);
330 f = fopen(file, "wb");
333 // FIXME: report a write error
336 fputs(text, f); // FIXME: catch error
341 _save_plain_utf8(const char *file, const char *text)
345 text2 = elm_entry_markup_to_utf8(text);
348 _save_markup_utf8(file, text2);
353 _save(Evas_Object *obj)
355 Widget_Data *wd = elm_widget_data_get(obj);
357 if (!wd->file) return;
360 case ELM_TEXT_FORMAT_PLAIN_UTF8:
361 _save_plain_utf8(wd->file, elm_object_text_get(obj));
363 case ELM_TEXT_FORMAT_MARKUP_UTF8:
364 _save_markup_utf8(wd->file, elm_object_text_get(obj));
372 _delay_write(void *data)
374 Widget_Data *wd = elm_widget_data_get(data);
375 if (!wd) return ECORE_CALLBACK_CANCEL;
377 wd->delay_write = NULL;
378 return ECORE_CALLBACK_CANCEL;
381 static Elm_Entry_Markup_Filter *
382 _filter_new(Elm_Entry_Filter_Cb func, void *data)
384 Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
385 if (!tf) return NULL;
388 if (func == elm_entry_filter_limit_size)
390 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
397 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
403 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
406 else if (func == elm_entry_filter_accept_set)
408 Elm_Entry_Filter_Accept_Set *as = data, *as2;
415 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
422 as2->accepted = eina_stringshare_add(as->accepted);
424 as2->accepted = NULL;
426 as2->rejected = eina_stringshare_add(as->rejected);
428 as2->rejected = NULL;
437 _filter_free(Elm_Entry_Markup_Filter *tf)
439 if (tf->func == elm_entry_filter_limit_size)
441 Elm_Entry_Filter_Limit_Size *lim = tf->data;
444 else if (tf->func == elm_entry_filter_accept_set)
446 Elm_Entry_Filter_Accept_Set *as = tf->data;
449 if (as->accepted) eina_stringshare_del(as->accepted);
450 if (as->rejected) eina_stringshare_del(as->rejected);
458 _del_pre_hook(Evas_Object *obj)
460 Widget_Data *wd = elm_widget_data_get(obj);
464 ecore_timer_del(wd->delay_write);
465 wd->delay_write = NULL;
466 if (wd->autosave) _save(obj);
468 elm_entry_anchor_hover_end(obj);
469 elm_entry_anchor_hover_parent_set(obj, NULL);
473 _del_hook(Evas_Object *obj)
475 Widget_Data *wd = elm_widget_data_get(obj);
476 Elm_Entry_Context_Menu_Item *it;
477 Elm_Entry_Item_Provider *ip;
478 Elm_Entry_Markup_Filter *tf;
480 evas_event_freeze(evas_object_evas_get(obj));
482 if (wd->file) eina_stringshare_del(wd->file);
484 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
485 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
487 entries = eina_list_remove(entries, obj);
488 #ifdef HAVE_ELEMENTARY_X
489 if (wd->sel_notify_handler)
490 ecore_event_handler_del(wd->sel_notify_handler);
491 if (wd->sel_clear_handler)
492 ecore_event_handler_del(wd->sel_clear_handler);
494 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
495 if (wd->text) eina_stringshare_del(wd->text);
496 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
497 if (wd->append_text_idler)
499 ecore_idler_del(wd->append_text_idler);
500 free(wd->append_text_left);
501 wd->append_text_left = NULL;
502 wd->append_text_idler = NULL;
504 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
505 EINA_LIST_FREE(wd->items, it)
507 eina_stringshare_del(it->label);
508 eina_stringshare_del(it->icon_file);
509 eina_stringshare_del(it->icon_group);
512 EINA_LIST_FREE(wd->item_providers, ip)
516 EINA_LIST_FREE(wd->text_filters, tf)
520 EINA_LIST_FREE(wd->markup_filters, tf)
524 if (wd->delay_write) ecore_timer_del(wd->delay_write);
525 if (wd->input_panel_imdata) free(wd->input_panel_imdata);
528 if (wd->anchor_hover.hover_style) eina_stringshare_del(wd->anchor_hover.hover_style);
529 evas_event_thaw(evas_object_evas_get(obj));
530 evas_event_thaw_eval(evas_object_evas_get(obj));
534 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
536 Widget_Data *wd = elm_widget_data_get(obj);
537 edje_object_mirrored_set(wd->ent, rtl);
538 if (wd->anchor_hover.hover)
539 elm_widget_mirrored_set(wd->anchor_hover.hover, rtl);
543 _theme_hook(Evas_Object *obj)
545 Widget_Data *wd = elm_widget_data_get(obj);
548 evas_event_freeze(evas_object_evas_get(obj));
549 _elm_widget_mirrored_reload(obj);
550 _mirrored_set(obj, elm_widget_mirrored_get(obj));
552 t = eina_stringshare_add(elm_object_text_get(obj));
553 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
554 if (_elm_config->desktop_entry)
555 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
556 elm_object_text_set(obj, t);
557 eina_stringshare_del(t);
558 if (elm_widget_disabled_get(obj))
559 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
560 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
561 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
562 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", wd->prediction_allow);
563 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
564 edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len);
565 edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", wd->input_panel_return_key_type);
566 edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", wd->input_panel_return_key_disabled);
568 if (wd->cursor_pos != 0)
569 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
570 if (elm_widget_focus_get(obj))
571 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
572 edje_object_message_signal_process(wd->ent);
573 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
579 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
580 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
581 elm_widget_style_get(obj));
582 edj = elm_smart_scroller_edje_object_get(wd->scroller);
583 str = edje_object_data_get(edj, "focus_highlight");
584 if ((str) && (!strcmp(str, "on")))
585 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
587 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
590 evas_event_thaw(evas_object_evas_get(obj));
591 evas_event_thaw_eval(evas_object_evas_get(obj));
595 _disable_hook(Evas_Object *obj)
597 Widget_Data *wd = elm_widget_data_get(obj);
599 if (elm_widget_disabled_get(obj))
601 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
602 wd->disabled = EINA_TRUE;
606 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
607 wd->disabled = EINA_FALSE;
612 _recalc_cursor_geometry(Evas_Object *obj)
614 Widget_Data *wd = elm_widget_data_get(obj);
616 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
617 if (!wd->deferred_recalc_job)
619 Evas_Coord cx, cy, cw, ch;
620 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
624 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
625 wd->cur_changed = EINA_FALSE;
629 wd->deferred_cur = EINA_TRUE;
633 _elm_deferred_recalc_job(void *data)
635 Widget_Data *wd = elm_widget_data_get(data);
636 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
638 wd->deferred_recalc_job = NULL;
640 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
641 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
642 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
643 /* This is a hack to workaround the way min size hints are treated.
644 * If the minimum width is smaller than the restricted width, it means
645 * the mininmum doesn't matter. */
648 Evas_Coord ominw = -1;
649 evas_object_size_hint_min_get(data, &ominw, NULL);
656 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
659 Evas_Coord vmw = 0, vmh = 0;
661 edje_object_size_min_calc
662 (elm_smart_scroller_edje_object_get(wd->scroller),
666 evas_object_size_hint_min_set(data, vmw, minh + vmh);
667 evas_object_size_hint_max_set(data, -1, minh + vmh);
671 evas_object_size_hint_min_set(data, vmw, vmh);
672 evas_object_size_hint_max_set(data, -1, -1);
679 evas_object_size_hint_min_set(data, minw, minh);
680 evas_object_size_hint_max_set(data, -1, minh);
684 evas_object_size_hint_min_set(data, fw, minh);
685 evas_object_size_hint_max_set(data, -1, -1);
689 if (wd->deferred_cur)
691 Evas_Coord cx, cy, cw, ch;
692 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
696 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
697 wd->cur_changed = EINA_FALSE;
703 _sizing_eval(Evas_Object *obj)
705 Widget_Data *wd = elm_widget_data_get(obj);
706 Evas_Coord minw = -1, minh = -1;
707 Evas_Coord resw, resh;
710 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
713 if ((resw == wd->lastw) && (!wd->changed)) return;
714 evas_event_freeze(evas_object_evas_get(obj));
715 wd->changed = EINA_FALSE;
719 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
721 evas_object_resize(wd->scroller, resw, resh);
722 edje_object_size_min_calc
723 (elm_smart_scroller_edje_object_get(wd->scroller),
725 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
726 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
727 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
728 /* This is a hack to workaround the way min size hints are treated.
729 * If the minimum width is smaller than the restricted width, it means
730 * the mininmum doesn't matter. */
733 Evas_Coord ominw = -1;
734 evas_object_size_hint_min_get(wd->ent, &ominw, NULL);
740 if ((minw > 0) && (vw < minw)) vw = minw;
741 if (minh > vh) vh = minh;
743 if (wd->single_line) h = vmh + minh;
745 evas_object_resize(wd->ent, vw, vh);
746 evas_object_size_hint_min_set(obj, w, h);
748 evas_object_size_hint_max_set(obj, -1, h);
750 evas_object_size_hint_max_set(obj, -1, -1);
754 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
755 wd->deferred_recalc_job = ecore_job_add(_elm_deferred_recalc_job, obj);
757 evas_event_thaw(evas_object_evas_get(obj));
758 evas_event_thaw_eval(evas_object_evas_get(obj));
762 if (!wd->changed) return;
763 evas_event_freeze(evas_object_evas_get(obj));
764 wd->changed = EINA_FALSE;
768 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
770 edje_object_size_min_calc(wd->ent, &minw, &minh);
773 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
775 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
777 if (minw > vw) vw = minw;
778 if (minh > vh) vh = minh;
780 evas_object_resize(wd->ent, vw, vh);
781 edje_object_size_min_calc
782 (elm_smart_scroller_edje_object_get(wd->scroller),
784 if (wd->single_line) h = vmh + minh;
786 evas_object_size_hint_min_set(obj, w, h);
788 evas_object_size_hint_max_set(obj, -1, h);
790 evas_object_size_hint_max_set(obj, -1, -1);
794 edje_object_size_min_calc(wd->ent, &minw, &minh);
797 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
798 evas_object_size_hint_min_set(obj, minw, minh);
800 evas_object_size_hint_max_set(obj, -1, minh);
802 evas_object_size_hint_max_set(obj, -1, -1);
804 evas_event_thaw(evas_object_evas_get(obj));
805 evas_event_thaw_eval(evas_object_evas_get(obj));
808 _recalc_cursor_geometry(obj);
812 _check_enable_return_key(Evas_Object *obj)
814 Widget_Data *wd = elm_widget_data_get(obj);
815 Eina_Bool return_key_disabled = EINA_FALSE;
818 if (!wd->autoreturnkey) return;
820 if (elm_entry_is_empty(obj) == EINA_TRUE)
821 return_key_disabled = EINA_TRUE;
823 elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
827 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
829 Widget_Data *wd = elm_widget_data_get(obj);
830 Evas_Object *top = elm_widget_top_get(obj);
832 if (!wd->editable) return;
833 if (elm_widget_focus_get(obj))
835 evas_object_focus_set(wd->ent, EINA_TRUE);
836 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
837 if (top && wd->input_panel_enable)
838 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
839 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
840 _check_enable_return_key(obj);
844 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
845 evas_object_focus_set(wd->ent, EINA_FALSE);
846 if (top && wd->input_panel_enable)
847 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
848 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
853 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
855 Widget_Data *wd = elm_widget_data_get(obj);
857 if ((!wd) || (!content)) return;
860 edje = elm_smart_scroller_edje_object_get(wd->scroller);
864 /* Delete the currently swallowed object */
865 Evas_Object *cswallow;
867 if (!part || !strcmp(part, "icon"))
869 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon");
870 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
872 else if (!strcmp(part, "end"))
874 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end");
875 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
878 cswallow = edje_object_part_swallow_get(edje, part);
880 if (cswallow) evas_object_del(cswallow);
882 evas_event_freeze(evas_object_evas_get(obj));
883 elm_widget_sub_object_add(obj, content);
885 if (!part || !strcmp(part, "icon"))
886 edje_object_part_swallow(edje, "elm.swallow.icon", content);
887 else if (!strcmp(part, "end"))
888 edje_object_part_swallow(edje, "elm.swallow.end", content);
890 edje_object_part_swallow(edje, part, content);
893 evas_event_thaw(evas_object_evas_get(obj));
894 evas_event_thaw_eval(evas_object_evas_get(obj));
898 _content_unset_hook(Evas_Object *obj, const char *part)
900 Widget_Data *wd = elm_widget_data_get(obj);
901 Evas_Object *content, *edje;
902 if (!wd) return NULL;
905 edje = elm_smart_scroller_edje_object_get(wd->scroller);
909 if (!part || !strcmp(part, "icon"))
911 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
912 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
914 else if (!strcmp(part, "end"))
916 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
917 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
920 content = edje_object_part_swallow_get(edje, part);
922 edje_object_part_swallow(edje, part, NULL);
923 if (!content) return NULL;
924 evas_event_freeze(evas_object_evas_get(obj));
925 elm_widget_sub_object_del(obj, content);
926 edje_object_part_unswallow(wd->ent, content);
928 evas_event_thaw(evas_object_evas_get(obj));
929 evas_event_thaw_eval(evas_object_evas_get(obj));
935 _content_get_hook(const Evas_Object *obj, const char *part)
937 Widget_Data *wd = elm_widget_data_get(obj);
938 Evas_Object *content = NULL, *edje;
939 if (!wd) return NULL;
942 edje = elm_smart_scroller_edje_object_get(wd->scroller);
946 if (!edje) return NULL;
948 if (!part || !strcmp(part, "icon"))
949 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
950 else if (!strcmp(part, "end"))
951 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
953 content = edje_object_part_swallow_get(edje, part);
959 _translate_hook(Evas_Object *obj)
961 evas_object_smart_callback_call(obj, "language,changed", NULL);
965 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
967 Widget_Data *wd = elm_widget_data_get(obj);
969 edje_object_signal_emit(wd->ent, emission, source);
971 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
976 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
978 Widget_Data *wd = elm_widget_data_get(obj);
980 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
982 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
983 emission, source, func_cb, data);
987 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
989 Widget_Data *wd = elm_widget_data_get(obj);
990 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
993 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
994 emission, source, func_cb, data);
998 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1000 Widget_Data *wd = elm_widget_data_get(obj);
1001 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
1005 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1007 Widget_Data *wd = elm_widget_data_get(obj);
1009 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1013 _show_region_hook(void *data, Evas_Object *obj)
1015 Widget_Data *wd = elm_widget_data_get(data);
1016 Evas_Coord x, y, w, h;
1018 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1020 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1024 _sub_del(void *data, Evas_Object *obj, void *event_info)
1026 Widget_Data *wd = data;
1027 Evas_Object *sub = event_info;
1031 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1035 if (sub == edje_object_part_swallow_get(edje, "elm.swallow.icon"))
1037 edje_object_part_unswallow(edje, sub);
1039 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1041 else if (sub == edje_object_part_swallow_get(edje, "elm.swallow.end"))
1043 edje_object_part_unswallow(edje, sub);
1045 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1051 _hoversel_position(Evas_Object *obj)
1053 Widget_Data *wd = elm_widget_data_get(obj);
1054 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1059 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1068 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1069 &cx, &cy, &cw, &ch);
1070 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1073 cx += (cw - mw) / 2;
1078 cy += (ch - mh) / 2;
1081 evas_object_move(wd->hoversel, x + cx, y + cy);
1082 evas_object_resize(wd->hoversel, cw, ch);
1086 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1088 Widget_Data *wd = elm_widget_data_get(data);
1090 if (wd->hoversel) _hoversel_position(data);
1094 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1096 Widget_Data *wd = elm_widget_data_get(data);
1103 else if (wd->scroll)
1105 Evas_Coord vw = 0, vh = 0;
1107 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1108 if (vw < wd->entmw) vw = wd->entmw;
1109 if (vh < wd->entmh) vh = wd->entmh;
1110 evas_object_resize(wd->ent, vw, vh);
1112 if (wd->hoversel) _hoversel_position(data);
1116 _hover_del(void *data)
1118 Widget_Data *wd = elm_widget_data_get(data);
1123 evas_object_del(wd->hoversel);
1124 wd->hoversel = NULL;
1126 wd->hovdeljob = NULL;
1130 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1132 Widget_Data *wd = elm_widget_data_get(data);
1135 if (wd->hoversel) evas_object_hide(wd->hoversel);
1138 if (!_elm_config->desktop_entry)
1141 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1144 elm_widget_scroll_freeze_pop(data);
1145 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1146 wd->hovdeljob = ecore_job_add(_hover_del, data);
1150 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1152 Widget_Data *wd = elm_widget_data_get(data);
1154 wd->selmode = EINA_TRUE;
1155 edje_object_part_text_select_none(wd->ent, "elm.text");
1156 if (!_elm_config->desktop_entry)
1159 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1161 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1162 if (!_elm_config->desktop_entry)
1163 elm_widget_scroll_hold_push(data);
1167 _remove_item_tags(const char *str)
1173 Eina_Strbuf *buf = eina_strbuf_new();
1177 if (!eina_strbuf_append(buf, str))
1182 const char *temp = eina_strbuf_string_get(buf);
1184 char *startTag = NULL;
1185 char *endTag = NULL;
1187 startTag = strstr(temp, "<item");
1189 startTag = strstr(temp, "</item");
1191 endTag = strstr(startTag, ">");
1194 if (!endTag || startTag > endTag)
1197 size_t sindex = startTag - temp;
1198 size_t eindex = endTag - temp + 1;
1199 if (!eina_strbuf_remove(buf, sindex, eindex))
1202 ret = eina_strbuf_string_steal(buf);
1203 eina_strbuf_free(buf);
1208 _elm_entry_entry_paste(Evas_Object *obj, const char *entry)
1210 Widget_Data *wd = elm_widget_data_get(obj);
1213 if (wd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
1215 str = _remove_item_tags(entry);
1216 if (!str) str = strdup(entry);
1219 str = strdup(entry);
1220 if (!str) str = (char *)entry;
1222 edje_object_part_text_user_insert(wd->ent, "elm.text", str);
1223 if (str != entry) free(str);
1227 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1229 Widget_Data *wd = elm_widget_data_get(data);
1231 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1232 if (wd->sel_notify_handler)
1234 #ifdef HAVE_ELEMENTARY_X
1235 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1236 wd->selection_asked = EINA_TRUE;
1237 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1238 formats = ELM_SEL_FORMAT_TEXT;
1239 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1240 formats |= ELM_SEL_FORMAT_IMAGE;
1241 elm_cnp_selection_get(data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1247 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1249 Widget_Data *wd = elm_widget_data_get(obj);
1253 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1254 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1255 elm_cnp_selection_set(obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1256 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1257 eina_stringshare_replace(&wd->cut_sel, sel);
1261 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1263 Widget_Data *wd = elm_widget_data_get(data);
1266 wd->selmode = EINA_FALSE;
1267 if (!_elm_config->desktop_entry)
1268 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1269 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1270 if (!_elm_config->desktop_entry)
1271 elm_widget_scroll_hold_pop(data);
1272 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1273 edje_object_part_text_user_insert(wd->ent, "elm.text", "");
1278 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1280 Widget_Data *wd = elm_widget_data_get(data);
1282 wd->selmode = EINA_FALSE;
1283 if (!_elm_config->desktop_entry)
1285 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1286 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1287 elm_widget_scroll_hold_pop(data);
1289 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1290 // edje_object_part_text_select_none(wd->ent, "elm.text");
1294 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1296 Widget_Data *wd = elm_widget_data_get(data);
1298 wd->selmode = EINA_FALSE;
1299 if (!_elm_config->desktop_entry)
1300 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1301 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1302 if (!_elm_config->desktop_entry)
1303 elm_widget_scroll_hold_pop(data);
1304 edje_object_part_text_select_none(wd->ent, "elm.text");
1308 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1310 Elm_Entry_Context_Menu_Item *it = data;
1311 Evas_Object *obj2 = it->obj;
1312 if (it->func) it->func(it->data, obj2, NULL);
1316 _menu_press(Evas_Object *obj)
1318 Widget_Data *wd = elm_widget_data_get(obj);
1321 const Elm_Entry_Context_Menu_Item *it;
1323 if ((wd->api) && (wd->api->obj_longpress))
1325 wd->api->obj_longpress(obj);
1327 else if (wd->context_menu)
1329 const char *context_menu_orientation;
1331 if (wd->hoversel) evas_object_del(wd->hoversel);
1332 else elm_widget_scroll_freeze_push(obj);
1333 wd->hoversel = elm_hoversel_add(obj);
1334 context_menu_orientation = edje_object_data_get
1335 (wd->ent, "context_menu_orientation");
1336 if ((context_menu_orientation) &&
1337 (!strcmp(context_menu_orientation, "horizontal")))
1338 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1339 elm_object_style_set(wd->hoversel, "entry");
1340 elm_widget_sub_object_add(obj, wd->hoversel);
1341 elm_object_text_set(wd->hoversel, "Text");
1342 top = elm_widget_top_get(obj);
1343 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1344 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1345 if (wd->have_selection)
1349 if (wd->have_selection)
1351 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1354 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1357 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1365 if (!_elm_config->desktop_entry)
1368 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1371 if (elm_selection_selection_has_owner())
1374 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1379 EINA_LIST_FOREACH(wd->items, l, it)
1381 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1382 it->icon_type, _item_clicked, it);
1386 _hoversel_position(obj);
1387 evas_object_show(wd->hoversel);
1388 elm_hoversel_hover_begin(wd->hoversel);
1390 if (!_elm_config->desktop_entry)
1392 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1393 edje_object_part_text_select_abort(wd->ent, "elm.text");
1399 _long_press(void *data)
1401 Widget_Data *wd = elm_widget_data_get(data);
1402 if (!wd) return ECORE_CALLBACK_CANCEL;
1404 wd->longpress_timer = NULL;
1405 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1406 return ECORE_CALLBACK_CANCEL;
1410 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1412 Widget_Data *wd = elm_widget_data_get(data);
1413 Evas_Event_Mouse_Down *ev = event_info;
1415 if (wd->disabled) return;
1416 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1417 wd->downx = ev->canvas.x;
1418 wd->downy = ev->canvas.y;
1419 if (ev->button == 1)
1421 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1422 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1427 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1429 Widget_Data *wd = elm_widget_data_get(data);
1430 Evas_Event_Mouse_Up *ev = event_info;
1432 if (wd->disabled) return;
1433 if (ev->button == 1)
1435 if (wd->longpress_timer)
1437 ecore_timer_del(wd->longpress_timer);
1438 wd->longpress_timer = NULL;
1441 else if (ev->button == 3)
1449 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1451 Widget_Data *wd = elm_widget_data_get(data);
1452 Evas_Event_Mouse_Move *ev = event_info;
1454 if (wd->disabled) return;
1457 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1459 if (wd->longpress_timer)
1461 ecore_timer_del(wd->longpress_timer);
1462 wd->longpress_timer = NULL;
1465 else if (wd->longpress_timer)
1469 dx = wd->downx - ev->cur.canvas.x;
1471 dy = wd->downy - ev->cur.canvas.y;
1474 ((_elm_config->finger_size / 2) *
1475 (_elm_config->finger_size / 2)))
1477 ecore_timer_del(wd->longpress_timer);
1478 wd->longpress_timer = NULL;
1482 else if (wd->longpress_timer)
1486 dx = wd->downx - ev->cur.canvas.x;
1488 dy = wd->downy - ev->cur.canvas.y;
1491 ((_elm_config->finger_size / 2) *
1492 (_elm_config->finger_size / 2)))
1494 ecore_timer_del(wd->longpress_timer);
1495 wd->longpress_timer = NULL;
1501 _getbase(Evas_Object *obj)
1503 Widget_Data *wd = elm_widget_data_get(obj);
1504 if (!wd) return "base";
1507 if (wd->password) return "base-password";
1510 if (wd->single_line) return "base-single";
1513 switch (wd->linewrap)
1516 return "base-charwrap";
1519 case ELM_WRAP_MIXED:
1520 return "base-mixedwrap";
1523 return "base-nowrap";
1530 if (wd->password) return "base-password";
1533 if (wd->single_line) return "base-single-noedit";
1536 switch (wd->linewrap)
1539 return "base-noedit-charwrap";
1541 return "base-noedit";
1542 case ELM_WRAP_MIXED:
1543 return "base-noedit-mixedwrap";
1546 return "base-nowrap-noedit";
1554 _entry_changed_common_handling(void *data, const char *event)
1556 Widget_Data *wd = elm_widget_data_get(data);
1559 evas_event_freeze(evas_object_evas_get(data));
1560 wd->changed = EINA_TRUE;
1561 /* Reset the size hints which are no more relevant.
1562 * Keep the height, this is a hack, but doesn't really matter
1563 * cause we'll re-eval in a moment. */
1564 evas_object_size_hint_min_get(data, NULL, &minh);
1565 evas_object_size_hint_min_set(data, -1, minh);
1567 if (wd->text) eina_stringshare_del(wd->text);
1569 if (wd->delay_write)
1571 ecore_timer_del(wd->delay_write);
1572 wd->delay_write = NULL;
1574 evas_event_thaw(evas_object_evas_get(data));
1575 evas_event_thaw_eval(evas_object_evas_get(data));
1576 if ((wd->autosave) && (wd->file))
1577 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1578 /* callback - this could call callbacks that delete the entry... thus...
1579 * any access to wd after this could be invalid */
1580 evas_object_smart_callback_call(data, event, NULL);
1581 _check_enable_return_key(data);
1585 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1587 _entry_changed_common_handling(data, SIG_CHANGED);
1591 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1593 Elm_Entry_Change_Info info;
1594 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
1595 edje_object_signal_callback_extra_data_get();
1598 memcpy(&info, edje_info, sizeof(info));
1599 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
1603 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
1608 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1610 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1614 _signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1616 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
1620 _signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1622 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
1626 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1628 Widget_Data *wd = elm_widget_data_get(data);
1632 EINA_LIST_FOREACH(entries, l, entry)
1634 if (entry != data) elm_entry_select_none(entry);
1636 wd->have_selection = EINA_TRUE;
1637 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1638 #ifdef HAVE_ELEMENTARY_X
1639 if (wd->sel_notify_handler)
1641 const char *txt = elm_entry_selection_get(data);
1644 top = elm_widget_top_get(data);
1645 if (txt && top && (elm_win_xwindow_get(top)))
1646 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
1647 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
1653 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1655 Widget_Data *wd = elm_widget_data_get(data);
1657 elm_entry_select_all(data);
1661 _signal_selection_none(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1663 Widget_Data *wd = elm_widget_data_get(data);
1665 elm_entry_select_none(data);
1669 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1671 Widget_Data *wd = elm_widget_data_get(data);
1673 wd->have_selection = EINA_TRUE;
1674 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1675 _store_selection(ELM_SEL_TYPE_PRIMARY, data);
1679 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1681 Widget_Data *wd = elm_widget_data_get(data);
1683 if (!wd->have_selection) return;
1684 wd->have_selection = EINA_FALSE;
1685 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1686 if (wd->sel_notify_handler)
1690 #ifdef HAVE_ELEMENTARY_X
1693 top = elm_widget_top_get(data);
1694 if ((top) && (elm_win_xwindow_get(top)))
1695 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
1696 ELM_SEL_FORMAT_MARKUP, wd->cut_sel,
1697 strlen(wd->cut_sel));
1699 eina_stringshare_del(wd->cut_sel);
1704 #ifdef HAVE_ELEMENTARY_X
1707 top = elm_widget_top_get(data);
1708 if ((top) && (elm_win_xwindow_get(top)))
1709 elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
1716 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1718 Widget_Data *wd = elm_widget_data_get(data);
1719 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
1720 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
1722 if (!wd->editable) return;
1723 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1724 if (wd->sel_notify_handler)
1726 #ifdef HAVE_ELEMENTARY_X
1729 top = elm_widget_top_get(data);
1730 if ((top) && (elm_win_xwindow_get(top)))
1732 wd->selection_asked = EINA_TRUE;
1733 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1734 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1735 formats = ELM_SEL_FORMAT_TEXT;
1736 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1737 formats |= ELM_SEL_FORMAT_IMAGE;
1738 elm_cnp_selection_get(data, type, formats,
1746 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1748 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1749 _copy(data, NULL, NULL);
1753 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1755 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1756 _cut(data, NULL, NULL);
1760 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1762 Widget_Data *wd = elm_widget_data_get(data);
1764 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1765 wd->cur_changed = EINA_TRUE;
1766 _recalc_cursor_geometry(data);
1770 _signal_cursor_changed_manual(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1772 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
1777 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
1779 const Eina_List *geoms, *l;
1780 Evas_Textblock_Rectangle *r;
1781 Evas_Coord px, py, x, y;
1783 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
1787 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1788 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1789 EINA_LIST_FOREACH(geoms, l, r)
1791 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1792 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1804 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1806 Widget_Data *wd = elm_widget_data_get(data);
1807 Elm_Entry_Anchor_Info ei;
1811 p = emission + sizeof("nchor,mouse,down,");
1812 ei.button = strtol(p, &p2, 10);
1814 ei.x = ei.y = ei.w = ei.h = 0;
1816 _signal_anchor_geoms_do_things_with(wd, &ei);
1819 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
1823 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1825 Widget_Data *wd = elm_widget_data_get(data);
1826 Elm_Entry_Anchor_Info ei;
1830 p = emission + sizeof("nchor,mouse,up,");
1831 ei.button = strtol(p, &p2, 10);
1833 ei.x = ei.y = ei.w = ei.h = 0;
1835 _signal_anchor_geoms_do_things_with(wd, &ei);
1838 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
1842 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1844 Widget_Data *wd = elm_widget_data_get(data);
1845 Elm_Entry_Anchor_Info ei;
1849 p = emission + sizeof("nchor,mouse,clicked,");
1850 ei.button = strtol(p, &p2, 10);
1852 ei.x = ei.y = ei.w = ei.h = 0;
1854 _signal_anchor_geoms_do_things_with(wd, &ei);
1858 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1860 _entry_hover_anchor_clicked(data, data, &ei);
1865 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1867 Widget_Data *wd = elm_widget_data_get(data);
1872 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1874 Widget_Data *wd = elm_widget_data_get(data);
1875 Elm_Entry_Anchor_Info ei;
1877 ei.name = emission + sizeof("nchor,mouse,in,");
1879 ei.x = ei.y = ei.w = ei.h = 0;
1881 _signal_anchor_geoms_do_things_with(wd, &ei);
1884 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
1888 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1890 Widget_Data *wd = elm_widget_data_get(data);
1891 Elm_Entry_Anchor_Info ei;
1893 ei.name = emission + sizeof("nchor,mouse,out,");
1895 ei.x = ei.y = ei.w = ei.h = 0;
1897 _signal_anchor_geoms_do_things_with(wd, &ei);
1900 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
1904 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1906 Widget_Data *wd = elm_widget_data_get(data);
1908 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1912 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1914 Widget_Data *wd = elm_widget_data_get(data);
1916 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1920 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1922 Widget_Data *wd = elm_widget_data_get(data);
1924 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1928 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1930 Widget_Data *wd = elm_widget_data_get(data);
1932 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1936 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1938 Widget_Data *wd = elm_widget_data_get(data);
1940 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
1943 #ifdef HAVE_ELEMENTARY_X
1945 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1947 Widget_Data *wd = elm_widget_data_get(data);
1948 Ecore_X_Event_Selection_Notify *ev = event;
1949 if (!wd) return ECORE_CALLBACK_PASS_ON;
1950 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1951 return ECORE_CALLBACK_PASS_ON;
1953 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1954 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1956 Ecore_X_Selection_Data_Text *text_data;
1958 text_data = ev->data;
1959 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1961 if (text_data->text)
1963 char *txt = _elm_util_text_to_mkup(text_data->text);
1967 elm_entry_entry_insert(data, txt);
1972 wd->selection_asked = EINA_FALSE;
1974 else if (ev->selection == ECORE_X_SELECTION_XDND)
1976 Ecore_X_Selection_Data_Text *text_data;
1978 text_data = ev->data;
1979 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1981 if (text_data->text)
1983 char *txt = _elm_util_text_to_mkup(text_data->text);
1987 /* Massive FIXME: this should be at the drag point */
1988 elm_entry_entry_insert(data, txt);
1993 wd->drag_selection_asked = EINA_FALSE;
1995 ecore_x_dnd_send_finished();
1998 return ECORE_CALLBACK_PASS_ON;
2002 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2004 Widget_Data *wd = elm_widget_data_get(data);
2005 Ecore_X_Event_Selection_Clear *ev = event;
2006 if (!wd) return ECORE_CALLBACK_PASS_ON;
2007 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2008 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2009 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2011 elm_entry_select_none(data);
2013 return ECORE_CALLBACK_PASS_ON;
2017 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2022 wd = elm_widget_data_get(obj);
2023 if (!wd) return EINA_FALSE;
2024 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2026 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2027 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2028 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2029 EDJE_CURSOR_MAIN,drop->x,drop->y);
2030 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2031 elm_entry_entry_insert(obj, drop->data);
2032 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2033 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2039 static Evas_Object *
2040 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2042 Widget_Data *wd = elm_widget_data_get(data);
2045 Elm_Entry_Item_Provider *ip;
2047 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2049 o = ip->func(ip->data, data, item);
2052 if (!strncmp(item, "file://", 7))
2054 const char *fname = item + 7;
2056 o = evas_object_image_filled_add(evas_object_evas_get(data));
2057 evas_object_image_file_set(o, fname, NULL);
2058 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2060 evas_object_show(o);
2065 o = edje_object_add(evas_object_evas_get(data));
2066 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2070 o = edje_object_add(evas_object_evas_get(data));
2071 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2072 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2077 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2079 Widget_Data *wd = elm_widget_data_get(data);
2081 Elm_Entry_Markup_Filter *tf;
2083 if (type == EDJE_TEXT_FILTER_FORMAT)
2086 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2088 tf->func(tf->data, data, text);
2095 _markup_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, char **text)
2097 Widget_Data *wd = elm_widget_data_get(data);
2099 Elm_Entry_Markup_Filter *tf;
2101 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
2103 tf->func(tf->data, data, text);
2109 /* This function is used to insert text by chunks in jobs */
2111 _text_append_idler(void *data)
2115 Evas_Object *obj = (Evas_Object *) data;
2116 Widget_Data *wd = elm_widget_data_get(obj);
2117 evas_event_freeze(evas_object_evas_get(obj));
2118 if (wd->text) eina_stringshare_del(wd->text);
2120 wd->changed = EINA_TRUE;
2122 start = wd->append_text_position;
2123 if (start + _CHUNK_SIZE < wd->append_text_len)
2126 int tag_start, esc_start;
2128 tag_start = esc_start = -1;
2129 /* Find proper markup cut place */
2130 while (pos - start < _CHUNK_SIZE)
2134 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2135 if (esc_start == -1)
2138 tag_start = prev_pos;
2139 else if (tmp == '>')
2142 if (tag_start == -1)
2145 esc_start = prev_pos;
2146 else if (tmp == ';')
2153 wd->append_text_position = tag_start;
2155 else if (esc_start >= 0)
2157 wd->append_text_position = esc_start;
2161 wd->append_text_position = pos;
2166 wd->append_text_position = wd->append_text_len;
2169 backup = wd->append_text_left[wd->append_text_position];
2170 wd->append_text_left[wd->append_text_position] = '\0';
2172 edje_object_part_text_append(wd->ent, "elm.text",
2173 wd->append_text_left + start);
2175 wd->append_text_left[wd->append_text_position] = backup;
2177 evas_event_thaw(evas_object_evas_get(obj));
2178 evas_event_thaw_eval(evas_object_evas_get(obj));
2180 /* If there's still more to go, renew the idler, else, cleanup */
2181 if (wd->append_text_position < wd->append_text_len)
2183 return ECORE_CALLBACK_RENEW;
2187 free(wd->append_text_left);
2188 wd->append_text_left = NULL;
2189 wd->append_text_idler = NULL;
2190 return ECORE_CALLBACK_CANCEL;
2195 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2197 int i = 0, current_len = 0;
2201 if (unit >= LENGTH_UNIT_LAST) return;
2203 current_len = strlen(*text);
2206 int idx = 0, unit_size = 0;
2207 char *markup, *utfstr;
2208 if (*new_text == '<')
2210 while (*(new_text + idx) != '>')
2213 if (!*(new_text + idx)) break;
2216 else if (*new_text == '&')
2218 while (*(new_text + idx) != ';')
2221 if (!*(new_text + idx)) break;
2224 idx = evas_string_char_next_get(new_text, idx, NULL);
2225 markup = malloc(idx + 1);
2228 strncpy(markup, new_text, idx);
2230 utfstr = elm_entry_markup_to_utf8(markup);
2233 if (unit == LENGTH_UNIT_BYTE)
2234 unit_size = strlen(utfstr);
2235 else if (unit == LENGTH_UNIT_CHAR)
2236 unit_size = evas_string_char_len_get(utfstr);
2243 if (can_add < unit_size)
2247 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2253 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2255 (*text)[current_len] = 0;
2260 can_add -= unit_size;
2264 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2268 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2271 ELM_CHECK_WIDTYPE(obj, widtype);
2272 Widget_Data *wd = elm_widget_data_get(obj);
2274 evas_event_freeze(evas_object_evas_get(obj));
2275 if (!entry) entry = "";
2276 if (item && strcmp(item, "default"))
2278 edje_object_part_text_set(wd->ent, item, entry);
2282 if (wd->text) eina_stringshare_del(wd->text);
2284 wd->changed = EINA_TRUE;
2286 /* Clear currently pending job if there is one */
2287 if (wd->append_text_idler)
2289 ecore_idler_del(wd->append_text_idler);
2290 free(wd->append_text_left);
2291 wd->append_text_left = NULL;
2292 wd->append_text_idler = NULL;
2295 len = strlen(entry);
2296 /* Split to ~_CHUNK_SIZE chunks */
2297 if (len > _CHUNK_SIZE)
2299 wd->append_text_left = (char *) malloc(len + 1);
2302 /* If we decided to use the idler */
2303 if (wd->append_text_left)
2305 /* Need to clear the entry first */
2306 edje_object_part_text_set(wd->ent, "elm.text", "");
2307 memcpy(wd->append_text_left, entry, len + 1);
2308 wd->append_text_position = 0;
2309 wd->append_text_len = len;
2310 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2314 edje_object_part_text_set(wd->ent, "elm.text", entry);
2316 evas_event_thaw(evas_object_evas_get(obj));
2317 evas_event_thaw_eval(evas_object_evas_get(obj));
2321 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2323 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2324 Widget_Data *wd = elm_widget_data_get(obj);
2325 if (item && strcmp(item, "default")) return NULL;
2327 if (!wd) return NULL;
2328 if (wd->text) return wd->text;
2329 text = edje_object_part_text_get(wd->ent, "elm.text");
2332 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2336 if (wd->append_text_len > 0)
2340 tlen = strlen(text);
2341 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2344 ERR("Failed to allocate memory for entry's text %p", obj);
2347 memcpy(tmpbuf, text, tlen);
2348 memcpy(tmpbuf + tlen, wd->append_text_left, wd->append_text_len);
2349 tmpbuf[tlen + wd->append_text_len] = '\0';
2350 eina_stringshare_replace(&wd->text, tmpbuf);
2355 eina_stringshare_replace(&wd->text, text);
2361 elm_entry_add(Evas_Object *parent)
2363 Evas_Object *obj, *top;
2367 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2369 ELM_SET_WIDTYPE(widtype, "entry");
2370 elm_widget_type_set(obj, "entry");
2371 elm_widget_sub_object_add(parent, obj);
2372 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2373 elm_widget_data_set(obj, wd);
2374 elm_widget_del_hook_set(obj, _del_hook);
2375 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2376 elm_widget_theme_hook_set(obj, _theme_hook);
2377 elm_widget_disable_hook_set(obj, _disable_hook);
2378 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2379 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2380 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2381 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2382 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2383 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2384 elm_widget_can_focus_set(obj, EINA_TRUE);
2385 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2386 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2387 elm_widget_content_set_hook_set(obj, _content_set_hook);
2388 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2389 elm_widget_content_get_hook_set(obj, _content_get_hook);
2390 elm_widget_translate_hook_set(obj, _translate_hook);
2392 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2394 wd->linewrap = ELM_WRAP_WORD;
2395 wd->editable = EINA_TRUE;
2396 wd->disabled = EINA_FALSE;
2397 wd->context_menu = EINA_TRUE;
2398 wd->autosave = EINA_TRUE;
2399 wd->cnp_mode = ELM_CNP_MODE_MARKUP;
2400 wd->scroll = EINA_FALSE;
2401 wd->input_panel_imdata = NULL;
2403 wd->ent = edje_object_add(e);
2404 edje_object_item_provider_set(wd->ent, _get_item, obj);
2405 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2406 edje_object_text_markup_filter_callback_add(wd->ent,"elm.text", _markup_filter, obj);
2407 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2408 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2410 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2412 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2414 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2416 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2417 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2418 _signal_entry_changed, obj);
2419 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
2420 _signal_entry_changed_user, obj);
2421 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2422 _signal_preedit_changed, obj);
2423 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2424 _signal_selection_start, obj);
2425 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2426 _signal_selection_changed, obj);
2427 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2428 _signal_selection_all, obj);
2429 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2430 _signal_selection_none, obj);
2431 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2432 _signal_selection_cleared, obj);
2433 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2434 _signal_entry_paste_request, obj);
2435 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2436 _signal_entry_copy_notify, obj);
2437 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2438 _signal_entry_cut_notify, obj);
2439 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2440 _signal_cursor_changed, obj);
2441 edje_object_signal_callback_add(wd->ent, "cursor,changed,manual", "elm.text",
2442 _signal_cursor_changed_manual, obj);
2443 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2444 _signal_anchor_down, obj);
2445 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2446 _signal_anchor_up, obj);
2447 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2448 _signal_anchor_clicked, obj);
2449 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2450 _signal_anchor_move, obj);
2451 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2452 _signal_anchor_in, obj);
2453 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2454 _signal_anchor_out, obj);
2455 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2456 _signal_key_enter, obj);
2457 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2458 _signal_mouse_down, obj);
2459 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2460 _signal_mouse_clicked, obj);
2461 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2462 _signal_mouse_double, obj);
2463 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
2464 _signal_mouse_triple, obj);
2465 edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
2466 _signal_undo_request, obj);
2467 edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
2468 _signal_redo_request, obj);
2469 edje_object_part_text_set(wd->ent, "elm.text", "");
2470 if (_elm_config->desktop_entry)
2471 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2472 elm_widget_resize_object_set(obj, wd->ent);
2475 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
2476 elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
2477 elm_entry_prediction_allow_set(obj, EINA_TRUE);
2479 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
2481 #ifdef HAVE_ELEMENTARY_X
2482 top = elm_widget_top_get(obj);
2483 if ((top) && (elm_win_xwindow_get(top)))
2485 wd->sel_notify_handler =
2486 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2487 _event_selection_notify, obj);
2488 wd->sel_clear_handler =
2489 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2490 _event_selection_clear, obj);
2493 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2494 _drag_drop_cb, NULL);
2497 entries = eina_list_prepend(entries, obj);
2499 // module - find module for entry
2500 wd->api = _module(obj);
2501 // if found - hook in
2502 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2504 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2505 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2506 // TODO: and save some bytes, making descriptions per-class and not instance!
2507 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2512 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2514 ELM_CHECK_WIDTYPE(obj, widtype);
2515 Widget_Data *wd = elm_widget_data_get(obj);
2517 if (wd->single_line == single_line) return;
2518 wd->single_line = single_line;
2519 wd->linewrap = ELM_WRAP_NONE;
2520 elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
2524 if (wd->single_line)
2525 elm_smart_scroller_policy_set(wd->scroller,
2526 ELM_SMART_SCROLLER_POLICY_OFF,
2527 ELM_SMART_SCROLLER_POLICY_OFF);
2530 const Elm_Scroller_Policy map[3] =
2532 ELM_SMART_SCROLLER_POLICY_AUTO,
2533 ELM_SMART_SCROLLER_POLICY_ON,
2534 ELM_SMART_SCROLLER_POLICY_OFF
2536 elm_smart_scroller_policy_set(wd->scroller,
2545 elm_entry_single_line_get(const Evas_Object *obj)
2547 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2548 Widget_Data *wd = elm_widget_data_get(obj);
2549 if (!wd) return EINA_FALSE;
2550 return wd->single_line;
2554 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2556 ELM_CHECK_WIDTYPE(obj, widtype);
2557 Widget_Data *wd = elm_widget_data_get(obj);
2559 if (wd->password == password) return;
2560 wd->password = password;
2563 wd->single_line = EINA_TRUE;
2564 wd->linewrap = ELM_WRAP_NONE;
2565 #ifdef HAVE_ELEMENTARY_X
2566 elm_drop_target_del(obj);
2568 edje_object_signal_callback_del_full(wd->ent, "selection,start", "elm.text",
2569 _signal_selection_start, obj);
2570 edje_object_signal_callback_del_full(wd->ent, "selection,changed", "elm.text",
2571 _signal_selection_changed, obj);
2572 edje_object_signal_callback_del_full(wd->ent, "entry,selection,all,request", "elm.text",
2573 _signal_selection_all, obj);
2574 edje_object_signal_callback_del_full(wd->ent, "entry,selection,none,request", "elm.text",
2575 _signal_selection_none, obj);
2576 edje_object_signal_callback_del_full(wd->ent, "selection,cleared", "elm.text",
2577 _signal_selection_cleared, obj);
2578 edje_object_signal_callback_del_full(wd->ent, "entry,paste,request,*", "elm.text",
2579 _signal_entry_paste_request, obj);
2580 edje_object_signal_callback_del_full(wd->ent, "entry,copy,notify", "elm.text",
2581 _signal_entry_copy_notify, obj);
2582 edje_object_signal_callback_del_full(wd->ent, "entry,cut,notify", "elm.text",
2583 _signal_entry_cut_notify, obj);
2587 #ifdef HAVE_ELEMENTARY_X
2588 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2590 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2591 _signal_selection_start, obj);
2592 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2593 _signal_selection_changed, obj);
2594 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2595 _signal_selection_all, obj);
2596 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2597 _signal_selection_none, obj);
2598 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2599 _signal_selection_cleared, obj);
2600 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
2601 _signal_entry_paste_request, obj);
2602 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2603 _signal_entry_copy_notify, obj);
2604 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2605 _signal_entry_cut_notify, obj);
2611 elm_entry_password_get(const Evas_Object *obj)
2613 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2614 Widget_Data *wd = elm_widget_data_get(obj);
2615 if (!wd) return EINA_FALSE;
2616 return wd->password;
2620 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2622 _elm_entry_text_set(obj, NULL, entry);
2626 elm_entry_entry_get(const Evas_Object *obj)
2628 return _elm_entry_text_get(obj, NULL);
2632 elm_entry_entry_append(Evas_Object *obj, const char *entry)
2635 ELM_CHECK_WIDTYPE(obj, widtype);
2636 Widget_Data *wd = elm_widget_data_get(obj);
2638 if (!entry) entry = "";
2639 wd->changed = EINA_TRUE;
2641 len = strlen(entry);
2642 if (wd->append_text_left)
2645 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
2651 wd->append_text_left = tmpbuf;
2652 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
2653 wd->append_text_len += len;
2657 /* FIXME: Add chunked appending here (like in entry_set) */
2658 edje_object_part_text_append(wd->ent, "elm.text", entry);
2663 elm_entry_is_empty(const Evas_Object *obj)
2665 /* FIXME: until there's support for that in textblock, we just check
2666 * to see if the there is text or not. */
2667 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2668 Widget_Data *wd = elm_widget_data_get(obj);
2669 const Evas_Object *tb;
2670 Evas_Textblock_Cursor *cur;
2672 if (!wd) return EINA_TRUE;
2673 /* It's a hack until we get the support suggested above.
2674 * We just create a cursor, point it to the begining, and then
2675 * try to advance it, if it can advance, the tb is not empty,
2676 * otherwise it is. */
2677 tb = edje_object_part_object_get(wd->ent, "elm.text");
2678 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2679 actually, ok for the time being, thsese hackish stuff will be removed
2680 once evas 1.0 is out*/
2681 evas_textblock_cursor_pos_set(cur, 0);
2682 ret = evas_textblock_cursor_char_next(cur);
2683 evas_textblock_cursor_free(cur);
2689 elm_entry_textblock_get(Evas_Object *obj)
2691 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2692 Widget_Data *wd = elm_widget_data_get(obj);
2693 if (!wd) return NULL;
2695 return (Evas_Object *) edje_object_part_object_get(wd->ent, "elm.text");
2699 elm_entry_calc_force(Evas_Object *obj)
2701 ELM_CHECK_WIDTYPE(obj, widtype);
2702 Widget_Data *wd = elm_widget_data_get(obj);
2705 edje_object_calc_force(wd->ent);
2706 wd->changed = EINA_TRUE;
2712 elm_entry_selection_get(const Evas_Object *obj)
2714 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2715 Widget_Data *wd = elm_widget_data_get(obj);
2716 if ((!wd) || (wd->password)) return NULL;
2717 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2721 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2723 ELM_CHECK_WIDTYPE(obj, widtype);
2724 Widget_Data *wd = elm_widget_data_get(obj);
2726 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2727 wd->changed = EINA_TRUE;
2732 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
2734 ELM_CHECK_WIDTYPE(obj, widtype);
2735 Widget_Data *wd = elm_widget_data_get(obj);
2737 if (wd->linewrap == wrap) return;
2739 wd->linewrap = wrap;
2744 elm_entry_line_wrap_get(const Evas_Object *obj)
2746 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2747 Widget_Data *wd = elm_widget_data_get(obj);
2748 if (!wd) return EINA_FALSE;
2749 return wd->linewrap;
2753 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2755 ELM_CHECK_WIDTYPE(obj, widtype);
2756 Widget_Data *wd = elm_widget_data_get(obj);
2758 if (wd->editable == editable) return;
2759 wd->editable = editable;
2762 #ifdef HAVE_ELEMENTARY_X
2764 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2766 elm_drop_target_del(obj);
2771 elm_entry_editable_get(const Evas_Object *obj)
2773 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2774 Widget_Data *wd = elm_widget_data_get(obj);
2775 if (!wd) return EINA_FALSE;
2776 return wd->editable;
2780 elm_entry_select_none(Evas_Object *obj)
2782 ELM_CHECK_WIDTYPE(obj, widtype);
2783 Widget_Data *wd = elm_widget_data_get(obj);
2784 if ((!wd) || (wd->password)) return;
2787 wd->selmode = EINA_FALSE;
2788 if (!_elm_config->desktop_entry)
2789 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2790 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2792 wd->have_selection = EINA_FALSE;
2793 edje_object_part_text_select_none(wd->ent, "elm.text");
2797 elm_entry_select_all(Evas_Object *obj)
2799 ELM_CHECK_WIDTYPE(obj, widtype);
2800 Widget_Data *wd = elm_widget_data_get(obj);
2801 if ((!wd) || (wd->password)) return;
2804 wd->selmode = EINA_FALSE;
2805 if (!_elm_config->desktop_entry)
2806 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2807 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2809 wd->have_selection = EINA_TRUE;
2810 edje_object_part_text_select_all(wd->ent, "elm.text");
2814 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2816 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2817 Widget_Data *wd = elm_widget_data_get(obj);
2818 if (!wd) return EINA_FALSE;
2819 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
2824 elm_entry_cursor_next(Evas_Object *obj)
2826 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2827 Widget_Data *wd = elm_widget_data_get(obj);
2828 if (!wd) return EINA_FALSE;
2829 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2833 elm_entry_cursor_prev(Evas_Object *obj)
2835 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2836 Widget_Data *wd = elm_widget_data_get(obj);
2837 if (!wd) return EINA_FALSE;
2838 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2842 elm_entry_cursor_up(Evas_Object *obj)
2844 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2845 Widget_Data *wd = elm_widget_data_get(obj);
2846 if (!wd) return EINA_FALSE;
2847 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2851 elm_entry_cursor_down(Evas_Object *obj)
2853 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2854 Widget_Data *wd = elm_widget_data_get(obj);
2855 if (!wd) return EINA_FALSE;
2856 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2860 elm_entry_cursor_begin_set(Evas_Object *obj)
2862 ELM_CHECK_WIDTYPE(obj, widtype);
2863 Widget_Data *wd = elm_widget_data_get(obj);
2865 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2869 elm_entry_cursor_end_set(Evas_Object *obj)
2871 ELM_CHECK_WIDTYPE(obj, widtype);
2872 Widget_Data *wd = elm_widget_data_get(obj);
2874 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2878 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2880 ELM_CHECK_WIDTYPE(obj, widtype);
2881 Widget_Data *wd = elm_widget_data_get(obj);
2883 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2887 elm_entry_cursor_line_end_set(Evas_Object *obj)
2889 ELM_CHECK_WIDTYPE(obj, widtype);
2890 Widget_Data *wd = elm_widget_data_get(obj);
2892 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2896 elm_entry_cursor_selection_begin(Evas_Object *obj)
2898 ELM_CHECK_WIDTYPE(obj, widtype);
2899 Widget_Data *wd = elm_widget_data_get(obj);
2901 edje_object_part_text_select_begin(wd->ent, "elm.text");
2905 elm_entry_cursor_selection_end(Evas_Object *obj)
2907 ELM_CHECK_WIDTYPE(obj, widtype);
2908 Widget_Data *wd = elm_widget_data_get(obj);
2910 edje_object_part_text_select_extend(wd->ent, "elm.text");
2914 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2916 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2917 Widget_Data *wd = elm_widget_data_get(obj);
2918 if (!wd) return EINA_FALSE;
2919 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2923 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2925 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2926 Widget_Data *wd = elm_widget_data_get(obj);
2927 if (!wd) return EINA_FALSE;
2928 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2932 elm_entry_cursor_content_get(const Evas_Object *obj)
2934 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2935 Widget_Data *wd = elm_widget_data_get(obj);
2936 if (!wd) return NULL;
2937 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2941 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
2943 ELM_CHECK_WIDTYPE(obj, widtype);
2944 Widget_Data *wd = elm_widget_data_get(obj);
2946 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
2947 edje_object_message_signal_process(wd->ent);
2951 elm_entry_cursor_pos_get(const Evas_Object *obj)
2953 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2954 Widget_Data *wd = elm_widget_data_get(obj);
2956 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2960 elm_entry_selection_cut(Evas_Object *obj)
2962 ELM_CHECK_WIDTYPE(obj, widtype);
2963 Widget_Data *wd = elm_widget_data_get(obj);
2964 if ((!wd) || (wd->password)) return;
2965 _cut(obj, NULL, NULL);
2969 elm_entry_selection_copy(Evas_Object *obj)
2971 ELM_CHECK_WIDTYPE(obj, widtype);
2972 Widget_Data *wd = elm_widget_data_get(obj);
2973 if ((!wd) || (wd->password)) return;
2974 _copy(obj, NULL, NULL);
2978 elm_entry_selection_paste(Evas_Object *obj)
2980 ELM_CHECK_WIDTYPE(obj, widtype);
2981 Widget_Data *wd = elm_widget_data_get(obj);
2982 if ((!wd) || (wd->password)) return;
2983 _paste(obj, NULL, NULL);
2987 elm_entry_context_menu_clear(Evas_Object *obj)
2989 ELM_CHECK_WIDTYPE(obj, widtype);
2990 Widget_Data *wd = elm_widget_data_get(obj);
2991 Elm_Entry_Context_Menu_Item *it;
2993 EINA_LIST_FREE(wd->items, it)
2995 eina_stringshare_del(it->label);
2996 eina_stringshare_del(it->icon_file);
2997 eina_stringshare_del(it->icon_group);
3003 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)
3005 ELM_CHECK_WIDTYPE(obj, widtype);
3006 Widget_Data *wd = elm_widget_data_get(obj);
3007 Elm_Entry_Context_Menu_Item *it;
3009 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3011 wd->items = eina_list_append(wd->items, it);
3013 it->label = eina_stringshare_add(label);
3014 it->icon_file = eina_stringshare_add(icon_file);
3015 it->icon_type = icon_type;
3017 it->data = (void *)data;
3021 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3023 ELM_CHECK_WIDTYPE(obj, widtype);
3024 Widget_Data *wd = elm_widget_data_get(obj);
3026 if (wd->context_menu == !disabled) return;
3027 wd->context_menu = !disabled;
3031 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3033 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3034 Widget_Data *wd = elm_widget_data_get(obj);
3035 if (!wd) return EINA_FALSE;
3036 return !wd->context_menu;
3040 elm_entry_item_provider_append(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3042 ELM_CHECK_WIDTYPE(obj, widtype);
3043 Widget_Data *wd = elm_widget_data_get(obj);
3045 EINA_SAFETY_ON_NULL_RETURN(func);
3046 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3050 wd->item_providers = eina_list_append(wd->item_providers, ip);
3054 elm_entry_item_provider_prepend(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3056 ELM_CHECK_WIDTYPE(obj, widtype);
3057 Widget_Data *wd = elm_widget_data_get(obj);
3059 EINA_SAFETY_ON_NULL_RETURN(func);
3060 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3064 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3068 elm_entry_item_provider_remove(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3070 ELM_CHECK_WIDTYPE(obj, widtype);
3071 Widget_Data *wd = elm_widget_data_get(obj);
3073 Elm_Entry_Item_Provider *ip;
3075 EINA_SAFETY_ON_NULL_RETURN(func);
3076 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3078 if ((ip->func == func) && ((!data) || (ip->data == data)))
3080 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3088 elm_entry_markup_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3091 Elm_Entry_Markup_Filter *tf;
3092 ELM_CHECK_WIDTYPE(obj, widtype);
3094 wd = elm_widget_data_get(obj);
3096 EINA_SAFETY_ON_NULL_RETURN(func);
3098 tf = _filter_new(func, data);
3101 wd->markup_filters = eina_list_append(wd->markup_filters, tf);
3105 elm_entry_markup_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3108 Elm_Entry_Markup_Filter *tf;
3109 ELM_CHECK_WIDTYPE(obj, widtype);
3111 wd = elm_widget_data_get(obj);
3113 EINA_SAFETY_ON_NULL_RETURN(func);
3115 tf = _filter_new(func, data);
3118 wd->markup_filters = eina_list_prepend(wd->markup_filters, tf);
3122 elm_entry_markup_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3126 Elm_Entry_Markup_Filter *tf;
3127 ELM_CHECK_WIDTYPE(obj, widtype);
3129 wd = elm_widget_data_get(obj);
3131 EINA_SAFETY_ON_NULL_RETURN(func);
3133 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
3135 if ((tf->func == func) && ((!data) || (tf->data == data)))
3137 wd->markup_filters = eina_list_remove_list(wd->markup_filters, l);
3145 elm_entry_markup_to_utf8(const char *s)
3147 char *ss = _elm_util_mkup_to_text(s);
3148 if (!ss) ss = strdup("");
3153 elm_entry_utf8_to_markup(const char *s)
3155 char *ss = _elm_util_text_to_mkup(s);
3156 if (!ss) ss = strdup("");
3161 _text_get(const Evas_Object *obj)
3163 return elm_object_text_get(obj);
3167 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3169 Elm_Entry_Filter_Limit_Size *lim = data;
3170 char *current, *utfstr;
3172 const char *(*text_get)(const Evas_Object *);
3174 EINA_SAFETY_ON_NULL_RETURN(data);
3175 EINA_SAFETY_ON_NULL_RETURN(entry);
3176 EINA_SAFETY_ON_NULL_RETURN(text);
3178 /* hack. I don't want to copy the entire function to work with
3180 text_get = _text_get;
3182 current = elm_entry_markup_to_utf8(text_get(entry));
3183 utfstr = elm_entry_markup_to_utf8(*text);
3185 if (lim->max_char_count > 0)
3187 len = evas_string_char_len_get(current);
3188 if (len >= lim->max_char_count)
3190 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3197 newlen = evas_string_char_len_get(utfstr);
3198 if ((len + newlen) > lim->max_char_count)
3199 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3201 else if (lim->max_byte_count > 0)
3203 len = strlen(current);
3204 if (len >= lim->max_byte_count)
3206 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3213 newlen = strlen(utfstr);
3214 if ((len + newlen) > lim->max_byte_count)
3215 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3222 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3224 Elm_Entry_Filter_Accept_Set *as = data;
3228 int read_idx, last_read_idx = 0, read_char;
3230 EINA_SAFETY_ON_NULL_RETURN(data);
3231 EINA_SAFETY_ON_NULL_RETURN(text);
3233 if ((!as->accepted) && (!as->rejected))
3239 goes_in = EINA_TRUE;
3244 goes_in = EINA_FALSE;
3248 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3251 int cmp_idx, cmp_char;
3252 Eina_Bool in_set = EINA_FALSE;
3254 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3257 if (read_char == cmp_char)
3262 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3264 if (in_set == goes_in)
3266 int size = read_idx - last_read_idx;
3267 const char *src = (*text) + last_read_idx;
3269 memcpy(insert, *text + last_read_idx, size);
3272 last_read_idx = read_idx;
3273 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3279 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3281 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3282 Widget_Data *wd = elm_widget_data_get(obj);
3283 if (!wd) return EINA_FALSE;
3284 if (wd->delay_write)
3286 ecore_timer_del(wd->delay_write);
3287 wd->delay_write = NULL;
3289 if (wd->autosave) _save(obj);
3290 eina_stringshare_replace(&wd->file, file);
3291 wd->format = format;
3296 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3298 ELM_CHECK_WIDTYPE(obj, widtype);
3299 Widget_Data *wd = elm_widget_data_get(obj);
3301 if (file) *file = wd->file;
3302 if (format) *format = wd->format;
3306 elm_entry_file_save(Evas_Object *obj)
3308 ELM_CHECK_WIDTYPE(obj, widtype);
3309 Widget_Data *wd = elm_widget_data_get(obj);
3311 if (wd->delay_write)
3313 ecore_timer_del(wd->delay_write);
3314 wd->delay_write = NULL;
3317 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3321 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3323 ELM_CHECK_WIDTYPE(obj, widtype);
3324 Widget_Data *wd = elm_widget_data_get(obj);
3326 wd->autosave = !!autosave;
3330 elm_entry_autosave_get(const Evas_Object *obj)
3332 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3333 Widget_Data *wd = elm_widget_data_get(obj);
3334 if (!wd) return EINA_FALSE;
3335 return wd->autosave;
3338 EINA_DEPRECATED EAPI void
3339 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3341 ELM_CHECK_WIDTYPE(obj, widtype);
3342 Elm_Cnp_Mode cnp_mode = ELM_CNP_MODE_MARKUP;
3344 cnp_mode = ELM_CNP_MODE_NO_IMAGE;
3345 elm_entry_cnp_mode_set(obj, cnp_mode);
3348 EINA_DEPRECATED EAPI Eina_Bool
3349 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3351 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3352 return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
3356 elm_entry_cnp_mode_set(Evas_Object *obj, Elm_Cnp_Mode cnp_mode)
3358 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3359 ELM_CHECK_WIDTYPE(obj, widtype);
3360 Widget_Data *wd = elm_widget_data_get(obj);
3362 if (wd->cnp_mode == cnp_mode) return;
3363 wd->cnp_mode = cnp_mode;
3364 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
3365 format = ELM_SEL_FORMAT_TEXT;
3366 else if (cnp_mode == ELM_CNP_MODE_MARKUP) format |= ELM_SEL_FORMAT_IMAGE;
3367 #ifdef HAVE_ELEMENTARY_X
3368 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3373 elm_entry_cnp_mode_get(const Evas_Object *obj)
3375 ELM_CHECK_WIDTYPE(obj, widtype) ELM_CNP_MODE_MARKUP;
3376 Widget_Data *wd = elm_widget_data_get(obj);
3377 if (!wd) return ELM_CNP_MODE_MARKUP;
3378 return wd->cnp_mode;
3382 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3384 ELM_CHECK_WIDTYPE(obj, widtype);
3385 Widget_Data *wd = elm_widget_data_get(obj);
3386 const Elm_Scroller_Policy map[3] =
3388 ELM_SMART_SCROLLER_POLICY_AUTO,
3389 ELM_SMART_SCROLLER_POLICY_ON,
3390 ELM_SMART_SCROLLER_POLICY_OFF
3394 if (wd->scroll == scroll) return;
3395 wd->scroll = scroll;
3400 wd->scroller = elm_smart_scroller_add(evas_object_evas_get(obj));
3401 elm_widget_resize_object_set(obj, wd->scroller);
3402 elm_smart_scroller_widget_set(wd->scroller, obj);
3403 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
3404 elm_widget_style_get(obj));
3405 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3406 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
3407 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
3408 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(wd->scroller),
3411 elm_smart_scroller_bounce_allow_set(wd->scroller, wd->h_bounce, wd->v_bounce);
3412 if (wd->single_line)
3413 elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
3414 ELM_SMART_SCROLLER_POLICY_OFF);
3416 elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]);
3417 elm_widget_sub_object_add(obj, wd->ent);
3418 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3419 evas_object_show(wd->scroller);
3420 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3426 elm_smart_scroller_child_set(wd->scroller, NULL);
3427 evas_object_smart_member_add(wd->scroller, obj);
3428 elm_widget_sub_object_add(obj, wd->scroller);
3429 evas_object_hide(wd->scroller);
3431 elm_widget_sub_object_del(obj, wd->ent);
3432 elm_widget_resize_object_set(obj, wd->ent);
3433 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3440 elm_entry_scrollable_get(const Evas_Object *obj)
3442 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3443 Widget_Data *wd = elm_widget_data_get(obj);
3444 if (!wd) return EINA_FALSE;
3449 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3451 ELM_CHECK_WIDTYPE(obj, widtype);
3452 Widget_Data *wd = elm_widget_data_get(obj);
3456 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3460 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3462 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3464 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3469 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3471 ELM_CHECK_WIDTYPE(obj, widtype);
3472 Widget_Data *wd = elm_widget_data_get(obj);
3476 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3480 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
3482 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3484 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3489 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3491 ELM_CHECK_WIDTYPE(obj, widtype);
3492 Widget_Data *wd = elm_widget_data_get(obj);
3493 const Elm_Scroller_Policy map[3] =
3495 ELM_SMART_SCROLLER_POLICY_AUTO,
3496 ELM_SMART_SCROLLER_POLICY_ON,
3497 ELM_SMART_SCROLLER_POLICY_OFF
3502 elm_smart_scroller_policy_set(wd->scroller,
3508 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3510 ELM_CHECK_WIDTYPE(obj, widtype);
3511 Widget_Data *wd = elm_widget_data_get(obj);
3513 wd->h_bounce = h_bounce;
3514 wd->v_bounce = v_bounce;
3515 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
3519 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3521 ELM_CHECK_WIDTYPE(obj, widtype);
3522 Widget_Data *wd = elm_widget_data_get(obj);
3524 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
3528 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3530 ELM_CHECK_WIDTYPE(obj, widtype);
3531 Widget_Data *wd = elm_widget_data_get(obj);
3534 wd->input_panel_layout = layout;
3536 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
3539 EAPI Elm_Input_Panel_Layout
3540 elm_entry_input_panel_layout_get(const Evas_Object *obj)
3542 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
3543 Widget_Data *wd = elm_widget_data_get(obj);
3544 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
3546 return wd->input_panel_layout;
3550 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
3552 ELM_CHECK_WIDTYPE(obj, widtype);
3553 Widget_Data *wd = elm_widget_data_get(obj);
3556 wd->autocapital_type = autocapital_type;
3557 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
3560 EAPI Elm_Autocapital_Type
3561 elm_entry_autocapital_type_get(const Evas_Object *obj)
3563 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
3564 Widget_Data *wd = elm_widget_data_get(obj);
3565 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
3567 return wd->autocapital_type;
3571 elm_entry_prediction_allow_set(Evas_Object *obj, Eina_Bool prediction)
3573 ELM_CHECK_WIDTYPE(obj, widtype);
3574 Widget_Data *wd = elm_widget_data_get(obj);
3577 wd->prediction_allow = prediction;
3578 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", prediction);
3582 elm_entry_prediction_allow_get(const Evas_Object *obj)
3584 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3585 Widget_Data *wd = elm_widget_data_get(obj);
3586 if (!wd) return EINA_TRUE;
3588 return wd->prediction_allow;
3592 elm_entry_imf_context_reset(Evas_Object *obj)
3594 ELM_CHECK_WIDTYPE(obj, widtype);
3595 Widget_Data *wd = elm_widget_data_get(obj);
3598 edje_object_part_text_imf_context_reset(wd->ent, "elm.text");
3602 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3604 ELM_CHECK_WIDTYPE(obj, widtype);
3605 Widget_Data *wd = elm_widget_data_get(obj);
3608 wd->input_panel_enable = enabled;
3609 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3613 elm_entry_input_panel_enabled_get(const Evas_Object *obj)
3615 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3616 Widget_Data *wd = elm_widget_data_get(obj);
3617 if (!wd) return EINA_TRUE;
3619 return wd->input_panel_enable;
3623 elm_entry_input_panel_show(Evas_Object *obj)
3625 ELM_CHECK_WIDTYPE(obj, widtype);
3626 Widget_Data *wd = elm_widget_data_get(obj);
3629 edje_object_part_text_input_panel_show(wd->ent, "elm.text");
3633 elm_entry_input_panel_hide(Evas_Object *obj)
3635 ELM_CHECK_WIDTYPE(obj, widtype);
3636 Widget_Data *wd = elm_widget_data_get(obj);
3639 edje_object_part_text_input_panel_hide(wd->ent, "elm.text");
3643 elm_entry_input_panel_language_set(Evas_Object *obj, Elm_Input_Panel_Lang lang)
3645 ELM_CHECK_WIDTYPE(obj, widtype);
3646 Widget_Data *wd = elm_widget_data_get(obj);
3649 wd->input_panel_lang = lang;
3650 edje_object_part_text_input_panel_language_set(wd->ent, "elm.text", lang);
3653 EAPI Elm_Input_Panel_Lang
3654 elm_entry_input_panel_language_get(const Evas_Object *obj)
3656 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LANG_AUTOMATIC;
3657 Widget_Data *wd = elm_widget_data_get(obj);
3658 if (!wd) return ELM_INPUT_PANEL_LANG_AUTOMATIC;
3660 return wd->input_panel_lang;
3664 elm_entry_input_panel_imdata_set(Evas_Object *obj, const void *data, int len)
3666 ELM_CHECK_WIDTYPE(obj, widtype);
3667 Widget_Data *wd = elm_widget_data_get(obj);
3670 if (wd->input_panel_imdata)
3671 free(wd->input_panel_imdata);
3673 wd->input_panel_imdata = calloc(1, len);
3674 wd->input_panel_imdata_len = len;
3675 memcpy(wd->input_panel_imdata, data, len);
3677 edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len);
3681 elm_entry_input_panel_imdata_get(const Evas_Object *obj, void *data, int *len)
3683 ELM_CHECK_WIDTYPE(obj, widtype);
3684 Widget_Data *wd = elm_widget_data_get(obj);
3687 edje_object_part_text_input_panel_imdata_get(wd->ent, "elm.text", data, len);
3691 elm_entry_input_panel_return_key_type_set(Evas_Object *obj, Elm_Input_Panel_Return_Key_Type return_key_type)
3693 ELM_CHECK_WIDTYPE(obj, widtype);
3694 Widget_Data *wd = elm_widget_data_get(obj);
3697 wd->input_panel_return_key_type = return_key_type;
3699 edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", return_key_type);
3702 EAPI Elm_Input_Panel_Return_Key_Type
3703 elm_entry_input_panel_return_key_type_get(const Evas_Object *obj)
3705 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
3706 Widget_Data *wd = elm_widget_data_get(obj);
3707 if (!wd) return ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
3709 return wd->input_panel_return_key_type;
3713 elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3715 ELM_CHECK_WIDTYPE(obj, widtype);
3716 Widget_Data *wd = elm_widget_data_get(obj);
3719 wd->input_panel_return_key_disabled = disabled;
3721 edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", disabled);
3725 elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
3727 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3728 Widget_Data *wd = elm_widget_data_get(obj);
3729 if (!wd) return EINA_FALSE;
3731 return wd->input_panel_return_key_disabled;
3735 elm_entry_input_panel_return_key_autoenabled_set(Evas_Object *obj, Eina_Bool enabled)
3737 ELM_CHECK_WIDTYPE(obj, widtype);
3738 Widget_Data *wd = elm_widget_data_get(obj);
3741 wd->autoreturnkey = enabled;
3742 _check_enable_return_key(obj);
3746 elm_entry_imf_context_get(Evas_Object *obj)
3748 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3749 Widget_Data *wd = elm_widget_data_get(obj);
3750 if (!wd) return NULL;
3752 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3755 /* START - ANCHOR HOVER */
3757 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
3759 Widget_Data *wd = elm_widget_data_get(data);
3761 wd->anchor_hover.hover_parent = NULL;
3765 elm_entry_anchor_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
3767 ELM_CHECK_WIDTYPE(obj, widtype);
3768 Widget_Data *wd = elm_widget_data_get(obj);
3770 if (wd->anchor_hover.hover_parent)
3771 evas_object_event_callback_del_full(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
3772 wd->anchor_hover.hover_parent = parent;
3773 if (wd->anchor_hover.hover_parent)
3774 evas_object_event_callback_add(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
3778 elm_entry_anchor_hover_parent_get(const Evas_Object *obj)
3780 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3781 Widget_Data *wd = elm_widget_data_get(obj);
3782 if (!wd) return NULL;
3783 return wd->anchor_hover.hover_parent;
3787 elm_entry_anchor_hover_style_set(Evas_Object *obj, const char *style)
3789 ELM_CHECK_WIDTYPE(obj, widtype);
3790 Widget_Data *wd = elm_widget_data_get(obj);
3792 eina_stringshare_replace(&wd->anchor_hover.hover_style, style);
3796 elm_entry_anchor_hover_style_get(const Evas_Object *obj)
3798 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3799 Widget_Data *wd = elm_widget_data_get(obj);
3800 if (!wd) return NULL;
3801 return wd->anchor_hover.hover_style;
3805 elm_entry_anchor_hover_end(Evas_Object *obj)
3807 ELM_CHECK_WIDTYPE(obj, widtype);
3808 Widget_Data *wd = elm_widget_data_get(obj);
3810 if (wd->anchor_hover.hover) evas_object_del(wd->anchor_hover.hover);
3811 if (wd->anchor_hover.pop) evas_object_del(wd->anchor_hover.pop);
3812 wd->anchor_hover.hover = NULL;
3813 wd->anchor_hover.pop = NULL;
3818 _anchor_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
3820 elm_entry_anchor_hover_end(data);
3824 _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info)
3826 Widget_Data *wd = elm_widget_data_get(obj);
3827 Elm_Entry_Anchor_Info *info = event_info;
3828 Evas_Object *hover_parent;
3829 Elm_Entry_Anchor_Hover_Info ei;
3830 Evas_Coord x, w, y, h, px, py;
3833 ei.anchor_info = event_info;
3835 wd->anchor_hover.pop = elm_icon_add(obj);
3836 evas_object_move(wd->anchor_hover.pop, info->x, info->y);
3837 evas_object_resize(wd->anchor_hover.pop, info->w, info->h);
3839 wd->anchor_hover.hover = elm_hover_add(obj);
3840 elm_widget_mirrored_set(wd->anchor_hover.hover, elm_widget_mirrored_get(obj));
3841 if (wd->anchor_hover.hover_style)
3842 elm_object_style_set(wd->anchor_hover.hover, wd->anchor_hover.hover_style);
3844 hover_parent = wd->anchor_hover.hover_parent;
3845 if (!hover_parent) hover_parent = obj;
3846 elm_hover_parent_set(wd->anchor_hover.hover, hover_parent);
3847 elm_hover_target_set(wd->anchor_hover.hover, wd->anchor_hover.pop);
3848 ei.hover = wd->anchor_hover.hover;
3850 evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
3851 ei.hover_parent.x = x;
3852 ei.hover_parent.y = y;
3853 ei.hover_parent.w = w;
3854 ei.hover_parent.h = h;
3855 px = info->x + (info->w / 2);
3856 py = info->y + (info->h / 2);
3858 if (px < (x + (w / 3))) ei.hover_left = 0;
3860 if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
3862 if (py < (y + (h / 3))) ei.hover_top = 0;
3863 ei.hover_bottom = 1;
3864 if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
3866 if (elm_widget_mirrored_get(wd->anchor_hover.hover))
3867 { /* Swap right and left because they switch sides in RTL */
3868 Eina_Bool tmp = ei.hover_left;
3869 ei.hover_left = ei.hover_right;
3870 ei.hover_right = tmp;
3873 evas_object_smart_callback_call(data, SIG_ANCHOR_HOVER_OPENED, &ei);
3874 evas_object_smart_callback_add(wd->anchor_hover.hover, "clicked", _anchor_hover_clicked, data);
3876 /* FIXME: Should just check if there's any callback registered to the smart
3878 * This is used to determine if anyone cares about the hover or not. */
3879 if (!elm_object_part_content_get(wd->anchor_hover.hover, "middle") &&
3880 !elm_object_part_content_get(wd->anchor_hover.hover, "left") &&
3881 !elm_object_part_content_get(wd->anchor_hover.hover, "right") &&
3882 !elm_object_part_content_get(wd->anchor_hover.hover, "top") &&
3883 !elm_object_part_content_get(wd->anchor_hover.hover, "bottom"))
3885 evas_object_del(wd->anchor_hover.hover);
3889 evas_object_show(wd->anchor_hover.hover);
3892 /* END - ANCHOR HOVER */