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;
59 Evas_Object *hover_parent;
60 Evas_Object *pop, *hover;
61 const char *hover_style;
63 Eina_Bool changed : 1;
64 Eina_Bool single_line : 1;
65 Eina_Bool password : 1;
66 Eina_Bool editable : 1;
67 Eina_Bool selection_asked : 1;
68 Eina_Bool have_selection : 1;
69 Eina_Bool selmode : 1;
70 Eina_Bool deferred_cur : 1;
71 Eina_Bool cur_changed : 1;
72 Eina_Bool disabled : 1;
73 Eina_Bool context_menu : 1;
74 Eina_Bool drag_selection_asked : 1;
75 Eina_Bool can_write : 1;
76 Eina_Bool autosave : 1;
77 Eina_Bool usedown : 1;
79 Eina_Bool h_bounce : 1;
80 Eina_Bool v_bounce : 1;
81 Eina_Bool input_panel_enable : 1;
82 Eina_Bool prediction_allow : 1;
83 Eina_Bool input_panel_return_key_disabled : 1;
84 Eina_Bool autoreturnkey : 1;
85 Elm_Cnp_Mode cnp_mode : 2;
87 Evas_Object *mgf_proxy;
88 Evas_Object *mgf_clip;
90 Evas_Coord mgf_height;
93 Ecore_Job *region_get_job;
94 Ecore_Job *region_recalc_job;
95 const char *password_text;
96 Evas_Coord cx, cy, cw, ch;
97 Eina_Bool double_clicked : 1;
98 Eina_Bool long_pressed : 1;
99 Eina_Bool magnifier_enabled : 1;
103 struct _Elm_Entry_Context_Menu_Item
107 const char *icon_file;
108 const char *icon_group;
109 Elm_Icon_Type icon_type;
114 struct _Elm_Entry_Item_Provider
116 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
120 struct _Elm_Entry_Markup_Filter
122 Elm_Entry_Filter_Cb func;
126 typedef enum _Length_Unit
133 static const char *widtype = NULL;
135 static Evas_Object *cnpwidgetdata = NULL;
138 #ifdef HAVE_ELEMENTARY_X
139 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
141 static void _del_hook(Evas_Object *obj);
142 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
143 static void _theme_hook(Evas_Object *obj);
144 static void _disable_hook(Evas_Object *obj);
145 static void _sizing_eval(Evas_Object *obj);
146 static void _on_focus_hook(void *data, Evas_Object *obj);
147 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
148 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
149 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
150 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
151 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
152 static const char *_getbase(Evas_Object *obj);
153 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
154 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
155 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
156 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
157 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
158 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
159 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
160 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
161 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
162 static void _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info);
164 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
165 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
166 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
167 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
168 static void _magnifier_create(void *data);
169 static void _magnifier_show(void *data);
170 static void _magnifier_hide(void *data);
171 static void _magnifier_move(void *data);
172 static Evas_Coord_Rectangle _layout_region_get(Evas_Object *data);
173 static Evas_Coord_Rectangle _viewport_region_get(Evas_Object *data);
174 static void _region_get_job(void *data);
175 static void _region_recalc_job(void *data);
178 static const char SIG_CHANGED[] = "changed";
179 static const char SIG_CHANGED_USER[] = "changed,user";
180 static const char SIG_ACTIVATED[] = "activated";
181 static const char SIG_PRESS[] = "press";
182 static const char SIG_LONGPRESSED[] = "longpressed";
183 static const char SIG_CLICKED[] = "clicked";
184 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
185 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
186 static const char SIG_FOCUSED[] = "focused";
187 static const char SIG_UNFOCUSED[] = "unfocused";
188 static const char SIG_SELECTION_PASTE[] = "selection,paste";
189 static const char SIG_SELECTION_COPY[] = "selection,copy";
190 static const char SIG_SELECTION_CUT[] = "selection,cut";
191 static const char SIG_SELECTION_START[] = "selection,start";
192 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
193 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
194 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
195 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
196 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
197 static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened";
198 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
199 static const char SIG_ANCHOR_UP[] = "anchor,up";
200 static const char SIG_ANCHOR_IN[] = "anchor,in";
201 static const char SIG_ANCHOR_OUT[] = "anchor,out";
202 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
203 static const char SIG_UNDO_REQUEST[] = "undo,request";
204 static const char SIG_REDO_REQUEST[] = "redo,request";
205 static const Evas_Smart_Cb_Description _signals[] = {
209 {SIG_LONGPRESSED, ""},
211 {SIG_CLICKED_DOUBLE, ""},
212 {SIG_CLICKED_TRIPLE, ""},
215 {SIG_SELECTION_PASTE, ""},
216 {SIG_SELECTION_COPY, ""},
217 {SIG_SELECTION_CUT, ""},
218 {SIG_SELECTION_START, ""},
219 {SIG_SELECTION_CHANGED, ""},
220 {SIG_SELECTION_CLEARED, ""},
221 {SIG_CURSOR_CHANGED, ""},
222 {SIG_CURSOR_CHANGED_MANUAL, ""},
223 {SIG_ANCHOR_CLICKED, ""},
224 {SIG_ANCHOR_HOVER_OPENED, ""},
225 {SIG_ANCHOR_DOWN, ""},
228 {SIG_ANCHOR_OUT, ""},
229 {SIG_PREEDIT_CHANGED, ""},
230 {SIG_CHANGED_USER, ""},
231 {SIG_UNDO_REQUEST, ""},
232 {SIG_REDO_REQUEST, ""},
236 typedef enum _Elm_Entry_Magnifier_Type
238 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
239 _ENTRY_MAGNIFIER_FILLWIDTH,
240 _ENTRY_MAGNIFIER_CIRCULAR,
241 } Elm_Entry_Magnifier_Type;
243 static Eina_List *entries = NULL;
247 void (*obj_hook) (Evas_Object *obj);
248 void (*obj_unhook) (Evas_Object *obj);
249 void (*obj_longpress) (Evas_Object *obj);
250 void (*obj_hidemenu) (Evas_Object *obj);
251 void (*obj_mouseup) (Evas_Object *obj);
255 _module(Evas_Object *obj __UNUSED__)
257 static Elm_Module *m = NULL;
258 if (m) goto ok; // already found - just use
259 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
261 m->api = malloc(sizeof(Mod_Api));
262 if (!m->api) return NULL;
263 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
264 _elm_module_symbol_get(m, "obj_hook");
265 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
266 _elm_module_symbol_get(m, "obj_unhook");
267 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
268 _elm_module_symbol_get(m, "obj_longpress");
269 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
270 _elm_module_symbol_get(m, "obj_hidemenu");
271 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
272 _elm_module_symbol_get(m, "obj_mouseup");
273 ok: // ok - return api
278 _buf_append(char *buf, const char *str, int *len, int *alloc)
280 int len2 = strlen(str);
281 if ((*len + len2) >= *alloc)
283 char *buf2 = realloc(buf, *alloc + len2 + 512);
284 if (!buf2) return NULL;
286 *alloc += (512 + len2);
288 strcpy(buf + *len, str);
294 _load_file(const char *file)
298 int alloc = 0, len = 0;
299 char *text = NULL, buf[16384 + 1];
301 f = fopen(file, "rb");
303 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
307 tmp_text = _buf_append(text, buf, &len, &alloc);
308 if (!tmp_text) break;
316 _load_plain(const char *file)
320 text = _load_file(file);
325 text2 = elm_entry_utf8_to_markup(text);
333 _load(Evas_Object *obj)
335 Widget_Data *wd = elm_widget_data_get(obj);
337 if (!wd) return EINA_FALSE;
340 elm_object_text_set(obj, "");
345 case ELM_TEXT_FORMAT_PLAIN_UTF8:
346 text = _load_plain(wd->file);
348 case ELM_TEXT_FORMAT_MARKUP_UTF8:
349 text = _load_file(wd->file);
357 elm_object_text_set(obj, text);
363 elm_object_text_set(obj, "");
369 _save_markup_utf8(const char *file, const char *text)
373 if ((!text) || (!text[0]))
375 ecore_file_unlink(file);
378 f = fopen(file, "wb");
381 // FIXME: report a write error
384 fputs(text, f); // FIXME: catch error
389 _save_plain_utf8(const char *file, const char *text)
393 text2 = elm_entry_markup_to_utf8(text);
396 _save_markup_utf8(file, text2);
401 _save(Evas_Object *obj)
403 Widget_Data *wd = elm_widget_data_get(obj);
405 if (!wd->file) return;
408 case ELM_TEXT_FORMAT_PLAIN_UTF8:
409 _save_plain_utf8(wd->file, elm_object_text_get(obj));
411 case ELM_TEXT_FORMAT_MARKUP_UTF8:
412 _save_markup_utf8(wd->file, elm_object_text_get(obj));
420 _delay_write(void *data)
422 Widget_Data *wd = elm_widget_data_get(data);
423 if (!wd) return ECORE_CALLBACK_CANCEL;
425 wd->delay_write = NULL;
426 return ECORE_CALLBACK_CANCEL;
429 static Elm_Entry_Markup_Filter *
430 _filter_new(Elm_Entry_Filter_Cb func, void *data)
432 Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
433 if (!tf) return NULL;
436 if (func == elm_entry_filter_limit_size)
438 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
445 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
451 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
454 else if (func == elm_entry_filter_accept_set)
456 Elm_Entry_Filter_Accept_Set *as = data, *as2;
463 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
470 as2->accepted = eina_stringshare_add(as->accepted);
472 as2->accepted = NULL;
474 as2->rejected = eina_stringshare_add(as->rejected);
476 as2->rejected = NULL;
485 _filter_free(Elm_Entry_Markup_Filter *tf)
487 if (tf->func == elm_entry_filter_limit_size)
489 Elm_Entry_Filter_Limit_Size *lim = tf->data;
492 else if (tf->func == elm_entry_filter_accept_set)
494 Elm_Entry_Filter_Accept_Set *as = tf->data;
497 if (as->accepted) eina_stringshare_del(as->accepted);
498 if (as->rejected) eina_stringshare_del(as->rejected);
506 _del_pre_hook(Evas_Object *obj)
508 Widget_Data *wd = elm_widget_data_get(obj);
512 ecore_timer_del(wd->delay_write);
513 wd->delay_write = NULL;
514 if (wd->autosave) _save(obj);
516 elm_entry_anchor_hover_end(obj);
517 elm_entry_anchor_hover_parent_set(obj, NULL);
521 _del_hook(Evas_Object *obj)
523 Widget_Data *wd = elm_widget_data_get(obj);
524 Elm_Entry_Context_Menu_Item *it;
525 Elm_Entry_Item_Provider *ip;
526 Elm_Entry_Markup_Filter *tf;
528 evas_event_freeze(evas_object_evas_get(obj));
530 if (wd->file) eina_stringshare_del(wd->file);
532 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
533 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
535 entries = eina_list_remove(entries, obj);
536 #ifdef HAVE_ELEMENTARY_X
537 if (wd->sel_notify_handler)
538 ecore_event_handler_del(wd->sel_notify_handler);
539 if (wd->sel_clear_handler)
540 ecore_event_handler_del(wd->sel_clear_handler);
542 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
543 if (wd->text) eina_stringshare_del(wd->text);
544 if (wd->password_text) eina_stringshare_del(wd->password_text);
545 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
546 if (wd->region_get_job) ecore_job_del(wd->region_get_job);
547 if (wd->region_recalc_job) ecore_job_del(wd->region_recalc_job);
548 if (wd->append_text_idler)
550 ecore_idler_del(wd->append_text_idler);
551 free(wd->append_text_left);
552 wd->append_text_left = NULL;
553 wd->append_text_idler = NULL;
555 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
556 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
557 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
558 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
559 EINA_LIST_FREE(wd->items, it)
561 eina_stringshare_del(it->label);
562 eina_stringshare_del(it->icon_file);
563 eina_stringshare_del(it->icon_group);
566 EINA_LIST_FREE(wd->item_providers, ip)
570 EINA_LIST_FREE(wd->text_filters, tf)
574 EINA_LIST_FREE(wd->markup_filters, tf)
578 if (wd->delay_write) ecore_timer_del(wd->delay_write);
579 if (wd->input_panel_imdata) free(wd->input_panel_imdata);
581 if (wd->anchor_hover.hover_style) eina_stringshare_del(wd->anchor_hover.hover_style);
582 evas_event_thaw(evas_object_evas_get(obj));
583 evas_event_thaw_eval(evas_object_evas_get(obj));
588 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
590 Widget_Data *wd = elm_widget_data_get(obj);
591 edje_object_mirrored_set(wd->ent, rtl);
592 if (wd->anchor_hover.hover)
593 elm_widget_mirrored_set(wd->anchor_hover.hover, rtl);
597 _theme_hook(Evas_Object *obj)
599 Widget_Data *wd = elm_widget_data_get(obj);
602 evas_event_freeze(evas_object_evas_get(obj));
603 _elm_widget_mirrored_reload(obj);
604 _mirrored_set(obj, elm_widget_mirrored_get(obj));
606 t = eina_stringshare_add(elm_object_text_get(obj));
607 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
608 if (_elm_config->desktop_entry)
609 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
610 elm_object_text_set(obj, t);
611 eina_stringshare_del(t);
612 if (elm_widget_disabled_get(obj))
613 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
614 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
615 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
616 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", wd->prediction_allow);
617 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
618 edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len);
619 edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", wd->input_panel_return_key_type);
620 edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", wd->input_panel_return_key_disabled);
622 if (wd->cursor_pos != 0)
623 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
624 if (elm_widget_focus_get(obj))
625 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
626 edje_object_message_signal_process(wd->ent);
627 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
633 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
634 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
635 elm_widget_style_get(obj));
636 edj = elm_smart_scroller_edje_object_get(wd->scroller);
637 str = edje_object_data_get(edj, "focus_highlight");
638 if ((str) && (!strcmp(str, "on")))
639 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
641 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
644 evas_event_thaw(evas_object_evas_get(obj));
645 evas_event_thaw_eval(evas_object_evas_get(obj));
649 _disable_hook(Evas_Object *obj)
651 Widget_Data *wd = elm_widget_data_get(obj);
653 if (elm_widget_disabled_get(obj))
655 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
656 wd->disabled = EINA_TRUE;
660 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
661 wd->disabled = EINA_FALSE;
666 _recalc_cursor_geometry(Evas_Object *obj)
668 Widget_Data *wd = elm_widget_data_get(obj);
670 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
671 if (!wd->deferred_recalc_job)
673 Evas_Coord cx, cy, cw, ch;
674 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
678 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
679 wd->cur_changed = EINA_FALSE;
683 wd->deferred_cur = EINA_TRUE;
687 _elm_deferred_recalc_job(void *data)
689 Widget_Data *wd = elm_widget_data_get(data);
690 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
692 wd->deferred_recalc_job = NULL;
694 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
695 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
696 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
697 /* This is a hack to workaround the way min size hints are treated.
698 * If the minimum width is smaller than the restricted width, it means
699 * the minimum doesn't matter. */
702 Evas_Coord ominw = -1;
703 evas_object_size_hint_min_get(data, &ominw, NULL);
710 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
713 Evas_Coord vmw = 0, vmh = 0;
715 edje_object_size_min_calc
716 (elm_smart_scroller_edje_object_get(wd->scroller),
720 evas_object_size_hint_min_set(data, vmw, minh + vmh);
721 evas_object_size_hint_max_set(data, -1, minh + vmh);
725 evas_object_size_hint_min_set(data, vmw, vmh);
726 evas_object_size_hint_max_set(data, -1, -1);
733 evas_object_size_hint_min_set(data, minw, minh);
734 evas_object_size_hint_max_set(data, -1, minh);
738 evas_object_size_hint_min_set(data, fw, minh);
739 evas_object_size_hint_max_set(data, -1, -1);
743 if (wd->deferred_cur)
745 Evas_Coord cx, cy, cw, ch;
746 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
750 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
751 wd->cur_changed = EINA_FALSE;
757 _sizing_eval(Evas_Object *obj)
759 Widget_Data *wd = elm_widget_data_get(obj);
760 Evas_Coord minw = -1, minh = -1;
761 Evas_Coord resw, resh;
764 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
767 if ((resw == wd->lastw) && (!wd->changed)) return;
768 evas_event_freeze(evas_object_evas_get(obj));
769 wd->changed = EINA_FALSE;
773 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
775 evas_object_resize(wd->scroller, resw, resh);
776 edje_object_size_min_calc
777 (elm_smart_scroller_edje_object_get(wd->scroller),
779 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
780 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
781 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
782 /* This is a hack to workaround the way min size hints are treated.
783 * If the minimum width is smaller than the restricted width, it means
784 * the minimum doesn't matter. */
787 Evas_Coord ominw = -1;
788 evas_object_size_hint_min_get(wd->ent, &ominw, NULL);
794 if ((minw > 0) && (vw < minw)) vw = minw;
795 if (minh > vh) vh = minh;
797 if (wd->single_line) h = vmh + minh;
799 evas_object_resize(wd->ent, vw, vh);
800 evas_object_size_hint_min_set(obj, w, h);
802 evas_object_size_hint_max_set(obj, -1, h);
804 evas_object_size_hint_max_set(obj, -1, -1);
808 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
809 wd->deferred_recalc_job = ecore_job_add(_elm_deferred_recalc_job, obj);
811 evas_event_thaw(evas_object_evas_get(obj));
812 evas_event_thaw_eval(evas_object_evas_get(obj));
816 if (!wd->changed) return;
817 evas_event_freeze(evas_object_evas_get(obj));
818 wd->changed = EINA_FALSE;
822 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
824 edje_object_size_min_calc(wd->ent, &minw, &minh);
827 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
829 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
831 if (minw > vw) vw = minw;
832 if (minh > vh) vh = minh;
834 evas_object_resize(wd->ent, vw, vh);
835 edje_object_size_min_calc
836 (elm_smart_scroller_edje_object_get(wd->scroller),
838 if (wd->single_line) h = vmh + minh;
840 evas_object_size_hint_min_set(obj, w, h);
842 evas_object_size_hint_max_set(obj, -1, h);
844 evas_object_size_hint_max_set(obj, -1, -1);
848 edje_object_size_min_calc(wd->ent, &minw, &minh);
851 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
852 evas_object_size_hint_min_set(obj, minw, minh);
854 evas_object_size_hint_max_set(obj, -1, minh);
856 evas_object_size_hint_max_set(obj, -1, -1);
858 evas_event_thaw(evas_object_evas_get(obj));
859 evas_event_thaw_eval(evas_object_evas_get(obj));
862 _recalc_cursor_geometry(obj);
866 _check_enable_return_key(Evas_Object *obj)
868 Widget_Data *wd = elm_widget_data_get(obj);
869 Eina_Bool return_key_disabled = EINA_FALSE;
872 if (!wd->autoreturnkey) return;
874 if (elm_entry_is_empty(obj) == EINA_TRUE)
875 return_key_disabled = EINA_TRUE;
877 elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
881 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
883 Widget_Data *wd = elm_widget_data_get(obj);
884 Evas_Object *top = elm_widget_top_get(obj);
887 if (elm_widget_focus_get(obj))
889 printf("[Elm_entry::Focused] obj : %p\n", obj);
890 evas_object_focus_set(wd->ent, EINA_TRUE);
891 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
892 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
895 if (top && wd->input_panel_enable)
896 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
897 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
898 _check_enable_return_key(obj);
903 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
904 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
905 evas_object_focus_set(wd->ent, EINA_FALSE);
906 if ((wd->api) && (wd->api->obj_hidemenu))
907 wd->api->obj_hidemenu(obj);
911 if (top && wd->input_panel_enable)
912 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
913 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
919 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
921 Widget_Data *wd = elm_widget_data_get(obj);
923 Evas_Object *prev_content;
924 if ((!wd) || (!content)) return;
927 edje = elm_smart_scroller_edje_object_get(wd->scroller);
931 if (!part || !strcmp(part, "icon"))
933 prev_content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
934 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
936 else if (!strcmp(part, "end"))
938 prev_content = edje_object_part_swallow_get(edje, "elm.swallow.end");
939 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
942 prev_content = edje_object_part_swallow_get(edje, part);
944 if (prev_content) evas_object_del(prev_content);
946 evas_event_freeze(evas_object_evas_get(obj));
947 elm_widget_sub_object_add(obj, content);
949 if (!part || !strcmp(part, "icon"))
950 edje_object_part_swallow(edje, "elm.swallow.icon", content);
951 else if (!strcmp(part, "end"))
952 edje_object_part_swallow(edje, "elm.swallow.end", content);
954 edje_object_part_swallow(edje, part, content);
957 evas_event_thaw(evas_object_evas_get(obj));
958 evas_event_thaw_eval(evas_object_evas_get(obj));
962 _content_unset_hook(Evas_Object *obj, const char *part)
964 Widget_Data *wd = elm_widget_data_get(obj);
965 Evas_Object *content, *edje;
966 if (!wd) return NULL;
969 edje = elm_smart_scroller_edje_object_get(wd->scroller);
973 if (!part || !strcmp(part, "icon"))
975 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
976 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
978 else if (!strcmp(part, "end"))
980 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
981 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
984 content = edje_object_part_swallow_get(edje, part);
986 edje_object_part_swallow(edje, part, NULL);
987 if (!content) return NULL;
988 evas_event_freeze(evas_object_evas_get(obj));
989 elm_widget_sub_object_del(obj, content);
990 edje_object_part_unswallow(wd->ent, content);
992 evas_event_thaw(evas_object_evas_get(obj));
993 evas_event_thaw_eval(evas_object_evas_get(obj));
999 _content_get_hook(const Evas_Object *obj, const char *part)
1001 Widget_Data *wd = elm_widget_data_get(obj);
1002 Evas_Object *content = NULL, *edje;
1003 if (!wd) return NULL;
1006 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1010 if (!edje) return NULL;
1012 if (!part || !strcmp(part, "icon"))
1013 content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
1014 else if (!strcmp(part, "end"))
1015 content = edje_object_part_swallow_get(edje, "elm.swallow.end");
1017 content = edje_object_part_swallow_get(edje, part);
1023 _translate_hook(Evas_Object *obj)
1025 evas_object_smart_callback_call(obj, "language,changed", NULL);
1029 _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
1031 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
1032 Evas_Event_Key_Down *ev = event_info;
1033 Widget_Data *wd = elm_widget_data_get(obj);
1034 if (!wd) return EINA_FALSE;
1035 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
1036 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
1041 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
1043 Widget_Data *wd = elm_widget_data_get(obj);
1045 edje_object_signal_emit(wd->ent, emission, source);
1047 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
1052 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1054 Widget_Data *wd = elm_widget_data_get(obj);
1056 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
1058 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
1059 emission, source, func_cb, data);
1063 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
1065 Widget_Data *wd = elm_widget_data_get(obj);
1066 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
1069 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
1070 emission, source, func_cb, data);
1074 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1076 Widget_Data *wd = elm_widget_data_get(obj);
1077 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
1081 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1083 Widget_Data *wd = elm_widget_data_get(obj);
1085 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1089 _show_region_hook(void *data, Evas_Object *obj)
1091 Widget_Data *wd = elm_widget_data_get(data);
1092 Evas_Coord x, y, w, h;
1094 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1096 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1100 _sub_del(void *data, Evas_Object *obj, void *event_info)
1102 Widget_Data *wd = data;
1103 Evas_Object *sub = event_info;
1107 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1111 if (sub == edje_object_part_swallow_get(edje, "elm.swallow.icon"))
1113 edje_object_part_unswallow(edje, sub);
1115 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1117 else if (sub == edje_object_part_swallow_get(edje, "elm.swallow.end"))
1119 edje_object_part_unswallow(edje, sub);
1121 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1127 _hoversel_position(Evas_Object *obj)
1129 Widget_Data *wd = elm_widget_data_get(obj);
1130 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1135 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1144 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1145 &cx, &cy, &cw, &ch);
1146 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1149 cx += (cw - mw) / 2;
1154 cy += (ch - mh) / 2;
1157 evas_object_move(wd->hoversel, x + cx, y + cy);
1158 evas_object_resize(wd->hoversel, cw, ch);
1162 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1164 Widget_Data *wd = elm_widget_data_get(data);
1166 if (wd->hoversel) _hoversel_position(data);
1168 if (!_elm_config->desktop_entry)
1170 if (wd->region_get_job) ecore_job_del(wd->region_get_job);
1171 wd->region_get_job = ecore_job_add(_region_get_job, data);
1176 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1178 Widget_Data *wd = elm_widget_data_get(data);
1185 else if (wd->scroll)
1187 Evas_Coord vw = 0, vh = 0;
1189 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1190 if (vw < wd->entmw) vw = wd->entmw;
1191 if (vh < wd->entmh) vh = wd->entmh;
1192 evas_object_resize(wd->ent, vw, vh);
1194 if (wd->hoversel) _hoversel_position(data);
1196 if (!_elm_config->desktop_entry)
1198 if (wd->region_get_job) ecore_job_del(wd->region_get_job);
1199 wd->region_get_job = ecore_job_add(_region_get_job, data);
1204 _hover_del(void *data)
1206 Widget_Data *wd = elm_widget_data_get(data);
1211 evas_object_del(wd->hoversel);
1212 wd->hoversel = NULL;
1214 wd->hovdeljob = NULL;
1218 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1220 Widget_Data *wd = elm_widget_data_get(data);
1223 if (wd->hoversel) evas_object_hide(wd->hoversel);
1226 if (!_elm_config->desktop_entry)
1229 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1232 elm_widget_scroll_freeze_pop(data);
1233 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1234 wd->hovdeljob = ecore_job_add(_hover_del, data);
1238 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1240 Widget_Data *wd = elm_widget_data_get(data);
1242 wd->selmode = EINA_TRUE;
1243 edje_object_part_text_select_none(wd->ent, "elm.text");
1244 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1245 edje_object_part_text_select_all(wd->ent, "elm.text");
1246 elm_object_scroll_freeze_pop(data);
1250 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1252 Widget_Data *wd = elm_widget_data_get(data);
1254 wd->selmode = EINA_TRUE;
1255 edje_object_part_text_select_none(wd->ent, "elm.text");
1256 if (!_elm_config->desktop_entry)
1259 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1261 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1262 if (!_elm_config->desktop_entry)
1263 elm_object_scroll_freeze_pop(data); // TIZEN ONLY
1264 //elm_widget_scroll_hold_push(data);
1268 _remove_item_tags(const char *str)
1274 Eina_Strbuf *buf = eina_strbuf_new();
1278 if (!eina_strbuf_append(buf, str))
1283 const char *temp = eina_strbuf_string_get(buf);
1285 char *startTag = NULL;
1286 char *endTag = NULL;
1288 startTag = strstr(temp, "<item");
1290 startTag = strstr(temp, "</item");
1292 endTag = strstr(startTag, ">");
1295 if (!endTag || startTag > endTag)
1298 size_t sindex = startTag - temp;
1299 size_t eindex = endTag - temp + 1;
1300 if (!eina_strbuf_remove(buf, sindex, eindex))
1303 ret = eina_strbuf_string_steal(buf);
1304 eina_strbuf_free(buf);
1309 _elm_entry_entry_paste(Evas_Object *obj, const char *entry)
1311 Widget_Data *wd = elm_widget_data_get(obj);
1314 if (wd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
1316 str = _remove_item_tags(entry);
1317 if (!str) str = strdup(entry);
1320 str = strdup(entry);
1321 if (!str) str = (char *)entry;
1323 edje_object_part_text_user_insert(wd->ent, "elm.text", str);
1324 if (str != entry) free(str);
1327 #ifdef HAVE_ELEMENTARY_X
1328 if (cnpwidgetdata == obj)
1329 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1335 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1337 Widget_Data *wd = elm_widget_data_get(data);
1339 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1340 if (wd->sel_notify_handler)
1342 #ifdef HAVE_ELEMENTARY_X
1343 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1344 wd->selection_asked = EINA_TRUE;
1345 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1346 formats = ELM_SEL_FORMAT_TEXT;
1347 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1348 formats |= ELM_SEL_FORMAT_IMAGE;
1349 elm_cnp_selection_get(data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1355 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1357 Widget_Data *wd = elm_widget_data_get(obj);
1361 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1362 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1363 elm_cnp_selection_set(obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1364 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1365 eina_stringshare_replace(&wd->cut_sel, sel);
1369 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1371 Widget_Data *wd = elm_widget_data_get(data);
1374 wd->selmode = EINA_FALSE;
1375 if (!_elm_config->desktop_entry)
1376 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1377 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1378 if (!_elm_config->desktop_entry)
1379 elm_widget_scroll_hold_pop(data);
1380 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1381 edje_object_part_text_user_insert(wd->ent, "elm.text", "");
1386 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1388 Widget_Data *wd = elm_widget_data_get(data);
1390 wd->selmode = EINA_TRUE; // TIZEN ONLY
1391 if (!_elm_config->desktop_entry)
1393 //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE); // TIZEN ONLY
1394 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1395 elm_widget_scroll_hold_pop(data);
1397 _store_selection(ELM_SEL_TYPE_CLIPBOARD, data);
1398 // edje_object_part_text_select_none(wd->ent, "elm.text");
1402 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1404 Widget_Data *wd = elm_widget_data_get(data);
1406 wd->selmode = EINA_FALSE;
1407 if (!_elm_config->desktop_entry)
1408 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1409 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1410 if (!_elm_config->desktop_entry)
1411 elm_widget_scroll_hold_pop(data);
1412 edje_object_part_text_select_none(wd->ent, "elm.text");
1417 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1419 Widget_Data *wd = elm_widget_data_get(data);
1421 cnpwidgetdata = data;
1427 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1429 Elm_Entry_Context_Menu_Item *it = data;
1430 Evas_Object *obj2 = it->obj;
1431 if (it->func) it->func(it->data, obj2, NULL);
1435 _menu_press(Evas_Object *obj)
1437 Widget_Data *wd = elm_widget_data_get(obj);
1440 const Elm_Entry_Context_Menu_Item *it;
1442 if ((wd->api) && (wd->api->obj_longpress))
1444 wd->api->obj_longpress(obj);
1446 else if (wd->context_menu)
1448 const char *context_menu_orientation;
1450 if (wd->hoversel) evas_object_del(wd->hoversel);
1451 else elm_widget_scroll_freeze_push(obj);
1452 wd->hoversel = elm_hoversel_add(obj);
1453 context_menu_orientation = edje_object_data_get
1454 (wd->ent, "context_menu_orientation");
1455 if ((context_menu_orientation) &&
1456 (!strcmp(context_menu_orientation, "horizontal")))
1457 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1458 elm_object_style_set(wd->hoversel, "entry");
1459 elm_widget_sub_object_add(obj, wd->hoversel);
1460 elm_object_text_set(wd->hoversel, "Text");
1461 top = elm_widget_top_get(obj);
1462 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1463 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1464 if (wd->have_selection)
1468 if (wd->have_selection)
1470 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1473 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1476 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1484 if (!_elm_config->desktop_entry)
1487 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1490 if (elm_selection_selection_has_owner())
1493 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1498 EINA_LIST_FOREACH(wd->items, l, it)
1500 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1501 it->icon_type, _item_clicked, it);
1505 _hoversel_position(obj);
1506 evas_object_show(wd->hoversel);
1507 elm_hoversel_hover_begin(wd->hoversel);
1509 if (!_elm_config->desktop_entry)
1511 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1512 edje_object_part_text_select_abort(wd->ent, "elm.text");
1518 _magnifier_hide(void *data)
1520 Widget_Data *wd = elm_widget_data_get(data);
1523 evas_object_hide(wd->mgf_bg);
1524 evas_object_hide(wd->mgf_clip);
1527 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1531 _magnifier_show(void *data)
1533 Widget_Data *wd = elm_widget_data_get(data);
1536 evas_object_show(wd->mgf_bg);
1537 evas_object_show(wd->mgf_clip);
1541 _magnifier_move(void *data)
1543 Widget_Data *wd = elm_widget_data_get(data);
1546 Evas_Coord x, y, w, h;
1547 Evas_Coord cx, cy, cw, ch, ox, oy;
1549 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1553 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1554 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1559 evas_object_geometry_get(data, &x, &y, &w, &h);
1563 if ((cy + y) - wd->mgf_height < 0)
1564 oy = -1 * ((cy + y) - wd->mgf_height);
1566 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1567 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height + oy);
1568 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1569 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height + oy);
1573 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);
1577 _magnifier_create(void *data)
1579 Widget_Data *wd = elm_widget_data_get(data);
1580 Evas_Coord x, y, w, h, mw, mh;
1581 const char* key_data = NULL;
1588 evas_object_image_source_unset(wd->mgf_proxy);
1589 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1590 evas_object_hide(wd->mgf_proxy);
1591 evas_object_clip_unset(wd->mgf_proxy);
1592 evas_object_del(wd->mgf_proxy);
1594 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1595 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1598 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1600 evas_object_geometry_get(data, &x, &y, &w, &h);
1602 if ((w <= 0) || (h <= 0))
1605 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1607 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1608 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1609 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1610 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1614 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1615 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1616 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1618 key_data = edje_object_data_get(wd->mgf_bg, "height");
1619 if (key_data) wd->mgf_height = atoi(key_data);
1620 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1621 if (key_data) wd->mgf_scale = atof(key_data);
1623 elm_scale = elm_config_scale_get();
1624 wd->mgf_height = (int)((float)wd->mgf_height * elm_scale);
1626 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1627 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1631 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1632 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1633 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1637 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1638 evas_object_image_source_set(wd->mgf_proxy, data);
1641 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1642 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1643 if ((mw <= 0) || (mh <= 0))
1646 evas_object_resize(wd->mgf_proxy, mw, mh);
1647 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1648 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1649 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1650 evas_object_show(wd->mgf_proxy);
1651 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1653 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1654 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1658 _signal_long_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1660 Widget_Data *wd = elm_widget_data_get(data);
1663 wd->long_pressed = EINA_TRUE;
1664 _cancel(data, NULL, NULL);
1665 if (wd->magnifier_enabled)
1667 _magnifier_create(data);
1668 _magnifier_move(data);
1669 _magnifier_show(data);
1670 elm_object_scroll_freeze_push(data);
1675 _long_press(void *data)
1677 Widget_Data *wd = elm_widget_data_get(data);
1678 if (!wd) return ECORE_CALLBACK_CANCEL;
1679 if ((!_elm_config->desktop_entry) && (!wd->magnifier_enabled))
1680 _menu_press(data); /////// TIZEN ONLY
1681 wd->longpress_timer = NULL;
1682 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1683 return ECORE_CALLBACK_CANCEL;
1687 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1689 Widget_Data *wd = elm_widget_data_get(data);
1690 Evas_Event_Mouse_Down *ev = event_info;
1692 if (wd->disabled) return;
1693 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1694 wd->downx = ev->canvas.x;
1695 wd->downy = ev->canvas.y;
1696 wd->long_pressed = EINA_FALSE;
1697 if (ev->button == 1)
1699 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1700 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1705 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1707 Widget_Data *wd = elm_widget_data_get(data);
1708 Evas_Event_Mouse_Up *ev = event_info;
1710 if (wd->disabled) return;
1711 if (ev->button == 1)
1713 if (!wd->double_clicked)
1715 if ((wd->api) && (wd->api->obj_mouseup))
1716 wd->api->obj_mouseup(data);
1718 if (wd->magnifier_enabled)
1720 _magnifier_hide(data);
1721 elm_object_scroll_freeze_pop(data);
1722 if (wd->long_pressed) _menu_press(data);
1724 if (wd->longpress_timer)
1726 ecore_timer_del(wd->longpress_timer);
1727 wd->longpress_timer = NULL;
1730 else if ((ev->button == 3) && (!_elm_config->desktop_entry))
1738 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1740 Widget_Data *wd = elm_widget_data_get(data);
1741 Evas_Event_Mouse_Move *ev = event_info;
1743 if (wd->disabled) return;
1745 if (ev->buttons == 1)
1747 if ((wd->long_pressed) && (wd->magnifier_enabled))
1749 _magnifier_show(data);
1750 _magnifier_move(data);
1755 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1757 if (wd->longpress_timer)
1759 ecore_timer_del(wd->longpress_timer);
1760 wd->longpress_timer = NULL;
1763 else if (wd->longpress_timer)
1767 dx = wd->downx - ev->cur.canvas.x;
1769 dy = wd->downy - ev->cur.canvas.y;
1772 ((_elm_config->finger_size / 2) *
1773 (_elm_config->finger_size / 2)))
1775 ecore_timer_del(wd->longpress_timer);
1776 wd->longpress_timer = NULL;
1780 else if (wd->longpress_timer)
1784 dx = wd->downx - ev->cur.canvas.x;
1786 dy = wd->downy - ev->cur.canvas.y;
1789 ((_elm_config->finger_size / 2) *
1790 (_elm_config->finger_size / 2)))
1792 ecore_timer_del(wd->longpress_timer);
1793 wd->longpress_timer = NULL;
1799 _getbase(Evas_Object *obj)
1801 Widget_Data *wd = elm_widget_data_get(obj);
1802 if (!wd) return "base";
1805 if (wd->password) return "base-password";
1808 if (wd->single_line) return "base-single";
1811 switch (wd->linewrap)
1814 return "base-charwrap";
1817 case ELM_WRAP_MIXED:
1818 return "base-mixedwrap";
1821 return "base-nowrap";
1828 if (wd->password) return "base-password";
1831 if (wd->single_line) return "base-single-noedit";
1834 switch (wd->linewrap)
1837 return "base-noedit-charwrap";
1839 return "base-noedit";
1840 case ELM_WRAP_MIXED:
1841 return "base-noedit-mixedwrap";
1844 return "base-nowrap-noedit";
1852 _entry_changed_common_handling(void *data, const char *event)
1854 Widget_Data *wd = elm_widget_data_get(data);
1857 evas_event_freeze(evas_object_evas_get(data));
1858 wd->changed = EINA_TRUE;
1859 /* Reset the size hints which are no more relevant.
1860 * Keep the height, this is a hack, but doesn't really matter
1861 * cause we'll re-eval in a moment. */
1862 evas_object_size_hint_min_get(data, NULL, &minh);
1863 evas_object_size_hint_min_set(data, -1, minh);
1865 if (wd->text) eina_stringshare_del(wd->text);
1867 if (wd->password_text) eina_stringshare_del(wd->password_text);
1868 wd->password_text = NULL;
1869 if (wd->delay_write)
1871 ecore_timer_del(wd->delay_write);
1872 wd->delay_write = NULL;
1875 if ((wd->api) && (wd->api->obj_hidemenu))
1876 wd->api->obj_hidemenu(data);
1878 evas_event_thaw(evas_object_evas_get(data));
1879 evas_event_thaw_eval(evas_object_evas_get(data));
1880 if ((wd->autosave) && (wd->file))
1881 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1882 /* callback - this could call callbacks that delete the entry... thus...
1883 * any access to wd after this could be invalid */
1884 evas_object_smart_callback_call(data, event, NULL);
1885 _check_enable_return_key(data);
1889 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1891 _entry_changed_common_handling(data, SIG_CHANGED);
1895 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1897 Widget_Data *wd = elm_widget_data_get(data);
1900 elm_object_scroll_freeze_push(data);
1902 if ((wd->api) && (wd->api->obj_hidemenu))
1903 wd->api->obj_hidemenu(data);
1905 if (wd->magnifier_enabled)
1907 _magnifier_create(data);
1908 _magnifier_move(data);
1909 _magnifier_show(data);
1914 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1916 Widget_Data *wd = elm_widget_data_get(data);
1919 elm_object_scroll_freeze_pop(data);
1921 if (wd->have_selection)
1923 _magnifier_hide(data);
1929 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1931 Widget_Data *wd = elm_widget_data_get(data);
1934 if (wd->magnifier_enabled)
1936 _magnifier_move(data);
1937 _magnifier_show(data);
1941 static Evas_Coord_Rectangle
1942 _intersection_region_get(Evas_Coord_Rectangle rect1, Evas_Coord_Rectangle rect2)
1944 Evas_Coord_Rectangle ret_rect;
1945 Evas_Coord_Point l1, l2, r1, r2, p1, p2;
1949 r1.x = rect1.x + rect1.w;
1950 r1.y = rect1.y + rect1.h;
1954 r2.x = rect2.x + rect2.w;
1955 r2.y = rect2.y + rect2.h;
1957 p1.x = (l1.x > l2.x) ? l1.x : l2.x;
1958 p1.y = (l1.y > l2.y) ? l1.y : l2.y;
1959 p2.x = (r1.x < r2.x) ? r1.x : r2.x;
1960 p2.y = (r1.y < r2.y) ? r1.y : r2.y;
1964 ret_rect.w = (p2.x > p1.x) ? p2.x - p1.x : -1;
1965 ret_rect.h = (p2.y > p1.y) ? p2.y - p1.y : -1;
1970 static Evas_Coord_Rectangle
1971 _viewport_region_get(Evas_Object *data)
1973 Evas_Coord_Rectangle geometry, ret_rect;
1974 geometry.x = geometry.y = geometry.w = geometry.h = -1;
1975 ret_rect = geometry;
1977 Widget_Data *wd = elm_widget_data_get(data);
1978 if (!wd) return geometry;
1979 if (!data || !strlen(elm_widget_type_get(data))) return geometry;
1983 evas_object_geometry_get(wd->scroller, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
1984 ret_rect = geometry;
1987 Evas_Object *parent_obj = data;
1989 while ((parent_obj = elm_widget_parent_get(parent_obj)))
1991 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
1992 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
1994 evas_object_geometry_get(parent_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
1995 if ((ret_rect.w == -1) && (ret_rect.h == -1)) ret_rect = geometry;
1996 ret_rect = _intersection_region_get(geometry, ret_rect);
2003 static Evas_Coord_Rectangle
2004 _layout_region_get(Evas_Object *data)
2006 Evas_Coord_Rectangle geometry;
2007 geometry.x = geometry.y = geometry.w = geometry.h = -1;
2009 Widget_Data *wd = elm_widget_data_get(data);
2010 if (!wd) return geometry;
2011 if (!data || !strlen(elm_widget_type_get(data))) return geometry;
2013 Evas_Object *child_obj = data;
2014 Evas_Object *parent_obj;
2016 while ((parent_obj = elm_widget_parent_get(child_obj)))
2018 if (!strcmp(elm_widget_type_get(parent_obj), "conformant"))
2020 evas_object_geometry_get(child_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
2023 child_obj = parent_obj;
2030 _region_get_job(void *data)
2032 Widget_Data *wd = elm_widget_data_get(data);
2034 wd->region_get_job = NULL;
2036 if (!_elm_config->desktop_entry)
2038 if (wd->region_recalc_job) ecore_job_del(wd->region_recalc_job);
2039 wd->region_recalc_job = ecore_job_add(_region_recalc_job, data);
2041 evas_smart_objects_calculate(evas_object_evas_get(data));
2046 _region_recalc_job(void *data)
2048 Widget_Data *wd = elm_widget_data_get(data);
2049 Evas_Coord_Rectangle ret_rect;
2051 wd->region_recalc_job = NULL;
2053 if (!_elm_config->desktop_entry)
2055 ret_rect = _viewport_region_get(data);
2056 edje_object_part_text_viewport_region_set(wd->ent, "elm.text", ret_rect.x, ret_rect.y, ret_rect.w, ret_rect.h);
2057 ret_rect = _layout_region_get(data);
2058 edje_object_part_text_layout_region_set(wd->ent, "elm.text", ret_rect.x, ret_rect.y, ret_rect.w, ret_rect.h);
2063 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2065 Widget_Data *wd = elm_widget_data_get(data);
2068 if (wd->magnifier_enabled)
2069 _magnifier_hide(data);
2074 _signal_entry_changed_user(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2076 Elm_Entry_Change_Info info;
2077 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
2078 edje_object_signal_callback_extra_data_get();
2081 memcpy(&info, edje_info, sizeof(info));
2082 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
2086 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
2091 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2093 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
2097 _signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2099 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
2103 _signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2105 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
2109 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2111 Widget_Data *wd = elm_widget_data_get(data);
2115 EINA_LIST_FOREACH(entries, l, entry)
2117 if (entry != data) elm_entry_select_none(entry);
2119 wd->have_selection = EINA_TRUE;
2120 wd->selmode = EINA_TRUE;
2121 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2122 #ifdef HAVE_ELEMENTARY_X
2123 if (wd->sel_notify_handler)
2125 const char *txt = elm_entry_selection_get(data);
2128 top = elm_widget_top_get(data);
2129 if (txt && top && (elm_win_xwindow_get(top)))
2130 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2131 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
2137 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2139 Evas_Coord cx, cy, cw, ch;
2140 Widget_Data *wd = elm_widget_data_get(data);
2143 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2144 if (!wd->deferred_recalc_job)
2145 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2148 wd->deferred_cur = EINA_TRUE;
2157 _signal_selection_all(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2159 Widget_Data *wd = elm_widget_data_get(data);
2161 elm_entry_select_all(data);
2165 _signal_selection_none(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2167 Widget_Data *wd = elm_widget_data_get(data);
2169 elm_entry_select_none(data);
2173 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2175 Evas_Coord cx, cy, cw, ch;
2176 Widget_Data *wd = elm_widget_data_get(data);
2178 wd->have_selection = EINA_TRUE;
2179 wd->selmode = EINA_TRUE;
2180 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2181 _store_selection(ELM_SEL_TYPE_PRIMARY, data);
2184 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2185 if (!wd->deferred_recalc_job)
2186 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2189 wd->deferred_cur = EINA_TRUE;
2199 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2201 Widget_Data *wd = elm_widget_data_get(data);
2203 if (!wd->have_selection) return;
2204 wd->have_selection = EINA_FALSE;
2205 wd->selmode = EINA_FALSE; /////////////// exist in ours only - necessary ?
2206 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2207 if (wd->sel_notify_handler)
2211 #ifdef HAVE_ELEMENTARY_X
2214 top = elm_widget_top_get(data);
2215 if ((top) && (elm_win_xwindow_get(top)))
2216 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2217 ELM_SEL_FORMAT_MARKUP, wd->cut_sel,
2218 strlen(wd->cut_sel));
2220 eina_stringshare_del(wd->cut_sel);
2225 #ifdef HAVE_ELEMENTARY_X
2228 top = elm_widget_top_get(data);
2229 if ((top) && (elm_win_xwindow_get(top)))
2230 elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
2235 if ((wd->api) && (wd->api->obj_hidemenu))
2237 wd->api->obj_hidemenu(data);
2242 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2244 Widget_Data *wd = elm_widget_data_get(data);
2245 #ifdef HAVE_ELEMENTARY_X
2246 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
2247 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
2251 if (!wd->editable) return;
2252 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2253 if (wd->sel_notify_handler)
2255 #ifdef HAVE_ELEMENTARY_X
2258 top = elm_widget_top_get(data);
2259 if ((top) && (elm_win_xwindow_get(top)))
2261 wd->selection_asked = EINA_TRUE;
2262 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2263 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2264 formats = ELM_SEL_FORMAT_TEXT;
2265 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2266 formats |= ELM_SEL_FORMAT_IMAGE;
2267 elm_cnp_selection_get(data, type, formats,
2275 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2277 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2278 _copy(data, NULL, NULL);
2282 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2284 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2285 _cut(data, NULL, NULL);
2289 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2291 Widget_Data *wd = elm_widget_data_get(data);
2293 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2294 wd->cur_changed = EINA_TRUE;
2295 _recalc_cursor_geometry(data);
2299 _signal_cursor_changed_manual(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2301 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
2306 _signal_anchor_geoms_do_things_with(Widget_Data *wd, Elm_Entry_Anchor_Info *ei)
2308 const Eina_List *geoms, *l;
2309 Evas_Textblock_Rectangle *r;
2310 Evas_Coord px, py, x, y;
2312 geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei->name);
2316 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2317 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2318 EINA_LIST_FOREACH(geoms, l, r)
2320 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2321 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2333 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2335 Widget_Data *wd = elm_widget_data_get(data);
2336 Elm_Entry_Anchor_Info ei;
2340 p = emission + sizeof("nchor,mouse,down,");
2341 ei.button = strtol(p, &p2, 10);
2343 ei.x = ei.y = ei.w = ei.h = 0;
2345 _signal_anchor_geoms_do_things_with(wd, &ei);
2348 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
2352 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2354 Widget_Data *wd = elm_widget_data_get(data);
2355 Elm_Entry_Anchor_Info ei;
2359 p = emission + sizeof("nchor,mouse,up,");
2360 ei.button = strtol(p, &p2, 10);
2362 ei.x = ei.y = ei.w = ei.h = 0;
2364 _signal_anchor_geoms_do_things_with(wd, &ei);
2367 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
2371 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2373 Widget_Data *wd = elm_widget_data_get(data);
2374 Elm_Entry_Anchor_Info ei;
2378 p = emission + sizeof("nchor,mouse,clicked,");
2379 ei.button = strtol(p, &p2, 10);
2381 ei.x = ei.y = ei.w = ei.h = 0;
2383 _signal_anchor_geoms_do_things_with(wd, &ei);
2387 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2389 if (!_elm_config->desktop_entry)
2390 _entry_hover_anchor_clicked(data, data, &ei);
2395 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2397 Widget_Data *wd = elm_widget_data_get(data);
2402 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2404 Widget_Data *wd = elm_widget_data_get(data);
2405 Elm_Entry_Anchor_Info ei;
2407 ei.name = emission + sizeof("nchor,mouse,in,");
2409 ei.x = ei.y = ei.w = ei.h = 0;
2411 _signal_anchor_geoms_do_things_with(wd, &ei);
2414 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
2418 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2420 Widget_Data *wd = elm_widget_data_get(data);
2421 Elm_Entry_Anchor_Info ei;
2423 ei.name = emission + sizeof("nchor,mouse,out,");
2425 ei.x = ei.y = ei.w = ei.h = 0;
2427 _signal_anchor_geoms_do_things_with(wd, &ei);
2430 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
2434 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2436 Widget_Data *wd = elm_widget_data_get(data);
2438 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2442 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2444 Widget_Data *wd = elm_widget_data_get(data);
2446 wd->double_clicked = EINA_FALSE;
2447 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2449 if ((wd->api) && (wd->api->obj_hidemenu))
2450 wd->api->obj_hidemenu(data);
2454 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2456 Widget_Data *wd = elm_widget_data_get(data);
2458 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2460 if (!_elm_config->desktop_entry && !wd->double_clicked)
2461 _cancel(data, NULL, NULL);
2465 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2467 Widget_Data *wd = elm_widget_data_get(data);
2469 wd->double_clicked = EINA_TRUE;
2470 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2474 _signal_mouse_triple(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2476 Widget_Data *wd = elm_widget_data_get(data);
2478 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
2481 #ifdef HAVE_ELEMENTARY_X
2483 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2485 Widget_Data *wd = elm_widget_data_get(data);
2486 Ecore_X_Event_Selection_Notify *ev = event;
2487 if (!wd) return ECORE_CALLBACK_PASS_ON;
2488 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2489 return ECORE_CALLBACK_PASS_ON;
2491 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2492 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2494 Ecore_X_Selection_Data_Text *text_data;
2496 text_data = ev->data;
2497 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2499 if (text_data->text)
2501 char *txt = _elm_util_text_to_mkup(text_data->text);
2505 elm_entry_entry_insert(data, txt);
2510 wd->selection_asked = EINA_FALSE;
2512 else if (ev->selection == ECORE_X_SELECTION_XDND)
2514 Ecore_X_Selection_Data_Text *text_data;
2516 text_data = ev->data;
2517 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2519 if (text_data->text)
2521 char *txt = _elm_util_text_to_mkup(text_data->text);
2525 /* Massive FIXME: this should be at the drag point */
2526 elm_entry_entry_insert(data, txt);
2531 wd->drag_selection_asked = EINA_FALSE;
2533 ecore_x_dnd_send_finished();
2536 return ECORE_CALLBACK_PASS_ON;
2540 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2543 Widget_Data *wd = elm_widget_data_get(data);
2544 Ecore_X_Event_Selection_Clear *ev = event;
2545 if (!wd) return ECORE_CALLBACK_PASS_ON;
2546 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2547 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2548 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2550 elm_entry_select_none(data);
2555 Evas_Object *top = elm_widget_top_get(data);
2556 Ecore_X_Event_Selection_Clear *ev = event;
2559 return ECORE_CALLBACK_PASS_ON;
2561 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2563 return ECORE_CALLBACK_PASS_ON;
2566 if (cnpwidgetdata == data)
2568 Widget_Data *wd = elm_widget_data_get(data);
2569 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2570 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2571 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2572 formats = ELM_SEL_FORMAT_TEXT;
2573 else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2574 formats |= ELM_SEL_FORMAT_IMAGE;
2575 elm_cnp_selection_get(data, ELM_SEL_TYPE_SECONDARY, formats, NULL, NULL);
2580 return ECORE_CALLBACK_PASS_ON;
2584 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2589 wd = elm_widget_data_get(obj);
2590 if (!wd) return EINA_FALSE;
2591 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2593 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2594 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2595 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2596 EDJE_CURSOR_MAIN,drop->x,drop->y);
2597 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2598 elm_entry_entry_insert(obj, drop->data);
2599 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2600 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2606 static Evas_Object *
2607 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2609 Widget_Data *wd = elm_widget_data_get(data);
2612 Elm_Entry_Item_Provider *ip;
2614 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2616 o = ip->func(ip->data, data, item);
2619 if (!strncmp(item, "file://", 7))
2621 const char *fname = item + 7;
2623 o = evas_object_image_filled_add(evas_object_evas_get(data));
2624 evas_object_image_file_set(o, fname, NULL);
2625 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2627 evas_object_show(o);
2632 o = edje_object_add(evas_object_evas_get(data));
2633 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2637 o = edje_object_add(evas_object_evas_get(data));
2638 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2639 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2644 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2646 Widget_Data *wd = elm_widget_data_get(data);
2648 Elm_Entry_Markup_Filter *tf;
2650 if (type == EDJE_TEXT_FILTER_FORMAT)
2653 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2655 tf->func(tf->data, data, text);
2662 _markup_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, char **text)
2664 Widget_Data *wd = elm_widget_data_get(data);
2666 Elm_Entry_Markup_Filter *tf;
2668 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
2670 tf->func(tf->data, data, text);
2676 /* This function is used to insert text by chunks in jobs */
2678 _text_append_idler(void *data)
2682 Evas_Object *obj = (Evas_Object *) data;
2683 Widget_Data *wd = elm_widget_data_get(obj);
2684 if (wd->text) eina_stringshare_del(wd->text);
2686 if (wd->password_text) eina_stringshare_del(wd->password_text);
2687 wd->password_text = NULL;
2688 evas_event_freeze(evas_object_evas_get(obj));
2689 wd->changed = EINA_TRUE;
2691 start = wd->append_text_position;
2692 if (start + _CHUNK_SIZE < wd->append_text_len)
2695 int tag_start, esc_start;
2697 tag_start = esc_start = -1;
2698 /* Find proper markup cut place */
2699 while (pos - start < _CHUNK_SIZE)
2703 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2704 if (esc_start == -1)
2707 tag_start = prev_pos;
2708 else if (tmp == '>')
2711 if (tag_start == -1)
2714 esc_start = prev_pos;
2715 else if (tmp == ';')
2722 wd->append_text_position = tag_start;
2724 else if (esc_start >= 0)
2726 wd->append_text_position = esc_start;
2730 wd->append_text_position = pos;
2735 wd->append_text_position = wd->append_text_len;
2738 backup = wd->append_text_left[wd->append_text_position];
2739 wd->append_text_left[wd->append_text_position] = '\0';
2741 edje_object_part_text_append(wd->ent, "elm.text",
2742 wd->append_text_left + start);
2744 wd->append_text_left[wd->append_text_position] = backup;
2746 evas_event_thaw(evas_object_evas_get(obj));
2747 evas_event_thaw_eval(evas_object_evas_get(obj));
2749 /* If there's still more to go, renew the idler, else, cleanup */
2750 if (wd->append_text_position < wd->append_text_len)
2752 return ECORE_CALLBACK_RENEW;
2756 free(wd->append_text_left);
2757 wd->append_text_left = NULL;
2758 wd->append_text_idler = NULL;
2759 return ECORE_CALLBACK_CANCEL;
2764 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2766 int i = 0, current_len = 0;
2770 if (unit >= LENGTH_UNIT_LAST) return;
2772 current_len = strlen(*text);
2775 int idx = 0, unit_size = 0;
2776 char *markup, *utfstr;
2777 if (*new_text == '<')
2779 while (*(new_text + idx) != '>')
2782 if (!*(new_text + idx)) break;
2785 else if (*new_text == '&')
2787 while (*(new_text + idx) != ';')
2790 if (!*(new_text + idx)) break;
2793 idx = evas_string_char_next_get(new_text, idx, NULL);
2794 markup = malloc(idx + 1);
2797 strncpy(markup, new_text, idx);
2799 utfstr = elm_entry_markup_to_utf8(markup);
2802 if (unit == LENGTH_UNIT_BYTE)
2803 unit_size = strlen(utfstr);
2804 else if (unit == LENGTH_UNIT_CHAR)
2805 unit_size = evas_string_char_len_get(utfstr);
2812 if (can_add < unit_size)
2816 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2822 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2824 (*text)[current_len] = 0;
2829 can_add -= unit_size;
2833 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2837 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2840 ELM_CHECK_WIDTYPE(obj, widtype);
2841 Widget_Data *wd = elm_widget_data_get(obj);
2843 if (!entry) entry = "";
2844 if (item && strcmp(item, "default"))
2846 edje_object_part_text_set(wd->ent, item, entry);
2850 evas_event_freeze(evas_object_evas_get(obj));
2851 if (wd->text) eina_stringshare_del(wd->text);
2853 if (wd->password_text) eina_stringshare_del(wd->password_text);
2854 wd->password_text = NULL;
2855 wd->changed = EINA_TRUE;
2857 /* Clear currently pending job if there is one */
2858 if (wd->append_text_idler)
2860 ecore_idler_del(wd->append_text_idler);
2861 free(wd->append_text_left);
2862 wd->append_text_left = NULL;
2863 wd->append_text_idler = NULL;
2866 len = strlen(entry);
2867 /* Split to ~_CHUNK_SIZE chunks */
2868 if (len > _CHUNK_SIZE)
2870 wd->append_text_left = (char *) malloc(len + 1);
2873 /* If we decided to use the idler */
2874 if (wd->append_text_left)
2876 /* Need to clear the entry first */
2877 edje_object_part_text_set(wd->ent, "elm.text", "");
2878 memcpy(wd->append_text_left, entry, len + 1);
2879 wd->append_text_position = 0;
2880 wd->append_text_len = len;
2881 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2885 edje_object_part_text_set(wd->ent, "elm.text", entry);
2887 evas_event_thaw(evas_object_evas_get(obj));
2888 evas_event_thaw_eval(evas_object_evas_get(obj));
2892 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2894 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2895 Widget_Data *wd = elm_widget_data_get(obj);
2896 if (item && strcmp(item, "default")) return NULL;
2898 if (!wd) return NULL;
2900 text = edje_object_part_text_get(wd->ent, "elm.text");
2903 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2907 if (wd->append_text_len > 0)
2911 tlen = strlen(text);
2912 tmpbuf = malloc(tlen + wd->append_text_len + 1);
2915 ERR("Failed to allocate memory for entry's text %p", obj);
2918 memcpy(tmpbuf, text, tlen);
2919 if (wd->append_text_left)
2920 memcpy(tmpbuf + tlen, wd->append_text_left, strlen(wd->append_text_left));
2921 tmpbuf[tlen + wd->append_text_len] = '\0';
2922 eina_stringshare_replace(&wd->text, tmpbuf);
2927 eina_stringshare_replace(&wd->text, text);
2932 pw_text = elm_entry_markup_to_utf8(wd->text);
2935 eina_stringshare_replace(&wd->password_text, pw_text);
2937 return wd->password_text;
2944 elm_entry_add(Evas_Object *parent)
2946 #ifdef HAVE_ELEMENTARY_X
2953 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2955 ELM_SET_WIDTYPE(widtype, "entry");
2956 elm_widget_type_set(obj, "entry");
2957 elm_widget_sub_object_add(parent, obj);
2958 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2959 elm_widget_data_set(obj, wd);
2960 elm_widget_del_hook_set(obj, _del_hook);
2961 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2962 elm_widget_theme_hook_set(obj, _theme_hook);
2963 elm_widget_disable_hook_set(obj, _disable_hook);
2964 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2965 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2966 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2967 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2968 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2969 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2970 elm_widget_can_focus_set(obj, EINA_TRUE);
2971 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2972 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2973 elm_widget_content_set_hook_set(obj, _content_set_hook);
2974 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2975 elm_widget_content_get_hook_set(obj, _content_get_hook);
2976 elm_widget_translate_hook_set(obj, _translate_hook);
2977 elm_widget_event_hook_set(obj, _event_hook);
2979 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2981 wd->linewrap = ELM_WRAP_WORD;
2982 wd->editable = EINA_TRUE;
2983 wd->disabled = EINA_FALSE;
2984 wd->context_menu = EINA_TRUE;
2985 wd->autosave = EINA_TRUE;
2986 wd->cnp_mode = ELM_CNP_MODE_MARKUP;
2987 wd->scroll = EINA_FALSE;
2988 wd->input_panel_imdata = NULL;
2990 wd->magnifier_enabled = EINA_TRUE;
2993 wd->ent = edje_object_add(e);
2994 edje_object_item_provider_set(wd->ent, _get_item, obj);
2995 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2996 edje_object_text_markup_filter_callback_add(wd->ent,"elm.text", _markup_filter, obj);
2997 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2998 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
3000 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
3002 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
3004 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
3006 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
3007 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
3008 _signal_entry_changed, obj);
3009 edje_object_signal_callback_add(wd->ent, "entry,changed,user", "elm.text",
3010 _signal_entry_changed_user, obj);
3011 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
3012 _signal_preedit_changed, obj);
3013 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
3014 _signal_selection_start, obj);
3015 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
3016 _signal_selection_changed, obj);
3017 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
3018 _signal_selection_all, obj);
3019 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
3020 _signal_selection_none, obj);
3021 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
3022 _signal_selection_cleared, obj);
3023 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
3024 _signal_entry_paste_request, obj);
3025 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
3026 _signal_entry_copy_notify, obj);
3027 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
3028 _signal_entry_cut_notify, obj);
3029 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
3030 _signal_cursor_changed, obj);
3031 edje_object_signal_callback_add(wd->ent, "cursor,changed,manual", "elm.text",
3032 _signal_cursor_changed_manual, obj);
3033 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
3034 _signal_anchor_down, obj);
3035 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
3036 _signal_anchor_up, obj);
3037 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
3038 _signal_anchor_clicked, obj);
3039 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
3040 _signal_anchor_move, obj);
3041 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
3042 _signal_anchor_in, obj);
3043 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
3044 _signal_anchor_out, obj);
3045 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
3046 _signal_key_enter, obj);
3047 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
3048 _signal_mouse_down, obj);
3049 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
3050 _signal_mouse_clicked, obj);
3051 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
3052 _signal_mouse_double, obj);
3053 edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
3054 _signal_mouse_triple, obj);
3055 edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
3056 _signal_undo_request, obj);
3057 edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
3058 _signal_redo_request, obj);
3060 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
3061 _signal_handler_move_start, obj);
3062 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
3063 _signal_handler_move_end, obj);
3064 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
3065 _signal_handler_moving, obj);
3066 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
3067 _signal_selection_end, obj);
3068 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
3069 _signal_long_pressed, obj);
3070 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
3071 _signal_magnifier_changed, obj);
3073 edje_object_part_text_set(wd->ent, "elm.text", "");
3074 if (_elm_config->desktop_entry)
3075 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
3078 edje_object_part_text_copy_paste_disabled_set(wd->ent, "elm.text", EINA_FALSE);
3079 edje_object_part_text_viewport_region_set(wd->ent, "elm.text", -1, -1, -1, -1);
3080 edje_object_part_text_layout_region_set(wd->ent, "elm.text", -1, -1, -1, -1);
3082 elm_widget_resize_object_set(obj, wd->ent);
3085 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
3087 elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
3088 elm_entry_prediction_allow_set(obj, EINA_TRUE);
3090 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
3092 #ifdef HAVE_ELEMENTARY_X
3093 top = elm_widget_top_get(obj);
3094 if ((top) && (elm_win_xwindow_get(top)))
3096 wd->sel_notify_handler =
3097 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
3098 _event_selection_notify, obj);
3099 wd->sel_clear_handler =
3100 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
3101 _event_selection_clear, obj);
3104 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3105 _drag_drop_cb, NULL);
3108 entries = eina_list_prepend(entries, obj);
3110 // module - find module for entry
3111 wd->api = _module(obj);
3112 // if found - hook in
3113 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
3115 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3116 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3117 // TODO: and save some bytes, making descriptions per-class and not instance!
3118 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3122 void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
3124 ELM_CHECK_WIDTYPE(obj, widtype);
3125 Widget_Data *wd = elm_widget_data_get(obj);
3127 ext_mod->cancel = _cancel;
3128 ext_mod->copy = _copy;
3129 ext_mod->cut = _cut;
3130 ext_mod->paste = _paste;
3131 ext_mod->select = _select;
3132 ext_mod->selectall = _selectall;
3133 ext_mod->ent = wd->ent;
3134 ext_mod->items = wd->items;
3135 ext_mod->editable = wd->editable;
3136 ext_mod->have_selection = wd->have_selection;
3137 ext_mod->password = wd->password;
3138 ext_mod->selmode = wd->selmode;
3139 ext_mod->cnpinit = _cnpinit;
3140 ext_mod->context_menu = wd->context_menu;
3141 ext_mod->cnp_mode = wd->cnp_mode;
3142 ext_mod->viewport_rect = _viewport_region_get(obj);
3146 elm_entry_text_style_user_push(Evas_Object *obj, const char *style)
3148 ELM_CHECK_WIDTYPE(obj, widtype);
3149 Widget_Data *wd = elm_widget_data_get(obj);
3151 edje_object_part_text_style_user_push(wd->ent, "elm.text", style);
3156 elm_entry_text_style_user_pop(Evas_Object *obj)
3158 ELM_CHECK_WIDTYPE(obj, widtype);
3159 Widget_Data *wd = elm_widget_data_get(obj);
3161 edje_object_part_text_style_user_pop(wd->ent, "elm.text");
3166 elm_entry_text_style_user_peek(const Evas_Object *obj)
3168 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3169 Widget_Data *wd = elm_widget_data_get(obj);
3170 if (!wd) return NULL;
3171 return edje_object_part_text_style_user_peek(wd->ent, "elm.text");
3175 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
3177 ELM_CHECK_WIDTYPE(obj, widtype);
3178 Widget_Data *wd = elm_widget_data_get(obj);
3180 if (wd->single_line == single_line) return;
3181 wd->single_line = single_line;
3182 wd->linewrap = ELM_WRAP_NONE;
3183 elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
3187 if (wd->single_line)
3189 elm_smart_scroller_policy_set(wd->scroller,
3190 ELM_SMART_SCROLLER_POLICY_OFF,
3191 ELM_SMART_SCROLLER_POLICY_OFF);
3192 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); // TIZEN ONLY
3196 const Elm_Scroller_Policy map[3] =
3198 ELM_SMART_SCROLLER_POLICY_AUTO,
3199 ELM_SMART_SCROLLER_POLICY_ON,
3200 ELM_SMART_SCROLLER_POLICY_OFF
3202 elm_smart_scroller_policy_set(wd->scroller,
3205 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); // TIZEN ONLY
3212 elm_entry_single_line_get(const Evas_Object *obj)
3214 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3215 Widget_Data *wd = elm_widget_data_get(obj);
3216 if (!wd) return EINA_FALSE;
3217 return wd->single_line;
3221 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3223 ELM_CHECK_WIDTYPE(obj, widtype);
3224 Widget_Data *wd = elm_widget_data_get(obj);
3226 if (wd->password == password) return;
3227 wd->password = password;
3230 wd->single_line = EINA_TRUE;
3231 wd->linewrap = ELM_WRAP_NONE;
3232 #ifdef HAVE_ELEMENTARY_X
3233 elm_drop_target_del(obj);
3235 edje_object_signal_callback_del_full(wd->ent, "selection,start", "elm.text",
3236 _signal_selection_start, obj);
3237 edje_object_signal_callback_del_full(wd->ent, "selection,changed", "elm.text",
3238 _signal_selection_changed, obj);
3239 edje_object_signal_callback_del_full(wd->ent, "entry,selection,all,request", "elm.text",
3240 _signal_selection_all, obj);
3241 edje_object_signal_callback_del_full(wd->ent, "entry,selection,none,request", "elm.text",
3242 _signal_selection_none, obj);
3243 edje_object_signal_callback_del_full(wd->ent, "selection,cleared", "elm.text",
3244 _signal_selection_cleared, obj);
3245 edje_object_signal_callback_del_full(wd->ent, "entry,paste,request,*", "elm.text",
3246 _signal_entry_paste_request, obj);
3247 edje_object_signal_callback_del_full(wd->ent, "entry,copy,notify", "elm.text",
3248 _signal_entry_copy_notify, obj);
3249 edje_object_signal_callback_del_full(wd->ent, "entry,cut,notify", "elm.text",
3250 _signal_entry_cut_notify, obj);
3254 #ifdef HAVE_ELEMENTARY_X
3255 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3257 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
3258 _signal_selection_start, obj);
3259 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
3260 _signal_selection_changed, obj);
3261 edje_object_signal_callback_add(wd->ent, "entry,selection,all,request", "elm.text",
3262 _signal_selection_all, obj);
3263 edje_object_signal_callback_add(wd->ent, "entry,selection,none,request", "elm.text",
3264 _signal_selection_none, obj);
3265 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
3266 _signal_selection_cleared, obj);
3267 edje_object_signal_callback_add(wd->ent, "entry,paste,request,*", "elm.text",
3268 _signal_entry_paste_request, obj);
3269 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
3270 _signal_entry_copy_notify, obj);
3271 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
3272 _signal_entry_cut_notify, obj);
3278 elm_entry_password_get(const Evas_Object *obj)
3280 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3281 Widget_Data *wd = elm_widget_data_get(obj);
3282 if (!wd) return EINA_FALSE;
3283 return wd->password;
3287 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3289 _elm_entry_text_set(obj, NULL, entry);
3293 elm_entry_entry_get(const Evas_Object *obj)
3295 return _elm_entry_text_get(obj, NULL);
3299 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3302 ELM_CHECK_WIDTYPE(obj, widtype);
3303 Widget_Data *wd = elm_widget_data_get(obj);
3305 if (!entry) entry = "";
3306 wd->changed = EINA_TRUE;
3308 len = strlen(entry);
3309 if (wd->append_text_left)
3312 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3318 wd->append_text_left = tmpbuf;
3319 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3320 wd->append_text_len += len;
3324 /* FIXME: Add chunked appending here (like in entry_set) */
3325 edje_object_part_text_append(wd->ent, "elm.text", entry);
3330 elm_entry_is_empty(const Evas_Object *obj)
3332 /* FIXME: until there's support for that in textblock, we just check
3333 * to see if the there is text or not. */
3334 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3335 Widget_Data *wd = elm_widget_data_get(obj);
3336 const Evas_Object *tb;
3337 Evas_Textblock_Cursor *cur;
3339 if (!wd) return EINA_TRUE;
3341 if (0) { // TIZEN ONLY
3342 /* It's a hack until we get the support suggested above.
3343 * We just create a cursor, point it to the begining, and then
3344 * try to advance it, if it can advance, the tb is not empty,
3345 * otherwise it is. */
3346 tb = edje_object_part_object_get(wd->ent, "elm.text");
3347 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3348 actually, ok for the time being, these hackish stuff will be removed
3349 once evas 1.0 is out*/
3350 evas_textblock_cursor_pos_set(cur, 0);
3351 ret = evas_textblock_cursor_char_next(cur);
3352 evas_textblock_cursor_free(cur);
3357 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3358 if (!str) return EINA_TRUE;
3360 ret = (strlen(str) == 0);
3367 elm_entry_textblock_get(Evas_Object *obj)
3369 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3370 Widget_Data *wd = elm_widget_data_get(obj);
3371 if (!wd) return NULL;
3373 return (Evas_Object *) edje_object_part_object_get(wd->ent, "elm.text");
3377 elm_entry_calc_force(Evas_Object *obj)
3379 ELM_CHECK_WIDTYPE(obj, widtype);
3380 Widget_Data *wd = elm_widget_data_get(obj);
3383 edje_object_calc_force(wd->ent);
3384 wd->changed = EINA_TRUE;
3390 elm_entry_selection_get(const Evas_Object *obj)
3392 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3393 Widget_Data *wd = elm_widget_data_get(obj);
3394 if ((!wd) || (wd->password)) return NULL;
3395 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3399 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3401 ELM_CHECK_WIDTYPE(obj, widtype);
3402 Widget_Data *wd = elm_widget_data_get(obj);
3404 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3406 #ifdef HAVE_ELEMENTARY_X
3407 if (cnpwidgetdata == obj)
3408 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3411 wd->changed = EINA_TRUE;
3416 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3418 ELM_CHECK_WIDTYPE(obj, widtype);
3419 Widget_Data *wd = elm_widget_data_get(obj);
3421 if (wd->linewrap == wrap) return;
3423 wd->linewrap = wrap;
3428 elm_entry_line_wrap_get(const Evas_Object *obj)
3430 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3431 Widget_Data *wd = elm_widget_data_get(obj);
3432 if (!wd) return EINA_FALSE;
3433 return wd->linewrap;
3437 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3439 ELM_CHECK_WIDTYPE(obj, widtype);
3440 Widget_Data *wd = elm_widget_data_get(obj);
3442 if (wd->editable == editable) return;
3443 wd->editable = editable;
3446 #ifdef HAVE_ELEMENTARY_X
3448 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3450 elm_drop_target_del(obj);
3455 elm_entry_editable_get(const 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 wd->editable;
3464 elm_entry_select_none(Evas_Object *obj)
3466 ELM_CHECK_WIDTYPE(obj, widtype);
3467 Widget_Data *wd = elm_widget_data_get(obj);
3468 if ((!wd) || (wd->password)) return;
3471 wd->selmode = EINA_FALSE;
3472 if (!_elm_config->desktop_entry)
3473 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3474 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3476 wd->have_selection = EINA_FALSE;
3477 edje_object_part_text_select_none(wd->ent, "elm.text");
3481 elm_entry_select_all(Evas_Object *obj)
3483 ELM_CHECK_WIDTYPE(obj, widtype);
3484 Widget_Data *wd = elm_widget_data_get(obj);
3485 if ((!wd) || (wd->password)) return;
3488 wd->selmode = EINA_FALSE;
3489 if (!_elm_config->desktop_entry)
3490 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3491 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3493 wd->have_selection = EINA_TRUE;
3494 edje_object_part_text_select_all(wd->ent, "elm.text");
3498 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3500 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3501 Widget_Data *wd = elm_widget_data_get(obj);
3502 if (!wd) return EINA_FALSE;
3503 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3508 elm_entry_cursor_next(Evas_Object *obj)
3510 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3511 Widget_Data *wd = elm_widget_data_get(obj);
3512 if (!wd) return EINA_FALSE;
3513 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3517 elm_entry_cursor_prev(Evas_Object *obj)
3519 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3520 Widget_Data *wd = elm_widget_data_get(obj);
3521 if (!wd) return EINA_FALSE;
3522 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3526 elm_entry_cursor_up(Evas_Object *obj)
3528 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3529 Widget_Data *wd = elm_widget_data_get(obj);
3530 if (!wd) return EINA_FALSE;
3531 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3535 elm_entry_cursor_down(Evas_Object *obj)
3537 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3538 Widget_Data *wd = elm_widget_data_get(obj);
3539 if (!wd) return EINA_FALSE;
3540 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3544 elm_entry_cursor_begin_set(Evas_Object *obj)
3546 ELM_CHECK_WIDTYPE(obj, widtype);
3547 Widget_Data *wd = elm_widget_data_get(obj);
3549 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3553 elm_entry_cursor_end_set(Evas_Object *obj)
3555 ELM_CHECK_WIDTYPE(obj, widtype);
3556 Widget_Data *wd = elm_widget_data_get(obj);
3558 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3562 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3564 ELM_CHECK_WIDTYPE(obj, widtype);
3565 Widget_Data *wd = elm_widget_data_get(obj);
3567 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3571 elm_entry_cursor_line_end_set(Evas_Object *obj)
3573 ELM_CHECK_WIDTYPE(obj, widtype);
3574 Widget_Data *wd = elm_widget_data_get(obj);
3576 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3580 elm_entry_cursor_selection_begin(Evas_Object *obj)
3582 ELM_CHECK_WIDTYPE(obj, widtype);
3583 Widget_Data *wd = elm_widget_data_get(obj);
3585 edje_object_part_text_select_begin(wd->ent, "elm.text");
3589 elm_entry_cursor_selection_end(Evas_Object *obj)
3591 ELM_CHECK_WIDTYPE(obj, widtype);
3592 Widget_Data *wd = elm_widget_data_get(obj);
3594 edje_object_part_text_select_extend(wd->ent, "elm.text");
3598 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3600 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3601 Widget_Data *wd = elm_widget_data_get(obj);
3602 if (!wd) return EINA_FALSE;
3603 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3607 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3609 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3610 Widget_Data *wd = elm_widget_data_get(obj);
3611 if (!wd) return EINA_FALSE;
3612 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3616 elm_entry_cursor_content_get(const Evas_Object *obj)
3618 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3619 Widget_Data *wd = elm_widget_data_get(obj);
3620 if (!wd) return NULL;
3621 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3625 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3627 ELM_CHECK_WIDTYPE(obj, widtype);
3628 Widget_Data *wd = elm_widget_data_get(obj);
3630 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3631 edje_object_message_signal_process(wd->ent);
3635 elm_entry_cursor_pos_get(const Evas_Object *obj)
3637 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3638 Widget_Data *wd = elm_widget_data_get(obj);
3640 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3644 elm_entry_selection_cut(Evas_Object *obj)
3646 ELM_CHECK_WIDTYPE(obj, widtype);
3647 Widget_Data *wd = elm_widget_data_get(obj);
3648 if ((!wd) || (wd->password)) return;
3649 _cut(obj, NULL, NULL);
3653 elm_entry_selection_copy(Evas_Object *obj)
3655 ELM_CHECK_WIDTYPE(obj, widtype);
3656 Widget_Data *wd = elm_widget_data_get(obj);
3657 if ((!wd) || (wd->password)) return;
3658 _copy(obj, NULL, NULL);
3662 elm_entry_selection_paste(Evas_Object *obj)
3664 ELM_CHECK_WIDTYPE(obj, widtype);
3665 Widget_Data *wd = elm_widget_data_get(obj);
3666 if ((!wd) || (wd->password)) return;
3667 _paste(obj, NULL, NULL);
3671 elm_entry_context_menu_clear(Evas_Object *obj)
3673 ELM_CHECK_WIDTYPE(obj, widtype);
3674 Widget_Data *wd = elm_widget_data_get(obj);
3675 Elm_Entry_Context_Menu_Item *it;
3677 EINA_LIST_FREE(wd->items, it)
3679 eina_stringshare_del(it->label);
3680 eina_stringshare_del(it->icon_file);
3681 eina_stringshare_del(it->icon_group);
3687 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)
3689 ELM_CHECK_WIDTYPE(obj, widtype);
3690 Widget_Data *wd = elm_widget_data_get(obj);
3691 Elm_Entry_Context_Menu_Item *it;
3693 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3695 wd->items = eina_list_append(wd->items, it);
3697 it->label = eina_stringshare_add(label);
3698 it->icon_file = eina_stringshare_add(icon_file);
3699 it->icon_type = icon_type;
3701 it->data = (void *)data;
3705 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3707 ELM_CHECK_WIDTYPE(obj, widtype);
3708 Widget_Data *wd = elm_widget_data_get(obj);
3710 if (wd->context_menu == !disabled) return;
3711 wd->context_menu = !disabled;
3713 if (!_elm_config->desktop_entry) // TIZEN ONLY : commit ?
3714 edje_object_part_text_copy_paste_disabled_set(wd->ent, "elm.text", disabled);
3718 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3720 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3721 Widget_Data *wd = elm_widget_data_get(obj);
3722 if (!wd) return EINA_FALSE;
3723 return !wd->context_menu;
3727 elm_entry_item_provider_append(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3729 ELM_CHECK_WIDTYPE(obj, widtype);
3730 Widget_Data *wd = elm_widget_data_get(obj);
3732 EINA_SAFETY_ON_NULL_RETURN(func);
3733 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3737 wd->item_providers = eina_list_append(wd->item_providers, ip);
3741 elm_entry_item_provider_prepend(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3743 ELM_CHECK_WIDTYPE(obj, widtype);
3744 Widget_Data *wd = elm_widget_data_get(obj);
3746 EINA_SAFETY_ON_NULL_RETURN(func);
3747 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3751 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3755 elm_entry_item_provider_remove(Evas_Object *obj, Elm_Entry_Item_Provider_Cb func, void *data)
3757 ELM_CHECK_WIDTYPE(obj, widtype);
3758 Widget_Data *wd = elm_widget_data_get(obj);
3760 Elm_Entry_Item_Provider *ip;
3762 EINA_SAFETY_ON_NULL_RETURN(func);
3763 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3765 if ((ip->func == func) && ((!data) || (ip->data == data)))
3767 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3775 elm_entry_markup_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3778 Elm_Entry_Markup_Filter *tf;
3779 ELM_CHECK_WIDTYPE(obj, widtype);
3781 wd = elm_widget_data_get(obj);
3783 EINA_SAFETY_ON_NULL_RETURN(func);
3785 tf = _filter_new(func, data);
3788 wd->markup_filters = eina_list_append(wd->markup_filters, tf);
3792 elm_entry_markup_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3795 Elm_Entry_Markup_Filter *tf;
3796 ELM_CHECK_WIDTYPE(obj, widtype);
3798 wd = elm_widget_data_get(obj);
3800 EINA_SAFETY_ON_NULL_RETURN(func);
3802 tf = _filter_new(func, data);
3805 wd->markup_filters = eina_list_prepend(wd->markup_filters, tf);
3809 elm_entry_markup_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
3813 Elm_Entry_Markup_Filter *tf;
3814 ELM_CHECK_WIDTYPE(obj, widtype);
3816 wd = elm_widget_data_get(obj);
3818 EINA_SAFETY_ON_NULL_RETURN(func);
3820 EINA_LIST_FOREACH(wd->markup_filters, l, tf)
3822 if ((tf->func == func) && ((!data) || (tf->data == data)))
3824 wd->markup_filters = eina_list_remove_list(wd->markup_filters, l);
3832 elm_entry_markup_to_utf8(const char *s)
3834 char *ss = _elm_util_mkup_to_text(s);
3835 if (!ss) ss = strdup("");
3840 elm_entry_utf8_to_markup(const char *s)
3842 char *ss = _elm_util_text_to_mkup(s);
3843 if (!ss) ss = strdup("");
3848 _text_get(const Evas_Object *obj)
3850 return elm_object_text_get(obj);
3854 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3856 Elm_Entry_Filter_Limit_Size *lim = data;
3857 char *current, *utfstr;
3859 const char *(*text_get)(const Evas_Object *);
3861 EINA_SAFETY_ON_NULL_RETURN(data);
3862 EINA_SAFETY_ON_NULL_RETURN(entry);
3863 EINA_SAFETY_ON_NULL_RETURN(text);
3865 /* hack. I don't want to copy the entire function to work with
3867 text_get = _text_get;
3869 current = elm_entry_markup_to_utf8(text_get(entry));
3870 utfstr = elm_entry_markup_to_utf8(*text);
3872 if (lim->max_char_count > 0)
3874 len = evas_string_char_len_get(current);
3875 newlen = evas_string_char_len_get(utfstr);
3876 if ((len >= lim->max_char_count) && (newlen > 0))
3878 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3885 if ((len + newlen) > lim->max_char_count)
3886 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3888 else if (lim->max_byte_count > 0)
3890 len = strlen(current);
3891 newlen = strlen(utfstr);
3892 if ((len >= lim->max_byte_count) && (newlen > 0))
3894 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3901 if ((len + newlen) > lim->max_byte_count)
3902 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3909 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3911 Elm_Entry_Filter_Accept_Set *as = data;
3915 int read_idx, last_read_idx = 0, read_char;
3917 EINA_SAFETY_ON_NULL_RETURN(data);
3918 EINA_SAFETY_ON_NULL_RETURN(text);
3920 if ((!as->accepted) && (!as->rejected))
3926 goes_in = EINA_TRUE;
3931 goes_in = EINA_FALSE;
3935 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3938 int cmp_idx, cmp_char;
3939 Eina_Bool in_set = EINA_FALSE;
3941 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3944 if (read_char == cmp_char)
3949 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3951 if (in_set == goes_in)
3953 int size = read_idx - last_read_idx;
3954 const char *src = (*text) + last_read_idx;
3956 memcpy(insert, *text + last_read_idx, size);
3959 last_read_idx = read_idx;
3960 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3966 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3968 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3969 Widget_Data *wd = elm_widget_data_get(obj);
3970 if (!wd) return EINA_FALSE;
3971 if (wd->delay_write)
3973 ecore_timer_del(wd->delay_write);
3974 wd->delay_write = NULL;
3976 if (wd->autosave) _save(obj);
3977 eina_stringshare_replace(&wd->file, file);
3978 wd->format = format;
3983 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3985 ELM_CHECK_WIDTYPE(obj, widtype);
3986 Widget_Data *wd = elm_widget_data_get(obj);
3988 if (file) *file = wd->file;
3989 if (format) *format = wd->format;
3993 elm_entry_file_save(Evas_Object *obj)
3995 ELM_CHECK_WIDTYPE(obj, widtype);
3996 Widget_Data *wd = elm_widget_data_get(obj);
3998 if (wd->delay_write)
4000 ecore_timer_del(wd->delay_write);
4001 wd->delay_write = NULL;
4004 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4008 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4010 ELM_CHECK_WIDTYPE(obj, widtype);
4011 Widget_Data *wd = elm_widget_data_get(obj);
4013 wd->autosave = !!autosave;
4017 elm_entry_autosave_get(const Evas_Object *obj)
4019 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4020 Widget_Data *wd = elm_widget_data_get(obj);
4021 if (!wd) return EINA_FALSE;
4022 return wd->autosave;
4025 EINA_DEPRECATED EAPI void
4026 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4028 ELM_CHECK_WIDTYPE(obj, widtype);
4029 Elm_Cnp_Mode cnp_mode = ELM_CNP_MODE_MARKUP;
4031 cnp_mode = ELM_CNP_MODE_NO_IMAGE;
4032 elm_entry_cnp_mode_set(obj, cnp_mode);
4035 EINA_DEPRECATED EAPI Eina_Bool
4036 elm_entry_cnp_textonly_get(const Evas_Object *obj)
4038 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4039 return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
4043 elm_entry_cnp_mode_set(Evas_Object *obj, Elm_Cnp_Mode cnp_mode)
4045 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4046 ELM_CHECK_WIDTYPE(obj, widtype);
4047 Widget_Data *wd = elm_widget_data_get(obj);
4049 if (wd->cnp_mode == cnp_mode) return;
4050 wd->cnp_mode = cnp_mode;
4051 if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
4052 format = ELM_SEL_FORMAT_TEXT;
4053 else if (cnp_mode == ELM_CNP_MODE_MARKUP) format |= ELM_SEL_FORMAT_IMAGE;
4054 #ifdef HAVE_ELEMENTARY_X
4055 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
4060 elm_entry_cnp_mode_get(const Evas_Object *obj)
4062 ELM_CHECK_WIDTYPE(obj, widtype) ELM_CNP_MODE_MARKUP;
4063 Widget_Data *wd = elm_widget_data_get(obj);
4064 if (!wd) return ELM_CNP_MODE_MARKUP;
4065 return wd->cnp_mode;
4069 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
4071 ELM_CHECK_WIDTYPE(obj, widtype);
4072 Widget_Data *wd = elm_widget_data_get(obj);
4073 const Elm_Scroller_Policy map[3] =
4075 ELM_SMART_SCROLLER_POLICY_AUTO,
4076 ELM_SMART_SCROLLER_POLICY_ON,
4077 ELM_SMART_SCROLLER_POLICY_OFF
4081 if (wd->scroll == scroll) return;
4082 wd->scroll = scroll;
4087 wd->scroller = elm_smart_scroller_add(evas_object_evas_get(obj));
4088 elm_widget_resize_object_set(obj, wd->scroller);
4089 elm_smart_scroller_widget_set(wd->scroller, obj);
4090 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
4091 elm_widget_style_get(obj));
4092 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4093 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
4094 evas_object_propagate_events_set(wd->scroller, EINA_TRUE);
4095 evas_object_propagate_events_set(elm_smart_scroller_edje_object_get(wd->scroller),
4098 elm_smart_scroller_bounce_allow_set(wd->scroller, wd->h_bounce, wd->v_bounce);
4099 if (wd->single_line)
4100 elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
4101 ELM_SMART_SCROLLER_POLICY_OFF);
4103 elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]);
4104 elm_widget_sub_object_add(obj, wd->ent);
4105 elm_smart_scroller_child_set(wd->scroller, wd->ent);
4106 evas_object_show(wd->scroller);
4107 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
4113 elm_smart_scroller_child_set(wd->scroller, NULL);
4114 evas_object_smart_member_add(wd->scroller, obj);
4115 elm_widget_sub_object_add(obj, wd->scroller);
4116 evas_object_hide(wd->scroller);
4118 elm_widget_sub_object_del(obj, wd->ent);
4119 elm_widget_resize_object_set(obj, wd->ent);
4120 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
4127 elm_entry_scrollable_get(const Evas_Object *obj)
4129 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4130 Widget_Data *wd = elm_widget_data_get(obj);
4131 if (!wd) return EINA_FALSE;
4136 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
4138 ELM_CHECK_WIDTYPE(obj, widtype);
4139 Widget_Data *wd = elm_widget_data_get(obj);
4143 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4147 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
4149 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
4151 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
4156 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
4158 ELM_CHECK_WIDTYPE(obj, widtype);
4159 Widget_Data *wd = elm_widget_data_get(obj);
4163 edje = elm_smart_scroller_edje_object_get(wd->scroller);
4167 if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
4169 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
4171 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
4176 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4178 ELM_CHECK_WIDTYPE(obj, widtype);
4179 Widget_Data *wd = elm_widget_data_get(obj);
4180 const Elm_Scroller_Policy map[3] =
4182 ELM_SMART_SCROLLER_POLICY_AUTO,
4183 ELM_SMART_SCROLLER_POLICY_ON,
4184 ELM_SMART_SCROLLER_POLICY_OFF
4189 elm_smart_scroller_policy_set(wd->scroller,
4195 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4197 ELM_CHECK_WIDTYPE(obj, widtype);
4198 Widget_Data *wd = elm_widget_data_get(obj);
4200 wd->h_bounce = h_bounce;
4201 wd->v_bounce = v_bounce;
4202 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4206 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4208 ELM_CHECK_WIDTYPE(obj, widtype);
4209 Widget_Data *wd = elm_widget_data_get(obj);
4211 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4215 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4217 ELM_CHECK_WIDTYPE(obj, widtype);
4218 Widget_Data *wd = elm_widget_data_get(obj);
4221 wd->input_panel_layout = layout;
4223 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
4226 EAPI Elm_Input_Panel_Layout
4227 elm_entry_input_panel_layout_get(const Evas_Object *obj)
4229 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
4230 Widget_Data *wd = elm_widget_data_get(obj);
4231 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
4233 return wd->input_panel_layout;
4237 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
4239 ELM_CHECK_WIDTYPE(obj, widtype);
4240 Widget_Data *wd = elm_widget_data_get(obj);
4243 wd->autocapital_type = autocapital_type;
4244 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
4247 EAPI Elm_Autocapital_Type
4248 elm_entry_autocapital_type_get(const Evas_Object *obj)
4250 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
4251 Widget_Data *wd = elm_widget_data_get(obj);
4252 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
4254 return wd->autocapital_type;
4258 elm_entry_prediction_allow_set(Evas_Object *obj, Eina_Bool prediction)
4260 ELM_CHECK_WIDTYPE(obj, widtype);
4261 Widget_Data *wd = elm_widget_data_get(obj);
4264 wd->prediction_allow = prediction;
4265 edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", prediction);
4269 elm_entry_prediction_allow_get(const Evas_Object *obj)
4271 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
4272 Widget_Data *wd = elm_widget_data_get(obj);
4273 if (!wd) return EINA_TRUE;
4275 return wd->prediction_allow;
4279 elm_entry_imf_context_reset(Evas_Object *obj)
4281 ELM_CHECK_WIDTYPE(obj, widtype);
4282 Widget_Data *wd = elm_widget_data_get(obj);
4285 edje_object_part_text_imf_context_reset(wd->ent, "elm.text");
4289 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4291 ELM_CHECK_WIDTYPE(obj, widtype);
4292 Widget_Data *wd = elm_widget_data_get(obj);
4295 wd->input_panel_enable = enabled;
4296 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4300 elm_entry_input_panel_enabled_get(const Evas_Object *obj)
4302 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
4303 Widget_Data *wd = elm_widget_data_get(obj);
4304 if (!wd) return EINA_TRUE;
4306 return wd->input_panel_enable;
4310 elm_entry_input_panel_show(Evas_Object *obj)
4312 ELM_CHECK_WIDTYPE(obj, widtype);
4313 Widget_Data *wd = elm_widget_data_get(obj);
4316 edje_object_part_text_input_panel_show(wd->ent, "elm.text");
4320 elm_entry_input_panel_hide(Evas_Object *obj)
4322 ELM_CHECK_WIDTYPE(obj, widtype);
4323 Widget_Data *wd = elm_widget_data_get(obj);
4326 edje_object_part_text_input_panel_hide(wd->ent, "elm.text");
4330 elm_entry_input_panel_language_set(Evas_Object *obj, Elm_Input_Panel_Lang lang)
4332 ELM_CHECK_WIDTYPE(obj, widtype);
4333 Widget_Data *wd = elm_widget_data_get(obj);
4336 wd->input_panel_lang = lang;
4337 edje_object_part_text_input_panel_language_set(wd->ent, "elm.text", lang);
4340 EAPI Elm_Input_Panel_Lang
4341 elm_entry_input_panel_language_get(const Evas_Object *obj)
4343 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LANG_AUTOMATIC;
4344 Widget_Data *wd = elm_widget_data_get(obj);
4345 if (!wd) return ELM_INPUT_PANEL_LANG_AUTOMATIC;
4347 return wd->input_panel_lang;
4351 elm_entry_input_panel_imdata_set(Evas_Object *obj, const void *data, int len)
4353 ELM_CHECK_WIDTYPE(obj, widtype);
4354 Widget_Data *wd = elm_widget_data_get(obj);
4357 if (wd->input_panel_imdata)
4358 free(wd->input_panel_imdata);
4360 wd->input_panel_imdata = calloc(1, len);
4361 wd->input_panel_imdata_len = len;
4362 memcpy(wd->input_panel_imdata, data, len);
4364 edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len);
4368 elm_entry_input_panel_imdata_get(const Evas_Object *obj, void *data, int *len)
4370 ELM_CHECK_WIDTYPE(obj, widtype);
4371 Widget_Data *wd = elm_widget_data_get(obj);
4374 edje_object_part_text_input_panel_imdata_get(wd->ent, "elm.text", data, len);
4378 elm_entry_input_panel_return_key_type_set(Evas_Object *obj, Elm_Input_Panel_Return_Key_Type return_key_type)
4380 ELM_CHECK_WIDTYPE(obj, widtype);
4381 Widget_Data *wd = elm_widget_data_get(obj);
4384 wd->input_panel_return_key_type = return_key_type;
4386 edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", return_key_type);
4389 EAPI Elm_Input_Panel_Return_Key_Type
4390 elm_entry_input_panel_return_key_type_get(const Evas_Object *obj)
4392 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4393 Widget_Data *wd = elm_widget_data_get(obj);
4394 if (!wd) return ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4396 return wd->input_panel_return_key_type;
4400 elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4402 ELM_CHECK_WIDTYPE(obj, widtype);
4403 Widget_Data *wd = elm_widget_data_get(obj);
4406 wd->input_panel_return_key_disabled = disabled;
4408 edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", disabled);
4412 elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
4414 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4415 Widget_Data *wd = elm_widget_data_get(obj);
4416 if (!wd) return EINA_FALSE;
4418 return wd->input_panel_return_key_disabled;
4422 elm_entry_input_panel_return_key_autoenabled_set(Evas_Object *obj, Eina_Bool enabled)
4424 ELM_CHECK_WIDTYPE(obj, widtype);
4425 Widget_Data *wd = elm_widget_data_get(obj);
4428 wd->autoreturnkey = enabled;
4429 _check_enable_return_key(obj);
4433 elm_entry_imf_context_get(Evas_Object *obj)
4435 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4436 Widget_Data *wd = elm_widget_data_get(obj);
4437 if (!wd) return NULL;
4439 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4442 /* START - ANCHOR HOVER */
4444 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
4446 Widget_Data *wd = elm_widget_data_get(data);
4448 wd->anchor_hover.hover_parent = NULL;
4452 _anchor_hover_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
4454 Widget_Data *wd = elm_widget_data_get(data);
4456 if (wd->anchor_hover.pop) evas_object_del(wd->anchor_hover.pop);
4457 wd->anchor_hover.pop = NULL;
4458 evas_object_event_callback_del_full(wd->anchor_hover.hover, EVAS_CALLBACK_DEL,
4459 _anchor_hover_del, obj);
4463 elm_entry_anchor_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
4465 ELM_CHECK_WIDTYPE(obj, widtype);
4466 Widget_Data *wd = elm_widget_data_get(obj);
4468 if (wd->anchor_hover.hover_parent)
4469 evas_object_event_callback_del_full(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
4470 wd->anchor_hover.hover_parent = parent;
4471 if (wd->anchor_hover.hover_parent)
4472 evas_object_event_callback_add(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
4476 elm_entry_anchor_hover_parent_get(const Evas_Object *obj)
4478 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4479 Widget_Data *wd = elm_widget_data_get(obj);
4480 if (!wd) return NULL;
4481 return wd->anchor_hover.hover_parent;
4485 elm_entry_anchor_hover_style_set(Evas_Object *obj, const char *style)
4487 ELM_CHECK_WIDTYPE(obj, widtype);
4488 Widget_Data *wd = elm_widget_data_get(obj);
4490 eina_stringshare_replace(&wd->anchor_hover.hover_style, style);
4494 elm_entry_anchor_hover_style_get(const Evas_Object *obj)
4496 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4497 Widget_Data *wd = elm_widget_data_get(obj);
4498 if (!wd) return NULL;
4499 return wd->anchor_hover.hover_style;
4503 elm_entry_anchor_hover_end(Evas_Object *obj)
4505 ELM_CHECK_WIDTYPE(obj, widtype);
4506 Widget_Data *wd = elm_widget_data_get(obj);
4508 if (wd->anchor_hover.hover) evas_object_del(wd->anchor_hover.hover);
4509 if (wd->anchor_hover.pop) evas_object_del(wd->anchor_hover.pop);
4510 wd->anchor_hover.hover = NULL;
4511 wd->anchor_hover.pop = NULL;
4516 _anchor_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
4518 elm_entry_anchor_hover_end(data);
4522 _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info)
4524 Widget_Data *wd = elm_widget_data_get(obj);
4525 Elm_Entry_Anchor_Info *info = event_info;
4526 Evas_Object *hover_parent;
4527 Elm_Entry_Anchor_Hover_Info ei;
4528 Evas_Coord x, w, y, h, px, py;
4531 ei.anchor_info = event_info;
4533 wd->anchor_hover.pop = elm_icon_add(obj);
4534 evas_object_move(wd->anchor_hover.pop, info->x, info->y);
4535 evas_object_resize(wd->anchor_hover.pop, info->w, info->h);
4537 wd->anchor_hover.hover = elm_hover_add(obj);
4538 evas_object_event_callback_add(wd->anchor_hover.hover, EVAS_CALLBACK_DEL,
4539 _anchor_hover_del, obj);
4540 elm_widget_mirrored_set(wd->anchor_hover.hover, elm_widget_mirrored_get(obj));
4541 if (wd->anchor_hover.hover_style)
4542 elm_object_style_set(wd->anchor_hover.hover, wd->anchor_hover.hover_style);
4544 hover_parent = wd->anchor_hover.hover_parent;
4545 if (!hover_parent) hover_parent = obj;
4546 elm_hover_parent_set(wd->anchor_hover.hover, hover_parent);
4547 elm_hover_target_set(wd->anchor_hover.hover, wd->anchor_hover.pop);
4548 ei.hover = wd->anchor_hover.hover;
4550 evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
4551 ei.hover_parent.x = x;
4552 ei.hover_parent.y = y;
4553 ei.hover_parent.w = w;
4554 ei.hover_parent.h = h;
4555 px = info->x + (info->w / 2);
4556 py = info->y + (info->h / 2);
4558 if (px < (x + (w / 3))) ei.hover_left = 0;
4560 if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
4562 if (py < (y + (h / 3))) ei.hover_top = 0;
4563 ei.hover_bottom = 1;
4564 if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
4566 if (elm_widget_mirrored_get(wd->anchor_hover.hover))
4567 { /* Swap right and left because they switch sides in RTL */
4568 Eina_Bool tmp = ei.hover_left;
4569 ei.hover_left = ei.hover_right;
4570 ei.hover_right = tmp;
4573 evas_object_smart_callback_call(data, SIG_ANCHOR_HOVER_OPENED, &ei);
4574 evas_object_smart_callback_add(wd->anchor_hover.hover, "clicked", _anchor_hover_clicked, data);
4576 /* FIXME: Should just check if there's any callback registered to the smart
4578 * This is used to determine if anyone cares about the hover or not. */
4579 if (!elm_object_part_content_get(wd->anchor_hover.hover, "middle") &&
4580 !elm_object_part_content_get(wd->anchor_hover.hover, "left") &&
4581 !elm_object_part_content_get(wd->anchor_hover.hover, "right") &&
4582 !elm_object_part_content_get(wd->anchor_hover.hover, "top") &&
4583 !elm_object_part_content_get(wd->anchor_hover.hover, "bottom"))
4585 evas_object_del(wd->anchor_hover.hover);
4586 wd->anchor_hover.hover = NULL;
4589 evas_object_show(wd->anchor_hover.hover);
4591 /* END - ANCHOR HOVER */
4594 elm_entry_magnifier_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4596 ELM_CHECK_WIDTYPE(obj, widtype);
4597 Widget_Data *wd = elm_widget_data_get(obj);
4599 if (wd->magnifier_enabled == !disabled) return;
4600 wd->magnifier_enabled = !disabled;
4604 elm_entry_magnifier_disabled_get(const Evas_Object *obj)
4606 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4607 Widget_Data *wd = elm_widget_data_get(obj);
4608 if (!wd) return EINA_FALSE;
4609 return !wd->magnifier_enabled;
4613 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4615 ELM_CHECK_WIDTYPE(obj, widtype);
4616 Widget_Data *wd = elm_widget_data_get(obj);
4619 wd->mgf_type = type;
4620 _magnifier_create(obj);