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_end(void *data, Evas_Object *obj, const char *emission, const char *source);
167 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
168 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
169 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
170 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
171 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
172 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
173 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
174 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
175 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
176 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
177 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
178 static int _is_width_over(Evas_Object *obj);
179 static void _ellipsis_entry_to_width(Evas_Object *obj);
180 static void _reverse_ellipsis_entry(Evas_Object *obj);
181 static int _textinput_control_function(void *data,void *input_data);
182 static int _entry_length_get(Evas_Object *obj);
184 static const char SIG_CHANGED[] = "changed";
185 static const char SIG_ACTIVATED[] = "activated";
186 static const char SIG_PRESS[] = "press";
187 static const char SIG_LONGPRESSED[] = "longpressed";
188 static const char SIG_CLICKED[] = "clicked";
189 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
190 static const char SIG_FOCUSED[] = "focused";
191 static const char SIG_UNFOCUSED[] = "unfocused";
192 static const char SIG_SELECTION_PASTE[] = "selection,paste";
193 static const char SIG_SELECTION_COPY[] = "selection,copy";
194 static const char SIG_SELECTION_CUT[] = "selection,cut";
195 static const char SIG_SELECTION_START[] = "selection,start";
196 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
197 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
198 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
199 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
200 #ifdef HAVE_CONFORMANT_AUTOSCROLL
201 static const char SIG_IMPREGION_CHANGED[] = "impregion,changed";
203 static const Evas_Smart_Cb_Description _signals[] = {
207 {SIG_LONGPRESSED, ""},
209 {SIG_CLICKED_DOUBLE, ""},
212 {SIG_SELECTION_PASTE, ""},
213 {SIG_SELECTION_COPY, ""},
214 {SIG_SELECTION_CUT, ""},
215 {SIG_SELECTION_START, ""},
216 {SIG_SELECTION_CHANGED, ""},
217 {SIG_SELECTION_CLEARED, ""},
218 {SIG_CURSOR_CHANGED, ""},
219 {SIG_ANCHOR_CLICKED, ""},
223 static Eina_List *entries = NULL;
227 void (*obj_hook) (Evas_Object *obj);
228 void (*obj_unhook) (Evas_Object *obj);
229 void (*obj_longpress) (Evas_Object *obj);
230 void (*obj_hidemenu) (Evas_Object *obj);
231 void (*obj_mouseup) (Evas_Object *obj);
235 _module(Evas_Object *obj __UNUSED__)
237 static Elm_Module *m = NULL;
238 if (m) goto ok; // already found - just use
239 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
241 m->api = malloc(sizeof(Mod_Api));
242 if (!m->api) return NULL;
243 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
244 _elm_module_symbol_get(m, "obj_hook");
245 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
246 _elm_module_symbol_get(m, "obj_unhook");
247 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
248 _elm_module_symbol_get(m, "obj_longpress");
249 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
250 _elm_module_symbol_get(m, "obj_hidemenu");
251 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
252 _elm_module_symbol_get(m, "obj_mouseup");
253 ok: // ok - return api
258 _del_hook(Evas_Object *obj)
260 Widget_Data *wd = elm_widget_data_get(obj);
261 Elm_Entry_Context_Menu_Item *it;
262 Elm_Entry_Item_Provider *ip;
263 Evas_Object *parent_obj = obj;
264 Evas_Object *above = NULL;
266 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
267 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
269 /* added for locating parents as they were */
272 above = evas_object_data_get(parent_obj, "raise");
274 evas_object_stack_below(parent_obj, above);
275 parent_obj = elm_widget_parent_get(parent_obj);
278 entries = eina_list_remove(entries, obj);
279 #ifdef HAVE_ELEMENTARY_X
280 ecore_event_handler_del(wd->sel_notify_handler);
281 ecore_event_handler_del(wd->sel_clear_handler);
283 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
284 if (wd->text) eina_stringshare_del(wd->text);
285 if (wd->bg) evas_object_del(wd->bg);
286 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
287 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
288 EINA_LIST_FREE(wd->items, it)
290 eina_stringshare_del(it->label);
291 eina_stringshare_del(it->icon_file);
292 eina_stringshare_del(it->icon_group);
295 EINA_LIST_FREE(wd->item_providers, ip)
303 _theme_hook(Evas_Object *obj)
305 Widget_Data *wd = elm_widget_data_get(obj);
307 Ecore_IMF_Context *ic;
309 t = eina_stringshare_add(elm_entry_entry_get(obj));
310 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
311 elm_entry_entry_set(obj, t);
312 eina_stringshare_del(t);
313 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
314 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
315 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
316 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
318 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
321 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
328 _disable_hook(Evas_Object *obj)
330 Widget_Data *wd = elm_widget_data_get(obj);
332 if (elm_widget_disabled_get(obj))
334 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
335 wd->disabled = EINA_TRUE;
339 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
340 wd->disabled = EINA_FALSE;
345 _elm_win_recalc_job(void *data)
347 Widget_Data *wd = elm_widget_data_get(data);
348 Evas_Coord minw = -1, minh = -1, maxh = -1;
349 Evas_Coord resw, resh, minminw;
351 wd->deferred_recalc_job = NULL;
352 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
355 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
356 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
358 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
359 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
360 evas_object_size_hint_min_set(data, minminw, minh);
361 if (wd->single_line) maxh = minh;
362 evas_object_size_hint_max_set(data, -1, maxh);
363 if (wd->deferred_cur)
364 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
368 _sizing_eval(Evas_Object *obj)
370 Widget_Data *wd = elm_widget_data_get(obj);
371 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
372 Evas_Coord resw, resh;
374 if (wd->linewrap || wd->char_linewrap)
376 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
377 if ((resw == wd->lastw) && (!wd->changed)) return;
378 wd->changed = EINA_FALSE;
380 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
381 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
385 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
386 edje_object_size_min_calc(wd->ent, &minw, &minh);
387 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
388 evas_object_size_hint_min_set(obj, minw, minh);
389 if (wd->single_line) maxh = minh;
390 evas_object_size_hint_max_set(obj, maxw, maxh);
392 if (wd->ellipsis && wd->single_line)
394 if (_is_width_over(obj))
395 _ellipsis_entry_to_width(obj);
396 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
397 _reverse_ellipsis_entry(obj);
403 _check_enable_returnkey(Evas_Object *obj)
405 Widget_Data *wd = elm_widget_data_get(obj);
408 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
411 if (!wd->autoreturnkey) return;
413 if (_entry_length_get(obj) == 0)
415 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
419 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
423 #ifdef HAVE_CONFORMANT_AUTOSCROLL
425 _imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
427 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
428 Widget_Data *wd = elm_widget_data_get(obj);
429 if (!wd) return NULL;
430 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
442 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
444 Widget_Data *wd = elm_widget_data_get(obj);
445 Evas_Object *top = elm_widget_top_get(obj);
446 Evas_Object *parent_obj = obj;
447 Evas_Object *above = NULL;
450 if (!wd->editable) return;
451 if (elm_widget_focus_get(obj))
453 evas_object_focus_set(wd->ent, EINA_TRUE);
454 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
456 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
457 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
458 _check_enable_returnkey(obj);
462 above = evas_object_above_get(parent_obj);
464 evas_object_data_set(parent_obj, "raise", above);
465 evas_object_raise(parent_obj);
466 parent_obj = elm_widget_parent_get(parent_obj);
471 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
472 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
473 evas_object_focus_set(wd->ent, EINA_FALSE);
474 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
475 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
479 above = evas_object_data_get(parent_obj, "raise");
481 evas_object_stack_below(parent_obj, above);
482 parent_obj = elm_widget_parent_get(parent_obj);
489 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
491 Widget_Data *wd = elm_widget_data_get(obj);
493 edje_object_signal_emit(wd->ent, emission, source);
497 _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)
499 Widget_Data *wd = elm_widget_data_get(obj);
501 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
505 _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))
507 Widget_Data *wd = elm_widget_data_get(obj);
508 if (!wd) return NULL;
509 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
513 _hoversel_position(Evas_Object *obj)
515 Widget_Data *wd = elm_widget_data_get(obj);
516 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
518 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
519 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
521 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
532 evas_object_move(wd->hoversel, x + cx, y + cy);
533 evas_object_resize(wd->hoversel, cw, ch);
537 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
539 Widget_Data *wd = elm_widget_data_get(data);
541 if (wd->hoversel) _hoversel_position(data);
545 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
547 Widget_Data *wd = elm_widget_data_get(data);
549 if (wd->linewrap || wd->char_linewrap)
553 if (wd->hoversel) _hoversel_position(data);
554 // Evas_Coord ww, hh;
555 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
559 _hover_del(void *data)
561 Widget_Data *wd = elm_widget_data_get(data);
566 evas_object_del(wd->hoversel);
569 wd->hovdeljob = NULL;
573 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
575 Widget_Data *wd = elm_widget_data_get(data);
577 if (wd->hoversel) evas_object_hide(wd->hoversel);
581 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
583 elm_widget_scroll_freeze_pop(data);
584 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
585 wd->hovdeljob = ecore_job_add(_hover_del, data);
589 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
591 Widget_Data *wd = elm_widget_data_get(data);
593 wd->selmode = EINA_TRUE;
595 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
596 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
597 edje_object_part_text_select_all(wd->ent, "elm.text");
598 //elm_widget_scroll_hold_push(data);
599 elm_object_scroll_freeze_pop(data);
603 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
605 Widget_Data *wd = elm_widget_data_get(data);
607 wd->selmode = EINA_TRUE;
608 edje_object_part_text_select_none(wd->ent, "elm.text");
610 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
611 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
612 elm_object_scroll_freeze_pop(data);
613 //elm_widget_scroll_hold_push(data);
617 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
619 Widget_Data *wd = elm_widget_data_get(data);
621 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
622 if (wd->sel_notify_handler)
624 #ifdef HAVE_ELEMENTARY_X
625 wd->selection_asked = EINA_TRUE;
626 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
632 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
634 Widget_Data *wd = elm_widget_data_get(obj);
638 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
639 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
640 if (seltype == ELM_SEL_CLIPBOARD)
641 eina_stringshare_replace(&wd->cut_sel, sel);
645 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
647 Widget_Data *wd = elm_widget_data_get(data);
650 wd->selmode = EINA_FALSE;
651 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
652 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
653 elm_widget_scroll_hold_pop(data);
654 _store_selection(ELM_SEL_CLIPBOARD, data);
655 edje_object_part_text_insert(wd->ent, "elm.text", "");
656 edje_object_part_text_select_none(wd->ent, "elm.text");
660 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
662 Widget_Data *wd = elm_widget_data_get(data);
664 //wd->selmode = EINA_FALSE;
665 //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
666 //edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
667 elm_widget_scroll_hold_pop(data);
668 _store_selection(ELM_SEL_CLIPBOARD, data);
669 //edje_object_part_text_select_none(wd->ent, "elm.text");
673 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
675 Widget_Data *wd = elm_widget_data_get(data);
677 wd->selmode = EINA_FALSE;
678 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
679 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
680 elm_widget_scroll_hold_pop(data);
681 edje_object_part_text_select_none(wd->ent, "elm.text");
685 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
687 Widget_Data *wd = elm_widget_data_get(data);
691 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
692 cnpwidgetdata = data;
693 elm_cbhm_helper_init(obj);
694 elm_cbhm_send_raw_data("show");
700 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
702 Widget_Data *wd = elm_widget_data_get(data);
704 cnpwidgetdata = data;
710 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
712 Elm_Entry_Context_Menu_Item *it = data;
713 Evas_Object *obj2 = it->obj;
715 if (it->func) it->func(it->data, obj2, NULL);
719 _long_press(void *data)
721 Widget_Data *wd = elm_widget_data_get(data);
724 const Elm_Entry_Context_Menu_Item *it;
725 if (!wd) return ECORE_CALLBACK_CANCEL;
727 if (wd->longpress_timer)
729 ecore_timer_del(wd->longpress_timer);
730 wd->longpress_timer = NULL;
733 if ((wd->api) && (wd->api->obj_longpress))
735 wd->api->obj_longpress(data);
737 else if (wd->context_menu)
739 const char *context_menu_orientation;
741 if (wd->hoversel) evas_object_del(wd->hoversel);
742 else elm_widget_scroll_freeze_push(data);
743 wd->hoversel = elm_hoversel_add(data);
744 context_menu_orientation = edje_object_data_get
745 (wd->ent, "context_menu_orientation");
746 if ((context_menu_orientation) &&
747 (!strcmp(context_menu_orientation, "horizontal")))
748 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
749 elm_object_style_set(wd->hoversel, "entry");
750 elm_widget_sub_object_add(data, wd->hoversel);
751 elm_hoversel_label_set(wd->hoversel, "Text");
752 top = elm_widget_top_get(data);
753 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
754 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
758 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
760 if (1) // need way to detect if someone has a selection
763 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
768 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
769 _clipboard_menu, data);
776 if (wd->have_selection)
778 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
781 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
784 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
787 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
788 _clipboard_menu, data);
792 EINA_LIST_FOREACH(wd->items, l, it)
794 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
795 it->icon_type, _item_clicked, it);
799 _hoversel_position(data);
800 evas_object_show(wd->hoversel);
801 elm_hoversel_hover_begin(wd->hoversel);
803 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
804 edje_object_part_text_select_abort(wd->ent, "elm.text");
806 wd->longpress_timer = NULL;
807 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
808 return ECORE_CALLBACK_CANCEL;
812 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
814 Widget_Data *wd = elm_widget_data_get(data);
815 Evas_Event_Mouse_Down *ev = event_info;
817 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
818 if (ev->button != 1) return;
819 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
820 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
821 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
822 wd->downx = ev->canvas.x;
823 wd->downy = ev->canvas.y;
827 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
829 Widget_Data *wd = elm_widget_data_get(data);
830 Evas_Event_Mouse_Up *ev = event_info;
832 if (ev->button != 1) return;
834 if (!wd->double_clicked)
836 if ((wd->api) && (wd->api->obj_mouseup))
838 wd->api->obj_mouseup(data);
841 if (wd->longpress_timer)
843 ecore_timer_del(wd->longpress_timer);
844 wd->longpress_timer = NULL;
849 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
851 Widget_Data *wd = elm_widget_data_get(data);
852 Evas_Event_Mouse_Move *ev = event_info;
856 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
858 if (wd->longpress_timer)
860 ecore_timer_del(wd->longpress_timer);
861 wd->longpress_timer = NULL;
864 else if (wd->longpress_timer)
868 dx = wd->downx - ev->cur.canvas.x;
870 dy = wd->downy - ev->cur.canvas.y;
873 ((_elm_config->finger_size / 2) *
874 (_elm_config->finger_size / 2)))
876 ecore_timer_del(wd->longpress_timer);
877 wd->longpress_timer = NULL;
881 else if (wd->longpress_timer)
885 dx = wd->downx - ev->cur.canvas.x;
887 dy = wd->downy - ev->cur.canvas.y;
890 ((_elm_config->finger_size / 2) *
891 (_elm_config->finger_size / 2)))
893 ecore_timer_del(wd->longpress_timer);
894 wd->longpress_timer = NULL;
900 _getbase(Evas_Object *obj)
902 Widget_Data *wd = elm_widget_data_get(obj);
903 if (!wd) return "base";
908 if (wd->show_last_character) return "custom-password";
909 else return "base-password";
913 if (wd->single_line) return "base-single";
916 if (wd->linewrap) return "base";
917 else if (wd->char_linewrap) return "base-charwrap";
918 else return "base-nowrap";
926 if (wd->show_last_character) return "custom-password";
927 else return "base-password";
931 if (wd->single_line) return "base-single-noedit";
934 if (wd->linewrap) return "base-noedit";
935 else if (wd->char_linewrap) return "base-noedit-charwrap";
936 else return "base-nowrap-noedit";
944 _str_append(char *str, const char *txt, int *len, int *alloc)
946 int txt_len = strlen(txt);
948 if (txt_len <= 0) return str;
949 if ((*len + txt_len) >= *alloc)
954 alloc2 = *alloc + txt_len + 128;
955 str2 = realloc(str, alloc2);
956 if (!str2) return str;
960 strcpy(str + *len, txt);
965 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
966 * because some markups can be implemented otherwise according to style.
967 * probably doing it in textblock and making it translate according to it's
968 * style is correct. */
970 _strncpy(char* dest, const char* src, size_t count)
974 ERR( "dest is NULL" );
979 ERR( "src is NULL" );
984 ERR( "count is smaller than 0" );
988 return strncpy( dest, src, count );
992 _mkup_to_text(const char *mkup)
995 int str_len = 0, str_alloc = 0;
997 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
999 if (!mkup) return NULL;
1001 tag_start = tag_end = esc_start = esc_end = NULL;
1006 if (((p!=NULL)&&(*p == 0)) ||
1007 (tag_end) || (esc_end) ||
1008 (tag_start) || (esc_start))
1014 ttag = malloc(tag_end - tag_start);
1017 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
1018 ttag[tag_end - tag_start - 1] = 0;
1019 if (!strcmp(ttag, "br"))
1020 str = _str_append(str, "\n", &str_len, &str_alloc);
1021 else if (!strcmp(ttag, "\n"))
1022 str = _str_append(str, "\n", &str_len, &str_alloc);
1023 else if (!strcmp(ttag, "\\n"))
1024 str = _str_append(str, "\n", &str_len, &str_alloc);
1025 else if (!strcmp(ttag, "\t"))
1026 str = _str_append(str, "\t", &str_len, &str_alloc);
1027 else if (!strcmp(ttag, "\\t"))
1028 str = _str_append(str, "\t", &str_len, &str_alloc);
1029 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
1030 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1033 tag_start = tag_end = NULL;
1037 ts = malloc(esc_end - esc_start + 1);
1041 _strncpy(ts, esc_start, esc_end - esc_start);
1042 ts[esc_end - esc_start] = 0;
1043 esc = evas_textblock_escape_string_get(ts);
1045 str = _str_append(str, esc, &str_len, &str_alloc);
1048 esc_start = esc_end = NULL;
1050 else if ((p!=NULL)&&(*p == 0))
1052 ts = malloc(p - s + 1);
1055 _strncpy(ts, s, p - s);
1057 str = _str_append(str, ts, &str_len, &str_alloc);
1063 if ((p!=NULL)&&(*p == '<'))
1069 ts = malloc(p - s + 1);
1072 _strncpy(ts, s, p - s);
1074 str = _str_append(str, ts, &str_len, &str_alloc);
1080 else if ((p!=NULL)&&(*p == '>'))
1088 else if ((p!=NULL)&&(*p == '&'))
1094 ts = malloc(p - s + 1);
1097 _strncpy(ts, s, p - s);
1099 str = _str_append(str, ts, &str_len, &str_alloc);
1105 else if ((p!=NULL)&&(*p == ';'))
1119 _entry_length_get(Evas_Object *obj)
1122 const char *str = elm_entry_entry_get(obj);
1125 char *plain_str = _mkup_to_text(str);
1126 if (!plain_str) return 0;
1128 len = strlen(plain_str);
1135 _text_to_mkup(const char *text)
1138 int str_len = 0, str_alloc = 0;
1139 int ch, pos = 0, pos2 = 0;
1141 if (!text) return NULL;
1145 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1146 if ((ch <= 0) || (pos2 <= 0)) break;
1148 str = _str_append(str, "<br>", &str_len, &str_alloc);
1149 else if (ch == '\t')
1150 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1152 str = _str_append(str, "<", &str_len, &str_alloc);
1154 str = _str_append(str, ">", &str_len, &str_alloc);
1156 str = _str_append(str, "&", &str_len, &str_alloc);
1157 else if (ch == 0x2029)
1158 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1163 _strncpy(tstr, text + pos, pos2 - pos);
1164 tstr[pos2 - pos] = 0;
1165 str = _str_append(str, tstr, &str_len, &str_alloc);
1172 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1174 Widget_Data *wd = elm_widget_data_get(data);
1176 wd->changed = EINA_TRUE;
1178 if (wd->text) eina_stringshare_del(wd->text);
1180 _check_enable_returnkey(data);
1181 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1185 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1187 Widget_Data *wd = elm_widget_data_get(data);
1188 elm_object_scroll_freeze_push(data);
1190 if ((wd->api) && (wd->api->obj_hidemenu))
1192 wd->api->obj_hidemenu(data);
1197 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1199 Widget_Data *wd = elm_widget_data_get(data);
1200 elm_object_scroll_freeze_pop(data);
1202 if (wd->have_selection)
1207 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1210 Widget_Data *wd = elm_widget_data_get(data);
1218 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1220 Widget_Data *wd = elm_widget_data_get(data);
1224 EINA_LIST_FOREACH(entries, l, entry)
1226 if (entry != data) elm_entry_select_none(entry);
1228 wd->have_selection = EINA_TRUE;
1229 wd->selmode = EINA_TRUE;
1230 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1231 #ifdef HAVE_ELEMENTARY_X
1232 if (wd->sel_notify_handler)
1234 const char *txt = elm_entry_selection_get(data);
1237 top = elm_widget_top_get(data);
1238 if ((top) && (elm_win_xwindow_get(top)))
1239 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1245 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1247 Evas_Coord cx, cy, cw, ch;
1248 Widget_Data *wd = elm_widget_data_get(data);
1250 wd->have_selection = EINA_TRUE;
1251 wd->selmode = EINA_TRUE;
1252 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1253 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1254 elm_entry_selection_get(data));
1256 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1257 if (!wd->deferred_recalc_job)
1258 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1261 wd->deferred_cur = EINA_TRUE;
1265 wd->ch = ch + elm_finger_size_get();
1270 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1272 Widget_Data *wd = elm_widget_data_get(data);
1274 if (!wd->have_selection) return;
1275 wd->have_selection = EINA_FALSE;
1276 wd->selmode = EINA_FALSE;
1277 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1278 if (wd->sel_notify_handler)
1282 #ifdef HAVE_ELEMENTARY_X
1285 top = elm_widget_top_get(data);
1286 if ((top) && (elm_win_xwindow_get(top)))
1287 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1290 eina_stringshare_del(wd->cut_sel);
1295 #ifdef HAVE_ELEMENTARY_X
1298 top = elm_widget_top_get(data);
1299 if ((top) && (elm_win_xwindow_get(top)))
1300 elm_selection_clear(ELM_SEL_PRIMARY, data);
1307 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1309 Widget_Data *wd = elm_widget_data_get(data);
1311 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1312 if (wd->sel_notify_handler)
1314 #ifdef HAVE_ELEMENTARY_X
1317 top = elm_widget_top_get(data);
1318 if ((top) && (elm_win_xwindow_get(top)))
1320 wd->selection_asked = EINA_TRUE;
1321 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1328 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1330 Widget_Data *wd = elm_widget_data_get(data);
1332 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1333 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1334 elm_entry_selection_get(data));
1338 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1340 Widget_Data *wd = elm_widget_data_get(data);
1342 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1343 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1344 elm_entry_selection_get(data));
1345 edje_object_part_text_insert(wd->ent, "elm.text", "");
1346 wd->changed = EINA_TRUE;
1351 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1353 Widget_Data *wd = elm_widget_data_get(data);
1354 Evas_Coord cx, cy, cw, ch;
1356 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1357 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1358 &cx, &cy, &cw, &ch);
1359 if (!wd->deferred_recalc_job)
1360 elm_widget_show_region_set(data, cx, cy, cw, ch);
1363 wd->deferred_cur = EINA_TRUE;
1369 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1370 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1375 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1377 Widget_Data *wd = elm_widget_data_get(data);
1382 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1384 Widget_Data *wd = elm_widget_data_get(data);
1385 Elm_Entry_Anchor_Info ei;
1386 char *buf2, *p, *p2, *n;
1388 p = strrchr(emission, ',');
1391 const Eina_List *geoms;
1395 while (p2 >= emission)
1397 if (*p2 == ',') break;
1401 buf2 = alloca(5 + p - p2);
1402 strncpy(buf2, p2, p - p2);
1405 ei.button = atoi(buf2);
1406 ei.x = ei.y = ei.w = ei.h = 0;
1408 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1411 Evas_Textblock_Rectangle *r;
1413 Evas_Coord px, py, x, y;
1415 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1416 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1417 EINA_LIST_FOREACH(geoms, l, r)
1419 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1420 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1431 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1436 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1438 Widget_Data *wd = elm_widget_data_get(data);
1443 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1445 Widget_Data *wd = elm_widget_data_get(data);
1450 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1452 Widget_Data *wd = elm_widget_data_get(data);
1457 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1459 Widget_Data *wd = elm_widget_data_get(data);
1461 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1465 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1467 Widget_Data *wd = elm_widget_data_get(data);
1469 wd->double_clicked = EINA_FALSE;
1470 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1472 if ((wd->api) && (wd->api->obj_hidemenu))
1474 wd->api->obj_hidemenu(data);
1479 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1481 Widget_Data *wd = elm_widget_data_get(data);
1483 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1485 // if (wd->have_selection)
1486 // _long_press(data);
1490 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1492 Widget_Data *wd = elm_widget_data_get(data);
1494 wd->double_clicked = EINA_TRUE;
1495 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1498 #ifdef HAVE_ELEMENTARY_X
1500 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1502 Widget_Data *wd = elm_widget_data_get(data);
1503 Ecore_X_Event_Selection_Notify *ev = event;
1504 if (!wd) return ECORE_CALLBACK_PASS_ON;
1505 if (!wd->selection_asked && !wd->drag_selection_asked)
1506 return ECORE_CALLBACK_PASS_ON;
1508 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1509 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1511 Ecore_X_Selection_Data_Text *text_data;
1513 text_data = ev->data;
1514 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1516 if (text_data->text)
1518 char *txt = _text_to_mkup(text_data->text);
1522 elm_entry_entry_insert(data, txt);
1527 wd->selection_asked = EINA_FALSE;
1529 else if (ev->selection == ECORE_X_SELECTION_XDND)
1531 Ecore_X_Selection_Data_Text *text_data;
1533 text_data = ev->data;
1534 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1536 if (text_data->text)
1538 char *txt = _text_to_mkup(text_data->text);
1542 /* Massive FIXME: this should be at the drag point */
1543 elm_entry_entry_insert(data, txt);
1548 wd->drag_selection_asked = EINA_FALSE;
1550 ecore_x_dnd_send_finished();
1553 return ECORE_CALLBACK_PASS_ON;
1557 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1560 Widget_Data *wd = elm_widget_data_get(data);
1561 Ecore_X_Event_Selection_Clear *ev = event;
1562 if (!wd) return ECORE_CALLBACK_PASS_ON;
1563 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1564 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1565 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1567 elm_entry_select_none(data);
1572 Evas_Object *top = elm_widget_top_get(data);
1573 Ecore_X_Event_Selection_Clear *ev = event;
1576 return ECORE_CALLBACK_PASS_ON;
1578 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1580 return ECORE_CALLBACK_PASS_ON;
1583 if (cnpwidgetdata == data)
1585 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1589 return ECORE_CALLBACK_PASS_ON;
1593 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1598 wd = elm_widget_data_get(obj);
1600 if (!wd) return EINA_FALSE;
1601 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1603 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1604 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1605 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1606 EDJE_CURSOR_MAIN,drop->x,drop->y);
1607 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1608 elm_entry_entry_insert(obj, drop->data);
1609 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1610 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1616 static Evas_Object *
1617 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1619 Widget_Data *wd = elm_widget_data_get(data);
1622 Elm_Entry_Item_Provider *ip;
1625 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1627 o = ip->func(ip->data, data, item);
1630 o = edje_object_add(evas_object_evas_get(data));
1631 if (!strncmp(item, "emoticon/", 9))
1632 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1634 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1639 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1641 char *curlocater, *starttag, *endtag;
1642 int firstindex = 0, foundflag = -1;
1644 curlocater = strstr(oldstring, key);
1647 starttag = curlocater;
1648 endtag = curlocater + strlen(key);
1649 if (endtag == NULL || *endtag != '=')
1655 firstindex = abs(oldstring - curlocater);
1656 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1657 *value = (char*)oldstring + firstindex;
1659 while (oldstring != starttag)
1661 if (*starttag == '>')
1666 if (*starttag == '<')
1670 if (starttag == NULL) break;
1673 while (NULL != endtag)
1684 if (endtag == NULL) break;
1687 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1697 if (foundflag == 1) return 0;
1703 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1705 const char *srcstring = NULL;
1706 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1707 char *curlocater, *replocater;
1708 char *starttag, *endtag;
1709 int tagtxtlen = 0, insertflag = 0;
1711 srcstring = eina_strbuf_string_get(srcbuf);
1712 curlocater = strstr(srcstring, key);
1714 if (curlocater == NULL)
1722 starttag = strchr(srcstring, '<');
1723 endtag = strchr(srcstring, '>');
1724 tagtxtlen = endtag - starttag;
1725 if (tagtxtlen <= 0) tagtxtlen = 0;
1726 if (starttag < curlocater && curlocater < endtag) break;
1727 if (endtag != NULL && endtag+1 != NULL)
1728 srcstring = endtag+1;
1731 } while (strlen(srcstring) > 1);
1733 if (starttag && endtag && tagtxtlen > strlen(key))
1735 repbuf = eina_strbuf_new();
1736 diffbuf = eina_strbuf_new();
1737 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1738 srcstring = eina_strbuf_string_get(repbuf);
1739 curlocater = strstr(srcstring, key);
1741 if (curlocater != NULL)
1743 replocater = curlocater + strlen(key) + 1;
1745 while (*replocater == ' ' || *replocater == '=')
1750 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1753 if (replocater-curlocater > strlen(key)+1)
1756 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1765 eina_strbuf_reset(repbuf);
1773 if (repbuf == NULL) repbuf = eina_strbuf_new();
1774 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1778 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1779 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1785 eina_strbuf_prepend(diffbuf, "<");
1786 eina_strbuf_append(diffbuf, ">");
1787 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1791 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1792 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1796 if (repbuf) eina_strbuf_free(repbuf);
1797 if (diffbuf) eina_strbuf_free(diffbuf);
1803 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1805 Eina_Strbuf *sharebuf = NULL;
1807 sharebuf = eina_strbuf_new();
1808 eina_strbuf_append(sharebuf, *srcstring);
1809 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1810 eina_stringshare_del(*srcstring);
1811 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1812 eina_strbuf_free(sharebuf);
1818 _is_width_over(Evas_Object *obj)
1820 Evas_Coord x, y, w, h;
1821 Evas_Coord vx, vy, vw, vh;
1822 Widget_Data *wd = elm_widget_data_get(obj);
1826 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1828 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1830 if (x >= 0 && y >= 0)
1833 if (4 < wd->wrap_w && w > wd->wrap_w)
1840 _reverse_ellipsis_entry(Evas_Object *obj)
1842 Widget_Data *wd = elm_widget_data_get(obj);
1843 int cur_fontsize = 0;
1844 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1845 char **kvalue = NULL;
1846 const char *minfont, *deffont, *maxfont;
1847 const char *ellipsis_string = "...";
1848 int minfontsize, maxfontsize, minshowcount;
1850 minshowcount = strlen(ellipsis_string) + 1;
1851 minfont = edje_object_data_get(wd->ent, "min_font_size");
1852 if (minfont) minfontsize = atoi(minfont);
1853 else minfontsize = 1;
1854 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1855 if (maxfont) maxfontsize = atoi(maxfont);
1856 else maxfontsize = 1;
1857 deffont = edje_object_data_get(wd->ent, "default_font_size");
1858 if (deffont) cur_fontsize = atoi(deffont);
1859 else cur_fontsize = 1;
1860 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1861 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1863 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1865 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1868 txtbuf = eina_strbuf_new();
1869 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1871 if (cur_fontsize >= atoi(deffont))
1873 if (txtbuf) eina_strbuf_free(txtbuf);
1877 if (_is_width_over(obj) != 1)
1879 int rev_fontsize = cur_fontsize;
1883 if (rev_fontsize > atoi(deffont))
1886 if (fontbuf != NULL)
1888 eina_strbuf_free(fontbuf);
1891 fontbuf = eina_strbuf_new();
1892 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1893 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1894 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1896 eina_strbuf_free(fontbuf);
1898 } while (_is_width_over(obj) != 1);
1900 while (_is_width_over(obj))
1903 if (rev_fontsize < atoi(deffont))
1906 if (fontbuf != NULL)
1908 eina_strbuf_free(fontbuf);
1911 fontbuf = eina_strbuf_new();
1912 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1913 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1914 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1915 eina_strbuf_free(fontbuf);
1920 if (txtbuf) eina_strbuf_free(txtbuf);
1926 _ellipsis_entry_to_width(Evas_Object *obj)
1928 Widget_Data *wd = elm_widget_data_get(obj);
1929 int cur_fontsize = 0, len, jumpcount;
1930 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1931 char **kvalue = NULL;
1932 const char *minfont, *deffont, *maxfont;
1933 const char *ellipsis_string = "...";
1934 int minfontsize, maxfontsize, minshowcount;
1935 int i, tagend, cur_len;
1938 minshowcount = strlen(ellipsis_string) + 1;
1939 minfont = edje_object_data_get(wd->ent, "min_font_size");
1940 if (minfont) minfontsize = atoi(minfont);
1941 else minfontsize = 1;
1942 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1943 if (maxfont) maxfontsize = atoi(maxfont);
1944 else maxfontsize = 1;
1945 deffont = edje_object_data_get(wd->ent, "default_font_size");
1946 if (deffont) cur_fontsize = atoi(deffont);
1947 else cur_fontsize = 1;
1948 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1949 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1951 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1953 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1956 txtbuf = eina_strbuf_new();
1957 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1959 while (_is_width_over(obj))
1961 if (wd->ellipsis_threshold == 0)
1962 wd->ellipsis_threshold = _entry_length_get(obj);
1963 if (cur_fontsize > minfontsize)
1966 if (fontbuf != NULL)
1968 eina_strbuf_free(fontbuf);
1971 fontbuf = eina_strbuf_new();
1972 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1973 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1974 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1975 eina_strbuf_free(fontbuf);
1977 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1981 len = _entry_length_get(obj);
1982 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1983 cur_len = strlen(cur_str);
1985 for (i = 0; i < len; i++)
1987 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1988 cur_str[i+1] != '<')
1995 while (jumpcount < len-strlen(ellipsis_string))
1997 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
2001 eina_strbuf_free(txtbuf);
2004 txtbuf = eina_strbuf_new();
2005 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
2006 eina_strbuf_append(txtbuf, ellipsis_string);
2007 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
2008 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2009 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2011 if (_is_width_over(obj))
2019 if (txtbuf) eina_strbuf_free(txtbuf);
2024 static int _textinput_control_function(void *data,void *input_data)
2026 /* calculate character count */
2027 Evas_Object *entry = (Evas_Object *)data;
2028 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2031 size_t insert_text_len=0;
2032 char *text = edje_object_part_text_get(wd->ent, "elm.text");
2034 size_t remain_bytes;
2037 byte_len = strlen(text); /* no of bytes */
2038 remain_bytes = wd->max_no_of_bytes - byte_len;
2039 sprintf(buf,"%d",remain_bytes);
2040 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2043 insert_text = (char *)input_data;
2044 insert_text_len = strlen(insert_text);
2045 if (remain_bytes < insert_text_len)
2047 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2050 if (byte_len >= wd->max_no_of_bytes)
2052 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2061 * This adds an entry to @p parent object.
2063 * @param parent The parent object
2064 * @return The new object or NULL if it cannot be created
2069 elm_entry_add(Evas_Object *parent)
2071 Evas_Object *obj, *top;
2075 wd = ELM_NEW(Widget_Data);
2076 e = evas_object_evas_get(parent);
2077 wd->bgcolor = EINA_FALSE;
2078 wd->bg = evas_object_rectangle_add(e);
2079 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2080 obj = elm_widget_add(e);
2081 ELM_SET_WIDTYPE(widtype, "entry");
2082 elm_widget_type_set(obj, "entry");
2083 elm_widget_sub_object_add(parent, obj);
2084 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2085 elm_widget_data_set(obj, wd);
2086 elm_widget_del_hook_set(obj, _del_hook);
2087 elm_widget_theme_hook_set(obj, _theme_hook);
2088 elm_widget_disable_hook_set(obj, _disable_hook);
2089 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2090 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2091 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2092 elm_widget_can_focus_set(obj, 1);
2093 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2094 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2097 wd->linewrap = EINA_TRUE;
2098 wd->ellipsis = EINA_FALSE;
2099 wd->char_linewrap= EINA_FALSE;
2100 wd->editable = EINA_TRUE;
2101 wd->disabled = EINA_FALSE;
2102 wd->context_menu = EINA_TRUE;
2103 wd->autoperiod = EINA_TRUE;
2105 wd->ellipsis_threshold = 0;
2107 wd->ent = edje_object_add(e);
2108 edje_object_item_provider_set(wd->ent, _get_item, obj);
2109 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2110 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2111 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2113 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2115 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2118 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2119 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2120 _signal_entry_changed, obj);
2121 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2122 _signal_handler_move_start, obj);
2123 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2124 _signal_handler_move_end, obj);
2125 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2126 _signal_selection_start, obj);
2127 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2128 _signal_selection_end, obj);
2129 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2130 _signal_selection_changed, obj);
2131 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2132 _signal_selection_cleared, obj);
2133 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2134 _signal_entry_paste_request, obj);
2135 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2136 _signal_entry_copy_notify, obj);
2137 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2138 _signal_entry_cut_notify, obj);
2139 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2140 _signal_cursor_changed, obj);
2141 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2142 _signal_anchor_down, obj);
2143 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2144 _signal_anchor_up, obj);
2145 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2146 _signal_anchor_move, obj);
2147 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2148 _signal_anchor_in, obj);
2149 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2150 _signal_anchor_out, obj);
2151 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2152 _signal_key_enter, obj);
2153 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2154 _signal_mouse_down, obj);
2155 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2156 _signal_mouse_clicked, obj);
2157 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2158 _signal_mouse_double, obj);
2159 edje_object_part_text_set(wd->ent, "elm.text", "");
2160 elm_widget_resize_object_set(obj, wd->ent);
2163 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2165 #ifdef HAVE_ELEMENTARY_X
2166 top = elm_widget_top_get(obj);
2167 if ((top) && (elm_win_xwindow_get(top)))
2169 wd->sel_notify_handler =
2170 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2171 _event_selection_notify, obj);
2172 wd->sel_clear_handler =
2173 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2174 _event_selection_clear, obj);
2177 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2180 entries = eina_list_prepend(entries, obj);
2182 // module - find module for entry
2183 wd->api = _module(obj);
2184 // if found - hook in
2185 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2187 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2188 // TODO: and save some bytes, making descriptions per-class and not instance!
2189 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2193 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2195 ELM_CHECK_WIDTYPE(obj, widtype);
2196 Widget_Data *wd = elm_widget_data_get(obj);
2198 ext_mod->cancel = _cancel;
2199 ext_mod->copy = _copy;
2200 ext_mod->cut = _cut;
2201 ext_mod->paste = _paste;
2202 ext_mod->select = _select;
2203 ext_mod->selectall = _selectall;
2204 ext_mod->ent = wd->ent;
2205 ext_mod->items = wd->items;
2206 ext_mod->longpress_timer = wd->longpress_timer;
2207 ext_mod->editable = wd->editable;
2208 ext_mod->have_selection = wd->have_selection;
2209 ext_mod->password = wd->password;
2210 ext_mod->selmode = wd->selmode;
2211 ext_mod->cnpinit = _cnpinit;
2212 ext_mod->context_menu = wd->context_menu;
2216 * This sets the entry object not to line wrap. All input will
2217 * be on a single line, and the entry box will extend with user input.
2219 * @param obj The entry object
2220 * @param single_line If true, the text in the entry
2221 * will be on a single line.
2226 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2228 ELM_CHECK_WIDTYPE(obj, widtype);
2229 Widget_Data *wd = elm_widget_data_get(obj);
2231 Ecore_IMF_Context *ic;
2233 if (wd->single_line == single_line) return;
2234 wd->single_line = single_line;
2235 wd->linewrap = EINA_FALSE;
2236 wd->char_linewrap = EINA_FALSE;
2237 t = eina_stringshare_add(elm_entry_entry_get(obj));
2238 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2239 elm_entry_entry_set(obj, t);
2240 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2241 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2242 ic = elm_entry_imf_context_get(obj);
2245 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2248 eina_stringshare_del(t);
2253 * This returns true if the entry has been set to single line mode.
2254 * See also elm_entry_single_line_set().
2256 * @param obj The entry object
2257 * @return single_line If true, the text in the entry is set to display
2263 elm_entry_single_line_get(const Evas_Object *obj)
2265 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2266 Widget_Data *wd = elm_widget_data_get(obj);
2267 if (!wd) return EINA_FALSE;
2268 return wd->single_line;
2272 * This set's the maximum bytes that can be added in entry.
2274 * @param obj The entry object
2275 * @param max_no_of_bytes Maximum number of bytes entry can have.
2280 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2282 Widget_Data *wd = elm_widget_data_get(obj);
2284 wd->max_no_of_bytes = max_no_of_bytes;
2285 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2286 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2291 * This sets the entry object to password mode. All text entered
2292 * and/or displayed within the widget will be replaced with asterisks (*).
2294 * @param obj The entry object
2295 * @param password If true, password mode is enabled.
2300 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2302 ELM_CHECK_WIDTYPE(obj, widtype);
2303 Widget_Data *wd = elm_widget_data_get(obj);
2304 Ecore_IMF_Context *ic;
2307 if (wd->password == password) return;
2308 wd->password = password;
2309 wd->single_line = EINA_TRUE;
2310 wd->linewrap = EINA_FALSE;
2311 wd->char_linewrap = EINA_FALSE;
2312 if (_elm_config->password_show_last_character)
2313 wd->show_last_character = EINA_TRUE;
2314 t = eina_stringshare_add(elm_entry_entry_get(obj));
2315 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2316 elm_entry_entry_set(obj, t);
2321 elm_entry_autoperiod_set(obj, EINA_FALSE);
2323 if (wd->autocapital)
2324 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2327 ic = elm_entry_imf_context_get(obj);
2329 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2331 eina_stringshare_del(t);
2336 * This set's the entry in password mode with out masking the last character entered by user,
2337 * and later masking the character after 2 seconds.
2339 * @param obj The entry object
2340 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2346 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2348 Widget_Data *wd = elm_widget_data_get(obj);
2351 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2352 wd->show_last_character = show_last_character;
2353 wd->password = show_last_character;
2354 wd->single_line = EINA_TRUE;
2355 wd->linewrap = EINA_FALSE;
2356 wd->char_linewrap = EINA_FALSE;
2357 t = eina_stringshare_add(elm_entry_entry_get(obj));
2358 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2359 elm_entry_entry_set(obj, t);
2360 eina_stringshare_del(t);
2365 * This returns whether password mode is enabled.
2366 * See also elm_entry_password_set().
2368 * @param obj The entry object
2369 * @return If true, the entry is set to display all characters
2375 elm_entry_password_get(const Evas_Object *obj)
2377 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2378 Widget_Data *wd = elm_widget_data_get(obj);
2379 if (!wd) return EINA_FALSE;
2380 return wd->password;
2384 * This sets the text displayed within the entry to @p entry.
2386 * @param obj The entry object
2387 * @param entry The text to be displayed
2392 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2394 ELM_CHECK_WIDTYPE(obj, widtype);
2395 Widget_Data *wd = elm_widget_data_get(obj);
2397 if (!entry) entry = "";
2398 if(wd->max_no_of_bytes)
2400 int len = strlen(entry);
2401 if(len > wd->max_no_of_bytes)
2403 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2407 edje_object_part_text_set(wd->ent, "elm.text", entry);
2408 if (wd->text) eina_stringshare_del(wd->text);
2410 wd->changed = EINA_TRUE;
2415 * This returns the text currently shown in object @p entry.
2416 * See also elm_entry_entry_set().
2418 * @param obj The entry object
2419 * @return The currently displayed text or NULL on failure
2424 elm_entry_entry_get(const Evas_Object *obj)
2426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2427 Widget_Data *wd = elm_widget_data_get(obj);
2429 if (!wd) return NULL;
2431 if ((wd->text)&&(wd->password))
2432 return elm_entry_markup_to_utf8(wd->text);
2434 if (wd->text) return wd->text;
2435 text = edje_object_part_text_get(wd->ent, "elm.text");
2438 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2441 eina_stringshare_replace(&wd->text, text);
2442 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2447 * This returns all selected text within the entry.
2449 * @param obj The entry object
2450 * @return The selected text within the entry or NULL on failure
2455 elm_entry_selection_get(const Evas_Object *obj)
2457 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2458 Widget_Data *wd = elm_widget_data_get(obj);
2459 if (!wd) return NULL;
2460 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2464 * This inserts text in @p entry at the beginning of the entry
2467 * @param obj The entry object
2468 * @param entry The text to insert
2473 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2475 ELM_CHECK_WIDTYPE(obj, widtype);
2476 Widget_Data *wd = elm_widget_data_get(obj);
2478 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2480 if (cnpwidgetdata == obj)
2481 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2483 wd->changed = EINA_TRUE;
2488 * This enables word line wrapping in the entry object. It is the opposite
2489 * of elm_entry_single_line_set(). Additionally, setting this disables
2490 * character line wrapping.
2491 * See also elm_entry_line_char_wrap_set().
2493 * @param obj The entry object
2494 * @param wrap If true, the entry will be wrapped once it reaches the end
2495 * of the object. Wrapping will occur at the end of the word before the end of the
2501 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2503 ELM_CHECK_WIDTYPE(obj, widtype);
2504 Widget_Data *wd = elm_widget_data_get(obj);
2507 if (wd->linewrap == wrap) return;
2508 wd->linewrap = wrap;
2510 wd->char_linewrap = EINA_FALSE;
2511 t = eina_stringshare_add(elm_entry_entry_get(obj));
2512 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2513 elm_entry_entry_set(obj, t);
2514 eina_stringshare_del(t);
2519 * Set wrap width of the entry
2521 * @param obj The entry object
2522 * @param w The wrap width in pixels at a minimum where words need to wrap
2526 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2528 Widget_Data *wd = elm_widget_data_get(obj);
2529 if (wd->wrap_w == w) return;
2535 * get wrap width of the entry
2537 * @param obj The entry object
2538 * @return The wrap width in pixels at a minimum where words need to wrap
2542 elm_entry_wrap_width_get(const Evas_Object *obj)
2544 Widget_Data *wd = elm_widget_data_get(obj);
2549 * This enables character line wrapping in the entry object. It is the opposite
2550 * of elm_entry_single_line_set(). Additionally, setting this disables
2551 * word line wrapping.
2552 * See also elm_entry_line_wrap_set().
2554 * @param obj The entry object
2555 * @param wrap If true, the entry will be wrapped once it reaches the end
2556 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2561 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2563 ELM_CHECK_WIDTYPE(obj, widtype);
2564 Widget_Data *wd = elm_widget_data_get(obj);
2567 if (wd->char_linewrap == wrap) return;
2568 wd->char_linewrap = wrap;
2569 if(wd->char_linewrap)
2570 wd->linewrap = EINA_FALSE;
2571 t = eina_stringshare_add(elm_entry_entry_get(obj));
2572 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2573 elm_entry_entry_set(obj, t);
2574 eina_stringshare_del(t);
2579 * This sets the editable attribute of the entry.
2581 * @param obj The entry object
2582 * @param editable If true, the entry will be editable by the user.
2583 * If false, it will be set to the disabled state.
2588 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2590 ELM_CHECK_WIDTYPE(obj, widtype);
2591 Widget_Data *wd = elm_widget_data_get(obj);
2594 if (wd->editable == editable) return;
2595 wd->editable = editable;
2596 t = eina_stringshare_add(elm_entry_entry_get(obj));
2597 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2598 elm_entry_entry_set(obj, t);
2599 eina_stringshare_del(t);
2602 #ifdef HAVE_ELEMENTARY_X
2604 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2606 elm_drop_target_del(obj);
2611 * This gets the editable attribute of the entry.
2612 * See also elm_entry_editable_set().
2614 * @param obj The entry object
2615 * @return If true, the entry is editable by the user.
2616 * If false, it is not editable by the user
2621 elm_entry_editable_get(const Evas_Object *obj)
2623 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2624 Widget_Data *wd = elm_widget_data_get(obj);
2625 if (!wd) return EINA_FALSE;
2626 return wd->editable;
2630 * This drops any existing text selection within the entry.
2632 * @param obj The entry object
2637 elm_entry_select_none(Evas_Object *obj)
2639 ELM_CHECK_WIDTYPE(obj, widtype);
2640 Widget_Data *wd = elm_widget_data_get(obj);
2644 wd->selmode = EINA_FALSE;
2645 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2646 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2648 wd->have_selection = EINA_FALSE;
2649 edje_object_part_text_select_none(wd->ent, "elm.text");
2653 * This selects all text within the entry.
2655 * @param obj The entry object
2660 elm_entry_select_all(Evas_Object *obj)
2662 ELM_CHECK_WIDTYPE(obj, widtype);
2663 Widget_Data *wd = elm_widget_data_get(obj);
2667 wd->selmode = EINA_FALSE;
2668 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2669 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2671 wd->have_selection = EINA_TRUE;
2672 edje_object_part_text_select_all(wd->ent, "elm.text");
2676 * This moves the cursor one place to the right within the entry.
2678 * @param obj The entry object
2679 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2684 elm_entry_cursor_next(Evas_Object *obj)
2686 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2687 Widget_Data *wd = elm_widget_data_get(obj);
2688 if (!wd) return EINA_FALSE;
2689 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2693 * This moves the cursor one place to the left within the entry.
2695 * @param obj The entry object
2696 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2701 elm_entry_cursor_prev(Evas_Object *obj)
2703 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2704 Widget_Data *wd = elm_widget_data_get(obj);
2705 if (!wd) return EINA_FALSE;
2706 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2710 * This moves the cursor one line up within the entry.
2712 * @param obj The entry object
2713 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2718 elm_entry_cursor_up(Evas_Object *obj)
2720 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2721 Widget_Data *wd = elm_widget_data_get(obj);
2722 if (!wd) return EINA_FALSE;
2723 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2727 * This moves the cursor one line down within the entry.
2729 * @param obj The entry object
2730 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2735 elm_entry_cursor_down(Evas_Object *obj)
2737 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2738 Widget_Data *wd = elm_widget_data_get(obj);
2739 if (!wd) return EINA_FALSE;
2740 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2744 * This moves the cursor to the beginning of the entry.
2746 * @param obj The entry object
2751 elm_entry_cursor_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_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2760 * This moves the cursor to the end of the entry.
2762 * @param obj The entry object
2767 elm_entry_cursor_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_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2776 * This moves the cursor to the beginning of the current line.
2778 * @param obj The entry object
2783 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2785 ELM_CHECK_WIDTYPE(obj, widtype);
2786 Widget_Data *wd = elm_widget_data_get(obj);
2788 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2792 * This moves the cursor to the end of the current line.
2794 * @param obj The entry object
2799 elm_entry_cursor_line_end_set(Evas_Object *obj)
2801 ELM_CHECK_WIDTYPE(obj, widtype);
2802 Widget_Data *wd = elm_widget_data_get(obj);
2804 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2808 * This begins a selection within the entry as though
2809 * the user were holding down the mouse button to make a selection.
2811 * @param obj The entry object
2816 elm_entry_cursor_selection_begin(Evas_Object *obj)
2818 ELM_CHECK_WIDTYPE(obj, widtype);
2819 Widget_Data *wd = elm_widget_data_get(obj);
2821 edje_object_part_text_select_begin(wd->ent, "elm.text");
2825 * This ends a selection within the entry as though
2826 * the user had just released the mouse button while making a selection.
2828 * @param obj The entry object
2833 elm_entry_cursor_selection_end(Evas_Object *obj)
2835 ELM_CHECK_WIDTYPE(obj, widtype);
2836 Widget_Data *wd = elm_widget_data_get(obj);
2838 edje_object_part_text_select_extend(wd->ent, "elm.text");
2842 * TODO: fill this in
2844 * @param obj The entry object
2845 * @return TODO: fill this in
2850 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2852 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2853 Widget_Data *wd = elm_widget_data_get(obj);
2854 if (!wd) return EINA_FALSE;
2855 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2859 * This returns whether the cursor is visible.
2861 * @param obj The entry object
2862 * @return If true, the cursor is visible.
2867 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2869 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2870 Widget_Data *wd = elm_widget_data_get(obj);
2871 if (!wd) return EINA_FALSE;
2872 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2876 * TODO: fill this in
2878 * @param obj The entry object
2879 * @return TODO: fill this in
2884 elm_entry_cursor_content_get(const Evas_Object *obj)
2886 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2887 Widget_Data *wd = elm_widget_data_get(obj);
2888 if (!wd) return NULL;
2889 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2893 * This executes a "cut" action on the selected text in the entry.
2895 * @param obj The entry object
2900 elm_entry_selection_cut(Evas_Object *obj)
2902 ELM_CHECK_WIDTYPE(obj, widtype);
2903 Widget_Data *wd = elm_widget_data_get(obj);
2905 _cut(obj, NULL, NULL);
2909 * This executes a "copy" action on the selected text in the entry.
2911 * @param obj The entry object
2916 elm_entry_selection_copy(Evas_Object *obj)
2918 ELM_CHECK_WIDTYPE(obj, widtype);
2919 Widget_Data *wd = elm_widget_data_get(obj);
2921 _copy(obj, NULL, NULL);
2925 * This executes a "paste" action in the entry.
2927 * @param obj The entry object
2932 elm_entry_selection_paste(Evas_Object *obj)
2934 ELM_CHECK_WIDTYPE(obj, widtype);
2935 Widget_Data *wd = elm_widget_data_get(obj);
2937 _paste(obj, NULL, NULL);
2941 * This clears and frees the items in a entry's contextual (right click) menu.
2943 * @param obj The entry object
2948 elm_entry_context_menu_clear(Evas_Object *obj)
2950 ELM_CHECK_WIDTYPE(obj, widtype);
2951 Widget_Data *wd = elm_widget_data_get(obj);
2952 Elm_Entry_Context_Menu_Item *it;
2954 EINA_LIST_FREE(wd->items, it)
2956 eina_stringshare_del(it->label);
2957 eina_stringshare_del(it->icon_file);
2958 eina_stringshare_del(it->icon_group);
2964 * This adds an item to the entry's contextual menu.
2966 * @param obj The entry object
2967 * @param label The item's text label
2968 * @param icon_file The item's icon file
2969 * @param icon_type The item's icon type
2970 * @param func The callback to execute when the item is clicked
2971 * @param data The data to associate with the item for related functions
2976 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)
2978 ELM_CHECK_WIDTYPE(obj, widtype);
2979 Widget_Data *wd = elm_widget_data_get(obj);
2980 Elm_Entry_Context_Menu_Item *it;
2982 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2984 wd->items = eina_list_append(wd->items, it);
2986 it->label = eina_stringshare_add(label);
2987 it->icon_file = eina_stringshare_add(icon_file);
2988 it->icon_type = icon_type;
2990 it->data = (void *)data;
2994 * This disables the entry's contextual (right click) menu.
2996 * @param obj The entry object
2997 * @param disabled If true, the menu is disabled
3002 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3004 ELM_CHECK_WIDTYPE(obj, widtype);
3005 Widget_Data *wd = elm_widget_data_get(obj);
3007 if (wd->context_menu == !disabled) return;
3008 wd->context_menu = !disabled;
3012 * This returns whether the entry's contextual (right click) menu is disabled.
3014 * @param obj The entry object
3015 * @return If true, the menu is disabled
3020 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3022 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3023 Widget_Data *wd = elm_widget_data_get(obj);
3024 if (!wd) return EINA_FALSE;
3025 return !wd->context_menu;
3029 * This appends a custom item provider to the list for that entry
3031 * This appends the given callback. The list is walked from beginning to end
3032 * with each function called given the item href string in the text. If the
3033 * function returns an object handle other than NULL (it should create an
3034 * and object to do this), then this object is used to replace that item. If
3035 * not the next provider is called until one provides an item object, or the
3036 * default provider in entry does.
3038 * @param obj The entry object
3039 * @param func The function called to provide the item object
3040 * @param data The data passed to @p func
3045 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3047 ELM_CHECK_WIDTYPE(obj, widtype);
3048 Widget_Data *wd = elm_widget_data_get(obj);
3051 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3055 wd->item_providers = eina_list_append(wd->item_providers, ip);
3059 * This prepends a custom item provider to the list for that entry
3061 * This prepends the given callback. See elm_entry_item_provider_append() for
3064 * @param obj The entry object
3065 * @param func The function called to provide the item object
3066 * @param data The data passed to @p func
3071 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3073 ELM_CHECK_WIDTYPE(obj, widtype);
3074 Widget_Data *wd = elm_widget_data_get(obj);
3077 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3081 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3085 * This removes a custom item provider to the list for that entry
3087 * This removes the given callback. See elm_entry_item_provider_append() for
3090 * @param obj The entry object
3091 * @param func The function called to provide the item object
3092 * @param data The data passed to @p func
3097 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3099 ELM_CHECK_WIDTYPE(obj, widtype);
3100 Widget_Data *wd = elm_widget_data_get(obj);
3102 Elm_Entry_Item_Provider *ip;
3105 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3107 if ((ip->func == func) && (ip->data == data))
3109 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3117 * This converts a markup (HTML-like) string into UTF-8.
3119 * @param s The string (in markup) to be converted
3120 * @return The converted string (in UTF-8)
3125 elm_entry_markup_to_utf8(const char *s)
3127 char *ss = _mkup_to_text(s);
3128 if (!ss) ss = strdup("");
3133 * This converts a UTF-8 string into markup (HTML-like).
3135 * @param s The string (in UTF-8) to be converted
3136 * @return The converted string (in markup)
3141 elm_entry_utf8_to_markup(const char *s)
3143 char *ss = _text_to_mkup(s);
3144 if (!ss) ss = strdup("");
3149 * Get the input method context in the entry widget
3151 * @param obj The entry object
3152 * @return The input method context
3156 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3158 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3159 Widget_Data *wd = elm_widget_data_get(obj);
3160 if (!wd || !wd->ent) return NULL;
3162 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3166 * Set whether entry should enable the return key on soft keyboard automatically
3168 * @param obj The entry object
3169 * @param on If true, entry enables the return key on soft keyboard automatically.
3174 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3176 ELM_CHECK_WIDTYPE(obj, widtype);
3177 Widget_Data *wd = elm_widget_data_get(obj);
3180 wd->autoreturnkey = on;
3181 _check_enable_returnkey(obj);
3185 * Set whether entry should support auto capitalization
3187 * @param obj The entry object
3188 * @param on If true, entry suports auto capitalization.
3193 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3195 ELM_CHECK_WIDTYPE(obj, widtype);
3196 Widget_Data *wd = elm_widget_data_get(obj);
3200 wd->autocapital = EINA_FALSE;
3202 wd->autocapital = autocap;
3204 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3205 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3206 wd->autocapital = EINA_FALSE;
3208 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3212 * Set whether entry should support auto period
3214 * @param obj The entry object
3215 * @param on If true, entry suports auto period.
3220 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3222 ELM_CHECK_WIDTYPE(obj, widtype);
3223 Widget_Data *wd = elm_widget_data_get(obj);
3227 wd->autoperiod = EINA_FALSE;
3229 wd->autoperiod = autoperiod;
3231 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3232 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3233 wd->autoperiod = EINA_FALSE;
3235 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3239 * Set the font size on the entry object
3241 * @param obj The entry object
3242 * @param size font size
3247 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3249 ELM_CHECK_WIDTYPE(obj, widtype);
3250 Widget_Data *wd = elm_widget_data_get(obj);
3251 Eina_Strbuf *fontbuf = NULL;
3256 t = eina_stringshare_add(elm_entry_entry_get(obj));
3257 fontbuf = eina_strbuf_new();
3258 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3260 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3262 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3264 elm_entry_entry_set(obj, t);
3268 eina_strbuf_free(fontbuf);
3269 eina_stringshare_del(t);
3273 * Set the text align on the entry object
3275 * @param obj The entry object
3276 * @param align align mode
3281 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3283 ELM_CHECK_WIDTYPE(obj, widtype);
3284 Widget_Data *wd = elm_widget_data_get(obj);
3289 t = eina_stringshare_add(elm_entry_entry_get(obj));
3291 if (len <= 0) return;
3293 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3294 elm_entry_entry_set(obj, t);
3298 eina_stringshare_del(t);
3302 * Set the text color on the entry object
3304 * @param obj The entry object
3305 * @param r Red property background color of The entry object
3306 * @param g Green property background color of The entry object
3307 * @param b Blue property background color of The entry object
3308 * @param a Alpha property background alpha of The entry object
3313 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3315 ELM_CHECK_WIDTYPE(obj, widtype);
3316 Widget_Data *wd = elm_widget_data_get(obj);
3317 Eina_Strbuf *colorbuf = NULL;
3322 t = eina_stringshare_add(elm_entry_entry_get(obj));
3324 if (len <= 0) return;
3325 colorbuf = eina_strbuf_new();
3326 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3328 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3330 elm_entry_entry_set(obj, t);
3334 eina_strbuf_free(colorbuf);
3335 eina_stringshare_del(t);
3340 * Set background color of the entry
3342 * @param obj The entry object
3343 * @param r Red property background color of The entry object
3344 * @param g Green property background color of The entry object
3345 * @param b Blue property background color of The entry object
3346 * @param a Alpha property background alpha of The entry object
3350 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3352 ELM_CHECK_WIDTYPE(obj, widtype);
3353 Widget_Data *wd = elm_widget_data_get(obj);
3354 evas_object_color_set(wd->bg, r, g, b, a);
3356 if (wd->bgcolor == EINA_FALSE)
3359 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3364 * Set the ellipsis behavior of the entry
3366 * @param obj The entry object
3367 * @param ellipsis To ellipsis text or not
3371 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3373 ELM_CHECK_WIDTYPE(obj, widtype);
3374 Widget_Data *wd = elm_widget_data_get(obj);
3375 if (wd->ellipsis == ellipsis) return;
3376 wd->ellipsis = ellipsis;
3382 * This sets the attribute to show the input panel automatically.
3384 * @param obj The entry object
3385 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3390 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3392 ELM_CHECK_WIDTYPE(obj, widtype);
3393 Widget_Data *wd = elm_widget_data_get(obj);
3396 wd->input_panel_enable = enabled;
3397 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3401 * Set the input panel layout of the entry
3403 * @param obj The entry object
3404 * @param layout the layout to set
3409 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3411 ELM_CHECK_WIDTYPE(obj, widtype);
3412 Widget_Data *wd = elm_widget_data_get(obj);
3415 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3418 wd->input_panel_layout = layout;
3420 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3423 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/