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 Eina_Bool *_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";
201 static const Evas_Smart_Cb_Description _signals[] = {
205 {SIG_LONGPRESSED, ""},
207 {SIG_CLICKED_DOUBLE, ""},
210 {SIG_SELECTION_PASTE, ""},
211 {SIG_SELECTION_COPY, ""},
212 {SIG_SELECTION_CUT, ""},
213 {SIG_SELECTION_START, ""},
214 {SIG_SELECTION_CHANGED, ""},
215 {SIG_SELECTION_CLEARED, ""},
216 {SIG_CURSOR_CHANGED, ""},
217 {SIG_ANCHOR_CLICKED, ""},
221 static Eina_List *entries = NULL;
225 void (*obj_hook) (Evas_Object *obj);
226 void (*obj_unhook) (Evas_Object *obj);
227 void (*obj_longpress) (Evas_Object *obj);
228 void (*obj_hidemenu) (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_hidemenu = // called on hide menu
248 _elm_module_symbol_get(m, "obj_hidemenu");
249 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
250 _elm_module_symbol_get(m, "obj_mouseup");
251 ok: // ok - return api
256 _del_hook(Evas_Object *obj)
258 Widget_Data *wd = elm_widget_data_get(obj);
259 Elm_Entry_Context_Menu_Item *it;
260 Elm_Entry_Item_Provider *ip;
261 Evas_Object *parent_obj = obj;
262 Evas_Object *above = NULL;
264 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
265 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
267 /* added for locating parents as they were */
270 above = evas_object_data_get(parent_obj, "raise");
272 evas_object_stack_below(parent_obj, above);
273 parent_obj = elm_widget_parent_get(parent_obj);
276 entries = eina_list_remove(entries, obj);
277 #ifdef HAVE_ELEMENTARY_X
278 ecore_event_handler_del(wd->sel_notify_handler);
279 ecore_event_handler_del(wd->sel_clear_handler);
281 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
282 if (wd->text) eina_stringshare_del(wd->text);
283 if (wd->bg) evas_object_del(wd->bg);
284 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
285 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
286 EINA_LIST_FREE(wd->items, it)
288 eina_stringshare_del(it->label);
289 eina_stringshare_del(it->icon_file);
290 eina_stringshare_del(it->icon_group);
293 EINA_LIST_FREE(wd->item_providers, ip)
301 _theme_hook(Evas_Object *obj)
303 Widget_Data *wd = elm_widget_data_get(obj);
305 Ecore_IMF_Context *ic;
307 t = eina_stringshare_add(elm_entry_entry_get(obj));
308 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
309 elm_entry_entry_set(obj, t);
310 eina_stringshare_del(t);
311 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
312 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
313 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
314 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
316 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
319 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
326 _disable_hook(Evas_Object *obj)
328 Widget_Data *wd = elm_widget_data_get(obj);
330 if (elm_widget_disabled_get(obj))
332 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
333 wd->disabled = EINA_TRUE;
337 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
338 wd->disabled = EINA_FALSE;
343 _elm_win_recalc_job(void *data)
345 Widget_Data *wd = elm_widget_data_get(data);
346 Evas_Coord minw = -1, minh = -1, maxh = -1;
347 Evas_Coord resw, resh, minminw;
349 wd->deferred_recalc_job = NULL;
350 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
353 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
354 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
356 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
357 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
358 evas_object_size_hint_min_set(data, minminw, minh);
359 if (wd->single_line) maxh = minh;
360 evas_object_size_hint_max_set(data, -1, maxh);
361 if (wd->deferred_cur)
362 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
366 _sizing_eval(Evas_Object *obj)
368 Widget_Data *wd = elm_widget_data_get(obj);
369 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
370 Evas_Coord resw, resh;
372 if (wd->linewrap || wd->char_linewrap)
374 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
375 if ((resw == wd->lastw) && (!wd->changed)) return;
376 wd->changed = EINA_FALSE;
378 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
379 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
383 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
384 edje_object_size_min_calc(wd->ent, &minw, &minh);
385 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
386 evas_object_size_hint_min_set(obj, minw, minh);
387 if (wd->single_line) maxh = minh;
388 evas_object_size_hint_max_set(obj, maxw, maxh);
390 if (wd->ellipsis && wd->single_line)
392 if (_is_width_over(obj))
393 _ellipsis_entry_to_width(obj);
394 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
395 _reverse_ellipsis_entry(obj);
401 _check_enable_returnkey(Evas_Object *obj)
403 Widget_Data *wd = elm_widget_data_get(obj);
406 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
409 if (!wd->autoreturnkey) return;
411 if (_entry_length_get(obj) == 0)
413 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
417 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
422 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
424 Widget_Data *wd = elm_widget_data_get(obj);
425 Evas_Object *top = elm_widget_top_get(obj);
426 Evas_Object *parent_obj = obj;
427 Evas_Object *above = NULL;
430 if (!wd->editable) return;
431 if (elm_widget_focus_get(obj))
433 evas_object_focus_set(wd->ent, EINA_TRUE);
434 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
436 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
437 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
438 _check_enable_returnkey(obj);
442 above = evas_object_above_get(parent_obj);
444 evas_object_data_set(parent_obj, "raise", above);
445 evas_object_raise(parent_obj);
446 parent_obj = elm_widget_parent_get(parent_obj);
451 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
452 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
453 evas_object_focus_set(wd->ent, EINA_FALSE);
454 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
455 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
459 above = evas_object_data_get(parent_obj, "raise");
461 evas_object_stack_below(parent_obj, above);
462 parent_obj = elm_widget_parent_get(parent_obj);
468 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
470 Widget_Data *wd = elm_widget_data_get(obj);
472 edje_object_signal_emit(wd->ent, emission, source);
476 _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)
478 Widget_Data *wd = elm_widget_data_get(obj);
480 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
484 _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), void *data)
486 Widget_Data *wd = elm_widget_data_get(obj);
487 if (!wd) return NULL;
488 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
492 _hoversel_position(Evas_Object *obj)
494 Widget_Data *wd = elm_widget_data_get(obj);
495 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
497 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
498 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
500 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
511 evas_object_move(wd->hoversel, x + cx, y + cy);
512 evas_object_resize(wd->hoversel, cw, ch);
516 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
518 Widget_Data *wd = elm_widget_data_get(data);
520 if (wd->hoversel) _hoversel_position(data);
524 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
526 Widget_Data *wd = elm_widget_data_get(data);
528 if (wd->linewrap || wd->char_linewrap)
532 if (wd->hoversel) _hoversel_position(data);
533 // Evas_Coord ww, hh;
534 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
538 _hover_del(void *data)
540 Widget_Data *wd = elm_widget_data_get(data);
545 evas_object_del(wd->hoversel);
548 wd->hovdeljob = NULL;
552 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
554 Widget_Data *wd = elm_widget_data_get(data);
556 if (wd->hoversel) evas_object_hide(wd->hoversel);
560 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
562 elm_widget_scroll_freeze_pop(data);
563 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
564 wd->hovdeljob = ecore_job_add(_hover_del, data);
568 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
570 Widget_Data *wd = elm_widget_data_get(data);
572 wd->selmode = EINA_TRUE;
574 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
575 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
576 edje_object_part_text_select_all(wd->ent, "elm.text");
577 //elm_widget_scroll_hold_push(data);
578 elm_object_scroll_freeze_pop(data);
582 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
584 Widget_Data *wd = elm_widget_data_get(data);
586 wd->selmode = EINA_TRUE;
587 edje_object_part_text_select_none(wd->ent, "elm.text");
589 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
590 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
591 elm_object_scroll_freeze_pop(data);
592 //elm_widget_scroll_hold_push(data);
596 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
598 Widget_Data *wd = elm_widget_data_get(data);
600 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
601 if (wd->sel_notify_handler)
603 #ifdef HAVE_ELEMENTARY_X
604 wd->selection_asked = EINA_TRUE;
605 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
611 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
613 Widget_Data *wd = elm_widget_data_get(obj);
617 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
618 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
619 if (seltype == ELM_SEL_CLIPBOARD)
620 eina_stringshare_replace(&wd->cut_sel, sel);
624 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
626 Widget_Data *wd = elm_widget_data_get(data);
629 wd->selmode = EINA_FALSE;
630 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
631 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
632 elm_widget_scroll_hold_pop(data);
633 _store_selection(ELM_SEL_CLIPBOARD, data);
634 edje_object_part_text_insert(wd->ent, "elm.text", "");
635 edje_object_part_text_select_none(wd->ent, "elm.text");
639 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
641 Widget_Data *wd = elm_widget_data_get(data);
643 //wd->selmode = EINA_FALSE;
644 //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
645 //edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
646 elm_widget_scroll_hold_pop(data);
647 _store_selection(ELM_SEL_CLIPBOARD, data);
648 //edje_object_part_text_select_none(wd->ent, "elm.text");
652 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
654 Widget_Data *wd = elm_widget_data_get(data);
656 wd->selmode = EINA_FALSE;
657 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
658 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
659 elm_widget_scroll_hold_pop(data);
660 edje_object_part_text_select_none(wd->ent, "elm.text");
664 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
666 Widget_Data *wd = elm_widget_data_get(data);
670 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
671 cnpwidgetdata = data;
672 elm_cbhm_helper_init(obj);
673 elm_cbhm_send_raw_data("show");
679 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
681 Widget_Data *wd = elm_widget_data_get(data);
683 cnpwidgetdata = data;
689 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
691 Elm_Entry_Context_Menu_Item *it = data;
692 Evas_Object *obj2 = it->obj;
694 if (it->func) it->func(it->data, obj2, NULL);
698 _long_press(void *data)
700 Widget_Data *wd = elm_widget_data_get(data);
703 const Elm_Entry_Context_Menu_Item *it;
704 if (!wd) return ECORE_CALLBACK_CANCEL;
706 if (wd->longpress_timer)
708 ecore_timer_del(wd->longpress_timer);
709 wd->longpress_timer = NULL;
712 if ((wd->api) && (wd->api->obj_longpress))
714 wd->api->obj_longpress(data);
716 else if (wd->context_menu)
718 const char *context_menu_orientation;
720 if (wd->hoversel) evas_object_del(wd->hoversel);
721 else elm_widget_scroll_freeze_push(data);
722 wd->hoversel = elm_hoversel_add(data);
723 context_menu_orientation = edje_object_data_get
724 (wd->ent, "context_menu_orientation");
725 if ((context_menu_orientation) &&
726 (!strcmp(context_menu_orientation, "horizontal")))
727 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
728 elm_object_style_set(wd->hoversel, "entry");
729 elm_widget_sub_object_add(data, wd->hoversel);
730 elm_hoversel_label_set(wd->hoversel, "Text");
731 top = elm_widget_top_get(data);
732 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
733 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
737 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
739 if (1) // need way to detect if someone has a selection
742 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
747 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
748 _clipboard_menu, data);
755 if (wd->have_selection)
757 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
760 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
763 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
766 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
767 _clipboard_menu, data);
771 EINA_LIST_FOREACH(wd->items, l, it)
773 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
774 it->icon_type, _item_clicked, it);
778 _hoversel_position(data);
779 evas_object_show(wd->hoversel);
780 elm_hoversel_hover_begin(wd->hoversel);
782 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
783 edje_object_part_text_select_abort(wd->ent, "elm.text");
785 wd->longpress_timer = NULL;
786 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
787 return ECORE_CALLBACK_CANCEL;
791 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
793 Widget_Data *wd = elm_widget_data_get(data);
794 Evas_Event_Mouse_Down *ev = event_info;
796 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
797 if (ev->button != 1) return;
798 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
799 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
800 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
801 wd->downx = ev->canvas.x;
802 wd->downy = ev->canvas.y;
806 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
808 Widget_Data *wd = elm_widget_data_get(data);
809 Evas_Event_Mouse_Up *ev = event_info;
811 if (ev->button != 1) return;
813 if (!wd->double_clicked)
815 if ((wd->api) && (wd->api->obj_mouseup))
817 wd->api->obj_mouseup(data);
820 if (wd->longpress_timer)
822 ecore_timer_del(wd->longpress_timer);
823 wd->longpress_timer = NULL;
828 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
830 Widget_Data *wd = elm_widget_data_get(data);
831 Evas_Event_Mouse_Move *ev = event_info;
835 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
837 if (wd->longpress_timer)
839 ecore_timer_del(wd->longpress_timer);
840 wd->longpress_timer = NULL;
843 else if (wd->longpress_timer)
847 dx = wd->downx - ev->cur.canvas.x;
849 dy = wd->downy - ev->cur.canvas.y;
852 ((_elm_config->finger_size / 2) *
853 (_elm_config->finger_size / 2)))
855 ecore_timer_del(wd->longpress_timer);
856 wd->longpress_timer = NULL;
860 else if (wd->longpress_timer)
864 dx = wd->downx - ev->cur.canvas.x;
866 dy = wd->downy - ev->cur.canvas.y;
869 ((_elm_config->finger_size / 2) *
870 (_elm_config->finger_size / 2)))
872 ecore_timer_del(wd->longpress_timer);
873 wd->longpress_timer = NULL;
879 _getbase(Evas_Object *obj)
881 Widget_Data *wd = elm_widget_data_get(obj);
882 if (!wd) return "base";
887 if (wd->show_last_character) return "custom-password";
888 else return "base-password";
892 if (wd->single_line) return "base-single";
895 if (wd->linewrap) return "base";
896 else if (wd->char_linewrap) return "base-charwrap";
897 else return "base-nowrap";
905 if (wd->show_last_character) return "custom-password";
906 else return "base-password";
910 if (wd->single_line) return "base-single-noedit";
913 if (wd->linewrap) return "base-noedit";
914 else if (wd->char_linewrap) return "base-noedit-charwrap";
915 else return "base-nowrap-noedit";
923 _str_append(char *str, const char *txt, int *len, int *alloc)
925 int txt_len = strlen(txt);
927 if (txt_len <= 0) return str;
928 if ((*len + txt_len) >= *alloc)
933 alloc2 = *alloc + txt_len + 128;
934 str2 = realloc(str, alloc2);
935 if (!str2) return str;
939 strcpy(str + *len, txt);
944 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
945 * because some markups can be implemented otherwise according to style.
946 * probably doing it in textblock and making it translate according to it's
947 * style is correct. */
949 _strncpy(char* dest, const char* src, size_t count)
953 ERR( "dest is NULL" );
958 ERR( "src is NULL" );
963 ERR( "count is smaller than 0" );
967 return strncpy( dest, src, count );
971 _mkup_to_text(const char *mkup)
974 int str_len = 0, str_alloc = 0;
976 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
978 if (!mkup) return NULL;
980 tag_start = tag_end = esc_start = esc_end = NULL;
985 if (((p!=NULL)&&(*p == 0)) ||
986 (tag_end) || (esc_end) ||
987 (tag_start) || (esc_start))
993 ttag = malloc(tag_end - tag_start);
996 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
997 ttag[tag_end - tag_start - 1] = 0;
998 if (!strcmp(ttag, "br"))
999 str = _str_append(str, "\n", &str_len, &str_alloc);
1000 else if (!strcmp(ttag, "\n"))
1001 str = _str_append(str, "\n", &str_len, &str_alloc);
1002 else if (!strcmp(ttag, "\\n"))
1003 str = _str_append(str, "\n", &str_len, &str_alloc);
1004 else if (!strcmp(ttag, "\t"))
1005 str = _str_append(str, "\t", &str_len, &str_alloc);
1006 else if (!strcmp(ttag, "\\t"))
1007 str = _str_append(str, "\t", &str_len, &str_alloc);
1008 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
1009 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1012 tag_start = tag_end = NULL;
1016 ts = malloc(esc_end - esc_start + 1);
1020 _strncpy(ts, esc_start, esc_end - esc_start);
1021 ts[esc_end - esc_start] = 0;
1022 esc = evas_textblock_escape_string_get(ts);
1024 str = _str_append(str, esc, &str_len, &str_alloc);
1027 esc_start = esc_end = NULL;
1029 else if ((p!=NULL)&&(*p == 0))
1031 ts = malloc(p - s + 1);
1034 _strncpy(ts, s, p - s);
1036 str = _str_append(str, ts, &str_len, &str_alloc);
1042 if ((p!=NULL)&&(*p == '<'))
1048 ts = malloc(p - s + 1);
1051 _strncpy(ts, s, p - s);
1053 str = _str_append(str, ts, &str_len, &str_alloc);
1059 else if ((p!=NULL)&&(*p == '>'))
1067 else if ((p!=NULL)&&(*p == '&'))
1073 ts = malloc(p - s + 1);
1076 _strncpy(ts, s, p - s);
1078 str = _str_append(str, ts, &str_len, &str_alloc);
1084 else if ((p!=NULL)&&(*p == ';'))
1098 _entry_length_get(Evas_Object *obj)
1101 const char *str = elm_entry_entry_get(obj);
1104 char *plain_str = _mkup_to_text(str);
1105 if (!plain_str) return 0;
1107 len = strlen(plain_str);
1114 _text_to_mkup(const char *text)
1117 int str_len = 0, str_alloc = 0;
1118 int ch, pos = 0, pos2 = 0;
1120 if (!text) return NULL;
1124 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1125 if ((ch <= 0) || (pos2 <= 0)) break;
1127 str = _str_append(str, "<br>", &str_len, &str_alloc);
1128 else if (ch == '\t')
1129 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1131 str = _str_append(str, "<", &str_len, &str_alloc);
1133 str = _str_append(str, ">", &str_len, &str_alloc);
1135 str = _str_append(str, "&", &str_len, &str_alloc);
1136 else if (ch == 0x2029)
1137 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1142 _strncpy(tstr, text + pos, pos2 - pos);
1143 tstr[pos2 - pos] = 0;
1144 str = _str_append(str, tstr, &str_len, &str_alloc);
1151 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1153 Widget_Data *wd = elm_widget_data_get(data);
1155 wd->changed = EINA_TRUE;
1157 if (wd->text) eina_stringshare_del(wd->text);
1159 _check_enable_returnkey(data);
1160 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1164 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1166 Widget_Data *wd = elm_widget_data_get(data);
1167 elm_object_scroll_freeze_push(data);
1169 if ((wd->api) && (wd->api->obj_hidemenu))
1171 wd->api->obj_hidemenu(data);
1176 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1178 Widget_Data *wd = elm_widget_data_get(data);
1179 elm_object_scroll_freeze_pop(data);
1181 if (wd->have_selection)
1186 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1189 Widget_Data *wd = elm_widget_data_get(data);
1197 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1199 Widget_Data *wd = elm_widget_data_get(data);
1203 EINA_LIST_FOREACH(entries, l, entry)
1205 if (entry != data) elm_entry_select_none(entry);
1207 wd->have_selection = EINA_TRUE;
1208 wd->selmode = EINA_TRUE;
1209 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1210 #ifdef HAVE_ELEMENTARY_X
1211 if (wd->sel_notify_handler)
1213 const char *txt = elm_entry_selection_get(data);
1216 top = elm_widget_top_get(data);
1217 if ((top) && (elm_win_xwindow_get(top)))
1218 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1224 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1226 Evas_Coord cx, cy, cw, ch;
1227 Widget_Data *wd = elm_widget_data_get(data);
1229 wd->have_selection = EINA_TRUE;
1230 wd->selmode = EINA_TRUE;
1231 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1232 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1233 elm_entry_selection_get(data));
1235 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1236 if (!wd->deferred_recalc_job)
1237 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1240 wd->deferred_cur = EINA_TRUE;
1244 wd->ch = ch + elm_finger_size_get();
1249 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1251 Widget_Data *wd = elm_widget_data_get(data);
1253 if (!wd->have_selection) return;
1254 wd->have_selection = EINA_FALSE;
1255 wd->selmode = EINA_FALSE;
1256 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1257 if (wd->sel_notify_handler)
1261 #ifdef HAVE_ELEMENTARY_X
1264 top = elm_widget_top_get(data);
1265 if ((top) && (elm_win_xwindow_get(top)))
1266 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1269 eina_stringshare_del(wd->cut_sel);
1274 #ifdef HAVE_ELEMENTARY_X
1277 top = elm_widget_top_get(data);
1278 if ((top) && (elm_win_xwindow_get(top)))
1279 elm_selection_clear(ELM_SEL_PRIMARY, data);
1286 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1288 Widget_Data *wd = elm_widget_data_get(data);
1290 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1291 if (wd->sel_notify_handler)
1293 #ifdef HAVE_ELEMENTARY_X
1296 top = elm_widget_top_get(data);
1297 if ((top) && (elm_win_xwindow_get(top)))
1299 wd->selection_asked = EINA_TRUE;
1300 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1307 _signal_entry_copy_notify(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_COPY, NULL);
1312 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1313 elm_entry_selection_get(data));
1317 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1319 Widget_Data *wd = elm_widget_data_get(data);
1321 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1322 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1323 elm_entry_selection_get(data));
1324 edje_object_part_text_insert(wd->ent, "elm.text", "");
1325 wd->changed = EINA_TRUE;
1330 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1332 Widget_Data *wd = elm_widget_data_get(data);
1333 Evas_Coord cx, cy, cw, ch;
1335 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1336 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1337 &cx, &cy, &cw, &ch);
1338 if (!wd->deferred_recalc_job)
1339 elm_widget_show_region_set(data, cx, cy, cw, ch);
1342 wd->deferred_cur = EINA_TRUE;
1351 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1353 Widget_Data *wd = elm_widget_data_get(data);
1358 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1360 Widget_Data *wd = elm_widget_data_get(data);
1361 Elm_Entry_Anchor_Info ei;
1362 char *buf2, *p, *p2, *n;
1364 p = strrchr(emission, ',');
1367 const Eina_List *geoms;
1371 while (p2 >= emission)
1373 if (*p2 == ',') break;
1377 buf2 = alloca(5 + p - p2);
1378 strncpy(buf2, p2, p - p2);
1381 ei.button = atoi(buf2);
1382 ei.x = ei.y = ei.w = ei.h = 0;
1384 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1387 Evas_Textblock_Rectangle *r;
1389 Evas_Coord px, py, x, y;
1391 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1392 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1393 EINA_LIST_FOREACH(geoms, l, r)
1395 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1396 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1407 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1412 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1414 Widget_Data *wd = elm_widget_data_get(data);
1419 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1421 Widget_Data *wd = elm_widget_data_get(data);
1426 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1428 Widget_Data *wd = elm_widget_data_get(data);
1433 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1435 Widget_Data *wd = elm_widget_data_get(data);
1437 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1441 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1443 Widget_Data *wd = elm_widget_data_get(data);
1445 wd->double_clicked = EINA_FALSE;
1446 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1448 if ((wd->api) && (wd->api->obj_hidemenu))
1450 wd->api->obj_hidemenu(data);
1455 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1457 Widget_Data *wd = elm_widget_data_get(data);
1459 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1461 // if (wd->have_selection)
1462 // _long_press(data);
1466 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1468 Widget_Data *wd = elm_widget_data_get(data);
1470 wd->double_clicked = EINA_TRUE;
1471 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1474 #ifdef HAVE_ELEMENTARY_X
1476 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1478 Widget_Data *wd = elm_widget_data_get(data);
1479 Ecore_X_Event_Selection_Notify *ev = event;
1480 if (!wd) return ECORE_CALLBACK_PASS_ON;
1481 if (!wd->selection_asked && !wd->drag_selection_asked)
1482 return ECORE_CALLBACK_PASS_ON;
1484 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1485 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1487 Ecore_X_Selection_Data_Text *text_data;
1489 text_data = ev->data;
1490 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1492 if (text_data->text)
1494 char *txt = _text_to_mkup(text_data->text);
1498 elm_entry_entry_insert(data, txt);
1503 wd->selection_asked = EINA_FALSE;
1505 else if (ev->selection == ECORE_X_SELECTION_XDND)
1507 Ecore_X_Selection_Data_Text *text_data;
1509 text_data = ev->data;
1510 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1512 if (text_data->text)
1514 char *txt = _text_to_mkup(text_data->text);
1518 /* Massive FIXME: this should be at the drag point */
1519 elm_entry_entry_insert(data, txt);
1524 wd->drag_selection_asked = EINA_FALSE;
1526 ecore_x_dnd_send_finished();
1529 return ECORE_CALLBACK_PASS_ON;
1533 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1536 Widget_Data *wd = elm_widget_data_get(data);
1537 Ecore_X_Event_Selection_Clear *ev = event;
1538 if (!wd) return ECORE_CALLBACK_PASS_ON;
1539 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1540 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1541 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1543 elm_entry_select_none(data);
1548 Evas_Object *top = elm_widget_top_get(data);
1549 Ecore_X_Event_Selection_Clear *ev = event;
1552 return ECORE_CALLBACK_PASS_ON;
1554 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1556 return ECORE_CALLBACK_PASS_ON;
1559 if (cnpwidgetdata == data)
1561 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1565 return ECORE_CALLBACK_PASS_ON;
1569 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1574 wd = elm_widget_data_get(obj);
1576 if (!wd) return EINA_FALSE;
1577 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1579 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1580 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1581 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1582 EDJE_CURSOR_MAIN,drop->x,drop->y);
1583 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1584 elm_entry_entry_insert(obj, drop->data);
1585 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1586 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1592 static Evas_Object *
1593 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1595 Widget_Data *wd = elm_widget_data_get(data);
1598 Elm_Entry_Item_Provider *ip;
1601 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1603 o = ip->func(ip->data, data, item);
1606 if (!strncmp(item, "file://", 7))
1608 const char *fname = item + 7;
1610 o = evas_object_image_filled_add(evas_object_evas_get(data));
1611 evas_object_image_file_set(o, fname, NULL);
1612 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1614 evas_object_show(o);
1619 o = edje_object_add(evas_object_evas_get(data));
1620 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1624 o = edje_object_add(evas_object_evas_get(data));
1625 if (!strncmp(item, "emoticon/", 9))
1626 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1628 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1633 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1635 char *curlocater, *starttag, *endtag;
1636 int firstindex = 0, foundflag = -1;
1638 curlocater = strstr(oldstring, key);
1641 starttag = curlocater;
1642 endtag = curlocater + strlen(key);
1643 if (endtag == NULL || *endtag != '=')
1649 firstindex = abs(oldstring - curlocater);
1650 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1651 *value = (char*)(oldstring + firstindex);
1653 while (oldstring != starttag)
1655 if (*starttag == '>')
1660 if (*starttag == '<')
1664 if (starttag == NULL) break;
1667 while (NULL != endtag)
1678 if (endtag == NULL) break;
1681 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1691 if (foundflag == 1) return 0;
1697 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1699 const char *srcstring = NULL;
1700 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1701 char *curlocater, *replocater;
1702 char *starttag, *endtag;
1703 int tagtxtlen = 0, insertflag = 0;
1705 srcstring = eina_strbuf_string_get(srcbuf);
1706 curlocater = strstr(srcstring, key);
1708 if (!curlocater || !srcstring)
1716 starttag = strchr(srcstring, '<');
1717 endtag = strchr(srcstring, '>');
1718 tagtxtlen = endtag - starttag;
1719 if (tagtxtlen <= 0) tagtxtlen = 0;
1720 if (starttag < curlocater && curlocater < endtag) break;
1721 if (endtag != NULL && endtag+1 != NULL)
1722 srcstring = endtag+1;
1725 } while (strlen(srcstring) > 1);
1727 if (starttag && endtag && tagtxtlen > strlen(key))
1729 repbuf = eina_strbuf_new();
1730 diffbuf = eina_strbuf_new();
1731 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1732 srcstring = eina_strbuf_string_get(repbuf);
1733 curlocater = strstr(srcstring, key);
1735 if (curlocater != NULL)
1737 replocater = curlocater + strlen(key) + 1;
1739 while (*replocater && *replocater == ' ' || *replocater == '=')
1742 while (*replocater && *replocater != ' ' && *replocater != '>')
1745 if (replocater-curlocater > strlen(key)+1)
1748 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1757 eina_strbuf_reset(repbuf);
1765 if (repbuf == NULL) repbuf = eina_strbuf_new();
1766 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1770 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1771 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1777 eina_strbuf_prepend(diffbuf, "<");
1778 eina_strbuf_append(diffbuf, ">");
1779 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1783 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1784 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1788 if (repbuf) eina_strbuf_free(repbuf);
1789 if (diffbuf) eina_strbuf_free(diffbuf);
1795 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1797 Eina_Strbuf *sharebuf = NULL;
1799 sharebuf = eina_strbuf_new();
1800 eina_strbuf_append(sharebuf, *srcstring);
1801 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1802 eina_stringshare_del(*srcstring);
1803 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1804 eina_strbuf_free(sharebuf);
1810 _is_width_over(Evas_Object *obj)
1812 Evas_Coord x, y, w, h;
1813 Evas_Coord vx, vy, vw, vh;
1814 Widget_Data *wd = elm_widget_data_get(obj);
1818 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1820 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1822 if (x >= 0 && y >= 0)
1825 if (4 < wd->wrap_w && w > wd->wrap_w)
1832 _reverse_ellipsis_entry(Evas_Object *obj)
1834 Widget_Data *wd = elm_widget_data_get(obj);
1835 int cur_fontsize = 0;
1836 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1837 char *kvalue = NULL;
1838 const char *minfont, *deffont, *maxfont;
1839 const char *ellipsis_string = "...";
1840 int minfontsize, maxfontsize, minshowcount;
1842 minshowcount = strlen(ellipsis_string) + 1;
1843 minfont = edje_object_data_get(wd->ent, "min_font_size");
1844 if (minfont) minfontsize = atoi(minfont);
1845 else minfontsize = 1;
1846 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1847 if (maxfont) maxfontsize = atoi(maxfont);
1848 else maxfontsize = 1;
1849 deffont = edje_object_data_get(wd->ent, "default_font_size");
1850 if (deffont) cur_fontsize = atoi(deffont);
1851 else cur_fontsize = 1;
1852 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1853 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1855 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1857 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
1860 txtbuf = eina_strbuf_new();
1861 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1863 if (cur_fontsize >= atoi(deffont))
1865 if (txtbuf) eina_strbuf_free(txtbuf);
1869 if (_is_width_over(obj) != 1)
1871 int rev_fontsize = cur_fontsize;
1875 if (rev_fontsize > atoi(deffont))
1878 if (fontbuf != NULL)
1880 eina_strbuf_free(fontbuf);
1883 fontbuf = eina_strbuf_new();
1884 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1885 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1886 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1888 eina_strbuf_free(fontbuf);
1890 } while (_is_width_over(obj) != 1);
1892 while (_is_width_over(obj))
1895 if (rev_fontsize < atoi(deffont))
1898 if (fontbuf != NULL)
1900 eina_strbuf_free(fontbuf);
1903 fontbuf = eina_strbuf_new();
1904 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1905 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1906 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1907 eina_strbuf_free(fontbuf);
1912 if (txtbuf) eina_strbuf_free(txtbuf);
1918 _ellipsis_entry_to_width(Evas_Object *obj)
1920 Widget_Data *wd = elm_widget_data_get(obj);
1921 int cur_fontsize = 0, len, jumpcount;
1922 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1923 char *kvalue = NULL;
1924 const char *minfont, *deffont, *maxfont;
1925 const char *ellipsis_string = "...";
1926 int minfontsize, maxfontsize, minshowcount;
1927 int i, tagend, cur_len;
1930 minshowcount = strlen(ellipsis_string) + 1;
1931 minfont = edje_object_data_get(wd->ent, "min_font_size");
1932 if (minfont) minfontsize = atoi(minfont);
1933 else minfontsize = 1;
1934 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1935 if (maxfont) maxfontsize = atoi(maxfont);
1936 else maxfontsize = 1;
1937 deffont = edje_object_data_get(wd->ent, "default_font_size");
1938 if (deffont) cur_fontsize = atoi(deffont);
1939 else cur_fontsize = 1;
1940 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1941 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1943 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1945 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
1948 txtbuf = eina_strbuf_new();
1949 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1951 while (_is_width_over(obj))
1953 if (wd->ellipsis_threshold == 0)
1954 wd->ellipsis_threshold = _entry_length_get(obj);
1955 if (cur_fontsize > minfontsize)
1958 if (fontbuf != NULL)
1960 eina_strbuf_free(fontbuf);
1963 fontbuf = eina_strbuf_new();
1964 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1965 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1966 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1967 eina_strbuf_free(fontbuf);
1969 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1973 len = _entry_length_get(obj);
1974 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
1975 cur_len = strlen(cur_str);
1977 for (i = 0; i < len; i++)
1979 if(cur_str[i] == '>' && cur_str[i+1] != '\0' &&
1980 cur_str[i+1] != '<')
1987 while (jumpcount < len-strlen(ellipsis_string))
1989 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
1993 eina_strbuf_free(txtbuf);
1996 txtbuf = eina_strbuf_new();
1997 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1998 eina_strbuf_append(txtbuf, ellipsis_string);
1999 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
2000 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2001 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2003 if (_is_width_over(obj))
2011 if (txtbuf) eina_strbuf_free(txtbuf);
2016 static Eina_Bool *_textinput_control_function(void *data,void *input_data)
2018 /* calculate character count */
2019 Evas_Object *entry = (Evas_Object *)data;
2020 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2023 size_t insert_text_len=0;
2024 char *text = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2026 size_t remain_bytes;
2029 byte_len = strlen(text); /* no of bytes */
2030 remain_bytes = wd->max_no_of_bytes - byte_len;
2031 sprintf(buf,"%d",remain_bytes);
2032 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2035 insert_text = (char *)input_data;
2036 insert_text_len = strlen(insert_text);
2037 if (remain_bytes < insert_text_len)
2039 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2042 if (byte_len >= wd->max_no_of_bytes)
2044 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2053 * This adds an entry to @p parent object.
2055 * @param parent The parent object
2056 * @return The new object or NULL if it cannot be created
2061 elm_entry_add(Evas_Object *parent)
2063 Evas_Object *obj, *top;
2067 wd = ELM_NEW(Widget_Data);
2068 e = evas_object_evas_get(parent);
2069 wd->bgcolor = EINA_FALSE;
2070 wd->bg = evas_object_rectangle_add(e);
2071 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2072 obj = elm_widget_add(e);
2073 ELM_SET_WIDTYPE(widtype, "entry");
2074 elm_widget_type_set(obj, "entry");
2075 elm_widget_sub_object_add(parent, obj);
2076 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2077 elm_widget_data_set(obj, wd);
2078 elm_widget_del_hook_set(obj, _del_hook);
2079 elm_widget_theme_hook_set(obj, _theme_hook);
2080 elm_widget_disable_hook_set(obj, _disable_hook);
2081 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2082 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2083 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2084 elm_widget_can_focus_set(obj, EINA_TRUE);
2086 wd->linewrap = EINA_TRUE;
2087 wd->ellipsis = EINA_FALSE;
2088 wd->char_linewrap= EINA_FALSE;
2089 wd->editable = EINA_TRUE;
2090 wd->disabled = EINA_FALSE;
2091 wd->context_menu = EINA_TRUE;
2092 wd->autoperiod = EINA_TRUE;
2094 wd->ellipsis_threshold = 0;
2096 wd->ent = edje_object_add(e);
2097 edje_object_item_provider_set(wd->ent, _get_item, obj);
2098 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2099 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2100 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2102 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2104 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2107 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2108 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2109 _signal_entry_changed, obj);
2110 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2111 _signal_handler_move_start, obj);
2112 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2113 _signal_handler_move_end, obj);
2114 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2115 _signal_selection_start, obj);
2116 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2117 _signal_selection_end, obj);
2118 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2119 _signal_selection_changed, obj);
2120 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2121 _signal_selection_cleared, obj);
2122 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2123 _signal_entry_paste_request, obj);
2124 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2125 _signal_entry_copy_notify, obj);
2126 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2127 _signal_entry_cut_notify, obj);
2128 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2129 _signal_cursor_changed, obj);
2130 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2131 _signal_anchor_down, obj);
2132 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2133 _signal_anchor_up, obj);
2134 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2135 _signal_anchor_move, obj);
2136 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2137 _signal_anchor_in, obj);
2138 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2139 _signal_anchor_out, obj);
2140 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2141 _signal_key_enter, obj);
2142 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2143 _signal_mouse_down, obj);
2144 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2145 _signal_mouse_clicked, obj);
2146 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2147 _signal_mouse_double, obj);
2148 edje_object_part_text_set(wd->ent, "elm.text", "");
2149 elm_widget_resize_object_set(obj, wd->ent);
2152 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2154 #ifdef HAVE_ELEMENTARY_X
2155 top = elm_widget_top_get(obj);
2156 if ((top) && (elm_win_xwindow_get(top)))
2158 wd->sel_notify_handler =
2159 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2160 _event_selection_notify, obj);
2161 wd->sel_clear_handler =
2162 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2163 _event_selection_clear, obj);
2166 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2169 entries = eina_list_prepend(entries, obj);
2171 // module - find module for entry
2172 wd->api = _module(obj);
2173 // if found - hook in
2174 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2176 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2177 // TODO: and save some bytes, making descriptions per-class and not instance!
2178 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2182 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2184 ELM_CHECK_WIDTYPE(obj, widtype);
2185 Widget_Data *wd = elm_widget_data_get(obj);
2187 ext_mod->cancel = _cancel;
2188 ext_mod->copy = _copy;
2189 ext_mod->cut = _cut;
2190 ext_mod->paste = _paste;
2191 ext_mod->select = _select;
2192 ext_mod->selectall = _selectall;
2193 ext_mod->ent = wd->ent;
2194 ext_mod->items = wd->items;
2195 ext_mod->longpress_timer = wd->longpress_timer;
2196 ext_mod->editable = wd->editable;
2197 ext_mod->have_selection = wd->have_selection;
2198 ext_mod->password = wd->password;
2199 ext_mod->selmode = wd->selmode;
2200 ext_mod->cnpinit = _cnpinit;
2201 ext_mod->context_menu = wd->context_menu;
2205 * This sets the entry object not to line wrap. All input will
2206 * be on a single line, and the entry box will extend with user input.
2208 * @param obj The entry object
2209 * @param single_line If true, the text in the entry
2210 * will be on a single line.
2215 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2217 ELM_CHECK_WIDTYPE(obj, widtype);
2218 Widget_Data *wd = elm_widget_data_get(obj);
2220 Ecore_IMF_Context *ic;
2222 if (wd->single_line == single_line) return;
2223 wd->single_line = single_line;
2224 wd->linewrap = EINA_FALSE;
2225 wd->char_linewrap = EINA_FALSE;
2226 t = eina_stringshare_add(elm_entry_entry_get(obj));
2227 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2228 elm_entry_entry_set(obj, t);
2229 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2230 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2231 ic = elm_entry_imf_context_get(obj);
2234 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2237 eina_stringshare_del(t);
2242 * This returns true if the entry has been set to single line mode.
2243 * See also elm_entry_single_line_set().
2245 * @param obj The entry object
2246 * @return single_line If true, the text in the entry is set to display
2252 elm_entry_single_line_get(const Evas_Object *obj)
2254 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2255 Widget_Data *wd = elm_widget_data_get(obj);
2256 if (!wd) return EINA_FALSE;
2257 return wd->single_line;
2261 * This set's the maximum bytes that can be added in entry.
2263 * @param obj The entry object
2264 * @param max_no_of_bytes Maximum number of bytes entry can have.
2269 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2271 Widget_Data *wd = elm_widget_data_get(obj);
2273 wd->max_no_of_bytes = max_no_of_bytes;
2274 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2275 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2280 * This sets the entry object to password mode. All text entered
2281 * and/or displayed within the widget will be replaced with asterisks (*).
2283 * @param obj The entry object
2284 * @param password If true, password mode is enabled.
2289 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2291 ELM_CHECK_WIDTYPE(obj, widtype);
2292 Widget_Data *wd = elm_widget_data_get(obj);
2293 Ecore_IMF_Context *ic;
2296 if (wd->password == password) return;
2297 wd->password = password;
2298 wd->single_line = EINA_TRUE;
2299 wd->linewrap = EINA_FALSE;
2300 wd->char_linewrap = EINA_FALSE;
2301 if (_elm_config->password_show_last_character)
2302 wd->show_last_character = EINA_TRUE;
2303 t = eina_stringshare_add(elm_entry_entry_get(obj));
2304 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2305 elm_entry_entry_set(obj, t);
2310 elm_entry_autoperiod_set(obj, EINA_FALSE);
2312 if (wd->autocapital)
2313 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2316 ic = elm_entry_imf_context_get(obj);
2318 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2320 eina_stringshare_del(t);
2325 * This set's the entry in password mode with out masking the last character entered by user,
2326 * and later masking the character after 2 seconds.
2328 * @param obj The entry object
2329 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2335 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2337 Widget_Data *wd = elm_widget_data_get(obj);
2340 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2341 wd->show_last_character = show_last_character;
2342 wd->password = show_last_character;
2343 wd->single_line = EINA_TRUE;
2344 wd->linewrap = EINA_FALSE;
2345 wd->char_linewrap = EINA_FALSE;
2346 t = eina_stringshare_add(elm_entry_entry_get(obj));
2347 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2348 elm_entry_entry_set(obj, t);
2349 eina_stringshare_del(t);
2354 * This returns whether password mode is enabled.
2355 * See also elm_entry_password_set().
2357 * @param obj The entry object
2358 * @return If true, the entry is set to display all characters
2364 elm_entry_password_get(const Evas_Object *obj)
2366 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2367 Widget_Data *wd = elm_widget_data_get(obj);
2368 if (!wd) return EINA_FALSE;
2369 return wd->password;
2373 * This sets the text displayed within the entry to @p entry.
2375 * @param obj The entry object
2376 * @param entry The text to be displayed
2381 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2383 ELM_CHECK_WIDTYPE(obj, widtype);
2384 Widget_Data *wd = elm_widget_data_get(obj);
2386 if (!entry) entry = "";
2387 if(wd->max_no_of_bytes)
2389 int len = strlen(entry);
2390 if(len > wd->max_no_of_bytes)
2392 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2396 edje_object_part_text_set(wd->ent, "elm.text", entry);
2397 if (wd->text) eina_stringshare_del(wd->text);
2399 wd->changed = EINA_TRUE;
2404 * This returns the text currently shown in object @p entry.
2405 * See also elm_entry_entry_set().
2407 * @param obj The entry object
2408 * @return The currently displayed text or NULL on failure
2413 elm_entry_entry_get(const Evas_Object *obj)
2415 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2416 Widget_Data *wd = elm_widget_data_get(obj);
2418 if (!wd) return NULL;
2420 if ((wd->text)&&(wd->password))
2421 return elm_entry_markup_to_utf8(wd->text);
2423 if (wd->text) return wd->text;
2424 text = edje_object_part_text_get(wd->ent, "elm.text");
2427 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2430 eina_stringshare_replace(&wd->text, text);
2431 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2436 * This returns all selected text within the entry.
2438 * @param obj The entry object
2439 * @return The selected text within the entry or NULL on failure
2444 elm_entry_selection_get(const Evas_Object *obj)
2446 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2447 Widget_Data *wd = elm_widget_data_get(obj);
2448 if (!wd) return NULL;
2449 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2453 * This inserts text in @p entry at the beginning of the entry
2456 * @param obj The entry object
2457 * @param entry The text to insert
2462 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2464 ELM_CHECK_WIDTYPE(obj, widtype);
2465 Widget_Data *wd = elm_widget_data_get(obj);
2467 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2469 if (cnpwidgetdata == obj)
2470 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2472 wd->changed = EINA_TRUE;
2477 * This enables word line wrapping in the entry object. It is the opposite
2478 * of elm_entry_single_line_set(). Additionally, setting this disables
2479 * character line wrapping.
2480 * See also elm_entry_line_char_wrap_set().
2482 * @param obj The entry object
2483 * @param wrap If true, the entry will be wrapped once it reaches the end
2484 * of the object. Wrapping will occur at the end of the word before the end of the
2490 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2492 ELM_CHECK_WIDTYPE(obj, widtype);
2493 Widget_Data *wd = elm_widget_data_get(obj);
2496 if (wd->linewrap == wrap) return;
2497 wd->linewrap = wrap;
2499 wd->char_linewrap = EINA_FALSE;
2500 t = eina_stringshare_add(elm_entry_entry_get(obj));
2501 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2502 elm_entry_entry_set(obj, t);
2503 eina_stringshare_del(t);
2508 * Set wrap width of the entry
2510 * @param obj The entry object
2511 * @param w The wrap width in pixels at a minimum where words need to wrap
2515 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2517 Widget_Data *wd = elm_widget_data_get(obj);
2518 if (wd->wrap_w == w) return;
2524 * get wrap width of the entry
2526 * @param obj The entry object
2527 * @return The wrap width in pixels at a minimum where words need to wrap
2531 elm_entry_wrap_width_get(const Evas_Object *obj)
2533 Widget_Data *wd = elm_widget_data_get(obj);
2538 * This enables character line wrapping in the entry object. It is the opposite
2539 * of elm_entry_single_line_set(). Additionally, setting this disables
2540 * word line wrapping.
2541 * See also elm_entry_line_wrap_set().
2543 * @param obj The entry object
2544 * @param wrap If true, the entry will be wrapped once it reaches the end
2545 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2550 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2552 ELM_CHECK_WIDTYPE(obj, widtype);
2553 Widget_Data *wd = elm_widget_data_get(obj);
2556 if (wd->char_linewrap == wrap) return;
2557 wd->char_linewrap = wrap;
2558 if(wd->char_linewrap)
2559 wd->linewrap = EINA_FALSE;
2560 t = eina_stringshare_add(elm_entry_entry_get(obj));
2561 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2562 elm_entry_entry_set(obj, t);
2563 eina_stringshare_del(t);
2568 * This sets the editable attribute of the entry.
2570 * @param obj The entry object
2571 * @param editable If true, the entry will be editable by the user.
2572 * If false, it will be set to the disabled state.
2577 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2579 ELM_CHECK_WIDTYPE(obj, widtype);
2580 Widget_Data *wd = elm_widget_data_get(obj);
2583 if (wd->editable == editable) return;
2584 wd->editable = editable;
2585 t = eina_stringshare_add(elm_entry_entry_get(obj));
2586 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2587 elm_entry_entry_set(obj, t);
2588 eina_stringshare_del(t);
2591 #ifdef HAVE_ELEMENTARY_X
2593 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2595 elm_drop_target_del(obj);
2600 * This gets the editable attribute of the entry.
2601 * See also elm_entry_editable_set().
2603 * @param obj The entry object
2604 * @return If true, the entry is editable by the user.
2605 * If false, it is not editable by the user
2610 elm_entry_editable_get(const Evas_Object *obj)
2612 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2613 Widget_Data *wd = elm_widget_data_get(obj);
2614 if (!wd) return EINA_FALSE;
2615 return wd->editable;
2619 * This drops any existing text selection within the entry.
2621 * @param obj The entry object
2626 elm_entry_select_none(Evas_Object *obj)
2628 ELM_CHECK_WIDTYPE(obj, widtype);
2629 Widget_Data *wd = elm_widget_data_get(obj);
2633 wd->selmode = EINA_FALSE;
2634 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2635 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2637 wd->have_selection = EINA_FALSE;
2638 edje_object_part_text_select_none(wd->ent, "elm.text");
2642 * This selects all text within the entry.
2644 * @param obj The entry object
2649 elm_entry_select_all(Evas_Object *obj)
2651 ELM_CHECK_WIDTYPE(obj, widtype);
2652 Widget_Data *wd = elm_widget_data_get(obj);
2656 wd->selmode = EINA_FALSE;
2657 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2658 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2660 wd->have_selection = EINA_TRUE;
2661 edje_object_part_text_select_all(wd->ent, "elm.text");
2665 * This moves the cursor one place to the right within the entry.
2667 * @param obj The entry object
2668 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2673 elm_entry_cursor_next(Evas_Object *obj)
2675 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2676 Widget_Data *wd = elm_widget_data_get(obj);
2677 if (!wd) return EINA_FALSE;
2678 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2682 * This moves the cursor one place to the left within the entry.
2684 * @param obj The entry object
2685 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2690 elm_entry_cursor_prev(Evas_Object *obj)
2692 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2693 Widget_Data *wd = elm_widget_data_get(obj);
2694 if (!wd) return EINA_FALSE;
2695 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2699 * This moves the cursor one line up within the entry.
2701 * @param obj The entry object
2702 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2707 elm_entry_cursor_up(Evas_Object *obj)
2709 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2710 Widget_Data *wd = elm_widget_data_get(obj);
2711 if (!wd) return EINA_FALSE;
2712 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2716 * This moves the cursor one line down within the entry.
2718 * @param obj The entry object
2719 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2724 elm_entry_cursor_down(Evas_Object *obj)
2726 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2727 Widget_Data *wd = elm_widget_data_get(obj);
2728 if (!wd) return EINA_FALSE;
2729 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2733 * This moves the cursor to the beginning of the entry.
2735 * @param obj The entry object
2740 elm_entry_cursor_begin_set(Evas_Object *obj)
2742 ELM_CHECK_WIDTYPE(obj, widtype);
2743 Widget_Data *wd = elm_widget_data_get(obj);
2745 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2749 * This moves the cursor to the end of the entry.
2751 * @param obj The entry object
2756 elm_entry_cursor_end_set(Evas_Object *obj)
2758 ELM_CHECK_WIDTYPE(obj, widtype);
2759 Widget_Data *wd = elm_widget_data_get(obj);
2761 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2765 * This moves the cursor to the beginning of the current line.
2767 * @param obj The entry object
2772 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2774 ELM_CHECK_WIDTYPE(obj, widtype);
2775 Widget_Data *wd = elm_widget_data_get(obj);
2777 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2781 * This moves the cursor to the end of the current line.
2783 * @param obj The entry object
2788 elm_entry_cursor_line_end_set(Evas_Object *obj)
2790 ELM_CHECK_WIDTYPE(obj, widtype);
2791 Widget_Data *wd = elm_widget_data_get(obj);
2793 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2797 * This begins a selection within the entry as though
2798 * the user were holding down the mouse button to make a selection.
2800 * @param obj The entry object
2805 elm_entry_cursor_selection_begin(Evas_Object *obj)
2807 ELM_CHECK_WIDTYPE(obj, widtype);
2808 Widget_Data *wd = elm_widget_data_get(obj);
2810 edje_object_part_text_select_begin(wd->ent, "elm.text");
2814 * This ends a selection within the entry as though
2815 * the user had just released the mouse button while making a selection.
2817 * @param obj The entry object
2822 elm_entry_cursor_selection_end(Evas_Object *obj)
2824 ELM_CHECK_WIDTYPE(obj, widtype);
2825 Widget_Data *wd = elm_widget_data_get(obj);
2827 edje_object_part_text_select_extend(wd->ent, "elm.text");
2831 * TODO: fill this in
2833 * @param obj The entry object
2834 * @return TODO: fill this in
2839 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2841 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2842 Widget_Data *wd = elm_widget_data_get(obj);
2843 if (!wd) return EINA_FALSE;
2844 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2848 * This returns whether the cursor is visible.
2850 * @param obj The entry object
2851 * @return If true, the cursor is visible.
2856 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2858 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2859 Widget_Data *wd = elm_widget_data_get(obj);
2860 if (!wd) return EINA_FALSE;
2861 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2865 * TODO: fill this in
2867 * @param obj The entry object
2868 * @return TODO: fill this in
2873 elm_entry_cursor_content_get(const Evas_Object *obj)
2875 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2876 Widget_Data *wd = elm_widget_data_get(obj);
2877 if (!wd) return NULL;
2878 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2882 * This executes a "cut" action on the selected text in the entry.
2884 * @param obj The entry object
2889 elm_entry_selection_cut(Evas_Object *obj)
2891 ELM_CHECK_WIDTYPE(obj, widtype);
2892 Widget_Data *wd = elm_widget_data_get(obj);
2894 _cut(obj, NULL, NULL);
2898 * This executes a "copy" action on the selected text in the entry.
2900 * @param obj The entry object
2905 elm_entry_selection_copy(Evas_Object *obj)
2907 ELM_CHECK_WIDTYPE(obj, widtype);
2908 Widget_Data *wd = elm_widget_data_get(obj);
2910 _copy(obj, NULL, NULL);
2914 * This executes a "paste" action in the entry.
2916 * @param obj The entry object
2921 elm_entry_selection_paste(Evas_Object *obj)
2923 ELM_CHECK_WIDTYPE(obj, widtype);
2924 Widget_Data *wd = elm_widget_data_get(obj);
2926 _paste(obj, NULL, NULL);
2930 * This clears and frees the items in a entry's contextual (right click) menu.
2932 * @param obj The entry object
2937 elm_entry_context_menu_clear(Evas_Object *obj)
2939 ELM_CHECK_WIDTYPE(obj, widtype);
2940 Widget_Data *wd = elm_widget_data_get(obj);
2941 Elm_Entry_Context_Menu_Item *it;
2943 EINA_LIST_FREE(wd->items, it)
2945 eina_stringshare_del(it->label);
2946 eina_stringshare_del(it->icon_file);
2947 eina_stringshare_del(it->icon_group);
2953 * This adds an item to the entry's contextual menu.
2955 * @param obj The entry object
2956 * @param label The item's text label
2957 * @param icon_file The item's icon file
2958 * @param icon_type The item's icon type
2959 * @param func The callback to execute when the item is clicked
2960 * @param data The data to associate with the item for related functions
2965 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)
2967 ELM_CHECK_WIDTYPE(obj, widtype);
2968 Widget_Data *wd = elm_widget_data_get(obj);
2969 Elm_Entry_Context_Menu_Item *it;
2971 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2973 wd->items = eina_list_append(wd->items, it);
2975 it->label = eina_stringshare_add(label);
2976 it->icon_file = eina_stringshare_add(icon_file);
2977 it->icon_type = icon_type;
2979 it->data = (void *)data;
2983 * This disables the entry's contextual (right click) menu.
2985 * @param obj The entry object
2986 * @param disabled If true, the menu is disabled
2991 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2993 ELM_CHECK_WIDTYPE(obj, widtype);
2994 Widget_Data *wd = elm_widget_data_get(obj);
2996 if (wd->context_menu == !disabled) return;
2997 wd->context_menu = !disabled;
3001 * This returns whether the entry's contextual (right click) menu is disabled.
3003 * @param obj The entry object
3004 * @return If true, the menu is disabled
3009 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3011 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3012 Widget_Data *wd = elm_widget_data_get(obj);
3013 if (!wd) return EINA_FALSE;
3014 return !wd->context_menu;
3018 * This appends a custom item provider to the list for that entry
3020 * This appends the given callback. The list is walked from beginning to end
3021 * with each function called given the item href string in the text. If the
3022 * function returns an object handle other than NULL (it should create an
3023 * and object to do this), then this object is used to replace that item. If
3024 * not the next provider is called until one provides an item object, or the
3025 * default provider in entry does.
3027 * @param obj The entry object
3028 * @param func The function called to provide the item object
3029 * @param data The data passed to @p func
3034 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3036 ELM_CHECK_WIDTYPE(obj, widtype);
3037 Widget_Data *wd = elm_widget_data_get(obj);
3040 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3044 wd->item_providers = eina_list_append(wd->item_providers, ip);
3048 * This prepends a custom item provider to the list for that entry
3050 * This prepends the given callback. See elm_entry_item_provider_append() for
3053 * @param obj The entry object
3054 * @param func The function called to provide the item object
3055 * @param data The data passed to @p func
3060 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3062 ELM_CHECK_WIDTYPE(obj, widtype);
3063 Widget_Data *wd = elm_widget_data_get(obj);
3066 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3070 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3074 * This removes a custom item provider to the list for that entry
3076 * This removes the given callback. See elm_entry_item_provider_append() for
3079 * @param obj The entry object
3080 * @param func The function called to provide the item object
3081 * @param data The data passed to @p func
3086 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3088 ELM_CHECK_WIDTYPE(obj, widtype);
3089 Widget_Data *wd = elm_widget_data_get(obj);
3091 Elm_Entry_Item_Provider *ip;
3094 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3096 if ((ip->func == func) && (ip->data == data))
3098 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3106 * This converts a markup (HTML-like) string into UTF-8.
3108 * @param s The string (in markup) to be converted
3109 * @return The converted string (in UTF-8)
3114 elm_entry_markup_to_utf8(const char *s)
3116 char *ss = _mkup_to_text(s);
3117 if (!ss) ss = strdup("");
3122 * This converts a UTF-8 string into markup (HTML-like).
3124 * @param s The string (in UTF-8) to be converted
3125 * @return The converted string (in markup)
3130 elm_entry_utf8_to_markup(const char *s)
3132 char *ss = _text_to_mkup(s);
3133 if (!ss) ss = strdup("");
3138 * Get the input method context in the entry widget
3140 * @param obj The entry object
3141 * @return The input method context
3145 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3147 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3148 Widget_Data *wd = elm_widget_data_get(obj);
3149 if (!wd || !wd->ent) return NULL;
3151 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3155 * Set whether entry should enable the return key on soft keyboard automatically
3157 * @param obj The entry object
3158 * @param on If true, entry enables the return key on soft keyboard automatically.
3163 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3165 ELM_CHECK_WIDTYPE(obj, widtype);
3166 Widget_Data *wd = elm_widget_data_get(obj);
3169 wd->autoreturnkey = on;
3170 _check_enable_returnkey(obj);
3174 * Set whether entry should support auto capitalization
3176 * @param obj The entry object
3177 * @param on If true, entry suports auto capitalization.
3182 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3184 ELM_CHECK_WIDTYPE(obj, widtype);
3185 Widget_Data *wd = elm_widget_data_get(obj);
3189 wd->autocapital = EINA_FALSE;
3191 wd->autocapital = autocap;
3193 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3194 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3195 wd->autocapital = EINA_FALSE;
3197 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3201 * Set whether entry should support auto period
3203 * @param obj The entry object
3204 * @param on If true, entry suports auto period.
3209 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3211 ELM_CHECK_WIDTYPE(obj, widtype);
3212 Widget_Data *wd = elm_widget_data_get(obj);
3216 wd->autoperiod = EINA_FALSE;
3218 wd->autoperiod = autoperiod;
3220 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3221 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3222 wd->autoperiod = EINA_FALSE;
3224 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3228 * Set the font size on the entry object
3230 * @param obj The entry object
3231 * @param size font size
3236 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3238 ELM_CHECK_WIDTYPE(obj, widtype);
3239 Widget_Data *wd = elm_widget_data_get(obj);
3240 Eina_Strbuf *fontbuf = NULL;
3245 t = eina_stringshare_add(elm_entry_entry_get(obj));
3246 fontbuf = eina_strbuf_new();
3247 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3249 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3251 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3253 elm_entry_entry_set(obj, t);
3257 eina_strbuf_free(fontbuf);
3258 eina_stringshare_del(t);
3262 * Set the text align on the entry object
3264 * @param obj The entry object
3265 * @param align align mode
3270 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3272 ELM_CHECK_WIDTYPE(obj, widtype);
3273 Widget_Data *wd = elm_widget_data_get(obj);
3278 t = eina_stringshare_add(elm_entry_entry_get(obj));
3280 if (len <= 0) return;
3282 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3283 elm_entry_entry_set(obj, t);
3287 eina_stringshare_del(t);
3291 * Set the text color on the entry object
3293 * @param obj The entry object
3294 * @param r Red property background color of The entry object
3295 * @param g Green property background color of The entry object
3296 * @param b Blue property background color of The entry object
3297 * @param a Alpha property background alpha of The entry object
3302 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3304 ELM_CHECK_WIDTYPE(obj, widtype);
3305 Widget_Data *wd = elm_widget_data_get(obj);
3306 Eina_Strbuf *colorbuf = NULL;
3311 t = eina_stringshare_add(elm_entry_entry_get(obj));
3313 if (len <= 0) return;
3314 colorbuf = eina_strbuf_new();
3315 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3317 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3319 elm_entry_entry_set(obj, t);
3323 eina_strbuf_free(colorbuf);
3324 eina_stringshare_del(t);
3328 * Set background color of the entry
3330 * @param obj The entry object
3331 * @param r Red property background color of The entry object
3332 * @param g Green property background color of The entry object
3333 * @param b Blue property background color of The entry object
3334 * @param a Alpha property background alpha of The entry object
3338 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3340 ELM_CHECK_WIDTYPE(obj, widtype);
3341 Widget_Data *wd = elm_widget_data_get(obj);
3342 evas_object_color_set(wd->bg, r, g, b, a);
3344 if (wd->bgcolor == EINA_FALSE)
3347 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3352 * Set the ellipsis behavior of the entry
3354 * @param obj The entry object
3355 * @param ellipsis To ellipsis text or not
3359 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3361 ELM_CHECK_WIDTYPE(obj, widtype);
3362 Widget_Data *wd = elm_widget_data_get(obj);
3363 if (wd->ellipsis == ellipsis) return;
3364 wd->ellipsis = ellipsis;
3370 * This sets the attribute to show the input panel automatically.
3372 * @param obj The entry object
3373 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3378 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3380 ELM_CHECK_WIDTYPE(obj, widtype);
3381 Widget_Data *wd = elm_widget_data_get(obj);
3384 wd->input_panel_enable = enabled;
3385 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3389 * Set the input panel layout of the entry
3391 * @param obj The entry object
3392 * @param layout the layout to set
3397 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3399 ELM_CHECK_WIDTYPE(obj, widtype);
3400 Widget_Data *wd = elm_widget_data_get(obj);
3403 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3406 wd->input_panel_layout = layout;
3408 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3411 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/