1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "elm_module_priv.h"
5 #include "els_scroller.h"
8 /* Maximum chunk size to be inserted to the entry at once
9 * FIXME: This size is arbitrary, should probably choose a better size.
10 * Possibly also find a way to set it to a low value for weak computers,
11 * and to a big value for better computers. */
12 #define _CHUNK_SIZE 10000
14 typedef struct _Mod_Api Mod_Api;
16 typedef struct _Widget_Data Widget_Data;
17 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
18 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
19 typedef struct _Elm_Entry_Markup_Filter Elm_Entry_Markup_Filter;
23 Evas_Object *ent, *scroller;
24 Evas_Object *hoversel;
25 Ecore_Job *deferred_recalc_job;
26 Ecore_Event_Handler *sel_notify_handler;
27 Ecore_Event_Handler *sel_clear_handler;
28 Ecore_Timer *longpress_timer;
29 Ecore_Timer *delay_write;
30 /* for deferred appending */
31 Ecore_Idler *append_text_idler;
32 char *append_text_left;
33 int append_text_position;
35 /* Only for clipboard */
39 Elm_Text_Format format;
40 Evas_Coord lastw, entmw, entmh;
41 Evas_Coord downx, downy;
43 Eina_List *item_providers;
44 Eina_List *text_filters;
45 Eina_List *markup_filters;
47 Mod_Api *api; // module api if supplied
49 Elm_Scroller_Policy policy_h, policy_v;
50 Elm_Wrap_Type linewrap;
51 Elm_Input_Panel_Layout input_panel_layout;
52 Elm_Autocapital_Type autocapital_type;
53 Elm_Input_Panel_Lang input_panel_lang;
54 Elm_Input_Panel_Return_Key_Type input_panel_return_key_type;
55 void *input_panel_imdata;
56 int input_panel_imdata_len;
58 Evas_Object *hover_parent;
59 Evas_Object *pop, *hover;
60 const char *hover_style;
62 Eina_Bool changed : 1;
63 Eina_Bool single_line : 1;
64 Eina_Bool password : 1;
65 Eina_Bool editable : 1;
66 Eina_Bool selection_asked : 1;
67 Eina_Bool have_selection : 1;
68 Eina_Bool selmode : 1;
69 Eina_Bool deferred_cur : 1;
70 Eina_Bool cur_changed : 1;
71 Eina_Bool disabled : 1;
72 Eina_Bool context_menu : 1;
73 Eina_Bool drag_selection_asked : 1;
74 Eina_Bool can_write : 1;
75 Eina_Bool autosave : 1;
76 Eina_Bool usedown : 1;
78 Eina_Bool h_bounce : 1;
79 Eina_Bool v_bounce : 1;
80 Eina_Bool input_panel_enable : 1;
81 Eina_Bool prediction_allow : 1;
82 Eina_Bool input_panel_return_key_disabled : 1;
83 Eina_Bool autoreturnkey : 1;
84 Elm_Cnp_Mode cnp_mode : 2;
86 Evas_Object *mgf_proxy;
87 Evas_Object *mgf_clip;
89 Evas_Coord mgf_height;
92 Ecore_Job *region_get_job;
93 Ecore_Job *region_recalc_job;
94 const char *password_text;
95 Evas_Coord cx, cy, cw, ch;
96 Eina_Bool double_clicked : 1;
97 Eina_Bool long_pressed : 1;
98 Eina_Bool magnifier_enabled : 1;
102 struct _Elm_Entry_Context_Menu_Item
106 const char *icon_file;
107 const char *icon_group;
108 Elm_Icon_Type icon_type;
113 struct _Elm_Entry_Item_Provider
115 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
119 struct _Elm_Entry_Markup_Filter
121 Elm_Entry_Filter_Cb func;
125 typedef enum _Length_Unit
132 static const char *widtype = NULL;
134 static Evas_Object *cnpwidgetdata = NULL;
137 #ifdef HAVE_ELEMENTARY_X
138 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
140 static void _del_hook(Evas_Object *obj);
141 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
142 static void _theme_hook(Evas_Object *obj);
143 static void _disable_hook(Evas_Object *obj);
144 static void _sizing_eval(Evas_Object *obj);
145 static void _on_focus_hook(void *data, Evas_Object *obj);
146 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
147 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
148 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
149 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
150 static const char *_getbase(Evas_Object *obj);
151 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
152 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
153 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
154 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
155 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
156 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
157 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
158 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
159 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
160 static void _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info);
162 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
163 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
164 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
165 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
166 static void _magnifier_create(void *data);
167 static void _magnifier_show(void *data);
168 static void _magnifier_hide(void *data);
169 static void _magnifier_move(void *data);
170 static Evas_Coord_Rectangle _layout_region_get(Evas_Object *data);
171 static Evas_Coord_Rectangle _viewport_region_get(Evas_Object *data);
172 static void _region_get_job(void *data);
173 static void _region_recalc_job(void *data);
176 static const char SIG_CHANGED[] = "changed";
177 static const char SIG_CHANGED_USER[] = "changed,user";
178 static const char SIG_ACTIVATED[] = "activated";
179 static const char SIG_PRESS[] = "press";
180 static const char SIG_LONGPRESSED[] = "longpressed";
181 static const char SIG_CLICKED[] = "clicked";
182 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
183 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
184 static const char SIG_FOCUSED[] = "focused";
185 static const char SIG_UNFOCUSED[] = "unfocused";
186 static const char SIG_SELECTION_PASTE[] = "selection,paste";
187 static const char SIG_SELECTION_COPY[] = "selection,copy";
188 static const char SIG_SELECTION_CUT[] = "selection,cut";
189 static const char SIG_SELECTION_START[] = "selection,start";
190 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
191 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
192 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
193 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
194 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
195 static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened";
196 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
197 static const char SIG_ANCHOR_UP[] = "anchor,up";
198 static const char SIG_ANCHOR_IN[] = "anchor,in";
199 static const char SIG_ANCHOR_OUT[] = "anchor,out";
200 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
201 static const char SIG_UNDO_REQUEST[] = "undo,request";
202 static const char SIG_REDO_REQUEST[] = "redo,request";
203 static const Evas_Smart_Cb_Description _signals[] = {
207 {SIG_LONGPRESSED, ""},
209 {SIG_CLICKED_DOUBLE, ""},
210 {SIG_CLICKED_TRIPLE, ""},
213 {SIG_SELECTION_PASTE, ""},
214 {SIG_SELECTION_COPY, ""},
215 {SIG_SELECTION_CUT, ""},
216 {SIG_SELECTION_START, ""},
217 {SIG_SELECTION_CHANGED, ""},
218 {SIG_SELECTION_CLEARED, ""},
219 {SIG_CURSOR_CHANGED, ""},
220 {SIG_CURSOR_CHANGED_MANUAL, ""},
221 {SIG_ANCHOR_CLICKED, ""},
222 {SIG_ANCHOR_HOVER_OPENED, ""},
223 {SIG_ANCHOR_DOWN, ""},
226 {SIG_ANCHOR_OUT, ""},
227 {SIG_PREEDIT_CHANGED, ""},
228 {SIG_CHANGED_USER, ""},
229 {SIG_UNDO_REQUEST, ""},
230 {SIG_REDO_REQUEST, ""},
234 typedef enum _Elm_Entry_Magnifier_Type
236 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
237 _ENTRY_MAGNIFIER_FILLWIDTH,
238 _ENTRY_MAGNIFIER_CIRCULAR,
239 } Elm_Entry_Magnifier_Type;
241 static Eina_List *entries = NULL;
245 void (*obj_hook) (Evas_Object *obj);
246 void (*obj_unhook) (Evas_Object *obj);
247 void (*obj_longpress) (Evas_Object *obj);
248 void (*obj_hidemenu) (Evas_Object *obj);
249 void (*obj_mouseup) (Evas_Object *obj);
253 _module(Evas_Object *obj __UNUSED__)
255 static Elm_Module *m = NULL;
256 if (m) goto ok; // already found - just use
257 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
259 m->api = malloc(sizeof(Mod_Api));
260 if (!m->api) return NULL;
261 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
262 _elm_module_symbol_get(m, "obj_hook");
263 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
264 _elm_module_symbol_get(m, "obj_unhook");
265 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
266 _elm_module_symbol_get(m, "obj_longpress");
267 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
268 _elm_module_symbol_get(m, "obj_hidemenu");
269 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
270 _elm_module_symbol_get(m, "obj_mouseup");
271 ok: // ok - return api
276 _buf_append(char *buf, const char *str, int *len, int *alloc)
278 int len2 = strlen(str);
279 if ((*len + len2) >= *alloc)
281 char *buf2 = realloc(buf, *alloc + len2 + 512);
282 if (!buf2) return NULL;
284 *alloc += (512 + len2);
286 strcpy(buf + *len, str);
292 _load_file(const char *file)
296 int alloc = 0, len = 0;
297 char *text = NULL, buf[16384 + 1];
299 f = fopen(file, "rb");
301 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
305 tmp_text = _buf_append(text, buf, &len, &alloc);
306 if (!tmp_text) break;
314 _load_plain(const char *file)
318 text = _load_file(file);
323 text2 = elm_entry_utf8_to_markup(text);
331 _load(Evas_Object *obj)
333 Widget_Data *wd = elm_widget_data_get(obj);
335 if (!wd) return EINA_FALSE;
338 elm_object_text_set(obj, "");
343 case ELM_TEXT_FORMAT_PLAIN_UTF8:
344 text = _load_plain(wd->file);
346 case ELM_TEXT_FORMAT_MARKUP_UTF8:
347 text = _load_file(wd->file);
355 elm_object_text_set(obj, text);
361 elm_object_text_set(obj, "");
367 _save_markup_utf8(const char *file, const char *text)
371 if ((!text) || (!text[0]))
373 ecore_file_unlink(file);
376 f = fopen(file, "wb");
379 // FIXME: report a write error
382 fputs(text, f); // FIXME: catch error
387 _save_plain_utf8(const char *file, const char *text)
391 text2 = elm_entry_markup_to_utf8(text);
394 _save_markup_utf8(file, text2);
399 _save(Evas_Object *obj)
401 Widget_Data *wd = elm_widget_data_get(obj);
403 if (!wd->file) return;
406 case ELM_TEXT_FORMAT_PLAIN_UTF8:
407 _save_plain_utf8(wd->file, elm_object_text_get(obj));
409 case ELM_TEXT_FORMAT_MARKUP_UTF8:
410 _save_markup_utf8(wd->file, elm_object_text_get(obj));
418 _delay_write(void *data)
420 Widget_Data *wd = elm_widget_data_get(data);
421 if (!wd) return ECORE_CALLBACK_CANCEL;
423 wd->delay_write = NULL;
424 return ECORE_CALLBACK_CANCEL;
427 static Elm_Entry_Markup_Filter *
428 _filter_new(Elm_Entry_Filter_Cb func, void *data)
430 Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
431 if (!tf) return NULL;
434 if (func == elm_entry_filter_limit_size)
436 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
443 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
449 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
452 else if (func == elm_entry_filter_accept_set)
454 Elm_Entry_Filter_Accept_Set *as = data, *as2;
461 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
468 as2->accepted = eina_stringshare_add(as->accepted);
470 as2->accepted = NULL;
472 as2->rejected = eina_stringshare_add(as->rejected);
474 as2->rejected = NULL;
483 _filter_free(Elm_Entry_Markup_Filter *tf)
485 if (tf->func == elm_entry_filter_limit_size)
487 Elm_Entry_Filter_Limit_Size *lim = tf->data;
490 else if (tf->func == elm_entry_filter_accept_set)
492 Elm_Entry_Filter_Accept_Set *as = tf->data;
495 if (as->accepted) eina_stringshare_del(as->accepted);
496 if (as->rejected) eina_stringshare_del(as->rejected);
504 _del_pre_hook(Evas_Object *obj)
506 Widget_Data *wd = elm_widget_data_get(obj);
510 ecore_timer_del(wd->delay_write);
511 wd->delay_write = NULL;
512 if (wd->autosave) _save(obj);
514 elm_entry_anchor_hover_end(obj);
515 elm_entry_anchor_hover_parent_set(obj, NULL);
519 _del_hook(Evas_Object *obj)
521 Widget_Data *wd = elm_widget_data_get(obj);
522 Elm_Entry_Context_Menu_Item *it;
523 Elm_Entry_Item_Provider *ip;
524 Elm_Entry_Markup_Filter *tf;
526 evas_event_freeze(evas_object_evas_get(obj));
528 if (wd->file) eina_stringshare_del(wd->file);
530 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
531 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
533 entries = eina_list_remove(entries, obj);
534 #ifdef HAVE_ELEMENTARY_X
535 if (wd->sel_notify_handler)
536 ecore_event_handler_del(wd->sel_notify_handler);
537 if (wd->sel_clear_handler)
538 ecore_event_handler_del(wd->sel_clear_handler);
540 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
541 if (wd->text) eina_stringshare_del(wd->text);
542 if (wd->password_text) eina_stringshare_del(wd->password_text);
543 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
544 if (wd->region_get_job) ecore_job_del(wd->region_get_job);
545 if (wd->region_recalc_job) ecore_job_del(wd->region_recalc_job);
546 if (wd->append_text_idler)
548 ecore_idler_del(wd->append_text_idler);
549 free(wd->append_text_left);
550 wd->append_text_left = NULL;
551 wd->append_text_idler = NULL;
553 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
554 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
555 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
556 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
557 EINA_LIST_FREE(wd->items, it)
559 eina_stringshare_del(it->label);
560 eina_stringshare_del(it->icon_file);
561 eina_stringshare_del(it->icon_group);
564 EINA_LIST_FREE(wd->item_providers, ip)
568 EINA_LIST_FREE(wd->text_filters, tf)
572 EINA_LIST_FREE(wd->markup_filters, tf)
576 if (wd->delay_write) ecore_timer_del(wd->delay_write);
577 if (wd->input_panel_imdata) free(wd->input_panel_imdata);
580 if (wd->anchor_hover.hover_style) eina_stringshare_del(wd->anchor_hover.hover_style);
581 evas_event_thaw(evas_object_evas_get(obj));
582 evas_event_thaw_eval(evas_object_evas_get(obj));
586 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
588 Widget_Data *wd = elm_widget_data_get(obj);
589 edje_object_mirrored_set(wd->ent, rtl);
590 if (wd->anchor_hover.hover)
591 elm_widget_mirrored_set(wd->anchor_hover.hover, rtl);
595 _theme_hook(Evas_Object *obj)
597 Widget_Data *wd = elm_widget_data_get(obj);
600 evas_event_freeze(evas_object_evas_get(obj));
601 _elm_widget_mirrored_reload(obj);
602 _mirrored_set(obj, elm_widget_mirrored_get(obj));
604 t = eina_stringshare_add(elm_object_text_get(obj));
605 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
606 if (_elm_config->desktop_entry)
607 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
608 elm_object_text_set(obj, t);
609 eina_stringshare_del(t);
610 if (elm_widget_disabled_get(obj))
611 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
612 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
613 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
614 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", wd->prediction_allow);
615 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
616 edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len);
617 edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", wd->input_panel_return_key_type);
618 edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", wd->input_panel_return_key_disabled);
620 if (wd->cursor_pos != 0)
621 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
622 if (elm_widget_focus_get(obj))
623 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
624 edje_object_message_signal_process(wd->ent);
625 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
631 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
632 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
633 elm_widget_style_get(obj));
634 edj = elm_smart_scroller_edje_object_get(wd->scroller);
635 str = edje_object_data_get(edj, "focus_highlight");
636 if ((str) && (!strcmp(str, "on")))
637 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
639 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
642 evas_event_thaw(evas_object_evas_get(obj));
643 evas_event_thaw_eval(evas_object_evas_get(obj));
647 _disable_hook(Evas_Object *obj)
649 Widget_Data *wd = elm_widget_data_get(obj);
651 if (elm_widget_disabled_get(obj))
653 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
654 wd->disabled = EINA_TRUE;
658 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
659 wd->disabled = EINA_FALSE;
664 _recalc_cursor_geometry(Evas_Object *obj)
666 Widget_Data *wd = elm_widget_data_get(obj);
668 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
669 if (!wd->deferred_recalc_job)
671 Evas_Coord cx, cy, cw, ch;
672 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
676 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
677 wd->cur_changed = EINA_FALSE;
681 wd->deferred_cur = EINA_TRUE;
685 _elm_deferred_recalc_job(void *data)
687 Widget_Data *wd = elm_widget_data_get(data);
688 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
690 wd->deferred_recalc_job = NULL;
692 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
693 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
694 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
695 /* This is a hack to workaround the way min size hints are treated.
696 * If the minimum width is smaller than the restricted width, it means
697 * the mininmum doesn't matter. */
700 Evas_Coord ominw = -1;
701 evas_object_size_hint_min_get(data, &ominw, NULL);
708 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
711 Evas_Coord vmw = 0, vmh = 0;
713 edje_object_size_min_calc
714 (elm_smart_scroller_edje_object_get(wd->scroller),
718 evas_object_size_hint_min_set(data, vmw, minh + vmh);
719 evas_object_size_hint_max_set(data, -1, minh + vmh);
723 evas_object_size_hint_min_set(data, vmw, vmh);
724 evas_object_size_hint_max_set(data, -1, -1);
731 evas_object_size_hint_min_set(data, minw, minh);
732 evas_object_size_hint_max_set(data, -1, minh);
736 evas_object_size_hint_min_set(data, fw, minh);
737 evas_object_size_hint_max_set(data, -1, -1);
741 if (wd->deferred_cur)
743 Evas_Coord cx, cy, cw, ch;
744 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
748 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
749 wd->cur_changed = EINA_FALSE;
755 _sizing_eval(Evas_Object *obj)
757 Widget_Data *wd = elm_widget_data_get(obj);
758 Evas_Coord minw = -1, minh = -1;
759 Evas_Coord resw, resh;
762 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
765 if ((resw == wd->lastw) && (!wd->changed)) return;
766 evas_event_freeze(evas_object_evas_get(obj));
767 wd->changed = EINA_FALSE;
771 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
773 evas_object_resize(wd->scroller, resw, resh);
774 edje_object_size_min_calc
775 (elm_smart_scroller_edje_object_get(wd->scroller),
777 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
778 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
779 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
780 /* This is a hack to workaround the way min size hints are treated.
781 * If the minimum width is smaller than the restricted width, it means
782 * the mininmum doesn't matter. */
785 Evas_Coord ominw = -1;
786 evas_object_size_hint_min_get(wd->ent, &ominw, NULL);
792 if ((minw > 0) && (vw < minw)) vw = minw;
793 if (minh > vh) vh = minh;
795 if (wd->single_line) h = vmh + minh;
797 evas_object_resize(wd->ent, vw, vh);
798 evas_object_size_hint_min_set(obj, w, h);
800 evas_object_size_hint_max_set(obj, -1, h);
802 evas_object_size_hint_max_set(obj, -1, -1);
806 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
807 wd->deferred_recalc_job = ecore_job_add(_elm_deferred_recalc_job, obj);
809 evas_event_thaw(evas_object_evas_get(obj));
810 evas_event_thaw_eval(evas_object_evas_get(obj));
814 if (!wd->changed) return;
815 evas_event_freeze(evas_object_evas_get(obj));
816 wd->changed = EINA_FALSE;
820 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
822 edje_object_size_min_calc(wd->ent, &minw, &minh);
825 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
827 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
829 if (minw > vw) vw = minw;
830 if (minh > vh) vh = minh;
832 evas_object_resize(wd->ent, vw, vh);
833 edje_object_size_min_calc
834 (elm_smart_scroller_edje_object_get(wd->scroller),
836 if (wd->single_line) h = vmh + minh;
838 evas_object_size_hint_min_set(obj, w, h);
840 evas_object_size_hint_max_set(obj, -1, h);
842 evas_object_size_hint_max_set(obj, -1, -1);
846 edje_object_size_min_calc(wd->ent, &minw, &minh);
849 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
850 evas_object_size_hint_min_set(obj, minw, minh);
852 evas_object_size_hint_max_set(obj, -1, minh);
854 evas_object_size_hint_max_set(obj, -1, -1);
856 evas_event_thaw(evas_object_evas_get(obj));
857 evas_event_thaw_eval(evas_object_evas_get(obj));
860 _recalc_cursor_geometry(obj);
864 _check_enable_return_key(Evas_Object *obj)
866 Widget_Data *wd = elm_widget_data_get(obj);
867 Eina_Bool return_key_disabled = EINA_FALSE;
870 if (!wd->autoreturnkey) return;
872 if (elm_entry_is_empty(obj) == EINA_TRUE)
873 return_key_disabled = EINA_TRUE;
875 elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
879 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
881 Widget_Data *wd = elm_widget_data_get(obj);
882 Evas_Object *top = elm_widget_top_get(obj);
884 if (!wd->editable) return;
885 if (elm_widget_focus_get(obj))
887 printf("[Elm_entry::Focused] obj : %p\n", obj);
888 evas_object_focus_set(wd->ent, EINA_TRUE);
889 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
890 if (top && wd->input_panel_enable)
891 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
892 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
893 _check_enable_return_key(obj);
894 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
898 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
899 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
900 evas_object_focus_set(wd->ent, EINA_FALSE);
901 if (top && wd->input_panel_enable)
902 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
903 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
905 if ((wd->api) && (wd->api->obj_hidemenu))
907 wd->api->obj_hidemenu(obj);
913 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
915 Widget_Data *wd = elm_widget_data_get(obj);
917 if ((!wd) || (!content)) return;
920 edje = elm_smart_scroller_edje_object_get(wd->scroller);
924 /* Delete the currently swallowed object */
925 Evas_Object *cswallow;
927 if (!part || !strcmp(part, "icon"))
929 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon");
930 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
932 else if (!strcmp(part, "end"))
934 cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end");
935 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
938 cswallow = edje_object_part_swallow_get(edje, part);
940 if (cswallow) evas_object_del(cswallow);
942 evas_event_freeze(evas_object_evas_get(obj));
943 elm_widget_sub_object_add(obj, content);
945 if (!part || !strcmp(part, "icon"))
946 edje_object_part_swallow(edje, "elm.swallow.icon", content);
947 else if (!strcmp(part, "end"))
948 edje_object_part_swallow(edje, "elm.swallow.end", content);
950 edje_object_part_swallow(edje, part, content);
953 evas_event_thaw(evas_object_evas_get(obj));
954 evas_event_thaw_eval(evas_object_evas_get(obj));
958 _content_unset_hook(Evas_Object *obj, const char *part)
960 Widget_Data *wd = elm_widget_data_get(obj);
961 Evas_Object *content, *edje;
962 if (!wd) return NULL;
965 edje = elm_smart_scroller_edje_object_get(wd->scroller);
969 if (!part || !strcmp(part, "icon"))
971 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
972 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
974 else if (!strcmp(part, "end"))
976 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
977 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
980 content = edje_object_part_swallow_get(edje, part);
982 edje_object_part_swallow(edje, part, NULL);
983 if (!content) return NULL;
984 evas_event_freeze(evas_object_evas_get(obj));
985 elm_widget_sub_object_del(obj, content);
986 edje_object_part_unswallow(wd->ent, content);
988 evas_event_thaw(evas_object_evas_get(obj));
989 evas_event_thaw_eval(evas_object_evas_get(obj));
995 _content_get_hook(const Evas_Object *obj, const char *part)
997 Widget_Data *wd = elm_widget_data_get(obj);
998 Evas_Object *content = NULL, *edje;
999 if (!wd) return NULL;
1002 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1006 if (!edje) return NULL;
1008 if (!part || !strcmp(part, "icon"))
1009 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
1010 else if (!strcmp(part, "end"))
1011 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
1013 content = edje_object_part_swallow_get(edje, part);
1019 _translate_hook(Evas_Object *obj)
1021 evas_object_smart_callback_call(obj, "language,changed", NULL);
1025 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
1027 Widget_Data *wd = elm_widget_data_get(obj);
1029 edje_object_signal_emit(wd->ent, emission, source);
1031 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
1036 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1038 Widget_Data *wd = elm_widget_data_get(obj);
1040 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
1042 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
1043 emission, source, func_cb, data);
1047 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1049 Widget_Data *wd = elm_widget_data_get(obj);
1050 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
1053 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
1054 emission, source, func_cb, data);
1058 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1060 Widget_Data *wd = elm_widget_data_get(obj);
1061 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
1065 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1067 Widget_Data *wd = elm_widget_data_get(obj);
1069 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1073 _show_region_hook(void *data, Evas_Object *obj)
1075 Widget_Data *wd = elm_widget_data_get(data);
1076 Evas_Coord x, y, w, h;
1078 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1080 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1084 _sub_del(void *data, Evas_Object *obj, void *event_info)
1086 Widget_Data *wd = data;
1087 Evas_Object *sub = event_info;
1091 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1095 if (sub == edje_object_part_swallow_get(edje, "elm.swallow.icon"))
1097 edje_object_part_unswallow(edje, sub);
1099 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1101 else if (sub == edje_object_part_swallow_get(edje, "elm.swallow.end"))
1103 edje_object_part_unswallow(edje, sub);
1105 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1111 _hoversel_position(Evas_Object *obj)
1113 Widget_Data *wd = elm_widget_data_get(obj);
1114 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1119 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1128 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1129 &cx, &cy, &cw, &ch);
1130 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1133 cx += (cw - mw) / 2;
1138 cy += (ch - mh) / 2;
1141 evas_object_move(wd->hoversel, x + cx, y + cy);
1142 evas_object_resize(wd->hoversel, cw, ch);
1146 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1148 Widget_Data *wd = elm_widget_data_get(data);
1150 if (wd->hoversel) _hoversel_position(data);
1152 if (!_elm_config->desktop_entry)
1154 if (wd->region_get_job) ecore_job_del(wd->region_get_job);
1155 wd->region_get_job = ecore_job_add(_region_get_job, data);
1160 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1162 Widget_Data *wd = elm_widget_data_get(data);
1169 else if (wd->scroll)
1171 Evas_Coord vw = 0, vh = 0;
1173 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1174 if (vw < wd->entmw) vw = wd->entmw;
1175 if (vh < wd->entmh) vh = wd->entmh;
1176 evas_object_resize(wd->ent, vw, vh);
1178 if (wd->hoversel) _hoversel_position(data);
1180 if (!_elm_config->desktop_entry)
1182 if (wd->region_get_job) ecore_job_del(wd->region_get_job);
1183 wd->region_get_job = ecore_job_add(_region_get_job, data);
1188 _hover_del(void *data)
1190 Widget_Data *wd = elm_widget_data_get(data);
1195 evas_object_del(wd->hoversel);
1196 wd->hoversel = NULL;
1198 wd->hovdeljob = NULL;
1202 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1204 Widget_Data *wd = elm_widget_data_get(data);
1207 if (wd->hoversel) evas_object_hide(wd->hoversel);
1210 if (!_elm_config->desktop_entry)
1213 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1216 elm_widget_scroll_freeze_pop(data);
1217 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1218 wd->hovdeljob = ecore_job_add(_hover_del, data);
1222 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1224 Widget_Data *wd = elm_widget_data_get(data);
1226 wd->selmode = EINA_TRUE;
1227 edje_object_part_text_select_none(wd->ent, "elm.text");
1228 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1229 edje_object_part_text_select_all(wd->ent, "elm.text");
1230 elm_object_scroll_freeze_pop(data);
1234 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1236 Widget_Data *wd = elm_widget_data_get(data);
1238 wd->selmode = EINA_TRUE;
1239 edje_object_part_text_select_none(wd->ent, "elm.text");
1240 if (!_elm_config->desktop_entry)
1243 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1245 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1246 if (!_elm_config->desktop_entry)
1247 elm_object_scroll_freeze_pop(data); // TIZEN ONLY
1248 //elm_widget_scroll_hold_push(data);
1252 _remove_item_tags(const char *str)
1258 Eina_Strbuf *buf = eina_strbuf_new();
1262 if (!eina_strbuf_append(buf, str))
1267 const char *temp = eina_strbuf_string_get(buf);
1269 char *startTag = NULL;
1270 char *endTag = NULL;
1272 startTag = strstr(temp, "<item");
1274 startTag = strstr(temp, "</item");
1276 endTag = strstr(startTag, ">");
1279 if (!endTag || startTag > endTag)
1282 size_t sindex = startTag - temp;
1283 size_t eindex = endTag - temp + 1;
1284 if (!eina_strbuf_remove(buf, sindex, eindex))
1287 ret = eina_strbuf_string_steal(buf);
1288 eina_strbuf_free(buf);
1293 _elm_entry_entry_paste(Evas_Object *obj, const char *entry)
1295 Widget_Data *wd = elm_widget_data_get(obj);
1298 if (wd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
1300 str = _remove_item_tags(entry);
1301 if (!str) str = strdup(entry);
1304 str = strdup(entry);
1305 if (!str) str = (char *)entry;
1307 edje_object_part_text_user_insert(wd->ent, "elm.text", str);
1308 if (str != entry) free(str);
1312 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1314 Widget_Data *wd = elm_widget_data_get(data);
1316 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1317 if (wd->sel_notify_handler)
1319 #ifdef HAVE_ELEMENTARY_X
1320 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1321 wd->selection_asked = EINA_TRUE;
1322 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1323 formats = ELM_SEL_FORMAT_TEXT;
1324 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1325 formats |= ELM_SEL_FORMAT_IMAGE;
1326 elm_cnp_selection_get(data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1332 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1334 Widget_Data *wd = elm_widget_data_get(obj);
1338 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1339 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1340 elm_cnp_selection_set(obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1341 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1342 eina_stringshare_replace(&wd->cut_sel, sel);
1346 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1348 Widget_Data *wd = elm_widget_data_get(data);
1351 wd->selmode = EINA_FALSE;
1352 if (!_elm_config->desktop_entry)
1353 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1354 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1355 if (!_elm_config->desktop_entry)
1356 elm_widget_scroll_hold_pop(data);
1357 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1358 edje_object_part_text_user_insert(wd->ent, "elm.text", "");
1363 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1365 Widget_Data *wd = elm_widget_data_get(data);
1367 wd->selmode = EINA_FALSE;
1368 if (!_elm_config->desktop_entry)
1370 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1371 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1372 elm_widget_scroll_hold_pop(data);
1374 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1375 // edje_object_part_text_select_none(wd->ent, "elm.text");
1379 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1381 Widget_Data *wd = elm_widget_data_get(data);
1383 wd->selmode = EINA_FALSE;
1384 if (!_elm_config->desktop_entry)
1385 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1386 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1387 if (!_elm_config->desktop_entry)
1388 elm_widget_scroll_hold_pop(data);
1389 edje_object_part_text_select_none(wd->ent, "elm.text");
1394 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1396 Widget_Data *wd = elm_widget_data_get(data);
1398 cnpwidgetdata = data;
1404 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1406 Elm_Entry_Context_Menu_Item *it = data;
1407 Evas_Object *obj2 = it->obj;
1408 if (it->func) it->func(it->data, obj2, NULL);
1412 _menu_press(Evas_Object *obj)
1414 Widget_Data *wd = elm_widget_data_get(obj);
1417 const Elm_Entry_Context_Menu_Item *it;
1419 if ((wd->api) && (wd->api->obj_longpress))
1421 wd->api->obj_longpress(obj);
1423 else if (wd->context_menu)
1425 const char *context_menu_orientation;
1427 if (wd->hoversel) evas_object_del(wd->hoversel);
1428 else elm_widget_scroll_freeze_push(obj);
1429 wd->hoversel = elm_hoversel_add(obj);
1430 context_menu_orientation = edje_object_data_get
1431 (wd->ent, "context_menu_orientation");
1432 if ((context_menu_orientation) &&
1433 (!strcmp(context_menu_orientation, "horizontal")))
1434 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1435 elm_object_style_set(wd->hoversel, "entry");
1436 elm_widget_sub_object_add(obj, wd->hoversel);
1437 elm_object_text_set(wd->hoversel, "Text");
1438 top = elm_widget_top_get(obj);
1439 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1440 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1441 if (wd->have_selection)
1445 if (wd->have_selection)
1447 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1450 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1453 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1461 if (!_elm_config->desktop_entry)
1464 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1467 if (elm_selection_selection_has_owner())
1470 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1475 EINA_LIST_FOREACH(wd->items, l, it)
1477 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1478 it->icon_type, _item_clicked, it);
1482 _hoversel_position(obj);
1483 evas_object_show(wd->hoversel);
1484 elm_hoversel_hover_begin(wd->hoversel);
1486 if (!_elm_config->desktop_entry)
1488 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1489 edje_object_part_text_select_abort(wd->ent, "elm.text");
1495 _magnifier_hide(void *data)
1497 Widget_Data *wd = elm_widget_data_get(data);
1500 evas_object_hide(wd->mgf_bg);
1501 evas_object_hide(wd->mgf_clip);
1504 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1508 _magnifier_show(void *data)
1510 Widget_Data *wd = elm_widget_data_get(data);
1513 evas_object_show(wd->mgf_bg);
1514 evas_object_show(wd->mgf_clip);
1518 _magnifier_move(void *data)
1520 Widget_Data *wd = elm_widget_data_get(data);
1523 Evas_Coord x, y, w, h;
1524 Evas_Coord cx, cy, cw, ch, ox, oy;
1526 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1530 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1531 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1536 evas_object_geometry_get(data, &x, &y, &w, &h);
1540 if ((cy + y) - wd->mgf_height < 0)
1541 oy = -1 * ((cy + y) - wd->mgf_height);
1543 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1544 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height + oy);
1545 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1546 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height + oy);
1550 evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 + oy);
1554 _magnifier_create(void *data)
1556 Widget_Data *wd = elm_widget_data_get(data);
1557 Evas_Coord x, y, w, h, mw, mh;
1558 const char* key_data = NULL;
1565 evas_object_image_source_unset(wd->mgf_proxy);
1566 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1567 evas_object_hide(wd->mgf_proxy);
1568 evas_object_clip_unset(wd->mgf_proxy);
1569 evas_object_del(wd->mgf_proxy);
1571 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1572 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1575 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1577 evas_object_geometry_get(data, &x, &y, &w, &h);
1579 if ((w <= 0) || (h <= 0))
1582 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1584 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1585 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1586 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1587 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1591 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1592 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1593 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1595 key_data = edje_object_data_get(wd->mgf_bg, "height");
1596 if (key_data) wd->mgf_height = atoi(key_data);
1597 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1598 if (key_data) wd->mgf_scale = atof(key_data);
1600 elm_scale = elm_scale_get();
1601 wd->mgf_height = (int)((float)wd->mgf_height * elm_scale);
1603 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1604 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1608 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1609 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1610 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1614 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1615 evas_object_image_source_set(wd->mgf_proxy, data);
1618 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1619 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1620 if ((mw <= 0) || (mh <= 0))
1623 evas_object_resize(wd->mgf_proxy, mw, mh);
1624 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1625 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1626 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1627 evas_object_show(wd->mgf_proxy);
1628 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1630 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1631 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1635 _signal_long_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1637 Widget_Data *wd = elm_widget_data_get(data);
1640 wd->long_pressed = EINA_TRUE;
1641 _cancel(data, NULL, NULL);
1642 if (wd->magnifier_enabled)
1644 _magnifier_create(data);
1645 _magnifier_move(data);
1646 _magnifier_show(data);
1647 elm_object_scroll_freeze_push(data);
1652 _long_press(void *data)
1654 Widget_Data *wd = elm_widget_data_get(data);
1655 if (!wd) return ECORE_CALLBACK_CANCEL;
1656 //_menu_press(data); /////// TIZEN ONLY
1657 wd->longpress_timer = NULL;
1658 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1659 return ECORE_CALLBACK_CANCEL;
1663 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1665 Widget_Data *wd = elm_widget_data_get(data);
1666 Evas_Event_Mouse_Down *ev = event_info;
1668 if (wd->disabled) return;
1669 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1670 wd->downx = ev->canvas.x;
1671 wd->downy = ev->canvas.y;
1672 wd->long_pressed = EINA_FALSE;
1673 if (ev->button == 1)
1675 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1676 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1681 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1683 Widget_Data *wd = elm_widget_data_get(data);
1684 Evas_Event_Mouse_Up *ev = event_info;
1686 if (wd->disabled) return;
1687 if (ev->button == 1)
1689 if (!wd->double_clicked)
1691 if ((wd->api) && (wd->api->obj_mouseup))
1692 wd->api->obj_mouseup(data);
1694 if (wd->magnifier_enabled)
1696 _magnifier_hide(data);
1697 elm_object_scroll_freeze_pop(data);
1699 if (wd->long_pressed)
1701 if (wd->longpress_timer)
1703 ecore_timer_del(wd->longpress_timer);
1704 wd->longpress_timer = NULL;
1707 else if (ev->button == 3)
1715 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1717 Widget_Data *wd = elm_widget_data_get(data);
1718 Evas_Event_Mouse_Move *ev = event_info;
1720 if (wd->disabled) return;
1722 if (ev->buttons == 1)
1724 if ((wd->long_pressed) && (wd->magnifier_enabled))
1726 _magnifier_show(data);
1727 _magnifier_move(data);
1732 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1734 if (wd->longpress_timer)
1736 ecore_timer_del(wd->longpress_timer);
1737 wd->longpress_timer = NULL;
1740 else if (wd->longpress_timer)
1744 dx = wd->downx - ev->cur.canvas.x;
1746 dy = wd->downy - ev->cur.canvas.y;
1749 ((_elm_config->finger_size / 2) *
1750 (_elm_config->finger_size / 2)))
1752 ecore_timer_del(wd->longpress_timer);
1753 wd->longpress_timer = NULL;
1757 else if (wd->longpress_timer)
1761 dx = wd->downx - ev->cur.canvas.x;
1763 dy = wd->downy - ev->cur.canvas.y;
1766 ((_elm_config->finger_size / 2) *
1767 (_elm_config->finger_size / 2)))
1769 ecore_timer_del(wd->longpress_timer);
1770 wd->longpress_timer = NULL;
1776 _getbase(Evas_Object *obj)
1778 Widget_Data *wd = elm_widget_data_get(obj);
1779 if (!wd) return "base";
1782 if (wd->password) return "base-password";
1785 if (wd->single_line) return "base-single";
1788 switch (wd->linewrap)
1791 return "base-charwrap";
1794 case ELM_WRAP_MIXED:
1795 return "base-mixedwrap";
1798 return "base-nowrap";
1805 if (wd->password) return "base-password";
1808 if (wd->single_line) return "base-single-noedit";
1811 switch (wd->linewrap)
1814 return "base-noedit-charwrap";
1816 return "base-noedit";
1817 case ELM_WRAP_MIXED:
1818 return "base-noedit-mixedwrap";
1821 return "base-nowrap-noedit";
1829 _entry_changed_common_handling(void *data, const char *event)
1831 Widget_Data *wd = elm_widget_data_get(data);
1834 evas_event_freeze(evas_object_evas_get(data));
1835 wd->changed = EINA_TRUE;
1836 /* Reset the size hints which are no more relevant.
1837 * Keep the height, this is a hack, but doesn't really matter
1838 * cause we'll re-eval in a moment. */
1839 evas_object_size_hint_min_get(data, NULL, &minh);
1840 evas_object_size_hint_min_set(data, -1, minh);
1842 if (wd->text) eina_stringshare_del(wd->text);
1844 if (wd->password_text) eina_stringshare_del(wd->password_text);
1845 wd->password_text = NULL;
1846 if (wd->delay_write)
1848 ecore_timer_del(wd->delay_write);
1849 wd->delay_write = NULL;
1852 if ((wd->api) && (wd->api->obj_hidemenu))
1853 wd->api->obj_hidemenu(data);
1855 evas_event_thaw(evas_object_evas_get(data));
1856 evas_event_thaw_eval(evas_object_evas_get(data));
1857 if ((wd->autosave) && (wd->file))
1858 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1859 /* callback - this could call callbacks that delete the entry... thus...
1860 * any access to wd after this could be invalid */
1861 evas_object_smart_callback_call(data, event, NULL);
1862 _check_enable_return_key(data);
1866 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1868 _entry_changed_common_handling(data, SIG_CHANGED);
1872 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1874 Widget_Data *wd = elm_widget_data_get(data);
1877 elm_object_scroll_freeze_push(data);
1879 if ((wd->api) && (wd->api->obj_hidemenu))
1880 wd->api->obj_hidemenu(data);
1882 if (wd->magnifier_enabled)
1884 _magnifier_create(data);
1885 _magnifier_move(data);
1886 _magnifier_show(data);
1891 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1893 Widget_Data *wd = elm_widget_data_get(data);
1896 elm_object_scroll_freeze_pop(data);
1898 if (wd->have_selection)
1900 _magnifier_hide(data);
1906 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1908 Widget_Data *wd = elm_widget_data_get(data);
1911 if (wd->magnifier_enabled)
1913 _magnifier_move(data);
1914 _magnifier_show(data);
1918 static Evas_Coord_Rectangle
1919 _intersection_region_get(Evas_Coord_Rectangle rect1, Evas_Coord_Rectangle rect2)
1921 Evas_Coord_Rectangle ret_rect;
1922 Evas_Coord_Point l1, l2, r1, r2, p1, p2;
1926 r1.x = rect1.x + rect1.w;
1927 r1.y = rect1.y + rect1.h;
1931 r2.x = rect2.x + rect2.w;
1932 r2.y = rect2.y + rect2.h;
1934 p1.x = (l1.x > l2.x) ? l1.x : l2.x;
1935 p1.y = (l1.y > l2.y) ? l1.y : l2.y;
1936 p2.x = (r1.x < r2.x) ? r1.x : r2.x;
1937 p2.y = (r1.y < r2.y) ? r1.y : r2.y;
1941 ret_rect.w = (p2.x > p1.x) ? p2.x - p1.x : -1;
1942 ret_rect.h = (p2.y > p1.y) ? p2.y - p1.y : -1;
1947 static Evas_Coord_Rectangle
1948 _viewport_region_get(Evas_Object *data)
1950 Evas_Coord_Rectangle geometry, ret_rect;
1951 geometry.x = geometry.y = geometry.w = geometry.h = -1;
1952 ret_rect = geometry;
1954 Widget_Data *wd = elm_widget_data_get(data);
1955 if (!wd) return geometry;
1956 if (!data || !strlen(elm_widget_type_get(data))) return geometry;
1960 evas_object_geometry_get(wd->scroller, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
1961 ret_rect = geometry;
1964 Evas_Object *parent_obj = data;
1966 while ((parent_obj = elm_widget_parent_get(parent_obj)))
1968 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
1969 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
1971 evas_object_geometry_get(parent_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
1972 if ((ret_rect.w == -1) && (ret_rect.h == -1)) ret_rect = geometry;
1973 ret_rect = _intersection_region_get(geometry, ret_rect);
1980 static Evas_Coord_Rectangle
1981 _layout_region_get(Evas_Object *data)
1983 Evas_Coord_Rectangle geometry;
1984 geometry.x = geometry.y = geometry.w = geometry.h = -1;
1986 Widget_Data *wd = elm_widget_data_get(data);
1987 if (!wd) return geometry;
1988 if (!data || !strlen(elm_widget_type_get(data))) return geometry;
1990 Evas_Object *child_obj = data;
1991 Evas_Object *parent_obj;
1993 while ((parent_obj = elm_widget_parent_get(child_obj)))
1995 if (!strcmp(elm_widget_type_get(parent_obj), "conformant"))
1997 evas_object_geometry_get(child_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
2000 child_obj = parent_obj;
2007 _region_get_job(void *data)
2009 Widget_Data *wd = elm_widget_data_get(data);
2010 Evas_Coord_Rectangle ret_rect;
2012 wd->region_get_job = NULL;
2014 if (!_elm_config->desktop_entry)
2016 if (wd->region_recalc_job) ecore_job_del(wd->region_recalc_job);
2017 wd->region_recalc_job = ecore_job_add(_region_recalc_job, data);
2019 evas_smart_objects_calculate(evas_object_evas_get(data));
2024 _region_recalc_job(void *data)
2026 Widget_Data *wd = elm_widget_data_get(data);
2027 Evas_Coord_Rectangle ret_rect;
2029 wd->region_recalc_job = NULL;
2031 if (!_elm_config->desktop_entry)
2033 ret_rect = _viewport_region_get(data);
2034 edje_object_part_text_viewport_region_set(wd->ent, "elm.text", ret_rect.x, ret_rect.y, ret_rect.w, ret_rect.h);
2035 ret_rect = _layout_region_get(data);
2036 edje_object_part_text_layout_region_set(wd->ent, "elm.text", ret_rect.x, ret_rect.y, ret_rect.w, ret_rect.h);
2041 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2043 Widget_Data *wd = elm_widget_data_get(data);
2046 if (wd->magnifier_enabled)
2047 _magnifier_hide(data);
2052 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2054 Elm_Entry_Change_Info info;
2055 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
2056 edje_object_signal_callback_extra_data_get();
2059 memcpy(&info, edje_info, sizeof(info));
2060 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
2064 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
2069 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2071 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
2075 _signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2077 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
2081 _signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2083 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
2087 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2089 Widget_Data *wd = elm_widget_data_get(data);
2093 EINA_LIST_FOREACH(entries, l, entry)
2095 if (entry != data) elm_entry_select_none(entry);
2097 wd->have_selection = EINA_TRUE;
2098 wd->selmode = EINA_TRUE;
2099 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2100 #ifdef HAVE_ELEMENTARY_X
2101 if (wd->sel_notify_handler)
2103 const char *txt = elm_entry_selection_get(data);
2106 top = elm_widget_top_get(data);
2107 if (txt && top && (elm_win_xwindow_get(top)))
2108 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2109 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
2115 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2117 Evas_Coord cx, cy, cw, ch;
2118 Widget_Data *wd = elm_widget_data_get(data);
2121 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2122 if (!wd->deferred_recalc_job)
2123 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2126 wd->deferred_cur = EINA_TRUE;
2135 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2137 Widget_Data *wd = elm_widget_data_get(data);
2139 elm_entry_select_all(data);
2143 _signal_selection_none(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2145 Widget_Data *wd = elm_widget_data_get(data);
2147 elm_entry_select_none(data);
2151 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2153 Evas_Coord cx, cy, cw, ch;
2154 Widget_Data *wd = elm_widget_data_get(data);
2156 wd->have_selection = EINA_TRUE;
2157 wd->selmode = EINA_TRUE;
2158 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2159 _store_selection(ELM_SEL_TYPE_PRIMARY, data);
2162 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2163 if (!wd->deferred_recalc_job)
2164 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2167 wd->deferred_cur = EINA_TRUE;
2177 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2179 Widget_Data *wd = elm_widget_data_get(data);
2181 if (!wd->have_selection) return;
2182 wd->have_selection = EINA_FALSE;
2183 wd->selmode = EINA_FALSE; /////////////// exist in ours only - necessary ?
2184 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2185 if (wd->sel_notify_handler)
2189 #ifdef HAVE_ELEMENTARY_X
2192 top = elm_widget_top_get(data);
2193 if ((top) && (elm_win_xwindow_get(top)))
2194 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2195 ELM_SEL_FORMAT_MARKUP, wd->cut_sel,
2196 strlen(wd->cut_sel));
2198 eina_stringshare_del(wd->cut_sel);
2203 #ifdef HAVE_ELEMENTARY_X
2206 top = elm_widget_top_get(data);
2207 if ((top) && (elm_win_xwindow_get(top)))
2208 elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
2213 if ((wd->api) && (wd->api->obj_hidemenu))
2215 wd->api->obj_hidemenu(data);
2220 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2222 Widget_Data *wd = elm_widget_data_get(data);
2223 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
2224 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
2226 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2227 if (wd->sel_notify_handler)
2229 #ifdef HAVE_ELEMENTARY_X
2232 top = elm_widget_top_get(data);
2233 if ((top) && (elm_win_xwindow_get(top)))
2235 wd->selection_asked = EINA_TRUE;
2236 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2237 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2238 formats = ELM_SEL_FORMAT_TEXT;
2239 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2240 formats |= ELM_SEL_FORMAT_IMAGE;
2241 elm_cnp_selection_get(data, type, formats,
2249 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2251 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2252 _copy(data, NULL, NULL);
2256 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2258 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2259 _cut(data, NULL, NULL);
2263 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2265 Widget_Data *wd = elm_widget_data_get(data);
2267 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2268 wd->cur_changed = EINA_TRUE;
2269 _recalc_cursor_geometry(data);
2273 _signal_cursor_changed_manual(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2275 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
2280 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
2282 const Eina_List *geoms, *l;
2283 Evas_Textblock_Rectangle *r;
2284 Evas_Coord px, py, x, y;
2286 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
2290 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2291 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2292 EINA_LIST_FOREACH(geoms, l, r)
2294 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2295 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2307 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2309 Widget_Data *wd = elm_widget_data_get(data);
2310 Elm_Entry_Anchor_Info ei;
2314 p = emission + sizeof("nchor,mouse,down,");
2315 ei.button = strtol(p, &p2, 10);
2317 ei.x = ei.y = ei.w = ei.h = 0;
2319 _signal_anchor_geoms_do_things_with(wd, &ei);
2322 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
2326 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2328 Widget_Data *wd = elm_widget_data_get(data);
2329 Elm_Entry_Anchor_Info ei;
2333 p = emission + sizeof("nchor,mouse,up,");
2334 ei.button = strtol(p, &p2, 10);
2336 ei.x = ei.y = ei.w = ei.h = 0;
2338 _signal_anchor_geoms_do_things_with(wd, &ei);
2341 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
2345 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2347 Widget_Data *wd = elm_widget_data_get(data);
2348 Elm_Entry_Anchor_Info ei;
2352 p = emission + sizeof("nchor,mouse,clicked,");
2353 ei.button = strtol(p, &p2, 10);
2355 ei.x = ei.y = ei.w = ei.h = 0;
2357 _signal_anchor_geoms_do_things_with(wd, &ei);
2361 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2363 _entry_hover_anchor_clicked(data, data, &ei);
2368 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2370 Widget_Data *wd = elm_widget_data_get(data);
2375 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2377 Widget_Data *wd = elm_widget_data_get(data);
2378 Elm_Entry_Anchor_Info ei;
2380 ei.name = emission + sizeof("nchor,mouse,in,");
2382 ei.x = ei.y = ei.w = ei.h = 0;
2384 _signal_anchor_geoms_do_things_with(wd, &ei);
2387 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
2391 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2393 Widget_Data *wd = elm_widget_data_get(data);
2394 Elm_Entry_Anchor_Info ei;
2396 ei.name = emission + sizeof("nchor,mouse,out,");
2398 ei.x = ei.y = ei.w = ei.h = 0;
2400 _signal_anchor_geoms_do_things_with(wd, &ei);
2403 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
2407 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2409 Widget_Data *wd = elm_widget_data_get(data);
2411 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2415 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2417 Widget_Data *wd = elm_widget_data_get(data);
2419 wd->double_clicked = EINA_FALSE;
2420 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2422 if ((wd->api) && (wd->api->obj_hidemenu))
2423 wd->api->obj_hidemenu(data);
2427 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2429 Widget_Data *wd = elm_widget_data_get(data);
2431 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2433 if (!_elm_config->desktop_entry && !wd->double_clicked)
2434 _cancel(data, NULL, NULL);
2438 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2440 Widget_Data *wd = elm_widget_data_get(data);
2442 wd->double_clicked = EINA_TRUE;
2443 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2447 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2449 Widget_Data *wd = elm_widget_data_get(data);
2451 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
2454 #ifdef HAVE_ELEMENTARY_X
2456 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2458 Widget_Data *wd = elm_widget_data_get(data);
2459 Ecore_X_Event_Selection_Notify *ev = event;
2460 if (!wd) return ECORE_CALLBACK_PASS_ON;
2461 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2462 return ECORE_CALLBACK_PASS_ON;
2464 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2465 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2467 Ecore_X_Selection_Data_Text *text_data;
2469 text_data = ev->data;
2470 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2472 if (text_data->text)
2474 char *txt = _elm_util_text_to_mkup(text_data->text);
2478 elm_entry_entry_insert(data, txt);
2483 wd->selection_asked = EINA_FALSE;
2485 else if (ev->selection == ECORE_X_SELECTION_XDND)
2487 Ecore_X_Selection_Data_Text *text_data;
2489 text_data = ev->data;
2490 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2492 if (text_data->text)
2494 char *txt = _elm_util_text_to_mkup(text_data->text);
2498 /* Massive FIXME: this should be at the drag point */
2499 elm_entry_entry_insert(data, txt);
2504 wd->drag_selection_asked = EINA_FALSE;
2506 ecore_x_dnd_send_finished();
2509 return ECORE_CALLBACK_PASS_ON;
2513 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2516 Widget_Data *wd = elm_widget_data_get(data);
2517 Ecore_X_Event_Selection_Clear *ev = event;
2518 if (!wd) return ECORE_CALLBACK_PASS_ON;
2519 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2520 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2521 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2523 elm_entry_select_none(data);
2528 Evas_Object *top = elm_widget_top_get(data);
2529 Ecore_X_Event_Selection_Clear *ev = event;
2532 return ECORE_CALLBACK_PASS_ON;
2534 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2536 return ECORE_CALLBACK_PASS_ON;
2539 if (cnpwidgetdata == data)
2541 Widget_Data *wd = elm_widget_data_get(data);
2542 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2543 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2544 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2545 formats = ELM_SEL_FORMAT_TEXT;
2546 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2547 formats |= ELM_SEL_FORMAT_IMAGE;
2548 elm_cnp_selection_get(ELM_SEL_TYPE_SECONDARY, formats, data, NULL, NULL);
2553 return ECORE_CALLBACK_PASS_ON;
2557 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2562 wd = elm_widget_data_get(obj);
2563 if (!wd) return EINA_FALSE;
2564 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2566 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2567 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2568 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2569 EDJE_CURSOR_MAIN,drop->x,drop->y);
2570 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2571 elm_entry_entry_insert(obj, drop->data);
2572 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2573 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2579 static Evas_Object *
2580 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2582 Widget_Data *wd = elm_widget_data_get(data);
2585 Elm_Entry_Item_Provider *ip;
2587 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2589 o = ip->func(ip->data, data, item);
2592 if (!strncmp(item, "file://", 7))
2594 const char *fname = item + 7;
2596 o = evas_object_image_filled_add(evas_object_evas_get(data));
2597 evas_object_image_file_set(o, fname, NULL);
2598 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2600 evas_object_show(o);
2605 o = edje_object_add(evas_object_evas_get(data));
2606 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2610 o = edje_object_add(evas_object_evas_get(data));
2611 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2612 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2617 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2619 Widget_Data *wd = elm_widget_data_get(data);
2621 Elm_Entry_Markup_Filter *tf;
2623 if (type == EDJE_TEXT_FILTER_FORMAT)
2626 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2628 tf->func(tf->data, data, text);
2635 _markup_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, char **text)
2637 Widget_Data *wd = elm_widget_data_get(data);
2639 Elm_Entry_Markup_Filter *tf;
2641 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
2643 tf->func(tf->data, data, text);
2649 /* This function is used to insert text by chunks in jobs */
2651 _text_append_idler(void *data)
2655 Evas_Object *obj = (Evas_Object *) data;
2656 Widget_Data *wd = elm_widget_data_get(obj);
2657 if (wd->text) eina_stringshare_del(wd->text);
2659 if (wd->password_text) eina_stringshare_del(wd->password_text);
2660 wd->password_text = NULL;
2661 evas_event_freeze(evas_object_evas_get(obj));
2662 wd->changed = EINA_TRUE;
2664 start = wd->append_text_position;
2665 if (start + _CHUNK_SIZE < wd->append_text_len)
2668 int tag_start, esc_start;
2670 tag_start = esc_start = -1;
2671 /* Find proper markup cut place */
2672 while (pos - start < _CHUNK_SIZE)
2676 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2677 if (esc_start == -1)
2680 tag_start = prev_pos;
2681 else if (tmp == '>')
2684 if (tag_start == -1)
2687 esc_start = prev_pos;
2688 else if (tmp == ';')
2695 wd->append_text_position = tag_start;
2697 else if (esc_start >= 0)
2699 wd->append_text_position = esc_start;
2703 wd->append_text_position = pos;
2708 wd->append_text_position = wd->append_text_len;
2711 backup = wd->append_text_left[wd->append_text_position];
2712 wd->append_text_left[wd->append_text_position] = '\0';
2714 edje_object_part_text_append(wd->ent, "elm.text",
2715 wd->append_text_left + start);
2717 wd->append_text_left[wd->append_text_position] = backup;
2719 evas_event_thaw(evas_object_evas_get(obj));
2720 evas_event_thaw_eval(evas_object_evas_get(obj));
2722 /* If there's still more to go, renew the idler, else, cleanup */
2723 if (wd->append_text_position < wd->append_text_len)
2725 return ECORE_CALLBACK_RENEW;
2729 free(wd->append_text_left);
2730 wd->append_text_left = NULL;
2731 wd->append_text_idler = NULL;
2732 return ECORE_CALLBACK_CANCEL;
2737 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2739 int i = 0, current_len = 0;
2743 if (unit >= LENGTH_UNIT_LAST) return;
2745 current_len = strlen(*text);
2748 int idx = 0, unit_size = 0;
2749 char *markup, *utfstr;
2750 if (*new_text == '<')
2752 while (*(new_text + idx) != '>')
2755 if (!*(new_text + idx)) break;
2758 else if (*new_text == '&')
2760 while (*(new_text + idx) != ';')
2763 if (!*(new_text + idx)) break;
2766 idx = evas_string_char_next_get(new_text, idx, NULL);
2767 markup = malloc(idx + 1);
2770 strncpy(markup, new_text, idx);
2772 utfstr = elm_entry_markup_to_utf8(markup);
2775 if (unit == LENGTH_UNIT_BYTE)
2776 unit_size = strlen(utfstr);
2777 else if (unit == LENGTH_UNIT_CHAR)
2778 unit_size = evas_string_char_len_get(utfstr);
2785 if (can_add < unit_size)
2789 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2795 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2797 (*text)[current_len] = 0;
2802 can_add -= unit_size;
2806 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2810 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2813 ELM_CHECK_WIDTYPE(obj, widtype);
2814 Widget_Data *wd = elm_widget_data_get(obj);
2816 evas_event_freeze(evas_object_evas_get(obj));
2817 if (!entry) entry = "";
2818 if (item && strcmp(item, "default"))
2820 edje_object_part_text_set(wd->ent, item, entry);
2824 if (wd->text) eina_stringshare_del(wd->text);
2826 if (wd->password_text) eina_stringshare_del(wd->password_text);
2827 wd->password_text = NULL;
2828 wd->changed = EINA_TRUE;
2830 /* Clear currently pending job if there is one */
2831 if (wd->append_text_idler)
2833 ecore_idler_del(wd->append_text_idler);
2834 free(wd->append_text_left);
2835 wd->append_text_left = NULL;
2836 wd->append_text_idler = NULL;
2839 len = strlen(entry);
2840 /* Split to ~_CHUNK_SIZE chunks */
2841 if (len > _CHUNK_SIZE)
2843 wd->append_text_left = (char *) malloc(len + 1);
2846 /* If we decided to use the idler */
2847 if (wd->append_text_left)
2849 /* Need to clear the entry first */
2850 edje_object_part_text_set(wd->ent, "elm.text", "");
2851 memcpy(wd->append_text_left, entry, len + 1);
2852 wd->append_text_position = 0;
2853 wd->append_text_len = len;
2854 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2858 edje_object_part_text_set(wd->ent, "elm.text", entry);
2860 evas_event_thaw(evas_object_evas_get(obj));
2861 evas_event_thaw_eval(evas_object_evas_get(obj));
2865 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2867 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2868 Widget_Data *wd = elm_widget_data_get(obj);
2869 if (item && strcmp(item, "default")) return NULL;
2871 if (!wd) return NULL;
2874 if(wd->password_text) return wd->password_text;
2880 text = edje_object_part_text_get(wd->ent, "elm.text");
2883 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2887 if (wd->append_text_len > 0)
2891 tlen = strlen(text);
2892 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2895 ERR("Failed to allocate memory for entry's text %p", obj);
2898 memcpy(tmpbuf, text, tlen);
2899 memcpy(tmpbuf + tlen, wd->append_text_left, wd->append_text_len);
2900 tmpbuf[tlen + wd->append_text_len] = '\0';
2901 eina_stringshare_replace(&wd->text, tmpbuf);
2906 eina_stringshare_replace(&wd->text, text);
2911 pw_text = elm_entry_markup_to_utf8(wd->text);
2914 eina_stringshare_replace(&wd->password_text, pw_text);
2916 return wd->password_text;
2923 elm_entry_add(Evas_Object *parent)
2925 Evas_Object *obj, *top;
2929 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2931 ELM_SET_WIDTYPE(widtype, "entry");
2932 elm_widget_type_set(obj, "entry");
2933 elm_widget_sub_object_add(parent, obj);
2934 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2935 elm_widget_data_set(obj, wd);
2936 elm_widget_del_hook_set(obj, _del_hook);
2937 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2938 elm_widget_theme_hook_set(obj, _theme_hook);
2939 elm_widget_disable_hook_set(obj, _disable_hook);
2940 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2941 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2942 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2943 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2944 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2945 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2946 elm_widget_can_focus_set(obj, EINA_TRUE);
2947 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2948 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2949 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2950 elm_widget_content_set_hook_set(obj, _content_set_hook);
2951 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2952 elm_widget_content_get_hook_set(obj, _content_get_hook);
2953 elm_widget_translate_hook_set(obj, _translate_hook);
2955 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2957 wd->linewrap = ELM_WRAP_WORD;
2958 wd->editable = EINA_TRUE;
2959 wd->disabled = EINA_FALSE;
2960 wd->context_menu = EINA_TRUE;
2961 wd->autosave = EINA_TRUE;
2962 wd->cnp_mode = ELM_CNP_MODE_MARKUP;
2963 wd->scroll = EINA_FALSE;
2964 wd->input_panel_imdata = NULL;
2966 wd->magnifier_enabled = EINA_TRUE;
2969 wd->ent = edje_object_add(e);
2970 edje_object_item_provider_set(wd->ent, _get_item, obj);
2971 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2972 edje_object_text_markup_filter_callback_add(wd->ent,"elm.text", _markup_filter, obj);
2973 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2974 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2976 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2978 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2980 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2982 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2983 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2984 _signal_entry_changed, obj);
2985 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
2986 _signal_entry_changed_user, obj);
2987 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2988 _signal_preedit_changed, obj);
2989 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2990 _signal_selection_start, obj);
2991 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2992 _signal_selection_changed, obj);
2993 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
2994 _signal_selection_all, obj);
2995 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
2996 _signal_selection_none, obj);
2997 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2998 _signal_selection_cleared, obj);
2999 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
3000 _signal_entry_paste_request, obj);
3001 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
3002 _signal_entry_copy_notify, obj);
3003 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
3004 _signal_entry_cut_notify, obj);
3005 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
3006 _signal_cursor_changed, obj);
3007 edje_object_signal_callback_add(wd->ent, "cursor,changed,manual", "elm.text",
3008 _signal_cursor_changed_manual, obj);
3009 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
3010 _signal_anchor_down, obj);
3011 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
3012 _signal_anchor_up, obj);
3013 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
3014 _signal_anchor_clicked, obj);
3015 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
3016 _signal_anchor_move, obj);
3017 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
3018 _signal_anchor_in, obj);
3019 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
3020 _signal_anchor_out, obj);
3021 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
3022 _signal_key_enter, obj);
3023 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
3024 _signal_mouse_down, obj);
3025 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
3026 _signal_mouse_clicked, obj);
3027 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
3028 _signal_mouse_double, obj);
3029 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
3030 _signal_mouse_triple, obj);
3031 edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
3032 _signal_undo_request, obj);
3033 edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
3034 _signal_redo_request, obj);
3036 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
3037 _signal_handler_move_start, obj);
3038 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
3039 _signal_handler_move_end, obj);
3040 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
3041 _signal_handler_moving, obj);
3042 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
3043 _signal_selection_end, obj);
3044 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
3045 _signal_long_pressed, obj);
3046 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
3047 _signal_magnifier_changed, obj);
3049 edje_object_part_text_set(wd->ent, "elm.text", "");
3050 if (_elm_config->desktop_entry)
3051 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
3054 edje_object_part_text_copy_paste_disabled_set(wd->ent, "elm.text", EINA_FALSE);
3055 edje_object_part_text_viewport_region_set(wd->ent, "elm.text", -1, -1, -1, -1);
3056 edje_object_part_text_layout_region_set(wd->ent, "elm.text", -1, -1, -1, -1);
3058 elm_widget_resize_object_set(obj, wd->ent);
3061 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
3063 elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
3064 elm_entry_prediction_allow_set(obj, EINA_TRUE);
3066 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
3068 #ifdef HAVE_ELEMENTARY_X
3069 top = elm_widget_top_get(obj);
3070 if ((top) && (elm_win_xwindow_get(top)))
3072 wd->sel_notify_handler =
3073 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
3074 _event_selection_notify, obj);
3075 wd->sel_clear_handler =
3076 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
3077 _event_selection_clear, obj);
3080 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3081 _drag_drop_cb, NULL);
3084 entries = eina_list_prepend(entries, obj);
3086 // module - find module for entry
3087 wd->api = _module(obj);
3088 // if found - hook in
3089 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
3091 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3092 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3093 // TODO: and save some bytes, making descriptions per-class and not instance!
3094 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3098 void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
3100 ELM_CHECK_WIDTYPE(obj, widtype);
3101 Widget_Data *wd = elm_widget_data_get(obj);
3103 ext_mod->cancel = _cancel;
3104 ext_mod->copy = _copy;
3105 ext_mod->cut = _cut;
3106 ext_mod->paste = _paste;
3107 ext_mod->select = _select;
3108 ext_mod->selectall = _selectall;
3109 ext_mod->ent = wd->ent;
3110 ext_mod->items = wd->items;
3111 ext_mod->editable = wd->editable;
3112 ext_mod->have_selection = wd->have_selection;
3113 ext_mod->password = wd->password;
3114 ext_mod->selmode = wd->selmode;
3115 ext_mod->cnpinit = _cnpinit;
3116 ext_mod->context_menu = wd->context_menu;
3117 ext_mod->cnp_mode = wd->cnp_mode;
3118 ext_mod->viewport_rect = _viewport_region_get(obj);
3122 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
3124 ELM_CHECK_WIDTYPE(obj, widtype);
3125 Widget_Data *wd = elm_widget_data_get(obj);
3127 if (wd->single_line == single_line) return;
3128 wd->single_line = single_line;
3129 wd->linewrap = ELM_WRAP_NONE;
3130 elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
3134 if (wd->single_line)
3136 elm_smart_scroller_policy_set(wd->scroller,
3137 ELM_SMART_SCROLLER_POLICY_OFF,
3138 ELM_SMART_SCROLLER_POLICY_OFF);
3139 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); // TIZEN ONLY
3143 const Elm_Scroller_Policy map[3] =
3145 ELM_SMART_SCROLLER_POLICY_AUTO,
3146 ELM_SMART_SCROLLER_POLICY_ON,
3147 ELM_SMART_SCROLLER_POLICY_OFF
3149 elm_smart_scroller_policy_set(wd->scroller,
3152 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); // TIZEN ONLY
3159 elm_entry_single_line_get(const Evas_Object *obj)
3161 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3162 Widget_Data *wd = elm_widget_data_get(obj);
3163 if (!wd) return EINA_FALSE;
3164 return wd->single_line;
3168 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3170 ELM_CHECK_WIDTYPE(obj, widtype);
3171 Widget_Data *wd = elm_widget_data_get(obj);
3173 if (wd->password == password) return;
3174 wd->password = password;
3177 wd->single_line = EINA_TRUE;
3178 wd->linewrap = ELM_WRAP_NONE;
3179 #ifdef HAVE_ELEMENTARY_X
3180 elm_drop_target_del(obj);
3182 edje_object_signal_callback_del_full(wd->ent, "selection,start", "elm.text",
3183 _signal_selection_start, obj);
3184 edje_object_signal_callback_del_full(wd->ent, "selection,changed", "elm.text",
3185 _signal_selection_changed, obj);
3186 edje_object_signal_callback_del_full(wd->ent, "entry,selection,all,request", "elm.text",
3187 _signal_selection_all, obj);
3188 edje_object_signal_callback_del_full(wd->ent, "entry,selection,none,request", "elm.text",
3189 _signal_selection_none, obj);
3190 edje_object_signal_callback_del_full(wd->ent, "selection,cleared", "elm.text",
3191 _signal_selection_cleared, obj);
3192 edje_object_signal_callback_del_full(wd->ent, "entry,paste,request,*", "elm.text",
3193 _signal_entry_paste_request, obj);
3194 edje_object_signal_callback_del_full(wd->ent, "entry,copy,notify", "elm.text",
3195 _signal_entry_copy_notify, obj);
3196 edje_object_signal_callback_del_full(wd->ent, "entry,cut,notify", "elm.text",
3197 _signal_entry_cut_notify, obj);
3201 #ifdef HAVE_ELEMENTARY_X
3202 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3204 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
3205 _signal_selection_start, obj);
3206 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
3207 _signal_selection_changed, obj);
3208 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
3209 _signal_selection_all, obj);
3210 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
3211 _signal_selection_none, obj);
3212 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
3213 _signal_selection_cleared, obj);
3214 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
3215 _signal_entry_paste_request, obj);
3216 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
3217 _signal_entry_copy_notify, obj);
3218 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
3219 _signal_entry_cut_notify, obj);
3225 elm_entry_password_get(const Evas_Object *obj)
3227 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3228 Widget_Data *wd = elm_widget_data_get(obj);
3229 if (!wd) return EINA_FALSE;
3230 return wd->password;
3234 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3236 _elm_entry_text_set(obj, NULL, entry);
3240 elm_entry_entry_get(const Evas_Object *obj)
3242 return _elm_entry_text_get(obj, NULL);
3246 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3249 ELM_CHECK_WIDTYPE(obj, widtype);
3250 Widget_Data *wd = elm_widget_data_get(obj);
3252 if (!entry) entry = "";
3253 wd->changed = EINA_TRUE;
3255 len = strlen(entry);
3256 if (wd->append_text_left)
3259 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3265 wd->append_text_left = tmpbuf;
3266 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3267 wd->append_text_len += len;
3271 /* FIXME: Add chunked appending here (like in entry_set) */
3272 edje_object_part_text_append(wd->ent, "elm.text", entry);
3277 elm_entry_is_empty(const Evas_Object *obj)
3279 /* FIXME: until there's support for that in textblock, we just check
3280 * to see if the there is text or not. */
3281 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3282 Widget_Data *wd = elm_widget_data_get(obj);
3283 const Evas_Object *tb;
3284 Evas_Textblock_Cursor *cur;
3286 if (!wd) return EINA_TRUE;
3288 if (0) { // TIZEN ONLY
3289 /* It's a hack until we get the support suggested above.
3290 * We just create a cursor, point it to the begining, and then
3291 * try to advance it, if it can advance, the tb is not empty,
3292 * otherwise it is. */
3293 tb = edje_object_part_object_get(wd->ent, "elm.text");
3294 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3295 actually, ok for the time being, thsese hackish stuff will be removed
3296 once evas 1.0 is out*/
3297 evas_textblock_cursor_pos_set(cur, 0);
3298 ret = evas_textblock_cursor_char_next(cur);
3299 evas_textblock_cursor_free(cur);
3304 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3305 if (!str) return EINA_TRUE;
3307 ret = (strlen(str) == 0);
3314 elm_entry_textblock_get(Evas_Object *obj)
3316 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3317 Widget_Data *wd = elm_widget_data_get(obj);
3318 if (!wd) return NULL;
3320 return (Evas_Object *) edje_object_part_object_get(wd->ent, "elm.text");
3324 elm_entry_calc_force(Evas_Object *obj)
3326 ELM_CHECK_WIDTYPE(obj, widtype);
3327 Widget_Data *wd = elm_widget_data_get(obj);
3330 edje_object_calc_force(wd->ent);
3331 wd->changed = EINA_TRUE;
3337 elm_entry_selection_get(const Evas_Object *obj)
3339 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3340 Widget_Data *wd = elm_widget_data_get(obj);
3341 if ((!wd) || (wd->password)) return NULL;
3342 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3346 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3348 ELM_CHECK_WIDTYPE(obj, widtype);
3349 Widget_Data *wd = elm_widget_data_get(obj);
3351 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3353 #ifdef HAVE_ELEMENTARY_X
3354 if (cnpwidgetdata == obj)
3355 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3358 wd->changed = EINA_TRUE;
3363 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3365 ELM_CHECK_WIDTYPE(obj, widtype);
3366 Widget_Data *wd = elm_widget_data_get(obj);
3368 if (wd->linewrap == wrap) return;
3370 wd->linewrap = wrap;
3375 elm_entry_line_wrap_get(const Evas_Object *obj)
3377 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3378 Widget_Data *wd = elm_widget_data_get(obj);
3379 if (!wd) return EINA_FALSE;
3380 return wd->linewrap;
3384 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3386 ELM_CHECK_WIDTYPE(obj, widtype);
3387 Widget_Data *wd = elm_widget_data_get(obj);
3389 if (wd->editable == editable) return;
3390 wd->editable = editable;
3393 #ifdef HAVE_ELEMENTARY_X
3395 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3397 elm_drop_target_del(obj);
3402 elm_entry_editable_get(const Evas_Object *obj)
3404 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3405 Widget_Data *wd = elm_widget_data_get(obj);
3406 if (!wd) return EINA_FALSE;
3407 return wd->editable;
3411 elm_entry_select_none(Evas_Object *obj)
3413 ELM_CHECK_WIDTYPE(obj, widtype);
3414 Widget_Data *wd = elm_widget_data_get(obj);
3415 if ((!wd) || (wd->password)) return;
3418 wd->selmode = EINA_FALSE;
3419 if (!_elm_config->desktop_entry)
3420 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3421 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3423 wd->have_selection = EINA_FALSE;
3424 edje_object_part_text_select_none(wd->ent, "elm.text");
3428 elm_entry_select_all(Evas_Object *obj)
3430 ELM_CHECK_WIDTYPE(obj, widtype);
3431 Widget_Data *wd = elm_widget_data_get(obj);
3432 if ((!wd) || (wd->password)) return;
3435 wd->selmode = EINA_FALSE;
3436 if (!_elm_config->desktop_entry)
3437 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3438 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3440 wd->have_selection = EINA_TRUE;
3441 edje_object_part_text_select_all(wd->ent, "elm.text");
3445 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3447 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3448 Widget_Data *wd = elm_widget_data_get(obj);
3449 if (!wd) return EINA_FALSE;
3450 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3455 elm_entry_cursor_next(Evas_Object *obj)
3457 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3458 Widget_Data *wd = elm_widget_data_get(obj);
3459 if (!wd) return EINA_FALSE;
3460 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3464 elm_entry_cursor_prev(Evas_Object *obj)
3466 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3467 Widget_Data *wd = elm_widget_data_get(obj);
3468 if (!wd) return EINA_FALSE;
3469 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3473 elm_entry_cursor_up(Evas_Object *obj)
3475 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3476 Widget_Data *wd = elm_widget_data_get(obj);
3477 if (!wd) return EINA_FALSE;
3478 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3482 elm_entry_cursor_down(Evas_Object *obj)
3484 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3485 Widget_Data *wd = elm_widget_data_get(obj);
3486 if (!wd) return EINA_FALSE;
3487 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3491 elm_entry_cursor_begin_set(Evas_Object *obj)
3493 ELM_CHECK_WIDTYPE(obj, widtype);
3494 Widget_Data *wd = elm_widget_data_get(obj);
3496 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3500 elm_entry_cursor_end_set(Evas_Object *obj)
3502 ELM_CHECK_WIDTYPE(obj, widtype);
3503 Widget_Data *wd = elm_widget_data_get(obj);
3505 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3509 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3511 ELM_CHECK_WIDTYPE(obj, widtype);
3512 Widget_Data *wd = elm_widget_data_get(obj);
3514 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3518 elm_entry_cursor_line_end_set(Evas_Object *obj)
3520 ELM_CHECK_WIDTYPE(obj, widtype);
3521 Widget_Data *wd = elm_widget_data_get(obj);
3523 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3527 elm_entry_cursor_selection_begin(Evas_Object *obj)
3529 ELM_CHECK_WIDTYPE(obj, widtype);
3530 Widget_Data *wd = elm_widget_data_get(obj);
3532 edje_object_part_text_select_begin(wd->ent, "elm.text");
3536 elm_entry_cursor_selection_end(Evas_Object *obj)
3538 ELM_CHECK_WIDTYPE(obj, widtype);
3539 Widget_Data *wd = elm_widget_data_get(obj);
3541 edje_object_part_text_select_extend(wd->ent, "elm.text");
3545 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3547 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3548 Widget_Data *wd = elm_widget_data_get(obj);
3549 if (!wd) return EINA_FALSE;
3550 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3554 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3556 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3557 Widget_Data *wd = elm_widget_data_get(obj);
3558 if (!wd) return EINA_FALSE;
3559 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3563 elm_entry_cursor_content_get(const Evas_Object *obj)
3565 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3566 Widget_Data *wd = elm_widget_data_get(obj);
3567 if (!wd) return NULL;
3568 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3572 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3574 ELM_CHECK_WIDTYPE(obj, widtype);
3575 Widget_Data *wd = elm_widget_data_get(obj);
3577 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3578 edje_object_message_signal_process(wd->ent);
3582 elm_entry_cursor_pos_get(const Evas_Object *obj)
3584 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3585 Widget_Data *wd = elm_widget_data_get(obj);
3587 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3591 elm_entry_selection_cut(Evas_Object *obj)
3593 ELM_CHECK_WIDTYPE(obj, widtype);
3594 Widget_Data *wd = elm_widget_data_get(obj);
3595 if ((!wd) || (wd->password)) return;
3596 _cut(obj, NULL, NULL);
3600 elm_entry_selection_copy(Evas_Object *obj)
3602 ELM_CHECK_WIDTYPE(obj, widtype);
3603 Widget_Data *wd = elm_widget_data_get(obj);
3604 if ((!wd) || (wd->password)) return;
3605 _copy(obj, NULL, NULL);
3609 elm_entry_selection_paste(Evas_Object *obj)
3611 ELM_CHECK_WIDTYPE(obj, widtype);
3612 Widget_Data *wd = elm_widget_data_get(obj);
3613 if ((!wd) || (wd->password)) return;
3614 _paste(obj, NULL, NULL);
3618 elm_entry_context_menu_clear(Evas_Object *obj)
3620 ELM_CHECK_WIDTYPE(obj, widtype);
3621 Widget_Data *wd = elm_widget_data_get(obj);
3622 Elm_Entry_Context_Menu_Item *it;
3624 EINA_LIST_FREE(wd->items, it)
3626 eina_stringshare_del(it->label);
3627 eina_stringshare_del(it->icon_file);
3628 eina_stringshare_del(it->icon_group);
3634 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)
3636 ELM_CHECK_WIDTYPE(obj, widtype);
3637 Widget_Data *wd = elm_widget_data_get(obj);
3638 Elm_Entry_Context_Menu_Item *it;
3640 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3642 wd->items = eina_list_append(wd->items, it);
3644 it->label = eina_stringshare_add(label);
3645 it->icon_file = eina_stringshare_add(icon_file);
3646 it->icon_type = icon_type;
3648 it->data = (void *)data;
3652 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3654 ELM_CHECK_WIDTYPE(obj, widtype);
3655 Widget_Data *wd = elm_widget_data_get(obj);
3657 if (wd->context_menu == !disabled) return;
3658 wd->context_menu = !disabled;
3660 if (!_elm_config->desktop_entry) // TIZEN ONLY : commit ?
3661 edje_object_part_text_copy_paste_disabled_set(wd->ent, "elm.text", disabled);
3665 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3667 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3668 Widget_Data *wd = elm_widget_data_get(obj);
3669 if (!wd) return EINA_FALSE;
3670 return !wd->context_menu;
3674 elm_entry_item_provider_append(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3676 ELM_CHECK_WIDTYPE(obj, widtype);
3677 Widget_Data *wd = elm_widget_data_get(obj);
3679 EINA_SAFETY_ON_NULL_RETURN(func);
3680 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3684 wd->item_providers = eina_list_append(wd->item_providers, ip);
3688 elm_entry_item_provider_prepend(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3690 ELM_CHECK_WIDTYPE(obj, widtype);
3691 Widget_Data *wd = elm_widget_data_get(obj);
3693 EINA_SAFETY_ON_NULL_RETURN(func);
3694 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3698 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3702 elm_entry_item_provider_remove(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3704 ELM_CHECK_WIDTYPE(obj, widtype);
3705 Widget_Data *wd = elm_widget_data_get(obj);
3707 Elm_Entry_Item_Provider *ip;
3709 EINA_SAFETY_ON_NULL_RETURN(func);
3710 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3712 if ((ip->func == func) && ((!data) || (ip->data == data)))
3714 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3722 elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3725 Elm_Entry_Markup_Filter *tf;
3726 ELM_CHECK_WIDTYPE(obj, widtype);
3728 wd = elm_widget_data_get(obj);
3730 EINA_SAFETY_ON_NULL_RETURN(func);
3732 tf = _filter_new(func, data);
3735 wd->text_filters = eina_list_append(wd->text_filters, tf);
3739 elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3742 Elm_Entry_Markup_Filter *tf;
3743 ELM_CHECK_WIDTYPE(obj, widtype);
3745 wd = elm_widget_data_get(obj);
3747 EINA_SAFETY_ON_NULL_RETURN(func);
3749 tf = _filter_new(func, data);
3752 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3756 elm_entry_text_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3760 Elm_Entry_Markup_Filter *tf;
3761 ELM_CHECK_WIDTYPE(obj, widtype);
3763 wd = elm_widget_data_get(obj);
3765 EINA_SAFETY_ON_NULL_RETURN(func);
3767 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3769 if ((tf->func == func) && ((!data) || (tf->data == data)))
3771 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3779 elm_entry_markup_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3782 Elm_Entry_Markup_Filter *tf;
3783 ELM_CHECK_WIDTYPE(obj, widtype);
3785 wd = elm_widget_data_get(obj);
3787 EINA_SAFETY_ON_NULL_RETURN(func);
3789 tf = _filter_new(func, data);
3792 wd->markup_filters = eina_list_append(wd->markup_filters, tf);
3796 elm_entry_markup_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3799 Elm_Entry_Markup_Filter *tf;
3800 ELM_CHECK_WIDTYPE(obj, widtype);
3802 wd = elm_widget_data_get(obj);
3804 EINA_SAFETY_ON_NULL_RETURN(func);
3806 tf = _filter_new(func, data);
3809 wd->markup_filters = eina_list_prepend(wd->markup_filters, tf);
3813 elm_entry_markup_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3817 Elm_Entry_Markup_Filter *tf;
3818 ELM_CHECK_WIDTYPE(obj, widtype);
3820 wd = elm_widget_data_get(obj);
3822 EINA_SAFETY_ON_NULL_RETURN(func);
3824 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
3826 if ((tf->func == func) && ((!data) || (tf->data == data)))
3828 wd->markup_filters = eina_list_remove_list(wd->markup_filters, l);
3836 elm_entry_markup_to_utf8(const char *s)
3838 char *ss = _elm_util_mkup_to_text(s);
3839 if (!ss) ss = strdup("");
3844 elm_entry_utf8_to_markup(const char *s)
3846 char *ss = _elm_util_text_to_mkup(s);
3847 if (!ss) ss = strdup("");
3852 _text_get(const Evas_Object *obj)
3854 return elm_object_text_get(obj);
3858 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3860 Elm_Entry_Filter_Limit_Size *lim = data;
3861 char *current, *utfstr;
3863 const char *(*text_get)(const Evas_Object *);
3865 EINA_SAFETY_ON_NULL_RETURN(data);
3866 EINA_SAFETY_ON_NULL_RETURN(entry);
3867 EINA_SAFETY_ON_NULL_RETURN(text);
3869 /* hack. I don't want to copy the entire function to work with
3871 text_get = _text_get;
3873 current = elm_entry_markup_to_utf8(text_get(entry));
3874 utfstr = elm_entry_markup_to_utf8(*text);
3876 if (lim->max_char_count > 0)
3878 len = evas_string_char_len_get(current);
3879 if (len >= lim->max_char_count)
3881 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3888 newlen = evas_string_char_len_get(utfstr);
3889 if ((len + newlen) > lim->max_char_count)
3890 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3892 else if (lim->max_byte_count > 0)
3894 len = strlen(current);
3895 if (len >= lim->max_byte_count)
3897 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3904 newlen = strlen(utfstr);
3905 if ((len + newlen) > lim->max_byte_count)
3906 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3913 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3915 Elm_Entry_Filter_Accept_Set *as = data;
3919 int read_idx, last_read_idx = 0, read_char;
3921 EINA_SAFETY_ON_NULL_RETURN(data);
3922 EINA_SAFETY_ON_NULL_RETURN(text);
3924 if ((!as->accepted) && (!as->rejected))
3930 goes_in = EINA_TRUE;
3935 goes_in = EINA_FALSE;
3939 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3942 int cmp_idx, cmp_char;
3943 Eina_Bool in_set = EINA_FALSE;
3945 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3948 if (read_char == cmp_char)
3953 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3955 if (in_set == goes_in)
3957 int size = read_idx - last_read_idx;
3958 const char *src = (*text) + last_read_idx;
3960 memcpy(insert, *text + last_read_idx, size);
3963 last_read_idx = read_idx;
3964 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3970 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3972 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3973 Widget_Data *wd = elm_widget_data_get(obj);
3974 if (!wd) return EINA_FALSE;
3975 if (wd->delay_write)
3977 ecore_timer_del(wd->delay_write);
3978 wd->delay_write = NULL;
3980 if (wd->autosave) _save(obj);
3981 eina_stringshare_replace(&wd->file, file);
3982 wd->format = format;
3987 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3989 ELM_CHECK_WIDTYPE(obj, widtype);
3990 Widget_Data *wd = elm_widget_data_get(obj);
3992 if (file) *file = wd->file;
3993 if (format) *format = wd->format;
3997 elm_entry_file_save(Evas_Object *obj)
3999 ELM_CHECK_WIDTYPE(obj, widtype);
4000 Widget_Data *wd = elm_widget_data_get(obj);
4002 if (wd->delay_write)
4004 ecore_timer_del(wd->delay_write);
4005 wd->delay_write = NULL;
4008 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4012 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4014 ELM_CHECK_WIDTYPE(obj, widtype);
4015 Widget_Data *wd = elm_widget_data_get(obj);
4017 wd->autosave = !!autosave;
4021 elm_entry_autosave_get(const Evas_Object *obj)
4023 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4024 Widget_Data *wd = elm_widget_data_get(obj);
4025 if (!wd) return EINA_FALSE;
4026 return wd->autosave;
4029 EINA_DEPRECATED EAPI void
4030 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4032 ELM_CHECK_WIDTYPE(obj, widtype);
4033 Elm_Cnp_Mode cnp_mode = ELM_CNP_MODE_MARKUP;
4035 cnp_mode = ELM_CNP_MODE_NO_IMAGE;
4036 elm_entry_cnp_mode_set(obj, cnp_mode);
4039 EINA_DEPRECATED EAPI Eina_Bool
4040 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4042 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4043 return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
4047 elm_entry_cnp_mode_set(Evas_Object *obj, Elm_Cnp_Mode cnp_mode)
4049 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4050 ELM_CHECK_WIDTYPE(obj, widtype);
4051 Widget_Data *wd = elm_widget_data_get(obj);
4053 if (wd->cnp_mode == cnp_mode) return;
4054 wd->cnp_mode = cnp_mode;
4055 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
4056 format = ELM_SEL_FORMAT_TEXT;
4057 else if (cnp_mode == ELM_CNP_MODE_MARKUP) format |= ELM_SEL_FORMAT_IMAGE;
4058 #ifdef HAVE_ELEMENTARY_X
4059 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4064 elm_entry_cnp_mode_get(const Evas_Object *obj)
4066 ELM_CHECK_WIDTYPE(obj, widtype) ELM_CNP_MODE_MARKUP;
4067 Widget_Data *wd = elm_widget_data_get(obj);
4068 if (!wd) return ELM_CNP_MODE_MARKUP;
4069 return wd->cnp_mode;
4073 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4075 ELM_CHECK_WIDTYPE(obj, widtype);
4076 Widget_Data *wd = elm_widget_data_get(obj);
4077 const Elm_Scroller_Policy map[3] =
4079 ELM_SMART_SCROLLER_POLICY_AUTO,
4080 ELM_SMART_SCROLLER_POLICY_ON,
4081 ELM_SMART_SCROLLER_POLICY_OFF
4085 if (wd->scroll == scroll) return;
4086 wd->scroll = scroll;
4091 wd->scroller = elm_smart_scroller_add(evas_object_evas_get(obj));
4092 elm_widget_resize_object_set(obj, wd->scroller);
4093 elm_smart_scroller_widget_set(wd->scroller, obj);
4094 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
4095 elm_widget_style_get(obj));
4096 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4097 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
4098 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
4099 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(wd->scroller),
4102 elm_smart_scroller_bounce_allow_set(wd->scroller, wd->h_bounce, wd->v_bounce);
4103 if (wd->single_line)
4104 elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
4105 ELM_SMART_SCROLLER_POLICY_OFF);
4107 elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]);
4108 elm_widget_sub_object_add(obj, wd->ent);
4109 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4110 evas_object_show(wd->scroller);
4111 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4117 elm_smart_scroller_child_set(wd->scroller, NULL);
4118 evas_object_smart_member_add(wd->scroller, obj);
4119 elm_widget_sub_object_add(obj, wd->scroller);
4120 evas_object_hide(wd->scroller);
4122 elm_widget_sub_object_del(obj, wd->ent);
4123 elm_widget_resize_object_set(obj, wd->ent);
4124 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4131 elm_entry_scrollable_get(const Evas_Object *obj)
4133 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4134 Widget_Data *wd = elm_widget_data_get(obj);
4135 if (!wd) return EINA_FALSE;
4140 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
4142 ELM_CHECK_WIDTYPE(obj, widtype);
4143 EINA_SAFETY_ON_NULL_RETURN(icon);
4144 _content_set_hook(obj, NULL, icon);
4148 elm_entry_icon_get(const Evas_Object *obj)
4150 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4151 return _content_get_hook(obj, NULL);
4155 elm_entry_icon_unset(Evas_Object *obj)
4157 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4158 return _content_unset_hook(obj, NULL);
4162 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4164 ELM_CHECK_WIDTYPE(obj, widtype);
4165 Widget_Data *wd = elm_widget_data_get(obj);
4169 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4173 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
4175 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4177 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4182 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
4184 ELM_CHECK_WIDTYPE(obj, widtype);
4185 EINA_SAFETY_ON_NULL_RETURN(end);
4186 _content_set_hook(obj, "end", end);
4190 elm_entry_end_get(const Evas_Object *obj)
4192 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4193 return _content_get_hook(obj, "end");
4197 elm_entry_end_unset(Evas_Object *obj)
4199 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4200 return _content_unset_hook(obj, "end");
4204 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4206 ELM_CHECK_WIDTYPE(obj, widtype);
4207 Widget_Data *wd = elm_widget_data_get(obj);
4211 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4215 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
4217 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4219 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4224 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4226 ELM_CHECK_WIDTYPE(obj, widtype);
4227 Widget_Data *wd = elm_widget_data_get(obj);
4228 const Elm_Scroller_Policy map[3] =
4230 ELM_SMART_SCROLLER_POLICY_AUTO,
4231 ELM_SMART_SCROLLER_POLICY_ON,
4232 ELM_SMART_SCROLLER_POLICY_OFF
4237 elm_smart_scroller_policy_set(wd->scroller,
4243 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4245 ELM_CHECK_WIDTYPE(obj, widtype);
4246 Widget_Data *wd = elm_widget_data_get(obj);
4248 wd->h_bounce = h_bounce;
4249 wd->v_bounce = v_bounce;
4250 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4254 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4256 ELM_CHECK_WIDTYPE(obj, widtype);
4257 Widget_Data *wd = elm_widget_data_get(obj);
4259 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4263 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4265 ELM_CHECK_WIDTYPE(obj, widtype);
4266 Widget_Data *wd = elm_widget_data_get(obj);
4269 wd->input_panel_layout = layout;
4271 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
4274 EAPI Elm_Input_Panel_Layout
4275 elm_entry_input_panel_layout_get(const Evas_Object *obj)
4277 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
4278 Widget_Data *wd = elm_widget_data_get(obj);
4279 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
4281 return wd->input_panel_layout;
4285 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
4287 ELM_CHECK_WIDTYPE(obj, widtype);
4288 Widget_Data *wd = elm_widget_data_get(obj);
4291 wd->autocapital_type = autocapital_type;
4292 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
4295 EAPI Elm_Autocapital_Type
4296 elm_entry_autocapital_type_get(const Evas_Object *obj)
4298 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
4299 Widget_Data *wd = elm_widget_data_get(obj);
4300 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
4302 return wd->autocapital_type;
4306 elm_entry_prediction_allow_set(Evas_Object *obj, Eina_Bool prediction)
4308 ELM_CHECK_WIDTYPE(obj, widtype);
4309 Widget_Data *wd = elm_widget_data_get(obj);
4312 wd->prediction_allow = prediction;
4313 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", prediction);
4317 elm_entry_prediction_allow_get(const Evas_Object *obj)
4319 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
4320 Widget_Data *wd = elm_widget_data_get(obj);
4321 if (!wd) return EINA_TRUE;
4323 return wd->prediction_allow;
4327 elm_entry_imf_context_reset(Evas_Object *obj)
4329 ELM_CHECK_WIDTYPE(obj, widtype);
4330 Widget_Data *wd = elm_widget_data_get(obj);
4333 edje_object_part_text_imf_context_reset(wd->ent, "elm.text");
4337 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4339 ELM_CHECK_WIDTYPE(obj, widtype);
4340 Widget_Data *wd = elm_widget_data_get(obj);
4343 wd->input_panel_enable = enabled;
4344 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4348 elm_entry_input_panel_enabled_get(const Evas_Object *obj)
4350 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
4351 Widget_Data *wd = elm_widget_data_get(obj);
4352 if (!wd) return EINA_TRUE;
4354 return wd->input_panel_enable;
4358 elm_entry_input_panel_show(Evas_Object *obj)
4360 ELM_CHECK_WIDTYPE(obj, widtype);
4361 Widget_Data *wd = elm_widget_data_get(obj);
4364 edje_object_part_text_input_panel_show(wd->ent, "elm.text");
4368 elm_entry_input_panel_hide(Evas_Object *obj)
4370 ELM_CHECK_WIDTYPE(obj, widtype);
4371 Widget_Data *wd = elm_widget_data_get(obj);
4374 edje_object_part_text_input_panel_hide(wd->ent, "elm.text");
4378 elm_entry_input_panel_language_set(Evas_Object *obj, Elm_Input_Panel_Lang lang)
4380 ELM_CHECK_WIDTYPE(obj, widtype);
4381 Widget_Data *wd = elm_widget_data_get(obj);
4384 wd->input_panel_lang = lang;
4385 edje_object_part_text_input_panel_language_set(wd->ent, "elm.text", lang);
4388 EAPI Elm_Input_Panel_Lang
4389 elm_entry_input_panel_language_get(const Evas_Object *obj)
4391 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LANG_AUTOMATIC;
4392 Widget_Data *wd = elm_widget_data_get(obj);
4393 if (!wd) return ELM_INPUT_PANEL_LANG_AUTOMATIC;
4395 return wd->input_panel_lang;
4399 elm_entry_input_panel_imdata_set(Evas_Object *obj, const void *data, int len)
4401 ELM_CHECK_WIDTYPE(obj, widtype);
4402 Widget_Data *wd = elm_widget_data_get(obj);
4405 if (wd->input_panel_imdata)
4406 free(wd->input_panel_imdata);
4408 wd->input_panel_imdata = calloc(1, len);
4409 wd->input_panel_imdata_len = len;
4410 memcpy(wd->input_panel_imdata, data, len);
4412 edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len);
4416 elm_entry_input_panel_imdata_get(const Evas_Object *obj, void *data, int *len)
4418 ELM_CHECK_WIDTYPE(obj, widtype);
4419 Widget_Data *wd = elm_widget_data_get(obj);
4422 edje_object_part_text_input_panel_imdata_get(wd->ent, "elm.text", data, len);
4426 elm_entry_input_panel_return_key_type_set(Evas_Object *obj, Elm_Input_Panel_Return_Key_Type return_key_type)
4428 ELM_CHECK_WIDTYPE(obj, widtype);
4429 Widget_Data *wd = elm_widget_data_get(obj);
4432 wd->input_panel_return_key_type = return_key_type;
4434 edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", return_key_type);
4437 EAPI Elm_Input_Panel_Return_Key_Type
4438 elm_entry_input_panel_return_key_type_get(const Evas_Object *obj)
4440 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4441 Widget_Data *wd = elm_widget_data_get(obj);
4442 if (!wd) return ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4444 return wd->input_panel_return_key_type;
4448 elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4450 ELM_CHECK_WIDTYPE(obj, widtype);
4451 Widget_Data *wd = elm_widget_data_get(obj);
4454 wd->input_panel_return_key_disabled = disabled;
4456 edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", disabled);
4460 elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
4462 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4463 Widget_Data *wd = elm_widget_data_get(obj);
4464 if (!wd) return EINA_FALSE;
4466 return wd->input_panel_return_key_disabled;
4470 elm_entry_input_panel_return_key_autoenabled_set(Evas_Object *obj, Eina_Bool enabled)
4472 ELM_CHECK_WIDTYPE(obj, widtype);
4473 Widget_Data *wd = elm_widget_data_get(obj);
4476 wd->autoreturnkey = enabled;
4477 _check_enable_return_key(obj);
4481 elm_entry_imf_context_get(Evas_Object *obj)
4483 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4484 Widget_Data *wd = elm_widget_data_get(obj);
4485 if (!wd) return NULL;
4487 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4490 /* START - ANCHOR HOVER */
4492 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
4494 Widget_Data *wd = elm_widget_data_get(data);
4496 wd->anchor_hover.hover_parent = NULL;
4500 elm_entry_anchor_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
4502 ELM_CHECK_WIDTYPE(obj, widtype);
4503 Widget_Data *wd = elm_widget_data_get(obj);
4505 if (wd->anchor_hover.hover_parent)
4506 evas_object_event_callback_del_full(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
4507 wd->anchor_hover.hover_parent = parent;
4508 if (wd->anchor_hover.hover_parent)
4509 evas_object_event_callback_add(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
4513 elm_entry_anchor_hover_parent_get(const Evas_Object *obj)
4515 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4516 Widget_Data *wd = elm_widget_data_get(obj);
4517 if (!wd) return NULL;
4518 return wd->anchor_hover.hover_parent;
4522 elm_entry_anchor_hover_style_set(Evas_Object *obj, const char *style)
4524 ELM_CHECK_WIDTYPE(obj, widtype);
4525 Widget_Data *wd = elm_widget_data_get(obj);
4527 eina_stringshare_replace(&wd->anchor_hover.hover_style, style);
4531 elm_entry_anchor_hover_style_get(const Evas_Object *obj)
4533 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4534 Widget_Data *wd = elm_widget_data_get(obj);
4535 if (!wd) return NULL;
4536 return wd->anchor_hover.hover_style;
4540 elm_entry_anchor_hover_end(Evas_Object *obj)
4542 ELM_CHECK_WIDTYPE(obj, widtype);
4543 Widget_Data *wd = elm_widget_data_get(obj);
4545 if (wd->anchor_hover.hover) evas_object_del(wd->anchor_hover.hover);
4546 if (wd->anchor_hover.pop) evas_object_del(wd->anchor_hover.pop);
4547 wd->anchor_hover.hover = NULL;
4548 wd->anchor_hover.pop = NULL;
4553 _anchor_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
4555 elm_entry_anchor_hover_end(data);
4559 _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info)
4561 Widget_Data *wd = elm_widget_data_get(obj);
4562 Elm_Entry_Anchor_Info *info = event_info;
4563 Evas_Object *hover_parent;
4564 Elm_Entry_Anchor_Hover_Info ei;
4565 Evas_Coord x, w, y, h, px, py;
4567 ei.anchor_info = event_info;
4568 wd->anchor_hover.pop = elm_icon_add(obj);
4569 evas_object_move(wd->anchor_hover.pop, info->x, info->y);
4570 evas_object_resize(wd->anchor_hover.pop, info->w, info->h);
4571 wd->anchor_hover.hover = elm_hover_add(obj);
4572 elm_widget_mirrored_set(wd->anchor_hover.hover, elm_widget_mirrored_get(obj));
4573 if (wd->anchor_hover.hover_style)
4574 elm_object_style_set(wd->anchor_hover.hover, wd->anchor_hover.hover_style);
4575 hover_parent = wd->anchor_hover.hover_parent;
4576 if (!hover_parent) hover_parent = obj;
4577 elm_hover_parent_set(wd->anchor_hover.hover, hover_parent);
4578 elm_hover_target_set(wd->anchor_hover.hover, wd->anchor_hover.pop);
4579 ei.hover = wd->anchor_hover.hover;
4580 evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
4581 ei.hover_parent.x = x;
4582 ei.hover_parent.y = y;
4583 ei.hover_parent.w = w;
4584 ei.hover_parent.h = h;
4585 px = info->x + (info->w / 2);
4586 py = info->y + (info->h / 2);
4588 if (px < (x + (w / 3))) ei.hover_left = 0;
4590 if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
4592 if (py < (y + (h / 3))) ei.hover_top = 0;
4593 ei.hover_bottom = 1;
4594 if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
4596 if (elm_widget_mirrored_get(wd->anchor_hover.hover))
4597 { /* Swap right and left because they switch sides in RTL */
4598 Eina_Bool tmp = ei.hover_left;
4599 ei.hover_left = ei.hover_right;
4600 ei.hover_right = tmp;
4603 evas_object_smart_callback_call(data, SIG_ANCHOR_HOVER_OPENED, &ei);
4604 evas_object_smart_callback_add(wd->anchor_hover.hover, "clicked", _anchor_hover_clicked, data);
4605 evas_object_show(wd->anchor_hover.hover);
4607 /* END - ANCHOR HOVER */