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 received focus and the cursor
76 * - "press" - The entry has been clicked
77 * - "longpressed" - The entry has been clicked for a couple seconds
78 * - "clicked" - The entry has been clicked
79 * - "clicked,double" - The entry has been double clicked
80 * - "focused" - The entry has received focus
81 * - "unfocused" - The entry has lost focus
82 * - "selection,paste" - A paste action has occurred
83 * - "selection,copy" - A copy action has occurred
84 * - "selection,cut" - A cut action has occurred
85 * - "selection,start" - A selection has begun
86 * - "selection,changed" - The selection has changed
87 * - "selection,cleared" - The selection has been cleared
88 * - "cursor,changed" - The cursor has changed
89 * - "anchor,clicked" - The anchor has been clicked
92 typedef struct _Mod_Api Mod_Api;
94 typedef struct _Widget_Data Widget_Data;
95 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
100 Evas_Object *popup;/*copy paste UI - elm_popup*/
101 Evas_Object *ctxpopup;/*copy paste UI - elm_ctxpopup*/
103 Evas_Object *hoversel;
104 Ecore_Job *deferred_recalc_job;
105 Ecore_Event_Handler *sel_notify_handler;
106 Ecore_Event_Handler *sel_clear_handler;
107 Ecore_Timer *longpress_timer;
108 /* Only for clipboard */
112 int ellipsis_threshold;
114 Evas_Coord downx, downy;
115 Evas_Coord cx, cy, cw, ch;
117 Eina_List *item_providers;
118 Ecore_Job *hovdeljob;
119 Mod_Api *api; // module api if supplied
121 Eina_Bool changed : 1;
122 Eina_Bool linewrap : 1;
123 Eina_Bool char_linewrap : 1;
124 Eina_Bool single_line : 1;
125 Eina_Bool password : 1;
126 Eina_Bool show_last_character : 1;
127 Eina_Bool editable : 1;
128 Eina_Bool selection_asked : 1;
129 Eina_Bool have_selection : 1;
130 Eina_Bool selmode : 1;
131 Eina_Bool deferred_cur : 1;
132 Eina_Bool disabled : 1;
133 Eina_Bool double_clicked : 1;
134 Eina_Bool context_menu : 1;
135 Eina_Bool drag_selection_asked : 1;
136 Eina_Bool bgcolor : 1;
137 Eina_Bool ellipsis : 1;
138 Eina_Bool autoreturnkey : 1;
139 Eina_Bool input_panel_enable : 1;
140 Eina_Bool autocapital : 1;
141 Elm_Input_Panel_Layout input_panel_layout;
142 Eina_Bool autoperiod : 1;
145 struct _Elm_Entry_Item_Provider
147 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
151 static const char *widtype = NULL;
153 static Evas_Object *cnpwidgetdata = NULL;
156 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
157 static void _del_hook(Evas_Object *obj);
158 static void _theme_hook(Evas_Object *obj);
159 static void _disable_hook(Evas_Object *obj);
160 static void _sizing_eval(Evas_Object *obj);
161 static void _on_focus_hook(void *data, Evas_Object *obj);
162 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
163 static const char *_getbase(Evas_Object *obj);
164 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
165 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
166 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
167 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
168 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
169 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
170 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
171 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
172 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
173 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
174 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
175 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
176 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
177 static int _is_width_over(Evas_Object *obj);
178 static void _ellipsis_entry_to_width(Evas_Object *obj);
179 static void _reverse_ellipsis_entry(Evas_Object *obj);
180 static int _textinput_control_function(void *data,void *input_data);
181 static int _entry_length_get(Evas_Object *obj);
183 static const char SIG_CHANGED[] = "changed";
184 static const char SIG_ACTIVATED[] = "activated";
185 static const char SIG_PRESS[] = "press";
186 static const char SIG_LONGPRESSED[] = "longpressed";
187 static const char SIG_CLICKED[] = "clicked";
188 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
189 static const char SIG_FOCUSED[] = "focused";
190 static const char SIG_UNFOCUSED[] = "unfocused";
191 static const char SIG_SELECTION_PASTE[] = "selection,paste";
192 static const char SIG_SELECTION_COPY[] = "selection,copy";
193 static const char SIG_SELECTION_CUT[] = "selection,cut";
194 static const char SIG_SELECTION_START[] = "selection,start";
195 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
196 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
197 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
198 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
199 #ifdef HAVE_CONFORMANT_AUTOSCROLL
200 static const char SIG_IMPREGION_CHANGED[] = "impregion,changed";
202 static const Evas_Smart_Cb_Description _signals[] = {
206 {SIG_LONGPRESSED, ""},
208 {SIG_CLICKED_DOUBLE, ""},
211 {SIG_SELECTION_PASTE, ""},
212 {SIG_SELECTION_COPY, ""},
213 {SIG_SELECTION_CUT, ""},
214 {SIG_SELECTION_START, ""},
215 {SIG_SELECTION_CHANGED, ""},
216 {SIG_SELECTION_CLEARED, ""},
217 {SIG_CURSOR_CHANGED, ""},
218 {SIG_ANCHOR_CLICKED, ""},
222 static Eina_List *entries = NULL;
226 void (*obj_hook) (Evas_Object *obj);
227 void (*obj_unhook) (Evas_Object *obj);
228 void (*obj_longpress) (Evas_Object *obj);
229 void (*obj_mouseup) (Evas_Object *obj);
233 _module(Evas_Object *obj __UNUSED__)
235 static Elm_Module *m = NULL;
236 if (m) goto ok; // already found - just use
237 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
239 m->api = malloc(sizeof(Mod_Api));
240 if (!m->api) return NULL;
241 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
242 _elm_module_symbol_get(m, "obj_hook");
243 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
244 _elm_module_symbol_get(m, "obj_unhook");
245 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
246 _elm_module_symbol_get(m, "obj_longpress");
247 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
248 _elm_module_symbol_get(m, "obj_mouseup");
249 ok: // ok - return api
254 _del_hook(Evas_Object *obj)
256 Widget_Data *wd = elm_widget_data_get(obj);
257 Elm_Entry_Context_Menu_Item *it;
258 Elm_Entry_Item_Provider *ip;
260 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
261 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
263 entries = eina_list_remove(entries, obj);
264 #ifdef HAVE_ELEMENTARY_X
265 ecore_event_handler_del(wd->sel_notify_handler);
266 ecore_event_handler_del(wd->sel_clear_handler);
268 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
269 if (wd->text) eina_stringshare_del(wd->text);
270 if (wd->bg) evas_object_del(wd->bg);
271 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
272 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
273 EINA_LIST_FREE(wd->items, it)
275 eina_stringshare_del(it->label);
276 eina_stringshare_del(it->icon_file);
277 eina_stringshare_del(it->icon_group);
280 EINA_LIST_FREE(wd->item_providers, ip)
288 _theme_hook(Evas_Object *obj)
290 Widget_Data *wd = elm_widget_data_get(obj);
292 Ecore_IMF_Context *ic;
294 t = eina_stringshare_add(elm_entry_entry_get(obj));
295 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
296 elm_entry_entry_set(obj, t);
297 eina_stringshare_del(t);
298 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
299 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
300 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
301 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
303 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
306 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
313 _disable_hook(Evas_Object *obj)
315 Widget_Data *wd = elm_widget_data_get(obj);
317 if (elm_widget_disabled_get(obj))
319 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
320 wd->disabled = EINA_TRUE;
324 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
325 wd->disabled = EINA_FALSE;
330 _elm_win_recalc_job(void *data)
332 Widget_Data *wd = elm_widget_data_get(data);
333 Evas_Coord minw = -1, minh = -1, maxh = -1;
334 Evas_Coord resw, resh, minminw;
336 wd->deferred_recalc_job = NULL;
337 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
340 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
341 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
343 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
344 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
345 evas_object_size_hint_min_set(data, minminw, minh);
346 if (wd->single_line) maxh = minh;
347 evas_object_size_hint_max_set(data, -1, maxh);
348 if (wd->deferred_cur)
349 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
353 _sizing_eval(Evas_Object *obj)
355 Widget_Data *wd = elm_widget_data_get(obj);
356 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
357 Evas_Coord resw, resh;
359 if (wd->linewrap || wd->char_linewrap)
361 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
362 if ((resw == wd->lastw) && (!wd->changed)) return;
363 wd->changed = EINA_FALSE;
365 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
366 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
370 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
371 edje_object_size_min_calc(wd->ent, &minw, &minh);
372 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
373 evas_object_size_hint_min_set(obj, minw, minh);
374 if (wd->single_line) maxh = minh;
375 evas_object_size_hint_max_set(obj, maxw, maxh);
377 if (wd->ellipsis && wd->single_line)
379 if (_is_width_over(obj))
380 _ellipsis_entry_to_width(obj);
381 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
382 _reverse_ellipsis_entry(obj);
388 _check_enable_returnkey(Evas_Object *obj)
390 Widget_Data *wd = elm_widget_data_get(obj);
393 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
396 if (!wd->autoreturnkey) return;
398 if (_entry_length_get(obj) == 0)
400 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
404 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
408 #ifdef HAVE_CONFORMANT_AUTOSCROLL
410 _imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
412 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
413 Widget_Data *wd = elm_widget_data_get(obj);
414 if (!wd) return NULL;
415 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
426 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
428 Widget_Data *wd = elm_widget_data_get(obj);
429 Evas_Object *top = elm_widget_top_get(obj);
431 if (!wd->editable) return;
432 if (elm_widget_focus_get(obj))
434 evas_object_focus_set(wd->ent, 1);
435 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
437 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
438 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
439 _check_enable_returnkey(obj);
443 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
444 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
445 evas_object_focus_set(wd->ent, 0);
446 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
447 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
452 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
454 Widget_Data *wd = elm_widget_data_get(obj);
456 edje_object_signal_emit(wd->ent, emission, source);
460 _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)
462 Widget_Data *wd = elm_widget_data_get(obj);
464 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
468 _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))
470 Widget_Data *wd = elm_widget_data_get(obj);
471 if (!wd) return NULL;
472 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
476 _hoversel_position(Evas_Object *obj)
478 Widget_Data *wd = elm_widget_data_get(obj);
479 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
481 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
482 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
484 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
495 evas_object_move(wd->hoversel, x + cx, y + cy);
496 evas_object_resize(wd->hoversel, cw, ch);
500 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
502 Widget_Data *wd = elm_widget_data_get(data);
504 if (wd->hoversel) _hoversel_position(data);
508 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
510 Widget_Data *wd = elm_widget_data_get(data);
512 if (wd->linewrap || wd->char_linewrap)
516 if (wd->hoversel) _hoversel_position(data);
517 // Evas_Coord ww, hh;
518 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
522 _hover_del(void *data)
524 Widget_Data *wd = elm_widget_data_get(data);
529 evas_object_del(wd->hoversel);
532 wd->hovdeljob = NULL;
536 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
538 Widget_Data *wd = elm_widget_data_get(data);
540 if (wd->hoversel) evas_object_hide(wd->hoversel);
544 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
546 elm_widget_scroll_freeze_pop(data);
547 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
548 wd->hovdeljob = ecore_job_add(_hover_del, data);
552 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
554 Widget_Data *wd = elm_widget_data_get(data);
556 wd->selmode = EINA_TRUE;
557 edje_object_part_text_select_none(wd->ent, "elm.text");
559 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
560 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
561 elm_widget_scroll_hold_push(data);
565 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
567 Widget_Data *wd = elm_widget_data_get(data);
569 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
570 if (wd->sel_notify_handler)
572 #ifdef HAVE_ELEMENTARY_X
573 wd->selection_asked = EINA_TRUE;
574 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
580 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
582 Widget_Data *wd = elm_widget_data_get(obj);
586 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
587 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
588 if (seltype == ELM_SEL_CLIPBOARD)
589 eina_stringshare_replace(&wd->cut_sel, sel);
593 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
595 Widget_Data *wd = elm_widget_data_get(data);
598 wd->selmode = EINA_FALSE;
599 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
600 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
601 elm_widget_scroll_hold_pop(data);
602 _store_selection(ELM_SEL_CLIPBOARD, data);
603 edje_object_part_text_insert(wd->ent, "elm.text", "");
604 edje_object_part_text_select_none(wd->ent, "elm.text");
608 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
610 Widget_Data *wd = elm_widget_data_get(data);
612 wd->selmode = EINA_FALSE;
613 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
614 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
615 elm_widget_scroll_hold_pop(data);
616 _store_selection(ELM_SEL_CLIPBOARD, data);
617 edje_object_part_text_select_none(wd->ent, "elm.text");
621 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
623 Widget_Data *wd = elm_widget_data_get(data);
625 wd->selmode = EINA_FALSE;
626 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
627 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
628 elm_widget_scroll_hold_pop(data);
629 edje_object_part_text_select_none(wd->ent, "elm.text");
633 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
635 Widget_Data *wd = elm_widget_data_get(data);
639 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
640 cnpwidgetdata = data;
641 elm_cbhm_helper_init(obj);
642 elm_cbhm_send_raw_data("show");
648 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
650 Widget_Data *wd = elm_widget_data_get(data);
652 cnpwidgetdata = data;
658 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
660 Elm_Entry_Context_Menu_Item *it = data;
661 Evas_Object *obj2 = it->obj;
663 if (it->func) it->func(it->data, obj2, NULL);
667 _long_press(void *data)
669 Widget_Data *wd = elm_widget_data_get(data);
672 const Elm_Entry_Context_Menu_Item *it;
673 if (!wd) return ECORE_CALLBACK_CANCEL;
675 if (wd->longpress_timer)
677 ecore_timer_del(wd->longpress_timer);
678 wd->longpress_timer = NULL;
681 if ((wd->api) && (wd->api->obj_longpress))
683 wd->api->obj_longpress(data);
685 else if (wd->context_menu)
687 const char *context_menu_orientation;
689 if (wd->hoversel) evas_object_del(wd->hoversel);
690 else elm_widget_scroll_freeze_push(data);
691 wd->hoversel = elm_hoversel_add(data);
692 context_menu_orientation = edje_object_data_get
693 (wd->ent, "context_menu_orientation");
694 if ((context_menu_orientation) &&
695 (!strcmp(context_menu_orientation, "horizontal")))
696 elm_hoversel_horizontal_set(wd->hoversel, 1);
697 elm_object_style_set(wd->hoversel, "entry");
698 elm_widget_sub_object_add(data, wd->hoversel);
699 elm_hoversel_label_set(wd->hoversel, "Text");
700 top = elm_widget_top_get(data);
701 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
702 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
706 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
708 if (1) // need way to detect if someone has a selection
711 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
716 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
717 _clipboard_menu, data);
724 if (wd->have_selection)
726 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
729 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
732 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
735 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
736 _clipboard_menu, data);
740 EINA_LIST_FOREACH(wd->items, l, it)
742 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
743 it->icon_type, _item_clicked, it);
747 _hoversel_position(data);
748 evas_object_show(wd->hoversel);
749 elm_hoversel_hover_begin(wd->hoversel);
751 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
752 edje_object_part_text_select_abort(wd->ent, "elm.text");
754 wd->longpress_timer = NULL;
755 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
756 return ECORE_CALLBACK_CANCEL;
760 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
762 Widget_Data *wd = elm_widget_data_get(data);
763 Evas_Event_Mouse_Down *ev = event_info;
765 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
766 if (ev->button != 1) return;
767 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
768 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
769 wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
770 wd->downx = ev->canvas.x;
771 wd->downy = ev->canvas.y;
775 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
777 Widget_Data *wd = elm_widget_data_get(data);
778 Evas_Event_Mouse_Up *ev = event_info;
780 if (ev->button != 1) return;
782 if (!wd->double_clicked)
784 if ((wd->api) && (wd->api->obj_mouseup))
786 wd->api->obj_mouseup(data);
789 if (wd->longpress_timer)
791 ecore_timer_del(wd->longpress_timer);
792 wd->longpress_timer = NULL;
797 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
799 Widget_Data *wd = elm_widget_data_get(data);
800 Evas_Event_Mouse_Move *ev = event_info;
804 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
806 if (wd->longpress_timer)
808 ecore_timer_del(wd->longpress_timer);
809 wd->longpress_timer = NULL;
812 else if (wd->longpress_timer)
816 dx = wd->downx - ev->cur.canvas.x;
818 dy = wd->downy - ev->cur.canvas.y;
821 ((_elm_config->finger_size / 2) *
822 (_elm_config->finger_size / 2)))
824 ecore_timer_del(wd->longpress_timer);
825 wd->longpress_timer = NULL;
829 else if (wd->longpress_timer)
833 dx = wd->downx - ev->cur.canvas.x;
835 dy = wd->downy - ev->cur.canvas.y;
838 ((_elm_config->finger_size / 2) *
839 (_elm_config->finger_size / 2)))
841 ecore_timer_del(wd->longpress_timer);
842 wd->longpress_timer = NULL;
848 _getbase(Evas_Object *obj)
850 Widget_Data *wd = elm_widget_data_get(obj);
851 if (!wd) return "base";
856 if (wd->show_last_character) return "custom-password";
857 else return "base-password";
861 if (wd->single_line) return "base-single";
864 if (wd->linewrap) return "base";
865 else if (wd->char_linewrap) return "base-charwrap";
866 else return "base-nowrap";
874 if (wd->show_last_character) return "custom-password";
875 else return "base-password";
879 if (wd->single_line) return "base-single-noedit";
882 if (wd->linewrap) return "base-noedit";
883 else if (wd->char_linewrap) return "base-noedit-charwrap";
884 else return "base-nowrap-noedit";
892 _str_append(char *str, const char *txt, int *len, int *alloc)
894 int txt_len = strlen(txt);
896 if (txt_len <= 0) return str;
897 if ((*len + txt_len) >= *alloc)
902 alloc2 = *alloc + txt_len + 128;
903 str2 = realloc(str, alloc2);
904 if (!str2) return str;
908 strcpy(str + *len, txt);
913 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
914 * because some markups can be implemented otherwise according to style.
915 * probably doing it in textblock and making it translate according to it's
916 * style is correct. */
918 _strncpy(char* dest, const char* src, size_t count)
922 ERR( "dest is NULL" );
927 ERR( "src is NULL" );
932 ERR( "count is smaller than 0" );
936 return strncpy( dest, src, count );
940 _mkup_to_text(const char *mkup)
943 int str_len = 0, str_alloc = 0;
945 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
947 if (!mkup) return NULL;
949 tag_start = tag_end = esc_start = esc_end = NULL;
954 if (((p!=NULL)&&(*p == 0)) ||
955 (tag_end) || (esc_end) ||
956 (tag_start) || (esc_start))
962 ttag = malloc(tag_end - tag_start);
965 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
966 ttag[tag_end - tag_start - 1] = 0;
967 if (!strcmp(ttag, "br"))
968 str = _str_append(str, "\n", &str_len, &str_alloc);
969 else if (!strcmp(ttag, "\n"))
970 str = _str_append(str, "\n", &str_len, &str_alloc);
971 else if (!strcmp(ttag, "\\n"))
972 str = _str_append(str, "\n", &str_len, &str_alloc);
973 else if (!strcmp(ttag, "\t"))
974 str = _str_append(str, "\t", &str_len, &str_alloc);
975 else if (!strcmp(ttag, "\\t"))
976 str = _str_append(str, "\t", &str_len, &str_alloc);
977 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
978 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
981 tag_start = tag_end = NULL;
985 ts = malloc(esc_end - esc_start + 1);
989 _strncpy(ts, esc_start, esc_end - esc_start);
990 ts[esc_end - esc_start] = 0;
991 esc = evas_textblock_escape_string_get(ts);
993 str = _str_append(str, esc, &str_len, &str_alloc);
996 esc_start = esc_end = NULL;
998 else if ((p!=NULL)&&(*p == 0))
1000 ts = malloc(p - s + 1);
1003 _strncpy(ts, s, p - s);
1005 str = _str_append(str, ts, &str_len, &str_alloc);
1011 if ((p!=NULL)&&(*p == '<'))
1017 ts = malloc(p - s + 1);
1020 _strncpy(ts, s, p - s);
1022 str = _str_append(str, ts, &str_len, &str_alloc);
1028 else if ((p!=NULL)&&(*p == '>'))
1036 else if ((p!=NULL)&&(*p == '&'))
1042 ts = malloc(p - s + 1);
1045 _strncpy(ts, s, p - s);
1047 str = _str_append(str, ts, &str_len, &str_alloc);
1053 else if ((p!=NULL)&&(*p == ';'))
1067 _entry_length_get(Evas_Object *obj)
1070 const char *str = elm_entry_entry_get(obj);
1073 char *plain_str = _mkup_to_text(str);
1074 if (!plain_str) return 0;
1076 len = strlen(plain_str);
1083 _text_to_mkup(const char *text)
1086 int str_len = 0, str_alloc = 0;
1087 int ch, pos = 0, pos2 = 0;
1089 if (!text) return NULL;
1093 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1094 if ((ch <= 0) || (pos2 <= 0)) break;
1096 str = _str_append(str, "<br>", &str_len, &str_alloc);
1097 else if (ch == '\t')
1098 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1100 str = _str_append(str, "<", &str_len, &str_alloc);
1102 str = _str_append(str, ">", &str_len, &str_alloc);
1104 str = _str_append(str, "&", &str_len, &str_alloc);
1105 else if (ch == 0x2029)
1106 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1111 _strncpy(tstr, text + pos, pos2 - pos);
1112 tstr[pos2 - pos] = 0;
1113 str = _str_append(str, tstr, &str_len, &str_alloc);
1120 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1122 Widget_Data *wd = elm_widget_data_get(data);
1124 wd->changed = EINA_TRUE;
1126 if (wd->text) eina_stringshare_del(wd->text);
1128 _check_enable_returnkey(data);
1129 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1133 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1135 Widget_Data *wd = elm_widget_data_get(data);
1136 elm_object_scroll_freeze_push(data);
1140 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1142 Widget_Data *wd = elm_widget_data_get(data);
1143 elm_object_scroll_freeze_pop(data);
1147 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1149 Widget_Data *wd = elm_widget_data_get(data);
1153 EINA_LIST_FOREACH(entries, l, entry)
1155 if (entry != data) elm_entry_select_none(entry);
1157 wd->have_selection = EINA_TRUE;
1158 wd->selmode = EINA_TRUE;
1159 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1160 #ifdef HAVE_ELEMENTARY_X
1161 if (wd->sel_notify_handler)
1163 const char *txt = elm_entry_selection_get(data);
1166 top = elm_widget_top_get(data);
1167 if ((top) && (elm_win_xwindow_get(top)))
1168 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1174 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1176 Evas_Coord cx, cy, cw, ch;
1177 Widget_Data *wd = elm_widget_data_get(data);
1179 wd->have_selection = EINA_TRUE;
1180 wd->selmode = EINA_TRUE;
1181 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1182 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1183 elm_entry_selection_get(data));
1185 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1186 if (!wd->deferred_recalc_job)
1187 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1190 wd->deferred_cur = EINA_TRUE;
1194 wd->ch = ch + elm_finger_size_get();
1199 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1201 Widget_Data *wd = elm_widget_data_get(data);
1203 if (!wd->have_selection) return;
1204 wd->have_selection = EINA_FALSE;
1205 wd->selmode = EINA_FALSE;
1206 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1207 if (wd->sel_notify_handler)
1211 #ifdef HAVE_ELEMENTARY_X
1214 top = elm_widget_top_get(data);
1215 if ((top) && (elm_win_xwindow_get(top)))
1216 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1219 eina_stringshare_del(wd->cut_sel);
1224 #ifdef HAVE_ELEMENTARY_X
1227 top = elm_widget_top_get(data);
1228 if ((top) && (elm_win_xwindow_get(top)))
1229 elm_selection_clear(ELM_SEL_PRIMARY, data);
1236 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1238 Widget_Data *wd = elm_widget_data_get(data);
1240 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1241 if (wd->sel_notify_handler)
1243 #ifdef HAVE_ELEMENTARY_X
1246 top = elm_widget_top_get(data);
1247 if ((top) && (elm_win_xwindow_get(top)))
1249 wd->selection_asked = EINA_TRUE;
1250 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1257 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1259 Widget_Data *wd = elm_widget_data_get(data);
1261 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1262 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1263 elm_entry_selection_get(data));
1267 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1269 Widget_Data *wd = elm_widget_data_get(data);
1271 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1272 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1273 elm_entry_selection_get(data));
1274 edje_object_part_text_insert(wd->ent, "elm.text", "");
1275 wd->changed = EINA_TRUE;
1280 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1282 Widget_Data *wd = elm_widget_data_get(data);
1283 Evas_Coord cx, cy, cw, ch;
1285 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1286 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1287 &cx, &cy, &cw, &ch);
1288 if (!wd->deferred_recalc_job)
1289 elm_widget_show_region_set(data, cx, cy, cw, ch);
1292 wd->deferred_cur = EINA_TRUE;
1298 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1299 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1304 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1306 Widget_Data *wd = elm_widget_data_get(data);
1311 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1313 Widget_Data *wd = elm_widget_data_get(data);
1314 Elm_Entry_Anchor_Info ei;
1315 char *buf2, *p, *p2, *n;
1317 p = strrchr(emission, ',');
1320 const Eina_List *geoms;
1324 while (p2 >= emission)
1326 if (*p2 == ',') break;
1330 buf2 = alloca(5 + p - p2);
1331 strncpy(buf2, p2, p - p2);
1334 ei.button = atoi(buf2);
1335 ei.x = ei.y = ei.w = ei.h = 0;
1337 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1340 Evas_Textblock_Rectangle *r;
1342 Evas_Coord px, py, x, y;
1344 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1345 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1346 EINA_LIST_FOREACH(geoms, l, r)
1348 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1349 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1360 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1365 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1367 Widget_Data *wd = elm_widget_data_get(data);
1372 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1374 Widget_Data *wd = elm_widget_data_get(data);
1379 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1381 Widget_Data *wd = elm_widget_data_get(data);
1386 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1388 Widget_Data *wd = elm_widget_data_get(data);
1390 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1394 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1396 Widget_Data *wd = elm_widget_data_get(data);
1398 wd->double_clicked = EINA_FALSE;
1399 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1403 _signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1405 Widget_Data *wd = elm_widget_data_get(data);
1407 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1411 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1413 Widget_Data *wd = elm_widget_data_get(data);
1415 wd->double_clicked = EINA_TRUE;
1416 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1419 #ifdef HAVE_ELEMENTARY_X
1421 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1423 Widget_Data *wd = elm_widget_data_get(data);
1424 Ecore_X_Event_Selection_Notify *ev = event;
1425 if (!wd) return ECORE_CALLBACK_PASS_ON;
1426 if (!wd->selection_asked && !wd->drag_selection_asked)
1427 return ECORE_CALLBACK_PASS_ON;
1429 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1430 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1432 Ecore_X_Selection_Data_Text *text_data;
1434 text_data = ev->data;
1435 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1437 if (text_data->text)
1439 char *txt = _text_to_mkup(text_data->text);
1443 elm_entry_entry_insert(data, txt);
1448 wd->selection_asked = EINA_FALSE;
1450 else if (ev->selection == ECORE_X_SELECTION_XDND)
1452 Ecore_X_Selection_Data_Text *text_data;
1454 text_data = ev->data;
1455 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1457 if (text_data->text)
1459 char *txt = _text_to_mkup(text_data->text);
1463 /* Massive FIXME: this should be at the drag point */
1464 elm_entry_entry_insert(data, txt);
1469 wd->drag_selection_asked = EINA_FALSE;
1471 ecore_x_dnd_send_finished();
1475 return ECORE_CALLBACK_PASS_ON;
1479 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1482 Widget_Data *wd = elm_widget_data_get(data);
1483 Ecore_X_Event_Selection_Clear *ev = event;
1485 if (!wd->have_selection) return 1;
1486 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1487 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1489 elm_entry_select_none(data);
1494 Evas_Object *top = elm_widget_top_get(data);
1495 Ecore_X_Event_Selection_Clear *ev = event;
1498 return ECORE_CALLBACK_PASS_ON;
1500 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1502 return ECORE_CALLBACK_PASS_ON;
1505 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1508 return ECORE_CALLBACK_PASS_ON;
1513 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1518 wd = elm_widget_data_get(obj);
1520 if (!wd) return EINA_FALSE;
1521 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1523 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1524 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1525 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1526 EDJE_CURSOR_MAIN,drop->x,drop->y);
1527 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1528 elm_entry_entry_insert(obj, drop->data);
1529 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1530 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1536 static Evas_Object *
1537 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1539 Widget_Data *wd = elm_widget_data_get(data);
1542 Elm_Entry_Item_Provider *ip;
1545 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1547 o = ip->func(ip->data, data, item);
1550 o = edje_object_add(evas_object_evas_get(data));
1551 if (!strncmp(item, "emoticon/", 9))
1552 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1554 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1559 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1561 char *curlocater, *starttag, *endtag;
1562 int firstindex = 0, foundflag = -1;
1564 curlocater = strstr(oldstring, key);
1567 starttag = curlocater;
1568 endtag = curlocater + strlen(key);
1569 if (endtag == NULL || *endtag != '=')
1575 firstindex = abs(oldstring - curlocater);
1576 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1577 *value = (char*)oldstring + firstindex;
1579 while (oldstring != starttag)
1581 if (*starttag == '>')
1586 if (*starttag == '<')
1590 if (starttag == NULL) break;
1593 while (NULL != endtag)
1604 if (endtag == NULL) break;
1607 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1617 if (foundflag == 1) return 0;
1623 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1625 const char *srcstring = NULL;
1626 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1627 char *curlocater, *replocater;
1628 char *starttag, *endtag;
1629 int tagtxtlen = 0, insertflag = 0;
1631 srcstring = eina_strbuf_string_get(srcbuf);
1632 curlocater = strstr(srcstring, key);
1634 if (curlocater == NULL)
1642 starttag = strchr(srcstring, '<');
1643 endtag = strchr(srcstring, '>');
1644 tagtxtlen = endtag - starttag;
1645 if (tagtxtlen <= 0) tagtxtlen = 0;
1646 if (starttag < curlocater && curlocater < endtag) break;
1647 if (endtag != NULL && endtag+1 != NULL)
1648 srcstring = endtag+1;
1651 } while (strlen(srcstring) > 1);
1653 if (starttag && endtag && tagtxtlen > strlen(key))
1655 repbuf = eina_strbuf_new();
1656 diffbuf = eina_strbuf_new();
1657 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1658 srcstring = eina_strbuf_string_get(repbuf);
1659 curlocater = strstr(srcstring, key);
1661 if (curlocater != NULL)
1663 replocater = curlocater + strlen(key) + 1;
1665 while (*replocater == ' ' || *replocater == '=')
1670 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1673 if (replocater-curlocater > strlen(key)+1)
1676 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1685 eina_strbuf_reset(repbuf);
1693 if (repbuf == NULL) repbuf = eina_strbuf_new();
1694 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1698 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1699 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1705 eina_strbuf_prepend(diffbuf, "<");
1706 eina_strbuf_append(diffbuf, ">");
1707 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1711 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1712 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1716 if (repbuf) eina_strbuf_free(repbuf);
1717 if (diffbuf) eina_strbuf_free(diffbuf);
1723 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1725 Eina_Strbuf *sharebuf = NULL;
1727 sharebuf = eina_strbuf_new();
1728 eina_strbuf_append(sharebuf, *srcstring);
1729 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1730 eina_stringshare_del(*srcstring);
1731 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1732 eina_strbuf_free(sharebuf);
1738 _is_width_over(Evas_Object *obj)
1740 Evas_Coord x, y, w, h;
1741 Evas_Coord vx, vy, vw, vh;
1742 Widget_Data *wd = elm_widget_data_get(obj);
1746 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1748 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1750 if (x >= 0 && y >= 0)
1753 if (4 < wd->wrap_w && w > wd->wrap_w)
1760 _reverse_ellipsis_entry(Evas_Object *obj)
1762 Widget_Data *wd = elm_widget_data_get(obj);
1763 int cur_fontsize = 0;
1764 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1765 char **kvalue = NULL;
1766 const char *minfont, *deffont, *maxfont;
1767 const char *ellipsis_string = "...";
1768 int minfontsize, maxfontsize, minshowcount;
1770 minshowcount = strlen(ellipsis_string) + 1;
1771 minfont = edje_object_data_get(wd->ent, "min_font_size");
1772 if (minfont) minfontsize = atoi(minfont);
1773 else minfontsize = 1;
1774 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1775 if (maxfont) maxfontsize = atoi(maxfont);
1776 else maxfontsize = 1;
1777 deffont = edje_object_data_get(wd->ent, "default_font_size");
1778 if (deffont) cur_fontsize = atoi(deffont);
1779 else cur_fontsize = 1;
1780 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1781 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1783 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1785 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1788 txtbuf = eina_strbuf_new();
1789 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1791 if (cur_fontsize >= atoi(deffont))
1793 if (txtbuf) eina_strbuf_free(txtbuf);
1797 if (_is_width_over(obj) != 1)
1799 int rev_fontsize = cur_fontsize;
1803 if (rev_fontsize > atoi(deffont))
1806 if (fontbuf != NULL)
1808 eina_strbuf_free(fontbuf);
1811 fontbuf = eina_strbuf_new();
1812 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1813 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1814 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1816 eina_strbuf_free(fontbuf);
1818 } while (_is_width_over(obj) != 1);
1820 while (_is_width_over(obj))
1823 if (rev_fontsize < atoi(deffont))
1826 if (fontbuf != NULL)
1828 eina_strbuf_free(fontbuf);
1831 fontbuf = eina_strbuf_new();
1832 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1833 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1834 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1835 eina_strbuf_free(fontbuf);
1840 if (txtbuf) eina_strbuf_free(txtbuf);
1846 _ellipsis_entry_to_width(Evas_Object *obj)
1848 Widget_Data *wd = elm_widget_data_get(obj);
1849 int cur_fontsize = 0, len, jumpcount;
1850 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1851 char **kvalue = NULL;
1852 const char *minfont, *deffont, *maxfont;
1853 const char *ellipsis_string = "...";
1854 int minfontsize, maxfontsize, minshowcount;
1855 int i, tagend, cur_len;
1858 minshowcount = strlen(ellipsis_string) + 1;
1859 minfont = edje_object_data_get(wd->ent, "min_font_size");
1860 if (minfont) minfontsize = atoi(minfont);
1861 else minfontsize = 1;
1862 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1863 if (maxfont) maxfontsize = atoi(maxfont);
1864 else maxfontsize = 1;
1865 deffont = edje_object_data_get(wd->ent, "default_font_size");
1866 if (deffont) cur_fontsize = atoi(deffont);
1867 else cur_fontsize = 1;
1868 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1869 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1871 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1873 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1876 txtbuf = eina_strbuf_new();
1877 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1879 while (_is_width_over(obj))
1881 if (wd->ellipsis_threshold == 0)
1882 wd->ellipsis_threshold = _entry_length_get(obj);
1883 if (cur_fontsize > minfontsize)
1886 if (fontbuf != NULL)
1888 eina_strbuf_free(fontbuf);
1891 fontbuf = eina_strbuf_new();
1892 eina_strbuf_append_printf(fontbuf, "%d", cur_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));
1895 eina_strbuf_free(fontbuf);
1897 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1901 len = _entry_length_get(obj);
1902 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1903 cur_len = strlen(cur_str);
1905 for (i = 0; i < len; i++)
1907 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1908 cur_str[i+1] != '<')
1915 while (jumpcount < len-strlen(ellipsis_string))
1917 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1921 eina_strbuf_free(txtbuf);
1924 txtbuf = eina_strbuf_new();
1925 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1926 eina_strbuf_append(txtbuf, ellipsis_string);
1927 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1928 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1929 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1931 if (_is_width_over(obj))
1939 if (txtbuf) eina_strbuf_free(txtbuf);
1944 static int _textinput_control_function(void *data,void *input_data)
1946 /*calculate character count*/
1947 Evas_Object *entry = (Evas_Object *)data;
1948 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
1951 size_t insert_text_len=0;
1952 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1954 size_t remain_bytes;
1957 byte_len = strlen(text);/*no of bytes*/
1958 remain_bytes = wd->max_no_of_bytes-byte_len;
1959 sprintf(buf,"%d",remain_bytes);
1960 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1963 insert_text = (char *)input_data;
1964 insert_text_len = strlen(insert_text);
1965 if(remain_bytes<insert_text_len)
1967 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1970 if(byte_len>=wd->max_no_of_bytes)
1972 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1981 * This adds an entry to @p parent object.
1983 * @param parent The parent object
1984 * @return The new object or NULL if it cannot be created
1989 elm_entry_add(Evas_Object *parent)
1991 Evas_Object *obj, *top;
1995 wd = ELM_NEW(Widget_Data);
1996 e = evas_object_evas_get(parent);
1997 wd->bgcolor = EINA_FALSE;
1998 wd->bg = evas_object_rectangle_add(e);
1999 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2000 obj = elm_widget_add(e);
2001 ELM_SET_WIDTYPE(widtype, "entry");
2002 elm_widget_type_set(obj, "entry");
2003 elm_widget_sub_object_add(parent, obj);
2004 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2005 elm_widget_data_set(obj, wd);
2006 elm_widget_del_hook_set(obj, _del_hook);
2007 elm_widget_theme_hook_set(obj, _theme_hook);
2008 elm_widget_disable_hook_set(obj, _disable_hook);
2009 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2010 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2011 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2012 elm_widget_can_focus_set(obj, 1);
2013 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2014 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2017 wd->linewrap = EINA_TRUE;
2018 wd->ellipsis = EINA_FALSE;
2019 wd->char_linewrap= EINA_FALSE;
2020 wd->editable = EINA_TRUE;
2021 wd->disabled = EINA_FALSE;
2022 wd->context_menu = EINA_TRUE;
2024 wd->ellipsis_threshold = 0;
2026 wd->ent = edje_object_add(e);
2027 edje_object_item_provider_set(wd->ent, _get_item, obj);
2028 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2029 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2030 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2032 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2034 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2037 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2038 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2039 _signal_entry_changed, obj);
2040 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2041 _signal_handler_move_start, obj);
2042 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2043 _signal_handler_move_end, obj);
2044 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2045 _signal_selection_start, obj);
2046 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2047 _signal_selection_changed, obj);
2048 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2049 _signal_selection_cleared, obj);
2050 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2051 _signal_entry_paste_request, obj);
2052 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2053 _signal_entry_copy_notify, obj);
2054 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2055 _signal_entry_cut_notify, obj);
2056 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2057 _signal_cursor_changed, obj);
2058 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2059 _signal_anchor_down, obj);
2060 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2061 _signal_anchor_up, obj);
2062 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2063 _signal_anchor_move, obj);
2064 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2065 _signal_anchor_in, obj);
2066 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2067 _signal_anchor_out, obj);
2068 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2069 _signal_key_enter, obj);
2070 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2071 _signal_mouse_down, obj);
2072 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2073 _signal_mouse_up, obj);
2074 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2075 _signal_mouse_double, obj);
2076 edje_object_part_text_set(wd->ent, "elm.text", "");
2077 elm_widget_resize_object_set(obj, wd->ent);
2080 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2082 #ifdef HAVE_ELEMENTARY_X
2083 top = elm_widget_top_get(obj);
2084 if ((top) && (elm_win_xwindow_get(top)))
2086 wd->sel_notify_handler =
2087 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2088 _event_selection_notify, obj);
2089 wd->sel_clear_handler =
2090 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2091 _event_selection_clear, obj);
2094 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2097 entries = eina_list_prepend(entries, obj);
2099 // module - find module for entry
2100 wd->api = _module(obj);
2101 // if found - hook in
2102 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2104 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2105 // TODO: and save some bytes, making descriptions per-class and not instance!
2106 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2110 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2112 ELM_CHECK_WIDTYPE(obj, widtype);
2113 Widget_Data *wd = elm_widget_data_get(obj);
2115 ext_mod->cancel = _cancel;
2116 ext_mod->copy = _copy;
2117 ext_mod->cut = _cut;
2118 ext_mod->paste = _paste;
2119 ext_mod->select = _select;
2120 ext_mod->selectall = NULL; /* to be implemented*/
2121 ext_mod->ent = wd->ent;
2122 ext_mod->items = wd->items;
2123 ext_mod->longpress_timer = wd->longpress_timer;
2124 ext_mod->editable = wd->editable;
2125 ext_mod->have_selection = wd->have_selection;
2126 ext_mod->password = wd->password;
2127 ext_mod->selmode = wd->selmode;
2128 ext_mod->cnpinit = _cnpinit;
2129 ext_mod->context_menu = wd->context_menu;
2133 * This sets the entry object not to line wrap. All input will
2134 * be on a single line, and the entry box will extend with user input.
2136 * @param obj The entry object
2137 * @param single_line If true, the text in the entry
2138 * will be on a single line.
2143 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2145 ELM_CHECK_WIDTYPE(obj, widtype);
2146 Widget_Data *wd = elm_widget_data_get(obj);
2148 Ecore_IMF_Context *ic;
2150 if (wd->single_line == single_line) return;
2151 wd->single_line = single_line;
2152 wd->linewrap = EINA_FALSE;
2153 wd->char_linewrap = EINA_FALSE;
2154 t = eina_stringshare_add(elm_entry_entry_get(obj));
2155 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2156 elm_entry_entry_set(obj, t);
2157 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2158 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2159 ic = elm_entry_imf_context_get(obj);
2162 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2165 eina_stringshare_del(t);
2170 * This returns true if the entry has been set to single line mode.
2171 * See also elm_entry_single_line_set().
2173 * @param obj The entry object
2174 * @return single_line If true, the text in the entry is set to display
2180 elm_entry_single_line_get(const Evas_Object *obj)
2182 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2183 Widget_Data *wd = elm_widget_data_get(obj);
2184 if (!wd) return EINA_FALSE;
2185 return wd->single_line;
2189 * This set's the maximum bytes that can be added in entry.
2191 * @param obj The entry object
2192 * @param max_no_of_bytes Maximum number of bytes entry can have.
2197 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2199 Widget_Data *wd = elm_widget_data_get(obj);
2201 wd->max_no_of_bytes = max_no_of_bytes;
2202 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2203 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2208 * This sets the entry object to password mode. All text entered
2209 * and/or displayed within the widget will be replaced with asterisks (*).
2211 * @param obj The entry object
2212 * @param password If true, password mode is enabled.
2217 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2219 ELM_CHECK_WIDTYPE(obj, widtype);
2220 Widget_Data *wd = elm_widget_data_get(obj);
2221 Ecore_IMF_Context *ic;
2224 if (wd->password == password) return;
2225 wd->password = password;
2226 wd->single_line = EINA_TRUE;
2227 wd->linewrap = EINA_FALSE;
2228 wd->char_linewrap = EINA_FALSE;
2229 if (_elm_config->password_show_last_character)
2230 wd->show_last_character = EINA_TRUE;
2231 t = eina_stringshare_add(elm_entry_entry_get(obj));
2232 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2233 elm_entry_entry_set(obj, t);
2239 elm_entry_autoperiod_set(obj, EINA_FALSE);
2242 if (wd->autocapital)
2244 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2248 ic = elm_entry_imf_context_get(obj);
2251 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2254 eina_stringshare_del(t);
2259 * This set's the entry in password mode with out masking the last character entered by user,
2260 * and later masking the character after 2 seconds.
2262 * @param obj The entry object
2263 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2269 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2271 Widget_Data *wd = elm_widget_data_get(obj);
2274 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2275 wd->show_last_character = show_last_character;
2276 wd->password = show_last_character;
2277 wd->single_line = EINA_TRUE;
2278 wd->linewrap = EINA_FALSE;
2279 wd->char_linewrap = EINA_FALSE;
2280 t = eina_stringshare_add(elm_entry_entry_get(obj));
2281 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2282 elm_entry_entry_set(obj, t);
2283 eina_stringshare_del(t);
2288 * This returns whether password mode is enabled.
2289 * See also elm_entry_password_set().
2291 * @param obj The entry object
2292 * @return If true, the entry is set to display all characters
2298 elm_entry_password_get(const Evas_Object *obj)
2300 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2301 Widget_Data *wd = elm_widget_data_get(obj);
2302 if (!wd) return EINA_FALSE;
2303 return wd->password;
2307 * This sets the text displayed within the entry to @p entry.
2309 * @param obj The entry object
2310 * @param entry The text to be displayed
2315 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2317 ELM_CHECK_WIDTYPE(obj, widtype);
2318 Widget_Data *wd = elm_widget_data_get(obj);
2320 if (!entry) entry = "";
2321 if(wd->max_no_of_bytes)
2323 int len = strlen(entry);
2324 if(len > wd->max_no_of_bytes)
2326 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2330 edje_object_part_text_set(wd->ent, "elm.text", entry);
2331 if (wd->text) eina_stringshare_del(wd->text);
2333 wd->changed = EINA_TRUE;
2338 * This returns the text currently shown in object @p entry.
2339 * See also elm_entry_entry_set().
2341 * @param obj The entry object
2342 * @return The currently displayed text or NULL on failure
2347 elm_entry_entry_get(const Evas_Object *obj)
2349 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2350 Widget_Data *wd = elm_widget_data_get(obj);
2352 if (!wd) return NULL;
2354 if ((wd->text)&&(wd->password))
2355 return elm_entry_markup_to_utf8(wd->text);
2357 if (wd->text) return wd->text;
2358 text = edje_object_part_text_get(wd->ent, "elm.text");
2361 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2364 eina_stringshare_replace(&wd->text, text);
2365 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2370 * This returns all selected text within the entry.
2372 * @param obj The entry object
2373 * @return The selected text within the entry or NULL on failure
2378 elm_entry_selection_get(const Evas_Object *obj)
2380 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2381 Widget_Data *wd = elm_widget_data_get(obj);
2382 if (!wd) return NULL;
2383 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2387 * This inserts text in @p entry at the beginning of the entry
2390 * @param obj The entry object
2391 * @param entry The text to insert
2396 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2398 ELM_CHECK_WIDTYPE(obj, widtype);
2399 Widget_Data *wd = elm_widget_data_get(obj);
2401 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2403 if (cnpwidgetdata == obj)
2404 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2406 wd->changed = EINA_TRUE;
2411 * This enables word line wrapping in the entry object. It is the opposite
2412 * of elm_entry_single_line_set(). Additionally, setting this disables
2413 * character line wrapping.
2414 * See also elm_entry_line_char_wrap_set().
2416 * @param obj The entry object
2417 * @param wrap If true, the entry will be wrapped once it reaches the end
2418 * of the object. Wrapping will occur at the end of the word before the end of the
2424 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2426 ELM_CHECK_WIDTYPE(obj, widtype);
2427 Widget_Data *wd = elm_widget_data_get(obj);
2430 if (wd->linewrap == wrap) return;
2431 wd->linewrap = wrap;
2433 wd->char_linewrap = EINA_FALSE;
2434 t = eina_stringshare_add(elm_entry_entry_get(obj));
2435 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2436 elm_entry_entry_set(obj, t);
2437 eina_stringshare_del(t);
2442 * Set wrap width of the entry
2444 * @param obj The entry object
2445 * @param w The wrap width in pixels at a minimum where words need to wrap
2449 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2451 Widget_Data *wd = elm_widget_data_get(obj);
2452 if (wd->wrap_w == w) return;
2458 * get wrap width of the entry
2460 * @param obj The entry object
2461 * @return The wrap width in pixels at a minimum where words need to wrap
2465 elm_entry_wrap_width_get(const Evas_Object *obj)
2467 Widget_Data *wd = elm_widget_data_get(obj);
2472 * This enables character line wrapping in the entry object. It is the opposite
2473 * of elm_entry_single_line_set(). Additionally, setting this disables
2474 * word line wrapping.
2475 * See also elm_entry_line_wrap_set().
2477 * @param obj The entry object
2478 * @param wrap If true, the entry will be wrapped once it reaches the end
2479 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2484 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2486 ELM_CHECK_WIDTYPE(obj, widtype);
2487 Widget_Data *wd = elm_widget_data_get(obj);
2490 if (wd->char_linewrap == wrap) return;
2491 wd->char_linewrap = wrap;
2492 if(wd->char_linewrap)
2493 wd->linewrap = EINA_FALSE;
2494 t = eina_stringshare_add(elm_entry_entry_get(obj));
2495 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2496 elm_entry_entry_set(obj, t);
2497 eina_stringshare_del(t);
2502 * This sets the editable attribute of the entry.
2504 * @param obj The entry object
2505 * @param editable If true, the entry will be editable by the user.
2506 * If false, it will be set to the disabled state.
2511 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2513 ELM_CHECK_WIDTYPE(obj, widtype);
2514 Widget_Data *wd = elm_widget_data_get(obj);
2517 if (wd->editable == editable) return;
2518 wd->editable = editable;
2519 t = eina_stringshare_add(elm_entry_entry_get(obj));
2520 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2521 elm_entry_entry_set(obj, t);
2522 eina_stringshare_del(t);
2525 #ifdef HAVE_ELEMENTARY_X
2527 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2529 elm_drop_target_del(obj);
2534 * This gets the editable attribute of the entry.
2535 * See also elm_entry_editable_set().
2537 * @param obj The entry object
2538 * @return If true, the entry is editable by the user.
2539 * If false, it is not editable by the user
2544 elm_entry_editable_get(const Evas_Object *obj)
2546 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2547 Widget_Data *wd = elm_widget_data_get(obj);
2548 if (!wd) return EINA_FALSE;
2549 return wd->editable;
2553 * This drops any existing text selection within the entry.
2555 * @param obj The entry object
2560 elm_entry_select_none(Evas_Object *obj)
2562 ELM_CHECK_WIDTYPE(obj, widtype);
2563 Widget_Data *wd = elm_widget_data_get(obj);
2567 wd->selmode = EINA_FALSE;
2568 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2569 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2571 wd->have_selection = EINA_FALSE;
2572 edje_object_part_text_select_none(wd->ent, "elm.text");
2576 * This selects all text within the entry.
2578 * @param obj The entry object
2583 elm_entry_select_all(Evas_Object *obj)
2585 ELM_CHECK_WIDTYPE(obj, widtype);
2586 Widget_Data *wd = elm_widget_data_get(obj);
2590 wd->selmode = EINA_FALSE;
2591 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2592 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2594 wd->have_selection = EINA_TRUE;
2595 edje_object_part_text_select_all(wd->ent, "elm.text");
2599 * This moves the cursor one place to the right within the entry.
2601 * @param obj The entry object
2602 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2607 elm_entry_cursor_next(Evas_Object *obj)
2609 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2610 Widget_Data *wd = elm_widget_data_get(obj);
2611 if (!wd) return EINA_FALSE;
2612 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2616 * This moves the cursor one place to the left within the entry.
2618 * @param obj The entry object
2619 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2624 elm_entry_cursor_prev(Evas_Object *obj)
2626 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2627 Widget_Data *wd = elm_widget_data_get(obj);
2628 if (!wd) return EINA_FALSE;
2629 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2633 * This moves the cursor one line up within the entry.
2635 * @param obj The entry object
2636 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2641 elm_entry_cursor_up(Evas_Object *obj)
2643 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2644 Widget_Data *wd = elm_widget_data_get(obj);
2645 if (!wd) return EINA_FALSE;
2646 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2650 * This moves the cursor one line down within the entry.
2652 * @param obj The entry object
2653 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2658 elm_entry_cursor_down(Evas_Object *obj)
2660 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2661 Widget_Data *wd = elm_widget_data_get(obj);
2662 if (!wd) return EINA_FALSE;
2663 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2667 * This moves the cursor to the beginning of the entry.
2669 * @param obj The entry object
2674 elm_entry_cursor_begin_set(Evas_Object *obj)
2676 ELM_CHECK_WIDTYPE(obj, widtype);
2677 Widget_Data *wd = elm_widget_data_get(obj);
2679 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2683 * This moves the cursor to the end of the entry.
2685 * @param obj The entry object
2690 elm_entry_cursor_end_set(Evas_Object *obj)
2692 ELM_CHECK_WIDTYPE(obj, widtype);
2693 Widget_Data *wd = elm_widget_data_get(obj);
2695 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2699 * This moves the cursor to the beginning of the current line.
2701 * @param obj The entry object
2706 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2708 ELM_CHECK_WIDTYPE(obj, widtype);
2709 Widget_Data *wd = elm_widget_data_get(obj);
2711 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2715 * This moves the cursor to the end of the current line.
2717 * @param obj The entry object
2722 elm_entry_cursor_line_end_set(Evas_Object *obj)
2724 ELM_CHECK_WIDTYPE(obj, widtype);
2725 Widget_Data *wd = elm_widget_data_get(obj);
2727 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2731 * This begins a selection within the entry as though
2732 * the user were holding down the mouse button to make a selection.
2734 * @param obj The entry object
2739 elm_entry_cursor_selection_begin(Evas_Object *obj)
2741 ELM_CHECK_WIDTYPE(obj, widtype);
2742 Widget_Data *wd = elm_widget_data_get(obj);
2744 edje_object_part_text_select_begin(wd->ent, "elm.text");
2748 * This ends a selection within the entry as though
2749 * the user had just released the mouse button while making a selection.
2751 * @param obj The entry object
2756 elm_entry_cursor_selection_end(Evas_Object *obj)
2758 ELM_CHECK_WIDTYPE(obj, widtype);
2759 Widget_Data *wd = elm_widget_data_get(obj);
2761 edje_object_part_text_select_extend(wd->ent, "elm.text");
2765 * TODO: fill this in
2767 * @param obj The entry object
2768 * @return TODO: fill this in
2773 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2775 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2776 Widget_Data *wd = elm_widget_data_get(obj);
2777 if (!wd) return EINA_FALSE;
2778 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2782 * This returns whether the cursor is visible.
2784 * @param obj The entry object
2785 * @return If true, the cursor is visible.
2790 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2792 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2793 Widget_Data *wd = elm_widget_data_get(obj);
2794 if (!wd) return EINA_FALSE;
2795 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2799 * TODO: fill this in
2801 * @param obj The entry object
2802 * @return TODO: fill this in
2807 elm_entry_cursor_content_get(const Evas_Object *obj)
2809 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2810 Widget_Data *wd = elm_widget_data_get(obj);
2811 if (!wd) return NULL;
2812 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2816 * This executes a "cut" action on the selected text in the entry.
2818 * @param obj The entry object
2823 elm_entry_selection_cut(Evas_Object *obj)
2825 ELM_CHECK_WIDTYPE(obj, widtype);
2826 Widget_Data *wd = elm_widget_data_get(obj);
2828 _cut(obj, NULL, NULL);
2832 * This executes a "copy" action on the selected text in the entry.
2834 * @param obj The entry object
2839 elm_entry_selection_copy(Evas_Object *obj)
2841 ELM_CHECK_WIDTYPE(obj, widtype);
2842 Widget_Data *wd = elm_widget_data_get(obj);
2844 _copy(obj, NULL, NULL);
2848 * This executes a "paste" action in the entry.
2850 * @param obj The entry object
2855 elm_entry_selection_paste(Evas_Object *obj)
2857 ELM_CHECK_WIDTYPE(obj, widtype);
2858 Widget_Data *wd = elm_widget_data_get(obj);
2860 _paste(obj, NULL, NULL);
2864 * This clears and frees the items in a entry's contextual (right click) menu.
2866 * @param obj The entry object
2871 elm_entry_context_menu_clear(Evas_Object *obj)
2873 ELM_CHECK_WIDTYPE(obj, widtype);
2874 Widget_Data *wd = elm_widget_data_get(obj);
2875 Elm_Entry_Context_Menu_Item *it;
2877 EINA_LIST_FREE(wd->items, it)
2879 eina_stringshare_del(it->label);
2880 eina_stringshare_del(it->icon_file);
2881 eina_stringshare_del(it->icon_group);
2887 * This adds an item to the entry's contextual menu.
2889 * @param obj The entry object
2890 * @param label The item's text label
2891 * @param icon_file The item's icon file
2892 * @param icon_type The item's icon type
2893 * @param func The callback to execute when the item is clicked
2894 * @param data The data to associate with the item for related functions
2899 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)
2901 ELM_CHECK_WIDTYPE(obj, widtype);
2902 Widget_Data *wd = elm_widget_data_get(obj);
2903 Elm_Entry_Context_Menu_Item *it;
2905 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2907 wd->items = eina_list_append(wd->items, it);
2909 it->label = eina_stringshare_add(label);
2910 it->icon_file = eina_stringshare_add(icon_file);
2911 it->icon_type = icon_type;
2913 it->data = (void *)data;
2917 * This disables the entry's contextual (right click) menu.
2919 * @param obj The entry object
2920 * @param disabled If true, the menu is disabled
2925 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2927 ELM_CHECK_WIDTYPE(obj, widtype);
2928 Widget_Data *wd = elm_widget_data_get(obj);
2930 if (wd->context_menu == !disabled) return;
2931 wd->context_menu = !disabled;
2935 * This returns whether the entry's contextual (right click) menu is disabled.
2937 * @param obj The entry object
2938 * @return If true, the menu is disabled
2943 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2945 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2946 Widget_Data *wd = elm_widget_data_get(obj);
2947 if (!wd) return EINA_FALSE;
2948 return !wd->context_menu;
2952 * This appends a custom item provider to the list for that entry
2954 * This appends the given callback. The list is walked from beginning to end
2955 * with each function called given the item href string in the text. If the
2956 * function returns an object handle other than NULL (it should create an
2957 * and object to do this), then this object is used to replace that item. If
2958 * not the next provider is called until one provides an item object, or the
2959 * default provider in entry does.
2961 * @param obj The entry object
2962 * @param func The function called to provide the item object
2963 * @param data The data passed to @p func
2968 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2970 ELM_CHECK_WIDTYPE(obj, widtype);
2971 Widget_Data *wd = elm_widget_data_get(obj);
2974 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2978 wd->item_providers = eina_list_append(wd->item_providers, ip);
2982 * This prepends a custom item provider to the list for that entry
2984 * This prepends the given callback. See elm_entry_item_provider_append() for
2987 * @param obj The entry object
2988 * @param func The function called to provide the item object
2989 * @param data The data passed to @p func
2994 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2996 ELM_CHECK_WIDTYPE(obj, widtype);
2997 Widget_Data *wd = elm_widget_data_get(obj);
3000 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3004 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3008 * This removes a custom item provider to the list for that entry
3010 * This removes the given callback. See elm_entry_item_provider_append() for
3013 * @param obj The entry object
3014 * @param func The function called to provide the item object
3015 * @param data The data passed to @p func
3020 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3022 ELM_CHECK_WIDTYPE(obj, widtype);
3023 Widget_Data *wd = elm_widget_data_get(obj);
3025 Elm_Entry_Item_Provider *ip;
3028 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3030 if ((ip->func == func) && (ip->data == data))
3032 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3040 * This converts a markup (HTML-like) string into UTF-8.
3042 * @param s The string (in markup) to be converted
3043 * @return The converted string (in UTF-8)
3048 elm_entry_markup_to_utf8(const char *s)
3050 char *ss = _mkup_to_text(s);
3051 if (!ss) ss = strdup("");
3056 * This converts a UTF-8 string into markup (HTML-like).
3058 * @param s The string (in UTF-8) to be converted
3059 * @return The converted string (in markup)
3064 elm_entry_utf8_to_markup(const char *s)
3066 char *ss = _text_to_mkup(s);
3067 if (!ss) ss = strdup("");
3072 * Get the input method context in the entry widget
3074 * @param obj The entry object
3075 * @return The input method context
3079 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3081 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3082 Widget_Data *wd = elm_widget_data_get(obj);
3083 if (!wd || !wd->ent) return NULL;
3085 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3089 * Set whether entry should enable the return key on soft keyboard automatically
3091 * @param obj The entry object
3092 * @param on If true, entry enables the return key on soft keyboard automatically.
3097 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3099 ELM_CHECK_WIDTYPE(obj, widtype);
3100 Widget_Data *wd = elm_widget_data_get(obj);
3103 wd->autoreturnkey = on;
3104 _check_enable_returnkey(obj);
3108 * Set whether entry should support auto capitalization
3110 * @param obj The entry object
3111 * @param on If true, entry suports auto capitalization.
3116 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3118 ELM_CHECK_WIDTYPE(obj, widtype);
3119 Widget_Data *wd = elm_widget_data_get(obj);
3123 wd->autocapital = EINA_FALSE;
3125 wd->autocapital = autocap;
3127 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3128 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3129 wd->autocapital = EINA_FALSE;
3131 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3135 * Set whether entry should support auto period
3137 * @param obj The entry object
3138 * @param on If true, entry suports auto period.
3143 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3145 ELM_CHECK_WIDTYPE(obj, widtype);
3146 Widget_Data *wd = elm_widget_data_get(obj);
3150 wd->autoperiod = EINA_FALSE;
3152 wd->autoperiod = autoperiod;
3154 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3155 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3156 wd->autoperiod = EINA_FALSE;
3158 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3162 * Set the font size on the entry object
3164 * @param obj The entry object
3165 * @param size font size
3170 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3172 ELM_CHECK_WIDTYPE(obj, widtype);
3173 Widget_Data *wd = elm_widget_data_get(obj);
3174 Eina_Strbuf *fontbuf = NULL;
3179 t = eina_stringshare_add(elm_entry_entry_get(obj));
3180 fontbuf = eina_strbuf_new();
3181 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3183 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3185 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3187 elm_entry_entry_set(obj, t);
3191 eina_strbuf_free(fontbuf);
3192 eina_stringshare_del(t);
3196 * Set the text align on the entry object
3198 * @param obj The entry object
3199 * @param align align mode
3204 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3206 ELM_CHECK_WIDTYPE(obj, widtype);
3207 Widget_Data *wd = elm_widget_data_get(obj);
3212 t = eina_stringshare_add(elm_entry_entry_get(obj));
3214 if (len <= 0) return;
3216 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3217 elm_entry_entry_set(obj, t);
3221 eina_stringshare_del(t);
3225 * Set the text color on the entry object
3227 * @param obj The entry object
3228 * @param r Red property background color of The entry object
3229 * @param g Green property background color of The entry object
3230 * @param b Blue property background color of The entry object
3231 * @param a Alpha property background alpha of The entry object
3236 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3238 ELM_CHECK_WIDTYPE(obj, widtype);
3239 Widget_Data *wd = elm_widget_data_get(obj);
3240 Eina_Strbuf *colorbuf = NULL;
3245 t = eina_stringshare_add(elm_entry_entry_get(obj));
3247 if (len <= 0) return;
3248 colorbuf = eina_strbuf_new();
3249 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3251 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3253 elm_entry_entry_set(obj, t);
3257 eina_strbuf_free(colorbuf);
3258 eina_stringshare_del(t);
3263 * Set background color of the entry
3265 * @param obj The entry object
3266 * @param r Red property background color of The entry object
3267 * @param g Green property background color of The entry object
3268 * @param b Blue property background color of The entry object
3269 * @param a Alpha property background alpha of The entry object
3273 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3275 ELM_CHECK_WIDTYPE(obj, widtype);
3276 Widget_Data *wd = elm_widget_data_get(obj);
3277 evas_object_color_set(wd->bg, r, g, b, a);
3279 if (wd->bgcolor == EINA_FALSE)
3282 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3287 * Set the ellipsis behavior of the entry
3289 * @param obj The entry object
3290 * @param ellipsis To ellipsis text or not
3294 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3296 ELM_CHECK_WIDTYPE(obj, widtype);
3297 Widget_Data *wd = elm_widget_data_get(obj);
3298 if (wd->ellipsis == ellipsis) return;
3299 wd->ellipsis = ellipsis;
3305 * This sets the attribute to show the input panel automatically.
3307 * @param obj The entry object
3308 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3313 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3315 ELM_CHECK_WIDTYPE(obj, widtype);
3316 Widget_Data *wd = elm_widget_data_get(obj);
3319 wd->input_panel_enable = enabled;
3320 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3324 * Set the input panel layout of the entry
3326 * @param obj The entry object
3327 * @param layout the layout to set
3332 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3334 ELM_CHECK_WIDTYPE(obj, widtype);
3335 Widget_Data *wd = elm_widget_data_get(obj);
3338 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3341 wd->input_panel_layout = layout;
3343 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3346 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/