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 printf(" long press timeout : %lf \n\n", elm_longpress_timeout_get());
819 wd->downx = ev->canvas.x;
820 wd->downy = ev->canvas.y;
824 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
826 Widget_Data *wd = elm_widget_data_get(data);
827 Evas_Event_Mouse_Up *ev = event_info;
829 if (ev->button != 1) return;
831 if (!wd->double_clicked)
833 if ((wd->api) && (wd->api->obj_mouseup))
835 wd->api->obj_mouseup(data);
838 if (wd->longpress_timer)
840 ecore_timer_del(wd->longpress_timer);
841 wd->longpress_timer = NULL;
846 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
848 Widget_Data *wd = elm_widget_data_get(data);
849 Evas_Event_Mouse_Move *ev = event_info;
853 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
855 if (wd->longpress_timer)
857 ecore_timer_del(wd->longpress_timer);
858 wd->longpress_timer = NULL;
861 else if (wd->longpress_timer)
865 dx = wd->downx - ev->cur.canvas.x;
867 dy = wd->downy - ev->cur.canvas.y;
870 ((_elm_config->finger_size / 2) *
871 (_elm_config->finger_size / 2)))
873 ecore_timer_del(wd->longpress_timer);
874 wd->longpress_timer = NULL;
878 else if (wd->longpress_timer)
882 dx = wd->downx - ev->cur.canvas.x;
884 dy = wd->downy - ev->cur.canvas.y;
887 ((_elm_config->finger_size / 2) *
888 (_elm_config->finger_size / 2)))
890 ecore_timer_del(wd->longpress_timer);
891 wd->longpress_timer = NULL;
897 _getbase(Evas_Object *obj)
899 Widget_Data *wd = elm_widget_data_get(obj);
900 if (!wd) return "base";
905 if (wd->show_last_character) return "custom-password";
906 else return "base-password";
910 if (wd->single_line) return "base-single";
913 if (wd->linewrap) return "base";
914 else if (wd->char_linewrap) return "base-charwrap";
915 else return "base-nowrap";
923 if (wd->show_last_character) return "custom-password";
924 else return "base-password";
928 if (wd->single_line) return "base-single-noedit";
931 if (wd->linewrap) return "base-noedit";
932 else if (wd->char_linewrap) return "base-noedit-charwrap";
933 else return "base-nowrap-noedit";
941 _str_append(char *str, const char *txt, int *len, int *alloc)
943 int txt_len = strlen(txt);
945 if (txt_len <= 0) return str;
946 if ((*len + txt_len) >= *alloc)
951 alloc2 = *alloc + txt_len + 128;
952 str2 = realloc(str, alloc2);
953 if (!str2) return str;
957 strcpy(str + *len, txt);
962 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
963 * because some markups can be implemented otherwise according to style.
964 * probably doing it in textblock and making it translate according to it's
965 * style is correct. */
967 _strncpy(char* dest, const char* src, size_t count)
971 ERR( "dest is NULL" );
976 ERR( "src is NULL" );
981 ERR( "count is smaller than 0" );
985 return strncpy( dest, src, count );
989 _mkup_to_text(const char *mkup)
992 int str_len = 0, str_alloc = 0;
994 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
996 if (!mkup) return NULL;
998 tag_start = tag_end = esc_start = esc_end = NULL;
1003 if (((p!=NULL)&&(*p == 0)) ||
1004 (tag_end) || (esc_end) ||
1005 (tag_start) || (esc_start))
1011 ttag = malloc(tag_end - tag_start);
1014 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
1015 ttag[tag_end - tag_start - 1] = 0;
1016 if (!strcmp(ttag, "br"))
1017 str = _str_append(str, "\n", &str_len, &str_alloc);
1018 else if (!strcmp(ttag, "\n"))
1019 str = _str_append(str, "\n", &str_len, &str_alloc);
1020 else if (!strcmp(ttag, "\\n"))
1021 str = _str_append(str, "\n", &str_len, &str_alloc);
1022 else if (!strcmp(ttag, "\t"))
1023 str = _str_append(str, "\t", &str_len, &str_alloc);
1024 else if (!strcmp(ttag, "\\t"))
1025 str = _str_append(str, "\t", &str_len, &str_alloc);
1026 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
1027 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1030 tag_start = tag_end = NULL;
1034 ts = malloc(esc_end - esc_start + 1);
1038 _strncpy(ts, esc_start, esc_end - esc_start);
1039 ts[esc_end - esc_start] = 0;
1040 esc = evas_textblock_escape_string_get(ts);
1042 str = _str_append(str, esc, &str_len, &str_alloc);
1045 esc_start = esc_end = NULL;
1047 else if ((p!=NULL)&&(*p == 0))
1049 ts = malloc(p - s + 1);
1052 _strncpy(ts, s, p - s);
1054 str = _str_append(str, ts, &str_len, &str_alloc);
1060 if ((p!=NULL)&&(*p == '<'))
1066 ts = malloc(p - s + 1);
1069 _strncpy(ts, s, p - s);
1071 str = _str_append(str, ts, &str_len, &str_alloc);
1077 else if ((p!=NULL)&&(*p == '>'))
1085 else if ((p!=NULL)&&(*p == '&'))
1091 ts = malloc(p - s + 1);
1094 _strncpy(ts, s, p - s);
1096 str = _str_append(str, ts, &str_len, &str_alloc);
1102 else if ((p!=NULL)&&(*p == ';'))
1116 _entry_length_get(Evas_Object *obj)
1119 const char *str = elm_entry_entry_get(obj);
1122 char *plain_str = _mkup_to_text(str);
1123 if (!plain_str) return 0;
1125 len = strlen(plain_str);
1132 _text_to_mkup(const char *text)
1135 int str_len = 0, str_alloc = 0;
1136 int ch, pos = 0, pos2 = 0;
1138 if (!text) return NULL;
1142 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1143 if ((ch <= 0) || (pos2 <= 0)) break;
1145 str = _str_append(str, "<br>", &str_len, &str_alloc);
1146 else if (ch == '\t')
1147 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1149 str = _str_append(str, "<", &str_len, &str_alloc);
1151 str = _str_append(str, ">", &str_len, &str_alloc);
1153 str = _str_append(str, "&", &str_len, &str_alloc);
1154 else if (ch == 0x2029)
1155 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1160 _strncpy(tstr, text + pos, pos2 - pos);
1161 tstr[pos2 - pos] = 0;
1162 str = _str_append(str, tstr, &str_len, &str_alloc);
1169 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1171 Widget_Data *wd = elm_widget_data_get(data);
1173 wd->changed = EINA_TRUE;
1175 if (wd->text) eina_stringshare_del(wd->text);
1177 _check_enable_returnkey(data);
1178 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1182 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1184 Widget_Data *wd = elm_widget_data_get(data);
1185 elm_object_scroll_freeze_push(data);
1189 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1191 Widget_Data *wd = elm_widget_data_get(data);
1192 elm_object_scroll_freeze_pop(data);
1196 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1198 Widget_Data *wd = elm_widget_data_get(data);
1202 EINA_LIST_FOREACH(entries, l, entry)
1204 if (entry != data) elm_entry_select_none(entry);
1206 wd->have_selection = EINA_TRUE;
1207 wd->selmode = EINA_TRUE;
1208 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1209 #ifdef HAVE_ELEMENTARY_X
1210 if (wd->sel_notify_handler)
1212 const char *txt = elm_entry_selection_get(data);
1215 top = elm_widget_top_get(data);
1216 if ((top) && (elm_win_xwindow_get(top)))
1217 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1223 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1225 Evas_Coord cx, cy, cw, ch;
1226 Widget_Data *wd = elm_widget_data_get(data);
1228 wd->have_selection = EINA_TRUE;
1229 wd->selmode = EINA_TRUE;
1230 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1231 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1232 elm_entry_selection_get(data));
1234 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1235 if (!wd->deferred_recalc_job)
1236 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1239 wd->deferred_cur = EINA_TRUE;
1243 wd->ch = ch + elm_finger_size_get();
1248 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1250 Widget_Data *wd = elm_widget_data_get(data);
1252 if (!wd->have_selection) return;
1253 wd->have_selection = EINA_FALSE;
1254 wd->selmode = EINA_FALSE;
1255 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1256 if (wd->sel_notify_handler)
1260 #ifdef HAVE_ELEMENTARY_X
1263 top = elm_widget_top_get(data);
1264 if ((top) && (elm_win_xwindow_get(top)))
1265 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1268 eina_stringshare_del(wd->cut_sel);
1273 #ifdef HAVE_ELEMENTARY_X
1276 top = elm_widget_top_get(data);
1277 if ((top) && (elm_win_xwindow_get(top)))
1278 elm_selection_clear(ELM_SEL_PRIMARY, data);
1285 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1287 Widget_Data *wd = elm_widget_data_get(data);
1289 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1290 if (wd->sel_notify_handler)
1292 #ifdef HAVE_ELEMENTARY_X
1295 top = elm_widget_top_get(data);
1296 if ((top) && (elm_win_xwindow_get(top)))
1298 wd->selection_asked = EINA_TRUE;
1299 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1306 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1308 Widget_Data *wd = elm_widget_data_get(data);
1310 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1311 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1312 elm_entry_selection_get(data));
1316 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1318 Widget_Data *wd = elm_widget_data_get(data);
1320 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1321 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1322 elm_entry_selection_get(data));
1323 edje_object_part_text_insert(wd->ent, "elm.text", "");
1324 wd->changed = EINA_TRUE;
1329 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1331 Widget_Data *wd = elm_widget_data_get(data);
1332 Evas_Coord cx, cy, cw, ch;
1334 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1335 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1336 &cx, &cy, &cw, &ch);
1337 if (!wd->deferred_recalc_job)
1338 elm_widget_show_region_set(data, cx, cy, cw, ch);
1341 wd->deferred_cur = EINA_TRUE;
1347 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1348 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1353 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1355 Widget_Data *wd = elm_widget_data_get(data);
1360 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1362 Widget_Data *wd = elm_widget_data_get(data);
1363 Elm_Entry_Anchor_Info ei;
1364 char *buf2, *p, *p2, *n;
1366 p = strrchr(emission, ',');
1369 const Eina_List *geoms;
1373 while (p2 >= emission)
1375 if (*p2 == ',') break;
1379 buf2 = alloca(5 + p - p2);
1380 strncpy(buf2, p2, p - p2);
1383 ei.button = atoi(buf2);
1384 ei.x = ei.y = ei.w = ei.h = 0;
1386 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1389 Evas_Textblock_Rectangle *r;
1391 Evas_Coord px, py, x, y;
1393 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1394 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1395 EINA_LIST_FOREACH(geoms, l, r)
1397 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1398 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1409 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1414 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1416 Widget_Data *wd = elm_widget_data_get(data);
1421 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1423 Widget_Data *wd = elm_widget_data_get(data);
1428 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1430 Widget_Data *wd = elm_widget_data_get(data);
1435 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1437 Widget_Data *wd = elm_widget_data_get(data);
1439 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1443 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1445 Widget_Data *wd = elm_widget_data_get(data);
1447 wd->double_clicked = EINA_FALSE;
1448 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1452 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1454 Widget_Data *wd = elm_widget_data_get(data);
1456 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1460 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1462 Widget_Data *wd = elm_widget_data_get(data);
1464 wd->double_clicked = EINA_TRUE;
1465 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1468 #ifdef HAVE_ELEMENTARY_X
1470 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1472 Widget_Data *wd = elm_widget_data_get(data);
1473 Ecore_X_Event_Selection_Notify *ev = event;
1474 if (!wd) return ECORE_CALLBACK_PASS_ON;
1475 if (!wd->selection_asked && !wd->drag_selection_asked)
1476 return ECORE_CALLBACK_PASS_ON;
1478 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1479 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1481 Ecore_X_Selection_Data_Text *text_data;
1483 text_data = ev->data;
1484 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1486 if (text_data->text)
1488 char *txt = _text_to_mkup(text_data->text);
1492 elm_entry_entry_insert(data, txt);
1497 wd->selection_asked = EINA_FALSE;
1499 else if (ev->selection == ECORE_X_SELECTION_XDND)
1501 Ecore_X_Selection_Data_Text *text_data;
1503 text_data = ev->data;
1504 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1506 if (text_data->text)
1508 char *txt = _text_to_mkup(text_data->text);
1512 /* Massive FIXME: this should be at the drag point */
1513 elm_entry_entry_insert(data, txt);
1518 wd->drag_selection_asked = EINA_FALSE;
1520 ecore_x_dnd_send_finished();
1523 return ECORE_CALLBACK_PASS_ON;
1527 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1530 Widget_Data *wd = elm_widget_data_get(data);
1531 Ecore_X_Event_Selection_Clear *ev = event;
1532 if (!wd) return ECORE_CALLBACK_PASS_ON;
1533 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1534 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1535 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1537 elm_entry_select_none(data);
1542 Evas_Object *top = elm_widget_top_get(data);
1543 Ecore_X_Event_Selection_Clear *ev = event;
1546 return ECORE_CALLBACK_PASS_ON;
1548 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1550 return ECORE_CALLBACK_PASS_ON;
1553 if (cnpwidgetdata == data)
1555 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1559 return ECORE_CALLBACK_PASS_ON;
1563 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1568 wd = elm_widget_data_get(obj);
1570 if (!wd) return EINA_FALSE;
1571 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1573 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1574 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1575 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1576 EDJE_CURSOR_MAIN,drop->x,drop->y);
1577 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1578 elm_entry_entry_insert(obj, drop->data);
1579 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1580 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1586 static Evas_Object *
1587 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1589 Widget_Data *wd = elm_widget_data_get(data);
1592 Elm_Entry_Item_Provider *ip;
1595 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1597 o = ip->func(ip->data, data, item);
1600 o = edje_object_add(evas_object_evas_get(data));
1601 if (!strncmp(item, "emoticon/", 9))
1602 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1604 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1609 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1611 char *curlocater, *starttag, *endtag;
1612 int firstindex = 0, foundflag = -1;
1614 curlocater = strstr(oldstring, key);
1617 starttag = curlocater;
1618 endtag = curlocater + strlen(key);
1619 if (endtag == NULL || *endtag != '=')
1625 firstindex = abs(oldstring - curlocater);
1626 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1627 *value = (char*)oldstring + firstindex;
1629 while (oldstring != starttag)
1631 if (*starttag == '>')
1636 if (*starttag == '<')
1640 if (starttag == NULL) break;
1643 while (NULL != endtag)
1654 if (endtag == NULL) break;
1657 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1667 if (foundflag == 1) return 0;
1673 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1675 const char *srcstring = NULL;
1676 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1677 char *curlocater, *replocater;
1678 char *starttag, *endtag;
1679 int tagtxtlen = 0, insertflag = 0;
1681 srcstring = eina_strbuf_string_get(srcbuf);
1682 curlocater = strstr(srcstring, key);
1684 if (curlocater == NULL)
1692 starttag = strchr(srcstring, '<');
1693 endtag = strchr(srcstring, '>');
1694 tagtxtlen = endtag - starttag;
1695 if (tagtxtlen <= 0) tagtxtlen = 0;
1696 if (starttag < curlocater && curlocater < endtag) break;
1697 if (endtag != NULL && endtag+1 != NULL)
1698 srcstring = endtag+1;
1701 } while (strlen(srcstring) > 1);
1703 if (starttag && endtag && tagtxtlen > strlen(key))
1705 repbuf = eina_strbuf_new();
1706 diffbuf = eina_strbuf_new();
1707 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1708 srcstring = eina_strbuf_string_get(repbuf);
1709 curlocater = strstr(srcstring, key);
1711 if (curlocater != NULL)
1713 replocater = curlocater + strlen(key) + 1;
1715 while (*replocater == ' ' || *replocater == '=')
1720 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1723 if (replocater-curlocater > strlen(key)+1)
1726 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1735 eina_strbuf_reset(repbuf);
1743 if (repbuf == NULL) repbuf = eina_strbuf_new();
1744 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1748 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1749 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1755 eina_strbuf_prepend(diffbuf, "<");
1756 eina_strbuf_append(diffbuf, ">");
1757 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1761 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1762 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1766 if (repbuf) eina_strbuf_free(repbuf);
1767 if (diffbuf) eina_strbuf_free(diffbuf);
1773 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1775 Eina_Strbuf *sharebuf = NULL;
1777 sharebuf = eina_strbuf_new();
1778 eina_strbuf_append(sharebuf, *srcstring);
1779 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1780 eina_stringshare_del(*srcstring);
1781 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1782 eina_strbuf_free(sharebuf);
1788 _is_width_over(Evas_Object *obj)
1790 Evas_Coord x, y, w, h;
1791 Evas_Coord vx, vy, vw, vh;
1792 Widget_Data *wd = elm_widget_data_get(obj);
1796 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1798 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1800 if (x >= 0 && y >= 0)
1803 if (4 < wd->wrap_w && w > wd->wrap_w)
1810 _reverse_ellipsis_entry(Evas_Object *obj)
1812 Widget_Data *wd = elm_widget_data_get(obj);
1813 int cur_fontsize = 0;
1814 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1815 char **kvalue = NULL;
1816 const char *minfont, *deffont, *maxfont;
1817 const char *ellipsis_string = "...";
1818 int minfontsize, maxfontsize, minshowcount;
1820 minshowcount = strlen(ellipsis_string) + 1;
1821 minfont = edje_object_data_get(wd->ent, "min_font_size");
1822 if (minfont) minfontsize = atoi(minfont);
1823 else minfontsize = 1;
1824 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1825 if (maxfont) maxfontsize = atoi(maxfont);
1826 else maxfontsize = 1;
1827 deffont = edje_object_data_get(wd->ent, "default_font_size");
1828 if (deffont) cur_fontsize = atoi(deffont);
1829 else cur_fontsize = 1;
1830 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1831 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1833 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1835 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1838 txtbuf = eina_strbuf_new();
1839 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1841 if (cur_fontsize >= atoi(deffont))
1843 if (txtbuf) eina_strbuf_free(txtbuf);
1847 if (_is_width_over(obj) != 1)
1849 int rev_fontsize = cur_fontsize;
1853 if (rev_fontsize > atoi(deffont))
1856 if (fontbuf != NULL)
1858 eina_strbuf_free(fontbuf);
1861 fontbuf = eina_strbuf_new();
1862 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1863 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1864 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1866 eina_strbuf_free(fontbuf);
1868 } while (_is_width_over(obj) != 1);
1870 while (_is_width_over(obj))
1873 if (rev_fontsize < atoi(deffont))
1876 if (fontbuf != NULL)
1878 eina_strbuf_free(fontbuf);
1881 fontbuf = eina_strbuf_new();
1882 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1883 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1884 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1885 eina_strbuf_free(fontbuf);
1890 if (txtbuf) eina_strbuf_free(txtbuf);
1896 _ellipsis_entry_to_width(Evas_Object *obj)
1898 Widget_Data *wd = elm_widget_data_get(obj);
1899 int cur_fontsize = 0, len, jumpcount;
1900 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1901 char **kvalue = NULL;
1902 const char *minfont, *deffont, *maxfont;
1903 const char *ellipsis_string = "...";
1904 int minfontsize, maxfontsize, minshowcount;
1905 int i, tagend, cur_len;
1908 minshowcount = strlen(ellipsis_string) + 1;
1909 minfont = edje_object_data_get(wd->ent, "min_font_size");
1910 if (minfont) minfontsize = atoi(minfont);
1911 else minfontsize = 1;
1912 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1913 if (maxfont) maxfontsize = atoi(maxfont);
1914 else maxfontsize = 1;
1915 deffont = edje_object_data_get(wd->ent, "default_font_size");
1916 if (deffont) cur_fontsize = atoi(deffont);
1917 else cur_fontsize = 1;
1918 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1919 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1921 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1923 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1926 txtbuf = eina_strbuf_new();
1927 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1929 while (_is_width_over(obj))
1931 if (wd->ellipsis_threshold == 0)
1932 wd->ellipsis_threshold = _entry_length_get(obj);
1933 if (cur_fontsize > minfontsize)
1936 if (fontbuf != NULL)
1938 eina_strbuf_free(fontbuf);
1941 fontbuf = eina_strbuf_new();
1942 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1943 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1944 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1945 eina_strbuf_free(fontbuf);
1947 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1951 len = _entry_length_get(obj);
1952 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1953 cur_len = strlen(cur_str);
1955 for (i = 0; i < len; i++)
1957 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1958 cur_str[i+1] != '<')
1965 while (jumpcount < len-strlen(ellipsis_string))
1967 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1971 eina_strbuf_free(txtbuf);
1974 txtbuf = eina_strbuf_new();
1975 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1976 eina_strbuf_append(txtbuf, ellipsis_string);
1977 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1978 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1979 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1981 if (_is_width_over(obj))
1989 if (txtbuf) eina_strbuf_free(txtbuf);
1994 static int _textinput_control_function(void *data,void *input_data)
1996 /* calculate character count */
1997 Evas_Object *entry = (Evas_Object *)data;
1998 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2001 size_t insert_text_len=0;
2002 char *text = edje_object_part_text_get(wd->ent, "elm.text");
2004 size_t remain_bytes;
2007 byte_len = strlen(text); /* no of bytes */
2008 remain_bytes = wd->max_no_of_bytes - byte_len;
2009 sprintf(buf,"%d",remain_bytes);
2010 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2013 insert_text = (char *)input_data;
2014 insert_text_len = strlen(insert_text);
2015 if (remain_bytes < insert_text_len)
2017 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2020 if (byte_len >= wd->max_no_of_bytes)
2022 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2031 * This adds an entry to @p parent object.
2033 * @param parent The parent object
2034 * @return The new object or NULL if it cannot be created
2039 elm_entry_add(Evas_Object *parent)
2041 Evas_Object *obj, *top;
2045 wd = ELM_NEW(Widget_Data);
2046 e = evas_object_evas_get(parent);
2047 wd->bgcolor = EINA_FALSE;
2048 wd->bg = evas_object_rectangle_add(e);
2049 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2050 obj = elm_widget_add(e);
2051 ELM_SET_WIDTYPE(widtype, "entry");
2052 elm_widget_type_set(obj, "entry");
2053 elm_widget_sub_object_add(parent, obj);
2054 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2055 elm_widget_data_set(obj, wd);
2056 elm_widget_del_hook_set(obj, _del_hook);
2057 elm_widget_theme_hook_set(obj, _theme_hook);
2058 elm_widget_disable_hook_set(obj, _disable_hook);
2059 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2060 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2061 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2062 elm_widget_can_focus_set(obj, 1);
2063 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2064 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2067 wd->linewrap = EINA_TRUE;
2068 wd->ellipsis = EINA_FALSE;
2069 wd->char_linewrap= EINA_FALSE;
2070 wd->editable = EINA_TRUE;
2071 wd->disabled = EINA_FALSE;
2072 wd->context_menu = EINA_TRUE;
2073 wd->autoperiod = EINA_TRUE;
2075 wd->ellipsis_threshold = 0;
2077 wd->ent = edje_object_add(e);
2078 edje_object_item_provider_set(wd->ent, _get_item, obj);
2079 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2080 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2081 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2083 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2085 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2088 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2089 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2090 _signal_entry_changed, obj);
2091 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2092 _signal_handler_move_start, obj);
2093 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2094 _signal_handler_move_end, obj);
2095 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2096 _signal_selection_start, obj);
2097 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2098 _signal_selection_changed, obj);
2099 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2100 _signal_selection_cleared, obj);
2101 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2102 _signal_entry_paste_request, obj);
2103 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2104 _signal_entry_copy_notify, obj);
2105 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2106 _signal_entry_cut_notify, obj);
2107 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2108 _signal_cursor_changed, obj);
2109 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2110 _signal_anchor_down, obj);
2111 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2112 _signal_anchor_up, obj);
2113 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2114 _signal_anchor_move, obj);
2115 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2116 _signal_anchor_in, obj);
2117 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2118 _signal_anchor_out, obj);
2119 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2120 _signal_key_enter, obj);
2121 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2122 _signal_mouse_down, obj);
2123 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2124 _signal_mouse_up, obj);
2125 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2126 _signal_mouse_double, obj);
2127 edje_object_part_text_set(wd->ent, "elm.text", "");
2128 elm_widget_resize_object_set(obj, wd->ent);
2131 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2133 #ifdef HAVE_ELEMENTARY_X
2134 top = elm_widget_top_get(obj);
2135 if ((top) && (elm_win_xwindow_get(top)))
2137 wd->sel_notify_handler =
2138 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2139 _event_selection_notify, obj);
2140 wd->sel_clear_handler =
2141 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2142 _event_selection_clear, obj);
2145 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2148 entries = eina_list_prepend(entries, obj);
2150 // module - find module for entry
2151 wd->api = _module(obj);
2152 // if found - hook in
2153 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2155 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2156 // TODO: and save some bytes, making descriptions per-class and not instance!
2157 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2161 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2163 ELM_CHECK_WIDTYPE(obj, widtype);
2164 Widget_Data *wd = elm_widget_data_get(obj);
2166 ext_mod->cancel = _cancel;
2167 ext_mod->copy = _copy;
2168 ext_mod->cut = _cut;
2169 ext_mod->paste = _paste;
2170 ext_mod->select = _select;
2171 ext_mod->selectall = _selectall;
2172 ext_mod->ent = wd->ent;
2173 ext_mod->items = wd->items;
2174 ext_mod->longpress_timer = wd->longpress_timer;
2175 ext_mod->editable = wd->editable;
2176 ext_mod->have_selection = wd->have_selection;
2177 ext_mod->password = wd->password;
2178 ext_mod->selmode = wd->selmode;
2179 ext_mod->cnpinit = _cnpinit;
2180 ext_mod->context_menu = wd->context_menu;
2184 * This sets the entry object not to line wrap. All input will
2185 * be on a single line, and the entry box will extend with user input.
2187 * @param obj The entry object
2188 * @param single_line If true, the text in the entry
2189 * will be on a single line.
2194 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2196 ELM_CHECK_WIDTYPE(obj, widtype);
2197 Widget_Data *wd = elm_widget_data_get(obj);
2199 Ecore_IMF_Context *ic;
2201 if (wd->single_line == single_line) return;
2202 wd->single_line = single_line;
2203 wd->linewrap = EINA_FALSE;
2204 wd->char_linewrap = EINA_FALSE;
2205 t = eina_stringshare_add(elm_entry_entry_get(obj));
2206 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2207 elm_entry_entry_set(obj, t);
2208 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2209 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2210 ic = elm_entry_imf_context_get(obj);
2213 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2216 eina_stringshare_del(t);
2221 * This returns true if the entry has been set to single line mode.
2222 * See also elm_entry_single_line_set().
2224 * @param obj The entry object
2225 * @return single_line If true, the text in the entry is set to display
2231 elm_entry_single_line_get(const Evas_Object *obj)
2233 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2234 Widget_Data *wd = elm_widget_data_get(obj);
2235 if (!wd) return EINA_FALSE;
2236 return wd->single_line;
2240 * This set's the maximum bytes that can be added in entry.
2242 * @param obj The entry object
2243 * @param max_no_of_bytes Maximum number of bytes entry can have.
2248 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2250 Widget_Data *wd = elm_widget_data_get(obj);
2252 wd->max_no_of_bytes = max_no_of_bytes;
2253 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2254 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2259 * This sets the entry object to password mode. All text entered
2260 * and/or displayed within the widget will be replaced with asterisks (*).
2262 * @param obj The entry object
2263 * @param password If true, password mode is enabled.
2268 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2270 ELM_CHECK_WIDTYPE(obj, widtype);
2271 Widget_Data *wd = elm_widget_data_get(obj);
2272 Ecore_IMF_Context *ic;
2275 if (wd->password == password) return;
2276 wd->password = password;
2277 wd->single_line = EINA_TRUE;
2278 wd->linewrap = EINA_FALSE;
2279 wd->char_linewrap = EINA_FALSE;
2280 if (_elm_config->password_show_last_character)
2281 wd->show_last_character = EINA_TRUE;
2282 t = eina_stringshare_add(elm_entry_entry_get(obj));
2283 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2284 elm_entry_entry_set(obj, t);
2289 elm_entry_autoperiod_set(obj, EINA_FALSE);
2291 if (wd->autocapital)
2292 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2295 ic = elm_entry_imf_context_get(obj);
2297 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2299 eina_stringshare_del(t);
2304 * This set's the entry in password mode with out masking the last character entered by user,
2305 * and later masking the character after 2 seconds.
2307 * @param obj The entry object
2308 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2314 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2316 Widget_Data *wd = elm_widget_data_get(obj);
2319 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2320 wd->show_last_character = show_last_character;
2321 wd->password = show_last_character;
2322 wd->single_line = EINA_TRUE;
2323 wd->linewrap = EINA_FALSE;
2324 wd->char_linewrap = EINA_FALSE;
2325 t = eina_stringshare_add(elm_entry_entry_get(obj));
2326 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2327 elm_entry_entry_set(obj, t);
2328 eina_stringshare_del(t);
2333 * This returns whether password mode is enabled.
2334 * See also elm_entry_password_set().
2336 * @param obj The entry object
2337 * @return If true, the entry is set to display all characters
2343 elm_entry_password_get(const Evas_Object *obj)
2345 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2346 Widget_Data *wd = elm_widget_data_get(obj);
2347 if (!wd) return EINA_FALSE;
2348 return wd->password;
2352 * This sets the text displayed within the entry to @p entry.
2354 * @param obj The entry object
2355 * @param entry The text to be displayed
2360 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2362 ELM_CHECK_WIDTYPE(obj, widtype);
2363 Widget_Data *wd = elm_widget_data_get(obj);
2365 if (!entry) entry = "";
2366 if(wd->max_no_of_bytes)
2368 int len = strlen(entry);
2369 if(len > wd->max_no_of_bytes)
2371 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2375 edje_object_part_text_set(wd->ent, "elm.text", entry);
2376 if (wd->text) eina_stringshare_del(wd->text);
2378 wd->changed = EINA_TRUE;
2383 * This returns the text currently shown in object @p entry.
2384 * See also elm_entry_entry_set().
2386 * @param obj The entry object
2387 * @return The currently displayed text or NULL on failure
2392 elm_entry_entry_get(const Evas_Object *obj)
2394 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2395 Widget_Data *wd = elm_widget_data_get(obj);
2397 if (!wd) return NULL;
2399 if ((wd->text)&&(wd->password))
2400 return elm_entry_markup_to_utf8(wd->text);
2402 if (wd->text) return wd->text;
2403 text = edje_object_part_text_get(wd->ent, "elm.text");
2406 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2409 eina_stringshare_replace(&wd->text, text);
2410 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2415 * This returns all selected text within the entry.
2417 * @param obj The entry object
2418 * @return The selected text within the entry or NULL on failure
2423 elm_entry_selection_get(const Evas_Object *obj)
2425 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2426 Widget_Data *wd = elm_widget_data_get(obj);
2427 if (!wd) return NULL;
2428 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2432 * This inserts text in @p entry at the beginning of the entry
2435 * @param obj The entry object
2436 * @param entry The text to insert
2441 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2443 ELM_CHECK_WIDTYPE(obj, widtype);
2444 Widget_Data *wd = elm_widget_data_get(obj);
2446 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2448 if (cnpwidgetdata == obj)
2449 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2451 wd->changed = EINA_TRUE;
2456 * This enables word line wrapping in the entry object. It is the opposite
2457 * of elm_entry_single_line_set(). Additionally, setting this disables
2458 * character line wrapping.
2459 * See also elm_entry_line_char_wrap_set().
2461 * @param obj The entry object
2462 * @param wrap If true, the entry will be wrapped once it reaches the end
2463 * of the object. Wrapping will occur at the end of the word before the end of the
2469 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2471 ELM_CHECK_WIDTYPE(obj, widtype);
2472 Widget_Data *wd = elm_widget_data_get(obj);
2475 if (wd->linewrap == wrap) return;
2476 wd->linewrap = wrap;
2478 wd->char_linewrap = EINA_FALSE;
2479 t = eina_stringshare_add(elm_entry_entry_get(obj));
2480 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2481 elm_entry_entry_set(obj, t);
2482 eina_stringshare_del(t);
2487 * Set wrap width of the entry
2489 * @param obj The entry object
2490 * @param w The wrap width in pixels at a minimum where words need to wrap
2494 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2496 Widget_Data *wd = elm_widget_data_get(obj);
2497 if (wd->wrap_w == w) return;
2503 * get wrap width of the entry
2505 * @param obj The entry object
2506 * @return The wrap width in pixels at a minimum where words need to wrap
2510 elm_entry_wrap_width_get(const Evas_Object *obj)
2512 Widget_Data *wd = elm_widget_data_get(obj);
2517 * This enables character line wrapping in the entry object. It is the opposite
2518 * of elm_entry_single_line_set(). Additionally, setting this disables
2519 * word line wrapping.
2520 * See also elm_entry_line_wrap_set().
2522 * @param obj The entry object
2523 * @param wrap If true, the entry will be wrapped once it reaches the end
2524 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2529 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2531 ELM_CHECK_WIDTYPE(obj, widtype);
2532 Widget_Data *wd = elm_widget_data_get(obj);
2535 if (wd->char_linewrap == wrap) return;
2536 wd->char_linewrap = wrap;
2537 if(wd->char_linewrap)
2538 wd->linewrap = EINA_FALSE;
2539 t = eina_stringshare_add(elm_entry_entry_get(obj));
2540 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2541 elm_entry_entry_set(obj, t);
2542 eina_stringshare_del(t);
2547 * This sets the editable attribute of the entry.
2549 * @param obj The entry object
2550 * @param editable If true, the entry will be editable by the user.
2551 * If false, it will be set to the disabled state.
2556 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2558 ELM_CHECK_WIDTYPE(obj, widtype);
2559 Widget_Data *wd = elm_widget_data_get(obj);
2562 if (wd->editable == editable) return;
2563 wd->editable = editable;
2564 t = eina_stringshare_add(elm_entry_entry_get(obj));
2565 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2566 elm_entry_entry_set(obj, t);
2567 eina_stringshare_del(t);
2570 #ifdef HAVE_ELEMENTARY_X
2572 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2574 elm_drop_target_del(obj);
2579 * This gets the editable attribute of the entry.
2580 * See also elm_entry_editable_set().
2582 * @param obj The entry object
2583 * @return If true, the entry is editable by the user.
2584 * If false, it is not editable by the user
2589 elm_entry_editable_get(const Evas_Object *obj)
2591 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2592 Widget_Data *wd = elm_widget_data_get(obj);
2593 if (!wd) return EINA_FALSE;
2594 return wd->editable;
2598 * This drops any existing text selection within the entry.
2600 * @param obj The entry object
2605 elm_entry_select_none(Evas_Object *obj)
2607 ELM_CHECK_WIDTYPE(obj, widtype);
2608 Widget_Data *wd = elm_widget_data_get(obj);
2612 wd->selmode = EINA_FALSE;
2613 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2614 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2616 wd->have_selection = EINA_FALSE;
2617 edje_object_part_text_select_none(wd->ent, "elm.text");
2621 * This selects all text within the entry.
2623 * @param obj The entry object
2628 elm_entry_select_all(Evas_Object *obj)
2630 ELM_CHECK_WIDTYPE(obj, widtype);
2631 Widget_Data *wd = elm_widget_data_get(obj);
2635 wd->selmode = EINA_FALSE;
2636 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2637 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2639 wd->have_selection = EINA_TRUE;
2640 edje_object_part_text_select_all(wd->ent, "elm.text");
2644 * This moves the cursor one place to the right within the entry.
2646 * @param obj The entry object
2647 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2652 elm_entry_cursor_next(Evas_Object *obj)
2654 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2655 Widget_Data *wd = elm_widget_data_get(obj);
2656 if (!wd) return EINA_FALSE;
2657 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2661 * This moves the cursor one place to the left within the entry.
2663 * @param obj The entry object
2664 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2669 elm_entry_cursor_prev(Evas_Object *obj)
2671 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2672 Widget_Data *wd = elm_widget_data_get(obj);
2673 if (!wd) return EINA_FALSE;
2674 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2678 * This moves the cursor one line up within the entry.
2680 * @param obj The entry object
2681 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2686 elm_entry_cursor_up(Evas_Object *obj)
2688 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2689 Widget_Data *wd = elm_widget_data_get(obj);
2690 if (!wd) return EINA_FALSE;
2691 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2695 * This moves the cursor one line down within the entry.
2697 * @param obj The entry object
2698 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2703 elm_entry_cursor_down(Evas_Object *obj)
2705 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2706 Widget_Data *wd = elm_widget_data_get(obj);
2707 if (!wd) return EINA_FALSE;
2708 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2712 * This moves the cursor to the beginning of the entry.
2714 * @param obj The entry object
2719 elm_entry_cursor_begin_set(Evas_Object *obj)
2721 ELM_CHECK_WIDTYPE(obj, widtype);
2722 Widget_Data *wd = elm_widget_data_get(obj);
2724 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2728 * This moves the cursor to the end of the entry.
2730 * @param obj The entry object
2735 elm_entry_cursor_end_set(Evas_Object *obj)
2737 ELM_CHECK_WIDTYPE(obj, widtype);
2738 Widget_Data *wd = elm_widget_data_get(obj);
2740 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2744 * This moves the cursor to the beginning of the current line.
2746 * @param obj The entry object
2751 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2753 ELM_CHECK_WIDTYPE(obj, widtype);
2754 Widget_Data *wd = elm_widget_data_get(obj);
2756 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2760 * This moves the cursor to the end of the current line.
2762 * @param obj The entry object
2767 elm_entry_cursor_line_end_set(Evas_Object *obj)
2769 ELM_CHECK_WIDTYPE(obj, widtype);
2770 Widget_Data *wd = elm_widget_data_get(obj);
2772 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2776 * This begins a selection within the entry as though
2777 * the user were holding down the mouse button to make a selection.
2779 * @param obj The entry object
2784 elm_entry_cursor_selection_begin(Evas_Object *obj)
2786 ELM_CHECK_WIDTYPE(obj, widtype);
2787 Widget_Data *wd = elm_widget_data_get(obj);
2789 edje_object_part_text_select_begin(wd->ent, "elm.text");
2793 * This ends a selection within the entry as though
2794 * the user had just released the mouse button while making a selection.
2796 * @param obj The entry object
2801 elm_entry_cursor_selection_end(Evas_Object *obj)
2803 ELM_CHECK_WIDTYPE(obj, widtype);
2804 Widget_Data *wd = elm_widget_data_get(obj);
2806 edje_object_part_text_select_extend(wd->ent, "elm.text");
2810 * TODO: fill this in
2812 * @param obj The entry object
2813 * @return TODO: fill this in
2818 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2820 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2821 Widget_Data *wd = elm_widget_data_get(obj);
2822 if (!wd) return EINA_FALSE;
2823 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2827 * This returns whether the cursor is visible.
2829 * @param obj The entry object
2830 * @return If true, the cursor is visible.
2835 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2837 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2838 Widget_Data *wd = elm_widget_data_get(obj);
2839 if (!wd) return EINA_FALSE;
2840 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2844 * TODO: fill this in
2846 * @param obj The entry object
2847 * @return TODO: fill this in
2852 elm_entry_cursor_content_get(const Evas_Object *obj)
2854 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2855 Widget_Data *wd = elm_widget_data_get(obj);
2856 if (!wd) return NULL;
2857 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2861 * This executes a "cut" action on the selected text in the entry.
2863 * @param obj The entry object
2868 elm_entry_selection_cut(Evas_Object *obj)
2870 ELM_CHECK_WIDTYPE(obj, widtype);
2871 Widget_Data *wd = elm_widget_data_get(obj);
2873 _cut(obj, NULL, NULL);
2877 * This executes a "copy" action on the selected text in the entry.
2879 * @param obj The entry object
2884 elm_entry_selection_copy(Evas_Object *obj)
2886 ELM_CHECK_WIDTYPE(obj, widtype);
2887 Widget_Data *wd = elm_widget_data_get(obj);
2889 _copy(obj, NULL, NULL);
2893 * This executes a "paste" action in the entry.
2895 * @param obj The entry object
2900 elm_entry_selection_paste(Evas_Object *obj)
2902 ELM_CHECK_WIDTYPE(obj, widtype);
2903 Widget_Data *wd = elm_widget_data_get(obj);
2905 _paste(obj, NULL, NULL);
2909 * This clears and frees the items in a entry's contextual (right click) menu.
2911 * @param obj The entry object
2916 elm_entry_context_menu_clear(Evas_Object *obj)
2918 ELM_CHECK_WIDTYPE(obj, widtype);
2919 Widget_Data *wd = elm_widget_data_get(obj);
2920 Elm_Entry_Context_Menu_Item *it;
2922 EINA_LIST_FREE(wd->items, it)
2924 eina_stringshare_del(it->label);
2925 eina_stringshare_del(it->icon_file);
2926 eina_stringshare_del(it->icon_group);
2932 * This adds an item to the entry's contextual menu.
2934 * @param obj The entry object
2935 * @param label The item's text label
2936 * @param icon_file The item's icon file
2937 * @param icon_type The item's icon type
2938 * @param func The callback to execute when the item is clicked
2939 * @param data The data to associate with the item for related functions
2944 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)
2946 ELM_CHECK_WIDTYPE(obj, widtype);
2947 Widget_Data *wd = elm_widget_data_get(obj);
2948 Elm_Entry_Context_Menu_Item *it;
2950 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2952 wd->items = eina_list_append(wd->items, it);
2954 it->label = eina_stringshare_add(label);
2955 it->icon_file = eina_stringshare_add(icon_file);
2956 it->icon_type = icon_type;
2958 it->data = (void *)data;
2962 * This disables the entry's contextual (right click) menu.
2964 * @param obj The entry object
2965 * @param disabled If true, the menu is disabled
2970 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2972 ELM_CHECK_WIDTYPE(obj, widtype);
2973 Widget_Data *wd = elm_widget_data_get(obj);
2975 if (wd->context_menu == !disabled) return;
2976 wd->context_menu = !disabled;
2980 * This returns whether the entry's contextual (right click) menu is disabled.
2982 * @param obj The entry object
2983 * @return If true, the menu is disabled
2988 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2990 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2991 Widget_Data *wd = elm_widget_data_get(obj);
2992 if (!wd) return EINA_FALSE;
2993 return !wd->context_menu;
2997 * This appends a custom item provider to the list for that entry
2999 * This appends the given callback. The list is walked from beginning to end
3000 * with each function called given the item href string in the text. If the
3001 * function returns an object handle other than NULL (it should create an
3002 * and object to do this), then this object is used to replace that item. If
3003 * not the next provider is called until one provides an item object, or the
3004 * default provider in entry does.
3006 * @param obj The entry object
3007 * @param func The function called to provide the item object
3008 * @param data The data passed to @p func
3013 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3015 ELM_CHECK_WIDTYPE(obj, widtype);
3016 Widget_Data *wd = elm_widget_data_get(obj);
3019 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3023 wd->item_providers = eina_list_append(wd->item_providers, ip);
3027 * This prepends a custom item provider to the list for that entry
3029 * This prepends the given callback. See elm_entry_item_provider_append() for
3032 * @param obj The entry object
3033 * @param func The function called to provide the item object
3034 * @param data The data passed to @p func
3039 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3041 ELM_CHECK_WIDTYPE(obj, widtype);
3042 Widget_Data *wd = elm_widget_data_get(obj);
3045 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3049 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3053 * This removes a custom item provider to the list for that entry
3055 * This removes the given callback. See elm_entry_item_provider_append() for
3058 * @param obj The entry object
3059 * @param func The function called to provide the item object
3060 * @param data The data passed to @p func
3065 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3067 ELM_CHECK_WIDTYPE(obj, widtype);
3068 Widget_Data *wd = elm_widget_data_get(obj);
3070 Elm_Entry_Item_Provider *ip;
3073 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3075 if ((ip->func == func) && (ip->data == data))
3077 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3085 * This converts a markup (HTML-like) string into UTF-8.
3087 * @param s The string (in markup) to be converted
3088 * @return The converted string (in UTF-8)
3093 elm_entry_markup_to_utf8(const char *s)
3095 char *ss = _mkup_to_text(s);
3096 if (!ss) ss = strdup("");
3101 * This converts a UTF-8 string into markup (HTML-like).
3103 * @param s The string (in UTF-8) to be converted
3104 * @return The converted string (in markup)
3109 elm_entry_utf8_to_markup(const char *s)
3111 char *ss = _text_to_mkup(s);
3112 if (!ss) ss = strdup("");
3117 * Get the input method context in the entry widget
3119 * @param obj The entry object
3120 * @return The input method context
3124 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3126 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3127 Widget_Data *wd = elm_widget_data_get(obj);
3128 if (!wd || !wd->ent) return NULL;
3130 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3134 * Set whether entry should enable the return key on soft keyboard automatically
3136 * @param obj The entry object
3137 * @param on If true, entry enables the return key on soft keyboard automatically.
3142 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3144 ELM_CHECK_WIDTYPE(obj, widtype);
3145 Widget_Data *wd = elm_widget_data_get(obj);
3148 wd->autoreturnkey = on;
3149 _check_enable_returnkey(obj);
3153 * Set whether entry should support auto capitalization
3155 * @param obj The entry object
3156 * @param on If true, entry suports auto capitalization.
3161 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3163 ELM_CHECK_WIDTYPE(obj, widtype);
3164 Widget_Data *wd = elm_widget_data_get(obj);
3168 wd->autocapital = EINA_FALSE;
3170 wd->autocapital = autocap;
3172 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3173 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3174 wd->autocapital = EINA_FALSE;
3176 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3180 * Set whether entry should support auto period
3182 * @param obj The entry object
3183 * @param on If true, entry suports auto period.
3188 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3190 ELM_CHECK_WIDTYPE(obj, widtype);
3191 Widget_Data *wd = elm_widget_data_get(obj);
3195 wd->autoperiod = EINA_FALSE;
3197 wd->autoperiod = autoperiod;
3199 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3200 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3201 wd->autoperiod = EINA_FALSE;
3203 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3207 * Set the font size on the entry object
3209 * @param obj The entry object
3210 * @param size font size
3215 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3217 ELM_CHECK_WIDTYPE(obj, widtype);
3218 Widget_Data *wd = elm_widget_data_get(obj);
3219 Eina_Strbuf *fontbuf = NULL;
3224 t = eina_stringshare_add(elm_entry_entry_get(obj));
3225 fontbuf = eina_strbuf_new();
3226 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3228 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3230 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3232 elm_entry_entry_set(obj, t);
3236 eina_strbuf_free(fontbuf);
3237 eina_stringshare_del(t);
3241 * Set the text align on the entry object
3243 * @param obj The entry object
3244 * @param align align mode
3249 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3251 ELM_CHECK_WIDTYPE(obj, widtype);
3252 Widget_Data *wd = elm_widget_data_get(obj);
3257 t = eina_stringshare_add(elm_entry_entry_get(obj));
3259 if (len <= 0) return;
3261 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3262 elm_entry_entry_set(obj, t);
3266 eina_stringshare_del(t);
3270 * Set the text color on the entry object
3272 * @param obj The entry object
3273 * @param r Red property background color of The entry object
3274 * @param g Green property background color of The entry object
3275 * @param b Blue property background color of The entry object
3276 * @param a Alpha property background alpha of The entry object
3281 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3283 ELM_CHECK_WIDTYPE(obj, widtype);
3284 Widget_Data *wd = elm_widget_data_get(obj);
3285 Eina_Strbuf *colorbuf = NULL;
3290 t = eina_stringshare_add(elm_entry_entry_get(obj));
3292 if (len <= 0) return;
3293 colorbuf = eina_strbuf_new();
3294 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3296 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3298 elm_entry_entry_set(obj, t);
3302 eina_strbuf_free(colorbuf);
3303 eina_stringshare_del(t);
3308 * Set background color of the entry
3310 * @param obj The entry object
3311 * @param r Red property background color of The entry object
3312 * @param g Green property background color of The entry object
3313 * @param b Blue property background color of The entry object
3314 * @param a Alpha property background alpha of The entry object
3318 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3320 ELM_CHECK_WIDTYPE(obj, widtype);
3321 Widget_Data *wd = elm_widget_data_get(obj);
3322 evas_object_color_set(wd->bg, r, g, b, a);
3324 if (wd->bgcolor == EINA_FALSE)
3327 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3332 * Set the ellipsis behavior of the entry
3334 * @param obj The entry object
3335 * @param ellipsis To ellipsis text or not
3339 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3341 ELM_CHECK_WIDTYPE(obj, widtype);
3342 Widget_Data *wd = elm_widget_data_get(obj);
3343 if (wd->ellipsis == ellipsis) return;
3344 wd->ellipsis = ellipsis;
3350 * This sets the attribute to show the input panel automatically.
3352 * @param obj The entry object
3353 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3358 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3360 ELM_CHECK_WIDTYPE(obj, widtype);
3361 Widget_Data *wd = elm_widget_data_get(obj);
3364 wd->input_panel_enable = enabled;
3365 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3369 * Set the input panel layout of the entry
3371 * @param obj The entry object
3372 * @param layout the layout to set
3377 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3379 ELM_CHECK_WIDTYPE(obj, widtype);
3380 Widget_Data *wd = elm_widget_data_get(obj);
3383 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3386 wd->input_panel_layout = layout;
3388 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3391 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/