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;
431 Evas_Object *above = NULL;
434 if (!wd->editable) return;
435 if (elm_widget_focus_get(obj))
437 evas_object_focus_set(wd->ent, EINA_TRUE);
438 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
440 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
441 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
442 _check_enable_returnkey(obj);
446 evas_object_data_set(parent_obj, "raise", evas_object_above_get(parent_obj));
447 evas_object_raise(parent_obj);
448 parent_obj = elm_widget_parent_get(parent_obj);
454 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
455 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
456 evas_object_focus_set(wd->ent, EINA_FALSE);
457 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
458 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
462 above = evas_object_data_get(parent_obj, "raise");
463 evas_object_stack_below(parent_obj, above);
464 parent_obj = elm_widget_parent_get(parent_obj);
471 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
473 Widget_Data *wd = elm_widget_data_get(obj);
475 edje_object_signal_emit(wd->ent, emission, source);
479 _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)
481 Widget_Data *wd = elm_widget_data_get(obj);
483 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
487 _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))
489 Widget_Data *wd = elm_widget_data_get(obj);
490 if (!wd) return NULL;
491 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
495 _hoversel_position(Evas_Object *obj)
497 Widget_Data *wd = elm_widget_data_get(obj);
498 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
500 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
501 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
503 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
514 evas_object_move(wd->hoversel, x + cx, y + cy);
515 evas_object_resize(wd->hoversel, cw, ch);
519 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
521 Widget_Data *wd = elm_widget_data_get(data);
523 if (wd->hoversel) _hoversel_position(data);
527 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
529 Widget_Data *wd = elm_widget_data_get(data);
531 if (wd->linewrap || wd->char_linewrap)
535 if (wd->hoversel) _hoversel_position(data);
536 // Evas_Coord ww, hh;
537 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
541 _hover_del(void *data)
543 Widget_Data *wd = elm_widget_data_get(data);
548 evas_object_del(wd->hoversel);
551 wd->hovdeljob = NULL;
555 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
557 Widget_Data *wd = elm_widget_data_get(data);
559 if (wd->hoversel) evas_object_hide(wd->hoversel);
563 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
565 elm_widget_scroll_freeze_pop(data);
566 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
567 wd->hovdeljob = ecore_job_add(_hover_del, data);
571 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
573 Widget_Data *wd = elm_widget_data_get(data);
575 wd->selmode = EINA_TRUE;
576 edje_object_part_text_select_none(wd->ent, "elm.text");
578 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
579 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
580 //elm_widget_scroll_hold_push(data);
584 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
586 Widget_Data *wd = elm_widget_data_get(data);
588 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
589 if (wd->sel_notify_handler)
591 #ifdef HAVE_ELEMENTARY_X
592 wd->selection_asked = EINA_TRUE;
593 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
599 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
601 Widget_Data *wd = elm_widget_data_get(obj);
605 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
606 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
607 if (seltype == ELM_SEL_CLIPBOARD)
608 eina_stringshare_replace(&wd->cut_sel, sel);
612 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
614 Widget_Data *wd = elm_widget_data_get(data);
617 wd->selmode = EINA_FALSE;
618 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
619 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
620 elm_widget_scroll_hold_pop(data);
621 _store_selection(ELM_SEL_CLIPBOARD, data);
622 edje_object_part_text_insert(wd->ent, "elm.text", "");
623 edje_object_part_text_select_none(wd->ent, "elm.text");
627 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
629 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_select_none(wd->ent, "elm.text");
640 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
642 Widget_Data *wd = elm_widget_data_get(data);
644 wd->selmode = EINA_FALSE;
645 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
646 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
647 elm_widget_scroll_hold_pop(data);
648 edje_object_part_text_select_none(wd->ent, "elm.text");
652 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
654 Widget_Data *wd = elm_widget_data_get(data);
658 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
659 cnpwidgetdata = data;
660 elm_cbhm_helper_init(obj);
661 elm_cbhm_send_raw_data("show");
667 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
669 Widget_Data *wd = elm_widget_data_get(data);
671 cnpwidgetdata = data;
677 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
679 Elm_Entry_Context_Menu_Item *it = data;
680 Evas_Object *obj2 = it->obj;
682 if (it->func) it->func(it->data, obj2, NULL);
686 _long_press(void *data)
688 Widget_Data *wd = elm_widget_data_get(data);
691 const Elm_Entry_Context_Menu_Item *it;
692 if (!wd) return ECORE_CALLBACK_CANCEL;
694 if (wd->longpress_timer)
696 ecore_timer_del(wd->longpress_timer);
697 wd->longpress_timer = NULL;
700 if ((wd->api) && (wd->api->obj_longpress))
702 wd->api->obj_longpress(data);
704 else if (wd->context_menu)
706 const char *context_menu_orientation;
708 if (wd->hoversel) evas_object_del(wd->hoversel);
709 else elm_widget_scroll_freeze_push(data);
710 wd->hoversel = elm_hoversel_add(data);
711 context_menu_orientation = edje_object_data_get
712 (wd->ent, "context_menu_orientation");
713 if ((context_menu_orientation) &&
714 (!strcmp(context_menu_orientation, "horizontal")))
715 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
716 elm_object_style_set(wd->hoversel, "entry");
717 elm_widget_sub_object_add(data, wd->hoversel);
718 elm_hoversel_label_set(wd->hoversel, "Text");
719 top = elm_widget_top_get(data);
720 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
721 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
725 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
727 if (1) // need way to detect if someone has a selection
730 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
735 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
736 _clipboard_menu, data);
743 if (wd->have_selection)
745 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
748 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
751 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
754 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
755 _clipboard_menu, data);
759 EINA_LIST_FOREACH(wd->items, l, it)
761 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
762 it->icon_type, _item_clicked, it);
766 _hoversel_position(data);
767 evas_object_show(wd->hoversel);
768 elm_hoversel_hover_begin(wd->hoversel);
770 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
771 edje_object_part_text_select_abort(wd->ent, "elm.text");
773 wd->longpress_timer = NULL;
774 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
775 return ECORE_CALLBACK_CANCEL;
779 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
781 Widget_Data *wd = elm_widget_data_get(data);
782 Evas_Event_Mouse_Down *ev = event_info;
784 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
785 if (ev->button != 1) return;
786 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
787 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
788 wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
789 wd->downx = ev->canvas.x;
790 wd->downy = ev->canvas.y;
794 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
796 Widget_Data *wd = elm_widget_data_get(data);
797 Evas_Event_Mouse_Up *ev = event_info;
799 if (ev->button != 1) return;
801 if (!wd->double_clicked)
803 if ((wd->api) && (wd->api->obj_mouseup))
805 wd->api->obj_mouseup(data);
808 if (wd->longpress_timer)
810 ecore_timer_del(wd->longpress_timer);
811 wd->longpress_timer = NULL;
816 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
818 Widget_Data *wd = elm_widget_data_get(data);
819 Evas_Event_Mouse_Move *ev = event_info;
823 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
825 if (wd->longpress_timer)
827 ecore_timer_del(wd->longpress_timer);
828 wd->longpress_timer = NULL;
831 else if (wd->longpress_timer)
835 dx = wd->downx - ev->cur.canvas.x;
837 dy = wd->downy - ev->cur.canvas.y;
840 ((_elm_config->finger_size / 2) *
841 (_elm_config->finger_size / 2)))
843 ecore_timer_del(wd->longpress_timer);
844 wd->longpress_timer = NULL;
848 else if (wd->longpress_timer)
852 dx = wd->downx - ev->cur.canvas.x;
854 dy = wd->downy - ev->cur.canvas.y;
857 ((_elm_config->finger_size / 2) *
858 (_elm_config->finger_size / 2)))
860 ecore_timer_del(wd->longpress_timer);
861 wd->longpress_timer = NULL;
867 _getbase(Evas_Object *obj)
869 Widget_Data *wd = elm_widget_data_get(obj);
870 if (!wd) return "base";
875 if (wd->show_last_character) return "custom-password";
876 else return "base-password";
880 if (wd->single_line) return "base-single";
883 if (wd->linewrap) return "base";
884 else if (wd->char_linewrap) return "base-charwrap";
885 else return "base-nowrap";
893 if (wd->show_last_character) return "custom-password";
894 else return "base-password";
898 if (wd->single_line) return "base-single-noedit";
901 if (wd->linewrap) return "base-noedit";
902 else if (wd->char_linewrap) return "base-noedit-charwrap";
903 else return "base-nowrap-noedit";
911 _str_append(char *str, const char *txt, int *len, int *alloc)
913 int txt_len = strlen(txt);
915 if (txt_len <= 0) return str;
916 if ((*len + txt_len) >= *alloc)
921 alloc2 = *alloc + txt_len + 128;
922 str2 = realloc(str, alloc2);
923 if (!str2) return str;
927 strcpy(str + *len, txt);
932 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
933 * because some markups can be implemented otherwise according to style.
934 * probably doing it in textblock and making it translate according to it's
935 * style is correct. */
937 _strncpy(char* dest, const char* src, size_t count)
941 ERR( "dest is NULL" );
946 ERR( "src is NULL" );
951 ERR( "count is smaller than 0" );
955 return strncpy( dest, src, count );
959 _mkup_to_text(const char *mkup)
962 int str_len = 0, str_alloc = 0;
964 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
966 if (!mkup) return NULL;
968 tag_start = tag_end = esc_start = esc_end = NULL;
973 if (((p!=NULL)&&(*p == 0)) ||
974 (tag_end) || (esc_end) ||
975 (tag_start) || (esc_start))
981 ttag = malloc(tag_end - tag_start);
984 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
985 ttag[tag_end - tag_start - 1] = 0;
986 if (!strcmp(ttag, "br"))
987 str = _str_append(str, "\n", &str_len, &str_alloc);
988 else if (!strcmp(ttag, "\n"))
989 str = _str_append(str, "\n", &str_len, &str_alloc);
990 else if (!strcmp(ttag, "\\n"))
991 str = _str_append(str, "\n", &str_len, &str_alloc);
992 else if (!strcmp(ttag, "\t"))
993 str = _str_append(str, "\t", &str_len, &str_alloc);
994 else if (!strcmp(ttag, "\\t"))
995 str = _str_append(str, "\t", &str_len, &str_alloc);
996 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
997 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1000 tag_start = tag_end = NULL;
1004 ts = malloc(esc_end - esc_start + 1);
1008 _strncpy(ts, esc_start, esc_end - esc_start);
1009 ts[esc_end - esc_start] = 0;
1010 esc = evas_textblock_escape_string_get(ts);
1012 str = _str_append(str, esc, &str_len, &str_alloc);
1015 esc_start = esc_end = NULL;
1017 else if ((p!=NULL)&&(*p == 0))
1019 ts = malloc(p - s + 1);
1022 _strncpy(ts, s, p - s);
1024 str = _str_append(str, ts, &str_len, &str_alloc);
1030 if ((p!=NULL)&&(*p == '<'))
1036 ts = malloc(p - s + 1);
1039 _strncpy(ts, s, p - s);
1041 str = _str_append(str, ts, &str_len, &str_alloc);
1047 else if ((p!=NULL)&&(*p == '>'))
1055 else if ((p!=NULL)&&(*p == '&'))
1061 ts = malloc(p - s + 1);
1064 _strncpy(ts, s, p - s);
1066 str = _str_append(str, ts, &str_len, &str_alloc);
1072 else if ((p!=NULL)&&(*p == ';'))
1086 _entry_length_get(Evas_Object *obj)
1089 const char *str = elm_entry_entry_get(obj);
1092 char *plain_str = _mkup_to_text(str);
1093 if (!plain_str) return 0;
1095 len = strlen(plain_str);
1102 _text_to_mkup(const char *text)
1105 int str_len = 0, str_alloc = 0;
1106 int ch, pos = 0, pos2 = 0;
1108 if (!text) return NULL;
1112 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1113 if ((ch <= 0) || (pos2 <= 0)) break;
1115 str = _str_append(str, "<br>", &str_len, &str_alloc);
1116 else if (ch == '\t')
1117 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1119 str = _str_append(str, "<", &str_len, &str_alloc);
1121 str = _str_append(str, ">", &str_len, &str_alloc);
1123 str = _str_append(str, "&", &str_len, &str_alloc);
1124 else if (ch == 0x2029)
1125 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1130 _strncpy(tstr, text + pos, pos2 - pos);
1131 tstr[pos2 - pos] = 0;
1132 str = _str_append(str, tstr, &str_len, &str_alloc);
1139 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1141 Widget_Data *wd = elm_widget_data_get(data);
1143 wd->changed = EINA_TRUE;
1145 if (wd->text) eina_stringshare_del(wd->text);
1147 _check_enable_returnkey(data);
1148 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1152 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1154 Widget_Data *wd = elm_widget_data_get(data);
1155 elm_object_scroll_freeze_push(data);
1159 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1161 Widget_Data *wd = elm_widget_data_get(data);
1162 elm_object_scroll_freeze_pop(data);
1166 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1168 Widget_Data *wd = elm_widget_data_get(data);
1172 EINA_LIST_FOREACH(entries, l, entry)
1174 if (entry != data) elm_entry_select_none(entry);
1176 wd->have_selection = EINA_TRUE;
1177 wd->selmode = EINA_TRUE;
1178 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1179 #ifdef HAVE_ELEMENTARY_X
1180 if (wd->sel_notify_handler)
1182 const char *txt = elm_entry_selection_get(data);
1185 top = elm_widget_top_get(data);
1186 if ((top) && (elm_win_xwindow_get(top)))
1187 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1193 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1195 Evas_Coord cx, cy, cw, ch;
1196 Widget_Data *wd = elm_widget_data_get(data);
1198 wd->have_selection = EINA_TRUE;
1199 wd->selmode = EINA_TRUE;
1200 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1201 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1202 elm_entry_selection_get(data));
1204 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1205 if (!wd->deferred_recalc_job)
1206 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1209 wd->deferred_cur = EINA_TRUE;
1213 wd->ch = ch + elm_finger_size_get();
1218 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1220 Widget_Data *wd = elm_widget_data_get(data);
1222 if (!wd->have_selection) return;
1223 wd->have_selection = EINA_FALSE;
1224 wd->selmode = EINA_FALSE;
1225 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1226 if (wd->sel_notify_handler)
1230 #ifdef HAVE_ELEMENTARY_X
1233 top = elm_widget_top_get(data);
1234 if ((top) && (elm_win_xwindow_get(top)))
1235 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1238 eina_stringshare_del(wd->cut_sel);
1243 #ifdef HAVE_ELEMENTARY_X
1246 top = elm_widget_top_get(data);
1247 if ((top) && (elm_win_xwindow_get(top)))
1248 elm_selection_clear(ELM_SEL_PRIMARY, data);
1255 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1257 Widget_Data *wd = elm_widget_data_get(data);
1259 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1260 if (wd->sel_notify_handler)
1262 #ifdef HAVE_ELEMENTARY_X
1265 top = elm_widget_top_get(data);
1266 if ((top) && (elm_win_xwindow_get(top)))
1268 wd->selection_asked = EINA_TRUE;
1269 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1276 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1278 Widget_Data *wd = elm_widget_data_get(data);
1280 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1281 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1282 elm_entry_selection_get(data));
1286 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1288 Widget_Data *wd = elm_widget_data_get(data);
1290 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1291 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1292 elm_entry_selection_get(data));
1293 edje_object_part_text_insert(wd->ent, "elm.text", "");
1294 wd->changed = EINA_TRUE;
1299 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1301 Widget_Data *wd = elm_widget_data_get(data);
1302 Evas_Coord cx, cy, cw, ch;
1304 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1305 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1306 &cx, &cy, &cw, &ch);
1307 if (!wd->deferred_recalc_job)
1308 elm_widget_show_region_set(data, cx, cy, cw, ch);
1311 wd->deferred_cur = EINA_TRUE;
1317 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1318 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1323 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1325 Widget_Data *wd = elm_widget_data_get(data);
1330 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1332 Widget_Data *wd = elm_widget_data_get(data);
1333 Elm_Entry_Anchor_Info ei;
1334 char *buf2, *p, *p2, *n;
1336 p = strrchr(emission, ',');
1339 const Eina_List *geoms;
1343 while (p2 >= emission)
1345 if (*p2 == ',') break;
1349 buf2 = alloca(5 + p - p2);
1350 strncpy(buf2, p2, p - p2);
1353 ei.button = atoi(buf2);
1354 ei.x = ei.y = ei.w = ei.h = 0;
1356 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1359 Evas_Textblock_Rectangle *r;
1361 Evas_Coord px, py, x, y;
1363 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1364 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1365 EINA_LIST_FOREACH(geoms, l, r)
1367 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1368 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1379 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1384 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1386 Widget_Data *wd = elm_widget_data_get(data);
1391 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1393 Widget_Data *wd = elm_widget_data_get(data);
1398 _signal_anchor_out(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_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1407 Widget_Data *wd = elm_widget_data_get(data);
1409 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1413 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1415 Widget_Data *wd = elm_widget_data_get(data);
1417 wd->double_clicked = EINA_FALSE;
1418 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1422 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1424 Widget_Data *wd = elm_widget_data_get(data);
1426 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1430 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1432 Widget_Data *wd = elm_widget_data_get(data);
1434 wd->double_clicked = EINA_TRUE;
1435 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1438 #ifdef HAVE_ELEMENTARY_X
1440 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1442 Widget_Data *wd = elm_widget_data_get(data);
1443 Ecore_X_Event_Selection_Notify *ev = event;
1444 if (!wd) return ECORE_CALLBACK_PASS_ON;
1445 if (!wd->selection_asked && !wd->drag_selection_asked)
1446 return ECORE_CALLBACK_PASS_ON;
1448 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1449 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1451 Ecore_X_Selection_Data_Text *text_data;
1453 text_data = ev->data;
1454 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1456 if (text_data->text)
1458 char *txt = _text_to_mkup(text_data->text);
1462 elm_entry_entry_insert(data, txt);
1467 wd->selection_asked = EINA_FALSE;
1469 else if (ev->selection == ECORE_X_SELECTION_XDND)
1471 Ecore_X_Selection_Data_Text *text_data;
1473 text_data = ev->data;
1474 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1476 if (text_data->text)
1478 char *txt = _text_to_mkup(text_data->text);
1482 /* Massive FIXME: this should be at the drag point */
1483 elm_entry_entry_insert(data, txt);
1488 wd->drag_selection_asked = EINA_FALSE;
1490 ecore_x_dnd_send_finished();
1494 return ECORE_CALLBACK_PASS_ON;
1498 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1501 Widget_Data *wd = elm_widget_data_get(data);
1502 Ecore_X_Event_Selection_Clear *ev = event;
1503 if (!wd) return ECORE_CALLBACK_PASS_ON;
1504 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1505 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1506 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1508 elm_entry_select_none(data);
1513 Evas_Object *top = elm_widget_top_get(data);
1514 Ecore_X_Event_Selection_Clear *ev = event;
1517 return ECORE_CALLBACK_PASS_ON;
1519 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1521 return ECORE_CALLBACK_PASS_ON;
1524 if (cnpwidgetdata == data)
1526 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1530 return ECORE_CALLBACK_PASS_ON;
1535 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1540 wd = elm_widget_data_get(obj);
1542 if (!wd) return EINA_FALSE;
1543 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1545 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1546 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1547 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1548 EDJE_CURSOR_MAIN,drop->x,drop->y);
1549 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1550 elm_entry_entry_insert(obj, drop->data);
1551 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1552 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1558 static Evas_Object *
1559 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1561 Widget_Data *wd = elm_widget_data_get(data);
1564 Elm_Entry_Item_Provider *ip;
1567 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1569 o = ip->func(ip->data, data, item);
1572 o = edje_object_add(evas_object_evas_get(data));
1573 if (!strncmp(item, "emoticon/", 9))
1574 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1576 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1581 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1583 char *curlocater, *starttag, *endtag;
1584 int firstindex = 0, foundflag = -1;
1586 curlocater = strstr(oldstring, key);
1589 starttag = curlocater;
1590 endtag = curlocater + strlen(key);
1591 if (endtag == NULL || *endtag != '=')
1597 firstindex = abs(oldstring - curlocater);
1598 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1599 *value = (char*)oldstring + firstindex;
1601 while (oldstring != starttag)
1603 if (*starttag == '>')
1608 if (*starttag == '<')
1612 if (starttag == NULL) break;
1615 while (NULL != endtag)
1626 if (endtag == NULL) break;
1629 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1639 if (foundflag == 1) return 0;
1645 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1647 const char *srcstring = NULL;
1648 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1649 char *curlocater, *replocater;
1650 char *starttag, *endtag;
1651 int tagtxtlen = 0, insertflag = 0;
1653 srcstring = eina_strbuf_string_get(srcbuf);
1654 curlocater = strstr(srcstring, key);
1656 if (curlocater == NULL)
1664 starttag = strchr(srcstring, '<');
1665 endtag = strchr(srcstring, '>');
1666 tagtxtlen = endtag - starttag;
1667 if (tagtxtlen <= 0) tagtxtlen = 0;
1668 if (starttag < curlocater && curlocater < endtag) break;
1669 if (endtag != NULL && endtag+1 != NULL)
1670 srcstring = endtag+1;
1673 } while (strlen(srcstring) > 1);
1675 if (starttag && endtag && tagtxtlen > strlen(key))
1677 repbuf = eina_strbuf_new();
1678 diffbuf = eina_strbuf_new();
1679 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1680 srcstring = eina_strbuf_string_get(repbuf);
1681 curlocater = strstr(srcstring, key);
1683 if (curlocater != NULL)
1685 replocater = curlocater + strlen(key) + 1;
1687 while (*replocater == ' ' || *replocater == '=')
1692 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1695 if (replocater-curlocater > strlen(key)+1)
1698 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1707 eina_strbuf_reset(repbuf);
1715 if (repbuf == NULL) repbuf = eina_strbuf_new();
1716 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1720 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1721 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1727 eina_strbuf_prepend(diffbuf, "<");
1728 eina_strbuf_append(diffbuf, ">");
1729 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1733 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1734 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1738 if (repbuf) eina_strbuf_free(repbuf);
1739 if (diffbuf) eina_strbuf_free(diffbuf);
1745 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1747 Eina_Strbuf *sharebuf = NULL;
1749 sharebuf = eina_strbuf_new();
1750 eina_strbuf_append(sharebuf, *srcstring);
1751 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1752 eina_stringshare_del(*srcstring);
1753 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1754 eina_strbuf_free(sharebuf);
1760 _is_width_over(Evas_Object *obj)
1762 Evas_Coord x, y, w, h;
1763 Evas_Coord vx, vy, vw, vh;
1764 Widget_Data *wd = elm_widget_data_get(obj);
1768 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1770 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1772 if (x >= 0 && y >= 0)
1775 if (4 < wd->wrap_w && w > wd->wrap_w)
1782 _reverse_ellipsis_entry(Evas_Object *obj)
1784 Widget_Data *wd = elm_widget_data_get(obj);
1785 int cur_fontsize = 0;
1786 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1787 char **kvalue = NULL;
1788 const char *minfont, *deffont, *maxfont;
1789 const char *ellipsis_string = "...";
1790 int minfontsize, maxfontsize, minshowcount;
1792 minshowcount = strlen(ellipsis_string) + 1;
1793 minfont = edje_object_data_get(wd->ent, "min_font_size");
1794 if (minfont) minfontsize = atoi(minfont);
1795 else minfontsize = 1;
1796 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1797 if (maxfont) maxfontsize = atoi(maxfont);
1798 else maxfontsize = 1;
1799 deffont = edje_object_data_get(wd->ent, "default_font_size");
1800 if (deffont) cur_fontsize = atoi(deffont);
1801 else cur_fontsize = 1;
1802 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1803 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1805 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1807 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1810 txtbuf = eina_strbuf_new();
1811 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1813 if (cur_fontsize >= atoi(deffont))
1815 if (txtbuf) eina_strbuf_free(txtbuf);
1819 if (_is_width_over(obj) != 1)
1821 int rev_fontsize = cur_fontsize;
1825 if (rev_fontsize > atoi(deffont))
1828 if (fontbuf != NULL)
1830 eina_strbuf_free(fontbuf);
1833 fontbuf = eina_strbuf_new();
1834 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1835 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1836 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1838 eina_strbuf_free(fontbuf);
1840 } while (_is_width_over(obj) != 1);
1842 while (_is_width_over(obj))
1845 if (rev_fontsize < atoi(deffont))
1848 if (fontbuf != NULL)
1850 eina_strbuf_free(fontbuf);
1853 fontbuf = eina_strbuf_new();
1854 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1855 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1856 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1857 eina_strbuf_free(fontbuf);
1862 if (txtbuf) eina_strbuf_free(txtbuf);
1868 _ellipsis_entry_to_width(Evas_Object *obj)
1870 Widget_Data *wd = elm_widget_data_get(obj);
1871 int cur_fontsize = 0, len, jumpcount;
1872 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1873 char **kvalue = NULL;
1874 const char *minfont, *deffont, *maxfont;
1875 const char *ellipsis_string = "...";
1876 int minfontsize, maxfontsize, minshowcount;
1877 int i, tagend, cur_len;
1880 minshowcount = strlen(ellipsis_string) + 1;
1881 minfont = edje_object_data_get(wd->ent, "min_font_size");
1882 if (minfont) minfontsize = atoi(minfont);
1883 else minfontsize = 1;
1884 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1885 if (maxfont) maxfontsize = atoi(maxfont);
1886 else maxfontsize = 1;
1887 deffont = edje_object_data_get(wd->ent, "default_font_size");
1888 if (deffont) cur_fontsize = atoi(deffont);
1889 else cur_fontsize = 1;
1890 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1891 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1893 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1895 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1898 txtbuf = eina_strbuf_new();
1899 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1901 while (_is_width_over(obj))
1903 if (wd->ellipsis_threshold == 0)
1904 wd->ellipsis_threshold = _entry_length_get(obj);
1905 if (cur_fontsize > minfontsize)
1908 if (fontbuf != NULL)
1910 eina_strbuf_free(fontbuf);
1913 fontbuf = eina_strbuf_new();
1914 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1915 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1916 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1917 eina_strbuf_free(fontbuf);
1919 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1923 len = _entry_length_get(obj);
1924 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1925 cur_len = strlen(cur_str);
1927 for (i = 0; i < len; i++)
1929 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1930 cur_str[i+1] != '<')
1937 while (jumpcount < len-strlen(ellipsis_string))
1939 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1943 eina_strbuf_free(txtbuf);
1946 txtbuf = eina_strbuf_new();
1947 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1948 eina_strbuf_append(txtbuf, ellipsis_string);
1949 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1950 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1951 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1953 if (_is_width_over(obj))
1961 if (txtbuf) eina_strbuf_free(txtbuf);
1966 static int _textinput_control_function(void *data,void *input_data)
1968 /*calculate character count*/
1969 Evas_Object *entry = (Evas_Object *)data;
1970 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
1973 size_t insert_text_len=0;
1974 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1976 size_t remain_bytes;
1979 byte_len = strlen(text);/*no of bytes*/
1980 remain_bytes = wd->max_no_of_bytes-byte_len;
1981 sprintf(buf,"%d",remain_bytes);
1982 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1985 insert_text = (char *)input_data;
1986 insert_text_len = strlen(insert_text);
1987 if(remain_bytes<insert_text_len)
1989 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1992 if(byte_len>=wd->max_no_of_bytes)
1994 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2003 * This adds an entry to @p parent object.
2005 * @param parent The parent object
2006 * @return The new object or NULL if it cannot be created
2011 elm_entry_add(Evas_Object *parent)
2013 Evas_Object *obj, *top;
2017 wd = ELM_NEW(Widget_Data);
2018 e = evas_object_evas_get(parent);
2019 wd->bgcolor = EINA_FALSE;
2020 wd->bg = evas_object_rectangle_add(e);
2021 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2022 obj = elm_widget_add(e);
2023 ELM_SET_WIDTYPE(widtype, "entry");
2024 elm_widget_type_set(obj, "entry");
2025 elm_widget_sub_object_add(parent, obj);
2026 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2027 elm_widget_data_set(obj, wd);
2028 elm_widget_del_hook_set(obj, _del_hook);
2029 elm_widget_theme_hook_set(obj, _theme_hook);
2030 elm_widget_disable_hook_set(obj, _disable_hook);
2031 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2032 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2033 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2034 elm_widget_can_focus_set(obj, 1);
2035 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2036 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2039 wd->linewrap = EINA_TRUE;
2040 wd->ellipsis = EINA_FALSE;
2041 wd->char_linewrap= EINA_FALSE;
2042 wd->editable = EINA_TRUE;
2043 wd->disabled = EINA_FALSE;
2044 wd->context_menu = EINA_TRUE;
2045 wd->autoperiod = EINA_TRUE;
2047 wd->ellipsis_threshold = 0;
2049 wd->ent = edje_object_add(e);
2050 edje_object_item_provider_set(wd->ent, _get_item, obj);
2051 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2052 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2053 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2055 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2057 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2060 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2061 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2062 _signal_entry_changed, obj);
2063 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2064 _signal_handler_move_start, obj);
2065 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2066 _signal_handler_move_end, obj);
2067 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2068 _signal_selection_start, obj);
2069 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2070 _signal_selection_changed, obj);
2071 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2072 _signal_selection_cleared, obj);
2073 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2074 _signal_entry_paste_request, obj);
2075 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2076 _signal_entry_copy_notify, obj);
2077 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2078 _signal_entry_cut_notify, obj);
2079 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2080 _signal_cursor_changed, obj);
2081 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2082 _signal_anchor_down, obj);
2083 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2084 _signal_anchor_up, obj);
2085 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2086 _signal_anchor_move, obj);
2087 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2088 _signal_anchor_in, obj);
2089 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2090 _signal_anchor_out, obj);
2091 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2092 _signal_key_enter, obj);
2093 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2094 _signal_mouse_down, obj);
2095 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2096 _signal_mouse_up, obj);
2097 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2098 _signal_mouse_double, obj);
2099 edje_object_part_text_set(wd->ent, "elm.text", "");
2100 elm_widget_resize_object_set(obj, wd->ent);
2103 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2105 #ifdef HAVE_ELEMENTARY_X
2106 top = elm_widget_top_get(obj);
2107 if ((top) && (elm_win_xwindow_get(top)))
2109 wd->sel_notify_handler =
2110 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2111 _event_selection_notify, obj);
2112 wd->sel_clear_handler =
2113 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2114 _event_selection_clear, obj);
2117 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2120 entries = eina_list_prepend(entries, obj);
2122 // module - find module for entry
2123 wd->api = _module(obj);
2124 // if found - hook in
2125 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2127 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2128 // TODO: and save some bytes, making descriptions per-class and not instance!
2129 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2133 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2135 ELM_CHECK_WIDTYPE(obj, widtype);
2136 Widget_Data *wd = elm_widget_data_get(obj);
2138 ext_mod->cancel = _cancel;
2139 ext_mod->copy = _copy;
2140 ext_mod->cut = _cut;
2141 ext_mod->paste = _paste;
2142 ext_mod->select = _select;
2143 ext_mod->selectall = NULL; /* to be implemented*/
2144 ext_mod->ent = wd->ent;
2145 ext_mod->items = wd->items;
2146 ext_mod->longpress_timer = wd->longpress_timer;
2147 ext_mod->editable = wd->editable;
2148 ext_mod->have_selection = wd->have_selection;
2149 ext_mod->password = wd->password;
2150 ext_mod->selmode = wd->selmode;
2151 ext_mod->cnpinit = _cnpinit;
2152 ext_mod->context_menu = wd->context_menu;
2156 * This sets the entry object not to line wrap. All input will
2157 * be on a single line, and the entry box will extend with user input.
2159 * @param obj The entry object
2160 * @param single_line If true, the text in the entry
2161 * will be on a single line.
2166 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2168 ELM_CHECK_WIDTYPE(obj, widtype);
2169 Widget_Data *wd = elm_widget_data_get(obj);
2171 Ecore_IMF_Context *ic;
2173 if (wd->single_line == single_line) return;
2174 wd->single_line = single_line;
2175 wd->linewrap = EINA_FALSE;
2176 wd->char_linewrap = EINA_FALSE;
2177 t = eina_stringshare_add(elm_entry_entry_get(obj));
2178 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2179 elm_entry_entry_set(obj, t);
2180 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2181 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2182 ic = elm_entry_imf_context_get(obj);
2185 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2188 eina_stringshare_del(t);
2193 * This returns true if the entry has been set to single line mode.
2194 * See also elm_entry_single_line_set().
2196 * @param obj The entry object
2197 * @return single_line If true, the text in the entry is set to display
2203 elm_entry_single_line_get(const Evas_Object *obj)
2205 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2206 Widget_Data *wd = elm_widget_data_get(obj);
2207 if (!wd) return EINA_FALSE;
2208 return wd->single_line;
2212 * This set's the maximum bytes that can be added in entry.
2214 * @param obj The entry object
2215 * @param max_no_of_bytes Maximum number of bytes entry can have.
2220 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2222 Widget_Data *wd = elm_widget_data_get(obj);
2224 wd->max_no_of_bytes = max_no_of_bytes;
2225 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2226 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2231 * This sets the entry object to password mode. All text entered
2232 * and/or displayed within the widget will be replaced with asterisks (*).
2234 * @param obj The entry object
2235 * @param password If true, password mode is enabled.
2240 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2242 ELM_CHECK_WIDTYPE(obj, widtype);
2243 Widget_Data *wd = elm_widget_data_get(obj);
2244 Ecore_IMF_Context *ic;
2247 if (wd->password == password) return;
2248 wd->password = password;
2249 wd->single_line = EINA_TRUE;
2250 wd->linewrap = EINA_FALSE;
2251 wd->char_linewrap = EINA_FALSE;
2252 if (_elm_config->password_show_last_character)
2253 wd->show_last_character = EINA_TRUE;
2254 t = eina_stringshare_add(elm_entry_entry_get(obj));
2255 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2256 elm_entry_entry_set(obj, t);
2262 elm_entry_autoperiod_set(obj, EINA_FALSE);
2265 if (wd->autocapital)
2267 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2271 ic = elm_entry_imf_context_get(obj);
2274 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2277 eina_stringshare_del(t);
2282 * This set's the entry in password mode with out masking the last character entered by user,
2283 * and later masking the character after 2 seconds.
2285 * @param obj The entry object
2286 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2292 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2294 Widget_Data *wd = elm_widget_data_get(obj);
2297 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2298 wd->show_last_character = show_last_character;
2299 wd->password = show_last_character;
2300 wd->single_line = EINA_TRUE;
2301 wd->linewrap = EINA_FALSE;
2302 wd->char_linewrap = EINA_FALSE;
2303 t = eina_stringshare_add(elm_entry_entry_get(obj));
2304 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2305 elm_entry_entry_set(obj, t);
2306 eina_stringshare_del(t);
2311 * This returns whether password mode is enabled.
2312 * See also elm_entry_password_set().
2314 * @param obj The entry object
2315 * @return If true, the entry is set to display all characters
2321 elm_entry_password_get(const Evas_Object *obj)
2323 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2324 Widget_Data *wd = elm_widget_data_get(obj);
2325 if (!wd) return EINA_FALSE;
2326 return wd->password;
2330 * This sets the text displayed within the entry to @p entry.
2332 * @param obj The entry object
2333 * @param entry The text to be displayed
2338 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2340 ELM_CHECK_WIDTYPE(obj, widtype);
2341 Widget_Data *wd = elm_widget_data_get(obj);
2343 if (!entry) entry = "";
2344 if(wd->max_no_of_bytes)
2346 int len = strlen(entry);
2347 if(len > wd->max_no_of_bytes)
2349 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2353 edje_object_part_text_set(wd->ent, "elm.text", entry);
2354 if (wd->text) eina_stringshare_del(wd->text);
2356 wd->changed = EINA_TRUE;
2361 * This returns the text currently shown in object @p entry.
2362 * See also elm_entry_entry_set().
2364 * @param obj The entry object
2365 * @return The currently displayed text or NULL on failure
2370 elm_entry_entry_get(const Evas_Object *obj)
2372 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2373 Widget_Data *wd = elm_widget_data_get(obj);
2375 if (!wd) return NULL;
2377 if ((wd->text)&&(wd->password))
2378 return elm_entry_markup_to_utf8(wd->text);
2380 if (wd->text) return wd->text;
2381 text = edje_object_part_text_get(wd->ent, "elm.text");
2384 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2387 eina_stringshare_replace(&wd->text, text);
2388 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2393 * This returns all selected text within the entry.
2395 * @param obj The entry object
2396 * @return The selected text within the entry or NULL on failure
2401 elm_entry_selection_get(const Evas_Object *obj)
2403 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2404 Widget_Data *wd = elm_widget_data_get(obj);
2405 if (!wd) return NULL;
2406 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2410 * This inserts text in @p entry at the beginning of the entry
2413 * @param obj The entry object
2414 * @param entry The text to insert
2419 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2421 ELM_CHECK_WIDTYPE(obj, widtype);
2422 Widget_Data *wd = elm_widget_data_get(obj);
2424 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2426 if (cnpwidgetdata == obj)
2427 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2429 wd->changed = EINA_TRUE;
2434 * This enables word line wrapping in the entry object. It is the opposite
2435 * of elm_entry_single_line_set(). Additionally, setting this disables
2436 * character line wrapping.
2437 * See also elm_entry_line_char_wrap_set().
2439 * @param obj The entry object
2440 * @param wrap If true, the entry will be wrapped once it reaches the end
2441 * of the object. Wrapping will occur at the end of the word before the end of the
2447 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2449 ELM_CHECK_WIDTYPE(obj, widtype);
2450 Widget_Data *wd = elm_widget_data_get(obj);
2453 if (wd->linewrap == wrap) return;
2454 wd->linewrap = wrap;
2456 wd->char_linewrap = EINA_FALSE;
2457 t = eina_stringshare_add(elm_entry_entry_get(obj));
2458 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2459 elm_entry_entry_set(obj, t);
2460 eina_stringshare_del(t);
2465 * Set wrap width of the entry
2467 * @param obj The entry object
2468 * @param w The wrap width in pixels at a minimum where words need to wrap
2472 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2474 Widget_Data *wd = elm_widget_data_get(obj);
2475 if (wd->wrap_w == w) return;
2481 * get wrap width of the entry
2483 * @param obj The entry object
2484 * @return The wrap width in pixels at a minimum where words need to wrap
2488 elm_entry_wrap_width_get(const Evas_Object *obj)
2490 Widget_Data *wd = elm_widget_data_get(obj);
2495 * This enables character line wrapping in the entry object. It is the opposite
2496 * of elm_entry_single_line_set(). Additionally, setting this disables
2497 * word line wrapping.
2498 * See also elm_entry_line_wrap_set().
2500 * @param obj The entry object
2501 * @param wrap If true, the entry will be wrapped once it reaches the end
2502 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2507 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2509 ELM_CHECK_WIDTYPE(obj, widtype);
2510 Widget_Data *wd = elm_widget_data_get(obj);
2513 if (wd->char_linewrap == wrap) return;
2514 wd->char_linewrap = wrap;
2515 if(wd->char_linewrap)
2516 wd->linewrap = EINA_FALSE;
2517 t = eina_stringshare_add(elm_entry_entry_get(obj));
2518 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2519 elm_entry_entry_set(obj, t);
2520 eina_stringshare_del(t);
2525 * This sets the editable attribute of the entry.
2527 * @param obj The entry object
2528 * @param editable If true, the entry will be editable by the user.
2529 * If false, it will be set to the disabled state.
2534 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2536 ELM_CHECK_WIDTYPE(obj, widtype);
2537 Widget_Data *wd = elm_widget_data_get(obj);
2540 if (wd->editable == editable) return;
2541 wd->editable = editable;
2542 t = eina_stringshare_add(elm_entry_entry_get(obj));
2543 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2544 elm_entry_entry_set(obj, t);
2545 eina_stringshare_del(t);
2548 #ifdef HAVE_ELEMENTARY_X
2550 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2552 elm_drop_target_del(obj);
2557 * This gets the editable attribute of the entry.
2558 * See also elm_entry_editable_set().
2560 * @param obj The entry object
2561 * @return If true, the entry is editable by the user.
2562 * If false, it is not editable by the user
2567 elm_entry_editable_get(const Evas_Object *obj)
2569 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2570 Widget_Data *wd = elm_widget_data_get(obj);
2571 if (!wd) return EINA_FALSE;
2572 return wd->editable;
2576 * This drops any existing text selection within the entry.
2578 * @param obj The entry object
2583 elm_entry_select_none(Evas_Object *obj)
2585 ELM_CHECK_WIDTYPE(obj, widtype);
2586 Widget_Data *wd = elm_widget_data_get(obj);
2590 wd->selmode = EINA_FALSE;
2591 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2592 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2594 wd->have_selection = EINA_FALSE;
2595 edje_object_part_text_select_none(wd->ent, "elm.text");
2599 * This selects all text within the entry.
2601 * @param obj The entry object
2606 elm_entry_select_all(Evas_Object *obj)
2608 ELM_CHECK_WIDTYPE(obj, widtype);
2609 Widget_Data *wd = elm_widget_data_get(obj);
2613 wd->selmode = EINA_FALSE;
2614 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2615 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2617 wd->have_selection = EINA_TRUE;
2618 edje_object_part_text_select_all(wd->ent, "elm.text");
2622 * This moves the cursor one place to the right within the entry.
2624 * @param obj The entry object
2625 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2630 elm_entry_cursor_next(Evas_Object *obj)
2632 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2633 Widget_Data *wd = elm_widget_data_get(obj);
2634 if (!wd) return EINA_FALSE;
2635 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2639 * This moves the cursor one place to the left within the entry.
2641 * @param obj The entry object
2642 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2647 elm_entry_cursor_prev(Evas_Object *obj)
2649 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2650 Widget_Data *wd = elm_widget_data_get(obj);
2651 if (!wd) return EINA_FALSE;
2652 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2656 * This moves the cursor one line up within the entry.
2658 * @param obj The entry object
2659 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2664 elm_entry_cursor_up(Evas_Object *obj)
2666 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2667 Widget_Data *wd = elm_widget_data_get(obj);
2668 if (!wd) return EINA_FALSE;
2669 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2673 * This moves the cursor one line down within the entry.
2675 * @param obj The entry object
2676 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2681 elm_entry_cursor_down(Evas_Object *obj)
2683 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2684 Widget_Data *wd = elm_widget_data_get(obj);
2685 if (!wd) return EINA_FALSE;
2686 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2690 * This moves the cursor to the beginning of the entry.
2692 * @param obj The entry object
2697 elm_entry_cursor_begin_set(Evas_Object *obj)
2699 ELM_CHECK_WIDTYPE(obj, widtype);
2700 Widget_Data *wd = elm_widget_data_get(obj);
2702 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2706 * This moves the cursor to the end of the entry.
2708 * @param obj The entry object
2713 elm_entry_cursor_end_set(Evas_Object *obj)
2715 ELM_CHECK_WIDTYPE(obj, widtype);
2716 Widget_Data *wd = elm_widget_data_get(obj);
2718 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2722 * This moves the cursor to the beginning of the current line.
2724 * @param obj The entry object
2729 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2731 ELM_CHECK_WIDTYPE(obj, widtype);
2732 Widget_Data *wd = elm_widget_data_get(obj);
2734 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2738 * This moves the cursor to the end of the current line.
2740 * @param obj The entry object
2745 elm_entry_cursor_line_end_set(Evas_Object *obj)
2747 ELM_CHECK_WIDTYPE(obj, widtype);
2748 Widget_Data *wd = elm_widget_data_get(obj);
2750 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2754 * This begins a selection within the entry as though
2755 * the user were holding down the mouse button to make a selection.
2757 * @param obj The entry object
2762 elm_entry_cursor_selection_begin(Evas_Object *obj)
2764 ELM_CHECK_WIDTYPE(obj, widtype);
2765 Widget_Data *wd = elm_widget_data_get(obj);
2767 edje_object_part_text_select_begin(wd->ent, "elm.text");
2771 * This ends a selection within the entry as though
2772 * the user had just released the mouse button while making a selection.
2774 * @param obj The entry object
2779 elm_entry_cursor_selection_end(Evas_Object *obj)
2781 ELM_CHECK_WIDTYPE(obj, widtype);
2782 Widget_Data *wd = elm_widget_data_get(obj);
2784 edje_object_part_text_select_extend(wd->ent, "elm.text");
2788 * TODO: fill this in
2790 * @param obj The entry object
2791 * @return TODO: fill this in
2796 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2798 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2799 Widget_Data *wd = elm_widget_data_get(obj);
2800 if (!wd) return EINA_FALSE;
2801 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2805 * This returns whether the cursor is visible.
2807 * @param obj The entry object
2808 * @return If true, the cursor is visible.
2813 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2815 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2816 Widget_Data *wd = elm_widget_data_get(obj);
2817 if (!wd) return EINA_FALSE;
2818 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2822 * TODO: fill this in
2824 * @param obj The entry object
2825 * @return TODO: fill this in
2830 elm_entry_cursor_content_get(const Evas_Object *obj)
2832 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2833 Widget_Data *wd = elm_widget_data_get(obj);
2834 if (!wd) return NULL;
2835 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2839 * This executes a "cut" action on the selected text in the entry.
2841 * @param obj The entry object
2846 elm_entry_selection_cut(Evas_Object *obj)
2848 ELM_CHECK_WIDTYPE(obj, widtype);
2849 Widget_Data *wd = elm_widget_data_get(obj);
2851 _cut(obj, NULL, NULL);
2855 * This executes a "copy" action on the selected text in the entry.
2857 * @param obj The entry object
2862 elm_entry_selection_copy(Evas_Object *obj)
2864 ELM_CHECK_WIDTYPE(obj, widtype);
2865 Widget_Data *wd = elm_widget_data_get(obj);
2867 _copy(obj, NULL, NULL);
2871 * This executes a "paste" action in the entry.
2873 * @param obj The entry object
2878 elm_entry_selection_paste(Evas_Object *obj)
2880 ELM_CHECK_WIDTYPE(obj, widtype);
2881 Widget_Data *wd = elm_widget_data_get(obj);
2883 _paste(obj, NULL, NULL);
2887 * This clears and frees the items in a entry's contextual (right click) menu.
2889 * @param obj The entry object
2894 elm_entry_context_menu_clear(Evas_Object *obj)
2896 ELM_CHECK_WIDTYPE(obj, widtype);
2897 Widget_Data *wd = elm_widget_data_get(obj);
2898 Elm_Entry_Context_Menu_Item *it;
2900 EINA_LIST_FREE(wd->items, it)
2902 eina_stringshare_del(it->label);
2903 eina_stringshare_del(it->icon_file);
2904 eina_stringshare_del(it->icon_group);
2910 * This adds an item to the entry's contextual menu.
2912 * @param obj The entry object
2913 * @param label The item's text label
2914 * @param icon_file The item's icon file
2915 * @param icon_type The item's icon type
2916 * @param func The callback to execute when the item is clicked
2917 * @param data The data to associate with the item for related functions
2922 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)
2924 ELM_CHECK_WIDTYPE(obj, widtype);
2925 Widget_Data *wd = elm_widget_data_get(obj);
2926 Elm_Entry_Context_Menu_Item *it;
2928 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2930 wd->items = eina_list_append(wd->items, it);
2932 it->label = eina_stringshare_add(label);
2933 it->icon_file = eina_stringshare_add(icon_file);
2934 it->icon_type = icon_type;
2936 it->data = (void *)data;
2940 * This disables the entry's contextual (right click) menu.
2942 * @param obj The entry object
2943 * @param disabled If true, the menu is disabled
2948 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2950 ELM_CHECK_WIDTYPE(obj, widtype);
2951 Widget_Data *wd = elm_widget_data_get(obj);
2953 if (wd->context_menu == !disabled) return;
2954 wd->context_menu = !disabled;
2958 * This returns whether the entry's contextual (right click) menu is disabled.
2960 * @param obj The entry object
2961 * @return If true, the menu is disabled
2966 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2968 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2969 Widget_Data *wd = elm_widget_data_get(obj);
2970 if (!wd) return EINA_FALSE;
2971 return !wd->context_menu;
2975 * This appends a custom item provider to the list for that entry
2977 * This appends the given callback. The list is walked from beginning to end
2978 * with each function called given the item href string in the text. If the
2979 * function returns an object handle other than NULL (it should create an
2980 * and object to do this), then this object is used to replace that item. If
2981 * not the next provider is called until one provides an item object, or the
2982 * default provider in entry does.
2984 * @param obj The entry object
2985 * @param func The function called to provide the item object
2986 * @param data The data passed to @p func
2991 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2993 ELM_CHECK_WIDTYPE(obj, widtype);
2994 Widget_Data *wd = elm_widget_data_get(obj);
2997 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3001 wd->item_providers = eina_list_append(wd->item_providers, ip);
3005 * This prepends a custom item provider to the list for that entry
3007 * This prepends the given callback. See elm_entry_item_provider_append() for
3010 * @param obj The entry object
3011 * @param func The function called to provide the item object
3012 * @param data The data passed to @p func
3017 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3019 ELM_CHECK_WIDTYPE(obj, widtype);
3020 Widget_Data *wd = elm_widget_data_get(obj);
3023 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3027 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3031 * This removes a custom item provider to the list for that entry
3033 * This removes the given callback. See elm_entry_item_provider_append() for
3036 * @param obj The entry object
3037 * @param func The function called to provide the item object
3038 * @param data The data passed to @p func
3043 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3045 ELM_CHECK_WIDTYPE(obj, widtype);
3046 Widget_Data *wd = elm_widget_data_get(obj);
3048 Elm_Entry_Item_Provider *ip;
3051 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3053 if ((ip->func == func) && (ip->data == data))
3055 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3063 * This converts a markup (HTML-like) string into UTF-8.
3065 * @param s The string (in markup) to be converted
3066 * @return The converted string (in UTF-8)
3071 elm_entry_markup_to_utf8(const char *s)
3073 char *ss = _mkup_to_text(s);
3074 if (!ss) ss = strdup("");
3079 * This converts a UTF-8 string into markup (HTML-like).
3081 * @param s The string (in UTF-8) to be converted
3082 * @return The converted string (in markup)
3087 elm_entry_utf8_to_markup(const char *s)
3089 char *ss = _text_to_mkup(s);
3090 if (!ss) ss = strdup("");
3095 * Get the input method context in the entry widget
3097 * @param obj The entry object
3098 * @return The input method context
3102 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3104 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3105 Widget_Data *wd = elm_widget_data_get(obj);
3106 if (!wd || !wd->ent) return NULL;
3108 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3112 * Set whether entry should enable the return key on soft keyboard automatically
3114 * @param obj The entry object
3115 * @param on If true, entry enables the return key on soft keyboard automatically.
3120 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3122 ELM_CHECK_WIDTYPE(obj, widtype);
3123 Widget_Data *wd = elm_widget_data_get(obj);
3126 wd->autoreturnkey = on;
3127 _check_enable_returnkey(obj);
3131 * Set whether entry should support auto capitalization
3133 * @param obj The entry object
3134 * @param on If true, entry suports auto capitalization.
3139 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3141 ELM_CHECK_WIDTYPE(obj, widtype);
3142 Widget_Data *wd = elm_widget_data_get(obj);
3146 wd->autocapital = EINA_FALSE;
3148 wd->autocapital = autocap;
3150 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3151 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3152 wd->autocapital = EINA_FALSE;
3154 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3158 * Set whether entry should support auto period
3160 * @param obj The entry object
3161 * @param on If true, entry suports auto period.
3166 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3168 ELM_CHECK_WIDTYPE(obj, widtype);
3169 Widget_Data *wd = elm_widget_data_get(obj);
3173 wd->autoperiod = EINA_FALSE;
3175 wd->autoperiod = autoperiod;
3177 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3178 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3179 wd->autoperiod = EINA_FALSE;
3181 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3185 * Set the font size on the entry object
3187 * @param obj The entry object
3188 * @param size font size
3193 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3195 ELM_CHECK_WIDTYPE(obj, widtype);
3196 Widget_Data *wd = elm_widget_data_get(obj);
3197 Eina_Strbuf *fontbuf = NULL;
3202 t = eina_stringshare_add(elm_entry_entry_get(obj));
3203 fontbuf = eina_strbuf_new();
3204 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3206 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3208 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3210 elm_entry_entry_set(obj, t);
3214 eina_strbuf_free(fontbuf);
3215 eina_stringshare_del(t);
3219 * Set the text align on the entry object
3221 * @param obj The entry object
3222 * @param align align mode
3227 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3229 ELM_CHECK_WIDTYPE(obj, widtype);
3230 Widget_Data *wd = elm_widget_data_get(obj);
3235 t = eina_stringshare_add(elm_entry_entry_get(obj));
3237 if (len <= 0) return;
3239 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3240 elm_entry_entry_set(obj, t);
3244 eina_stringshare_del(t);
3248 * Set the text color on the entry object
3250 * @param obj The entry object
3251 * @param r Red property background color of The entry object
3252 * @param g Green property background color of The entry object
3253 * @param b Blue property background color of The entry object
3254 * @param a Alpha property background alpha of The entry object
3259 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3261 ELM_CHECK_WIDTYPE(obj, widtype);
3262 Widget_Data *wd = elm_widget_data_get(obj);
3263 Eina_Strbuf *colorbuf = NULL;
3268 t = eina_stringshare_add(elm_entry_entry_get(obj));
3270 if (len <= 0) return;
3271 colorbuf = eina_strbuf_new();
3272 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3274 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3276 elm_entry_entry_set(obj, t);
3280 eina_strbuf_free(colorbuf);
3281 eina_stringshare_del(t);
3286 * Set background color of the entry
3288 * @param obj The entry object
3289 * @param r Red property background color of The entry object
3290 * @param g Green property background color of The entry object
3291 * @param b Blue property background color of The entry object
3292 * @param a Alpha property background alpha of The entry object
3296 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3298 ELM_CHECK_WIDTYPE(obj, widtype);
3299 Widget_Data *wd = elm_widget_data_get(obj);
3300 evas_object_color_set(wd->bg, r, g, b, a);
3302 if (wd->bgcolor == EINA_FALSE)
3305 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3310 * Set the ellipsis behavior of the entry
3312 * @param obj The entry object
3313 * @param ellipsis To ellipsis text or not
3317 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3319 ELM_CHECK_WIDTYPE(obj, widtype);
3320 Widget_Data *wd = elm_widget_data_get(obj);
3321 if (wd->ellipsis == ellipsis) return;
3322 wd->ellipsis = ellipsis;
3328 * This sets the attribute to show the input panel automatically.
3330 * @param obj The entry object
3331 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3336 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3338 ELM_CHECK_WIDTYPE(obj, widtype);
3339 Widget_Data *wd = elm_widget_data_get(obj);
3342 wd->input_panel_enable = enabled;
3343 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3347 * Set the input panel layout of the entry
3349 * @param obj The entry object
3350 * @param layout the layout to set
3355 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3357 ELM_CHECK_WIDTYPE(obj, widtype);
3358 Widget_Data *wd = elm_widget_data_get(obj);
3361 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3364 wd->input_panel_layout = layout;
3366 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3369 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/