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_Text_Filter Elm_Entry_Text_Filter;
23 Evas_Object *ent, *scroller, *end, *icon;
25 Evas_Object *hoversel;
29 Evas_Object *mgf_proxy;
30 Evas_Object *mgf_clip;
32 Evas_Coord mgf_height;
35 Ecore_Job *deferred_recalc_job;
36 Ecore_Event_Handler *sel_notify_handler;
37 Ecore_Event_Handler *sel_clear_handler;
38 Ecore_Timer *delay_write;
39 /* for deferred appending */
40 Ecore_Idler *append_text_idler;
41 char *append_text_left;
42 int append_text_position;
44 /* Only for clipboard */
47 const char *password_text;
50 Elm_Text_Format format;
51 Evas_Coord lastw, entmw, entmh;
52 Evas_Coord downx, downy;
53 Evas_Coord cx, cy, cw, ch;
55 Eina_List *item_providers;
56 Eina_List *text_filters;
57 Eina_List *match_list;
58 Ecore_Job *matchlist_job;
59 int matchlist_threshold;
61 Mod_Api *api; // module api if supplied
63 Elm_Scroller_Policy policy_h, policy_v;
64 Elm_Wrap_Type linewrap;
65 Elm_Input_Panel_Layout input_panel_layout;
66 Elm_Autocapital_Type autocapital_type;
67 Eina_Bool changed : 1;
68 Eina_Bool single_line : 1;
69 Eina_Bool password : 1;
70 Eina_Bool editable : 1;
71 Eina_Bool selection_asked : 1;
72 Eina_Bool have_selection : 1;
73 Eina_Bool selmode : 1;
74 Eina_Bool deferred_cur : 1;
75 Eina_Bool cur_changed : 1;
76 Eina_Bool disabled : 1;
77 Eina_Bool double_clicked : 1;
78 Eina_Bool long_pressed : 1;
79 Eina_Bool context_menu : 1;
80 Eina_Bool drag_selection_asked : 1;
81 Eina_Bool bgcolor : 1;
82 Eina_Bool can_write : 1;
83 Eina_Bool autosave : 1;
84 Eina_Bool textonly : 1;
85 Eina_Bool usedown : 1;
87 Eina_Bool input_panel_enable : 1;
88 Eina_Bool autoreturnkey : 1;
89 Eina_Bool autoperiod : 1;
90 Eina_Bool matchlist_list_clicked : 1;
91 Eina_Bool matchlist_case_sensitive : 1;
94 struct _Elm_Entry_Context_Menu_Item
98 const char *icon_file;
99 const char *icon_group;
100 Elm_Icon_Type icon_type;
105 struct _Elm_Entry_Item_Provider
107 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
111 struct _Elm_Entry_Text_Filter
113 void (*func) (void *data, Evas_Object *entry, char **text);
117 typedef enum _Length_Unit
124 static const char *widtype = NULL;
126 static Evas_Object *cnpwidgetdata = NULL;
129 #ifdef HAVE_ELEMENTARY_X
130 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
132 static void _del_hook(Evas_Object *obj);
133 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
134 static void _theme_hook(Evas_Object *obj);
135 static void _disable_hook(Evas_Object *obj);
136 static void _sizing_eval(Evas_Object *obj);
137 static void _on_focus_hook(void *data, Evas_Object *obj);
138 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
139 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
140 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
141 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
142 static const char *_getbase(Evas_Object *obj);
143 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
144 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
145 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
146 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
147 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
148 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
149 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
150 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
151 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
152 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
153 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
154 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
155 static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit);
156 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
157 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
158 static int _entry_length_get(Evas_Object *obj);
159 static void _magnifier_create(void *data);
160 static void _magnifier_show(void *data);
161 static void _magnifier_hide(void *data);
162 static void _magnifier_move(void *data);
163 static Evas_Coord_Rectangle _layout_region_get(Evas_Object *data);
164 static Evas_Coord_Rectangle _viewport_region_get(Evas_Object *data);
166 static const char SIG_CHANGED[] = "changed";
167 static const char SIG_ACTIVATED[] = "activated";
168 static const char SIG_PRESS[] = "press";
169 static const char SIG_LONGPRESSED[] = "longpressed";
170 static const char SIG_CLICKED[] = "clicked";
171 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
172 static const char SIG_FOCUSED[] = "focused";
173 static const char SIG_UNFOCUSED[] = "unfocused";
174 static const char SIG_SELECTION_PASTE[] = "selection,paste";
175 static const char SIG_SELECTION_COPY[] = "selection,copy";
176 static const char SIG_SELECTION_CUT[] = "selection,cut";
177 static const char SIG_SELECTION_START[] = "selection,start";
178 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
179 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
180 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
181 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
182 static const char SIG_MATCHLIST_CLICKED[] = "matchlist,clicked";
183 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
184 static const Evas_Smart_Cb_Description _signals[] = {
188 {SIG_LONGPRESSED, ""},
190 {SIG_CLICKED_DOUBLE, ""},
193 {SIG_SELECTION_PASTE, ""},
194 {SIG_SELECTION_COPY, ""},
195 {SIG_SELECTION_CUT, ""},
196 {SIG_SELECTION_START, ""},
197 {SIG_SELECTION_CHANGED, ""},
198 {SIG_SELECTION_CLEARED, ""},
199 {SIG_CURSOR_CHANGED, ""},
200 {SIG_ANCHOR_CLICKED, ""},
201 {SIG_PREEDIT_CHANGED, ""},
202 {SIG_MATCHLIST_CLICKED, ""},
206 typedef enum _Elm_Entry_Magnifier_Type
208 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
209 _ENTRY_MAGNIFIER_FILLWIDTH,
210 _ENTRY_MAGNIFIER_CIRCULAR,
211 } Elm_Entry_Magnifier_Type;
214 static Eina_List *entries = NULL;
218 void (*obj_hook) (Evas_Object *obj);
219 void (*obj_unhook) (Evas_Object *obj);
220 void (*obj_longpress) (Evas_Object *obj);
221 void (*obj_hidemenu) (Evas_Object *obj);
222 void (*obj_mouseup) (Evas_Object *obj);
226 _module(Evas_Object *obj __UNUSED__)
228 static Elm_Module *m = NULL;
229 if (m) goto ok; // already found - just use
230 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
232 m->api = malloc(sizeof(Mod_Api));
233 if (!m->api) return NULL;
234 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
235 _elm_module_symbol_get(m, "obj_hook");
236 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
237 _elm_module_symbol_get(m, "obj_unhook");
238 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
239 _elm_module_symbol_get(m, "obj_longpress");
240 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
241 _elm_module_symbol_get(m, "obj_hidemenu");
242 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
243 _elm_module_symbol_get(m, "obj_mouseup");
244 ok: // ok - return api
249 _buf_append(char *buf, const char *str, int *len, int *alloc)
251 int len2 = strlen(str);
252 if ((*len + len2) >= *alloc)
254 char *buf2 = realloc(buf, *alloc + len2 + 512);
255 if (!buf2) return NULL;
257 *alloc += (512 + len2);
259 strcpy(buf + *len, str);
265 _load_file(const char *file)
269 int alloc = 0, len = 0;
270 char *text = NULL, buf[16384 + 1];
272 f = fopen(file, "rb");
274 while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
278 tmp_text = _buf_append(text, buf, &len, &alloc);
279 if (!tmp_text) break;
287 _load_plain(const char *file)
291 text = _load_file(file);
296 text2 = elm_entry_utf8_to_markup(text);
304 _load(Evas_Object *obj)
306 Widget_Data *wd = elm_widget_data_get(obj);
311 elm_entry_entry_set(obj, "");
316 case ELM_TEXT_FORMAT_PLAIN_UTF8:
317 text = _load_plain(wd->file);
319 case ELM_TEXT_FORMAT_MARKUP_UTF8:
320 text = _load_file(wd->file);
328 elm_entry_entry_set(obj, text);
332 elm_entry_entry_set(obj, "");
336 _save_markup_utf8(const char *file, const char *text)
340 if ((!text) || (!text[0]))
342 ecore_file_unlink(file);
345 f = fopen(file, "wb");
348 // FIXME: report a write error
351 fputs(text, f); // FIXME: catch error
356 _save_plain_utf8(const char *file, const char *text)
360 text2 = elm_entry_markup_to_utf8(text);
363 _save_markup_utf8(file, text2);
368 _save(Evas_Object *obj)
370 Widget_Data *wd = elm_widget_data_get(obj);
372 if (!wd->file) return;
375 case ELM_TEXT_FORMAT_PLAIN_UTF8:
376 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
378 case ELM_TEXT_FORMAT_MARKUP_UTF8:
379 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
387 _delay_write(void *data)
389 Widget_Data *wd = elm_widget_data_get(data);
390 if (!wd) return ECORE_CALLBACK_CANCEL;
392 wd->delay_write = NULL;
393 return ECORE_CALLBACK_CANCEL;
396 static Elm_Entry_Text_Filter *
397 _filter_new(void (*func) (void *data, Evas_Object *entry, char **text), void *data)
399 Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
400 if (!tf) return NULL;
403 if (func == elm_entry_filter_limit_size)
405 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
412 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
418 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
421 else if (func == elm_entry_filter_accept_set)
423 Elm_Entry_Filter_Accept_Set *as = data, *as2;
430 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
437 as2->accepted = eina_stringshare_add(as->accepted);
439 as2->accepted = NULL;
441 as2->rejected = eina_stringshare_add(as->rejected);
443 as2->rejected = NULL;
452 _filter_free(Elm_Entry_Text_Filter *tf)
454 if (tf->func == elm_entry_filter_limit_size)
456 Elm_Entry_Filter_Limit_Size *lim = tf->data;
459 else if (tf->func == elm_entry_filter_accept_set)
461 Elm_Entry_Filter_Accept_Set *as = tf->data;
464 if (as->accepted) eina_stringshare_del(as->accepted);
465 if (as->rejected) eina_stringshare_del(as->rejected);
473 _del_pre_hook(Evas_Object *obj)
475 Widget_Data *wd = elm_widget_data_get(obj);
479 ecore_timer_del(wd->delay_write);
480 wd->delay_write = NULL;
481 if (wd->autosave) _save(obj);
486 _del_hook(Evas_Object *obj)
488 Widget_Data *wd = elm_widget_data_get(obj);
489 Elm_Entry_Context_Menu_Item *it;
490 Elm_Entry_Item_Provider *ip;
491 Elm_Entry_Text_Filter *tf;
493 if (wd->file) eina_stringshare_del(wd->file);
495 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
496 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
498 entries = eina_list_remove(entries, obj);
499 #ifdef HAVE_ELEMENTARY_X
500 if (wd->sel_notify_handler)
501 ecore_event_handler_del(wd->sel_notify_handler);
502 if (wd->sel_clear_handler)
503 ecore_event_handler_del(wd->sel_clear_handler);
505 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
506 if (wd->text) eina_stringshare_del(wd->text);
507 if (wd->password_text) eina_stringshare_del(wd->password_text);
508 if (wd->bg) evas_object_del(wd->bg);
509 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
510 if (wd->append_text_idler)
512 ecore_idler_del(wd->append_text_idler);
513 free(wd->append_text_left);
514 wd->append_text_left = NULL;
515 wd->append_text_idler = NULL;
517 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
518 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
519 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
520 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
522 EINA_LIST_FREE(wd->items, it)
524 eina_stringshare_del(it->label);
525 eina_stringshare_del(it->icon_file);
526 eina_stringshare_del(it->icon_group);
529 EINA_LIST_FREE(wd->item_providers, ip)
533 EINA_LIST_FREE(wd->text_filters, tf)
537 if (wd->delay_write) ecore_timer_del(wd->delay_write);
542 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
544 Widget_Data *wd = elm_widget_data_get(obj);
545 edje_object_mirrored_set(wd->ent, rtl);
549 _theme_hook(Evas_Object *obj)
551 Widget_Data *wd = elm_widget_data_get(obj);
553 _elm_widget_mirrored_reload(obj);
554 _mirrored_set(obj, elm_widget_mirrored_get(obj));
556 t = eina_stringshare_add(elm_entry_entry_get(obj));
557 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
558 if (_elm_config->desktop_entry)
559 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
560 elm_entry_entry_set(obj, t);
561 eina_stringshare_del(t);
562 if (elm_widget_disabled_get(obj))
563 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
564 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", wd->input_panel_layout);
565 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
566 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
567 elm_entry_cursor_pos_set(obj, wd->cursor_pos);
568 if (elm_widget_focus_get(obj))
569 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
570 edje_object_message_signal_process(wd->ent);
571 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
572 elm_smart_scroller_mirrored_set(wd->scroller, elm_widget_mirrored_get(obj));
573 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
574 elm_widget_style_get(obj));
580 edj = elm_smart_scroller_edje_object_get(wd->scroller);
581 str = edje_object_data_get(edj, "focus_highlight");
582 if ((str) && (!strcmp(str, "on")))
583 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
585 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
591 _disable_hook(Evas_Object *obj)
593 Widget_Data *wd = elm_widget_data_get(obj);
595 if (elm_widget_disabled_get(obj))
597 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
598 wd->disabled = EINA_TRUE;
602 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
603 wd->disabled = EINA_FALSE;
608 _recalc_cursor_geometry(Evas_Object *obj)
610 Widget_Data *wd = elm_widget_data_get(obj);
612 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
613 if (!elm_object_focus_get(obj)) return;
614 if (!wd->deferred_recalc_job)
616 Evas_Coord cx, cy, cw, ch;
617 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
621 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
622 wd->cur_changed = EINA_FALSE;
626 wd->deferred_cur = EINA_TRUE;
630 _elm_win_recalc_job(void *data)
632 Widget_Data *wd = elm_widget_data_get(data);
633 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
635 wd->deferred_recalc_job = NULL;
637 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
638 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
639 edje_object_size_min_restricted_calc(wd->ent, &fw, &fh, 0, 0);
640 elm_coords_finger_size_adjust(1, &fw, 1, &minh);
643 /* This is a hack to workaround the way min size hints are treated.
644 * If the minimum width is smaller than the restricted width, it means
645 * the mininmum doesn't matter. */
648 Evas_Coord ominw = -1;
649 evas_object_size_hint_min_get(data, &ominw, NULL);
653 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
656 Evas_Coord vmw = 0, vmh = 0;
658 edje_object_size_min_calc
659 (elm_smart_scroller_edje_object_get(wd->scroller),
663 evas_object_size_hint_min_set(data, vmw, minh + vmh);
664 evas_object_size_hint_max_set(data, -1, minh + vmh);
668 evas_object_size_hint_min_set(data, vmw, vmh);
669 evas_object_size_hint_max_set(data, -1, -1);
676 evas_object_size_hint_min_set(data, minw, minh);
677 evas_object_size_hint_max_set(data, -1, minh);
681 evas_object_size_hint_min_set(data, fw, minh);
682 evas_object_size_hint_max_set(data, -1, -1);
686 if ((wd->deferred_cur) && (elm_object_focus_get(data)))
688 Evas_Coord cx, cy, cw, ch;
689 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
693 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
694 wd->cur_changed = EINA_FALSE;
700 _sizing_eval(Evas_Object *obj)
702 Widget_Data *wd = elm_widget_data_get(obj);
703 Evas_Coord minw = -1, minh = -1;
704 Evas_Coord resw, resh;
707 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
710 if ((resw == wd->lastw) && (!wd->changed)) return;
711 wd->changed = EINA_FALSE;
715 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
717 evas_object_resize(wd->scroller, resw, resh);
718 edje_object_size_min_calc
719 (elm_smart_scroller_edje_object_get(wd->scroller),
721 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
722 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, vw, 0);
725 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
727 if ((minw > 0) && (vw < minw)) vw = minw;
728 if (minh > vh) vh = minh;
730 if (wd->single_line) h = vmh + minh;
732 evas_object_resize(wd->ent, vw, vh);
733 evas_object_size_hint_min_get(obj, &w, NULL);
734 evas_object_size_hint_min_set(obj, w, h);
736 evas_object_size_hint_max_set(obj, -1, h);
738 evas_object_size_hint_max_set(obj, -1, -1);
742 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
743 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
748 if (!wd->changed) return;
749 wd->changed = EINA_FALSE;
753 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
755 edje_object_size_min_calc(wd->ent, &minw, &minh);
758 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
760 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
762 if ((minw > 0) && (vw < minw)) vw = minw;
763 if (minh > 0) vh = minh;
765 evas_object_resize(wd->ent, vw, vh);
766 edje_object_size_min_calc
767 (elm_smart_scroller_edje_object_get(wd->scroller),
769 if (wd->single_line) h = vmh + minh;
771 evas_object_size_hint_min_get(obj, &w, NULL);
772 evas_object_size_hint_min_set(obj, w, h);
774 evas_object_size_hint_max_set(obj, -1, h);
776 evas_object_size_hint_max_set(obj, -1, -1);
780 edje_object_size_min_calc(wd->ent, &minw, &minh);
783 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
784 evas_object_size_hint_min_set(obj, minw, minh);
786 evas_object_size_hint_max_set(obj, -1, minh);
788 evas_object_size_hint_max_set(obj, -1, -1);
792 _recalc_cursor_geometry(obj);
796 _check_enable_returnkey(Evas_Object *obj)
798 Widget_Data *wd = elm_widget_data_get(obj);
801 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
804 if (!wd->autoreturnkey) return;
806 if (_entry_length_get(obj) == 0)
808 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
812 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
817 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
819 Widget_Data *wd = elm_widget_data_get(obj);
820 Evas_Object *top = elm_widget_top_get(obj);
822 if (elm_widget_focus_get(obj))
824 printf("[Elm_entry::Focused] obj : %p\n", obj);
825 evas_object_focus_set(wd->ent, EINA_TRUE);
826 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
827 if (top && wd->input_panel_enable)
828 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
829 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
830 _check_enable_returnkey(obj);
831 wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
835 printf("[Elm_entry::Unfocused] obj : %p\n", obj);
836 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
837 evas_object_focus_set(wd->ent, EINA_FALSE);
838 if (top && wd->input_panel_enable)
839 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
840 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
842 if ((wd->api) && (wd->api->obj_hidemenu))
844 wd->api->obj_hidemenu(obj);
851 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
853 Widget_Data *wd = elm_widget_data_get(obj);
855 if ((!wd) || (!content)) return;
859 edje = elm_smart_scroller_edje_object_get(wd->scroller);
860 if (!strcmp(part, "elm.swallow.icon"))
863 evas_object_del(wd->icon);
865 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
867 else if (!strcmp(part, "elm.swallow.end"))
870 evas_object_del(wd->end);
872 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
877 evas_event_freeze(evas_object_evas_get(obj));
878 elm_widget_sub_object_add(obj, content);
879 edje_object_part_swallow(edje, part, content);
881 evas_event_thaw(evas_object_evas_get(obj));
882 evas_event_thaw_eval(evas_object_evas_get(obj));
886 _content_unset_hook(Evas_Object *obj, const char *part)
888 Widget_Data *wd = elm_widget_data_get(obj);
889 Evas_Object *content, *edje;
890 if (!wd) return NULL;
894 edje = elm_smart_scroller_edje_object_get(wd->scroller);
895 if (!strcmp(part, "elm.swallow.icon"))
898 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
900 else if (!strcmp(part, "elm.swallow.end"))
903 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
909 content = edje_object_part_swallow_get(edje, part);
910 edje_object_part_swallow(edje, part, NULL);
911 if (!content) return NULL;
912 evas_event_freeze(evas_object_evas_get(obj));
913 elm_widget_sub_object_del(obj, content);
914 edje_object_part_unswallow(wd->ent, content);
916 evas_event_thaw(evas_object_evas_get(obj));
917 evas_event_thaw_eval(evas_object_evas_get(obj));
923 _content_get_hook(const Evas_Object *obj, const char *part)
925 Widget_Data *wd = elm_widget_data_get(obj);
926 Evas_Object *content = NULL, *edje;
927 if (!wd) return NULL;
931 if (!strcmp(part, "elm.swallow.icon"))
933 if (!strcmp(part, "elm.swallow.end"))
936 edje = elm_smart_scroller_edje_object_get(wd->scroller);
942 content = edje_object_part_swallow_get(edje, part);
947 _translate_hook(Evas_Object *obj)
949 evas_object_smart_callback_call(obj, "language,changed", NULL);
953 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
955 Widget_Data *wd = elm_widget_data_get(obj);
957 edje_object_signal_emit(wd->ent, emission, source);
959 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scroller),
964 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
966 Widget_Data *wd = elm_widget_data_get(obj);
968 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
970 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scroller),
971 emission, source, func_cb, data);
975 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
977 Widget_Data *wd = elm_widget_data_get(obj);
978 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
981 edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scroller),
982 emission, source, func_cb, data);
986 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
988 Widget_Data *wd = elm_widget_data_get(obj);
989 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
993 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
995 Widget_Data *wd = elm_widget_data_get(obj);
997 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1001 _show_region_hook(void *data, Evas_Object *obj)
1003 Widget_Data *wd = elm_widget_data_get(data);
1004 Evas_Coord x, y, w, h;
1006 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1008 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
1012 _sub_del(void *data, Evas_Object *obj, void *event_info)
1014 Widget_Data *wd = data;
1015 Evas_Object *sub = event_info;
1018 edje = elm_smart_scroller_edje_object_get(wd->scroller);
1019 if (sub == wd->icon)
1023 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
1025 else if (sub == wd->end)
1029 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
1035 _hoversel_position(Evas_Object *obj)
1037 Widget_Data *wd = elm_widget_data_get(obj);
1038 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1043 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1052 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1053 &cx, &cy, &cw, &ch);
1054 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
1057 cx += (cw - mw) / 2;
1062 cy += (ch - mh) / 2;
1065 evas_object_move(wd->hoversel, x + cx, y + cy);
1066 evas_object_resize(wd->hoversel, cw, ch);
1070 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1072 Widget_Data *wd = elm_widget_data_get(data);
1074 if (wd->hoversel) _hoversel_position(data);
1076 if (!_elm_config->desktop_entry)
1077 edje_object_part_text_viewport_region_set(wd->ent, "elm.text", _viewport_region_get(data));
1079 if (!_elm_config->desktop_entry)
1080 edje_object_part_text_layout_region_set(wd->ent, "elm.text", _layout_region_get(data));
1084 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1086 Widget_Data *wd = elm_widget_data_get(data);
1093 else if (wd->scroll)
1095 Evas_Coord vw = 0, vh = 0;
1097 elm_smart_scroller_child_viewport_size_get(wd->scroller, &vw, &vh);
1098 if (vw < wd->entmw) vw = wd->entmw;
1099 if (vh < wd->entmh) vh = wd->entmh;
1100 evas_object_resize(wd->ent, vw, vh);
1102 if (wd->hoversel) _hoversel_position(data);
1106 _hover_del(void *data)
1108 Widget_Data *wd = elm_widget_data_get(data);
1113 evas_object_del(wd->hoversel);
1114 wd->hoversel = NULL;
1116 wd->hovdeljob = NULL;
1120 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1122 Widget_Data *wd = elm_widget_data_get(data);
1125 if (wd->hoversel) evas_object_hide(wd->hoversel);
1128 if (!_elm_config->desktop_entry)
1131 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1134 elm_widget_scroll_freeze_pop(data);
1135 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
1136 wd->hovdeljob = ecore_job_add(_hover_del, data);
1140 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1142 Widget_Data *wd = elm_widget_data_get(data);
1144 wd->selmode = EINA_TRUE;
1145 edje_object_part_text_select_none(wd->ent, "elm.text");
1146 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1147 edje_object_part_text_select_all(wd->ent, "elm.text");
1148 elm_object_scroll_freeze_pop(data);
1152 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1154 Widget_Data *wd = elm_widget_data_get(data);
1156 wd->selmode = EINA_TRUE;
1157 edje_object_part_text_select_none(wd->ent, "elm.text");
1158 if (!_elm_config->desktop_entry)
1161 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
1163 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
1164 if (!_elm_config->desktop_entry)
1165 elm_object_scroll_freeze_pop(data);
1166 //elm_widget_scroll_hold_push(data);
1170 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1172 Widget_Data *wd = elm_widget_data_get(data);
1174 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1175 if (wd->sel_notify_handler)
1177 #ifdef HAVE_ELEMENTARY_X
1178 Elm_Sel_Format formats;
1179 wd->selection_asked = EINA_TRUE;
1180 formats = ELM_SEL_FORMAT_MARKUP;
1182 formats |= ELM_SEL_FORMAT_IMAGE;
1183 elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
1189 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
1191 Widget_Data *wd = elm_widget_data_get(obj);
1196 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
1197 sel_str = strdup(sel);
1204 char *startTag = NULL;
1205 char *endTag = NULL;
1207 startTag = strstr(sel_str, "<item");
1209 startTag = strstr(sel_str, "</item");
1211 endTag = strstr(startTag, ">");
1214 if (!endTag || startTag > endTag)
1217 size_t sindex = startTag - sel_str;
1218 size_t eindex = endTag - sel_str + 1;
1220 Eina_Strbuf *buf = eina_strbuf_new();
1223 eina_strbuf_append(buf, sel_str);
1224 eina_strbuf_remove(buf, sindex, eindex);
1225 sel_str = eina_strbuf_string_steal(buf);
1226 eina_strbuf_free(buf);
1230 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str);
1231 if (seltype == ELM_SEL_CLIPBOARD)
1232 eina_stringshare_replace(&wd->cut_sel, sel_str);
1237 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1239 Widget_Data *wd = elm_widget_data_get(data);
1242 wd->selmode = EINA_FALSE;
1243 if (!_elm_config->desktop_entry)
1244 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1245 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1246 if (!_elm_config->desktop_entry)
1247 elm_widget_scroll_hold_pop(data);
1248 _store_selection(ELM_SEL_CLIPBOARD, data);
1249 edje_object_part_text_insert(wd->ent, "elm.text", "");
1250 edje_object_part_text_select_none(wd->ent, "elm.text");
1254 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1256 Widget_Data *wd = elm_widget_data_get(data);
1258 wd->selmode = EINA_TRUE;
1259 if (!_elm_config->desktop_entry)
1261 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1262 elm_widget_scroll_hold_pop(data);
1264 _store_selection(ELM_SEL_CLIPBOARD, data);
1268 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1270 Widget_Data *wd = elm_widget_data_get(data);
1272 wd->selmode = EINA_FALSE;
1273 if (!_elm_config->desktop_entry)
1274 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1275 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
1276 if (!_elm_config->desktop_entry)
1277 elm_widget_scroll_hold_pop(data);
1278 edje_object_part_text_select_none(wd->ent, "elm.text");
1282 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1284 Widget_Data *wd = elm_widget_data_get(data);
1288 #ifdef HAVE_ELEMENTARY_X
1289 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1291 cnpwidgetdata = data;
1292 elm_cbhm_helper_init(obj);
1293 if (elm_entry_cnp_textonly_get(obj))
1294 elm_cbhm_send_raw_data("show0");
1296 elm_cbhm_send_raw_data("show1");
1302 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1304 Widget_Data *wd = elm_widget_data_get(data);
1306 cnpwidgetdata = data;
1312 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1314 Elm_Entry_Context_Menu_Item *it = data;
1315 Evas_Object *obj2 = it->obj;
1316 if (it->func) it->func(it->data, obj2, NULL);
1320 _menu_press(Evas_Object *obj)
1322 Widget_Data *wd = elm_widget_data_get(obj);
1325 const Elm_Entry_Context_Menu_Item *it;
1327 if ((wd->api) && (wd->api->obj_longpress))
1329 wd->api->obj_longpress(obj);
1331 else if (wd->context_menu)
1333 const char *context_menu_orientation;
1335 if (wd->hoversel) evas_object_del(wd->hoversel);
1336 else elm_widget_scroll_freeze_push(obj);
1337 wd->hoversel = elm_hoversel_add(obj);
1338 context_menu_orientation = edje_object_data_get
1339 (wd->ent, "context_menu_orientation");
1340 if ((context_menu_orientation) &&
1341 (!strcmp(context_menu_orientation, "horizontal")))
1342 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
1343 elm_object_style_set(wd->hoversel, "entry");
1344 elm_widget_sub_object_add(obj, wd->hoversel);
1345 elm_object_text_set(wd->hoversel, "Text");
1346 top = elm_widget_top_get(obj);
1347 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
1348 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, obj);
1352 elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1354 if (1) // need way to detect if someone has a selection
1357 elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1361 if ((!wd->password) && (wd->editable))
1362 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1363 _clipboard_menu, obj);
1370 if (wd->have_selection)
1372 elm_hoversel_item_add(wd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1375 elm_hoversel_item_add(wd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1378 elm_hoversel_item_add(wd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1382 elm_hoversel_item_add(wd->hoversel, E_("More"), NULL, ELM_ICON_NONE,
1383 _clipboard_menu, obj);
1387 EINA_LIST_FOREACH(wd->items, l, it)
1389 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
1390 it->icon_type, _item_clicked, it);
1394 _hoversel_position(obj);
1395 evas_object_show(wd->hoversel);
1396 elm_hoversel_hover_begin(wd->hoversel);
1398 if (!_elm_config->desktop_entry)
1400 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
1401 edje_object_part_text_select_abort(wd->ent, "elm.text");
1407 _magnifier_hide(void *data)
1409 Widget_Data *wd = elm_widget_data_get(data);
1412 evas_object_hide(wd->mgf_bg);
1413 evas_object_hide(wd->mgf_clip);
1416 elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
1420 _magnifier_show(void *data)
1422 Widget_Data *wd = elm_widget_data_get(data);
1425 evas_object_show(wd->mgf_bg);
1426 evas_object_show(wd->mgf_clip);
1430 _magnifier_move(void *data)
1432 Widget_Data *wd = elm_widget_data_get(data);
1435 Evas_Coord x, y, w, h;
1436 Evas_Coord cx, cy, cw, ch, ox, oy;
1438 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1442 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1443 elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
1448 evas_object_geometry_get(data, &x, &y, &w, &h);
1452 if ((cy + y) - wd->mgf_height < 0)
1453 oy = -1 * ((cy + y) - wd->mgf_height);
1455 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1456 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height + oy);
1457 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1458 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height + oy);
1462 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);
1466 _magnifier_create(void *data)
1468 Widget_Data *wd = elm_widget_data_get(data);
1469 Evas_Coord x, y, w, h, mw, mh;
1470 const char* key_data = NULL;
1477 evas_object_image_source_unset(wd->mgf_proxy);
1478 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1479 evas_object_hide(wd->mgf_proxy);
1480 evas_object_clip_unset(wd->mgf_proxy);
1481 evas_object_del(wd->mgf_proxy);
1483 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1484 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1487 evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
1489 evas_object_geometry_get(data, &x, &y, &w, &h);
1491 if ((w <= 0) || (h <= 0))
1494 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1496 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1497 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1498 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1499 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1503 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1504 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1505 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1507 key_data = edje_object_data_get(wd->mgf_bg, "height");
1508 if (key_data) wd->mgf_height = atoi(key_data);
1509 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1510 if (key_data) wd->mgf_scale = atof(key_data);
1512 elm_scale = elm_scale_get();
1513 wd->mgf_height = (int)((float)wd->mgf_height * elm_scale);
1515 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1516 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1520 elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
1521 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
1522 evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
1526 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1527 evas_object_image_source_set(wd->mgf_proxy, data);
1530 mw = (Evas_Coord)((float)w * wd->mgf_scale);
1531 mh = (Evas_Coord)((float)h * wd->mgf_scale);
1532 if ((mw <= 0) || (mh <= 0))
1535 evas_object_resize(wd->mgf_proxy, mw, mh);
1536 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
1537 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1538 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1539 evas_object_show(wd->mgf_proxy);
1540 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1542 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1543 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1547 _signal_long_pressed(void *data)
1549 Widget_Data *wd = elm_widget_data_get(data);
1550 if (!wd) return ECORE_CALLBACK_CANCEL;
1552 wd->long_pressed = EINA_TRUE;
1554 _cancel(data, NULL, NULL);
1556 _magnifier_create(data);
1557 _magnifier_move(data);
1558 _magnifier_show(data);
1559 elm_object_scroll_freeze_push(data);
1561 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1562 return ECORE_CALLBACK_CANCEL;
1566 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1568 Widget_Data *wd = elm_widget_data_get(data);
1569 Evas_Event_Mouse_Down *ev = event_info;
1571 if (wd->disabled) return;
1572 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1573 wd->downx = ev->canvas.x;
1574 wd->downy = ev->canvas.y;
1575 wd->long_pressed = EINA_FALSE;
1579 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1581 Widget_Data *wd = elm_widget_data_get(data);
1582 Evas_Event_Mouse_Up *ev = event_info;
1584 if (wd->disabled) return;
1585 if (ev->button == 1)
1587 if (!wd->double_clicked)
1589 if ((wd->api) && (wd->api->obj_mouseup))
1590 wd->api->obj_mouseup(data);
1592 _magnifier_hide(data);
1593 elm_object_scroll_freeze_pop(data);
1595 if (wd->long_pressed)
1598 else if (ev->button == 3)
1606 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1608 Widget_Data *wd = elm_widget_data_get(data);
1609 Evas_Event_Mouse_Move *ev = event_info;
1611 if (wd->disabled) return;
1613 if (ev->buttons == 1)
1615 if (wd->long_pressed)
1617 _magnifier_show(data);
1618 _magnifier_move(data);
1624 _getbase(Evas_Object *obj)
1626 Widget_Data *wd = elm_widget_data_get(obj);
1627 if (!wd) return "base";
1630 if (wd->password) return "base-password";
1633 if (wd->single_line) return "base-single";
1636 switch (wd->linewrap)
1639 return "base-charwrap";
1642 case ELM_WRAP_MIXED:
1643 return "base-mixedwrap";
1646 return "base-nowrap";
1653 if (wd->password) return "base-password";
1656 if (wd->single_line) return "base-single-noedit";
1659 switch (wd->linewrap)
1662 return "base-noedit-charwrap";
1664 return "base-noedit";
1665 case ELM_WRAP_MIXED:
1666 return "base-noedit-mixedwrap";
1669 return "base-nowrap-noedit";
1679 _entry_length_get(Evas_Object *obj)
1682 const char *str = elm_entry_entry_get(obj);
1685 char *plain_str = _elm_util_mkup_to_text(str);
1686 if (!plain_str) return 0;
1688 len = strlen(plain_str);
1694 #ifndef HAVE_STRCASESTR
1695 char* _strcasestr(const char *s, const char *find)
1700 if ((c = *find++) != 0) {
1701 c = tolower((unsigned char) c);
1705 if( (sc = *s++) == 0)
1707 } while ((char)tolower((unsigned char)sc) != c);
1708 } while (strncasecmp(s, find, len) != 0);
1716 _matchlist_show(void *data)
1718 Widget_Data *wd = elm_widget_data_get(data);
1719 const char *text = NULL;
1721 char *str_list = NULL, *str_result = NULL;
1722 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1725 Eina_Bool textfound = EINA_FALSE;
1728 if (elm_widget_disabled_get(data)) return;
1730 wd->matchlist_job = NULL;
1732 if (wd->matchlist_list_clicked)
1734 evas_object_hide(wd->hover);
1735 wd->matchlist_list_clicked = EINA_FALSE;
1738 text = elm_entry_entry_get(data);
1741 textlen = strlen(text);
1743 if (textlen < wd->matchlist_threshold)
1745 evas_object_hide(wd->hover);
1749 evas_object_hide(wd->hover);
1753 elm_list_clear(wd->list);
1754 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1756 if (wd->matchlist_case_sensitive)
1757 str_result = strstr(str_list, text);
1759 #ifdef HAVE_STRCASESTR
1760 str_result = strcasestr(str_list, text);
1762 str_result = _strcasestr(str_list, text);
1767 str_mkup = malloc(strlen(str_list) + 16);
1768 if (str_mkup == NULL) return;
1770 textlen = strlen(str_list) - strlen(str_result);
1771 str_front = malloc(textlen + 1);
1772 if (str_front == NULL)
1778 memset(str_front, 0, textlen + 1);
1779 strncpy(str_front, str_list, textlen);
1781 textlen = strlen(text);
1782 str_mid = malloc(textlen + 1);
1783 if (str_mid == NULL)
1790 memset(str_mid, 0, textlen + 1);
1791 strncpy(str_mid, str_list + strlen(str_front), textlen);
1793 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1795 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1797 if (str_mkup) free(str_mkup);
1798 if (str_front) free(str_front);
1799 if (str_mid) free(str_mid);
1801 textfound=EINA_TRUE;
1810 elm_list_go(wd->list);
1811 evas_object_show(wd->hover);
1812 evas_object_raise(wd->hover);
1816 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1818 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1819 Widget_Data *wd = elm_widget_data_get(data);
1820 if ((it == NULL) || (wd == NULL))
1823 const char *str = NULL;
1824 const char *text = elm_list_item_label_get(it);
1825 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1830 str = elm_entry_markup_to_utf8(text);
1831 elm_entry_entry_set(data, str);
1832 elm_entry_cursor_end_set(data);
1833 wd->matchlist_list_clicked = EINA_TRUE;
1835 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1839 elm_widget_focus_set(data, EINA_TRUE);
1843 _entry_changed_common_handling(void *data, const char *event)
1845 Widget_Data *wd = elm_widget_data_get(data);
1846 Evas_Coord minw, minh;
1848 wd->changed = EINA_TRUE;
1849 /* Reset the size hints which are no more relevant.
1850 * Keep the height, this is a hack, but doesn't really matter
1851 * cause we'll re-eval in a moment. */
1854 evas_object_size_hint_min_get(data, &minw, &minh);
1855 evas_object_size_hint_min_set(data, minw, minh);
1859 evas_object_size_hint_min_get(data, NULL, &minh);
1860 evas_object_size_hint_min_set(data, -1, minh);
1864 if (wd->text) eina_stringshare_del(wd->text);
1866 if (wd->password_text) eina_stringshare_del(wd->password_text);
1867 wd->password_text = NULL;
1868 _check_enable_returnkey(data);
1869 if (wd->delay_write)
1871 ecore_timer_del(wd->delay_write);
1872 wd->delay_write = NULL;
1875 if ((wd->single_line) && (wd->match_list))
1877 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1878 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1881 if ((wd->api) && (wd->api->obj_hidemenu))
1882 wd->api->obj_hidemenu(data);
1884 if ((wd->autosave) && (wd->file))
1885 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1886 /* callback - this could call callbacks that delete the entry... thus...
1887 * any access to wd after this could be invalid */
1888 evas_object_smart_callback_call(data, event, NULL);
1892 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1894 Widget_Data *wd = elm_widget_data_get(data);
1897 _entry_changed_common_handling(data, SIG_CHANGED);
1901 _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1903 Widget_Data *wd = elm_widget_data_get(data);
1906 _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED);
1910 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1912 Widget_Data *wd = elm_widget_data_get(data);
1915 elm_object_scroll_freeze_push(data);
1917 if ((wd->api) && (wd->api->obj_hidemenu))
1918 wd->api->obj_hidemenu(data);
1920 _magnifier_create(data);
1921 _magnifier_move(data);
1922 _magnifier_show(data);
1926 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1928 Widget_Data *wd = elm_widget_data_get(data);
1931 elm_object_scroll_freeze_pop(data);
1933 if (wd->have_selection)
1935 _magnifier_hide(data);
1941 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1943 _magnifier_move(data);
1944 _magnifier_show(data);
1947 static Evas_Coord_Rectangle
1948 _layout_region_get(Evas_Object *data)
1950 Evas_Coord_Rectangle geometry;
1951 geometry.x = geometry.y = geometry.w = geometry.h = -1;
1953 Widget_Data *wd = elm_widget_data_get(data);
1954 if (!wd) return geometry;
1956 if (!data || !strlen(elm_widget_type_get(data)))
1959 Evas_Object *child_obj = data;
1960 Evas_Object *parent_obj;
1962 while (parent_obj = elm_widget_parent_get(child_obj))
1964 if (!strcmp(elm_widget_type_get(parent_obj), "conformant"))
1966 evas_object_geometry_get(child_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
1969 child_obj = parent_obj;
1975 static Evas_Coord_Rectangle
1976 _viewport_region_get(Evas_Object *data)
1978 Evas_Coord_Rectangle geometry;
1979 geometry.x = geometry.y = geometry.w = geometry.h = -1;
1981 Widget_Data *wd = elm_widget_data_get(data);
1982 if (!wd) return geometry;
1984 if (!data || !strlen(elm_widget_type_get(data)))
1989 evas_object_geometry_get(wd->scroller, &geometry.x, &geometry.y, NULL, NULL);
1990 elm_smart_scroller_child_viewport_size_get(wd->scroller, &geometry.w, &geometry.h);
1995 Evas_Object *parent_obj = data;
1997 while (parent_obj = elm_widget_parent_get(parent_obj))
1999 if (!strcmp(elm_widget_type_get(parent_obj), "scroller") ||
2000 !strcmp(elm_widget_type_get(parent_obj), "genlist"))
2002 evas_object_geometry_get(parent_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
2011 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2013 _magnifier_hide(data);
2018 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2020 Widget_Data *wd = elm_widget_data_get(data);
2024 EINA_LIST_FOREACH(entries, l, entry)
2026 if (entry != data) elm_entry_select_none(entry);
2028 wd->have_selection = EINA_TRUE;
2029 wd->selmode = EINA_TRUE;
2030 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2031 #ifdef HAVE_ELEMENTARY_X
2032 if (wd->sel_notify_handler)
2034 const char *txt = elm_entry_selection_get(data);
2037 top = elm_widget_top_get(data);
2038 if ((top) && (elm_win_xwindow_get(top)))
2039 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
2046 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2048 Evas_Coord cx, cy, cw, ch;
2049 Widget_Data *wd = elm_widget_data_get(data);
2052 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2053 if (!wd->deferred_recalc_job)
2054 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2057 wd->deferred_cur = EINA_TRUE;
2066 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2068 Evas_Coord cx, cy, cw, ch;
2069 Widget_Data *wd = elm_widget_data_get(data);
2071 wd->have_selection = EINA_TRUE;
2072 wd->selmode = EINA_TRUE;
2073 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2074 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
2075 elm_entry_selection_get(data));
2077 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
2078 if (!wd->deferred_recalc_job)
2079 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2082 wd->deferred_cur = EINA_TRUE;
2091 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2093 Widget_Data *wd = elm_widget_data_get(data);
2095 if (!wd->have_selection) return;
2096 wd->have_selection = EINA_FALSE;
2097 wd->selmode = EINA_FALSE;
2098 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2099 if (wd->sel_notify_handler)
2103 #ifdef HAVE_ELEMENTARY_X
2106 top = elm_widget_top_get(data);
2107 if ((top) && (elm_win_xwindow_get(top)))
2108 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
2111 eina_stringshare_del(wd->cut_sel);
2116 #ifdef HAVE_ELEMENTARY_X
2119 top = elm_widget_top_get(data);
2120 if ((top) && (elm_win_xwindow_get(top)))
2121 elm_selection_clear(ELM_SEL_PRIMARY, data);
2126 if ((wd->api) && (wd->api->obj_hidemenu))
2128 wd->api->obj_hidemenu(data);
2133 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2135 Widget_Data *wd = elm_widget_data_get(data);
2137 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2138 if (wd->sel_notify_handler)
2140 #ifdef HAVE_ELEMENTARY_X
2143 top = elm_widget_top_get(data);
2144 if ((top) && (elm_win_xwindow_get(top)))
2146 wd->selection_asked = EINA_TRUE;
2147 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
2155 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2157 Widget_Data *wd = elm_widget_data_get(data);
2159 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2160 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2161 elm_entry_selection_get(data));
2165 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2167 Widget_Data *wd = elm_widget_data_get(data);
2169 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2170 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
2171 elm_entry_selection_get(data));
2172 edje_object_part_text_insert(wd->ent, "elm.text", "");
2173 wd->changed = EINA_TRUE;
2178 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2180 Widget_Data *wd = elm_widget_data_get(data);
2182 wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2183 wd->cur_changed = EINA_TRUE;
2184 _recalc_cursor_geometry(data);
2188 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2190 Widget_Data *wd = elm_widget_data_get(data);
2195 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2197 Widget_Data *wd = elm_widget_data_get(data);
2202 _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
2204 Widget_Data *wd = elm_widget_data_get(data);
2205 Elm_Entry_Anchor_Info ei;
2206 char *buf2, *p, *p2, *n;
2208 p = strrchr(emission, ',');
2211 const Eina_List *geoms;
2215 while (p2 >= emission)
2217 if (*p2 == ',') break;
2221 buf2 = alloca(5 + p - p2);
2222 strncpy(buf2, p2, p - p2);
2225 ei.button = atoi(buf2);
2226 ei.x = ei.y = ei.w = ei.h = 0;
2228 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
2231 Evas_Textblock_Rectangle *r;
2233 Evas_Coord px, py, x, y;
2235 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
2236 evas_pointer_canvas_xy_get(evas_object_evas_get(wd->ent), &px, &py);
2237 EINA_LIST_FOREACH(geoms, l, r)
2239 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2240 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2251 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2256 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2258 Widget_Data *wd = elm_widget_data_get(data);
2263 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2265 Widget_Data *wd = elm_widget_data_get(data);
2270 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2272 Widget_Data *wd = elm_widget_data_get(data);
2277 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2279 Widget_Data *wd = elm_widget_data_get(data);
2281 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2285 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2287 Widget_Data *wd = elm_widget_data_get(data);
2289 wd->double_clicked = EINA_FALSE;
2290 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2292 if ((wd->api) && (wd->api->obj_hidemenu))
2293 wd->api->obj_hidemenu(data);
2297 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2299 Widget_Data *wd = elm_widget_data_get(data);
2301 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2303 if (!_elm_config->desktop_entry && !wd->double_clicked)
2304 _cancel(data, NULL, NULL);
2308 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
2310 Widget_Data *wd = elm_widget_data_get(data);
2312 wd->double_clicked = EINA_TRUE;
2313 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2316 #ifdef HAVE_ELEMENTARY_X
2318 _event_selection_notify(void *data, int type __UNUSED__, void *event)
2320 Widget_Data *wd = elm_widget_data_get(data);
2321 Ecore_X_Event_Selection_Notify *ev = event;
2322 if (!wd) return ECORE_CALLBACK_PASS_ON;
2323 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
2324 return ECORE_CALLBACK_PASS_ON;
2326 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2327 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2329 Ecore_X_Selection_Data_Text *text_data;
2331 text_data = ev->data;
2332 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2334 if (text_data->text)
2336 char *txt = _elm_util_text_to_mkup(text_data->text);
2340 elm_entry_entry_insert(data, txt);
2345 wd->selection_asked = EINA_FALSE;
2347 else if (ev->selection == ECORE_X_SELECTION_XDND)
2349 Ecore_X_Selection_Data_Text *text_data;
2351 text_data = ev->data;
2352 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2354 if (text_data->text)
2356 char *txt = _elm_util_text_to_mkup(text_data->text);
2360 /* Massive FIXME: this should be at the drag point */
2361 elm_entry_entry_insert(data, txt);
2366 wd->drag_selection_asked = EINA_FALSE;
2368 ecore_x_dnd_send_finished();
2371 return ECORE_CALLBACK_PASS_ON;
2375 _event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
2378 Widget_Data *wd = elm_widget_data_get(data);
2379 Ecore_X_Event_Selection_Clear *ev = event;
2380 if (!wd) return ECORE_CALLBACK_PASS_ON;
2381 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
2382 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2383 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2385 elm_entry_select_none(data);
2390 Evas_Object *top = elm_widget_top_get(data);
2391 Ecore_X_Event_Selection_Clear *ev = event;
2394 return ECORE_CALLBACK_PASS_ON;
2396 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2398 return ECORE_CALLBACK_PASS_ON;
2401 if (cnpwidgetdata == data)
2403 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2404 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
2409 return ECORE_CALLBACK_PASS_ON;
2413 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
2418 wd = elm_widget_data_get(obj);
2419 if (!wd) return EINA_FALSE;
2420 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
2422 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2423 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
2424 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
2425 EDJE_CURSOR_MAIN,drop->x,drop->y);
2426 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
2427 elm_entry_entry_insert(obj, drop->data);
2428 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
2429 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
2435 static Evas_Object *
2436 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
2438 Widget_Data *wd = elm_widget_data_get(data);
2441 Elm_Entry_Item_Provider *ip;
2443 EINA_LIST_FOREACH(wd->item_providers, l, ip)
2445 o = ip->func(ip->data, data, item);
2448 if (!strncmp(item, "file://", 7))
2450 const char *fname = item + 7;
2452 o = evas_object_image_filled_add(evas_object_evas_get(data));
2453 evas_object_image_file_set(o, fname, NULL);
2454 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2456 evas_object_show(o);
2461 o = edje_object_add(evas_object_evas_get(data));
2462 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2466 o = edje_object_add(evas_object_evas_get(data));
2467 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
2468 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2473 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2475 const char *srcstring = NULL;
2476 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2477 char *curlocater = NULL, *replocater;
2478 char *starttag, *endtag;
2479 int tagtxtlen = 0, insertflag = 0;
2481 srcstring = eina_strbuf_string_get(srcbuf);
2483 curlocater = strstr(srcstring, key);
2484 if (!curlocater || !srcstring)
2492 starttag = strchr(srcstring, '<');
2493 endtag = strchr(srcstring, '>');
2494 tagtxtlen = endtag - starttag;
2495 if (tagtxtlen <= 0) tagtxtlen = 0;
2496 if (starttag < curlocater && curlocater < endtag) break;
2497 if (endtag != NULL && endtag+1 != NULL)
2498 srcstring = endtag+1;
2501 } while (strlen(srcstring) > 1);
2503 if (starttag && endtag && tagtxtlen > strlen(key))
2505 repbuf = eina_strbuf_new();
2506 diffbuf = eina_strbuf_new();
2507 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2508 srcstring = eina_strbuf_string_get(repbuf);
2509 curlocater = strstr(srcstring, key);
2511 if (curlocater != NULL)
2513 replocater = curlocater + strlen(key) + 1;
2515 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2518 if (replocater-curlocater > strlen(key)+1)
2520 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2529 eina_strbuf_reset(repbuf);
2537 if (repbuf == NULL) repbuf = eina_strbuf_new();
2538 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2542 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2543 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2549 eina_strbuf_prepend(diffbuf, "<");
2550 eina_strbuf_append(diffbuf, ">");
2551 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2555 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2556 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2560 if (repbuf) eina_strbuf_free(repbuf);
2561 if (diffbuf) eina_strbuf_free(diffbuf);
2567 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2569 Eina_Strbuf *sharebuf = NULL;
2571 sharebuf = eina_strbuf_new();
2572 eina_strbuf_append(sharebuf, *srcstring);
2573 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2574 eina_stringshare_del(*srcstring);
2575 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2576 eina_strbuf_free(sharebuf);
2582 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2584 Widget_Data *wd = elm_widget_data_get(data);
2586 Elm_Entry_Text_Filter *tf;
2588 if (type == EDJE_TEXT_FILTER_FORMAT)
2591 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2593 tf->func(tf->data, data, text);
2599 /* This function is used to insert text by chunks in jobs */
2601 _text_append_idler(void *data)
2605 Evas_Object *obj = (Evas_Object *) data;
2606 Widget_Data *wd = elm_widget_data_get(obj);
2607 if (wd->text) eina_stringshare_del(wd->text);
2609 if (wd->password_text) eina_stringshare_del(wd->password_text);
2610 wd->password_text = NULL;
2611 wd->changed = EINA_TRUE;
2613 start = wd->append_text_position;
2614 if (start + _CHUNK_SIZE < wd->append_text_len)
2617 int tag_start, esc_start;
2619 tag_start = esc_start = -1;
2620 /* Find proper markup cut place */
2621 while (pos - start < _CHUNK_SIZE)
2625 eina_unicode_utf8_get_next(wd->append_text_left, &pos);
2626 if (esc_start == -1)
2629 tag_start = prev_pos;
2630 else if (tmp == '>')
2633 else if (tag_start == -1)
2636 esc_start = prev_pos;
2637 else if (tmp == ';')
2644 wd->append_text_position = tag_start;
2646 else if (esc_start >= 0)
2648 wd->append_text_position = esc_start;
2652 wd->append_text_position = pos;
2657 wd->append_text_position = wd->append_text_len;
2660 backup = wd->append_text_left[wd->append_text_position];
2661 wd->append_text_left[wd->append_text_position] = '\0';
2663 edje_object_part_text_append(wd->ent, "elm.text",
2664 wd->append_text_left + start);
2666 wd->append_text_left[wd->append_text_position] = backup;
2668 /* If there's still more to go, renew the idler, else, cleanup */
2669 if (wd->append_text_position < wd->append_text_len)
2671 return ECORE_CALLBACK_RENEW;
2675 free(wd->append_text_left);
2676 wd->append_text_left = NULL;
2677 wd->append_text_idler = NULL;
2678 return ECORE_CALLBACK_CANCEL;
2683 _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit)
2685 int i = 0, unit_size;
2686 int current_len = strlen(*text);
2687 char *new_text = *text;
2688 if (unit >= LENGTH_UNIT_LAST) return;
2691 if (*new_text == '<')
2693 while (*new_text != '>')
2696 if (!*new_text) break;
2703 if (*new_text == '&')
2705 while (*(new_text + idx) != ';')
2708 if (!*(new_text + idx)) break;
2712 idx = evas_string_char_next_get(new_text, idx, NULL);
2713 markup = malloc(idx + 1);
2714 strncpy(markup, new_text, idx);
2716 if (unit == LENGTH_UNIT_BYTE)
2717 unit_size = strlen(elm_entry_markup_to_utf8(markup));
2718 else if (unit == LENGTH_UNIT_CHAR)
2719 unit_size = evas_string_char_len_get(elm_entry_markup_to_utf8(markup));
2725 if (can_add < unit_size)
2729 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2735 strncpy(new_text, new_text + idx, current_len - ((new_text + idx) - *text));
2737 (*text)[current_len] = 0;
2742 can_add -= unit_size;
2747 evas_object_smart_callback_call(obj, "maxlength,reached", NULL);
2751 _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
2754 ELM_CHECK_WIDTYPE(obj, widtype);
2755 Widget_Data *wd = elm_widget_data_get(obj);
2757 if (!entry) entry = "";
2758 if (item && strcmp(item, "default"))
2760 edje_object_part_text_set(wd->ent, item, entry);
2764 if (wd->text) eina_stringshare_del(wd->text);
2766 if (wd->password_text) eina_stringshare_del(wd->password_text);
2767 wd->password_text = NULL;
2768 wd->changed = EINA_TRUE;
2770 /* Clear currently pending job if there is one */
2771 if (wd->append_text_idler)
2773 ecore_idler_del(wd->append_text_idler);
2774 free(wd->append_text_left);
2775 wd->append_text_left = NULL;
2776 wd->append_text_idler = NULL;
2779 len = strlen(entry);
2780 /* Split to ~_CHUNK_SIZE chunks */
2781 if (len > _CHUNK_SIZE)
2783 wd->append_text_left = (char *) malloc(len + 1);
2786 /* If we decided to use the idler */
2787 if (wd->append_text_left)
2789 /* Need to clear the entry first */
2790 edje_object_part_text_set(wd->ent, "elm.text", "");
2791 memcpy(wd->append_text_left, entry, len + 1);
2792 wd->append_text_position = 0;
2793 wd->append_text_len = len;
2794 wd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
2798 edje_object_part_text_set(wd->ent, "elm.text", entry);
2803 _elm_entry_text_get(const Evas_Object *obj, const char *item)
2805 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2806 Widget_Data *wd = elm_widget_data_get(obj);
2807 if (item && strcmp(item, "default")) return NULL;
2809 if (!wd) return NULL;
2812 if(wd->password_text) return wd->password_text;
2818 text = edje_object_part_text_get(wd->ent, "elm.text");
2821 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2824 eina_stringshare_replace(&wd->text, text);
2827 const char *pw_text;
2828 pw_text = elm_entry_markup_to_utf8(wd->text);
2831 eina_stringshare_replace(&wd->password_text, pw_text);
2833 return wd->password_text;
2840 elm_entry_add(Evas_Object *parent)
2842 Evas_Object *obj, *top;
2846 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2848 ELM_SET_WIDTYPE(widtype, "entry");
2849 elm_widget_type_set(obj, "entry");
2850 elm_widget_sub_object_add(parent, obj);
2851 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2852 elm_widget_data_set(obj, wd);
2853 elm_widget_del_hook_set(obj, _del_hook);
2854 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2855 elm_widget_theme_hook_set(obj, _theme_hook);
2856 elm_widget_disable_hook_set(obj, _disable_hook);
2857 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2858 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
2859 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2860 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2861 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2862 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2863 elm_widget_can_focus_set(obj, EINA_TRUE);
2864 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2865 elm_widget_text_set_hook_set(obj, _elm_entry_text_set);
2866 elm_widget_text_get_hook_set(obj, _elm_entry_text_get);
2867 elm_widget_content_set_hook_set(obj, _content_set_hook);
2868 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
2869 elm_widget_content_get_hook_set(obj, _content_get_hook);
2870 elm_widget_translate_hook_set(obj, _translate_hook);
2872 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, wd);
2874 wd->scroller = elm_smart_scroller_add(e);
2875 elm_widget_sub_object_add(obj, wd->scroller);
2876 elm_smart_scroller_widget_set(wd->scroller, obj);
2877 elm_smart_scroller_object_theme_set(obj, wd->scroller, "scroller", "entry",
2878 elm_widget_style_get(obj));
2879 evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2880 evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
2881 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
2882 elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
2884 wd->linewrap = ELM_WRAP_WORD;
2885 wd->editable = EINA_TRUE;
2886 wd->disabled = EINA_FALSE;
2887 wd->context_menu = EINA_TRUE;
2888 wd->autosave = EINA_TRUE;
2889 wd->textonly = EINA_FALSE;
2890 wd->autoperiod = EINA_TRUE;
2892 wd->ent = edje_object_add(e);
2893 elm_widget_sub_object_add(obj, wd->ent);
2894 edje_object_item_provider_set(wd->ent, _get_item, obj);
2895 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2896 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2897 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2899 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2901 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2903 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
2905 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2906 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2907 _signal_entry_changed, obj);
2908 edje_object_signal_callback_add(wd->ent, "preedit,changed", "elm.text",
2909 _signal_preedit_changed, obj);
2910 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2911 _signal_handler_move_start, obj);
2912 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2913 _signal_handler_move_end, obj);
2914 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2915 _signal_handler_moving, obj);
2916 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2917 _signal_selection_start, obj);
2918 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2919 _signal_selection_end, obj);
2920 edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text",
2921 _signal_long_pressed, obj);
2922 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2923 _signal_magnifier_changed, obj);
2924 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2925 _signal_selection_changed, obj);
2926 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2927 _signal_selection_cleared, obj);
2928 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2929 _signal_entry_paste_request, obj);
2930 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2931 _signal_entry_copy_notify, obj);
2932 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2933 _signal_entry_cut_notify, obj);
2934 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2935 _signal_cursor_changed, obj);
2936 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2937 _signal_anchor_down, obj);
2938 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2939 _signal_anchor_up, obj);
2940 edje_object_signal_callback_add(wd->ent, "anchor,mouse,clicked,*", "elm.text",
2941 _signal_anchor_clicked, obj);
2942 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2943 _signal_anchor_move, obj);
2944 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2945 _signal_anchor_in, obj);
2946 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2947 _signal_anchor_out, obj);
2948 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2949 _signal_key_enter, obj);
2950 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2951 _signal_mouse_down, obj);
2952 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2953 _signal_mouse_clicked, obj);
2954 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2955 _signal_mouse_double, obj);
2956 edje_object_part_text_set(wd->ent, "elm.text", "");
2957 if (_elm_config->desktop_entry)
2958 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
2959 elm_widget_resize_object_set(obj, wd->ent);
2962 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
2964 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2965 wd->autocapital_type = edje_object_part_text_autocapital_type_get(wd->ent, "elm.text");
2967 #ifdef HAVE_ELEMENTARY_X
2968 top = elm_widget_top_get(obj);
2969 if ((top) && (elm_win_xwindow_get(top)))
2971 wd->sel_notify_handler =
2972 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2973 _event_selection_notify, obj);
2974 wd->sel_clear_handler =
2975 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2976 _event_selection_clear, obj);
2979 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
2980 _drag_drop_cb, NULL);
2983 entries = eina_list_prepend(entries, obj);
2985 // module - find module for entry
2986 wd->api = _module(obj);
2987 // if found - hook in
2988 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2990 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2991 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2992 // TODO: and save some bytes, making descriptions per-class and not instance!
2993 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2997 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2999 ELM_CHECK_WIDTYPE(obj, widtype);
3000 Widget_Data *wd = elm_widget_data_get(obj);
3002 ext_mod->cancel = _cancel;
3003 ext_mod->copy = _copy;
3004 ext_mod->cut = _cut;
3005 ext_mod->paste = _paste;
3006 ext_mod->select = _select;
3007 ext_mod->selectall = _selectall;
3008 ext_mod->ent = wd->ent;
3009 ext_mod->items = wd->items;
3010 ext_mod->editable = wd->editable;
3011 ext_mod->have_selection = wd->have_selection;
3012 ext_mod->password = wd->password;
3013 ext_mod->selmode = wd->selmode;
3014 ext_mod->cnpinit = _cnpinit;
3015 ext_mod->context_menu = wd->context_menu;
3016 ext_mod->textonly = wd->textonly;
3020 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
3022 ELM_CHECK_WIDTYPE(obj, widtype);
3023 Widget_Data *wd = elm_widget_data_get(obj);
3025 if (wd->single_line == single_line) return;
3026 wd->single_line = single_line;
3027 wd->linewrap = ELM_WRAP_NONE;
3028 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
3032 if (wd->single_line)
3034 elm_smart_scroller_policy_set(wd->scroller,
3035 ELM_SMART_SCROLLER_POLICY_OFF,
3036 ELM_SMART_SCROLLER_POLICY_OFF);
3037 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3041 const Elm_Scroller_Policy map[3] =
3043 ELM_SMART_SCROLLER_POLICY_AUTO,
3044 ELM_SMART_SCROLLER_POLICY_ON,
3045 ELM_SMART_SCROLLER_POLICY_OFF
3047 elm_smart_scroller_policy_set(wd->scroller,
3050 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3057 elm_entry_single_line_get(const Evas_Object *obj)
3059 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3060 Widget_Data *wd = elm_widget_data_get(obj);
3061 if (!wd) return EINA_FALSE;
3062 return wd->single_line;
3066 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
3068 ELM_CHECK_WIDTYPE(obj, widtype);
3069 Widget_Data *wd = elm_widget_data_get(obj);
3071 if (wd->password == password) return;
3072 wd->password = password;
3073 wd->single_line = EINA_TRUE;
3074 wd->linewrap = ELM_WRAP_NONE;
3079 elm_entry_password_get(const Evas_Object *obj)
3081 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3082 Widget_Data *wd = elm_widget_data_get(obj);
3083 if (!wd) return EINA_FALSE;
3084 return wd->password;
3088 elm_entry_entry_set(Evas_Object *obj, const char *entry)
3090 _elm_entry_text_set(obj, NULL, entry);
3094 elm_entry_entry_append(Evas_Object *obj, const char *entry)
3097 ELM_CHECK_WIDTYPE(obj, widtype);
3098 Widget_Data *wd = elm_widget_data_get(obj);
3100 if (!entry) entry = "";
3101 wd->changed = EINA_TRUE;
3103 len = strlen(entry);
3104 if (wd->append_text_left)
3107 tmpbuf = realloc(wd->append_text_left, wd->append_text_len + len + 1);
3113 wd->append_text_left = tmpbuf;
3114 memcpy(wd->append_text_left + wd->append_text_len, entry, len + 1);
3115 wd->append_text_len += len;
3119 /* FIXME: Add chunked appending here (like in entry_set) */
3120 edje_object_part_text_append(wd->ent, "elm.text", entry);
3125 elm_entry_entry_get(const Evas_Object *obj)
3127 return _elm_entry_text_get(obj, NULL);
3131 elm_entry_is_empty(const Evas_Object *obj)
3133 /* FIXME: until there's support for that in textblock, we just check
3134 * to see if the there is text or not. */
3135 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
3136 Widget_Data *wd = elm_widget_data_get(obj);
3137 const Evas_Object *tb;
3138 Evas_Textblock_Cursor *cur;
3140 if (!wd) return EINA_TRUE;
3143 /* It's a hack until we get the support suggested above.
3144 * We just create a cursor, point it to the begining, and then
3145 * try to advance it, if it can advance, the tb is not empty,
3146 * otherwise it is. */
3147 tb = edje_object_part_object_get(wd->ent, "elm.text");
3148 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
3149 actually, ok for the time being, thsese hackish stuff will be removed
3150 once evas 1.0 is out*/
3151 evas_textblock_cursor_pos_set(cur, 0);
3152 ret = evas_textblock_cursor_char_next(cur);
3153 evas_textblock_cursor_free(cur);
3158 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
3159 if (!str) return EINA_TRUE;
3161 ret = (strlen(str) == 0);
3168 elm_entry_selection_get(const Evas_Object *obj)
3170 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3171 Widget_Data *wd = elm_widget_data_get(obj);
3172 if (!wd) return NULL;
3173 return edje_object_part_text_selection_get(wd->ent, "elm.text");
3177 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
3179 ELM_CHECK_WIDTYPE(obj, widtype);
3180 Widget_Data *wd = elm_widget_data_get(obj);
3182 edje_object_part_text_insert(wd->ent, "elm.text", entry);
3184 #ifdef HAVE_ELEMENTARY_X
3185 if (cnpwidgetdata == obj)
3186 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
3189 wd->changed = EINA_TRUE;
3194 elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
3196 ELM_CHECK_WIDTYPE(obj, widtype);
3197 Widget_Data *wd = elm_widget_data_get(obj);
3199 if (wd->linewrap == wrap) return;
3201 wd->linewrap = wrap;
3206 elm_entry_line_wrap_get(const Evas_Object *obj)
3208 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3209 Widget_Data *wd = elm_widget_data_get(obj);
3210 if (!wd) return EINA_FALSE;
3211 return wd->linewrap;
3215 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
3217 ELM_CHECK_WIDTYPE(obj, widtype);
3218 Widget_Data *wd = elm_widget_data_get(obj);
3220 if (wd->editable == editable) return;
3221 wd->editable = editable;
3224 #ifdef HAVE_ELEMENTARY_X
3226 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
3228 elm_drop_target_del(obj);
3233 elm_entry_editable_get(const Evas_Object *obj)
3235 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3236 Widget_Data *wd = elm_widget_data_get(obj);
3237 if (!wd) return EINA_FALSE;
3238 return wd->editable;
3242 elm_entry_select_none(Evas_Object *obj)
3244 ELM_CHECK_WIDTYPE(obj, widtype);
3245 Widget_Data *wd = elm_widget_data_get(obj);
3249 wd->selmode = EINA_FALSE;
3250 if (!_elm_config->desktop_entry)
3251 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3252 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3254 wd->have_selection = EINA_FALSE;
3255 edje_object_part_text_select_none(wd->ent, "elm.text");
3259 elm_entry_select_all(Evas_Object *obj)
3261 ELM_CHECK_WIDTYPE(obj, widtype);
3262 Widget_Data *wd = elm_widget_data_get(obj);
3266 wd->selmode = EINA_FALSE;
3267 if (!_elm_config->desktop_entry)
3268 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3269 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3271 wd->have_selection = EINA_TRUE;
3272 edje_object_part_text_select_all(wd->ent, "elm.text");
3276 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3278 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3279 Widget_Data *wd = elm_widget_data_get(obj);
3280 if (!wd) return EINA_FALSE;
3281 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3286 elm_entry_cursor_next(Evas_Object *obj)
3288 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3289 Widget_Data *wd = elm_widget_data_get(obj);
3290 if (!wd) return EINA_FALSE;
3291 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3295 elm_entry_cursor_prev(Evas_Object *obj)
3297 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3298 Widget_Data *wd = elm_widget_data_get(obj);
3299 if (!wd) return EINA_FALSE;
3300 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3304 elm_entry_cursor_up(Evas_Object *obj)
3306 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3307 Widget_Data *wd = elm_widget_data_get(obj);
3308 if (!wd) return EINA_FALSE;
3309 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3313 elm_entry_cursor_down(Evas_Object *obj)
3315 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3316 Widget_Data *wd = elm_widget_data_get(obj);
3317 if (!wd) return EINA_FALSE;
3318 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3322 elm_entry_cursor_begin_set(Evas_Object *obj)
3324 ELM_CHECK_WIDTYPE(obj, widtype);
3325 Widget_Data *wd = elm_widget_data_get(obj);
3327 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3331 elm_entry_cursor_end_set(Evas_Object *obj)
3333 ELM_CHECK_WIDTYPE(obj, widtype);
3334 Widget_Data *wd = elm_widget_data_get(obj);
3337 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3340 elm_widget_show_region_get(wd->ent, &x, &y, &w, &h);
3341 elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h);
3346 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3348 ELM_CHECK_WIDTYPE(obj, widtype);
3349 Widget_Data *wd = elm_widget_data_get(obj);
3351 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3355 elm_entry_cursor_line_end_set(Evas_Object *obj)
3357 ELM_CHECK_WIDTYPE(obj, widtype);
3358 Widget_Data *wd = elm_widget_data_get(obj);
3360 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3364 elm_entry_cursor_selection_begin(Evas_Object *obj)
3366 ELM_CHECK_WIDTYPE(obj, widtype);
3367 Widget_Data *wd = elm_widget_data_get(obj);
3369 edje_object_part_text_select_begin(wd->ent, "elm.text");
3373 elm_entry_cursor_selection_end(Evas_Object *obj)
3375 ELM_CHECK_WIDTYPE(obj, widtype);
3376 Widget_Data *wd = elm_widget_data_get(obj);
3378 edje_object_part_text_select_extend(wd->ent, "elm.text");
3382 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3384 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3385 Widget_Data *wd = elm_widget_data_get(obj);
3386 if (!wd) return EINA_FALSE;
3387 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3391 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3393 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3394 Widget_Data *wd = elm_widget_data_get(obj);
3395 if (!wd) return EINA_FALSE;
3396 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3400 elm_entry_cursor_content_get(const Evas_Object *obj)
3402 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3403 Widget_Data *wd = elm_widget_data_get(obj);
3404 if (!wd) return NULL;
3405 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3409 elm_entry_cursor_pos_set(Evas_Object *obj, int pos)
3411 ELM_CHECK_WIDTYPE(obj, widtype);
3412 Widget_Data *wd = elm_widget_data_get(obj);
3414 edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos);
3415 edje_object_message_signal_process(wd->ent);
3419 elm_entry_cursor_pos_get(const Evas_Object *obj)
3421 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3422 Widget_Data *wd = elm_widget_data_get(obj);
3424 return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3428 elm_entry_selection_cut(Evas_Object *obj)
3430 ELM_CHECK_WIDTYPE(obj, widtype);
3431 Widget_Data *wd = elm_widget_data_get(obj);
3433 _cut(obj, NULL, NULL);
3437 elm_entry_selection_copy(Evas_Object *obj)
3439 ELM_CHECK_WIDTYPE(obj, widtype);
3440 Widget_Data *wd = elm_widget_data_get(obj);
3442 _copy(obj, NULL, NULL);
3446 elm_entry_selection_paste(Evas_Object *obj)
3448 ELM_CHECK_WIDTYPE(obj, widtype);
3449 Widget_Data *wd = elm_widget_data_get(obj);
3451 _paste(obj, NULL, NULL);
3455 elm_entry_context_menu_clear(Evas_Object *obj)
3457 ELM_CHECK_WIDTYPE(obj, widtype);
3458 Widget_Data *wd = elm_widget_data_get(obj);
3459 Elm_Entry_Context_Menu_Item *it;
3461 EINA_LIST_FREE(wd->items, it)
3463 eina_stringshare_del(it->label);
3464 eina_stringshare_del(it->icon_file);
3465 eina_stringshare_del(it->icon_group);
3471 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)
3473 ELM_CHECK_WIDTYPE(obj, widtype);
3474 Widget_Data *wd = elm_widget_data_get(obj);
3475 Elm_Entry_Context_Menu_Item *it;
3477 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3479 wd->items = eina_list_append(wd->items, it);
3481 it->label = eina_stringshare_add(label);
3482 it->icon_file = eina_stringshare_add(icon_file);
3483 it->icon_type = icon_type;
3485 it->data = (void *)data;
3489 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3491 ELM_CHECK_WIDTYPE(obj, widtype);
3492 Widget_Data *wd = elm_widget_data_get(obj);
3494 if (wd->context_menu == !disabled) return;
3495 wd->context_menu = !disabled;
3499 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3501 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3502 Widget_Data *wd = elm_widget_data_get(obj);
3503 if (!wd) return EINA_FALSE;
3504 return !wd->context_menu;
3508 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3510 ELM_CHECK_WIDTYPE(obj, widtype);
3511 Widget_Data *wd = elm_widget_data_get(obj);
3513 EINA_SAFETY_ON_NULL_RETURN(func);
3514 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3518 wd->item_providers = eina_list_append(wd->item_providers, ip);
3522 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3524 ELM_CHECK_WIDTYPE(obj, widtype);
3525 Widget_Data *wd = elm_widget_data_get(obj);
3527 EINA_SAFETY_ON_NULL_RETURN(func);
3528 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3532 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3536 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3538 ELM_CHECK_WIDTYPE(obj, widtype);
3539 Widget_Data *wd = elm_widget_data_get(obj);
3541 Elm_Entry_Item_Provider *ip;
3543 EINA_SAFETY_ON_NULL_RETURN(func);
3544 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3546 if ((ip->func == func) && ((!data) || (ip->data == data)))
3548 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3556 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3559 Elm_Entry_Text_Filter *tf;
3560 ELM_CHECK_WIDTYPE(obj, widtype);
3562 wd = elm_widget_data_get(obj);
3564 EINA_SAFETY_ON_NULL_RETURN(func);
3566 tf = _filter_new(func, data);
3569 wd->text_filters = eina_list_append(wd->text_filters, tf);
3573 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3576 Elm_Entry_Text_Filter *tf;
3577 ELM_CHECK_WIDTYPE(obj, widtype);
3579 wd = elm_widget_data_get(obj);
3581 EINA_SAFETY_ON_NULL_RETURN(func);
3583 tf = _filter_new(func, data);
3586 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3590 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3594 Elm_Entry_Text_Filter *tf;
3595 ELM_CHECK_WIDTYPE(obj, widtype);
3597 wd = elm_widget_data_get(obj);
3599 EINA_SAFETY_ON_NULL_RETURN(func);
3601 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3603 if ((tf->func == func) && ((!data) || (tf->data == data)))
3605 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3613 elm_entry_markup_to_utf8(const char *s)
3615 char *ss = _elm_util_mkup_to_text(s);
3616 if (!ss) ss = strdup("");
3621 elm_entry_utf8_to_markup(const char *s)
3623 char *ss = _elm_util_text_to_mkup(s);
3624 if (!ss) ss = strdup("");
3629 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3631 Elm_Entry_Filter_Limit_Size *lim = data;
3634 const char *(*text_get)(const Evas_Object *);
3635 const char *widget_type;
3637 EINA_SAFETY_ON_NULL_RETURN(data);
3638 EINA_SAFETY_ON_NULL_RETURN(entry);
3639 EINA_SAFETY_ON_NULL_RETURN(text);
3641 /* hack. I don't want to copy the entire function to work with
3643 widget_type = elm_widget_type_get(entry);
3644 if (!strcmp(widget_type, "entry"))
3645 text_get = elm_entry_entry_get;
3649 current = elm_entry_markup_to_utf8(text_get(entry));
3651 if (lim->max_char_count > 0)
3653 len = evas_string_char_len_get(current);
3654 if (len >= lim->max_char_count)
3656 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3662 newlen = evas_string_char_len_get(elm_entry_markup_to_utf8(*text));
3663 if ((len + newlen) > lim->max_char_count)
3664 _add_chars_till_limit(entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
3666 else if (lim->max_byte_count > 0)
3668 len = strlen(current);
3669 if (len >= lim->max_byte_count)
3671 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3677 newlen = strlen(elm_entry_markup_to_utf8(*text));
3678 if ((len + newlen) > lim->max_byte_count)
3679 _add_chars_till_limit(entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
3685 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3687 Elm_Entry_Filter_Accept_Set *as = data;
3691 int read_idx, last_read_idx = 0, read_char;
3693 EINA_SAFETY_ON_NULL_RETURN(data);
3694 EINA_SAFETY_ON_NULL_RETURN(text);
3696 if ((!as->accepted) && (!as->rejected))
3702 goes_in = EINA_TRUE;
3707 goes_in = EINA_FALSE;
3711 read_idx = evas_string_char_next_get(*text, 0, &read_char);
3714 int cmp_idx, cmp_char;
3715 Eina_Bool in_set = EINA_FALSE;
3717 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
3720 if (read_char == cmp_char)
3725 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
3727 if (in_set == goes_in)
3729 int size = read_idx - last_read_idx;
3730 const char *src = (*text) + last_read_idx;
3732 memcpy(insert, *text + last_read_idx, size);
3735 last_read_idx = read_idx;
3736 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
3742 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
3744 ELM_CHECK_WIDTYPE(obj, widtype);
3745 Widget_Data *wd = elm_widget_data_get(obj);
3747 if (wd->delay_write)
3749 ecore_timer_del(wd->delay_write);
3750 wd->delay_write = NULL;
3752 if (wd->autosave) _save(obj);
3753 eina_stringshare_replace(&wd->file, file);
3754 wd->format = format;
3759 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
3761 ELM_CHECK_WIDTYPE(obj, widtype);
3762 Widget_Data *wd = elm_widget_data_get(obj);
3764 if (file) *file = wd->file;
3765 if (format) *format = wd->format;
3769 elm_entry_file_save(Evas_Object *obj)
3771 ELM_CHECK_WIDTYPE(obj, widtype);
3772 Widget_Data *wd = elm_widget_data_get(obj);
3774 if (wd->delay_write)
3776 ecore_timer_del(wd->delay_write);
3777 wd->delay_write = NULL;
3780 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
3784 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
3786 ELM_CHECK_WIDTYPE(obj, widtype);
3787 Widget_Data *wd = elm_widget_data_get(obj);
3789 wd->autosave = !!autosave;
3793 elm_entry_autosave_get(const Evas_Object *obj)
3795 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3796 Widget_Data *wd = elm_widget_data_get(obj);
3797 if (!wd) return EINA_FALSE;
3798 return wd->autosave;
3802 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
3804 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
3805 ELM_CHECK_WIDTYPE(obj, widtype);
3806 Widget_Data *wd = elm_widget_data_get(obj);
3808 textonly = !!textonly;
3809 if (wd->textonly == textonly) return;
3810 wd->textonly = !!textonly;
3811 if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
3812 #ifdef HAVE_ELEMENTARY_X
3813 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
3818 elm_entry_cnp_textonly_get(const Evas_Object *obj)
3820 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3821 Widget_Data *wd = elm_widget_data_get(obj);
3822 if (!wd) return EINA_FALSE;
3823 return wd->textonly;
3827 elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll)
3829 ELM_CHECK_WIDTYPE(obj, widtype);
3830 Widget_Data *wd = elm_widget_data_get(obj);
3833 if (wd->scroll == scroll) return;
3834 wd->scroll = scroll;
3837 elm_widget_sub_object_del(obj, wd->scroller);
3838 elm_widget_resize_object_set(obj, wd->scroller);
3839 elm_widget_sub_object_add(obj, wd->ent);
3840 elm_smart_scroller_child_set(wd->scroller, wd->ent);
3841 evas_object_show(wd->scroller);
3842 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3843 if (wd->single_line)
3845 elm_smart_scroller_policy_set(wd->scroller,
3846 ELM_SMART_SCROLLER_POLICY_OFF,
3847 ELM_SMART_SCROLLER_POLICY_OFF);
3848 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3852 const Elm_Scroller_Policy map[3] =
3854 ELM_SMART_SCROLLER_POLICY_AUTO,
3855 ELM_SMART_SCROLLER_POLICY_ON,
3856 ELM_SMART_SCROLLER_POLICY_OFF
3858 elm_smart_scroller_policy_set(wd->scroller,
3861 elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE);
3866 elm_smart_scroller_child_set(wd->scroller, NULL);
3867 elm_widget_sub_object_del(obj, wd->ent);
3868 elm_widget_resize_object_set(obj, wd->ent);
3869 evas_object_smart_member_add(wd->scroller, obj);
3870 elm_widget_sub_object_add(obj, wd->scroller);
3871 evas_object_hide(wd->scroller);
3872 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
3879 elm_entry_scrollable_get(const Evas_Object *obj)
3881 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3882 Widget_Data *wd = elm_widget_data_get(obj);
3883 if (!wd) return EINA_FALSE;
3888 elm_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
3890 ELM_CHECK_WIDTYPE(obj, widtype);
3891 Widget_Data *wd = elm_widget_data_get(obj);
3894 EINA_SAFETY_ON_NULL_RETURN(icon);
3895 if (wd->icon == icon) return;
3896 if (wd->icon) evas_object_del(wd->icon);
3898 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3900 edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
3901 edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
3906 elm_entry_icon_get(const Evas_Object *obj)
3908 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3909 Widget_Data *wd = elm_widget_data_get(obj);
3910 if (!wd) return NULL;
3915 elm_entry_icon_unset(Evas_Object *obj)
3917 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3918 Widget_Data *wd = elm_widget_data_get(obj);
3919 Evas_Object *ret = NULL;
3920 if (!wd) return NULL;
3923 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
3924 if (!edje) return NULL;
3926 edje_object_part_unswallow(edje, wd->icon);
3927 edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
3935 elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
3937 ELM_CHECK_WIDTYPE(obj, widtype);
3938 Widget_Data *wd = elm_widget_data_get(obj);
3939 if ((!wd) || (!wd->icon)) return;
3941 evas_object_hide(wd->icon);
3943 evas_object_show(wd->icon);
3948 elm_entry_end_set(Evas_Object *obj, Evas_Object *end)
3950 ELM_CHECK_WIDTYPE(obj, widtype);
3951 Widget_Data *wd = elm_widget_data_get(obj);
3954 EINA_SAFETY_ON_NULL_RETURN(end);
3955 if (wd->end == end) return;
3956 if (wd->end) evas_object_del(wd->end);
3958 edje = elm_smart_scroller_edje_object_get(wd->scroller);
3960 edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
3961 edje_object_signal_emit(edje, "elm,action,show,end", "elm");
3966 elm_entry_end_get(const Evas_Object *obj)
3968 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3969 Widget_Data *wd = elm_widget_data_get(obj);
3970 if (!wd) return NULL;
3975 elm_entry_end_unset(Evas_Object *obj)
3977 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3978 Widget_Data *wd = elm_widget_data_get(obj);
3979 Evas_Object *ret = NULL;
3980 if (!wd) return NULL;
3983 Evas_Object *edje = elm_smart_scroller_edje_object_get(wd->scroller);
3984 if (!edje) return NULL;
3986 edje_object_part_unswallow(edje, wd->end);
3987 edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
3995 elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
3997 ELM_CHECK_WIDTYPE(obj, widtype);
3998 Widget_Data *wd = elm_widget_data_get(obj);
3999 if ((!wd) || (!wd->end)) return;
4001 evas_object_hide(wd->end);
4003 evas_object_show(wd->end);
4008 elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
4010 ELM_CHECK_WIDTYPE(obj, widtype);
4011 Widget_Data *wd = elm_widget_data_get(obj);
4012 const Elm_Scroller_Policy map[3] =
4014 ELM_SMART_SCROLLER_POLICY_AUTO,
4015 ELM_SMART_SCROLLER_POLICY_ON,
4016 ELM_SMART_SCROLLER_POLICY_OFF
4021 elm_smart_scroller_policy_set(wd->scroller,
4027 elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4029 ELM_CHECK_WIDTYPE(obj, widtype);
4030 Widget_Data *wd = elm_widget_data_get(obj);
4032 elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
4036 elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4038 ELM_CHECK_WIDTYPE(obj, widtype);
4039 Widget_Data *wd = elm_widget_data_get(obj);
4041 elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
4045 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4047 ELM_CHECK_WIDTYPE(obj, widtype);
4048 Widget_Data *wd = elm_widget_data_get(obj);
4051 wd->input_panel_layout = layout;
4053 edje_object_part_text_input_panel_layout_set(wd->ent, "elm.text", layout);
4056 EAPI Elm_Input_Panel_Layout
4057 elm_entry_input_panel_layout_get(Evas_Object *obj)
4059 ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LAYOUT_INVALID;
4060 Widget_Data *wd = elm_widget_data_get(obj);
4061 if (!wd) return ELM_INPUT_PANEL_LAYOUT_INVALID;
4063 return wd->input_panel_layout;
4067 elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type)
4069 ELM_CHECK_WIDTYPE(obj, widtype);
4070 Widget_Data *wd = elm_widget_data_get(obj);
4073 wd->autocapital_type = autocapital_type;
4074 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", autocapital_type);
4077 EAPI Elm_Autocapital_Type
4078 elm_entry_autocapital_type_get(Evas_Object *obj)
4080 ELM_CHECK_WIDTYPE(obj, widtype) ELM_AUTOCAPITAL_TYPE_NONE;
4081 Widget_Data *wd = elm_widget_data_get(obj);
4082 if (!wd) return ELM_AUTOCAPITAL_TYPE_NONE;
4084 return wd->autocapital_type;
4088 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4090 ELM_CHECK_WIDTYPE(obj, widtype);
4091 Widget_Data *wd = elm_widget_data_get(obj);
4094 wd->input_panel_enable = enabled;
4095 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4098 EINA_DEPRECATED EAPI void
4099 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
4101 if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR);
4105 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4107 ELM_CHECK_WIDTYPE(obj, widtype);
4108 Widget_Data *wd = elm_widget_data_get(obj);
4109 evas_object_color_set(wd->bg, r, g, b, a);
4111 if (wd->bgcolor == EINA_FALSE)
4114 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
4119 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
4121 ELM_CHECK_WIDTYPE(obj, widtype);
4122 Widget_Data *wd = elm_widget_data_get(obj);
4126 wd->autocapital_type = ELM_AUTOCAPITAL_TYPE_SENTENCE;
4128 wd->autocapital_type = ELM_AUTOCAPITAL_TYPE_NONE;
4130 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4131 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4132 wd->autocapital_type = ELM_AUTOCAPITAL_TYPE_NONE;
4134 edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type);
4138 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
4140 ELM_CHECK_WIDTYPE(obj, widtype);
4141 Widget_Data *wd = elm_widget_data_get(obj);
4145 wd->autoperiod = EINA_FALSE;
4147 wd->autoperiod = autoperiod;
4149 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
4150 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
4151 wd->autoperiod = EINA_FALSE;
4153 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
4157 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
4159 ELM_CHECK_WIDTYPE(obj, widtype);
4160 Widget_Data *wd = elm_widget_data_get(obj);
4163 wd->autoreturnkey = on;
4164 _check_enable_returnkey(obj);
4167 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
4169 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4170 Widget_Data *wd = elm_widget_data_get(obj);
4171 if (!wd || !wd->ent) return NULL;
4173 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
4177 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
4179 Widget_Data *wd = elm_widget_data_get(obj);
4184 Evas_Coord max_w = 9999, max_h = 9999;
4185 const char* key_data = NULL;
4187 wd->matchlist_threshold = 1;
4188 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
4189 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
4190 elm_hover_target_set(wd->hover, obj);
4191 elm_object_style_set(wd->hover, "matchlist");
4193 wd->layout = elm_layout_add(wd->hover);
4194 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
4195 wd->list = elm_list_add(wd->layout);
4196 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
4197 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
4198 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
4199 elm_object_style_set(wd->list, "matchlist");
4201 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
4202 if (key_data) max_w = atoi(key_data);
4203 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
4204 if (key_data) max_h = atoi(key_data);
4206 elm_list_go(wd->list);
4207 evas_object_size_hint_max_set(wd->list, max_w, max_h);
4208 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
4209 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
4210 elm_hover_content_set(wd->hover, "bottom", wd->layout);
4212 wd->match_list = match_list;
4217 evas_object_del(wd->hover);
4219 wd->match_list = NULL;
4222 wd->matchlist_case_sensitive = case_sensitive;
4226 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4228 ELM_CHECK_WIDTYPE(obj, widtype);
4229 Widget_Data *wd = elm_widget_data_get(obj);
4232 wd->mgf_type = type;
4233 _magnifier_create(obj);
4237 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
4239 Widget_Data *wd = elm_widget_data_get(obj);
4241 if (wd->wrap_w == w) return;
4247 elm_entry_wrap_width_get(const Evas_Object *obj)
4249 Widget_Data *wd = elm_widget_data_get(obj);
4255 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
4257 ELM_CHECK_WIDTYPE(obj, widtype);
4258 Widget_Data *wd = elm_widget_data_get(obj);
4259 Eina_Strbuf *fontbuf = NULL;
4264 t = eina_stringshare_add(elm_entry_entry_get(obj));
4265 fontbuf = eina_strbuf_new();
4266 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
4268 if (fontsize == 0) removeflag = 1; // remove fontsize tag
4270 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
4272 elm_entry_entry_set(obj, t);
4276 eina_strbuf_free(fontbuf);
4277 eina_stringshare_del(t);
4281 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
4283 ELM_CHECK_WIDTYPE(obj, widtype);
4284 Widget_Data *wd = elm_widget_data_get(obj);
4285 Eina_Strbuf *colorbuf = NULL;
4290 t = eina_stringshare_add(elm_entry_entry_get(obj));
4292 if (len <= 0) return;
4293 colorbuf = eina_strbuf_new();
4294 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
4296 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
4298 elm_entry_entry_set(obj, t);
4302 eina_strbuf_free(colorbuf);
4303 eina_stringshare_del(t);
4307 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
4309 ELM_CHECK_WIDTYPE(obj, widtype);
4310 Widget_Data *wd = elm_widget_data_get(obj);
4315 t = eina_stringshare_add(elm_entry_entry_get(obj));
4317 if (len <= 0) return;
4319 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
4320 elm_entry_entry_set(obj, t);
4324 eina_stringshare_del(t);