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 if (cnpwidgetdata == data)
1507 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1511 return ECORE_CALLBACK_PASS_ON;
1516 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1521 wd = elm_widget_data_get(obj);
1523 if (!wd) return EINA_FALSE;
1524 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1526 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1527 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1528 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1529 EDJE_CURSOR_MAIN,drop->x,drop->y);
1530 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1531 elm_entry_entry_insert(obj, drop->data);
1532 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1533 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1539 static Evas_Object *
1540 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1542 Widget_Data *wd = elm_widget_data_get(data);
1545 Elm_Entry_Item_Provider *ip;
1548 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1550 o = ip->func(ip->data, data, item);
1553 o = edje_object_add(evas_object_evas_get(data));
1554 if (!strncmp(item, "emoticon/", 9))
1555 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1557 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1562 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1564 char *curlocater, *starttag, *endtag;
1565 int firstindex = 0, foundflag = -1;
1567 curlocater = strstr(oldstring, key);
1570 starttag = curlocater;
1571 endtag = curlocater + strlen(key);
1572 if (endtag == NULL || *endtag != '=')
1578 firstindex = abs(oldstring - curlocater);
1579 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1580 *value = (char*)oldstring + firstindex;
1582 while (oldstring != starttag)
1584 if (*starttag == '>')
1589 if (*starttag == '<')
1593 if (starttag == NULL) break;
1596 while (NULL != endtag)
1607 if (endtag == NULL) break;
1610 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1620 if (foundflag == 1) return 0;
1626 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1628 const char *srcstring = NULL;
1629 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1630 char *curlocater, *replocater;
1631 char *starttag, *endtag;
1632 int tagtxtlen = 0, insertflag = 0;
1634 srcstring = eina_strbuf_string_get(srcbuf);
1635 curlocater = strstr(srcstring, key);
1637 if (curlocater == NULL)
1645 starttag = strchr(srcstring, '<');
1646 endtag = strchr(srcstring, '>');
1647 tagtxtlen = endtag - starttag;
1648 if (tagtxtlen <= 0) tagtxtlen = 0;
1649 if (starttag < curlocater && curlocater < endtag) break;
1650 if (endtag != NULL && endtag+1 != NULL)
1651 srcstring = endtag+1;
1654 } while (strlen(srcstring) > 1);
1656 if (starttag && endtag && tagtxtlen > strlen(key))
1658 repbuf = eina_strbuf_new();
1659 diffbuf = eina_strbuf_new();
1660 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1661 srcstring = eina_strbuf_string_get(repbuf);
1662 curlocater = strstr(srcstring, key);
1664 if (curlocater != NULL)
1666 replocater = curlocater + strlen(key) + 1;
1668 while (*replocater == ' ' || *replocater == '=')
1673 while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
1676 if (replocater-curlocater > strlen(key)+1)
1679 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1688 eina_strbuf_reset(repbuf);
1696 if (repbuf == NULL) repbuf = eina_strbuf_new();
1697 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1701 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1702 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1708 eina_strbuf_prepend(diffbuf, "<");
1709 eina_strbuf_append(diffbuf, ">");
1710 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1714 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1715 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1719 if (repbuf) eina_strbuf_free(repbuf);
1720 if (diffbuf) eina_strbuf_free(diffbuf);
1726 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1728 Eina_Strbuf *sharebuf = NULL;
1730 sharebuf = eina_strbuf_new();
1731 eina_strbuf_append(sharebuf, *srcstring);
1732 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1733 eina_stringshare_del(*srcstring);
1734 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1735 eina_strbuf_free(sharebuf);
1741 _is_width_over(Evas_Object *obj)
1743 Evas_Coord x, y, w, h;
1744 Evas_Coord vx, vy, vw, vh;
1745 Widget_Data *wd = elm_widget_data_get(obj);
1749 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1751 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1753 if (x >= 0 && y >= 0)
1756 if (4 < wd->wrap_w && w > wd->wrap_w)
1763 _reverse_ellipsis_entry(Evas_Object *obj)
1765 Widget_Data *wd = elm_widget_data_get(obj);
1766 int cur_fontsize = 0;
1767 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1768 char **kvalue = NULL;
1769 const char *minfont, *deffont, *maxfont;
1770 const char *ellipsis_string = "...";
1771 int minfontsize, maxfontsize, minshowcount;
1773 minshowcount = strlen(ellipsis_string) + 1;
1774 minfont = edje_object_data_get(wd->ent, "min_font_size");
1775 if (minfont) minfontsize = atoi(minfont);
1776 else minfontsize = 1;
1777 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1778 if (maxfont) maxfontsize = atoi(maxfont);
1779 else maxfontsize = 1;
1780 deffont = edje_object_data_get(wd->ent, "default_font_size");
1781 if (deffont) cur_fontsize = atoi(deffont);
1782 else cur_fontsize = 1;
1783 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1784 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1786 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1788 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1791 txtbuf = eina_strbuf_new();
1792 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1794 if (cur_fontsize >= atoi(deffont))
1796 if (txtbuf) eina_strbuf_free(txtbuf);
1800 if (_is_width_over(obj) != 1)
1802 int rev_fontsize = cur_fontsize;
1806 if (rev_fontsize > atoi(deffont))
1809 if (fontbuf != NULL)
1811 eina_strbuf_free(fontbuf);
1814 fontbuf = eina_strbuf_new();
1815 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1816 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1817 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1819 eina_strbuf_free(fontbuf);
1821 } while (_is_width_over(obj) != 1);
1823 while (_is_width_over(obj))
1826 if (rev_fontsize < atoi(deffont))
1829 if (fontbuf != NULL)
1831 eina_strbuf_free(fontbuf);
1834 fontbuf = eina_strbuf_new();
1835 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1836 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1837 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1838 eina_strbuf_free(fontbuf);
1843 if (txtbuf) eina_strbuf_free(txtbuf);
1849 _ellipsis_entry_to_width(Evas_Object *obj)
1851 Widget_Data *wd = elm_widget_data_get(obj);
1852 int cur_fontsize = 0, len, jumpcount;
1853 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1854 char **kvalue = NULL;
1855 const char *minfont, *deffont, *maxfont;
1856 const char *ellipsis_string = "...";
1857 int minfontsize, maxfontsize, minshowcount;
1858 int i, tagend, cur_len;
1861 minshowcount = strlen(ellipsis_string) + 1;
1862 minfont = edje_object_data_get(wd->ent, "min_font_size");
1863 if (minfont) minfontsize = atoi(minfont);
1864 else minfontsize = 1;
1865 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1866 if (maxfont) maxfontsize = atoi(maxfont);
1867 else maxfontsize = 1;
1868 deffont = edje_object_data_get(wd->ent, "default_font_size");
1869 if (deffont) cur_fontsize = atoi(deffont);
1870 else cur_fontsize = 1;
1871 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1872 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1874 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1876 if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
1879 txtbuf = eina_strbuf_new();
1880 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1882 while (_is_width_over(obj))
1884 if (wd->ellipsis_threshold == 0)
1885 wd->ellipsis_threshold = _entry_length_get(obj);
1886 if (cur_fontsize > minfontsize)
1889 if (fontbuf != NULL)
1891 eina_strbuf_free(fontbuf);
1894 fontbuf = eina_strbuf_new();
1895 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1896 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1897 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1898 eina_strbuf_free(fontbuf);
1900 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1904 len = _entry_length_get(obj);
1905 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1906 cur_len = strlen(cur_str);
1908 for (i = 0; i < len; i++)
1910 if(cur_str[i] == '>' && cur_str[i+1] != NULL &&
1911 cur_str[i+1] != '<')
1918 while (jumpcount < len-strlen(ellipsis_string))
1920 cur_str = edje_object_part_text_get(wd->ent, "elm.text");
1924 eina_strbuf_free(txtbuf);
1927 txtbuf = eina_strbuf_new();
1928 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
1929 eina_strbuf_append(txtbuf, ellipsis_string);
1930 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
1931 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1932 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1934 if (_is_width_over(obj))
1942 if (txtbuf) eina_strbuf_free(txtbuf);
1947 static int _textinput_control_function(void *data,void *input_data)
1949 /*calculate character count*/
1950 Evas_Object *entry = (Evas_Object *)data;
1951 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
1954 size_t insert_text_len=0;
1955 char *text = edje_object_part_text_get(wd->ent, "elm.text");
1957 size_t remain_bytes;
1960 byte_len = strlen(text);/*no of bytes*/
1961 remain_bytes = wd->max_no_of_bytes-byte_len;
1962 sprintf(buf,"%d",remain_bytes);
1963 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
1966 insert_text = (char *)input_data;
1967 insert_text_len = strlen(insert_text);
1968 if(remain_bytes<insert_text_len)
1970 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1973 if(byte_len>=wd->max_no_of_bytes)
1975 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
1984 * This adds an entry to @p parent object.
1986 * @param parent The parent object
1987 * @return The new object or NULL if it cannot be created
1992 elm_entry_add(Evas_Object *parent)
1994 Evas_Object *obj, *top;
1998 wd = ELM_NEW(Widget_Data);
1999 e = evas_object_evas_get(parent);
2000 wd->bgcolor = EINA_FALSE;
2001 wd->bg = evas_object_rectangle_add(e);
2002 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2003 obj = elm_widget_add(e);
2004 ELM_SET_WIDTYPE(widtype, "entry");
2005 elm_widget_type_set(obj, "entry");
2006 elm_widget_sub_object_add(parent, obj);
2007 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2008 elm_widget_data_set(obj, wd);
2009 elm_widget_del_hook_set(obj, _del_hook);
2010 elm_widget_theme_hook_set(obj, _theme_hook);
2011 elm_widget_disable_hook_set(obj, _disable_hook);
2012 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2013 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2014 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2015 elm_widget_can_focus_set(obj, 1);
2016 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2017 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2020 wd->linewrap = EINA_TRUE;
2021 wd->ellipsis = EINA_FALSE;
2022 wd->char_linewrap= EINA_FALSE;
2023 wd->editable = EINA_TRUE;
2024 wd->disabled = EINA_FALSE;
2025 wd->context_menu = EINA_TRUE;
2027 wd->ellipsis_threshold = 0;
2029 wd->ent = edje_object_add(e);
2030 edje_object_item_provider_set(wd->ent, _get_item, obj);
2031 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2032 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2033 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2035 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2037 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2040 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2041 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2042 _signal_entry_changed, obj);
2043 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2044 _signal_handler_move_start, obj);
2045 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2046 _signal_handler_move_end, obj);
2047 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2048 _signal_selection_start, obj);
2049 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2050 _signal_selection_changed, obj);
2051 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2052 _signal_selection_cleared, obj);
2053 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2054 _signal_entry_paste_request, obj);
2055 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2056 _signal_entry_copy_notify, obj);
2057 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2058 _signal_entry_cut_notify, obj);
2059 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2060 _signal_cursor_changed, obj);
2061 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2062 _signal_anchor_down, obj);
2063 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2064 _signal_anchor_up, obj);
2065 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2066 _signal_anchor_move, obj);
2067 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2068 _signal_anchor_in, obj);
2069 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2070 _signal_anchor_out, obj);
2071 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2072 _signal_key_enter, obj);
2073 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2074 _signal_mouse_down, obj);
2075 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
2076 _signal_mouse_up, obj);
2077 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2078 _signal_mouse_double, obj);
2079 edje_object_part_text_set(wd->ent, "elm.text", "");
2080 elm_widget_resize_object_set(obj, wd->ent);
2083 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2085 #ifdef HAVE_ELEMENTARY_X
2086 top = elm_widget_top_get(obj);
2087 if ((top) && (elm_win_xwindow_get(top)))
2089 wd->sel_notify_handler =
2090 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2091 _event_selection_notify, obj);
2092 wd->sel_clear_handler =
2093 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2094 _event_selection_clear, obj);
2097 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2100 entries = eina_list_prepend(entries, obj);
2102 // module - find module for entry
2103 wd->api = _module(obj);
2104 // if found - hook in
2105 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2107 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2108 // TODO: and save some bytes, making descriptions per-class and not instance!
2109 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2113 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2115 ELM_CHECK_WIDTYPE(obj, widtype);
2116 Widget_Data *wd = elm_widget_data_get(obj);
2118 ext_mod->cancel = _cancel;
2119 ext_mod->copy = _copy;
2120 ext_mod->cut = _cut;
2121 ext_mod->paste = _paste;
2122 ext_mod->select = _select;
2123 ext_mod->selectall = NULL; /* to be implemented*/
2124 ext_mod->ent = wd->ent;
2125 ext_mod->items = wd->items;
2126 ext_mod->longpress_timer = wd->longpress_timer;
2127 ext_mod->editable = wd->editable;
2128 ext_mod->have_selection = wd->have_selection;
2129 ext_mod->password = wd->password;
2130 ext_mod->selmode = wd->selmode;
2131 ext_mod->cnpinit = _cnpinit;
2132 ext_mod->context_menu = wd->context_menu;
2136 * This sets the entry object not to line wrap. All input will
2137 * be on a single line, and the entry box will extend with user input.
2139 * @param obj The entry object
2140 * @param single_line If true, the text in the entry
2141 * will be on a single line.
2146 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2148 ELM_CHECK_WIDTYPE(obj, widtype);
2149 Widget_Data *wd = elm_widget_data_get(obj);
2151 Ecore_IMF_Context *ic;
2153 if (wd->single_line == single_line) return;
2154 wd->single_line = single_line;
2155 wd->linewrap = EINA_FALSE;
2156 wd->char_linewrap = EINA_FALSE;
2157 t = eina_stringshare_add(elm_entry_entry_get(obj));
2158 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2159 elm_entry_entry_set(obj, t);
2160 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2161 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2162 ic = elm_entry_imf_context_get(obj);
2165 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2168 eina_stringshare_del(t);
2173 * This returns true if the entry has been set to single line mode.
2174 * See also elm_entry_single_line_set().
2176 * @param obj The entry object
2177 * @return single_line If true, the text in the entry is set to display
2183 elm_entry_single_line_get(const Evas_Object *obj)
2185 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2186 Widget_Data *wd = elm_widget_data_get(obj);
2187 if (!wd) return EINA_FALSE;
2188 return wd->single_line;
2192 * This set's the maximum bytes that can be added in entry.
2194 * @param obj The entry object
2195 * @param max_no_of_bytes Maximum number of bytes entry can have.
2200 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2202 Widget_Data *wd = elm_widget_data_get(obj);
2204 wd->max_no_of_bytes = max_no_of_bytes;
2205 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2206 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2211 * This sets the entry object to password mode. All text entered
2212 * and/or displayed within the widget will be replaced with asterisks (*).
2214 * @param obj The entry object
2215 * @param password If true, password mode is enabled.
2220 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2222 ELM_CHECK_WIDTYPE(obj, widtype);
2223 Widget_Data *wd = elm_widget_data_get(obj);
2224 Ecore_IMF_Context *ic;
2227 if (wd->password == password) return;
2228 wd->password = password;
2229 wd->single_line = EINA_TRUE;
2230 wd->linewrap = EINA_FALSE;
2231 wd->char_linewrap = EINA_FALSE;
2232 if (_elm_config->password_show_last_character)
2233 wd->show_last_character = EINA_TRUE;
2234 t = eina_stringshare_add(elm_entry_entry_get(obj));
2235 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2236 elm_entry_entry_set(obj, t);
2242 elm_entry_autoperiod_set(obj, EINA_FALSE);
2245 if (wd->autocapital)
2247 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2251 ic = elm_entry_imf_context_get(obj);
2254 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2257 eina_stringshare_del(t);
2262 * This set's the entry in password mode with out masking the last character entered by user,
2263 * and later masking the character after 2 seconds.
2265 * @param obj The entry object
2266 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2272 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2274 Widget_Data *wd = elm_widget_data_get(obj);
2277 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2278 wd->show_last_character = show_last_character;
2279 wd->password = show_last_character;
2280 wd->single_line = EINA_TRUE;
2281 wd->linewrap = EINA_FALSE;
2282 wd->char_linewrap = EINA_FALSE;
2283 t = eina_stringshare_add(elm_entry_entry_get(obj));
2284 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2285 elm_entry_entry_set(obj, t);
2286 eina_stringshare_del(t);
2291 * This returns whether password mode is enabled.
2292 * See also elm_entry_password_set().
2294 * @param obj The entry object
2295 * @return If true, the entry is set to display all characters
2301 elm_entry_password_get(const Evas_Object *obj)
2303 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2304 Widget_Data *wd = elm_widget_data_get(obj);
2305 if (!wd) return EINA_FALSE;
2306 return wd->password;
2310 * This sets the text displayed within the entry to @p entry.
2312 * @param obj The entry object
2313 * @param entry The text to be displayed
2318 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2320 ELM_CHECK_WIDTYPE(obj, widtype);
2321 Widget_Data *wd = elm_widget_data_get(obj);
2323 if (!entry) entry = "";
2324 if(wd->max_no_of_bytes)
2326 int len = strlen(entry);
2327 if(len > wd->max_no_of_bytes)
2329 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2333 edje_object_part_text_set(wd->ent, "elm.text", entry);
2334 if (wd->text) eina_stringshare_del(wd->text);
2336 wd->changed = EINA_TRUE;
2341 * This returns the text currently shown in object @p entry.
2342 * See also elm_entry_entry_set().
2344 * @param obj The entry object
2345 * @return The currently displayed text or NULL on failure
2350 elm_entry_entry_get(const Evas_Object *obj)
2352 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2353 Widget_Data *wd = elm_widget_data_get(obj);
2355 if (!wd) return NULL;
2357 if ((wd->text)&&(wd->password))
2358 return elm_entry_markup_to_utf8(wd->text);
2360 if (wd->text) return wd->text;
2361 text = edje_object_part_text_get(wd->ent, "elm.text");
2364 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2367 eina_stringshare_replace(&wd->text, text);
2368 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2373 * This returns all selected text within the entry.
2375 * @param obj The entry object
2376 * @return The selected text within the entry or NULL on failure
2381 elm_entry_selection_get(const Evas_Object *obj)
2383 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2384 Widget_Data *wd = elm_widget_data_get(obj);
2385 if (!wd) return NULL;
2386 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2390 * This inserts text in @p entry at the beginning of the entry
2393 * @param obj The entry object
2394 * @param entry The text to insert
2399 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2401 ELM_CHECK_WIDTYPE(obj, widtype);
2402 Widget_Data *wd = elm_widget_data_get(obj);
2404 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2406 if (cnpwidgetdata == obj)
2407 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2409 wd->changed = EINA_TRUE;
2414 * This enables word line wrapping in the entry object. It is the opposite
2415 * of elm_entry_single_line_set(). Additionally, setting this disables
2416 * character line wrapping.
2417 * See also elm_entry_line_char_wrap_set().
2419 * @param obj The entry object
2420 * @param wrap If true, the entry will be wrapped once it reaches the end
2421 * of the object. Wrapping will occur at the end of the word before the end of the
2427 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2429 ELM_CHECK_WIDTYPE(obj, widtype);
2430 Widget_Data *wd = elm_widget_data_get(obj);
2433 if (wd->linewrap == wrap) return;
2434 wd->linewrap = wrap;
2436 wd->char_linewrap = EINA_FALSE;
2437 t = eina_stringshare_add(elm_entry_entry_get(obj));
2438 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2439 elm_entry_entry_set(obj, t);
2440 eina_stringshare_del(t);
2445 * Set wrap width of the entry
2447 * @param obj The entry object
2448 * @param w The wrap width in pixels at a minimum where words need to wrap
2452 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2454 Widget_Data *wd = elm_widget_data_get(obj);
2455 if (wd->wrap_w == w) return;
2461 * get wrap width of the entry
2463 * @param obj The entry object
2464 * @return The wrap width in pixels at a minimum where words need to wrap
2468 elm_entry_wrap_width_get(const Evas_Object *obj)
2470 Widget_Data *wd = elm_widget_data_get(obj);
2475 * This enables character line wrapping in the entry object. It is the opposite
2476 * of elm_entry_single_line_set(). Additionally, setting this disables
2477 * word line wrapping.
2478 * See also elm_entry_line_wrap_set().
2480 * @param obj The entry object
2481 * @param wrap If true, the entry will be wrapped once it reaches the end
2482 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2487 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2489 ELM_CHECK_WIDTYPE(obj, widtype);
2490 Widget_Data *wd = elm_widget_data_get(obj);
2493 if (wd->char_linewrap == wrap) return;
2494 wd->char_linewrap = wrap;
2495 if(wd->char_linewrap)
2496 wd->linewrap = EINA_FALSE;
2497 t = eina_stringshare_add(elm_entry_entry_get(obj));
2498 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2499 elm_entry_entry_set(obj, t);
2500 eina_stringshare_del(t);
2505 * This sets the editable attribute of the entry.
2507 * @param obj The entry object
2508 * @param editable If true, the entry will be editable by the user.
2509 * If false, it will be set to the disabled state.
2514 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2516 ELM_CHECK_WIDTYPE(obj, widtype);
2517 Widget_Data *wd = elm_widget_data_get(obj);
2520 if (wd->editable == editable) return;
2521 wd->editable = editable;
2522 t = eina_stringshare_add(elm_entry_entry_get(obj));
2523 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2524 elm_entry_entry_set(obj, t);
2525 eina_stringshare_del(t);
2528 #ifdef HAVE_ELEMENTARY_X
2530 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2532 elm_drop_target_del(obj);
2537 * This gets the editable attribute of the entry.
2538 * See also elm_entry_editable_set().
2540 * @param obj The entry object
2541 * @return If true, the entry is editable by the user.
2542 * If false, it is not editable by the user
2547 elm_entry_editable_get(const Evas_Object *obj)
2549 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2550 Widget_Data *wd = elm_widget_data_get(obj);
2551 if (!wd) return EINA_FALSE;
2552 return wd->editable;
2556 * This drops any existing text selection within the entry.
2558 * @param obj The entry object
2563 elm_entry_select_none(Evas_Object *obj)
2565 ELM_CHECK_WIDTYPE(obj, widtype);
2566 Widget_Data *wd = elm_widget_data_get(obj);
2570 wd->selmode = EINA_FALSE;
2571 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2572 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2574 wd->have_selection = EINA_FALSE;
2575 edje_object_part_text_select_none(wd->ent, "elm.text");
2579 * This selects all text within the entry.
2581 * @param obj The entry object
2586 elm_entry_select_all(Evas_Object *obj)
2588 ELM_CHECK_WIDTYPE(obj, widtype);
2589 Widget_Data *wd = elm_widget_data_get(obj);
2593 wd->selmode = EINA_FALSE;
2594 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2595 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2597 wd->have_selection = EINA_TRUE;
2598 edje_object_part_text_select_all(wd->ent, "elm.text");
2602 * This moves the cursor one place to the right within the entry.
2604 * @param obj The entry object
2605 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2610 elm_entry_cursor_next(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 edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2619 * This moves the cursor one place to the left within the entry.
2621 * @param obj The entry object
2622 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2627 elm_entry_cursor_prev(Evas_Object *obj)
2629 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2630 Widget_Data *wd = elm_widget_data_get(obj);
2631 if (!wd) return EINA_FALSE;
2632 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2636 * This moves the cursor one line up within the entry.
2638 * @param obj The entry object
2639 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2644 elm_entry_cursor_up(Evas_Object *obj)
2646 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2647 Widget_Data *wd = elm_widget_data_get(obj);
2648 if (!wd) return EINA_FALSE;
2649 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2653 * This moves the cursor one line down within the entry.
2655 * @param obj The entry object
2656 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2661 elm_entry_cursor_down(Evas_Object *obj)
2663 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2664 Widget_Data *wd = elm_widget_data_get(obj);
2665 if (!wd) return EINA_FALSE;
2666 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2670 * This moves the cursor to the beginning of the entry.
2672 * @param obj The entry object
2677 elm_entry_cursor_begin_set(Evas_Object *obj)
2679 ELM_CHECK_WIDTYPE(obj, widtype);
2680 Widget_Data *wd = elm_widget_data_get(obj);
2682 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2686 * This moves the cursor to the end of the entry.
2688 * @param obj The entry object
2693 elm_entry_cursor_end_set(Evas_Object *obj)
2695 ELM_CHECK_WIDTYPE(obj, widtype);
2696 Widget_Data *wd = elm_widget_data_get(obj);
2698 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2702 * This moves the cursor to the beginning of the current line.
2704 * @param obj The entry object
2709 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2711 ELM_CHECK_WIDTYPE(obj, widtype);
2712 Widget_Data *wd = elm_widget_data_get(obj);
2714 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2718 * This moves the cursor to the end of the current line.
2720 * @param obj The entry object
2725 elm_entry_cursor_line_end_set(Evas_Object *obj)
2727 ELM_CHECK_WIDTYPE(obj, widtype);
2728 Widget_Data *wd = elm_widget_data_get(obj);
2730 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2734 * This begins a selection within the entry as though
2735 * the user were holding down the mouse button to make a selection.
2737 * @param obj The entry object
2742 elm_entry_cursor_selection_begin(Evas_Object *obj)
2744 ELM_CHECK_WIDTYPE(obj, widtype);
2745 Widget_Data *wd = elm_widget_data_get(obj);
2747 edje_object_part_text_select_begin(wd->ent, "elm.text");
2751 * This ends a selection within the entry as though
2752 * the user had just released the mouse button while making a selection.
2754 * @param obj The entry object
2759 elm_entry_cursor_selection_end(Evas_Object *obj)
2761 ELM_CHECK_WIDTYPE(obj, widtype);
2762 Widget_Data *wd = elm_widget_data_get(obj);
2764 edje_object_part_text_select_extend(wd->ent, "elm.text");
2768 * TODO: fill this in
2770 * @param obj The entry object
2771 * @return TODO: fill this in
2776 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2778 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2779 Widget_Data *wd = elm_widget_data_get(obj);
2780 if (!wd) return EINA_FALSE;
2781 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2785 * This returns whether the cursor is visible.
2787 * @param obj The entry object
2788 * @return If true, the cursor is visible.
2793 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2795 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2796 Widget_Data *wd = elm_widget_data_get(obj);
2797 if (!wd) return EINA_FALSE;
2798 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2802 * TODO: fill this in
2804 * @param obj The entry object
2805 * @return TODO: fill this in
2810 elm_entry_cursor_content_get(const Evas_Object *obj)
2812 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2813 Widget_Data *wd = elm_widget_data_get(obj);
2814 if (!wd) return NULL;
2815 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2819 * This executes a "cut" action on the selected text in the entry.
2821 * @param obj The entry object
2826 elm_entry_selection_cut(Evas_Object *obj)
2828 ELM_CHECK_WIDTYPE(obj, widtype);
2829 Widget_Data *wd = elm_widget_data_get(obj);
2831 _cut(obj, NULL, NULL);
2835 * This executes a "copy" action on the selected text in the entry.
2837 * @param obj The entry object
2842 elm_entry_selection_copy(Evas_Object *obj)
2844 ELM_CHECK_WIDTYPE(obj, widtype);
2845 Widget_Data *wd = elm_widget_data_get(obj);
2847 _copy(obj, NULL, NULL);
2851 * This executes a "paste" action in the entry.
2853 * @param obj The entry object
2858 elm_entry_selection_paste(Evas_Object *obj)
2860 ELM_CHECK_WIDTYPE(obj, widtype);
2861 Widget_Data *wd = elm_widget_data_get(obj);
2863 _paste(obj, NULL, NULL);
2867 * This clears and frees the items in a entry's contextual (right click) menu.
2869 * @param obj The entry object
2874 elm_entry_context_menu_clear(Evas_Object *obj)
2876 ELM_CHECK_WIDTYPE(obj, widtype);
2877 Widget_Data *wd = elm_widget_data_get(obj);
2878 Elm_Entry_Context_Menu_Item *it;
2880 EINA_LIST_FREE(wd->items, it)
2882 eina_stringshare_del(it->label);
2883 eina_stringshare_del(it->icon_file);
2884 eina_stringshare_del(it->icon_group);
2890 * This adds an item to the entry's contextual menu.
2892 * @param obj The entry object
2893 * @param label The item's text label
2894 * @param icon_file The item's icon file
2895 * @param icon_type The item's icon type
2896 * @param func The callback to execute when the item is clicked
2897 * @param data The data to associate with the item for related functions
2902 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)
2904 ELM_CHECK_WIDTYPE(obj, widtype);
2905 Widget_Data *wd = elm_widget_data_get(obj);
2906 Elm_Entry_Context_Menu_Item *it;
2908 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
2910 wd->items = eina_list_append(wd->items, it);
2912 it->label = eina_stringshare_add(label);
2913 it->icon_file = eina_stringshare_add(icon_file);
2914 it->icon_type = icon_type;
2916 it->data = (void *)data;
2920 * This disables the entry's contextual (right click) menu.
2922 * @param obj The entry object
2923 * @param disabled If true, the menu is disabled
2928 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
2930 ELM_CHECK_WIDTYPE(obj, widtype);
2931 Widget_Data *wd = elm_widget_data_get(obj);
2933 if (wd->context_menu == !disabled) return;
2934 wd->context_menu = !disabled;
2938 * This returns whether the entry's contextual (right click) menu is disabled.
2940 * @param obj The entry object
2941 * @return If true, the menu is disabled
2946 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
2948 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2949 Widget_Data *wd = elm_widget_data_get(obj);
2950 if (!wd) return EINA_FALSE;
2951 return !wd->context_menu;
2955 * This appends a custom item provider to the list for that entry
2957 * This appends the given callback. The list is walked from beginning to end
2958 * with each function called given the item href string in the text. If the
2959 * function returns an object handle other than NULL (it should create an
2960 * and object to do this), then this object is used to replace that item. If
2961 * not the next provider is called until one provides an item object, or the
2962 * default provider in entry does.
2964 * @param obj The entry object
2965 * @param func The function called to provide the item object
2966 * @param data The data passed to @p func
2971 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2973 ELM_CHECK_WIDTYPE(obj, widtype);
2974 Widget_Data *wd = elm_widget_data_get(obj);
2977 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
2981 wd->item_providers = eina_list_append(wd->item_providers, ip);
2985 * This prepends a custom item provider to the list for that entry
2987 * This prepends the given callback. See elm_entry_item_provider_append() for
2990 * @param obj The entry object
2991 * @param func The function called to provide the item object
2992 * @param data The data passed to @p func
2997 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
2999 ELM_CHECK_WIDTYPE(obj, widtype);
3000 Widget_Data *wd = elm_widget_data_get(obj);
3003 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3007 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3011 * This removes a custom item provider to the list for that entry
3013 * This removes the given callback. See elm_entry_item_provider_append() for
3016 * @param obj The entry object
3017 * @param func The function called to provide the item object
3018 * @param data The data passed to @p func
3023 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3025 ELM_CHECK_WIDTYPE(obj, widtype);
3026 Widget_Data *wd = elm_widget_data_get(obj);
3028 Elm_Entry_Item_Provider *ip;
3031 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3033 if ((ip->func == func) && (ip->data == data))
3035 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3043 * This converts a markup (HTML-like) string into UTF-8.
3045 * @param s The string (in markup) to be converted
3046 * @return The converted string (in UTF-8)
3051 elm_entry_markup_to_utf8(const char *s)
3053 char *ss = _mkup_to_text(s);
3054 if (!ss) ss = strdup("");
3059 * This converts a UTF-8 string into markup (HTML-like).
3061 * @param s The string (in UTF-8) to be converted
3062 * @return The converted string (in markup)
3067 elm_entry_utf8_to_markup(const char *s)
3069 char *ss = _text_to_mkup(s);
3070 if (!ss) ss = strdup("");
3075 * Get the input method context in the entry widget
3077 * @param obj The entry object
3078 * @return The input method context
3082 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3084 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3085 Widget_Data *wd = elm_widget_data_get(obj);
3086 if (!wd || !wd->ent) return NULL;
3088 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3092 * Set whether entry should enable the return key on soft keyboard automatically
3094 * @param obj The entry object
3095 * @param on If true, entry enables the return key on soft keyboard automatically.
3100 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3102 ELM_CHECK_WIDTYPE(obj, widtype);
3103 Widget_Data *wd = elm_widget_data_get(obj);
3106 wd->autoreturnkey = on;
3107 _check_enable_returnkey(obj);
3111 * Set whether entry should support auto capitalization
3113 * @param obj The entry object
3114 * @param on If true, entry suports auto capitalization.
3119 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3121 ELM_CHECK_WIDTYPE(obj, widtype);
3122 Widget_Data *wd = elm_widget_data_get(obj);
3126 wd->autocapital = EINA_FALSE;
3128 wd->autocapital = autocap;
3130 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3131 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3132 wd->autocapital = EINA_FALSE;
3134 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3138 * Set whether entry should support auto period
3140 * @param obj The entry object
3141 * @param on If true, entry suports auto period.
3146 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3148 ELM_CHECK_WIDTYPE(obj, widtype);
3149 Widget_Data *wd = elm_widget_data_get(obj);
3153 wd->autoperiod = EINA_FALSE;
3155 wd->autoperiod = autoperiod;
3157 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3158 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3159 wd->autoperiod = EINA_FALSE;
3161 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3165 * Set the font size on the entry object
3167 * @param obj The entry object
3168 * @param size font size
3173 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3175 ELM_CHECK_WIDTYPE(obj, widtype);
3176 Widget_Data *wd = elm_widget_data_get(obj);
3177 Eina_Strbuf *fontbuf = NULL;
3182 t = eina_stringshare_add(elm_entry_entry_get(obj));
3183 fontbuf = eina_strbuf_new();
3184 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3186 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3188 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3190 elm_entry_entry_set(obj, t);
3194 eina_strbuf_free(fontbuf);
3195 eina_stringshare_del(t);
3199 * Set the text align on the entry object
3201 * @param obj The entry object
3202 * @param align align mode
3207 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3209 ELM_CHECK_WIDTYPE(obj, widtype);
3210 Widget_Data *wd = elm_widget_data_get(obj);
3215 t = eina_stringshare_add(elm_entry_entry_get(obj));
3217 if (len <= 0) return;
3219 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3220 elm_entry_entry_set(obj, t);
3224 eina_stringshare_del(t);
3228 * Set the text color on the entry object
3230 * @param obj The entry object
3231 * @param r Red property background color of The entry object
3232 * @param g Green property background color of The entry object
3233 * @param b Blue property background color of The entry object
3234 * @param a Alpha property background alpha of The entry object
3239 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3241 ELM_CHECK_WIDTYPE(obj, widtype);
3242 Widget_Data *wd = elm_widget_data_get(obj);
3243 Eina_Strbuf *colorbuf = NULL;
3248 t = eina_stringshare_add(elm_entry_entry_get(obj));
3250 if (len <= 0) return;
3251 colorbuf = eina_strbuf_new();
3252 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3254 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3256 elm_entry_entry_set(obj, t);
3260 eina_strbuf_free(colorbuf);
3261 eina_stringshare_del(t);
3266 * Set background color of the entry
3268 * @param obj The entry object
3269 * @param r Red property background color of The entry object
3270 * @param g Green property background color of The entry object
3271 * @param b Blue property background color of The entry object
3272 * @param a Alpha property background alpha of The entry object
3276 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3278 ELM_CHECK_WIDTYPE(obj, widtype);
3279 Widget_Data *wd = elm_widget_data_get(obj);
3280 evas_object_color_set(wd->bg, r, g, b, a);
3282 if (wd->bgcolor == EINA_FALSE)
3285 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3290 * Set the ellipsis behavior of the entry
3292 * @param obj The entry object
3293 * @param ellipsis To ellipsis text or not
3297 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3299 ELM_CHECK_WIDTYPE(obj, widtype);
3300 Widget_Data *wd = elm_widget_data_get(obj);
3301 if (wd->ellipsis == ellipsis) return;
3302 wd->ellipsis = ellipsis;
3308 * This sets the attribute to show the input panel automatically.
3310 * @param obj The entry object
3311 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3316 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3318 ELM_CHECK_WIDTYPE(obj, widtype);
3319 Widget_Data *wd = elm_widget_data_get(obj);
3322 wd->input_panel_enable = enabled;
3323 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3327 * Set the input panel layout of the entry
3329 * @param obj The entry object
3330 * @param layout the layout to set
3335 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3337 ELM_CHECK_WIDTYPE(obj, widtype);
3338 Widget_Data *wd = elm_widget_data_get(obj);
3341 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3344 wd->input_panel_layout = layout;
3346 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3349 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/