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",
438 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
440 Widget_Data *wd = elm_widget_data_get(obj);
441 Evas_Object *top = elm_widget_top_get(obj);
442 Evas_Object *parent_obj = obj;
443 Evas_Object *above = NULL;
446 if (!wd->editable) return;
447 if (elm_widget_focus_get(obj))
449 evas_object_focus_set(wd->ent, EINA_TRUE);
450 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
452 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
453 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
454 _check_enable_returnkey(obj);
458 above = evas_object_above_get(parent_obj);
460 evas_object_data_set(parent_obj, "raise", above);
461 evas_object_raise(parent_obj);
462 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 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
587 Widget_Data *wd = elm_widget_data_get(data);
589 wd->selmode = EINA_TRUE;
591 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
592 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
593 edje_object_part_text_select_all(wd->ent, "elm.text");
594 //elm_widget_scroll_hold_push(data);
595 elm_object_scroll_freeze_pop(data);
599 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
601 Widget_Data *wd = elm_widget_data_get(data);
603 wd->selmode = EINA_TRUE;
604 edje_object_part_text_select_none(wd->ent, "elm.text");
606 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
607 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
608 elm_object_scroll_freeze_pop(data);
609 //elm_widget_scroll_hold_push(data);
613 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
615 Widget_Data *wd = elm_widget_data_get(data);
617 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
618 if (wd->sel_notify_handler)
620 #ifdef HAVE_ELEMENTARY_X
621 wd->selection_asked = EINA_TRUE;
622 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
628 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
630 Widget_Data *wd = elm_widget_data_get(obj);
634 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
635 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
636 if (seltype == ELM_SEL_CLIPBOARD)
637 eina_stringshare_replace(&wd->cut_sel, sel);
641 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
643 Widget_Data *wd = elm_widget_data_get(data);
646 wd->selmode = EINA_FALSE;
647 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
648 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
649 elm_widget_scroll_hold_pop(data);
650 _store_selection(ELM_SEL_CLIPBOARD, data);
651 edje_object_part_text_insert(wd->ent, "elm.text", "");
652 edje_object_part_text_select_none(wd->ent, "elm.text");
656 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
658 Widget_Data *wd = elm_widget_data_get(data);
660 wd->selmode = EINA_FALSE;
661 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
662 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
663 elm_widget_scroll_hold_pop(data);
664 _store_selection(ELM_SEL_CLIPBOARD, data);
665 edje_object_part_text_select_none(wd->ent, "elm.text");
669 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
671 Widget_Data *wd = elm_widget_data_get(data);
673 wd->selmode = EINA_FALSE;
674 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
675 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
676 elm_widget_scroll_hold_pop(data);
677 edje_object_part_text_select_none(wd->ent, "elm.text");
681 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
683 Widget_Data *wd = elm_widget_data_get(data);
687 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
688 cnpwidgetdata = data;
689 elm_cbhm_helper_init(obj);
690 elm_cbhm_send_raw_data("show");
696 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
698 Widget_Data *wd = elm_widget_data_get(data);
700 cnpwidgetdata = data;
706 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
708 Elm_Entry_Context_Menu_Item *it = data;
709 Evas_Object *obj2 = it->obj;
711 if (it->func) it->func(it->data, obj2, NULL);
715 _long_press(void *data)
717 Widget_Data *wd = elm_widget_data_get(data);
720 const Elm_Entry_Context_Menu_Item *it;
721 if (!wd) return ECORE_CALLBACK_CANCEL;
723 if (wd->longpress_timer)
725 ecore_timer_del(wd->longpress_timer);
726 wd->longpress_timer = NULL;
729 if ((wd->api) && (wd->api->obj_longpress))
731 wd->api->obj_longpress(data);
733 else if (wd->context_menu)
735 const char *context_menu_orientation;
737 if (wd->hoversel) evas_object_del(wd->hoversel);
738 else elm_widget_scroll_freeze_push(data);
739 wd->hoversel = elm_hoversel_add(data);
740 context_menu_orientation = edje_object_data_get
741 (wd->ent, "context_menu_orientation");
742 if ((context_menu_orientation) &&
743 (!strcmp(context_menu_orientation, "horizontal")))
744 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
745 elm_object_style_set(wd->hoversel, "entry");
746 elm_widget_sub_object_add(data, wd->hoversel);
747 elm_hoversel_label_set(wd->hoversel, "Text");
748 top = elm_widget_top_get(data);
749 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
750 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
754 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
756 if (1) // need way to detect if someone has a selection
759 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
764 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
765 _clipboard_menu, data);
772 if (wd->have_selection)
774 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
777 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
780 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
783 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
784 _clipboard_menu, data);
788 EINA_LIST_FOREACH(wd->items, l, it)
790 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
791 it->icon_type, _item_clicked, it);
795 _hoversel_position(data);
796 evas_object_show(wd->hoversel);
797 elm_hoversel_hover_begin(wd->hoversel);
799 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
800 edje_object_part_text_select_abort(wd->ent, "elm.text");
802 wd->longpress_timer = NULL;
803 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
804 return ECORE_CALLBACK_CANCEL;
808 _mouse_down(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_Down *ev = event_info;
813 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
814 if (ev->button != 1) return;
815 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
816 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
817 wd->longpress_timer = ecore_timer_add(elm_longpress_timeout_get(), _long_press, data);
818 wd->downx = ev->canvas.x;
819 wd->downy = ev->canvas.y;
823 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
825 Widget_Data *wd = elm_widget_data_get(data);
826 Evas_Event_Mouse_Up *ev = event_info;
828 if (ev->button != 1) return;
830 if (!wd->double_clicked)
832 if ((wd->api) && (wd->api->obj_mouseup))
834 wd->api->obj_mouseup(data);
837 if (wd->longpress_timer)
839 ecore_timer_del(wd->longpress_timer);
840 wd->longpress_timer = NULL;
845 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
847 Widget_Data *wd = elm_widget_data_get(data);
848 Evas_Event_Mouse_Move *ev = event_info;
852 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
854 if (wd->longpress_timer)
856 ecore_timer_del(wd->longpress_timer);
857 wd->longpress_timer = NULL;
860 else if (wd->longpress_timer)
864 dx = wd->downx - ev->cur.canvas.x;
866 dy = wd->downy - ev->cur.canvas.y;
869 ((_elm_config->finger_size / 2) *
870 (_elm_config->finger_size / 2)))
872 ecore_timer_del(wd->longpress_timer);
873 wd->longpress_timer = NULL;
877 else if (wd->longpress_timer)
881 dx = wd->downx - ev->cur.canvas.x;
883 dy = wd->downy - ev->cur.canvas.y;
886 ((_elm_config->finger_size / 2) *
887 (_elm_config->finger_size / 2)))
889 ecore_timer_del(wd->longpress_timer);
890 wd->longpress_timer = NULL;
896 _getbase(Evas_Object *obj)
898 Widget_Data *wd = elm_widget_data_get(obj);
899 if (!wd) return "base";
904 if (wd->show_last_character) return "custom-password";
905 else return "base-password";
909 if (wd->single_line) return "base-single";
912 if (wd->linewrap) return "base";
913 else if (wd->char_linewrap) return "base-charwrap";
914 else return "base-nowrap";
922 if (wd->show_last_character) return "custom-password";
923 else return "base-password";
927 if (wd->single_line) return "base-single-noedit";
930 if (wd->linewrap) return "base-noedit";
931 else if (wd->char_linewrap) return "base-noedit-charwrap";
932 else return "base-nowrap-noedit";
940 _str_append(char *str, const char *txt, int *len, int *alloc)
942 int txt_len = strlen(txt);
944 if (txt_len <= 0) return str;
945 if ((*len + txt_len) >= *alloc)
950 alloc2 = *alloc + txt_len + 128;
951 str2 = realloc(str, alloc2);
952 if (!str2) return str;
956 strcpy(str + *len, txt);
961 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
962 * because some markups can be implemented otherwise according to style.
963 * probably doing it in textblock and making it translate according to it's
964 * style is correct. */
966 _strncpy(char* dest, const char* src, size_t count)
970 ERR( "dest is NULL" );
975 ERR( "src is NULL" );
980 ERR( "count is smaller than 0" );
984 return strncpy( dest, src, count );
988 _mkup_to_text(const char *mkup)
991 int str_len = 0, str_alloc = 0;
993 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
995 if (!mkup) return NULL;
997 tag_start = tag_end = esc_start = esc_end = NULL;
1002 if (((p!=NULL)&&(*p == 0)) ||
1003 (tag_end) || (esc_end) ||
1004 (tag_start) || (esc_start))
1010 ttag = malloc(tag_end - tag_start);
1013 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
1014 ttag[tag_end - tag_start - 1] = 0;
1015 if (!strcmp(ttag, "br"))
1016 str = _str_append(str, "\n", &str_len, &str_alloc);
1017 else if (!strcmp(ttag, "\n"))
1018 str = _str_append(str, "\n", &str_len, &str_alloc);
1019 else if (!strcmp(ttag, "\\n"))
1020 str = _str_append(str, "\n", &str_len, &str_alloc);
1021 else if (!strcmp(ttag, "\t"))
1022 str = _str_append(str, "\t", &str_len, &str_alloc);
1023 else if (!strcmp(ttag, "\\t"))
1024 str = _str_append(str, "\t", &str_len, &str_alloc);
1025 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
1026 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1029 tag_start = tag_end = NULL;
1033 ts = malloc(esc_end - esc_start + 1);
1037 _strncpy(ts, esc_start, esc_end - esc_start);
1038 ts[esc_end - esc_start] = 0;
1039 esc = evas_textblock_escape_string_get(ts);
1041 str = _str_append(str, esc, &str_len, &str_alloc);
1044 esc_start = esc_end = NULL;
1046 else if ((p!=NULL)&&(*p == 0))
1048 ts = malloc(p - s + 1);
1051 _strncpy(ts, s, p - s);
1053 str = _str_append(str, ts, &str_len, &str_alloc);
1059 if ((p!=NULL)&&(*p == '<'))
1065 ts = malloc(p - s + 1);
1068 _strncpy(ts, s, p - s);
1070 str = _str_append(str, ts, &str_len, &str_alloc);
1076 else if ((p!=NULL)&&(*p == '>'))
1084 else if ((p!=NULL)&&(*p == '&'))
1090 ts = malloc(p - s + 1);
1093 _strncpy(ts, s, p - s);
1095 str = _str_append(str, ts, &str_len, &str_alloc);
1101 else if ((p!=NULL)&&(*p == ';'))
1115 _entry_length_get(Evas_Object *obj)
1118 const char *str = elm_entry_entry_get(obj);
1121 char *plain_str = _mkup_to_text(str);
1122 if (!plain_str) return 0;
1124 len = strlen(plain_str);
1131 _text_to_mkup(const char *text)
1134 int str_len = 0, str_alloc = 0;
1135 int ch, pos = 0, pos2 = 0;
1137 if (!text) return NULL;
1141 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1142 if ((ch <= 0) || (pos2 <= 0)) break;
1144 str = _str_append(str, "<br>", &str_len, &str_alloc);
1145 else if (ch == '\t')
1146 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1148 str = _str_append(str, "<", &str_len, &str_alloc);
1150 str = _str_append(str, ">", &str_len, &str_alloc);
1152 str = _str_append(str, "&", &str_len, &str_alloc);
1153 else if (ch == 0x2029)
1154 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1159 _strncpy(tstr, text + pos, pos2 - pos);
1160 tstr[pos2 - pos] = 0;
1161 str = _str_append(str, tstr, &str_len, &str_alloc);
1168 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1170 Widget_Data *wd = elm_widget_data_get(data);
1172 wd->changed = EINA_TRUE;
1174 if (wd->text) eina_stringshare_del(wd->text);
1176 _check_enable_returnkey(data);
1177 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1181 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1183 Widget_Data *wd = elm_widget_data_get(data);
1184 elm_object_scroll_freeze_push(data);
1188 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1190 Widget_Data *wd = elm_widget_data_get(data);
1191 elm_object_scroll_freeze_pop(data);
1195 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1197 Widget_Data *wd = elm_widget_data_get(data);
1201 EINA_LIST_FOREACH(entries, l, entry)
1203 if (entry != data) elm_entry_select_none(entry);
1205 wd->have_selection = EINA_TRUE;
1206 wd->selmode = EINA_TRUE;
1207 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1208 #ifdef HAVE_ELEMENTARY_X
1209 if (wd->sel_notify_handler)
1211 const char *txt = elm_entry_selection_get(data);
1214 top = elm_widget_top_get(data);
1215 if ((top) && (elm_win_xwindow_get(top)))
1216 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1222 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1224 Evas_Coord cx, cy, cw, ch;
1225 Widget_Data *wd = elm_widget_data_get(data);
1227 wd->have_selection = EINA_TRUE;
1228 wd->selmode = EINA_TRUE;
1229 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1230 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1231 elm_entry_selection_get(data));
1233 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1234 if (!wd->deferred_recalc_job)
1235 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1238 wd->deferred_cur = EINA_TRUE;
1242 wd->ch = ch + elm_finger_size_get();
1247 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1249 Widget_Data *wd = elm_widget_data_get(data);
1251 if (!wd->have_selection) return;
1252 wd->have_selection = EINA_FALSE;
1253 wd->selmode = EINA_FALSE;
1254 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1255 if (wd->sel_notify_handler)
1259 #ifdef HAVE_ELEMENTARY_X
1262 top = elm_widget_top_get(data);
1263 if ((top) && (elm_win_xwindow_get(top)))
1264 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1267 eina_stringshare_del(wd->cut_sel);
1272 #ifdef HAVE_ELEMENTARY_X
1275 top = elm_widget_top_get(data);
1276 if ((top) && (elm_win_xwindow_get(top)))
1277 elm_selection_clear(ELM_SEL_PRIMARY, data);
1284 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1286 Widget_Data *wd = elm_widget_data_get(data);
1288 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1289 if (wd->sel_notify_handler)
1291 #ifdef HAVE_ELEMENTARY_X
1294 top = elm_widget_top_get(data);
1295 if ((top) && (elm_win_xwindow_get(top)))
1297 wd->selection_asked = EINA_TRUE;
1298 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1305 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1307 Widget_Data *wd = elm_widget_data_get(data);
1309 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1310 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1311 elm_entry_selection_get(data));
1315 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1317 Widget_Data *wd = elm_widget_data_get(data);
1319 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1320 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1321 elm_entry_selection_get(data));
1322 edje_object_part_text_insert(wd->ent, "elm.text", "");
1323 wd->changed = EINA_TRUE;
1328 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1330 Widget_Data *wd = elm_widget_data_get(data);
1331 Evas_Coord cx, cy, cw, ch;
1333 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1334 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1335 &cx, &cy, &cw, &ch);
1336 if (!wd->deferred_recalc_job)
1337 elm_widget_show_region_set(data, cx, cy, cw, ch);
1340 wd->deferred_cur = EINA_TRUE;
1346 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1347 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1352 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1354 Widget_Data *wd = elm_widget_data_get(data);
1359 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1361 Widget_Data *wd = elm_widget_data_get(data);
1362 Elm_Entry_Anchor_Info ei;
1363 char *buf2, *p, *p2, *n;
1365 p = strrchr(emission, ',');
1368 const Eina_List *geoms;
1372 while (p2 >= emission)
1374 if (*p2 == ',') break;
1378 buf2 = alloca(5 + p - p2);
1379 strncpy(buf2, p2, p - p2);
1382 ei.button = atoi(buf2);
1383 ei.x = ei.y = ei.w = ei.h = 0;
1385 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1388 Evas_Textblock_Rectangle *r;
1390 Evas_Coord px, py, x, y;
1392 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1393 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1394 EINA_LIST_FOREACH(geoms, l, r)
1396 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1397 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1408 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1413 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1415 Widget_Data *wd = elm_widget_data_get(data);
1420 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1422 Widget_Data *wd = elm_widget_data_get(data);
1427 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1429 Widget_Data *wd = elm_widget_data_get(data);
1434 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1436 Widget_Data *wd = elm_widget_data_get(data);
1438 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1442 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1444 Widget_Data *wd = elm_widget_data_get(data);
1446 wd->double_clicked = EINA_FALSE;
1447 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1451 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1453 Widget_Data *wd = elm_widget_data_get(data);
1455 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1459 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1461 Widget_Data *wd = elm_widget_data_get(data);
1463 wd->double_clicked = EINA_TRUE;
1464 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1467 #ifdef HAVE_ELEMENTARY_X
1469 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1471 Widget_Data *wd = elm_widget_data_get(data);
1472 Ecore_X_Event_Selection_Notify *ev = event;
1473 if (!wd) return ECORE_CALLBACK_PASS_ON;
1474 if (!wd->selection_asked && !wd->drag_selection_asked)
1475 return ECORE_CALLBACK_PASS_ON;
1477 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1478 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1480 Ecore_X_Selection_Data_Text *text_data;
1482 text_data = ev->data;
1483 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1485 if (text_data->text)
1487 char *txt = _text_to_mkup(text_data->text);
1491 elm_entry_entry_insert(data, txt);
1496 wd->selection_asked = EINA_FALSE;
1498 else if (ev->selection == ECORE_X_SELECTION_XDND)
1500 Ecore_X_Selection_Data_Text *text_data;
1502 text_data = ev->data;
1503 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1505 if (text_data->text)
1507 char *txt = _text_to_mkup(text_data->text);
1511 /* Massive FIXME: this should be at the drag point */
1512 elm_entry_entry_insert(data, txt);
1517 wd->drag_selection_asked = EINA_FALSE;
1519 ecore_x_dnd_send_finished();
1522 return ECORE_CALLBACK_PASS_ON;
1526 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1529 Widget_Data *wd = elm_widget_data_get(data);
1530 Ecore_X_Event_Selection_Clear *ev = event;
1531 if (!wd) return ECORE_CALLBACK_PASS_ON;
1532 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1533 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1534 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1536 elm_entry_select_none(data);
1541 Evas_Object *top = elm_widget_top_get(data);
1542 Ecore_X_Event_Selection_Clear *ev = event;
1545 return ECORE_CALLBACK_PASS_ON;
1547 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1549 return ECORE_CALLBACK_PASS_ON;
1552 if (cnpwidgetdata == data)
1554 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1558 return ECORE_CALLBACK_PASS_ON;
1562 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1567 wd = elm_widget_data_get(obj);
1569 if (!wd) return EINA_FALSE;
1570 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1572 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1573 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1574 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1575 EDJE_CURSOR_MAIN,drop->x,drop->y);
1576 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1577 elm_entry_entry_insert(obj, drop->data);
1578 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1579 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1585 static Evas_Object *
1586 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1588 Widget_Data *wd = elm_widget_data_get(data);
1591 Elm_Entry_Item_Provider *ip;
1594 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1596 o = ip->func(ip->data, data, item);
1599 o = edje_object_add(evas_object_evas_get(data));
1600 if (!strncmp(item, "emoticon/", 9))
1601 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1603 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1608 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1610 char *curlocater, *starttag, *endtag;
1611 int firstindex = 0, foundflag = -1;
1613 curlocater = strstr(oldstring, key);
1616 starttag = curlocater;
1617 endtag = curlocater + strlen(key);
1618 if (endtag == NULL || *endtag != '=')
1624 firstindex = abs(oldstring - curlocater);
1625 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1626 *value = (char*)oldstring + firstindex;
1628 while (oldstring != starttag)
1630 if (*starttag == '>')
1635 if (*starttag == '<')
1639 if (starttag == NULL) break;
1642 while (NULL != endtag)
1653 if (endtag == NULL) break;
1656 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1666 if (foundflag == 1) return 0;
1672 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1674 const char *srcstring = NULL;
1675 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1676 char *curlocater, *replocater;
1677 char *starttag, *endtag;
1678 int tagtxtlen = 0, insertflag = 0;
1680 srcstring = eina_strbuf_string_get(srcbuf);
1681 curlocater = strstr(srcstring, key);
1683 if (curlocater == NULL)
1691 starttag = strchr(srcstring, '<');
1692 endtag = strchr(srcstring, '>');
1693 tagtxtlen = endtag - starttag;
1694 if (tagtxtlen <= 0) tagtxtlen = 0;
1695 if (starttag < curlocater && curlocater < endtag) break;
1696 if (endtag != NULL && endtag+1 != NULL)
1697 srcstring = endtag+1;
1700 } while (strlen(srcstring) > 1);
1702 if (starttag && endtag && tagtxtlen > strlen(key))
1704 repbuf = eina_strbuf_new();
1705 diffbuf = eina_strbuf_new();
1706 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1707 srcstring = eina_strbuf_string_get(repbuf);
1708 curlocater = strstr(srcstring, key);
1710 if (curlocater != NULL)
1712 replocater = curlocater + strlen(key) + 1;
1714 while (*replocater == ' ' || *replocater == '=')
1719 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1722 if (replocater-curlocater > strlen(key)+1)
1725 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1734 eina_strbuf_reset(repbuf);
1742 if (repbuf == NULL) repbuf = eina_strbuf_new();
1743 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1747 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1748 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1754 eina_strbuf_prepend(diffbuf, "<");
1755 eina_strbuf_append(diffbuf, ">");
1756 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1760 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1761 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1765 if (repbuf) eina_strbuf_free(repbuf);
1766 if (diffbuf) eina_strbuf_free(diffbuf);
1772 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1774 Eina_Strbuf *sharebuf = NULL;
1776 sharebuf = eina_strbuf_new();
1777 eina_strbuf_append(sharebuf, *srcstring);
1778 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1779 eina_stringshare_del(*srcstring);
1780 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1781 eina_strbuf_free(sharebuf);
1787 _is_width_over(Evas_Object *obj)
1789 Evas_Coord x, y, w, h;
1790 Evas_Coord vx, vy, vw, vh;
1791 Widget_Data *wd = elm_widget_data_get(obj);
1795 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1797 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1799 if (x >= 0 && y >= 0)
1802 if (4 < wd->wrap_w && w > wd->wrap_w)
1809 _reverse_ellipsis_entry(Evas_Object *obj)
1811 Widget_Data *wd = elm_widget_data_get(obj);
1812 int cur_fontsize = 0;
1813 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1814 char **kvalue = NULL;
1815 const char *minfont, *deffont, *maxfont;
1816 const char *ellipsis_string = "...";
1817 int minfontsize, maxfontsize, minshowcount;
1819 minshowcount = strlen(ellipsis_string) + 1;
1820 minfont = edje_object_data_get(wd->ent, "min_font_size");
1821 if (minfont) minfontsize = atoi(minfont);
1822 else minfontsize = 1;
1823 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1824 if (maxfont) maxfontsize = atoi(maxfont);
1825 else maxfontsize = 1;
1826 deffont = edje_object_data_get(wd->ent, "default_font_size");
1827 if (deffont) cur_fontsize = atoi(deffont);
1828 else cur_fontsize = 1;
1829 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1830 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1832 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1834 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1837 txtbuf = eina_strbuf_new();
1838 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1840 if (cur_fontsize >= atoi(deffont))
1842 if (txtbuf) eina_strbuf_free(txtbuf);
1846 if (_is_width_over(obj) != 1)
1848 int rev_fontsize = cur_fontsize;
1852 if (rev_fontsize > atoi(deffont))
1855 if (fontbuf != NULL)
1857 eina_strbuf_free(fontbuf);
1860 fontbuf = eina_strbuf_new();
1861 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1862 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1863 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1865 eina_strbuf_free(fontbuf);
1867 } while (_is_width_over(obj) != 1);
1869 while (_is_width_over(obj))
1872 if (rev_fontsize < atoi(deffont))
1875 if (fontbuf != NULL)
1877 eina_strbuf_free(fontbuf);
1880 fontbuf = eina_strbuf_new();
1881 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1882 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1883 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1884 eina_strbuf_free(fontbuf);
1889 if (txtbuf) eina_strbuf_free(txtbuf);
1895 _ellipsis_entry_to_width(Evas_Object *obj)
1897 Widget_Data *wd = elm_widget_data_get(obj);
1898 int cur_fontsize = 0, len, jumpcount;
1899 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1900 char **kvalue = NULL;
1901 const char *minfont, *deffont, *maxfont;
1902 const char *ellipsis_string = "...";
1903 int minfontsize, maxfontsize, minshowcount;
1904 int i, tagend, cur_len;
1907 minshowcount = strlen(ellipsis_string) + 1;
1908 minfont = edje_object_data_get(wd->ent, "min_font_size");
1909 if (minfont) minfontsize = atoi(minfont);
1910 else minfontsize = 1;
1911 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1912 if (maxfont) maxfontsize = atoi(maxfont);
1913 else maxfontsize = 1;
1914 deffont = edje_object_data_get(wd->ent, "default_font_size");
1915 if (deffont) cur_fontsize = atoi(deffont);
1916 else cur_fontsize = 1;
1917 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1918 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1920 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1922 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1925 txtbuf = eina_strbuf_new();
1926 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1928 while (_is_width_over(obj))
1930 if (wd->ellipsis_threshold == 0)
1931 wd->ellipsis_threshold = _entry_length_get(obj);
1932 if (cur_fontsize > minfontsize)
1935 if (fontbuf != NULL)
1937 eina_strbuf_free(fontbuf);
1940 fontbuf = eina_strbuf_new();
1941 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1942 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1943 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1944 eina_strbuf_free(fontbuf);
1946 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1950 len = _entry_length_get(obj);
1951 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1952 cur_len = strlen(cur_str);
1954 for (i = 0; i < len; i++)
1956 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1957 cur_str[i+1] != '<')
1964 while (jumpcount < len-strlen(ellipsis_string))
1966 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1970 eina_strbuf_free(txtbuf);
1973 txtbuf = eina_strbuf_new();
1974 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1975 eina_strbuf_append(txtbuf, ellipsis_string);
1976 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1977 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1978 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1980 if (_is_width_over(obj))
1988 if (txtbuf) eina_strbuf_free(txtbuf);
1993 static int _textinput_control_function(void *data,void *input_data)
1995 /* calculate character count */
1996 Evas_Object *entry = (Evas_Object *)data;
1997 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2000 size_t insert_text_len=0;
2001 char *text = edje_object_part_text_get(wd->ent, "elm.text");
2003 size_t remain_bytes;
2006 byte_len = strlen(text); /* no of bytes */
2007 remain_bytes = wd->max_no_of_bytes - byte_len;
2008 sprintf(buf,"%d",remain_bytes);
2009 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2012 insert_text = (char *)input_data;
2013 insert_text_len = strlen(insert_text);
2014 if (remain_bytes < insert_text_len)
2016 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2019 if (byte_len >= wd->max_no_of_bytes)
2021 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2030 * This adds an entry to @p parent object.
2032 * @param parent The parent object
2033 * @return The new object or NULL if it cannot be created
2038 elm_entry_add(Evas_Object *parent)
2040 Evas_Object *obj, *top;
2044 wd = ELM_NEW(Widget_Data);
2045 e = evas_object_evas_get(parent);
2046 wd->bgcolor = EINA_FALSE;
2047 wd->bg = evas_object_rectangle_add(e);
2048 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2049 obj = elm_widget_add(e);
2050 ELM_SET_WIDTYPE(widtype, "entry");
2051 elm_widget_type_set(obj, "entry");
2052 elm_widget_sub_object_add(parent, obj);
2053 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2054 elm_widget_data_set(obj, wd);
2055 elm_widget_del_hook_set(obj, _del_hook);
2056 elm_widget_theme_hook_set(obj, _theme_hook);
2057 elm_widget_disable_hook_set(obj, _disable_hook);
2058 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2059 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2060 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2061 elm_widget_can_focus_set(obj, 1);
2062 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2063 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2066 wd->linewrap = EINA_TRUE;
2067 wd->ellipsis = EINA_FALSE;
2068 wd->char_linewrap= EINA_FALSE;
2069 wd->editable = EINA_TRUE;
2070 wd->disabled = EINA_FALSE;
2071 wd->context_menu = EINA_TRUE;
2072 wd->autoperiod = EINA_TRUE;
2074 wd->ellipsis_threshold = 0;
2076 wd->ent = edje_object_add(e);
2077 edje_object_item_provider_set(wd->ent, _get_item, obj);
2078 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2079 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2080 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2082 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2084 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2087 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2088 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2089 _signal_entry_changed, obj);
2090 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2091 _signal_handler_move_start, obj);
2092 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2093 _signal_handler_move_end, obj);
2094 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2095 _signal_selection_start, obj);
2096 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2097 _signal_selection_changed, obj);
2098 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2099 _signal_selection_cleared, obj);
2100 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2101 _signal_entry_paste_request, obj);
2102 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2103 _signal_entry_copy_notify, obj);
2104 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2105 _signal_entry_cut_notify, obj);
2106 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2107 _signal_cursor_changed, obj);
2108 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2109 _signal_anchor_down, obj);
2110 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2111 _signal_anchor_up, obj);
2112 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2113 _signal_anchor_move, obj);
2114 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2115 _signal_anchor_in, obj);
2116 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2117 _signal_anchor_out, obj);
2118 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2119 _signal_key_enter, obj);
2120 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2121 _signal_mouse_down, obj);
2122 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2123 _signal_mouse_up, obj);
2124 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2125 _signal_mouse_double, obj);
2126 edje_object_part_text_set(wd->ent, "elm.text", "");
2127 elm_widget_resize_object_set(obj, wd->ent);
2130 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2132 #ifdef HAVE_ELEMENTARY_X
2133 top = elm_widget_top_get(obj);
2134 if ((top) && (elm_win_xwindow_get(top)))
2136 wd->sel_notify_handler =
2137 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2138 _event_selection_notify, obj);
2139 wd->sel_clear_handler =
2140 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2141 _event_selection_clear, obj);
2144 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2147 entries = eina_list_prepend(entries, obj);
2149 // module - find module for entry
2150 wd->api = _module(obj);
2151 // if found - hook in
2152 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2154 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2155 // TODO: and save some bytes, making descriptions per-class and not instance!
2156 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2160 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2162 ELM_CHECK_WIDTYPE(obj, widtype);
2163 Widget_Data *wd = elm_widget_data_get(obj);
2165 ext_mod->cancel = _cancel;
2166 ext_mod->copy = _copy;
2167 ext_mod->cut = _cut;
2168 ext_mod->paste = _paste;
2169 ext_mod->select = _select;
2170 ext_mod->selectall = _selectall;
2171 ext_mod->ent = wd->ent;
2172 ext_mod->items = wd->items;
2173 ext_mod->longpress_timer = wd->longpress_timer;
2174 ext_mod->editable = wd->editable;
2175 ext_mod->have_selection = wd->have_selection;
2176 ext_mod->password = wd->password;
2177 ext_mod->selmode = wd->selmode;
2178 ext_mod->cnpinit = _cnpinit;
2179 ext_mod->context_menu = wd->context_menu;
2183 * This sets the entry object not to line wrap. All input will
2184 * be on a single line, and the entry box will extend with user input.
2186 * @param obj The entry object
2187 * @param single_line If true, the text in the entry
2188 * will be on a single line.
2193 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2195 ELM_CHECK_WIDTYPE(obj, widtype);
2196 Widget_Data *wd = elm_widget_data_get(obj);
2198 Ecore_IMF_Context *ic;
2200 if (wd->single_line == single_line) return;
2201 wd->single_line = single_line;
2202 wd->linewrap = EINA_FALSE;
2203 wd->char_linewrap = EINA_FALSE;
2204 t = eina_stringshare_add(elm_entry_entry_get(obj));
2205 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2206 elm_entry_entry_set(obj, t);
2207 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2208 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2209 ic = elm_entry_imf_context_get(obj);
2212 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2215 eina_stringshare_del(t);
2220 * This returns true if the entry has been set to single line mode.
2221 * See also elm_entry_single_line_set().
2223 * @param obj The entry object
2224 * @return single_line If true, the text in the entry is set to display
2230 elm_entry_single_line_get(const Evas_Object *obj)
2232 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2233 Widget_Data *wd = elm_widget_data_get(obj);
2234 if (!wd) return EINA_FALSE;
2235 return wd->single_line;
2239 * This set's the maximum bytes that can be added in entry.
2241 * @param obj The entry object
2242 * @param max_no_of_bytes Maximum number of bytes entry can have.
2247 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2249 Widget_Data *wd = elm_widget_data_get(obj);
2251 wd->max_no_of_bytes = max_no_of_bytes;
2252 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2253 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2258 * This sets the entry object to password mode. All text entered
2259 * and/or displayed within the widget will be replaced with asterisks (*).
2261 * @param obj The entry object
2262 * @param password If true, password mode is enabled.
2267 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2269 ELM_CHECK_WIDTYPE(obj, widtype);
2270 Widget_Data *wd = elm_widget_data_get(obj);
2271 Ecore_IMF_Context *ic;
2274 if (wd->password == password) return;
2275 wd->password = password;
2276 wd->single_line = EINA_TRUE;
2277 wd->linewrap = EINA_FALSE;
2278 wd->char_linewrap = EINA_FALSE;
2279 if (_elm_config->password_show_last_character)
2280 wd->show_last_character = EINA_TRUE;
2281 t = eina_stringshare_add(elm_entry_entry_get(obj));
2282 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2283 elm_entry_entry_set(obj, t);
2288 elm_entry_autoperiod_set(obj, EINA_FALSE);
2290 if (wd->autocapital)
2291 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2294 ic = elm_entry_imf_context_get(obj);
2296 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2298 eina_stringshare_del(t);
2303 * This set's the entry in password mode with out masking the last character entered by user,
2304 * and later masking the character after 2 seconds.
2306 * @param obj The entry object
2307 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2313 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2315 Widget_Data *wd = elm_widget_data_get(obj);
2318 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2319 wd->show_last_character = show_last_character;
2320 wd->password = show_last_character;
2321 wd->single_line = EINA_TRUE;
2322 wd->linewrap = EINA_FALSE;
2323 wd->char_linewrap = EINA_FALSE;
2324 t = eina_stringshare_add(elm_entry_entry_get(obj));
2325 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2326 elm_entry_entry_set(obj, t);
2327 eina_stringshare_del(t);
2332 * This returns whether password mode is enabled.
2333 * See also elm_entry_password_set().
2335 * @param obj The entry object
2336 * @return If true, the entry is set to display all characters
2342 elm_entry_password_get(const Evas_Object *obj)
2344 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2345 Widget_Data *wd = elm_widget_data_get(obj);
2346 if (!wd) return EINA_FALSE;
2347 return wd->password;
2351 * This sets the text displayed within the entry to @p entry.
2353 * @param obj The entry object
2354 * @param entry The text to be displayed
2359 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2361 ELM_CHECK_WIDTYPE(obj, widtype);
2362 Widget_Data *wd = elm_widget_data_get(obj);
2364 if (!entry) entry = "";
2365 if(wd->max_no_of_bytes)
2367 int len = strlen(entry);
2368 if(len > wd->max_no_of_bytes)
2370 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2374 edje_object_part_text_set(wd->ent, "elm.text", entry);
2375 if (wd->text) eina_stringshare_del(wd->text);
2377 wd->changed = EINA_TRUE;
2382 * This returns the text currently shown in object @p entry.
2383 * See also elm_entry_entry_set().
2385 * @param obj The entry object
2386 * @return The currently displayed text or NULL on failure
2391 elm_entry_entry_get(const Evas_Object *obj)
2393 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2394 Widget_Data *wd = elm_widget_data_get(obj);
2396 if (!wd) return NULL;
2398 if ((wd->text)&&(wd->password))
2399 return elm_entry_markup_to_utf8(wd->text);
2401 if (wd->text) return wd->text;
2402 text = edje_object_part_text_get(wd->ent, "elm.text");
2405 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2408 eina_stringshare_replace(&wd->text, text);
2409 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2414 * This returns all selected text within the entry.
2416 * @param obj The entry object
2417 * @return The selected text within the entry or NULL on failure
2422 elm_entry_selection_get(const Evas_Object *obj)
2424 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2425 Widget_Data *wd = elm_widget_data_get(obj);
2426 if (!wd) return NULL;
2427 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2431 * This inserts text in @p entry at the beginning of the entry
2434 * @param obj The entry object
2435 * @param entry The text to insert
2440 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2442 ELM_CHECK_WIDTYPE(obj, widtype);
2443 Widget_Data *wd = elm_widget_data_get(obj);
2445 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2447 if (cnpwidgetdata == obj)
2448 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2450 wd->changed = EINA_TRUE;
2455 * This enables word line wrapping in the entry object. It is the opposite
2456 * of elm_entry_single_line_set(). Additionally, setting this disables
2457 * character line wrapping.
2458 * See also elm_entry_line_char_wrap_set().
2460 * @param obj The entry object
2461 * @param wrap If true, the entry will be wrapped once it reaches the end
2462 * of the object. Wrapping will occur at the end of the word before the end of the
2468 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2470 ELM_CHECK_WIDTYPE(obj, widtype);
2471 Widget_Data *wd = elm_widget_data_get(obj);
2474 if (wd->linewrap == wrap) return;
2475 wd->linewrap = wrap;
2477 wd->char_linewrap = EINA_FALSE;
2478 t = eina_stringshare_add(elm_entry_entry_get(obj));
2479 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2480 elm_entry_entry_set(obj, t);
2481 eina_stringshare_del(t);
2486 * Set wrap width of the entry
2488 * @param obj The entry object
2489 * @param w The wrap width in pixels at a minimum where words need to wrap
2493 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2495 Widget_Data *wd = elm_widget_data_get(obj);
2496 if (wd->wrap_w == w) return;
2502 * get wrap width of the entry
2504 * @param obj The entry object
2505 * @return The wrap width in pixels at a minimum where words need to wrap
2509 elm_entry_wrap_width_get(const Evas_Object *obj)
2511 Widget_Data *wd = elm_widget_data_get(obj);
2516 * This enables character line wrapping in the entry object. It is the opposite
2517 * of elm_entry_single_line_set(). Additionally, setting this disables
2518 * word line wrapping.
2519 * See also elm_entry_line_wrap_set().
2521 * @param obj The entry object
2522 * @param wrap If true, the entry will be wrapped once it reaches the end
2523 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2528 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2530 ELM_CHECK_WIDTYPE(obj, widtype);
2531 Widget_Data *wd = elm_widget_data_get(obj);
2534 if (wd->char_linewrap == wrap) return;
2535 wd->char_linewrap = wrap;
2536 if(wd->char_linewrap)
2537 wd->linewrap = EINA_FALSE;
2538 t = eina_stringshare_add(elm_entry_entry_get(obj));
2539 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2540 elm_entry_entry_set(obj, t);
2541 eina_stringshare_del(t);
2546 * This sets the editable attribute of the entry.
2548 * @param obj The entry object
2549 * @param editable If true, the entry will be editable by the user.
2550 * If false, it will be set to the disabled state.
2555 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2557 ELM_CHECK_WIDTYPE(obj, widtype);
2558 Widget_Data *wd = elm_widget_data_get(obj);
2561 if (wd->editable == editable) return;
2562 wd->editable = editable;
2563 t = eina_stringshare_add(elm_entry_entry_get(obj));
2564 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2565 elm_entry_entry_set(obj, t);
2566 eina_stringshare_del(t);
2569 #ifdef HAVE_ELEMENTARY_X
2571 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2573 elm_drop_target_del(obj);
2578 * This gets the editable attribute of the entry.
2579 * See also elm_entry_editable_set().
2581 * @param obj The entry object
2582 * @return If true, the entry is editable by the user.
2583 * If false, it is not editable by the user
2588 elm_entry_editable_get(const Evas_Object *obj)
2590 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2591 Widget_Data *wd = elm_widget_data_get(obj);
2592 if (!wd) return EINA_FALSE;
2593 return wd->editable;
2597 * This drops any existing text selection within the entry.
2599 * @param obj The entry object
2604 elm_entry_select_none(Evas_Object *obj)
2606 ELM_CHECK_WIDTYPE(obj, widtype);
2607 Widget_Data *wd = elm_widget_data_get(obj);
2611 wd->selmode = EINA_FALSE;
2612 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2613 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2615 wd->have_selection = EINA_FALSE;
2616 edje_object_part_text_select_none(wd->ent, "elm.text");
2620 * This selects all text within the entry.
2622 * @param obj The entry object
2627 elm_entry_select_all(Evas_Object *obj)
2629 ELM_CHECK_WIDTYPE(obj, widtype);
2630 Widget_Data *wd = elm_widget_data_get(obj);
2634 wd->selmode = EINA_FALSE;
2635 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2636 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2638 wd->have_selection = EINA_TRUE;
2639 edje_object_part_text_select_all(wd->ent, "elm.text");
2643 * This moves the cursor one place to the right within the entry.
2645 * @param obj The entry object
2646 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2651 elm_entry_cursor_next(Evas_Object *obj)
2653 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2654 Widget_Data *wd = elm_widget_data_get(obj);
2655 if (!wd) return EINA_FALSE;
2656 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2660 * This moves the cursor one place to the left within the entry.
2662 * @param obj The entry object
2663 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2668 elm_entry_cursor_prev(Evas_Object *obj)
2670 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2671 Widget_Data *wd = elm_widget_data_get(obj);
2672 if (!wd) return EINA_FALSE;
2673 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2677 * This moves the cursor one line up within the entry.
2679 * @param obj The entry object
2680 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2685 elm_entry_cursor_up(Evas_Object *obj)
2687 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2688 Widget_Data *wd = elm_widget_data_get(obj);
2689 if (!wd) return EINA_FALSE;
2690 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2694 * This moves the cursor one line down within the entry.
2696 * @param obj The entry object
2697 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2702 elm_entry_cursor_down(Evas_Object *obj)
2704 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2705 Widget_Data *wd = elm_widget_data_get(obj);
2706 if (!wd) return EINA_FALSE;
2707 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2711 * This moves the cursor to the beginning of the entry.
2713 * @param obj The entry object
2718 elm_entry_cursor_begin_set(Evas_Object *obj)
2720 ELM_CHECK_WIDTYPE(obj, widtype);
2721 Widget_Data *wd = elm_widget_data_get(obj);
2723 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2727 * This moves the cursor to the end of the entry.
2729 * @param obj The entry object
2734 elm_entry_cursor_end_set(Evas_Object *obj)
2736 ELM_CHECK_WIDTYPE(obj, widtype);
2737 Widget_Data *wd = elm_widget_data_get(obj);
2739 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2743 * This moves the cursor to the beginning of the current line.
2745 * @param obj The entry object
2750 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2752 ELM_CHECK_WIDTYPE(obj, widtype);
2753 Widget_Data *wd = elm_widget_data_get(obj);
2755 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2759 * This moves the cursor to the end of the current line.
2761 * @param obj The entry object
2766 elm_entry_cursor_line_end_set(Evas_Object *obj)
2768 ELM_CHECK_WIDTYPE(obj, widtype);
2769 Widget_Data *wd = elm_widget_data_get(obj);
2771 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2775 * This begins a selection within the entry as though
2776 * the user were holding down the mouse button to make a selection.
2778 * @param obj The entry object
2783 elm_entry_cursor_selection_begin(Evas_Object *obj)
2785 ELM_CHECK_WIDTYPE(obj, widtype);
2786 Widget_Data *wd = elm_widget_data_get(obj);
2788 edje_object_part_text_select_begin(wd->ent, "elm.text");
2792 * This ends a selection within the entry as though
2793 * the user had just released the mouse button while making a selection.
2795 * @param obj The entry object
2800 elm_entry_cursor_selection_end(Evas_Object *obj)
2802 ELM_CHECK_WIDTYPE(obj, widtype);
2803 Widget_Data *wd = elm_widget_data_get(obj);
2805 edje_object_part_text_select_extend(wd->ent, "elm.text");
2809 * TODO: fill this in
2811 * @param obj The entry object
2812 * @return TODO: fill this in
2817 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2819 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2820 Widget_Data *wd = elm_widget_data_get(obj);
2821 if (!wd) return EINA_FALSE;
2822 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2826 * This returns whether the cursor is visible.
2828 * @param obj The entry object
2829 * @return If true, the cursor is visible.
2834 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2836 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2837 Widget_Data *wd = elm_widget_data_get(obj);
2838 if (!wd) return EINA_FALSE;
2839 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2843 * TODO: fill this in
2845 * @param obj The entry object
2846 * @return TODO: fill this in
2851 elm_entry_cursor_content_get(const Evas_Object *obj)
2853 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2854 Widget_Data *wd = elm_widget_data_get(obj);
2855 if (!wd) return NULL;
2856 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2860 * This executes a "cut" action on the selected text in the entry.
2862 * @param obj The entry object
2867 elm_entry_selection_cut(Evas_Object *obj)
2869 ELM_CHECK_WIDTYPE(obj, widtype);
2870 Widget_Data *wd = elm_widget_data_get(obj);
2872 _cut(obj, NULL, NULL);
2876 * This executes a "copy" action on the selected text in the entry.
2878 * @param obj The entry object
2883 elm_entry_selection_copy(Evas_Object *obj)
2885 ELM_CHECK_WIDTYPE(obj, widtype);
2886 Widget_Data *wd = elm_widget_data_get(obj);
2888 _copy(obj, NULL, NULL);
2892 * This executes a "paste" action in the entry.
2894 * @param obj The entry object
2899 elm_entry_selection_paste(Evas_Object *obj)
2901 ELM_CHECK_WIDTYPE(obj, widtype);
2902 Widget_Data *wd = elm_widget_data_get(obj);
2904 _paste(obj, NULL, NULL);
2908 * This clears and frees the items in a entry's contextual (right click) menu.
2910 * @param obj The entry object
2915 elm_entry_context_menu_clear(Evas_Object *obj)
2917 ELM_CHECK_WIDTYPE(obj, widtype);
2918 Widget_Data *wd = elm_widget_data_get(obj);
2919 Elm_Entry_Context_Menu_Item *it;
2921 EINA_LIST_FREE(wd->items, it)
2923 eina_stringshare_del(it->label);
2924 eina_stringshare_del(it->icon_file);
2925 eina_stringshare_del(it->icon_group);
2931 * This adds an item to the entry's contextual menu.
2933 * @param obj The entry object
2934 * @param label The item's text label
2935 * @param icon_file The item's icon file
2936 * @param icon_type The item's icon type
2937 * @param func The callback to execute when the item is clicked
2938 * @param data The data to associate with the item for related functions
2943 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)
2945 ELM_CHECK_WIDTYPE(obj, widtype);
2946 Widget_Data *wd = elm_widget_data_get(obj);
2947 Elm_Entry_Context_Menu_Item *it;
2949 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2951 wd->items = eina_list_append(wd->items, it);
2953 it->label = eina_stringshare_add(label);
2954 it->icon_file = eina_stringshare_add(icon_file);
2955 it->icon_type = icon_type;
2957 it->data = (void *)data;
2961 * This disables the entry's contextual (right click) menu.
2963 * @param obj The entry object
2964 * @param disabled If true, the menu is disabled
2969 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2971 ELM_CHECK_WIDTYPE(obj, widtype);
2972 Widget_Data *wd = elm_widget_data_get(obj);
2974 if (wd->context_menu == !disabled) return;
2975 wd->context_menu = !disabled;
2979 * This returns whether the entry's contextual (right click) menu is disabled.
2981 * @param obj The entry object
2982 * @return If true, the menu is disabled
2987 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2989 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2990 Widget_Data *wd = elm_widget_data_get(obj);
2991 if (!wd) return EINA_FALSE;
2992 return !wd->context_menu;
2996 * This appends a custom item provider to the list for that entry
2998 * This appends the given callback. The list is walked from beginning to end
2999 * with each function called given the item href string in the text. If the
3000 * function returns an object handle other than NULL (it should create an
3001 * and object to do this), then this object is used to replace that item. If
3002 * not the next provider is called until one provides an item object, or the
3003 * default provider in entry does.
3005 * @param obj The entry object
3006 * @param func The function called to provide the item object
3007 * @param data The data passed to @p func
3012 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3014 ELM_CHECK_WIDTYPE(obj, widtype);
3015 Widget_Data *wd = elm_widget_data_get(obj);
3018 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3022 wd->item_providers = eina_list_append(wd->item_providers, ip);
3026 * This prepends a custom item provider to the list for that entry
3028 * This prepends the given callback. See elm_entry_item_provider_append() for
3031 * @param obj The entry object
3032 * @param func The function called to provide the item object
3033 * @param data The data passed to @p func
3038 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3040 ELM_CHECK_WIDTYPE(obj, widtype);
3041 Widget_Data *wd = elm_widget_data_get(obj);
3044 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3048 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3052 * This removes a custom item provider to the list for that entry
3054 * This removes the given callback. See elm_entry_item_provider_append() for
3057 * @param obj The entry object
3058 * @param func The function called to provide the item object
3059 * @param data The data passed to @p func
3064 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3066 ELM_CHECK_WIDTYPE(obj, widtype);
3067 Widget_Data *wd = elm_widget_data_get(obj);
3069 Elm_Entry_Item_Provider *ip;
3072 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3074 if ((ip->func == func) && (ip->data == data))
3076 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3084 * This converts a markup (HTML-like) string into UTF-8.
3086 * @param s The string (in markup) to be converted
3087 * @return The converted string (in UTF-8)
3092 elm_entry_markup_to_utf8(const char *s)
3094 char *ss = _mkup_to_text(s);
3095 if (!ss) ss = strdup("");
3100 * This converts a UTF-8 string into markup (HTML-like).
3102 * @param s The string (in UTF-8) to be converted
3103 * @return The converted string (in markup)
3108 elm_entry_utf8_to_markup(const char *s)
3110 char *ss = _text_to_mkup(s);
3111 if (!ss) ss = strdup("");
3116 * Get the input method context in the entry widget
3118 * @param obj The entry object
3119 * @return The input method context
3123 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3125 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3126 Widget_Data *wd = elm_widget_data_get(obj);
3127 if (!wd || !wd->ent) return NULL;
3129 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3133 * Set whether entry should enable the return key on soft keyboard automatically
3135 * @param obj The entry object
3136 * @param on If true, entry enables the return key on soft keyboard automatically.
3141 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3143 ELM_CHECK_WIDTYPE(obj, widtype);
3144 Widget_Data *wd = elm_widget_data_get(obj);
3147 wd->autoreturnkey = on;
3148 _check_enable_returnkey(obj);
3152 * Set whether entry should support auto capitalization
3154 * @param obj The entry object
3155 * @param on If true, entry suports auto capitalization.
3160 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3162 ELM_CHECK_WIDTYPE(obj, widtype);
3163 Widget_Data *wd = elm_widget_data_get(obj);
3167 wd->autocapital = EINA_FALSE;
3169 wd->autocapital = autocap;
3171 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3172 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3173 wd->autocapital = EINA_FALSE;
3175 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3179 * Set whether entry should support auto period
3181 * @param obj The entry object
3182 * @param on If true, entry suports auto period.
3187 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3189 ELM_CHECK_WIDTYPE(obj, widtype);
3190 Widget_Data *wd = elm_widget_data_get(obj);
3194 wd->autoperiod = EINA_FALSE;
3196 wd->autoperiod = autoperiod;
3198 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3199 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3200 wd->autoperiod = EINA_FALSE;
3202 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3206 * Set the font size on the entry object
3208 * @param obj The entry object
3209 * @param size font size
3214 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3216 ELM_CHECK_WIDTYPE(obj, widtype);
3217 Widget_Data *wd = elm_widget_data_get(obj);
3218 Eina_Strbuf *fontbuf = NULL;
3223 t = eina_stringshare_add(elm_entry_entry_get(obj));
3224 fontbuf = eina_strbuf_new();
3225 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3227 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3229 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3231 elm_entry_entry_set(obj, t);
3235 eina_strbuf_free(fontbuf);
3236 eina_stringshare_del(t);
3240 * Set the text align on the entry object
3242 * @param obj The entry object
3243 * @param align align mode
3248 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3250 ELM_CHECK_WIDTYPE(obj, widtype);
3251 Widget_Data *wd = elm_widget_data_get(obj);
3256 t = eina_stringshare_add(elm_entry_entry_get(obj));
3258 if (len <= 0) return;
3260 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3261 elm_entry_entry_set(obj, t);
3265 eina_stringshare_del(t);
3269 * Set the text color on the entry object
3271 * @param obj The entry object
3272 * @param r Red property background color of The entry object
3273 * @param g Green property background color of The entry object
3274 * @param b Blue property background color of The entry object
3275 * @param a Alpha property background alpha of The entry object
3280 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3282 ELM_CHECK_WIDTYPE(obj, widtype);
3283 Widget_Data *wd = elm_widget_data_get(obj);
3284 Eina_Strbuf *colorbuf = NULL;
3289 t = eina_stringshare_add(elm_entry_entry_get(obj));
3291 if (len <= 0) return;
3292 colorbuf = eina_strbuf_new();
3293 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3295 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3297 elm_entry_entry_set(obj, t);
3301 eina_strbuf_free(colorbuf);
3302 eina_stringshare_del(t);
3307 * Set background color of the entry
3309 * @param obj The entry object
3310 * @param r Red property background color of The entry object
3311 * @param g Green property background color of The entry object
3312 * @param b Blue property background color of The entry object
3313 * @param a Alpha property background alpha of The entry object
3317 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3319 ELM_CHECK_WIDTYPE(obj, widtype);
3320 Widget_Data *wd = elm_widget_data_get(obj);
3321 evas_object_color_set(wd->bg, r, g, b, a);
3323 if (wd->bgcolor == EINA_FALSE)
3326 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3331 * Set the ellipsis behavior of the entry
3333 * @param obj The entry object
3334 * @param ellipsis To ellipsis text or not
3338 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3340 ELM_CHECK_WIDTYPE(obj, widtype);
3341 Widget_Data *wd = elm_widget_data_get(obj);
3342 if (wd->ellipsis == ellipsis) return;
3343 wd->ellipsis = ellipsis;
3349 * This sets the attribute to show the input panel automatically.
3351 * @param obj The entry object
3352 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3357 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3359 ELM_CHECK_WIDTYPE(obj, widtype);
3360 Widget_Data *wd = elm_widget_data_get(obj);
3363 wd->input_panel_enable = enabled;
3364 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3368 * Set the input panel layout of the entry
3370 * @param obj The entry object
3371 * @param layout the layout to set
3376 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3378 ELM_CHECK_WIDTYPE(obj, widtype);
3379 Widget_Data *wd = elm_widget_data_get(obj);
3382 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3385 wd->input_panel_layout = layout;
3387 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3390 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/