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;
259 Evas_Object *parent_obj = obj;
260 Evas_Object *above = NULL;
262 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
263 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
265 /* added for locating parents as they were */
268 above = evas_object_data_get(parent_obj, "raise");
270 evas_object_stack_below(parent_obj, above);
271 parent_obj = elm_widget_parent_get(parent_obj);
274 entries = eina_list_remove(entries, obj);
275 #ifdef HAVE_ELEMENTARY_X
276 ecore_event_handler_del(wd->sel_notify_handler);
277 ecore_event_handler_del(wd->sel_clear_handler);
279 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
280 if (wd->text) eina_stringshare_del(wd->text);
281 if (wd->bg) evas_object_del(wd->bg);
282 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
283 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
284 EINA_LIST_FREE(wd->items, it)
286 eina_stringshare_del(it->label);
287 eina_stringshare_del(it->icon_file);
288 eina_stringshare_del(it->icon_group);
291 EINA_LIST_FREE(wd->item_providers, ip)
299 _theme_hook(Evas_Object *obj)
301 Widget_Data *wd = elm_widget_data_get(obj);
303 Ecore_IMF_Context *ic;
305 t = eina_stringshare_add(elm_entry_entry_get(obj));
306 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
307 elm_entry_entry_set(obj, t);
308 eina_stringshare_del(t);
309 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
310 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
311 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
312 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
314 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
317 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
324 _disable_hook(Evas_Object *obj)
326 Widget_Data *wd = elm_widget_data_get(obj);
328 if (elm_widget_disabled_get(obj))
330 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
331 wd->disabled = EINA_TRUE;
335 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
336 wd->disabled = EINA_FALSE;
341 _elm_win_recalc_job(void *data)
343 Widget_Data *wd = elm_widget_data_get(data);
344 Evas_Coord minw = -1, minh = -1, maxh = -1;
345 Evas_Coord resw, resh, minminw;
347 wd->deferred_recalc_job = NULL;
348 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
351 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
352 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
354 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
355 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
356 evas_object_size_hint_min_set(data, minminw, minh);
357 if (wd->single_line) maxh = minh;
358 evas_object_size_hint_max_set(data, -1, maxh);
359 if (wd->deferred_cur)
360 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
364 _sizing_eval(Evas_Object *obj)
366 Widget_Data *wd = elm_widget_data_get(obj);
367 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
368 Evas_Coord resw, resh;
370 if (wd->linewrap || wd->char_linewrap)
372 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
373 if ((resw == wd->lastw) && (!wd->changed)) return;
374 wd->changed = EINA_FALSE;
376 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
377 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
381 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
382 edje_object_size_min_calc(wd->ent, &minw, &minh);
383 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
384 evas_object_size_hint_min_set(obj, minw, minh);
385 if (wd->single_line) maxh = minh;
386 evas_object_size_hint_max_set(obj, maxw, maxh);
388 if (wd->ellipsis && wd->single_line)
390 if (_is_width_over(obj))
391 _ellipsis_entry_to_width(obj);
392 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
393 _reverse_ellipsis_entry(obj);
399 _check_enable_returnkey(Evas_Object *obj)
401 Widget_Data *wd = elm_widget_data_get(obj);
404 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
407 if (!wd->autoreturnkey) return;
409 if (_entry_length_get(obj) == 0)
411 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
415 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
419 #ifdef HAVE_CONFORMANT_AUTOSCROLL
421 _imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
423 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
424 Widget_Data *wd = elm_widget_data_get(obj);
425 if (!wd) return NULL;
426 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
437 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
439 Widget_Data *wd = elm_widget_data_get(obj);
440 Evas_Object *top = elm_widget_top_get(obj);
441 Evas_Object *parent_obj = obj;
442 Evas_Object *above = NULL;
445 if (!wd->editable) return;
446 if (elm_widget_focus_get(obj))
448 evas_object_focus_set(wd->ent, EINA_TRUE);
449 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
451 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
452 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
453 _check_enable_returnkey(obj);
457 above = evas_object_above_get(parent_obj);
459 evas_object_data_set(parent_obj, "raise", above);
460 evas_object_raise(parent_obj);
461 parent_obj = elm_widget_parent_get(parent_obj);
467 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
468 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
469 evas_object_focus_set(wd->ent, EINA_FALSE);
470 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
471 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
475 above = evas_object_data_get(parent_obj, "raise");
477 evas_object_stack_below(parent_obj, above);
478 parent_obj = elm_widget_parent_get(parent_obj);
485 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
487 Widget_Data *wd = elm_widget_data_get(obj);
489 edje_object_signal_emit(wd->ent, emission, source);
493 _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)
495 Widget_Data *wd = elm_widget_data_get(obj);
497 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
501 _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))
503 Widget_Data *wd = elm_widget_data_get(obj);
504 if (!wd) return NULL;
505 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
509 _hoversel_position(Evas_Object *obj)
511 Widget_Data *wd = elm_widget_data_get(obj);
512 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
514 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
515 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
517 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
528 evas_object_move(wd->hoversel, x + cx, y + cy);
529 evas_object_resize(wd->hoversel, cw, ch);
533 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
535 Widget_Data *wd = elm_widget_data_get(data);
537 if (wd->hoversel) _hoversel_position(data);
541 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
543 Widget_Data *wd = elm_widget_data_get(data);
545 if (wd->linewrap || wd->char_linewrap)
549 if (wd->hoversel) _hoversel_position(data);
550 // Evas_Coord ww, hh;
551 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
555 _hover_del(void *data)
557 Widget_Data *wd = elm_widget_data_get(data);
562 evas_object_del(wd->hoversel);
565 wd->hovdeljob = NULL;
569 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
571 Widget_Data *wd = elm_widget_data_get(data);
573 if (wd->hoversel) evas_object_hide(wd->hoversel);
577 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
579 elm_widget_scroll_freeze_pop(data);
580 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
581 wd->hovdeljob = ecore_job_add(_hover_del, data);
585 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
587 Widget_Data *wd = elm_widget_data_get(data);
589 wd->selmode = EINA_TRUE;
590 edje_object_part_text_select_none(wd->ent, "elm.text");
592 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
593 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
594 //elm_widget_scroll_hold_push(data);
598 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
600 Widget_Data *wd = elm_widget_data_get(data);
602 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
603 if (wd->sel_notify_handler)
605 #ifdef HAVE_ELEMENTARY_X
606 wd->selection_asked = EINA_TRUE;
607 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
613 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
615 Widget_Data *wd = elm_widget_data_get(obj);
619 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
620 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
621 if (seltype == ELM_SEL_CLIPBOARD)
622 eina_stringshare_replace(&wd->cut_sel, sel);
626 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
628 Widget_Data *wd = elm_widget_data_get(data);
631 wd->selmode = EINA_FALSE;
632 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
633 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
634 elm_widget_scroll_hold_pop(data);
635 _store_selection(ELM_SEL_CLIPBOARD, data);
636 edje_object_part_text_insert(wd->ent, "elm.text", "");
637 edje_object_part_text_select_none(wd->ent, "elm.text");
641 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
643 Widget_Data *wd = elm_widget_data_get(data);
645 wd->selmode = EINA_FALSE;
646 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
647 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
648 elm_widget_scroll_hold_pop(data);
649 _store_selection(ELM_SEL_CLIPBOARD, data);
650 edje_object_part_text_select_none(wd->ent, "elm.text");
654 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
656 Widget_Data *wd = elm_widget_data_get(data);
658 wd->selmode = EINA_FALSE;
659 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
660 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
661 elm_widget_scroll_hold_pop(data);
662 edje_object_part_text_select_none(wd->ent, "elm.text");
666 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
668 Widget_Data *wd = elm_widget_data_get(data);
672 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
673 cnpwidgetdata = data;
674 elm_cbhm_helper_init(obj);
675 elm_cbhm_send_raw_data("show");
681 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
683 Widget_Data *wd = elm_widget_data_get(data);
685 cnpwidgetdata = data;
691 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
693 Elm_Entry_Context_Menu_Item *it = data;
694 Evas_Object *obj2 = it->obj;
696 if (it->func) it->func(it->data, obj2, NULL);
700 _long_press(void *data)
702 Widget_Data *wd = elm_widget_data_get(data);
705 const Elm_Entry_Context_Menu_Item *it;
706 if (!wd) return ECORE_CALLBACK_CANCEL;
708 if (wd->longpress_timer)
710 ecore_timer_del(wd->longpress_timer);
711 wd->longpress_timer = NULL;
714 if ((wd->api) && (wd->api->obj_longpress))
716 wd->api->obj_longpress(data);
718 else if (wd->context_menu)
720 const char *context_menu_orientation;
722 if (wd->hoversel) evas_object_del(wd->hoversel);
723 else elm_widget_scroll_freeze_push(data);
724 wd->hoversel = elm_hoversel_add(data);
725 context_menu_orientation = edje_object_data_get
726 (wd->ent, "context_menu_orientation");
727 if ((context_menu_orientation) &&
728 (!strcmp(context_menu_orientation, "horizontal")))
729 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
730 elm_object_style_set(wd->hoversel, "entry");
731 elm_widget_sub_object_add(data, wd->hoversel);
732 elm_hoversel_label_set(wd->hoversel, "Text");
733 top = elm_widget_top_get(data);
734 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
735 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
739 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
741 if (1) // need way to detect if someone has a selection
744 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
749 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
750 _clipboard_menu, data);
757 if (wd->have_selection)
759 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
762 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
765 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
768 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
769 _clipboard_menu, data);
773 EINA_LIST_FOREACH(wd->items, l, it)
775 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
776 it->icon_type, _item_clicked, it);
780 _hoversel_position(data);
781 evas_object_show(wd->hoversel);
782 elm_hoversel_hover_begin(wd->hoversel);
784 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
785 edje_object_part_text_select_abort(wd->ent, "elm.text");
787 wd->longpress_timer = NULL;
788 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
789 return ECORE_CALLBACK_CANCEL;
793 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
795 Widget_Data *wd = elm_widget_data_get(data);
796 Evas_Event_Mouse_Down *ev = event_info;
798 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
799 if (ev->button != 1) return;
800 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
801 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
802 wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
803 wd->downx = ev->canvas.x;
804 wd->downy = ev->canvas.y;
808 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
810 Widget_Data *wd = elm_widget_data_get(data);
811 Evas_Event_Mouse_Up *ev = event_info;
813 if (ev->button != 1) return;
815 if (!wd->double_clicked)
817 if ((wd->api) && (wd->api->obj_mouseup))
819 wd->api->obj_mouseup(data);
822 if (wd->longpress_timer)
824 ecore_timer_del(wd->longpress_timer);
825 wd->longpress_timer = NULL;
830 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
832 Widget_Data *wd = elm_widget_data_get(data);
833 Evas_Event_Mouse_Move *ev = event_info;
837 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
839 if (wd->longpress_timer)
841 ecore_timer_del(wd->longpress_timer);
842 wd->longpress_timer = NULL;
845 else if (wd->longpress_timer)
849 dx = wd->downx - ev->cur.canvas.x;
851 dy = wd->downy - ev->cur.canvas.y;
854 ((_elm_config->finger_size / 2) *
855 (_elm_config->finger_size / 2)))
857 ecore_timer_del(wd->longpress_timer);
858 wd->longpress_timer = NULL;
862 else if (wd->longpress_timer)
866 dx = wd->downx - ev->cur.canvas.x;
868 dy = wd->downy - ev->cur.canvas.y;
871 ((_elm_config->finger_size / 2) *
872 (_elm_config->finger_size / 2)))
874 ecore_timer_del(wd->longpress_timer);
875 wd->longpress_timer = NULL;
881 _getbase(Evas_Object *obj)
883 Widget_Data *wd = elm_widget_data_get(obj);
884 if (!wd) return "base";
889 if (wd->show_last_character) return "custom-password";
890 else return "base-password";
894 if (wd->single_line) return "base-single";
897 if (wd->linewrap) return "base";
898 else if (wd->char_linewrap) return "base-charwrap";
899 else return "base-nowrap";
907 if (wd->show_last_character) return "custom-password";
908 else return "base-password";
912 if (wd->single_line) return "base-single-noedit";
915 if (wd->linewrap) return "base-noedit";
916 else if (wd->char_linewrap) return "base-noedit-charwrap";
917 else return "base-nowrap-noedit";
925 _str_append(char *str, const char *txt, int *len, int *alloc)
927 int txt_len = strlen(txt);
929 if (txt_len <= 0) return str;
930 if ((*len + txt_len) >= *alloc)
935 alloc2 = *alloc + txt_len + 128;
936 str2 = realloc(str, alloc2);
937 if (!str2) return str;
941 strcpy(str + *len, txt);
946 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
947 * because some markups can be implemented otherwise according to style.
948 * probably doing it in textblock and making it translate according to it's
949 * style is correct. */
951 _strncpy(char* dest, const char* src, size_t count)
955 ERR( "dest is NULL" );
960 ERR( "src is NULL" );
965 ERR( "count is smaller than 0" );
969 return strncpy( dest, src, count );
973 _mkup_to_text(const char *mkup)
976 int str_len = 0, str_alloc = 0;
978 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
980 if (!mkup) return NULL;
982 tag_start = tag_end = esc_start = esc_end = NULL;
987 if (((p!=NULL)&&(*p == 0)) ||
988 (tag_end) || (esc_end) ||
989 (tag_start) || (esc_start))
995 ttag = malloc(tag_end - tag_start);
998 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
999 ttag[tag_end - tag_start - 1] = 0;
1000 if (!strcmp(ttag, "br"))
1001 str = _str_append(str, "\n", &str_len, &str_alloc);
1002 else if (!strcmp(ttag, "\n"))
1003 str = _str_append(str, "\n", &str_len, &str_alloc);
1004 else if (!strcmp(ttag, "\\n"))
1005 str = _str_append(str, "\n", &str_len, &str_alloc);
1006 else if (!strcmp(ttag, "\t"))
1007 str = _str_append(str, "\t", &str_len, &str_alloc);
1008 else if (!strcmp(ttag, "\\t"))
1009 str = _str_append(str, "\t", &str_len, &str_alloc);
1010 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
1011 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1014 tag_start = tag_end = NULL;
1018 ts = malloc(esc_end - esc_start + 1);
1022 _strncpy(ts, esc_start, esc_end - esc_start);
1023 ts[esc_end - esc_start] = 0;
1024 esc = evas_textblock_escape_string_get(ts);
1026 str = _str_append(str, esc, &str_len, &str_alloc);
1029 esc_start = esc_end = NULL;
1031 else if ((p!=NULL)&&(*p == 0))
1033 ts = malloc(p - s + 1);
1036 _strncpy(ts, s, p - s);
1038 str = _str_append(str, ts, &str_len, &str_alloc);
1044 if ((p!=NULL)&&(*p == '<'))
1050 ts = malloc(p - s + 1);
1053 _strncpy(ts, s, p - s);
1055 str = _str_append(str, ts, &str_len, &str_alloc);
1061 else if ((p!=NULL)&&(*p == '>'))
1069 else if ((p!=NULL)&&(*p == '&'))
1075 ts = malloc(p - s + 1);
1078 _strncpy(ts, s, p - s);
1080 str = _str_append(str, ts, &str_len, &str_alloc);
1086 else if ((p!=NULL)&&(*p == ';'))
1100 _entry_length_get(Evas_Object *obj)
1103 const char *str = elm_entry_entry_get(obj);
1106 char *plain_str = _mkup_to_text(str);
1107 if (!plain_str) return 0;
1109 len = strlen(plain_str);
1116 _text_to_mkup(const char *text)
1119 int str_len = 0, str_alloc = 0;
1120 int ch, pos = 0, pos2 = 0;
1122 if (!text) return NULL;
1126 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1127 if ((ch <= 0) || (pos2 <= 0)) break;
1129 str = _str_append(str, "<br>", &str_len, &str_alloc);
1130 else if (ch == '\t')
1131 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1133 str = _str_append(str, "<", &str_len, &str_alloc);
1135 str = _str_append(str, ">", &str_len, &str_alloc);
1137 str = _str_append(str, "&", &str_len, &str_alloc);
1138 else if (ch == 0x2029)
1139 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1144 _strncpy(tstr, text + pos, pos2 - pos);
1145 tstr[pos2 - pos] = 0;
1146 str = _str_append(str, tstr, &str_len, &str_alloc);
1153 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1155 Widget_Data *wd = elm_widget_data_get(data);
1157 wd->changed = EINA_TRUE;
1159 if (wd->text) eina_stringshare_del(wd->text);
1161 _check_enable_returnkey(data);
1162 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1166 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1168 Widget_Data *wd = elm_widget_data_get(data);
1169 elm_object_scroll_freeze_push(data);
1173 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1175 Widget_Data *wd = elm_widget_data_get(data);
1176 elm_object_scroll_freeze_pop(data);
1180 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1182 Widget_Data *wd = elm_widget_data_get(data);
1186 EINA_LIST_FOREACH(entries, l, entry)
1188 if (entry != data) elm_entry_select_none(entry);
1190 wd->have_selection = EINA_TRUE;
1191 wd->selmode = EINA_TRUE;
1192 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1193 #ifdef HAVE_ELEMENTARY_X
1194 if (wd->sel_notify_handler)
1196 const char *txt = elm_entry_selection_get(data);
1199 top = elm_widget_top_get(data);
1200 if ((top) && (elm_win_xwindow_get(top)))
1201 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1207 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1209 Evas_Coord cx, cy, cw, ch;
1210 Widget_Data *wd = elm_widget_data_get(data);
1212 wd->have_selection = EINA_TRUE;
1213 wd->selmode = EINA_TRUE;
1214 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1215 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1216 elm_entry_selection_get(data));
1218 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1219 if (!wd->deferred_recalc_job)
1220 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1223 wd->deferred_cur = EINA_TRUE;
1227 wd->ch = ch + elm_finger_size_get();
1232 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1234 Widget_Data *wd = elm_widget_data_get(data);
1236 if (!wd->have_selection) return;
1237 wd->have_selection = EINA_FALSE;
1238 wd->selmode = EINA_FALSE;
1239 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1240 if (wd->sel_notify_handler)
1244 #ifdef HAVE_ELEMENTARY_X
1247 top = elm_widget_top_get(data);
1248 if ((top) && (elm_win_xwindow_get(top)))
1249 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1252 eina_stringshare_del(wd->cut_sel);
1257 #ifdef HAVE_ELEMENTARY_X
1260 top = elm_widget_top_get(data);
1261 if ((top) && (elm_win_xwindow_get(top)))
1262 elm_selection_clear(ELM_SEL_PRIMARY, data);
1269 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1271 Widget_Data *wd = elm_widget_data_get(data);
1273 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1274 if (wd->sel_notify_handler)
1276 #ifdef HAVE_ELEMENTARY_X
1279 top = elm_widget_top_get(data);
1280 if ((top) && (elm_win_xwindow_get(top)))
1282 wd->selection_asked = EINA_TRUE;
1283 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1290 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1292 Widget_Data *wd = elm_widget_data_get(data);
1294 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1295 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1296 elm_entry_selection_get(data));
1300 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1302 Widget_Data *wd = elm_widget_data_get(data);
1304 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1305 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1306 elm_entry_selection_get(data));
1307 edje_object_part_text_insert(wd->ent, "elm.text", "");
1308 wd->changed = EINA_TRUE;
1313 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1315 Widget_Data *wd = elm_widget_data_get(data);
1316 Evas_Coord cx, cy, cw, ch;
1318 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1319 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1320 &cx, &cy, &cw, &ch);
1321 if (!wd->deferred_recalc_job)
1322 elm_widget_show_region_set(data, cx, cy, cw, ch);
1325 wd->deferred_cur = EINA_TRUE;
1331 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1332 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1337 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1339 Widget_Data *wd = elm_widget_data_get(data);
1344 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1346 Widget_Data *wd = elm_widget_data_get(data);
1347 Elm_Entry_Anchor_Info ei;
1348 char *buf2, *p, *p2, *n;
1350 p = strrchr(emission, ',');
1353 const Eina_List *geoms;
1357 while (p2 >= emission)
1359 if (*p2 == ',') break;
1363 buf2 = alloca(5 + p - p2);
1364 strncpy(buf2, p2, p - p2);
1367 ei.button = atoi(buf2);
1368 ei.x = ei.y = ei.w = ei.h = 0;
1370 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1373 Evas_Textblock_Rectangle *r;
1375 Evas_Coord px, py, x, y;
1377 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1378 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1379 EINA_LIST_FOREACH(geoms, l, r)
1381 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1382 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1393 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1398 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1400 Widget_Data *wd = elm_widget_data_get(data);
1405 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1407 Widget_Data *wd = elm_widget_data_get(data);
1412 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1414 Widget_Data *wd = elm_widget_data_get(data);
1419 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1421 Widget_Data *wd = elm_widget_data_get(data);
1423 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1427 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1429 Widget_Data *wd = elm_widget_data_get(data);
1431 wd->double_clicked = EINA_FALSE;
1432 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1436 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1438 Widget_Data *wd = elm_widget_data_get(data);
1440 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1444 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1446 Widget_Data *wd = elm_widget_data_get(data);
1448 wd->double_clicked = EINA_TRUE;
1449 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1452 #ifdef HAVE_ELEMENTARY_X
1454 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1456 Widget_Data *wd = elm_widget_data_get(data);
1457 Ecore_X_Event_Selection_Notify *ev = event;
1458 if (!wd) return ECORE_CALLBACK_PASS_ON;
1459 if (!wd->selection_asked && !wd->drag_selection_asked)
1460 return ECORE_CALLBACK_PASS_ON;
1462 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1463 (ev->selection == ECORE_X_SELECTION_PRIMARY))
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 elm_entry_entry_insert(data, txt);
1481 wd->selection_asked = EINA_FALSE;
1483 else if (ev->selection == ECORE_X_SELECTION_XDND)
1485 Ecore_X_Selection_Data_Text *text_data;
1487 text_data = ev->data;
1488 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1490 if (text_data->text)
1492 char *txt = _text_to_mkup(text_data->text);
1496 /* Massive FIXME: this should be at the drag point */
1497 elm_entry_entry_insert(data, txt);
1502 wd->drag_selection_asked = EINA_FALSE;
1504 ecore_x_dnd_send_finished();
1508 return ECORE_CALLBACK_PASS_ON;
1512 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1515 Widget_Data *wd = elm_widget_data_get(data);
1516 Ecore_X_Event_Selection_Clear *ev = event;
1517 if (!wd) return ECORE_CALLBACK_PASS_ON;
1518 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1519 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1520 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1522 elm_entry_select_none(data);
1527 Evas_Object *top = elm_widget_top_get(data);
1528 Ecore_X_Event_Selection_Clear *ev = event;
1531 return ECORE_CALLBACK_PASS_ON;
1533 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1535 return ECORE_CALLBACK_PASS_ON;
1538 if (cnpwidgetdata == data)
1540 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1544 return ECORE_CALLBACK_PASS_ON;
1549 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1554 wd = elm_widget_data_get(obj);
1556 if (!wd) return EINA_FALSE;
1557 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1559 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1560 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1561 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1562 EDJE_CURSOR_MAIN,drop->x,drop->y);
1563 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1564 elm_entry_entry_insert(obj, drop->data);
1565 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1566 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1572 static Evas_Object *
1573 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1575 Widget_Data *wd = elm_widget_data_get(data);
1578 Elm_Entry_Item_Provider *ip;
1581 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1583 o = ip->func(ip->data, data, item);
1586 o = edje_object_add(evas_object_evas_get(data));
1587 if (!strncmp(item, "emoticon/", 9))
1588 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1590 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1595 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1597 char *curlocater, *starttag, *endtag;
1598 int firstindex = 0, foundflag = -1;
1600 curlocater = strstr(oldstring, key);
1603 starttag = curlocater;
1604 endtag = curlocater + strlen(key);
1605 if (endtag == NULL || *endtag != '=')
1611 firstindex = abs(oldstring - curlocater);
1612 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1613 *value = (char*)oldstring + firstindex;
1615 while (oldstring != starttag)
1617 if (*starttag == '>')
1622 if (*starttag == '<')
1626 if (starttag == NULL) break;
1629 while (NULL != endtag)
1640 if (endtag == NULL) break;
1643 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1653 if (foundflag == 1) return 0;
1659 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1661 const char *srcstring = NULL;
1662 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1663 char *curlocater, *replocater;
1664 char *starttag, *endtag;
1665 int tagtxtlen = 0, insertflag = 0;
1667 srcstring = eina_strbuf_string_get(srcbuf);
1668 curlocater = strstr(srcstring, key);
1670 if (curlocater == NULL)
1678 starttag = strchr(srcstring, '<');
1679 endtag = strchr(srcstring, '>');
1680 tagtxtlen = endtag - starttag;
1681 if (tagtxtlen <= 0) tagtxtlen = 0;
1682 if (starttag < curlocater && curlocater < endtag) break;
1683 if (endtag != NULL && endtag+1 != NULL)
1684 srcstring = endtag+1;
1687 } while (strlen(srcstring) > 1);
1689 if (starttag && endtag && tagtxtlen > strlen(key))
1691 repbuf = eina_strbuf_new();
1692 diffbuf = eina_strbuf_new();
1693 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1694 srcstring = eina_strbuf_string_get(repbuf);
1695 curlocater = strstr(srcstring, key);
1697 if (curlocater != NULL)
1699 replocater = curlocater + strlen(key) + 1;
1701 while (*replocater == ' ' || *replocater == '=')
1706 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1709 if (replocater-curlocater > strlen(key)+1)
1712 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1721 eina_strbuf_reset(repbuf);
1729 if (repbuf == NULL) repbuf = eina_strbuf_new();
1730 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1734 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1735 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1741 eina_strbuf_prepend(diffbuf, "<");
1742 eina_strbuf_append(diffbuf, ">");
1743 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1747 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1748 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1752 if (repbuf) eina_strbuf_free(repbuf);
1753 if (diffbuf) eina_strbuf_free(diffbuf);
1759 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1761 Eina_Strbuf *sharebuf = NULL;
1763 sharebuf = eina_strbuf_new();
1764 eina_strbuf_append(sharebuf, *srcstring);
1765 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1766 eina_stringshare_del(*srcstring);
1767 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1768 eina_strbuf_free(sharebuf);
1774 _is_width_over(Evas_Object *obj)
1776 Evas_Coord x, y, w, h;
1777 Evas_Coord vx, vy, vw, vh;
1778 Widget_Data *wd = elm_widget_data_get(obj);
1782 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1784 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1786 if (x >= 0 && y >= 0)
1789 if (4 < wd->wrap_w && w > wd->wrap_w)
1796 _reverse_ellipsis_entry(Evas_Object *obj)
1798 Widget_Data *wd = elm_widget_data_get(obj);
1799 int cur_fontsize = 0;
1800 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1801 char **kvalue = NULL;
1802 const char *minfont, *deffont, *maxfont;
1803 const char *ellipsis_string = "...";
1804 int minfontsize, maxfontsize, minshowcount;
1806 minshowcount = strlen(ellipsis_string) + 1;
1807 minfont = edje_object_data_get(wd->ent, "min_font_size");
1808 if (minfont) minfontsize = atoi(minfont);
1809 else minfontsize = 1;
1810 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1811 if (maxfont) maxfontsize = atoi(maxfont);
1812 else maxfontsize = 1;
1813 deffont = edje_object_data_get(wd->ent, "default_font_size");
1814 if (deffont) cur_fontsize = atoi(deffont);
1815 else cur_fontsize = 1;
1816 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1817 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1819 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1821 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1824 txtbuf = eina_strbuf_new();
1825 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1827 if (cur_fontsize >= atoi(deffont))
1829 if (txtbuf) eina_strbuf_free(txtbuf);
1833 if (_is_width_over(obj) != 1)
1835 int rev_fontsize = cur_fontsize;
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));
1852 eina_strbuf_free(fontbuf);
1854 } while (_is_width_over(obj) != 1);
1856 while (_is_width_over(obj))
1859 if (rev_fontsize < atoi(deffont))
1862 if (fontbuf != NULL)
1864 eina_strbuf_free(fontbuf);
1867 fontbuf = eina_strbuf_new();
1868 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1869 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1870 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1871 eina_strbuf_free(fontbuf);
1876 if (txtbuf) eina_strbuf_free(txtbuf);
1882 _ellipsis_entry_to_width(Evas_Object *obj)
1884 Widget_Data *wd = elm_widget_data_get(obj);
1885 int cur_fontsize = 0, len, jumpcount;
1886 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1887 char **kvalue = NULL;
1888 const char *minfont, *deffont, *maxfont;
1889 const char *ellipsis_string = "...";
1890 int minfontsize, maxfontsize, minshowcount;
1891 int i, tagend, cur_len;
1894 minshowcount = strlen(ellipsis_string) + 1;
1895 minfont = edje_object_data_get(wd->ent, "min_font_size");
1896 if (minfont) minfontsize = atoi(minfont);
1897 else minfontsize = 1;
1898 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1899 if (maxfont) maxfontsize = atoi(maxfont);
1900 else maxfontsize = 1;
1901 deffont = edje_object_data_get(wd->ent, "default_font_size");
1902 if (deffont) cur_fontsize = atoi(deffont);
1903 else cur_fontsize = 1;
1904 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1905 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1907 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1909 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1912 txtbuf = eina_strbuf_new();
1913 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1915 while (_is_width_over(obj))
1917 if (wd->ellipsis_threshold == 0)
1918 wd->ellipsis_threshold = _entry_length_get(obj);
1919 if (cur_fontsize > minfontsize)
1922 if (fontbuf != NULL)
1924 eina_strbuf_free(fontbuf);
1927 fontbuf = eina_strbuf_new();
1928 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1929 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1930 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1931 eina_strbuf_free(fontbuf);
1933 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1937 len = _entry_length_get(obj);
1938 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1939 cur_len = strlen(cur_str);
1941 for (i = 0; i < len; i++)
1943 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1944 cur_str[i+1] != '<')
1951 while (jumpcount < len-strlen(ellipsis_string))
1953 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1957 eina_strbuf_free(txtbuf);
1960 txtbuf = eina_strbuf_new();
1961 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1962 eina_strbuf_append(txtbuf, ellipsis_string);
1963 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1964 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1965 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1967 if (_is_width_over(obj))
1975 if (txtbuf) eina_strbuf_free(txtbuf);
1980 static int _textinput_control_function(void *data,void *input_data)
1982 /*calculate character count*/
1983 Evas_Object *entry = (Evas_Object *)data;
1984 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
1987 size_t insert_text_len=0;
1988 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1990 size_t remain_bytes;
1993 byte_len = strlen(text);/*no of bytes*/
1994 remain_bytes = wd->max_no_of_bytes-byte_len;
1995 sprintf(buf,"%d",remain_bytes);
1996 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1999 insert_text = (char *)input_data;
2000 insert_text_len = strlen(insert_text);
2001 if(remain_bytes<insert_text_len)
2003 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2006 if(byte_len>=wd->max_no_of_bytes)
2008 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2017 * This adds an entry to @p parent object.
2019 * @param parent The parent object
2020 * @return The new object or NULL if it cannot be created
2025 elm_entry_add(Evas_Object *parent)
2027 Evas_Object *obj, *top;
2031 wd = ELM_NEW(Widget_Data);
2032 e = evas_object_evas_get(parent);
2033 wd->bgcolor = EINA_FALSE;
2034 wd->bg = evas_object_rectangle_add(e);
2035 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2036 obj = elm_widget_add(e);
2037 ELM_SET_WIDTYPE(widtype, "entry");
2038 elm_widget_type_set(obj, "entry");
2039 elm_widget_sub_object_add(parent, obj);
2040 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2041 elm_widget_data_set(obj, wd);
2042 elm_widget_del_hook_set(obj, _del_hook);
2043 elm_widget_theme_hook_set(obj, _theme_hook);
2044 elm_widget_disable_hook_set(obj, _disable_hook);
2045 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2046 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2047 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2048 elm_widget_can_focus_set(obj, 1);
2049 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2050 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2053 wd->linewrap = EINA_TRUE;
2054 wd->ellipsis = EINA_FALSE;
2055 wd->char_linewrap= EINA_FALSE;
2056 wd->editable = EINA_TRUE;
2057 wd->disabled = EINA_FALSE;
2058 wd->context_menu = EINA_TRUE;
2059 wd->autoperiod = EINA_TRUE;
2061 wd->ellipsis_threshold = 0;
2063 wd->ent = edje_object_add(e);
2064 edje_object_item_provider_set(wd->ent, _get_item, obj);
2065 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2066 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2067 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2069 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2071 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2074 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2075 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2076 _signal_entry_changed, obj);
2077 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2078 _signal_handler_move_start, obj);
2079 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2080 _signal_handler_move_end, obj);
2081 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2082 _signal_selection_start, obj);
2083 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2084 _signal_selection_changed, obj);
2085 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2086 _signal_selection_cleared, obj);
2087 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2088 _signal_entry_paste_request, obj);
2089 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2090 _signal_entry_copy_notify, obj);
2091 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2092 _signal_entry_cut_notify, obj);
2093 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2094 _signal_cursor_changed, obj);
2095 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2096 _signal_anchor_down, obj);
2097 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2098 _signal_anchor_up, obj);
2099 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2100 _signal_anchor_move, obj);
2101 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2102 _signal_anchor_in, obj);
2103 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2104 _signal_anchor_out, obj);
2105 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2106 _signal_key_enter, obj);
2107 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2108 _signal_mouse_down, obj);
2109 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2110 _signal_mouse_up, obj);
2111 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2112 _signal_mouse_double, obj);
2113 edje_object_part_text_set(wd->ent, "elm.text", "");
2114 elm_widget_resize_object_set(obj, wd->ent);
2117 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2119 #ifdef HAVE_ELEMENTARY_X
2120 top = elm_widget_top_get(obj);
2121 if ((top) && (elm_win_xwindow_get(top)))
2123 wd->sel_notify_handler =
2124 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2125 _event_selection_notify, obj);
2126 wd->sel_clear_handler =
2127 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2128 _event_selection_clear, obj);
2131 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2134 entries = eina_list_prepend(entries, obj);
2136 // module - find module for entry
2137 wd->api = _module(obj);
2138 // if found - hook in
2139 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2141 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2142 // TODO: and save some bytes, making descriptions per-class and not instance!
2143 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2147 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2149 ELM_CHECK_WIDTYPE(obj, widtype);
2150 Widget_Data *wd = elm_widget_data_get(obj);
2152 ext_mod->cancel = _cancel;
2153 ext_mod->copy = _copy;
2154 ext_mod->cut = _cut;
2155 ext_mod->paste = _paste;
2156 ext_mod->select = _select;
2157 ext_mod->selectall = NULL; /* to be implemented*/
2158 ext_mod->ent = wd->ent;
2159 ext_mod->items = wd->items;
2160 ext_mod->longpress_timer = wd->longpress_timer;
2161 ext_mod->editable = wd->editable;
2162 ext_mod->have_selection = wd->have_selection;
2163 ext_mod->password = wd->password;
2164 ext_mod->selmode = wd->selmode;
2165 ext_mod->cnpinit = _cnpinit;
2166 ext_mod->context_menu = wd->context_menu;
2170 * This sets the entry object not to line wrap. All input will
2171 * be on a single line, and the entry box will extend with user input.
2173 * @param obj The entry object
2174 * @param single_line If true, the text in the entry
2175 * will be on a single line.
2180 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2182 ELM_CHECK_WIDTYPE(obj, widtype);
2183 Widget_Data *wd = elm_widget_data_get(obj);
2185 Ecore_IMF_Context *ic;
2187 if (wd->single_line == single_line) return;
2188 wd->single_line = single_line;
2189 wd->linewrap = EINA_FALSE;
2190 wd->char_linewrap = EINA_FALSE;
2191 t = eina_stringshare_add(elm_entry_entry_get(obj));
2192 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2193 elm_entry_entry_set(obj, t);
2194 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2195 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2196 ic = elm_entry_imf_context_get(obj);
2199 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2202 eina_stringshare_del(t);
2207 * This returns true if the entry has been set to single line mode.
2208 * See also elm_entry_single_line_set().
2210 * @param obj The entry object
2211 * @return single_line If true, the text in the entry is set to display
2217 elm_entry_single_line_get(const Evas_Object *obj)
2219 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2220 Widget_Data *wd = elm_widget_data_get(obj);
2221 if (!wd) return EINA_FALSE;
2222 return wd->single_line;
2226 * This set's the maximum bytes that can be added in entry.
2228 * @param obj The entry object
2229 * @param max_no_of_bytes Maximum number of bytes entry can have.
2234 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2236 Widget_Data *wd = elm_widget_data_get(obj);
2238 wd->max_no_of_bytes = max_no_of_bytes;
2239 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2240 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2245 * This sets the entry object to password mode. All text entered
2246 * and/or displayed within the widget will be replaced with asterisks (*).
2248 * @param obj The entry object
2249 * @param password If true, password mode is enabled.
2254 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2256 ELM_CHECK_WIDTYPE(obj, widtype);
2257 Widget_Data *wd = elm_widget_data_get(obj);
2258 Ecore_IMF_Context *ic;
2261 if (wd->password == password) return;
2262 wd->password = password;
2263 wd->single_line = EINA_TRUE;
2264 wd->linewrap = EINA_FALSE;
2265 wd->char_linewrap = EINA_FALSE;
2266 if (_elm_config->password_show_last_character)
2267 wd->show_last_character = EINA_TRUE;
2268 t = eina_stringshare_add(elm_entry_entry_get(obj));
2269 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2270 elm_entry_entry_set(obj, t);
2276 elm_entry_autoperiod_set(obj, EINA_FALSE);
2279 if (wd->autocapital)
2281 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2285 ic = elm_entry_imf_context_get(obj);
2288 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2291 eina_stringshare_del(t);
2296 * This set's the entry in password mode with out masking the last character entered by user,
2297 * and later masking the character after 2 seconds.
2299 * @param obj The entry object
2300 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2306 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2308 Widget_Data *wd = elm_widget_data_get(obj);
2311 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2312 wd->show_last_character = show_last_character;
2313 wd->password = show_last_character;
2314 wd->single_line = EINA_TRUE;
2315 wd->linewrap = EINA_FALSE;
2316 wd->char_linewrap = EINA_FALSE;
2317 t = eina_stringshare_add(elm_entry_entry_get(obj));
2318 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2319 elm_entry_entry_set(obj, t);
2320 eina_stringshare_del(t);
2325 * This returns whether password mode is enabled.
2326 * See also elm_entry_password_set().
2328 * @param obj The entry object
2329 * @return If true, the entry is set to display all characters
2335 elm_entry_password_get(const Evas_Object *obj)
2337 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2338 Widget_Data *wd = elm_widget_data_get(obj);
2339 if (!wd) return EINA_FALSE;
2340 return wd->password;
2344 * This sets the text displayed within the entry to @p entry.
2346 * @param obj The entry object
2347 * @param entry The text to be displayed
2352 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2354 ELM_CHECK_WIDTYPE(obj, widtype);
2355 Widget_Data *wd = elm_widget_data_get(obj);
2357 if (!entry) entry = "";
2358 if(wd->max_no_of_bytes)
2360 int len = strlen(entry);
2361 if(len > wd->max_no_of_bytes)
2363 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2367 edje_object_part_text_set(wd->ent, "elm.text", entry);
2368 if (wd->text) eina_stringshare_del(wd->text);
2370 wd->changed = EINA_TRUE;
2375 * This returns the text currently shown in object @p entry.
2376 * See also elm_entry_entry_set().
2378 * @param obj The entry object
2379 * @return The currently displayed text or NULL on failure
2384 elm_entry_entry_get(const Evas_Object *obj)
2386 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2387 Widget_Data *wd = elm_widget_data_get(obj);
2389 if (!wd) return NULL;
2391 if ((wd->text)&&(wd->password))
2392 return elm_entry_markup_to_utf8(wd->text);
2394 if (wd->text) return wd->text;
2395 text = edje_object_part_text_get(wd->ent, "elm.text");
2398 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2401 eina_stringshare_replace(&wd->text, text);
2402 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2407 * This returns all selected text within the entry.
2409 * @param obj The entry object
2410 * @return The selected text within the entry or NULL on failure
2415 elm_entry_selection_get(const Evas_Object *obj)
2417 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2418 Widget_Data *wd = elm_widget_data_get(obj);
2419 if (!wd) return NULL;
2420 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2424 * This inserts text in @p entry at the beginning of the entry
2427 * @param obj The entry object
2428 * @param entry The text to insert
2433 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2435 ELM_CHECK_WIDTYPE(obj, widtype);
2436 Widget_Data *wd = elm_widget_data_get(obj);
2438 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2440 if (cnpwidgetdata == obj)
2441 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2443 wd->changed = EINA_TRUE;
2448 * This enables word line wrapping in the entry object. It is the opposite
2449 * of elm_entry_single_line_set(). Additionally, setting this disables
2450 * character line wrapping.
2451 * See also elm_entry_line_char_wrap_set().
2453 * @param obj The entry object
2454 * @param wrap If true, the entry will be wrapped once it reaches the end
2455 * of the object. Wrapping will occur at the end of the word before the end of the
2461 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2463 ELM_CHECK_WIDTYPE(obj, widtype);
2464 Widget_Data *wd = elm_widget_data_get(obj);
2467 if (wd->linewrap == wrap) return;
2468 wd->linewrap = wrap;
2470 wd->char_linewrap = EINA_FALSE;
2471 t = eina_stringshare_add(elm_entry_entry_get(obj));
2472 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2473 elm_entry_entry_set(obj, t);
2474 eina_stringshare_del(t);
2479 * Set wrap width of the entry
2481 * @param obj The entry object
2482 * @param w The wrap width in pixels at a minimum where words need to wrap
2486 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2488 Widget_Data *wd = elm_widget_data_get(obj);
2489 if (wd->wrap_w == w) return;
2495 * get wrap width of the entry
2497 * @param obj The entry object
2498 * @return The wrap width in pixels at a minimum where words need to wrap
2502 elm_entry_wrap_width_get(const Evas_Object *obj)
2504 Widget_Data *wd = elm_widget_data_get(obj);
2509 * This enables character line wrapping in the entry object. It is the opposite
2510 * of elm_entry_single_line_set(). Additionally, setting this disables
2511 * word line wrapping.
2512 * See also elm_entry_line_wrap_set().
2514 * @param obj The entry object
2515 * @param wrap If true, the entry will be wrapped once it reaches the end
2516 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2521 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2523 ELM_CHECK_WIDTYPE(obj, widtype);
2524 Widget_Data *wd = elm_widget_data_get(obj);
2527 if (wd->char_linewrap == wrap) return;
2528 wd->char_linewrap = wrap;
2529 if(wd->char_linewrap)
2530 wd->linewrap = EINA_FALSE;
2531 t = eina_stringshare_add(elm_entry_entry_get(obj));
2532 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2533 elm_entry_entry_set(obj, t);
2534 eina_stringshare_del(t);
2539 * This sets the editable attribute of the entry.
2541 * @param obj The entry object
2542 * @param editable If true, the entry will be editable by the user.
2543 * If false, it will be set to the disabled state.
2548 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2550 ELM_CHECK_WIDTYPE(obj, widtype);
2551 Widget_Data *wd = elm_widget_data_get(obj);
2554 if (wd->editable == editable) return;
2555 wd->editable = editable;
2556 t = eina_stringshare_add(elm_entry_entry_get(obj));
2557 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2558 elm_entry_entry_set(obj, t);
2559 eina_stringshare_del(t);
2562 #ifdef HAVE_ELEMENTARY_X
2564 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2566 elm_drop_target_del(obj);
2571 * This gets the editable attribute of the entry.
2572 * See also elm_entry_editable_set().
2574 * @param obj The entry object
2575 * @return If true, the entry is editable by the user.
2576 * If false, it is not editable by the user
2581 elm_entry_editable_get(const Evas_Object *obj)
2583 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2584 Widget_Data *wd = elm_widget_data_get(obj);
2585 if (!wd) return EINA_FALSE;
2586 return wd->editable;
2590 * This drops any existing text selection within the entry.
2592 * @param obj The entry object
2597 elm_entry_select_none(Evas_Object *obj)
2599 ELM_CHECK_WIDTYPE(obj, widtype);
2600 Widget_Data *wd = elm_widget_data_get(obj);
2604 wd->selmode = EINA_FALSE;
2605 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2606 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2608 wd->have_selection = EINA_FALSE;
2609 edje_object_part_text_select_none(wd->ent, "elm.text");
2613 * This selects all text within the entry.
2615 * @param obj The entry object
2620 elm_entry_select_all(Evas_Object *obj)
2622 ELM_CHECK_WIDTYPE(obj, widtype);
2623 Widget_Data *wd = elm_widget_data_get(obj);
2627 wd->selmode = EINA_FALSE;
2628 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2629 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2631 wd->have_selection = EINA_TRUE;
2632 edje_object_part_text_select_all(wd->ent, "elm.text");
2636 * This moves the cursor one place to the right within the entry.
2638 * @param obj The entry object
2639 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2644 elm_entry_cursor_next(Evas_Object *obj)
2646 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2647 Widget_Data *wd = elm_widget_data_get(obj);
2648 if (!wd) return EINA_FALSE;
2649 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2653 * This moves the cursor one place to the left within the entry.
2655 * @param obj The entry object
2656 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2661 elm_entry_cursor_prev(Evas_Object *obj)
2663 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2664 Widget_Data *wd = elm_widget_data_get(obj);
2665 if (!wd) return EINA_FALSE;
2666 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2670 * This moves the cursor one line up within the entry.
2672 * @param obj The entry object
2673 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2678 elm_entry_cursor_up(Evas_Object *obj)
2680 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2681 Widget_Data *wd = elm_widget_data_get(obj);
2682 if (!wd) return EINA_FALSE;
2683 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2687 * This moves the cursor one line down within the entry.
2689 * @param obj The entry object
2690 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2695 elm_entry_cursor_down(Evas_Object *obj)
2697 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2698 Widget_Data *wd = elm_widget_data_get(obj);
2699 if (!wd) return EINA_FALSE;
2700 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2704 * This moves the cursor to the beginning of the entry.
2706 * @param obj The entry object
2711 elm_entry_cursor_begin_set(Evas_Object *obj)
2713 ELM_CHECK_WIDTYPE(obj, widtype);
2714 Widget_Data *wd = elm_widget_data_get(obj);
2716 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2720 * This moves the cursor to the end of the entry.
2722 * @param obj The entry object
2727 elm_entry_cursor_end_set(Evas_Object *obj)
2729 ELM_CHECK_WIDTYPE(obj, widtype);
2730 Widget_Data *wd = elm_widget_data_get(obj);
2732 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2736 * This moves the cursor to the beginning of the current line.
2738 * @param obj The entry object
2743 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2745 ELM_CHECK_WIDTYPE(obj, widtype);
2746 Widget_Data *wd = elm_widget_data_get(obj);
2748 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2752 * This moves the cursor to the end of the current line.
2754 * @param obj The entry object
2759 elm_entry_cursor_line_end_set(Evas_Object *obj)
2761 ELM_CHECK_WIDTYPE(obj, widtype);
2762 Widget_Data *wd = elm_widget_data_get(obj);
2764 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2768 * This begins a selection within the entry as though
2769 * the user were holding down the mouse button to make a selection.
2771 * @param obj The entry object
2776 elm_entry_cursor_selection_begin(Evas_Object *obj)
2778 ELM_CHECK_WIDTYPE(obj, widtype);
2779 Widget_Data *wd = elm_widget_data_get(obj);
2781 edje_object_part_text_select_begin(wd->ent, "elm.text");
2785 * This ends a selection within the entry as though
2786 * the user had just released the mouse button while making a selection.
2788 * @param obj The entry object
2793 elm_entry_cursor_selection_end(Evas_Object *obj)
2795 ELM_CHECK_WIDTYPE(obj, widtype);
2796 Widget_Data *wd = elm_widget_data_get(obj);
2798 edje_object_part_text_select_extend(wd->ent, "elm.text");
2802 * TODO: fill this in
2804 * @param obj The entry object
2805 * @return TODO: fill this in
2810 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2812 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2813 Widget_Data *wd = elm_widget_data_get(obj);
2814 if (!wd) return EINA_FALSE;
2815 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2819 * This returns whether the cursor is visible.
2821 * @param obj The entry object
2822 * @return If true, the cursor is visible.
2827 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2829 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2830 Widget_Data *wd = elm_widget_data_get(obj);
2831 if (!wd) return EINA_FALSE;
2832 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2836 * TODO: fill this in
2838 * @param obj The entry object
2839 * @return TODO: fill this in
2844 elm_entry_cursor_content_get(const Evas_Object *obj)
2846 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2847 Widget_Data *wd = elm_widget_data_get(obj);
2848 if (!wd) return NULL;
2849 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2853 * This executes a "cut" action on the selected text in the entry.
2855 * @param obj The entry object
2860 elm_entry_selection_cut(Evas_Object *obj)
2862 ELM_CHECK_WIDTYPE(obj, widtype);
2863 Widget_Data *wd = elm_widget_data_get(obj);
2865 _cut(obj, NULL, NULL);
2869 * This executes a "copy" action on the selected text in the entry.
2871 * @param obj The entry object
2876 elm_entry_selection_copy(Evas_Object *obj)
2878 ELM_CHECK_WIDTYPE(obj, widtype);
2879 Widget_Data *wd = elm_widget_data_get(obj);
2881 _copy(obj, NULL, NULL);
2885 * This executes a "paste" action in the entry.
2887 * @param obj The entry object
2892 elm_entry_selection_paste(Evas_Object *obj)
2894 ELM_CHECK_WIDTYPE(obj, widtype);
2895 Widget_Data *wd = elm_widget_data_get(obj);
2897 _paste(obj, NULL, NULL);
2901 * This clears and frees the items in a entry's contextual (right click) menu.
2903 * @param obj The entry object
2908 elm_entry_context_menu_clear(Evas_Object *obj)
2910 ELM_CHECK_WIDTYPE(obj, widtype);
2911 Widget_Data *wd = elm_widget_data_get(obj);
2912 Elm_Entry_Context_Menu_Item *it;
2914 EINA_LIST_FREE(wd->items, it)
2916 eina_stringshare_del(it->label);
2917 eina_stringshare_del(it->icon_file);
2918 eina_stringshare_del(it->icon_group);
2924 * This adds an item to the entry's contextual menu.
2926 * @param obj The entry object
2927 * @param label The item's text label
2928 * @param icon_file The item's icon file
2929 * @param icon_type The item's icon type
2930 * @param func The callback to execute when the item is clicked
2931 * @param data The data to associate with the item for related functions
2936 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)
2938 ELM_CHECK_WIDTYPE(obj, widtype);
2939 Widget_Data *wd = elm_widget_data_get(obj);
2940 Elm_Entry_Context_Menu_Item *it;
2942 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2944 wd->items = eina_list_append(wd->items, it);
2946 it->label = eina_stringshare_add(label);
2947 it->icon_file = eina_stringshare_add(icon_file);
2948 it->icon_type = icon_type;
2950 it->data = (void *)data;
2954 * This disables the entry's contextual (right click) menu.
2956 * @param obj The entry object
2957 * @param disabled If true, the menu is disabled
2962 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2964 ELM_CHECK_WIDTYPE(obj, widtype);
2965 Widget_Data *wd = elm_widget_data_get(obj);
2967 if (wd->context_menu == !disabled) return;
2968 wd->context_menu = !disabled;
2972 * This returns whether the entry's contextual (right click) menu is disabled.
2974 * @param obj The entry object
2975 * @return If true, the menu is disabled
2980 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2982 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2983 Widget_Data *wd = elm_widget_data_get(obj);
2984 if (!wd) return EINA_FALSE;
2985 return !wd->context_menu;
2989 * This appends a custom item provider to the list for that entry
2991 * This appends the given callback. The list is walked from beginning to end
2992 * with each function called given the item href string in the text. If the
2993 * function returns an object handle other than NULL (it should create an
2994 * and object to do this), then this object is used to replace that item. If
2995 * not the next provider is called until one provides an item object, or the
2996 * default provider in entry does.
2998 * @param obj The entry object
2999 * @param func The function called to provide the item object
3000 * @param data The data passed to @p func
3005 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3007 ELM_CHECK_WIDTYPE(obj, widtype);
3008 Widget_Data *wd = elm_widget_data_get(obj);
3011 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3015 wd->item_providers = eina_list_append(wd->item_providers, ip);
3019 * This prepends a custom item provider to the list for that entry
3021 * This prepends the given callback. See elm_entry_item_provider_append() for
3024 * @param obj The entry object
3025 * @param func The function called to provide the item object
3026 * @param data The data passed to @p func
3031 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3033 ELM_CHECK_WIDTYPE(obj, widtype);
3034 Widget_Data *wd = elm_widget_data_get(obj);
3037 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3041 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3045 * This removes a custom item provider to the list for that entry
3047 * This removes the given callback. See elm_entry_item_provider_append() for
3050 * @param obj The entry object
3051 * @param func The function called to provide the item object
3052 * @param data The data passed to @p func
3057 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3059 ELM_CHECK_WIDTYPE(obj, widtype);
3060 Widget_Data *wd = elm_widget_data_get(obj);
3062 Elm_Entry_Item_Provider *ip;
3065 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3067 if ((ip->func == func) && (ip->data == data))
3069 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3077 * This converts a markup (HTML-like) string into UTF-8.
3079 * @param s The string (in markup) to be converted
3080 * @return The converted string (in UTF-8)
3085 elm_entry_markup_to_utf8(const char *s)
3087 char *ss = _mkup_to_text(s);
3088 if (!ss) ss = strdup("");
3093 * This converts a UTF-8 string into markup (HTML-like).
3095 * @param s The string (in UTF-8) to be converted
3096 * @return The converted string (in markup)
3101 elm_entry_utf8_to_markup(const char *s)
3103 char *ss = _text_to_mkup(s);
3104 if (!ss) ss = strdup("");
3109 * Get the input method context in the entry widget
3111 * @param obj The entry object
3112 * @return The input method context
3116 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3118 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3119 Widget_Data *wd = elm_widget_data_get(obj);
3120 if (!wd || !wd->ent) return NULL;
3122 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3126 * Set whether entry should enable the return key on soft keyboard automatically
3128 * @param obj The entry object
3129 * @param on If true, entry enables the return key on soft keyboard automatically.
3134 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3136 ELM_CHECK_WIDTYPE(obj, widtype);
3137 Widget_Data *wd = elm_widget_data_get(obj);
3140 wd->autoreturnkey = on;
3141 _check_enable_returnkey(obj);
3145 * Set whether entry should support auto capitalization
3147 * @param obj The entry object
3148 * @param on If true, entry suports auto capitalization.
3153 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3155 ELM_CHECK_WIDTYPE(obj, widtype);
3156 Widget_Data *wd = elm_widget_data_get(obj);
3160 wd->autocapital = EINA_FALSE;
3162 wd->autocapital = autocap;
3164 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3165 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3166 wd->autocapital = EINA_FALSE;
3168 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3172 * Set whether entry should support auto period
3174 * @param obj The entry object
3175 * @param on If true, entry suports auto period.
3180 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3182 ELM_CHECK_WIDTYPE(obj, widtype);
3183 Widget_Data *wd = elm_widget_data_get(obj);
3187 wd->autoperiod = EINA_FALSE;
3189 wd->autoperiod = autoperiod;
3191 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3192 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3193 wd->autoperiod = EINA_FALSE;
3195 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3199 * Set the font size on the entry object
3201 * @param obj The entry object
3202 * @param size font size
3207 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3209 ELM_CHECK_WIDTYPE(obj, widtype);
3210 Widget_Data *wd = elm_widget_data_get(obj);
3211 Eina_Strbuf *fontbuf = NULL;
3216 t = eina_stringshare_add(elm_entry_entry_get(obj));
3217 fontbuf = eina_strbuf_new();
3218 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3220 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3222 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3224 elm_entry_entry_set(obj, t);
3228 eina_strbuf_free(fontbuf);
3229 eina_stringshare_del(t);
3233 * Set the text align on the entry object
3235 * @param obj The entry object
3236 * @param align align mode
3241 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3243 ELM_CHECK_WIDTYPE(obj, widtype);
3244 Widget_Data *wd = elm_widget_data_get(obj);
3249 t = eina_stringshare_add(elm_entry_entry_get(obj));
3251 if (len <= 0) return;
3253 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3254 elm_entry_entry_set(obj, t);
3258 eina_stringshare_del(t);
3262 * Set the text color on the entry object
3264 * @param obj The entry object
3265 * @param r Red property background color of The entry object
3266 * @param g Green property background color of The entry object
3267 * @param b Blue property background color of The entry object
3268 * @param a Alpha property background alpha of The entry object
3273 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3275 ELM_CHECK_WIDTYPE(obj, widtype);
3276 Widget_Data *wd = elm_widget_data_get(obj);
3277 Eina_Strbuf *colorbuf = NULL;
3282 t = eina_stringshare_add(elm_entry_entry_get(obj));
3284 if (len <= 0) return;
3285 colorbuf = eina_strbuf_new();
3286 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3288 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3290 elm_entry_entry_set(obj, t);
3294 eina_strbuf_free(colorbuf);
3295 eina_stringshare_del(t);
3300 * Set background color of the entry
3302 * @param obj The entry object
3303 * @param r Red property background color of The entry object
3304 * @param g Green property background color of The entry object
3305 * @param b Blue property background color of The entry object
3306 * @param a Alpha property background alpha of The entry object
3310 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3312 ELM_CHECK_WIDTYPE(obj, widtype);
3313 Widget_Data *wd = elm_widget_data_get(obj);
3314 evas_object_color_set(wd->bg, r, g, b, a);
3316 if (wd->bgcolor == EINA_FALSE)
3319 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3324 * Set the ellipsis behavior of the entry
3326 * @param obj The entry object
3327 * @param ellipsis To ellipsis text or not
3331 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3333 ELM_CHECK_WIDTYPE(obj, widtype);
3334 Widget_Data *wd = elm_widget_data_get(obj);
3335 if (wd->ellipsis == ellipsis) return;
3336 wd->ellipsis = ellipsis;
3342 * This sets the attribute to show the input panel automatically.
3344 * @param obj The entry object
3345 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3350 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3352 ELM_CHECK_WIDTYPE(obj, widtype);
3353 Widget_Data *wd = elm_widget_data_get(obj);
3356 wd->input_panel_enable = enabled;
3357 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3361 * Set the input panel layout of the entry
3363 * @param obj The entry object
3364 * @param layout the layout to set
3369 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3371 ELM_CHECK_WIDTYPE(obj, widtype);
3372 Widget_Data *wd = elm_widget_data_get(obj);
3375 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3378 wd->input_panel_layout = layout;
3380 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3383 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/