2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
4 #include <Elementary.h>
6 #include "elm_module_priv.h"
8 * @defgroup Entry Entry
11 * An entry is a convenience widget which shows
12 * a box that the user can enter text into. Unlike a
13 * @ref Scrolled_Entry widget, entries DO NOT scroll with user
14 * input. Entry widgets are capable of expanding past the
15 * boundaries of the window, thus resizing the window to its
18 * You can also insert "items" in the entry with:
20 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
22 * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
23 * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
24 * supports a list of emoticon names by default. These are:
27 * - emoticon/angry-shout
28 * - emoticon/crazy-laugh
29 * - emoticon/evil-laugh
31 * - emoticon/goggle-smile
33 * - emoticon/grumpy-smile
35 * - emoticon/guilty-smile
37 * - emoticon/half-smile
38 * - emoticon/happy-panting
40 * - emoticon/indifferent
42 * - emoticon/knowing-grin
44 * - emoticon/little-bit-sorry
45 * - emoticon/love-lots
47 * - emoticon/minimal-smile
48 * - emoticon/not-happy
49 * - emoticon/not-impressed
51 * - emoticon/opensmile
54 * - emoticon/squint-laugh
55 * - emoticon/surprised
56 * - emoticon/suspicious
57 * - emoticon/tongue-dangling
58 * - emoticon/tongue-poke
61 * - emoticon/very-sorry
67 * These are built-in currently, but you can add your own item provieer that
68 * can create inlined objects in the text and fill the space allocated to the
69 * item with a custom object of your own.
71 * See the entry test for some more examples of use of this.
73 * Signals that you can add callbacks for are:
74 * - "changed" - The text within the entry was changed
75 * - "activated" - The entry has had editing finished and changes are to be committed (generally when enter key is pressed)
76 * - "press" - The entry has been clicked
77 * - "longpressed" - The entry has been clicked for a couple seconds
78 * - "clicked" - The entry has been clicked
79 * - "clicked,double" - The entry has been double clicked
80 * - "focused" - The entry has received focus
81 * - "unfocused" - The entry has lost focus
82 * - "selection,paste" - A paste action has occurred
83 * - "selection,copy" - A copy action has occurred
84 * - "selection,cut" - A cut action has occurred
85 * - "selection,start" - A selection has begun
86 * - "selection,changed" - The selection has changed
87 * - "selection,cleared" - The selection has been cleared
88 * - "cursor,changed" - The cursor has changed
89 * - "anchor,clicked" - The anchor has been clicked
92 typedef struct _Mod_Api Mod_Api;
94 typedef struct _Widget_Data Widget_Data;
95 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
100 Evas_Object *popup;/*copy paste UI - elm_popup*/
101 Evas_Object *ctxpopup;/*copy paste UI - elm_ctxpopup*/
103 Evas_Object *hoversel;
104 Ecore_Job *deferred_recalc_job;
105 Ecore_Event_Handler *sel_notify_handler;
106 Ecore_Event_Handler *sel_clear_handler;
107 Ecore_Timer *longpress_timer;
108 /* Only for clipboard */
112 int ellipsis_threshold;
114 Evas_Coord downx, downy;
115 Evas_Coord cx, cy, cw, ch;
117 Eina_List *item_providers;
118 Ecore_Job *hovdeljob;
119 Mod_Api *api; // module api if supplied
121 Eina_Bool changed : 1;
122 Eina_Bool linewrap : 1;
123 Eina_Bool char_linewrap : 1;
124 Eina_Bool single_line : 1;
125 Eina_Bool password : 1;
126 Eina_Bool show_last_character : 1;
127 Eina_Bool editable : 1;
128 Eina_Bool selection_asked : 1;
129 Eina_Bool have_selection : 1;
130 Eina_Bool selmode : 1;
131 Eina_Bool deferred_cur : 1;
132 Eina_Bool disabled : 1;
133 Eina_Bool double_clicked : 1;
134 Eina_Bool context_menu : 1;
135 Eina_Bool drag_selection_asked : 1;
136 Eina_Bool bgcolor : 1;
137 Eina_Bool ellipsis : 1;
138 Eina_Bool autoreturnkey : 1;
139 Eina_Bool input_panel_enable : 1;
140 Eina_Bool autocapital : 1;
141 Elm_Input_Panel_Layout input_panel_layout;
142 Eina_Bool autoperiod : 1;
145 struct _Elm_Entry_Item_Provider
147 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
151 static const char *widtype = NULL;
153 static Evas_Object *cnpwidgetdata = NULL;
156 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
157 static void _del_hook(Evas_Object *obj);
158 static void _theme_hook(Evas_Object *obj);
159 static void _disable_hook(Evas_Object *obj);
160 static void _sizing_eval(Evas_Object *obj);
161 static void _on_focus_hook(void *data, Evas_Object *obj);
162 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
163 static const char *_getbase(Evas_Object *obj);
164 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
165 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
166 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
167 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
168 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
169 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
170 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
171 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
172 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
173 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
174 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
175 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
176 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
177 static int _is_width_over(Evas_Object *obj);
178 static void _ellipsis_entry_to_width(Evas_Object *obj);
179 static void _reverse_ellipsis_entry(Evas_Object *obj);
180 static int _textinput_control_function(void *data,void *input_data);
181 static int _entry_length_get(Evas_Object *obj);
183 static const char SIG_CHANGED[] = "changed";
184 static const char SIG_ACTIVATED[] = "activated";
185 static const char SIG_PRESS[] = "press";
186 static const char SIG_LONGPRESSED[] = "longpressed";
187 static const char SIG_CLICKED[] = "clicked";
188 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
189 static const char SIG_FOCUSED[] = "focused";
190 static const char SIG_UNFOCUSED[] = "unfocused";
191 static const char SIG_SELECTION_PASTE[] = "selection,paste";
192 static const char SIG_SELECTION_COPY[] = "selection,copy";
193 static const char SIG_SELECTION_CUT[] = "selection,cut";
194 static const char SIG_SELECTION_START[] = "selection,start";
195 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
196 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
197 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
198 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
199 #ifdef HAVE_CONFORMANT_AUTOSCROLL
200 static const char SIG_IMPREGION_CHANGED[] = "impregion,changed";
202 static const Evas_Smart_Cb_Description _signals[] = {
206 {SIG_LONGPRESSED, ""},
208 {SIG_CLICKED_DOUBLE, ""},
211 {SIG_SELECTION_PASTE, ""},
212 {SIG_SELECTION_COPY, ""},
213 {SIG_SELECTION_CUT, ""},
214 {SIG_SELECTION_START, ""},
215 {SIG_SELECTION_CHANGED, ""},
216 {SIG_SELECTION_CLEARED, ""},
217 {SIG_CURSOR_CHANGED, ""},
218 {SIG_ANCHOR_CLICKED, ""},
222 static Eina_List *entries = NULL;
226 void (*obj_hook) (Evas_Object *obj);
227 void (*obj_unhook) (Evas_Object *obj);
228 void (*obj_longpress) (Evas_Object *obj);
229 void (*obj_mouseup) (Evas_Object *obj);
233 _module(Evas_Object *obj __UNUSED__)
235 static Elm_Module *m = NULL;
236 if (m) goto ok; // already found - just use
237 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
239 m->api = malloc(sizeof(Mod_Api));
240 if (!m->api) return NULL;
241 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
242 _elm_module_symbol_get(m, "obj_hook");
243 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
244 _elm_module_symbol_get(m, "obj_unhook");
245 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
246 _elm_module_symbol_get(m, "obj_longpress");
247 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
248 _elm_module_symbol_get(m, "obj_mouseup");
249 ok: // ok - return api
254 _del_hook(Evas_Object *obj)
256 Widget_Data *wd = elm_widget_data_get(obj);
257 Elm_Entry_Context_Menu_Item *it;
258 Elm_Entry_Item_Provider *ip;
260 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
261 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
263 entries = eina_list_remove(entries, obj);
264 #ifdef HAVE_ELEMENTARY_X
265 ecore_event_handler_del(wd->sel_notify_handler);
266 ecore_event_handler_del(wd->sel_clear_handler);
268 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
269 if (wd->text) eina_stringshare_del(wd->text);
270 if (wd->bg) evas_object_del(wd->bg);
271 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
272 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
273 EINA_LIST_FREE(wd->items, it)
275 eina_stringshare_del(it->label);
276 eina_stringshare_del(it->icon_file);
277 eina_stringshare_del(it->icon_group);
280 EINA_LIST_FREE(wd->item_providers, ip)
288 _theme_hook(Evas_Object *obj)
290 Widget_Data *wd = elm_widget_data_get(obj);
292 Ecore_IMF_Context *ic;
294 t = eina_stringshare_add(elm_entry_entry_get(obj));
295 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
296 elm_entry_entry_set(obj, t);
297 eina_stringshare_del(t);
298 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
299 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
300 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
301 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
303 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
306 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
313 _disable_hook(Evas_Object *obj)
315 Widget_Data *wd = elm_widget_data_get(obj);
317 if (elm_widget_disabled_get(obj))
319 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
320 wd->disabled = EINA_TRUE;
324 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
325 wd->disabled = EINA_FALSE;
330 _elm_win_recalc_job(void *data)
332 Widget_Data *wd = elm_widget_data_get(data);
333 Evas_Coord minw = -1, minh = -1, maxh = -1;
334 Evas_Coord resw, resh, minminw;
336 wd->deferred_recalc_job = NULL;
337 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
340 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
341 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
343 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
344 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
345 evas_object_size_hint_min_set(data, minminw, minh);
346 if (wd->single_line) maxh = minh;
347 evas_object_size_hint_max_set(data, -1, maxh);
348 if (wd->deferred_cur)
349 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
353 _sizing_eval(Evas_Object *obj)
355 Widget_Data *wd = elm_widget_data_get(obj);
356 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
357 Evas_Coord resw, resh;
359 if (wd->linewrap || wd->char_linewrap)
361 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
362 if ((resw == wd->lastw) && (!wd->changed)) return;
363 wd->changed = EINA_FALSE;
365 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
366 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
370 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
371 edje_object_size_min_calc(wd->ent, &minw, &minh);
372 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
373 evas_object_size_hint_min_set(obj, minw, minh);
374 if (wd->single_line) maxh = minh;
375 evas_object_size_hint_max_set(obj, maxw, maxh);
377 if (wd->ellipsis && wd->single_line)
379 if (_is_width_over(obj))
380 _ellipsis_entry_to_width(obj);
381 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
382 _reverse_ellipsis_entry(obj);
388 _check_enable_returnkey(Evas_Object *obj)
390 Widget_Data *wd = elm_widget_data_get(obj);
393 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
396 if (!wd->autoreturnkey) return;
398 if (_entry_length_get(obj) == 0)
400 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
404 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
408 #ifdef HAVE_CONFORMANT_AUTOSCROLL
410 _imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
412 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
413 Widget_Data *wd = elm_widget_data_get(obj);
414 if (!wd) return NULL;
415 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
426 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
428 Widget_Data *wd = elm_widget_data_get(obj);
429 Evas_Object *top = elm_widget_top_get(obj);
430 Evas_Object *parent_obj = obj;
433 if (!wd->editable) return;
434 if (elm_widget_focus_get(obj))
436 evas_object_focus_set(wd->ent, EINA_TRUE);
437 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
439 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
440 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
441 _check_enable_returnkey(obj);
445 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
446 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
447 evas_object_focus_set(wd->ent, EINA_FALSE);
448 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
449 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
454 parent_obj = elm_widget_parent_get(parent_obj);
455 if (!parent_obj) break;
457 evas_object_raise(parent_obj);
461 evas_object_raise(obj);
465 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
467 Widget_Data *wd = elm_widget_data_get(obj);
469 edje_object_signal_emit(wd->ent, emission, source);
473 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
475 Widget_Data *wd = elm_widget_data_get(obj);
477 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
481 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source))
483 Widget_Data *wd = elm_widget_data_get(obj);
484 if (!wd) return NULL;
485 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
489 _hoversel_position(Evas_Object *obj)
491 Widget_Data *wd = elm_widget_data_get(obj);
492 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
494 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
495 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
497 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
508 evas_object_move(wd->hoversel, x + cx, y + cy);
509 evas_object_resize(wd->hoversel, cw, ch);
513 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
515 Widget_Data *wd = elm_widget_data_get(data);
517 if (wd->hoversel) _hoversel_position(data);
521 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
523 Widget_Data *wd = elm_widget_data_get(data);
525 if (wd->linewrap || wd->char_linewrap)
529 if (wd->hoversel) _hoversel_position(data);
530 // Evas_Coord ww, hh;
531 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
535 _hover_del(void *data)
537 Widget_Data *wd = elm_widget_data_get(data);
542 evas_object_del(wd->hoversel);
545 wd->hovdeljob = NULL;
549 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
551 Widget_Data *wd = elm_widget_data_get(data);
553 if (wd->hoversel) evas_object_hide(wd->hoversel);
557 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
559 elm_widget_scroll_freeze_pop(data);
560 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
561 wd->hovdeljob = ecore_job_add(_hover_del, data);
565 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
567 Widget_Data *wd = elm_widget_data_get(data);
569 wd->selmode = EINA_TRUE;
570 edje_object_part_text_select_none(wd->ent, "elm.text");
572 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
573 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
574 //elm_widget_scroll_hold_push(data);
578 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
580 Widget_Data *wd = elm_widget_data_get(data);
582 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
583 if (wd->sel_notify_handler)
585 #ifdef HAVE_ELEMENTARY_X
586 wd->selection_asked = EINA_TRUE;
587 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
593 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
595 Widget_Data *wd = elm_widget_data_get(obj);
599 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
600 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
601 if (seltype == ELM_SEL_CLIPBOARD)
602 eina_stringshare_replace(&wd->cut_sel, sel);
606 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
608 Widget_Data *wd = elm_widget_data_get(data);
611 wd->selmode = EINA_FALSE;
612 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
613 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
614 elm_widget_scroll_hold_pop(data);
615 _store_selection(ELM_SEL_CLIPBOARD, data);
616 edje_object_part_text_insert(wd->ent, "elm.text", "");
617 edje_object_part_text_select_none(wd->ent, "elm.text");
621 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
623 Widget_Data *wd = elm_widget_data_get(data);
625 wd->selmode = EINA_FALSE;
626 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
627 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
628 elm_widget_scroll_hold_pop(data);
629 _store_selection(ELM_SEL_CLIPBOARD, data);
630 edje_object_part_text_select_none(wd->ent, "elm.text");
634 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
636 Widget_Data *wd = elm_widget_data_get(data);
638 wd->selmode = EINA_FALSE;
639 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
640 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
641 elm_widget_scroll_hold_pop(data);
642 edje_object_part_text_select_none(wd->ent, "elm.text");
646 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
648 Widget_Data *wd = elm_widget_data_get(data);
652 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
653 cnpwidgetdata = data;
654 elm_cbhm_helper_init(obj);
655 elm_cbhm_send_raw_data("show");
661 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
663 Widget_Data *wd = elm_widget_data_get(data);
665 cnpwidgetdata = data;
671 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
673 Elm_Entry_Context_Menu_Item *it = data;
674 Evas_Object *obj2 = it->obj;
676 if (it->func) it->func(it->data, obj2, NULL);
680 _long_press(void *data)
682 Widget_Data *wd = elm_widget_data_get(data);
685 const Elm_Entry_Context_Menu_Item *it;
686 if (!wd) return ECORE_CALLBACK_CANCEL;
688 if (wd->longpress_timer)
690 ecore_timer_del(wd->longpress_timer);
691 wd->longpress_timer = NULL;
694 if ((wd->api) && (wd->api->obj_longpress))
696 wd->api->obj_longpress(data);
698 else if (wd->context_menu)
700 const char *context_menu_orientation;
702 if (wd->hoversel) evas_object_del(wd->hoversel);
703 else elm_widget_scroll_freeze_push(data);
704 wd->hoversel = elm_hoversel_add(data);
705 context_menu_orientation = edje_object_data_get
706 (wd->ent, "context_menu_orientation");
707 if ((context_menu_orientation) &&
708 (!strcmp(context_menu_orientation, "horizontal")))
709 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
710 elm_object_style_set(wd->hoversel, "entry");
711 elm_widget_sub_object_add(data, wd->hoversel);
712 elm_hoversel_label_set(wd->hoversel, "Text");
713 top = elm_widget_top_get(data);
714 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
715 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
719 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
721 if (1) // need way to detect if someone has a selection
724 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
729 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
730 _clipboard_menu, data);
737 if (wd->have_selection)
739 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
742 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
745 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
748 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
749 _clipboard_menu, data);
753 EINA_LIST_FOREACH(wd->items, l, it)
755 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
756 it->icon_type, _item_clicked, it);
760 _hoversel_position(data);
761 evas_object_show(wd->hoversel);
762 elm_hoversel_hover_begin(wd->hoversel);
764 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
765 edje_object_part_text_select_abort(wd->ent, "elm.text");
767 wd->longpress_timer = NULL;
768 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
769 return ECORE_CALLBACK_CANCEL;
773 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
775 Widget_Data *wd = elm_widget_data_get(data);
776 Evas_Event_Mouse_Down *ev = event_info;
778 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
779 if (ev->button != 1) return;
780 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
781 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
782 wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
783 wd->downx = ev->canvas.x;
784 wd->downy = ev->canvas.y;
788 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
790 Widget_Data *wd = elm_widget_data_get(data);
791 Evas_Event_Mouse_Up *ev = event_info;
793 if (ev->button != 1) return;
795 if (!wd->double_clicked)
797 if ((wd->api) && (wd->api->obj_mouseup))
799 wd->api->obj_mouseup(data);
802 if (wd->longpress_timer)
804 ecore_timer_del(wd->longpress_timer);
805 wd->longpress_timer = NULL;
810 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
812 Widget_Data *wd = elm_widget_data_get(data);
813 Evas_Event_Mouse_Move *ev = event_info;
817 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
819 if (wd->longpress_timer)
821 ecore_timer_del(wd->longpress_timer);
822 wd->longpress_timer = NULL;
825 else if (wd->longpress_timer)
829 dx = wd->downx - ev->cur.canvas.x;
831 dy = wd->downy - ev->cur.canvas.y;
834 ((_elm_config->finger_size / 2) *
835 (_elm_config->finger_size / 2)))
837 ecore_timer_del(wd->longpress_timer);
838 wd->longpress_timer = NULL;
842 else if (wd->longpress_timer)
846 dx = wd->downx - ev->cur.canvas.x;
848 dy = wd->downy - ev->cur.canvas.y;
851 ((_elm_config->finger_size / 2) *
852 (_elm_config->finger_size / 2)))
854 ecore_timer_del(wd->longpress_timer);
855 wd->longpress_timer = NULL;
861 _getbase(Evas_Object *obj)
863 Widget_Data *wd = elm_widget_data_get(obj);
864 if (!wd) return "base";
869 if (wd->show_last_character) return "custom-password";
870 else return "base-password";
874 if (wd->single_line) return "base-single";
877 if (wd->linewrap) return "base";
878 else if (wd->char_linewrap) return "base-charwrap";
879 else return "base-nowrap";
887 if (wd->show_last_character) return "custom-password";
888 else return "base-password";
892 if (wd->single_line) return "base-single-noedit";
895 if (wd->linewrap) return "base-noedit";
896 else if (wd->char_linewrap) return "base-noedit-charwrap";
897 else return "base-nowrap-noedit";
905 _str_append(char *str, const char *txt, int *len, int *alloc)
907 int txt_len = strlen(txt);
909 if (txt_len <= 0) return str;
910 if ((*len + txt_len) >= *alloc)
915 alloc2 = *alloc + txt_len + 128;
916 str2 = realloc(str, alloc2);
917 if (!str2) return str;
921 strcpy(str + *len, txt);
926 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
927 * because some markups can be implemented otherwise according to style.
928 * probably doing it in textblock and making it translate according to it's
929 * style is correct. */
931 _strncpy(char* dest, const char* src, size_t count)
935 ERR( "dest is NULL" );
940 ERR( "src is NULL" );
945 ERR( "count is smaller than 0" );
949 return strncpy( dest, src, count );
953 _mkup_to_text(const char *mkup)
956 int str_len = 0, str_alloc = 0;
958 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
960 if (!mkup) return NULL;
962 tag_start = tag_end = esc_start = esc_end = NULL;
967 if (((p!=NULL)&&(*p == 0)) ||
968 (tag_end) || (esc_end) ||
969 (tag_start) || (esc_start))
975 ttag = malloc(tag_end - tag_start);
978 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
979 ttag[tag_end - tag_start - 1] = 0;
980 if (!strcmp(ttag, "br"))
981 str = _str_append(str, "\n", &str_len, &str_alloc);
982 else if (!strcmp(ttag, "\n"))
983 str = _str_append(str, "\n", &str_len, &str_alloc);
984 else if (!strcmp(ttag, "\\n"))
985 str = _str_append(str, "\n", &str_len, &str_alloc);
986 else if (!strcmp(ttag, "\t"))
987 str = _str_append(str, "\t", &str_len, &str_alloc);
988 else if (!strcmp(ttag, "\\t"))
989 str = _str_append(str, "\t", &str_len, &str_alloc);
990 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
991 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
994 tag_start = tag_end = NULL;
998 ts = malloc(esc_end - esc_start + 1);
1002 _strncpy(ts, esc_start, esc_end - esc_start);
1003 ts[esc_end - esc_start] = 0;
1004 esc = evas_textblock_escape_string_get(ts);
1006 str = _str_append(str, esc, &str_len, &str_alloc);
1009 esc_start = esc_end = NULL;
1011 else if ((p!=NULL)&&(*p == 0))
1013 ts = malloc(p - s + 1);
1016 _strncpy(ts, s, p - s);
1018 str = _str_append(str, ts, &str_len, &str_alloc);
1024 if ((p!=NULL)&&(*p == '<'))
1030 ts = malloc(p - s + 1);
1033 _strncpy(ts, s, p - s);
1035 str = _str_append(str, ts, &str_len, &str_alloc);
1041 else if ((p!=NULL)&&(*p == '>'))
1049 else if ((p!=NULL)&&(*p == '&'))
1055 ts = malloc(p - s + 1);
1058 _strncpy(ts, s, p - s);
1060 str = _str_append(str, ts, &str_len, &str_alloc);
1066 else if ((p!=NULL)&&(*p == ';'))
1080 _entry_length_get(Evas_Object *obj)
1083 const char *str = elm_entry_entry_get(obj);
1086 char *plain_str = _mkup_to_text(str);
1087 if (!plain_str) return 0;
1089 len = strlen(plain_str);
1096 _text_to_mkup(const char *text)
1099 int str_len = 0, str_alloc = 0;
1100 int ch, pos = 0, pos2 = 0;
1102 if (!text) return NULL;
1106 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1107 if ((ch <= 0) || (pos2 <= 0)) break;
1109 str = _str_append(str, "<br>", &str_len, &str_alloc);
1110 else if (ch == '\t')
1111 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1113 str = _str_append(str, "<", &str_len, &str_alloc);
1115 str = _str_append(str, ">", &str_len, &str_alloc);
1117 str = _str_append(str, "&", &str_len, &str_alloc);
1118 else if (ch == 0x2029)
1119 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1124 _strncpy(tstr, text + pos, pos2 - pos);
1125 tstr[pos2 - pos] = 0;
1126 str = _str_append(str, tstr, &str_len, &str_alloc);
1133 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1135 Widget_Data *wd = elm_widget_data_get(data);
1137 wd->changed = EINA_TRUE;
1139 if (wd->text) eina_stringshare_del(wd->text);
1141 _check_enable_returnkey(data);
1142 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1146 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1148 Widget_Data *wd = elm_widget_data_get(data);
1149 elm_object_scroll_freeze_push(data);
1153 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1155 Widget_Data *wd = elm_widget_data_get(data);
1156 elm_object_scroll_freeze_pop(data);
1160 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1162 Widget_Data *wd = elm_widget_data_get(data);
1166 EINA_LIST_FOREACH(entries, l, entry)
1168 if (entry != data) elm_entry_select_none(entry);
1170 wd->have_selection = EINA_TRUE;
1171 wd->selmode = EINA_TRUE;
1172 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1173 #ifdef HAVE_ELEMENTARY_X
1174 if (wd->sel_notify_handler)
1176 const char *txt = elm_entry_selection_get(data);
1179 top = elm_widget_top_get(data);
1180 if ((top) && (elm_win_xwindow_get(top)))
1181 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1187 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1189 Evas_Coord cx, cy, cw, ch;
1190 Widget_Data *wd = elm_widget_data_get(data);
1192 wd->have_selection = EINA_TRUE;
1193 wd->selmode = EINA_TRUE;
1194 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1195 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1196 elm_entry_selection_get(data));
1198 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1199 if (!wd->deferred_recalc_job)
1200 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1203 wd->deferred_cur = EINA_TRUE;
1207 wd->ch = ch + elm_finger_size_get();
1212 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1214 Widget_Data *wd = elm_widget_data_get(data);
1216 if (!wd->have_selection) return;
1217 wd->have_selection = EINA_FALSE;
1218 wd->selmode = EINA_FALSE;
1219 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1220 if (wd->sel_notify_handler)
1224 #ifdef HAVE_ELEMENTARY_X
1227 top = elm_widget_top_get(data);
1228 if ((top) && (elm_win_xwindow_get(top)))
1229 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1232 eina_stringshare_del(wd->cut_sel);
1237 #ifdef HAVE_ELEMENTARY_X
1240 top = elm_widget_top_get(data);
1241 if ((top) && (elm_win_xwindow_get(top)))
1242 elm_selection_clear(ELM_SEL_PRIMARY, data);
1249 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1251 Widget_Data *wd = elm_widget_data_get(data);
1253 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1254 if (wd->sel_notify_handler)
1256 #ifdef HAVE_ELEMENTARY_X
1259 top = elm_widget_top_get(data);
1260 if ((top) && (elm_win_xwindow_get(top)))
1262 wd->selection_asked = EINA_TRUE;
1263 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1270 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1272 Widget_Data *wd = elm_widget_data_get(data);
1274 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1275 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1276 elm_entry_selection_get(data));
1280 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1282 Widget_Data *wd = elm_widget_data_get(data);
1284 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1285 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1286 elm_entry_selection_get(data));
1287 edje_object_part_text_insert(wd->ent, "elm.text", "");
1288 wd->changed = EINA_TRUE;
1293 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1295 Widget_Data *wd = elm_widget_data_get(data);
1296 Evas_Coord cx, cy, cw, ch;
1298 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1299 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1300 &cx, &cy, &cw, &ch);
1301 if (!wd->deferred_recalc_job)
1302 elm_widget_show_region_set(data, cx, cy, cw, ch);
1305 wd->deferred_cur = EINA_TRUE;
1311 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1312 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1317 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1319 Widget_Data *wd = elm_widget_data_get(data);
1324 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1326 Widget_Data *wd = elm_widget_data_get(data);
1327 Elm_Entry_Anchor_Info ei;
1328 char *buf2, *p, *p2, *n;
1330 p = strrchr(emission, ',');
1333 const Eina_List *geoms;
1337 while (p2 >= emission)
1339 if (*p2 == ',') break;
1343 buf2 = alloca(5 + p - p2);
1344 strncpy(buf2, p2, p - p2);
1347 ei.button = atoi(buf2);
1348 ei.x = ei.y = ei.w = ei.h = 0;
1350 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1353 Evas_Textblock_Rectangle *r;
1355 Evas_Coord px, py, x, y;
1357 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1358 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1359 EINA_LIST_FOREACH(geoms, l, r)
1361 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1362 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1373 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1378 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1380 Widget_Data *wd = elm_widget_data_get(data);
1385 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1387 Widget_Data *wd = elm_widget_data_get(data);
1392 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1394 Widget_Data *wd = elm_widget_data_get(data);
1399 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1401 Widget_Data *wd = elm_widget_data_get(data);
1403 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1407 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1409 Widget_Data *wd = elm_widget_data_get(data);
1411 wd->double_clicked = EINA_FALSE;
1412 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1416 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1418 Widget_Data *wd = elm_widget_data_get(data);
1420 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1424 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1426 Widget_Data *wd = elm_widget_data_get(data);
1428 wd->double_clicked = EINA_TRUE;
1429 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1432 #ifdef HAVE_ELEMENTARY_X
1434 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1436 Widget_Data *wd = elm_widget_data_get(data);
1437 Ecore_X_Event_Selection_Notify *ev = event;
1438 if (!wd) return ECORE_CALLBACK_PASS_ON;
1439 if (!wd->selection_asked && !wd->drag_selection_asked)
1440 return ECORE_CALLBACK_PASS_ON;
1442 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1443 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1445 Ecore_X_Selection_Data_Text *text_data;
1447 text_data = ev->data;
1448 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1450 if (text_data->text)
1452 char *txt = _text_to_mkup(text_data->text);
1456 elm_entry_entry_insert(data, txt);
1461 wd->selection_asked = EINA_FALSE;
1463 else if (ev->selection == ECORE_X_SELECTION_XDND)
1465 Ecore_X_Selection_Data_Text *text_data;
1467 text_data = ev->data;
1468 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1470 if (text_data->text)
1472 char *txt = _text_to_mkup(text_data->text);
1476 /* Massive FIXME: this should be at the drag point */
1477 elm_entry_entry_insert(data, txt);
1482 wd->drag_selection_asked = EINA_FALSE;
1484 ecore_x_dnd_send_finished();
1488 return ECORE_CALLBACK_PASS_ON;
1492 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1495 Widget_Data *wd = elm_widget_data_get(data);
1496 Ecore_X_Event_Selection_Clear *ev = event;
1497 if (!wd) return ECORE_CALLBACK_PASS_ON;
1498 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1499 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1500 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1502 elm_entry_select_none(data);
1507 Evas_Object *top = elm_widget_top_get(data);
1508 Ecore_X_Event_Selection_Clear *ev = event;
1511 return ECORE_CALLBACK_PASS_ON;
1513 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1515 return ECORE_CALLBACK_PASS_ON;
1518 if (cnpwidgetdata == data)
1520 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1524 return ECORE_CALLBACK_PASS_ON;
1529 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1534 wd = elm_widget_data_get(obj);
1536 if (!wd) return EINA_FALSE;
1537 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1539 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1540 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1541 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1542 EDJE_CURSOR_MAIN,drop->x,drop->y);
1543 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1544 elm_entry_entry_insert(obj, drop->data);
1545 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1546 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1552 static Evas_Object *
1553 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1555 Widget_Data *wd = elm_widget_data_get(data);
1558 Elm_Entry_Item_Provider *ip;
1561 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1563 o = ip->func(ip->data, data, item);
1566 o = edje_object_add(evas_object_evas_get(data));
1567 if (!strncmp(item, "emoticon/", 9))
1568 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1570 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1575 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1577 char *curlocater, *starttag, *endtag;
1578 int firstindex = 0, foundflag = -1;
1580 curlocater = strstr(oldstring, key);
1583 starttag = curlocater;
1584 endtag = curlocater + strlen(key);
1585 if (endtag == NULL || *endtag != '=')
1591 firstindex = abs(oldstring - curlocater);
1592 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1593 *value = (char*)oldstring + firstindex;
1595 while (oldstring != starttag)
1597 if (*starttag == '>')
1602 if (*starttag == '<')
1606 if (starttag == NULL) break;
1609 while (NULL != endtag)
1620 if (endtag == NULL) break;
1623 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1633 if (foundflag == 1) return 0;
1639 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1641 const char *srcstring = NULL;
1642 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1643 char *curlocater, *replocater;
1644 char *starttag, *endtag;
1645 int tagtxtlen = 0, insertflag = 0;
1647 srcstring = eina_strbuf_string_get(srcbuf);
1648 curlocater = strstr(srcstring, key);
1650 if (curlocater == NULL)
1658 starttag = strchr(srcstring, '<');
1659 endtag = strchr(srcstring, '>');
1660 tagtxtlen = endtag - starttag;
1661 if (tagtxtlen <= 0) tagtxtlen = 0;
1662 if (starttag < curlocater && curlocater < endtag) break;
1663 if (endtag != NULL && endtag+1 != NULL)
1664 srcstring = endtag+1;
1667 } while (strlen(srcstring) > 1);
1669 if (starttag && endtag && tagtxtlen > strlen(key))
1671 repbuf = eina_strbuf_new();
1672 diffbuf = eina_strbuf_new();
1673 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1674 srcstring = eina_strbuf_string_get(repbuf);
1675 curlocater = strstr(srcstring, key);
1677 if (curlocater != NULL)
1679 replocater = curlocater + strlen(key) + 1;
1681 while (*replocater == ' ' || *replocater == '=')
1686 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1689 if (replocater-curlocater > strlen(key)+1)
1692 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1701 eina_strbuf_reset(repbuf);
1709 if (repbuf == NULL) repbuf = eina_strbuf_new();
1710 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1714 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1715 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1721 eina_strbuf_prepend(diffbuf, "<");
1722 eina_strbuf_append(diffbuf, ">");
1723 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1727 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1728 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1732 if (repbuf) eina_strbuf_free(repbuf);
1733 if (diffbuf) eina_strbuf_free(diffbuf);
1739 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1741 Eina_Strbuf *sharebuf = NULL;
1743 sharebuf = eina_strbuf_new();
1744 eina_strbuf_append(sharebuf, *srcstring);
1745 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1746 eina_stringshare_del(*srcstring);
1747 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1748 eina_strbuf_free(sharebuf);
1754 _is_width_over(Evas_Object *obj)
1756 Evas_Coord x, y, w, h;
1757 Evas_Coord vx, vy, vw, vh;
1758 Widget_Data *wd = elm_widget_data_get(obj);
1762 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1764 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1766 if (x >= 0 && y >= 0)
1769 if (4 < wd->wrap_w && w > wd->wrap_w)
1776 _reverse_ellipsis_entry(Evas_Object *obj)
1778 Widget_Data *wd = elm_widget_data_get(obj);
1779 int cur_fontsize = 0;
1780 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1781 char **kvalue = NULL;
1782 const char *minfont, *deffont, *maxfont;
1783 const char *ellipsis_string = "...";
1784 int minfontsize, maxfontsize, minshowcount;
1786 minshowcount = strlen(ellipsis_string) + 1;
1787 minfont = edje_object_data_get(wd->ent, "min_font_size");
1788 if (minfont) minfontsize = atoi(minfont);
1789 else minfontsize = 1;
1790 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1791 if (maxfont) maxfontsize = atoi(maxfont);
1792 else maxfontsize = 1;
1793 deffont = edje_object_data_get(wd->ent, "default_font_size");
1794 if (deffont) cur_fontsize = atoi(deffont);
1795 else cur_fontsize = 1;
1796 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1797 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1799 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1801 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1804 txtbuf = eina_strbuf_new();
1805 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1807 if (cur_fontsize >= atoi(deffont))
1809 if (txtbuf) eina_strbuf_free(txtbuf);
1813 if (_is_width_over(obj) != 1)
1815 int rev_fontsize = cur_fontsize;
1819 if (rev_fontsize > atoi(deffont))
1822 if (fontbuf != NULL)
1824 eina_strbuf_free(fontbuf);
1827 fontbuf = eina_strbuf_new();
1828 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1829 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1830 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1832 eina_strbuf_free(fontbuf);
1834 } while (_is_width_over(obj) != 1);
1836 while (_is_width_over(obj))
1839 if (rev_fontsize < atoi(deffont))
1842 if (fontbuf != NULL)
1844 eina_strbuf_free(fontbuf);
1847 fontbuf = eina_strbuf_new();
1848 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1849 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1850 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1851 eina_strbuf_free(fontbuf);
1856 if (txtbuf) eina_strbuf_free(txtbuf);
1862 _ellipsis_entry_to_width(Evas_Object *obj)
1864 Widget_Data *wd = elm_widget_data_get(obj);
1865 int cur_fontsize = 0, len, jumpcount;
1866 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1867 char **kvalue = NULL;
1868 const char *minfont, *deffont, *maxfont;
1869 const char *ellipsis_string = "...";
1870 int minfontsize, maxfontsize, minshowcount;
1871 int i, tagend, cur_len;
1874 minshowcount = strlen(ellipsis_string) + 1;
1875 minfont = edje_object_data_get(wd->ent, "min_font_size");
1876 if (minfont) minfontsize = atoi(minfont);
1877 else minfontsize = 1;
1878 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1879 if (maxfont) maxfontsize = atoi(maxfont);
1880 else maxfontsize = 1;
1881 deffont = edje_object_data_get(wd->ent, "default_font_size");
1882 if (deffont) cur_fontsize = atoi(deffont);
1883 else cur_fontsize = 1;
1884 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1885 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1887 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1889 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1892 txtbuf = eina_strbuf_new();
1893 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1895 while (_is_width_over(obj))
1897 if (wd->ellipsis_threshold == 0)
1898 wd->ellipsis_threshold = _entry_length_get(obj);
1899 if (cur_fontsize > minfontsize)
1902 if (fontbuf != NULL)
1904 eina_strbuf_free(fontbuf);
1907 fontbuf = eina_strbuf_new();
1908 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1909 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1910 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1911 eina_strbuf_free(fontbuf);
1913 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1917 len = _entry_length_get(obj);
1918 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1919 cur_len = strlen(cur_str);
1921 for (i = 0; i < len; i++)
1923 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1924 cur_str[i+1] != '<')
1931 while (jumpcount < len-strlen(ellipsis_string))
1933 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1937 eina_strbuf_free(txtbuf);
1940 txtbuf = eina_strbuf_new();
1941 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1942 eina_strbuf_append(txtbuf, ellipsis_string);
1943 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1944 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1945 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1947 if (_is_width_over(obj))
1955 if (txtbuf) eina_strbuf_free(txtbuf);
1960 static int _textinput_control_function(void *data,void *input_data)
1962 /*calculate character count*/
1963 Evas_Object *entry = (Evas_Object *)data;
1964 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
1967 size_t insert_text_len=0;
1968 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1970 size_t remain_bytes;
1973 byte_len = strlen(text);/*no of bytes*/
1974 remain_bytes = wd->max_no_of_bytes-byte_len;
1975 sprintf(buf,"%d",remain_bytes);
1976 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1979 insert_text = (char *)input_data;
1980 insert_text_len = strlen(insert_text);
1981 if(remain_bytes<insert_text_len)
1983 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1986 if(byte_len>=wd->max_no_of_bytes)
1988 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1997 * This adds an entry to @p parent object.
1999 * @param parent The parent object
2000 * @return The new object or NULL if it cannot be created
2005 elm_entry_add(Evas_Object *parent)
2007 Evas_Object *obj, *top;
2011 wd = ELM_NEW(Widget_Data);
2012 e = evas_object_evas_get(parent);
2013 wd->bgcolor = EINA_FALSE;
2014 wd->bg = evas_object_rectangle_add(e);
2015 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2016 obj = elm_widget_add(e);
2017 ELM_SET_WIDTYPE(widtype, "entry");
2018 elm_widget_type_set(obj, "entry");
2019 elm_widget_sub_object_add(parent, obj);
2020 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2021 elm_widget_data_set(obj, wd);
2022 elm_widget_del_hook_set(obj, _del_hook);
2023 elm_widget_theme_hook_set(obj, _theme_hook);
2024 elm_widget_disable_hook_set(obj, _disable_hook);
2025 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2026 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2027 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2028 elm_widget_can_focus_set(obj, 1);
2029 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2030 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2033 wd->linewrap = EINA_TRUE;
2034 wd->ellipsis = EINA_FALSE;
2035 wd->char_linewrap= EINA_FALSE;
2036 wd->editable = EINA_TRUE;
2037 wd->disabled = EINA_FALSE;
2038 wd->context_menu = EINA_TRUE;
2039 wd->autoperiod = EINA_TRUE;
2041 wd->ellipsis_threshold = 0;
2043 wd->ent = edje_object_add(e);
2044 edje_object_item_provider_set(wd->ent, _get_item, obj);
2045 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2046 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2047 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2049 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2051 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2054 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2055 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2056 _signal_entry_changed, obj);
2057 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2058 _signal_handler_move_start, obj);
2059 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2060 _signal_handler_move_end, obj);
2061 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2062 _signal_selection_start, obj);
2063 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2064 _signal_selection_changed, obj);
2065 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2066 _signal_selection_cleared, obj);
2067 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2068 _signal_entry_paste_request, obj);
2069 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2070 _signal_entry_copy_notify, obj);
2071 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2072 _signal_entry_cut_notify, obj);
2073 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2074 _signal_cursor_changed, obj);
2075 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2076 _signal_anchor_down, obj);
2077 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2078 _signal_anchor_up, obj);
2079 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2080 _signal_anchor_move, obj);
2081 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2082 _signal_anchor_in, obj);
2083 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2084 _signal_anchor_out, obj);
2085 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2086 _signal_key_enter, obj);
2087 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2088 _signal_mouse_down, obj);
2089 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2090 _signal_mouse_up, obj);
2091 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2092 _signal_mouse_double, obj);
2093 edje_object_part_text_set(wd->ent, "elm.text", "");
2094 elm_widget_resize_object_set(obj, wd->ent);
2097 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2099 #ifdef HAVE_ELEMENTARY_X
2100 top = elm_widget_top_get(obj);
2101 if ((top) && (elm_win_xwindow_get(top)))
2103 wd->sel_notify_handler =
2104 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2105 _event_selection_notify, obj);
2106 wd->sel_clear_handler =
2107 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2108 _event_selection_clear, obj);
2111 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2114 entries = eina_list_prepend(entries, obj);
2116 // module - find module for entry
2117 wd->api = _module(obj);
2118 // if found - hook in
2119 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2121 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2122 // TODO: and save some bytes, making descriptions per-class and not instance!
2123 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2127 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2129 ELM_CHECK_WIDTYPE(obj, widtype);
2130 Widget_Data *wd = elm_widget_data_get(obj);
2132 ext_mod->cancel = _cancel;
2133 ext_mod->copy = _copy;
2134 ext_mod->cut = _cut;
2135 ext_mod->paste = _paste;
2136 ext_mod->select = _select;
2137 ext_mod->selectall = NULL; /* to be implemented*/
2138 ext_mod->ent = wd->ent;
2139 ext_mod->items = wd->items;
2140 ext_mod->longpress_timer = wd->longpress_timer;
2141 ext_mod->editable = wd->editable;
2142 ext_mod->have_selection = wd->have_selection;
2143 ext_mod->password = wd->password;
2144 ext_mod->selmode = wd->selmode;
2145 ext_mod->cnpinit = _cnpinit;
2146 ext_mod->context_menu = wd->context_menu;
2150 * This sets the entry object not to line wrap. All input will
2151 * be on a single line, and the entry box will extend with user input.
2153 * @param obj The entry object
2154 * @param single_line If true, the text in the entry
2155 * will be on a single line.
2160 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2162 ELM_CHECK_WIDTYPE(obj, widtype);
2163 Widget_Data *wd = elm_widget_data_get(obj);
2165 Ecore_IMF_Context *ic;
2167 if (wd->single_line == single_line) return;
2168 wd->single_line = single_line;
2169 wd->linewrap = EINA_FALSE;
2170 wd->char_linewrap = EINA_FALSE;
2171 t = eina_stringshare_add(elm_entry_entry_get(obj));
2172 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2173 elm_entry_entry_set(obj, t);
2174 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2175 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2176 ic = elm_entry_imf_context_get(obj);
2179 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2182 eina_stringshare_del(t);
2187 * This returns true if the entry has been set to single line mode.
2188 * See also elm_entry_single_line_set().
2190 * @param obj The entry object
2191 * @return single_line If true, the text in the entry is set to display
2197 elm_entry_single_line_get(const Evas_Object *obj)
2199 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2200 Widget_Data *wd = elm_widget_data_get(obj);
2201 if (!wd) return EINA_FALSE;
2202 return wd->single_line;
2206 * This set's the maximum bytes that can be added in entry.
2208 * @param obj The entry object
2209 * @param max_no_of_bytes Maximum number of bytes entry can have.
2214 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2216 Widget_Data *wd = elm_widget_data_get(obj);
2218 wd->max_no_of_bytes = max_no_of_bytes;
2219 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2220 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2225 * This sets the entry object to password mode. All text entered
2226 * and/or displayed within the widget will be replaced with asterisks (*).
2228 * @param obj The entry object
2229 * @param password If true, password mode is enabled.
2234 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2236 ELM_CHECK_WIDTYPE(obj, widtype);
2237 Widget_Data *wd = elm_widget_data_get(obj);
2238 Ecore_IMF_Context *ic;
2241 if (wd->password == password) return;
2242 wd->password = password;
2243 wd->single_line = EINA_TRUE;
2244 wd->linewrap = EINA_FALSE;
2245 wd->char_linewrap = EINA_FALSE;
2246 if (_elm_config->password_show_last_character)
2247 wd->show_last_character = EINA_TRUE;
2248 t = eina_stringshare_add(elm_entry_entry_get(obj));
2249 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2250 elm_entry_entry_set(obj, t);
2256 elm_entry_autoperiod_set(obj, EINA_FALSE);
2259 if (wd->autocapital)
2261 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2265 ic = elm_entry_imf_context_get(obj);
2268 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2271 eina_stringshare_del(t);
2276 * This set's the entry in password mode with out masking the last character entered by user,
2277 * and later masking the character after 2 seconds.
2279 * @param obj The entry object
2280 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2286 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2288 Widget_Data *wd = elm_widget_data_get(obj);
2291 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2292 wd->show_last_character = show_last_character;
2293 wd->password = show_last_character;
2294 wd->single_line = EINA_TRUE;
2295 wd->linewrap = EINA_FALSE;
2296 wd->char_linewrap = EINA_FALSE;
2297 t = eina_stringshare_add(elm_entry_entry_get(obj));
2298 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2299 elm_entry_entry_set(obj, t);
2300 eina_stringshare_del(t);
2305 * This returns whether password mode is enabled.
2306 * See also elm_entry_password_set().
2308 * @param obj The entry object
2309 * @return If true, the entry is set to display all characters
2315 elm_entry_password_get(const Evas_Object *obj)
2317 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2318 Widget_Data *wd = elm_widget_data_get(obj);
2319 if (!wd) return EINA_FALSE;
2320 return wd->password;
2324 * This sets the text displayed within the entry to @p entry.
2326 * @param obj The entry object
2327 * @param entry The text to be displayed
2332 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2334 ELM_CHECK_WIDTYPE(obj, widtype);
2335 Widget_Data *wd = elm_widget_data_get(obj);
2337 if (!entry) entry = "";
2338 if(wd->max_no_of_bytes)
2340 int len = strlen(entry);
2341 if(len > wd->max_no_of_bytes)
2343 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2347 edje_object_part_text_set(wd->ent, "elm.text", entry);
2348 if (wd->text) eina_stringshare_del(wd->text);
2350 wd->changed = EINA_TRUE;
2355 * This returns the text currently shown in object @p entry.
2356 * See also elm_entry_entry_set().
2358 * @param obj The entry object
2359 * @return The currently displayed text or NULL on failure
2364 elm_entry_entry_get(const Evas_Object *obj)
2366 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2367 Widget_Data *wd = elm_widget_data_get(obj);
2369 if (!wd) return NULL;
2371 if ((wd->text)&&(wd->password))
2372 return elm_entry_markup_to_utf8(wd->text);
2374 if (wd->text) return wd->text;
2375 text = edje_object_part_text_get(wd->ent, "elm.text");
2378 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2381 eina_stringshare_replace(&wd->text, text);
2382 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2387 * This returns all selected text within the entry.
2389 * @param obj The entry object
2390 * @return The selected text within the entry or NULL on failure
2395 elm_entry_selection_get(const Evas_Object *obj)
2397 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2398 Widget_Data *wd = elm_widget_data_get(obj);
2399 if (!wd) return NULL;
2400 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2404 * This inserts text in @p entry at the beginning of the entry
2407 * @param obj The entry object
2408 * @param entry The text to insert
2413 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2415 ELM_CHECK_WIDTYPE(obj, widtype);
2416 Widget_Data *wd = elm_widget_data_get(obj);
2418 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2420 if (cnpwidgetdata == obj)
2421 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2423 wd->changed = EINA_TRUE;
2428 * This enables word line wrapping in the entry object. It is the opposite
2429 * of elm_entry_single_line_set(). Additionally, setting this disables
2430 * character line wrapping.
2431 * See also elm_entry_line_char_wrap_set().
2433 * @param obj The entry object
2434 * @param wrap If true, the entry will be wrapped once it reaches the end
2435 * of the object. Wrapping will occur at the end of the word before the end of the
2441 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2443 ELM_CHECK_WIDTYPE(obj, widtype);
2444 Widget_Data *wd = elm_widget_data_get(obj);
2447 if (wd->linewrap == wrap) return;
2448 wd->linewrap = wrap;
2450 wd->char_linewrap = EINA_FALSE;
2451 t = eina_stringshare_add(elm_entry_entry_get(obj));
2452 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2453 elm_entry_entry_set(obj, t);
2454 eina_stringshare_del(t);
2459 * Set wrap width of the entry
2461 * @param obj The entry object
2462 * @param w The wrap width in pixels at a minimum where words need to wrap
2466 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2468 Widget_Data *wd = elm_widget_data_get(obj);
2469 if (wd->wrap_w == w) return;
2475 * get wrap width of the entry
2477 * @param obj The entry object
2478 * @return The wrap width in pixels at a minimum where words need to wrap
2482 elm_entry_wrap_width_get(const Evas_Object *obj)
2484 Widget_Data *wd = elm_widget_data_get(obj);
2489 * This enables character line wrapping in the entry object. It is the opposite
2490 * of elm_entry_single_line_set(). Additionally, setting this disables
2491 * word line wrapping.
2492 * See also elm_entry_line_wrap_set().
2494 * @param obj The entry object
2495 * @param wrap If true, the entry will be wrapped once it reaches the end
2496 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2501 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2503 ELM_CHECK_WIDTYPE(obj, widtype);
2504 Widget_Data *wd = elm_widget_data_get(obj);
2507 if (wd->char_linewrap == wrap) return;
2508 wd->char_linewrap = wrap;
2509 if(wd->char_linewrap)
2510 wd->linewrap = EINA_FALSE;
2511 t = eina_stringshare_add(elm_entry_entry_get(obj));
2512 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2513 elm_entry_entry_set(obj, t);
2514 eina_stringshare_del(t);
2519 * This sets the editable attribute of the entry.
2521 * @param obj The entry object
2522 * @param editable If true, the entry will be editable by the user.
2523 * If false, it will be set to the disabled state.
2528 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2530 ELM_CHECK_WIDTYPE(obj, widtype);
2531 Widget_Data *wd = elm_widget_data_get(obj);
2534 if (wd->editable == editable) return;
2535 wd->editable = editable;
2536 t = eina_stringshare_add(elm_entry_entry_get(obj));
2537 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2538 elm_entry_entry_set(obj, t);
2539 eina_stringshare_del(t);
2542 #ifdef HAVE_ELEMENTARY_X
2544 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2546 elm_drop_target_del(obj);
2551 * This gets the editable attribute of the entry.
2552 * See also elm_entry_editable_set().
2554 * @param obj The entry object
2555 * @return If true, the entry is editable by the user.
2556 * If false, it is not editable by the user
2561 elm_entry_editable_get(const Evas_Object *obj)
2563 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2564 Widget_Data *wd = elm_widget_data_get(obj);
2565 if (!wd) return EINA_FALSE;
2566 return wd->editable;
2570 * This drops any existing text selection within the entry.
2572 * @param obj The entry object
2577 elm_entry_select_none(Evas_Object *obj)
2579 ELM_CHECK_WIDTYPE(obj, widtype);
2580 Widget_Data *wd = elm_widget_data_get(obj);
2584 wd->selmode = EINA_FALSE;
2585 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2586 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2588 wd->have_selection = EINA_FALSE;
2589 edje_object_part_text_select_none(wd->ent, "elm.text");
2593 * This selects all text within the entry.
2595 * @param obj The entry object
2600 elm_entry_select_all(Evas_Object *obj)
2602 ELM_CHECK_WIDTYPE(obj, widtype);
2603 Widget_Data *wd = elm_widget_data_get(obj);
2607 wd->selmode = EINA_FALSE;
2608 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2609 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2611 wd->have_selection = EINA_TRUE;
2612 edje_object_part_text_select_all(wd->ent, "elm.text");
2616 * This moves the cursor one place to the right within the entry.
2618 * @param obj The entry object
2619 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2624 elm_entry_cursor_next(Evas_Object *obj)
2626 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2627 Widget_Data *wd = elm_widget_data_get(obj);
2628 if (!wd) return EINA_FALSE;
2629 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2633 * This moves the cursor one place to the left within the entry.
2635 * @param obj The entry object
2636 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2641 elm_entry_cursor_prev(Evas_Object *obj)
2643 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2644 Widget_Data *wd = elm_widget_data_get(obj);
2645 if (!wd) return EINA_FALSE;
2646 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2650 * This moves the cursor one line up within the entry.
2652 * @param obj The entry object
2653 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2658 elm_entry_cursor_up(Evas_Object *obj)
2660 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2661 Widget_Data *wd = elm_widget_data_get(obj);
2662 if (!wd) return EINA_FALSE;
2663 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2667 * This moves the cursor one line down within the entry.
2669 * @param obj The entry object
2670 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2675 elm_entry_cursor_down(Evas_Object *obj)
2677 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2678 Widget_Data *wd = elm_widget_data_get(obj);
2679 if (!wd) return EINA_FALSE;
2680 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2684 * This moves the cursor to the beginning of the entry.
2686 * @param obj The entry object
2691 elm_entry_cursor_begin_set(Evas_Object *obj)
2693 ELM_CHECK_WIDTYPE(obj, widtype);
2694 Widget_Data *wd = elm_widget_data_get(obj);
2696 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2700 * This moves the cursor to the end of the entry.
2702 * @param obj The entry object
2707 elm_entry_cursor_end_set(Evas_Object *obj)
2709 ELM_CHECK_WIDTYPE(obj, widtype);
2710 Widget_Data *wd = elm_widget_data_get(obj);
2712 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2716 * This moves the cursor to the beginning of the current line.
2718 * @param obj The entry object
2723 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2725 ELM_CHECK_WIDTYPE(obj, widtype);
2726 Widget_Data *wd = elm_widget_data_get(obj);
2728 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2732 * This moves the cursor to the end of the current line.
2734 * @param obj The entry object
2739 elm_entry_cursor_line_end_set(Evas_Object *obj)
2741 ELM_CHECK_WIDTYPE(obj, widtype);
2742 Widget_Data *wd = elm_widget_data_get(obj);
2744 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2748 * This begins a selection within the entry as though
2749 * the user were holding down the mouse button to make a selection.
2751 * @param obj The entry object
2756 elm_entry_cursor_selection_begin(Evas_Object *obj)
2758 ELM_CHECK_WIDTYPE(obj, widtype);
2759 Widget_Data *wd = elm_widget_data_get(obj);
2761 edje_object_part_text_select_begin(wd->ent, "elm.text");
2765 * This ends a selection within the entry as though
2766 * the user had just released the mouse button while making a selection.
2768 * @param obj The entry object
2773 elm_entry_cursor_selection_end(Evas_Object *obj)
2775 ELM_CHECK_WIDTYPE(obj, widtype);
2776 Widget_Data *wd = elm_widget_data_get(obj);
2778 edje_object_part_text_select_extend(wd->ent, "elm.text");
2782 * TODO: fill this in
2784 * @param obj The entry object
2785 * @return TODO: fill this in
2790 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2792 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2793 Widget_Data *wd = elm_widget_data_get(obj);
2794 if (!wd) return EINA_FALSE;
2795 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2799 * This returns whether the cursor is visible.
2801 * @param obj The entry object
2802 * @return If true, the cursor is visible.
2807 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2809 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2810 Widget_Data *wd = elm_widget_data_get(obj);
2811 if (!wd) return EINA_FALSE;
2812 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2816 * TODO: fill this in
2818 * @param obj The entry object
2819 * @return TODO: fill this in
2824 elm_entry_cursor_content_get(const Evas_Object *obj)
2826 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2827 Widget_Data *wd = elm_widget_data_get(obj);
2828 if (!wd) return NULL;
2829 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2833 * This executes a "cut" action on the selected text in the entry.
2835 * @param obj The entry object
2840 elm_entry_selection_cut(Evas_Object *obj)
2842 ELM_CHECK_WIDTYPE(obj, widtype);
2843 Widget_Data *wd = elm_widget_data_get(obj);
2845 _cut(obj, NULL, NULL);
2849 * This executes a "copy" action on the selected text in the entry.
2851 * @param obj The entry object
2856 elm_entry_selection_copy(Evas_Object *obj)
2858 ELM_CHECK_WIDTYPE(obj, widtype);
2859 Widget_Data *wd = elm_widget_data_get(obj);
2861 _copy(obj, NULL, NULL);
2865 * This executes a "paste" action in the entry.
2867 * @param obj The entry object
2872 elm_entry_selection_paste(Evas_Object *obj)
2874 ELM_CHECK_WIDTYPE(obj, widtype);
2875 Widget_Data *wd = elm_widget_data_get(obj);
2877 _paste(obj, NULL, NULL);
2881 * This clears and frees the items in a entry's contextual (right click) menu.
2883 * @param obj The entry object
2888 elm_entry_context_menu_clear(Evas_Object *obj)
2890 ELM_CHECK_WIDTYPE(obj, widtype);
2891 Widget_Data *wd = elm_widget_data_get(obj);
2892 Elm_Entry_Context_Menu_Item *it;
2894 EINA_LIST_FREE(wd->items, it)
2896 eina_stringshare_del(it->label);
2897 eina_stringshare_del(it->icon_file);
2898 eina_stringshare_del(it->icon_group);
2904 * This adds an item to the entry's contextual menu.
2906 * @param obj The entry object
2907 * @param label The item's text label
2908 * @param icon_file The item's icon file
2909 * @param icon_type The item's icon type
2910 * @param func The callback to execute when the item is clicked
2911 * @param data The data to associate with the item for related functions
2916 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)
2918 ELM_CHECK_WIDTYPE(obj, widtype);
2919 Widget_Data *wd = elm_widget_data_get(obj);
2920 Elm_Entry_Context_Menu_Item *it;
2922 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2924 wd->items = eina_list_append(wd->items, it);
2926 it->label = eina_stringshare_add(label);
2927 it->icon_file = eina_stringshare_add(icon_file);
2928 it->icon_type = icon_type;
2930 it->data = (void *)data;
2934 * This disables the entry's contextual (right click) menu.
2936 * @param obj The entry object
2937 * @param disabled If true, the menu is disabled
2942 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2944 ELM_CHECK_WIDTYPE(obj, widtype);
2945 Widget_Data *wd = elm_widget_data_get(obj);
2947 if (wd->context_menu == !disabled) return;
2948 wd->context_menu = !disabled;
2952 * This returns whether the entry's contextual (right click) menu is disabled.
2954 * @param obj The entry object
2955 * @return If true, the menu is disabled
2960 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2962 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2963 Widget_Data *wd = elm_widget_data_get(obj);
2964 if (!wd) return EINA_FALSE;
2965 return !wd->context_menu;
2969 * This appends a custom item provider to the list for that entry
2971 * This appends the given callback. The list is walked from beginning to end
2972 * with each function called given the item href string in the text. If the
2973 * function returns an object handle other than NULL (it should create an
2974 * and object to do this), then this object is used to replace that item. If
2975 * not the next provider is called until one provides an item object, or the
2976 * default provider in entry does.
2978 * @param obj The entry object
2979 * @param func The function called to provide the item object
2980 * @param data The data passed to @p func
2985 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2987 ELM_CHECK_WIDTYPE(obj, widtype);
2988 Widget_Data *wd = elm_widget_data_get(obj);
2991 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2995 wd->item_providers = eina_list_append(wd->item_providers, ip);
2999 * This prepends a custom item provider to the list for that entry
3001 * This prepends the given callback. See elm_entry_item_provider_append() for
3004 * @param obj The entry object
3005 * @param func The function called to provide the item object
3006 * @param data The data passed to @p func
3011 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3013 ELM_CHECK_WIDTYPE(obj, widtype);
3014 Widget_Data *wd = elm_widget_data_get(obj);
3017 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3021 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3025 * This removes a custom item provider to the list for that entry
3027 * This removes the given callback. See elm_entry_item_provider_append() for
3030 * @param obj The entry object
3031 * @param func The function called to provide the item object
3032 * @param data The data passed to @p func
3037 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3039 ELM_CHECK_WIDTYPE(obj, widtype);
3040 Widget_Data *wd = elm_widget_data_get(obj);
3042 Elm_Entry_Item_Provider *ip;
3045 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3047 if ((ip->func == func) && (ip->data == data))
3049 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3057 * This converts a markup (HTML-like) string into UTF-8.
3059 * @param s The string (in markup) to be converted
3060 * @return The converted string (in UTF-8)
3065 elm_entry_markup_to_utf8(const char *s)
3067 char *ss = _mkup_to_text(s);
3068 if (!ss) ss = strdup("");
3073 * This converts a UTF-8 string into markup (HTML-like).
3075 * @param s The string (in UTF-8) to be converted
3076 * @return The converted string (in markup)
3081 elm_entry_utf8_to_markup(const char *s)
3083 char *ss = _text_to_mkup(s);
3084 if (!ss) ss = strdup("");
3089 * Get the input method context in the entry widget
3091 * @param obj The entry object
3092 * @return The input method context
3096 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3098 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3099 Widget_Data *wd = elm_widget_data_get(obj);
3100 if (!wd || !wd->ent) return NULL;
3102 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3106 * Set whether entry should enable the return key on soft keyboard automatically
3108 * @param obj The entry object
3109 * @param on If true, entry enables the return key on soft keyboard automatically.
3114 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3116 ELM_CHECK_WIDTYPE(obj, widtype);
3117 Widget_Data *wd = elm_widget_data_get(obj);
3120 wd->autoreturnkey = on;
3121 _check_enable_returnkey(obj);
3125 * Set whether entry should support auto capitalization
3127 * @param obj The entry object
3128 * @param on If true, entry suports auto capitalization.
3133 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3135 ELM_CHECK_WIDTYPE(obj, widtype);
3136 Widget_Data *wd = elm_widget_data_get(obj);
3140 wd->autocapital = EINA_FALSE;
3142 wd->autocapital = autocap;
3144 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3145 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3146 wd->autocapital = EINA_FALSE;
3148 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3152 * Set whether entry should support auto period
3154 * @param obj The entry object
3155 * @param on If true, entry suports auto period.
3160 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3162 ELM_CHECK_WIDTYPE(obj, widtype);
3163 Widget_Data *wd = elm_widget_data_get(obj);
3167 wd->autoperiod = EINA_FALSE;
3169 wd->autoperiod = autoperiod;
3171 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3172 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3173 wd->autoperiod = EINA_FALSE;
3175 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3179 * Set the font size on the entry object
3181 * @param obj The entry object
3182 * @param size font size
3187 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3189 ELM_CHECK_WIDTYPE(obj, widtype);
3190 Widget_Data *wd = elm_widget_data_get(obj);
3191 Eina_Strbuf *fontbuf = NULL;
3196 t = eina_stringshare_add(elm_entry_entry_get(obj));
3197 fontbuf = eina_strbuf_new();
3198 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3200 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3202 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3204 elm_entry_entry_set(obj, t);
3208 eina_strbuf_free(fontbuf);
3209 eina_stringshare_del(t);
3213 * Set the text align on the entry object
3215 * @param obj The entry object
3216 * @param align align mode
3221 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3223 ELM_CHECK_WIDTYPE(obj, widtype);
3224 Widget_Data *wd = elm_widget_data_get(obj);
3229 t = eina_stringshare_add(elm_entry_entry_get(obj));
3231 if (len <= 0) return;
3233 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3234 elm_entry_entry_set(obj, t);
3238 eina_stringshare_del(t);
3242 * Set the text color on the entry object
3244 * @param obj The entry object
3245 * @param r Red property background color of The entry object
3246 * @param g Green property background color of The entry object
3247 * @param b Blue property background color of The entry object
3248 * @param a Alpha property background alpha of The entry object
3253 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3255 ELM_CHECK_WIDTYPE(obj, widtype);
3256 Widget_Data *wd = elm_widget_data_get(obj);
3257 Eina_Strbuf *colorbuf = NULL;
3262 t = eina_stringshare_add(elm_entry_entry_get(obj));
3264 if (len <= 0) return;
3265 colorbuf = eina_strbuf_new();
3266 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3268 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3270 elm_entry_entry_set(obj, t);
3274 eina_strbuf_free(colorbuf);
3275 eina_stringshare_del(t);
3280 * Set background color of the entry
3282 * @param obj The entry object
3283 * @param r Red property background color of The entry object
3284 * @param g Green property background color of The entry object
3285 * @param b Blue property background color of The entry object
3286 * @param a Alpha property background alpha of The entry object
3290 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3292 ELM_CHECK_WIDTYPE(obj, widtype);
3293 Widget_Data *wd = elm_widget_data_get(obj);
3294 evas_object_color_set(wd->bg, r, g, b, a);
3296 if (wd->bgcolor == EINA_FALSE)
3299 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3304 * Set the ellipsis behavior of the entry
3306 * @param obj The entry object
3307 * @param ellipsis To ellipsis text or not
3311 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3313 ELM_CHECK_WIDTYPE(obj, widtype);
3314 Widget_Data *wd = elm_widget_data_get(obj);
3315 if (wd->ellipsis == ellipsis) return;
3316 wd->ellipsis = ellipsis;
3322 * This sets the attribute to show the input panel automatically.
3324 * @param obj The entry object
3325 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3330 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3332 ELM_CHECK_WIDTYPE(obj, widtype);
3333 Widget_Data *wd = elm_widget_data_get(obj);
3336 wd->input_panel_enable = enabled;
3337 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3341 * Set the input panel layout of the entry
3343 * @param obj The entry object
3344 * @param layout the layout to set
3349 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3351 ELM_CHECK_WIDTYPE(obj, widtype);
3352 Widget_Data *wd = elm_widget_data_get(obj);
3355 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3358 wd->input_panel_layout = layout;
3360 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3363 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/