2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
4 #include <Elementary.h>
6 #include "elm_module_priv.h"
8 * @defgroup Entry Entry
11 * An entry is a convenience widget which shows
12 * a box that the user can enter text into. Unlike a
13 * @ref Scrolled_Entry widget, entries DO NOT scroll with user
14 * input. Entry widgets are capable of expanding past the
15 * boundaries of the window, thus resizing the window to its
18 * You can also insert "items" in the entry with:
20 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
22 * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
23 * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
24 * supports a list of emoticon names by default. These are:
27 * - emoticon/angry-shout
28 * - emoticon/crazy-laugh
29 * - emoticon/evil-laugh
31 * - emoticon/goggle-smile
33 * - emoticon/grumpy-smile
35 * - emoticon/guilty-smile
37 * - emoticon/half-smile
38 * - emoticon/happy-panting
40 * - emoticon/indifferent
42 * - emoticon/knowing-grin
44 * - emoticon/little-bit-sorry
45 * - emoticon/love-lots
47 * - emoticon/minimal-smile
48 * - emoticon/not-happy
49 * - emoticon/not-impressed
51 * - emoticon/opensmile
54 * - emoticon/squint-laugh
55 * - emoticon/surprised
56 * - emoticon/suspicious
57 * - emoticon/tongue-dangling
58 * - emoticon/tongue-poke
61 * - emoticon/very-sorry
67 * These are built-in currently, but you can add your own item provieer that
68 * can create inlined objects in the text and fill the space allocated to the
69 * item with a custom object of your own.
71 * See the entry test for some more examples of use of this.
73 * Signals that you can add callbacks for are:
74 * - "changed" - The text within the entry was changed
75 * - "activated" - The entry has had editing finished and changes are to be committed (generally when enter key is pressed)
76 * - "press" - The entry has been clicked
77 * - "longpressed" - The entry has been clicked for a couple seconds
78 * - "clicked" - The entry has been clicked
79 * - "clicked,double" - The entry has been double clicked
80 * - "focused" - The entry has received focus
81 * - "unfocused" - The entry has lost focus
82 * - "selection,paste" - A paste action has occurred
83 * - "selection,copy" - A copy action has occurred
84 * - "selection,cut" - A cut action has occurred
85 * - "selection,start" - A selection has begun
86 * - "selection,changed" - The selection has changed
87 * - "selection,cleared" - The selection has been cleared
88 * - "cursor,changed" - The cursor has changed
89 * - "anchor,clicked" - The anchor has been clicked
92 typedef struct _Mod_Api Mod_Api;
94 typedef struct _Widget_Data Widget_Data;
95 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
100 Evas_Object *popup;/*copy paste UI - elm_popup*/
101 Evas_Object *ctxpopup;/*copy paste UI - elm_ctxpopup*/
103 Evas_Object *hoversel;
104 Ecore_Job *deferred_recalc_job;
105 Ecore_Event_Handler *sel_notify_handler;
106 Ecore_Event_Handler *sel_clear_handler;
107 Ecore_Timer *longpress_timer;
108 /* Only for clipboard */
112 int ellipsis_threshold;
114 Evas_Coord downx, downy;
115 Evas_Coord cx, cy, cw, ch;
117 Eina_List *item_providers;
118 Ecore_Job *hovdeljob;
119 Mod_Api *api; // module api if supplied
121 Eina_Bool changed : 1;
122 Eina_Bool linewrap : 1;
123 Eina_Bool char_linewrap : 1;
124 Eina_Bool single_line : 1;
125 Eina_Bool password : 1;
126 Eina_Bool show_last_character : 1;
127 Eina_Bool editable : 1;
128 Eina_Bool selection_asked : 1;
129 Eina_Bool have_selection : 1;
130 Eina_Bool selmode : 1;
131 Eina_Bool deferred_cur : 1;
132 Eina_Bool disabled : 1;
133 Eina_Bool double_clicked : 1;
134 Eina_Bool context_menu : 1;
135 Eina_Bool drag_selection_asked : 1;
136 Eina_Bool bgcolor : 1;
137 Eina_Bool ellipsis : 1;
138 Eina_Bool autoreturnkey : 1;
139 Eina_Bool input_panel_enable : 1;
140 Eina_Bool autocapital : 1;
141 Elm_Input_Panel_Layout input_panel_layout;
142 Eina_Bool autoperiod : 1;
145 struct _Elm_Entry_Item_Provider
147 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
151 static const char *widtype = NULL;
153 static Evas_Object *cnpwidgetdata = NULL;
156 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
157 static void _del_hook(Evas_Object *obj);
158 static void _theme_hook(Evas_Object *obj);
159 static void _disable_hook(Evas_Object *obj);
160 static void _sizing_eval(Evas_Object *obj);
161 static void _on_focus_hook(void *data, Evas_Object *obj);
162 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
163 static const char *_getbase(Evas_Object *obj);
164 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
165 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
166 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
167 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
168 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
169 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
170 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
171 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
172 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
173 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
174 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
175 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
176 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
177 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
178 static int _is_width_over(Evas_Object *obj);
179 static void _ellipsis_entry_to_width(Evas_Object *obj);
180 static void _reverse_ellipsis_entry(Evas_Object *obj);
181 static int _textinput_control_function(void *data,void *input_data);
182 static int _entry_length_get(Evas_Object *obj);
184 static const char SIG_CHANGED[] = "changed";
185 static const char SIG_ACTIVATED[] = "activated";
186 static const char SIG_PRESS[] = "press";
187 static const char SIG_LONGPRESSED[] = "longpressed";
188 static const char SIG_CLICKED[] = "clicked";
189 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
190 static const char SIG_FOCUSED[] = "focused";
191 static const char SIG_UNFOCUSED[] = "unfocused";
192 static const char SIG_SELECTION_PASTE[] = "selection,paste";
193 static const char SIG_SELECTION_COPY[] = "selection,copy";
194 static const char SIG_SELECTION_CUT[] = "selection,cut";
195 static const char SIG_SELECTION_START[] = "selection,start";
196 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
197 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
198 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
199 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
200 #ifdef HAVE_CONFORMANT_AUTOSCROLL
201 static const char SIG_IMPREGION_CHANGED[] = "impregion,changed";
203 static const Evas_Smart_Cb_Description _signals[] = {
207 {SIG_LONGPRESSED, ""},
209 {SIG_CLICKED_DOUBLE, ""},
212 {SIG_SELECTION_PASTE, ""},
213 {SIG_SELECTION_COPY, ""},
214 {SIG_SELECTION_CUT, ""},
215 {SIG_SELECTION_START, ""},
216 {SIG_SELECTION_CHANGED, ""},
217 {SIG_SELECTION_CLEARED, ""},
218 {SIG_CURSOR_CHANGED, ""},
219 {SIG_ANCHOR_CLICKED, ""},
223 static Eina_List *entries = NULL;
227 void (*obj_hook) (Evas_Object *obj);
228 void (*obj_unhook) (Evas_Object *obj);
229 void (*obj_longpress) (Evas_Object *obj);
230 void (*obj_hidemenu) (Evas_Object *obj);
231 void (*obj_mouseup) (Evas_Object *obj);
235 _module(Evas_Object *obj __UNUSED__)
237 static Elm_Module *m = NULL;
238 if (m) goto ok; // already found - just use
239 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
241 m->api = malloc(sizeof(Mod_Api));
242 if (!m->api) return NULL;
243 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
244 _elm_module_symbol_get(m, "obj_hook");
245 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
246 _elm_module_symbol_get(m, "obj_unhook");
247 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
248 _elm_module_symbol_get(m, "obj_longpress");
249 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
250 _elm_module_symbol_get(m, "obj_hidemenu");
251 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
252 _elm_module_symbol_get(m, "obj_mouseup");
253 ok: // ok - return api
258 _del_hook(Evas_Object *obj)
260 Widget_Data *wd = elm_widget_data_get(obj);
261 Elm_Entry_Context_Menu_Item *it;
262 Elm_Entry_Item_Provider *ip;
263 Evas_Object *parent_obj = obj;
264 Evas_Object *above = NULL;
266 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
267 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
269 /* added for locating parents as they were */
272 above = evas_object_data_get(parent_obj, "raise");
274 evas_object_stack_below(parent_obj, above);
275 parent_obj = elm_widget_parent_get(parent_obj);
278 entries = eina_list_remove(entries, obj);
279 #ifdef HAVE_ELEMENTARY_X
280 ecore_event_handler_del(wd->sel_notify_handler);
281 ecore_event_handler_del(wd->sel_clear_handler);
283 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
284 if (wd->text) eina_stringshare_del(wd->text);
285 if (wd->bg) evas_object_del(wd->bg);
286 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
287 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
288 EINA_LIST_FREE(wd->items, it)
290 eina_stringshare_del(it->label);
291 eina_stringshare_del(it->icon_file);
292 eina_stringshare_del(it->icon_group);
295 EINA_LIST_FREE(wd->item_providers, ip)
303 _theme_hook(Evas_Object *obj)
305 Widget_Data *wd = elm_widget_data_get(obj);
307 Ecore_IMF_Context *ic;
309 t = eina_stringshare_add(elm_entry_entry_get(obj));
310 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
311 elm_entry_entry_set(obj, t);
312 eina_stringshare_del(t);
313 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
314 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
315 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
316 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
318 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
321 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
328 _disable_hook(Evas_Object *obj)
330 Widget_Data *wd = elm_widget_data_get(obj);
332 if (elm_widget_disabled_get(obj))
334 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
335 wd->disabled = EINA_TRUE;
339 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
340 wd->disabled = EINA_FALSE;
345 _elm_win_recalc_job(void *data)
347 Widget_Data *wd = elm_widget_data_get(data);
348 Evas_Coord minw = -1, minh = -1, maxh = -1;
349 Evas_Coord resw, resh, minminw;
351 wd->deferred_recalc_job = NULL;
352 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
355 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
356 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
358 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
359 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
360 evas_object_size_hint_min_set(data, minminw, minh);
361 if (wd->single_line) maxh = minh;
362 evas_object_size_hint_max_set(data, -1, maxh);
363 if (wd->deferred_cur)
364 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
368 _sizing_eval(Evas_Object *obj)
370 Widget_Data *wd = elm_widget_data_get(obj);
371 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
372 Evas_Coord resw, resh;
374 if (wd->linewrap || wd->char_linewrap)
376 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
377 if ((resw == wd->lastw) && (!wd->changed)) return;
378 wd->changed = EINA_FALSE;
380 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
381 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
385 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
386 edje_object_size_min_calc(wd->ent, &minw, &minh);
387 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
388 evas_object_size_hint_min_set(obj, minw, minh);
389 if (wd->single_line) maxh = minh;
390 evas_object_size_hint_max_set(obj, maxw, maxh);
392 if (wd->ellipsis && wd->single_line)
394 if (_is_width_over(obj))
395 _ellipsis_entry_to_width(obj);
396 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
397 _reverse_ellipsis_entry(obj);
403 _check_enable_returnkey(Evas_Object *obj)
405 Widget_Data *wd = elm_widget_data_get(obj);
408 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
411 if (!wd->autoreturnkey) return;
413 if (_entry_length_get(obj) == 0)
415 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
419 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
423 #ifdef HAVE_CONFORMANT_AUTOSCROLL
425 _imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
427 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
428 Widget_Data *wd = elm_widget_data_get(obj);
429 if (!wd) return NULL;
430 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
442 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
444 Widget_Data *wd = elm_widget_data_get(obj);
445 Evas_Object *top = elm_widget_top_get(obj);
446 Evas_Object *parent_obj = obj;
447 Evas_Object *above = NULL;
450 if (!wd->editable) return;
451 if (elm_widget_focus_get(obj))
453 evas_object_focus_set(wd->ent, EINA_TRUE);
454 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
456 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
457 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
458 _check_enable_returnkey(obj);
462 above = evas_object_above_get(parent_obj);
464 evas_object_data_set(parent_obj, "raise", above);
465 evas_object_raise(parent_obj);
466 parent_obj = elm_widget_parent_get(parent_obj);
471 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
472 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
473 evas_object_focus_set(wd->ent, EINA_FALSE);
474 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
475 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
479 above = evas_object_data_get(parent_obj, "raise");
481 evas_object_stack_below(parent_obj, above);
482 parent_obj = elm_widget_parent_get(parent_obj);
488 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
490 Widget_Data *wd = elm_widget_data_get(obj);
492 edje_object_signal_emit(wd->ent, emission, source);
496 _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)
498 Widget_Data *wd = elm_widget_data_get(obj);
500 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
504 _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))
506 Widget_Data *wd = elm_widget_data_get(obj);
507 if (!wd) return NULL;
508 return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
512 _hoversel_position(Evas_Object *obj)
514 Widget_Data *wd = elm_widget_data_get(obj);
515 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
517 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
518 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
520 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
531 evas_object_move(wd->hoversel, x + cx, y + cy);
532 evas_object_resize(wd->hoversel, cw, ch);
536 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
538 Widget_Data *wd = elm_widget_data_get(data);
540 if (wd->hoversel) _hoversel_position(data);
544 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
546 Widget_Data *wd = elm_widget_data_get(data);
548 if (wd->linewrap || wd->char_linewrap)
552 if (wd->hoversel) _hoversel_position(data);
553 // Evas_Coord ww, hh;
554 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
558 _hover_del(void *data)
560 Widget_Data *wd = elm_widget_data_get(data);
565 evas_object_del(wd->hoversel);
568 wd->hovdeljob = NULL;
572 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
574 Widget_Data *wd = elm_widget_data_get(data);
576 if (wd->hoversel) evas_object_hide(wd->hoversel);
580 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
582 elm_widget_scroll_freeze_pop(data);
583 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
584 wd->hovdeljob = ecore_job_add(_hover_del, data);
588 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
590 Widget_Data *wd = elm_widget_data_get(data);
592 wd->selmode = EINA_TRUE;
594 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
595 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
596 edje_object_part_text_select_all(wd->ent, "elm.text");
597 //elm_widget_scroll_hold_push(data);
598 elm_object_scroll_freeze_pop(data);
602 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
604 Widget_Data *wd = elm_widget_data_get(data);
606 wd->selmode = EINA_TRUE;
607 edje_object_part_text_select_none(wd->ent, "elm.text");
609 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
610 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
611 elm_object_scroll_freeze_pop(data);
612 //elm_widget_scroll_hold_push(data);
616 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
618 Widget_Data *wd = elm_widget_data_get(data);
620 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
621 if (wd->sel_notify_handler)
623 #ifdef HAVE_ELEMENTARY_X
624 wd->selection_asked = EINA_TRUE;
625 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
631 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
633 Widget_Data *wd = elm_widget_data_get(obj);
637 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
638 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
639 if (seltype == ELM_SEL_CLIPBOARD)
640 eina_stringshare_replace(&wd->cut_sel, sel);
644 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
646 Widget_Data *wd = elm_widget_data_get(data);
649 wd->selmode = EINA_FALSE;
650 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
651 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
652 elm_widget_scroll_hold_pop(data);
653 _store_selection(ELM_SEL_CLIPBOARD, data);
654 edje_object_part_text_insert(wd->ent, "elm.text", "");
655 edje_object_part_text_select_none(wd->ent, "elm.text");
659 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
661 Widget_Data *wd = elm_widget_data_get(data);
663 //wd->selmode = EINA_FALSE;
664 //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
665 //edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
666 elm_widget_scroll_hold_pop(data);
667 _store_selection(ELM_SEL_CLIPBOARD, data);
668 //edje_object_part_text_select_none(wd->ent, "elm.text");
672 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
674 Widget_Data *wd = elm_widget_data_get(data);
676 wd->selmode = EINA_FALSE;
677 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
678 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
679 elm_widget_scroll_hold_pop(data);
680 edje_object_part_text_select_none(wd->ent, "elm.text");
684 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
686 Widget_Data *wd = elm_widget_data_get(data);
690 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
691 cnpwidgetdata = data;
692 elm_cbhm_helper_init(obj);
693 elm_cbhm_send_raw_data("show");
699 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
701 Widget_Data *wd = elm_widget_data_get(data);
703 cnpwidgetdata = data;
709 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
711 Elm_Entry_Context_Menu_Item *it = data;
712 Evas_Object *obj2 = it->obj;
714 if (it->func) it->func(it->data, obj2, NULL);
718 _long_press(void *data)
720 Widget_Data *wd = elm_widget_data_get(data);
723 const Elm_Entry_Context_Menu_Item *it;
724 if (!wd) return ECORE_CALLBACK_CANCEL;
726 if (wd->longpress_timer)
728 ecore_timer_del(wd->longpress_timer);
729 wd->longpress_timer = NULL;
732 if ((wd->api) && (wd->api->obj_longpress))
734 wd->api->obj_longpress(data);
736 else if (wd->context_menu)
738 const char *context_menu_orientation;
740 if (wd->hoversel) evas_object_del(wd->hoversel);
741 else elm_widget_scroll_freeze_push(data);
742 wd->hoversel = elm_hoversel_add(data);
743 context_menu_orientation = edje_object_data_get
744 (wd->ent, "context_menu_orientation");
745 if ((context_menu_orientation) &&
746 (!strcmp(context_menu_orientation, "horizontal")))
747 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
748 elm_object_style_set(wd->hoversel, "entry");
749 elm_widget_sub_object_add(data, wd->hoversel);
750 elm_hoversel_label_set(wd->hoversel, "Text");
751 top = elm_widget_top_get(data);
752 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
753 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
757 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
759 if (1) // need way to detect if someone has a selection
762 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
767 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
768 _clipboard_menu, data);
775 if (wd->have_selection)
777 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
780 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
783 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
786 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
787 _clipboard_menu, data);
791 EINA_LIST_FOREACH(wd->items, l, it)
793 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
794 it->icon_type, _item_clicked, it);
798 _hoversel_position(data);
799 evas_object_show(wd->hoversel);
800 elm_hoversel_hover_begin(wd->hoversel);
802 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
803 edje_object_part_text_select_abort(wd->ent, "elm.text");
805 wd->longpress_timer = NULL;
806 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
807 return ECORE_CALLBACK_CANCEL;
811 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
813 Widget_Data *wd = elm_widget_data_get(data);
814 Evas_Event_Mouse_Down *ev = event_info;
816 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
817 if (ev->button != 1) return;
818 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
819 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
820 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
821 wd->downx = ev->canvas.x;
822 wd->downy = ev->canvas.y;
826 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
828 Widget_Data *wd = elm_widget_data_get(data);
829 Evas_Event_Mouse_Up *ev = event_info;
831 if (ev->button != 1) return;
833 if (!wd->double_clicked)
835 if ((wd->api) && (wd->api->obj_mouseup))
837 wd->api->obj_mouseup(data);
840 if (wd->longpress_timer)
842 ecore_timer_del(wd->longpress_timer);
843 wd->longpress_timer = NULL;
848 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
850 Widget_Data *wd = elm_widget_data_get(data);
851 Evas_Event_Mouse_Move *ev = event_info;
855 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
857 if (wd->longpress_timer)
859 ecore_timer_del(wd->longpress_timer);
860 wd->longpress_timer = NULL;
863 else if (wd->longpress_timer)
867 dx = wd->downx - ev->cur.canvas.x;
869 dy = wd->downy - ev->cur.canvas.y;
872 ((_elm_config->finger_size / 2) *
873 (_elm_config->finger_size / 2)))
875 ecore_timer_del(wd->longpress_timer);
876 wd->longpress_timer = NULL;
880 else if (wd->longpress_timer)
884 dx = wd->downx - ev->cur.canvas.x;
886 dy = wd->downy - ev->cur.canvas.y;
889 ((_elm_config->finger_size / 2) *
890 (_elm_config->finger_size / 2)))
892 ecore_timer_del(wd->longpress_timer);
893 wd->longpress_timer = NULL;
899 _getbase(Evas_Object *obj)
901 Widget_Data *wd = elm_widget_data_get(obj);
902 if (!wd) return "base";
907 if (wd->show_last_character) return "custom-password";
908 else return "base-password";
912 if (wd->single_line) return "base-single";
915 if (wd->linewrap) return "base";
916 else if (wd->char_linewrap) return "base-charwrap";
917 else return "base-nowrap";
925 if (wd->show_last_character) return "custom-password";
926 else return "base-password";
930 if (wd->single_line) return "base-single-noedit";
933 if (wd->linewrap) return "base-noedit";
934 else if (wd->char_linewrap) return "base-noedit-charwrap";
935 else return "base-nowrap-noedit";
943 _str_append(char *str, const char *txt, int *len, int *alloc)
945 int txt_len = strlen(txt);
947 if (txt_len <= 0) return str;
948 if ((*len + txt_len) >= *alloc)
953 alloc2 = *alloc + txt_len + 128;
954 str2 = realloc(str, alloc2);
955 if (!str2) return str;
959 strcpy(str + *len, txt);
964 /*FIXME: Sholud be implemented somewhere else, it really depends on the context
965 * because some markups can be implemented otherwise according to style.
966 * probably doing it in textblock and making it translate according to it's
967 * style is correct. */
969 _strncpy(char* dest, const char* src, size_t count)
973 ERR( "dest is NULL" );
978 ERR( "src is NULL" );
983 ERR( "count is smaller than 0" );
987 return strncpy( dest, src, count );
991 _mkup_to_text(const char *mkup)
994 int str_len = 0, str_alloc = 0;
996 char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
998 if (!mkup) return NULL;
1000 tag_start = tag_end = esc_start = esc_end = NULL;
1005 if (((p!=NULL)&&(*p == 0)) ||
1006 (tag_end) || (esc_end) ||
1007 (tag_start) || (esc_start))
1013 ttag = malloc(tag_end - tag_start);
1016 _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
1017 ttag[tag_end - tag_start - 1] = 0;
1018 if (!strcmp(ttag, "br"))
1019 str = _str_append(str, "\n", &str_len, &str_alloc);
1020 else if (!strcmp(ttag, "\n"))
1021 str = _str_append(str, "\n", &str_len, &str_alloc);
1022 else if (!strcmp(ttag, "\\n"))
1023 str = _str_append(str, "\n", &str_len, &str_alloc);
1024 else if (!strcmp(ttag, "\t"))
1025 str = _str_append(str, "\t", &str_len, &str_alloc);
1026 else if (!strcmp(ttag, "\\t"))
1027 str = _str_append(str, "\t", &str_len, &str_alloc);
1028 else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
1029 str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
1032 tag_start = tag_end = NULL;
1036 ts = malloc(esc_end - esc_start + 1);
1040 _strncpy(ts, esc_start, esc_end - esc_start);
1041 ts[esc_end - esc_start] = 0;
1042 esc = evas_textblock_escape_string_get(ts);
1044 str = _str_append(str, esc, &str_len, &str_alloc);
1047 esc_start = esc_end = NULL;
1049 else if ((p!=NULL)&&(*p == 0))
1051 ts = malloc(p - s + 1);
1054 _strncpy(ts, s, p - s);
1056 str = _str_append(str, ts, &str_len, &str_alloc);
1062 if ((p!=NULL)&&(*p == '<'))
1068 ts = malloc(p - s + 1);
1071 _strncpy(ts, s, p - s);
1073 str = _str_append(str, ts, &str_len, &str_alloc);
1079 else if ((p!=NULL)&&(*p == '>'))
1087 else if ((p!=NULL)&&(*p == '&'))
1093 ts = malloc(p - s + 1);
1096 _strncpy(ts, s, p - s);
1098 str = _str_append(str, ts, &str_len, &str_alloc);
1104 else if ((p!=NULL)&&(*p == ';'))
1118 _entry_length_get(Evas_Object *obj)
1121 const char *str = elm_entry_entry_get(obj);
1124 char *plain_str = _mkup_to_text(str);
1125 if (!plain_str) return 0;
1127 len = strlen(plain_str);
1134 _text_to_mkup(const char *text)
1137 int str_len = 0, str_alloc = 0;
1138 int ch, pos = 0, pos2 = 0;
1140 if (!text) return NULL;
1144 pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
1145 if ((ch <= 0) || (pos2 <= 0)) break;
1147 str = _str_append(str, "<br>", &str_len, &str_alloc);
1148 else if (ch == '\t')
1149 str = _str_append(str, "<\t>", &str_len, &str_alloc);
1151 str = _str_append(str, "<", &str_len, &str_alloc);
1153 str = _str_append(str, ">", &str_len, &str_alloc);
1155 str = _str_append(str, "&", &str_len, &str_alloc);
1156 else if (ch == 0x2029)
1157 str = _str_append(str, "<ps>", &str_len, &str_alloc);
1162 _strncpy(tstr, text + pos, pos2 - pos);
1163 tstr[pos2 - pos] = 0;
1164 str = _str_append(str, tstr, &str_len, &str_alloc);
1171 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1173 Widget_Data *wd = elm_widget_data_get(data);
1175 wd->changed = EINA_TRUE;
1177 if (wd->text) eina_stringshare_del(wd->text);
1179 _check_enable_returnkey(data);
1180 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1184 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1186 Widget_Data *wd = elm_widget_data_get(data);
1187 elm_object_scroll_freeze_push(data);
1189 if ((wd->api) && (wd->api->obj_hidemenu))
1191 wd->api->obj_hidemenu(data);
1196 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1198 Widget_Data *wd = elm_widget_data_get(data);
1199 elm_object_scroll_freeze_pop(data);
1201 if (wd->have_selection)
1206 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1209 Widget_Data *wd = elm_widget_data_get(data);
1217 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1219 Widget_Data *wd = elm_widget_data_get(data);
1223 EINA_LIST_FOREACH(entries, l, entry)
1225 if (entry != data) elm_entry_select_none(entry);
1227 wd->have_selection = EINA_TRUE;
1228 wd->selmode = EINA_TRUE;
1229 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1230 #ifdef HAVE_ELEMENTARY_X
1231 if (wd->sel_notify_handler)
1233 const char *txt = elm_entry_selection_get(data);
1236 top = elm_widget_top_get(data);
1237 if ((top) && (elm_win_xwindow_get(top)))
1238 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1244 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1246 Evas_Coord cx, cy, cw, ch;
1247 Widget_Data *wd = elm_widget_data_get(data);
1249 wd->have_selection = EINA_TRUE;
1250 wd->selmode = EINA_TRUE;
1251 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1252 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1253 elm_entry_selection_get(data));
1255 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1256 if (!wd->deferred_recalc_job)
1257 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1260 wd->deferred_cur = EINA_TRUE;
1264 wd->ch = ch + elm_finger_size_get();
1269 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1271 Widget_Data *wd = elm_widget_data_get(data);
1273 if (!wd->have_selection) return;
1274 wd->have_selection = EINA_FALSE;
1275 wd->selmode = EINA_FALSE;
1276 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1277 if (wd->sel_notify_handler)
1281 #ifdef HAVE_ELEMENTARY_X
1284 top = elm_widget_top_get(data);
1285 if ((top) && (elm_win_xwindow_get(top)))
1286 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1289 eina_stringshare_del(wd->cut_sel);
1294 #ifdef HAVE_ELEMENTARY_X
1297 top = elm_widget_top_get(data);
1298 if ((top) && (elm_win_xwindow_get(top)))
1299 elm_selection_clear(ELM_SEL_PRIMARY, data);
1306 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1308 Widget_Data *wd = elm_widget_data_get(data);
1310 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1311 if (wd->sel_notify_handler)
1313 #ifdef HAVE_ELEMENTARY_X
1316 top = elm_widget_top_get(data);
1317 if ((top) && (elm_win_xwindow_get(top)))
1319 wd->selection_asked = EINA_TRUE;
1320 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
1327 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1329 Widget_Data *wd = elm_widget_data_get(data);
1331 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1332 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1333 elm_entry_selection_get(data));
1337 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1339 Widget_Data *wd = elm_widget_data_get(data);
1341 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1342 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1343 elm_entry_selection_get(data));
1344 edje_object_part_text_insert(wd->ent, "elm.text", "");
1345 wd->changed = EINA_TRUE;
1350 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1352 Widget_Data *wd = elm_widget_data_get(data);
1353 Evas_Coord cx, cy, cw, ch;
1355 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1356 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1357 &cx, &cy, &cw, &ch);
1358 if (!wd->deferred_recalc_job)
1359 elm_widget_show_region_set(data, cx, cy, cw, ch);
1362 wd->deferred_cur = EINA_TRUE;
1368 #ifdef HAVE_CONFORMANT_AUTOSCROLL
1369 evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
1374 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1376 Widget_Data *wd = elm_widget_data_get(data);
1381 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1383 Widget_Data *wd = elm_widget_data_get(data);
1384 Elm_Entry_Anchor_Info ei;
1385 char *buf2, *p, *p2, *n;
1387 p = strrchr(emission, ',');
1390 const Eina_List *geoms;
1394 while (p2 >= emission)
1396 if (*p2 == ',') break;
1400 buf2 = alloca(5 + p - p2);
1401 strncpy(buf2, p2, p - p2);
1404 ei.button = atoi(buf2);
1405 ei.x = ei.y = ei.w = ei.h = 0;
1407 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1410 Evas_Textblock_Rectangle *r;
1412 Evas_Coord px, py, x, y;
1414 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1415 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1416 EINA_LIST_FOREACH(geoms, l, r)
1418 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1419 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1430 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1435 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1437 Widget_Data *wd = elm_widget_data_get(data);
1442 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1444 Widget_Data *wd = elm_widget_data_get(data);
1449 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1451 Widget_Data *wd = elm_widget_data_get(data);
1456 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1458 Widget_Data *wd = elm_widget_data_get(data);
1460 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1464 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1466 Widget_Data *wd = elm_widget_data_get(data);
1468 wd->double_clicked = EINA_FALSE;
1469 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1471 if ((wd->api) && (wd->api->obj_hidemenu))
1473 wd->api->obj_hidemenu(data);
1478 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1480 Widget_Data *wd = elm_widget_data_get(data);
1482 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1484 // if (wd->have_selection)
1485 // _long_press(data);
1489 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1491 Widget_Data *wd = elm_widget_data_get(data);
1493 wd->double_clicked = EINA_TRUE;
1494 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1497 #ifdef HAVE_ELEMENTARY_X
1499 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1501 Widget_Data *wd = elm_widget_data_get(data);
1502 Ecore_X_Event_Selection_Notify *ev = event;
1503 if (!wd) return ECORE_CALLBACK_PASS_ON;
1504 if (!wd->selection_asked && !wd->drag_selection_asked)
1505 return ECORE_CALLBACK_PASS_ON;
1507 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1508 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1510 Ecore_X_Selection_Data_Text *text_data;
1512 text_data = ev->data;
1513 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1515 if (text_data->text)
1517 char *txt = _text_to_mkup(text_data->text);
1521 elm_entry_entry_insert(data, txt);
1526 wd->selection_asked = EINA_FALSE;
1528 else if (ev->selection == ECORE_X_SELECTION_XDND)
1530 Ecore_X_Selection_Data_Text *text_data;
1532 text_data = ev->data;
1533 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1535 if (text_data->text)
1537 char *txt = _text_to_mkup(text_data->text);
1541 /* Massive FIXME: this should be at the drag point */
1542 elm_entry_entry_insert(data, txt);
1547 wd->drag_selection_asked = EINA_FALSE;
1549 ecore_x_dnd_send_finished();
1552 return ECORE_CALLBACK_PASS_ON;
1556 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1559 Widget_Data *wd = elm_widget_data_get(data);
1560 Ecore_X_Event_Selection_Clear *ev = event;
1561 if (!wd) return ECORE_CALLBACK_PASS_ON;
1562 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1563 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1564 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1566 elm_entry_select_none(data);
1571 Evas_Object *top = elm_widget_top_get(data);
1572 Ecore_X_Event_Selection_Clear *ev = event;
1575 return ECORE_CALLBACK_PASS_ON;
1577 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1579 return ECORE_CALLBACK_PASS_ON;
1582 if (cnpwidgetdata == data)
1584 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1588 return ECORE_CALLBACK_PASS_ON;
1592 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1597 wd = elm_widget_data_get(obj);
1599 if (!wd) return EINA_FALSE;
1600 //printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1602 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1603 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1604 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1605 EDJE_CURSOR_MAIN,drop->x,drop->y);
1606 // if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1607 elm_entry_entry_insert(obj, drop->data);
1608 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1609 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1615 static Evas_Object *
1616 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1618 Widget_Data *wd = elm_widget_data_get(data);
1621 Elm_Entry_Item_Provider *ip;
1624 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1626 o = ip->func(ip->data, data, item);
1629 if (!strncmp(item, "file://", 7))
1631 const char *fname = item + 7;
1633 o = evas_object_image_filled_add(evas_object_evas_get(data));
1634 evas_object_image_file_set(o, fname, NULL);
1635 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1637 evas_object_show(o);
1642 o = edje_object_add(evas_object_evas_get(data));
1643 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1647 o = edje_object_add(evas_object_evas_get(data));
1648 if (!strncmp(item, "emoticon/", 9))
1649 ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
1651 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1656 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1658 char *curlocater, *starttag, *endtag;
1659 int firstindex = 0, foundflag = -1;
1661 curlocater = strstr(oldstring, key);
1664 starttag = curlocater;
1665 endtag = curlocater + strlen(key);
1666 if (endtag == NULL || *endtag != '=')
1672 firstindex = abs(oldstring - curlocater);
1673 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1674 *value = (char*)(oldstring + firstindex);
1676 while (oldstring != starttag)
1678 if (*starttag == '>')
1683 if (*starttag == '<')
1687 if (starttag == NULL) break;
1690 while (NULL != endtag)
1701 if (endtag == NULL) break;
1704 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
1714 if (foundflag == 1) return 0;
1720 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
1722 const char *srcstring = NULL;
1723 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
1724 char *curlocater, *replocater;
1725 char *starttag, *endtag;
1726 int tagtxtlen = 0, insertflag = 0;
1728 srcstring = eina_strbuf_string_get(srcbuf);
1729 curlocater = strstr(srcstring, key);
1731 if (curlocater == NULL)
1739 starttag = strchr(srcstring, '<');
1740 endtag = strchr(srcstring, '>');
1741 tagtxtlen = endtag - starttag;
1742 if (tagtxtlen <= 0) tagtxtlen = 0;
1743 if (starttag < curlocater && curlocater < endtag) break;
1744 if (endtag != NULL && endtag+1 != NULL)
1745 srcstring = endtag+1;
1748 } while (strlen(srcstring) > 1);
1750 if (starttag && endtag && tagtxtlen > strlen(key))
1752 repbuf = eina_strbuf_new();
1753 diffbuf = eina_strbuf_new();
1754 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
1755 srcstring = eina_strbuf_string_get(repbuf);
1756 curlocater = strstr(srcstring, key);
1758 if (curlocater != NULL)
1760 replocater = curlocater + strlen(key) + 1;
1762 while (*replocater == ' ' || *replocater == '=')
1767 while (replocater != NULL && *replocater != ' ' && *replocater != '>')
1770 if (replocater-curlocater > strlen(key)+1)
1773 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
1782 eina_strbuf_reset(repbuf);
1790 if (repbuf == NULL) repbuf = eina_strbuf_new();
1791 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
1795 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
1796 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
1802 eina_strbuf_prepend(diffbuf, "<");
1803 eina_strbuf_append(diffbuf, ">");
1804 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
1808 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
1809 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
1813 if (repbuf) eina_strbuf_free(repbuf);
1814 if (diffbuf) eina_strbuf_free(diffbuf);
1820 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
1822 Eina_Strbuf *sharebuf = NULL;
1824 sharebuf = eina_strbuf_new();
1825 eina_strbuf_append(sharebuf, *srcstring);
1826 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
1827 eina_stringshare_del(*srcstring);
1828 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
1829 eina_strbuf_free(sharebuf);
1835 _is_width_over(Evas_Object *obj)
1837 Evas_Coord x, y, w, h;
1838 Evas_Coord vx, vy, vw, vh;
1839 Widget_Data *wd = elm_widget_data_get(obj);
1843 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
1845 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
1847 if (x >= 0 && y >= 0)
1850 if (4 < wd->wrap_w && w > wd->wrap_w)
1857 _reverse_ellipsis_entry(Evas_Object *obj)
1859 Widget_Data *wd = elm_widget_data_get(obj);
1860 int cur_fontsize = 0;
1861 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1862 char *kvalue = NULL;
1863 const char *minfont, *deffont, *maxfont;
1864 const char *ellipsis_string = "...";
1865 int minfontsize, maxfontsize, minshowcount;
1867 minshowcount = strlen(ellipsis_string) + 1;
1868 minfont = edje_object_data_get(wd->ent, "min_font_size");
1869 if (minfont) minfontsize = atoi(minfont);
1870 else minfontsize = 1;
1871 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1872 if (maxfont) maxfontsize = atoi(maxfont);
1873 else maxfontsize = 1;
1874 deffont = edje_object_data_get(wd->ent, "default_font_size");
1875 if (deffont) cur_fontsize = atoi(deffont);
1876 else cur_fontsize = 1;
1877 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1878 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1880 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1882 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
1885 txtbuf = eina_strbuf_new();
1886 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1888 if (cur_fontsize >= atoi(deffont))
1890 if (txtbuf) eina_strbuf_free(txtbuf);
1894 if (_is_width_over(obj) != 1)
1896 int rev_fontsize = cur_fontsize;
1900 if (rev_fontsize > atoi(deffont))
1903 if (fontbuf != NULL)
1905 eina_strbuf_free(fontbuf);
1908 fontbuf = eina_strbuf_new();
1909 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1910 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1911 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1913 eina_strbuf_free(fontbuf);
1915 } while (_is_width_over(obj) != 1);
1917 while (_is_width_over(obj))
1920 if (rev_fontsize < atoi(deffont))
1923 if (fontbuf != NULL)
1925 eina_strbuf_free(fontbuf);
1928 fontbuf = eina_strbuf_new();
1929 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
1930 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1931 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1932 eina_strbuf_free(fontbuf);
1937 if (txtbuf) eina_strbuf_free(txtbuf);
1943 _ellipsis_entry_to_width(Evas_Object *obj)
1945 Widget_Data *wd = elm_widget_data_get(obj);
1946 int cur_fontsize = 0, len, jumpcount;
1947 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
1948 char *kvalue = NULL;
1949 const char *minfont, *deffont, *maxfont;
1950 const char *ellipsis_string = "...";
1951 int minfontsize, maxfontsize, minshowcount;
1952 int i, tagend, cur_len;
1955 minshowcount = strlen(ellipsis_string) + 1;
1956 minfont = edje_object_data_get(wd->ent, "min_font_size");
1957 if (minfont) minfontsize = atoi(minfont);
1958 else minfontsize = 1;
1959 maxfont = edje_object_data_get(wd->ent, "max_font_size");
1960 if (maxfont) maxfontsize = atoi(maxfont);
1961 else maxfontsize = 1;
1962 deffont = edje_object_data_get(wd->ent, "default_font_size");
1963 if (deffont) cur_fontsize = atoi(deffont);
1964 else cur_fontsize = 1;
1965 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
1966 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
1968 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
1970 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
1973 txtbuf = eina_strbuf_new();
1974 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
1976 while (_is_width_over(obj))
1978 if (wd->ellipsis_threshold == 0)
1979 wd->ellipsis_threshold = _entry_length_get(obj);
1980 if (cur_fontsize > minfontsize)
1983 if (fontbuf != NULL)
1985 eina_strbuf_free(fontbuf);
1988 fontbuf = eina_strbuf_new();
1989 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
1990 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
1991 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
1992 eina_strbuf_free(fontbuf);
1994 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1998 len = _entry_length_get(obj);
1999 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2000 cur_len = strlen(cur_str);
2002 for (i = 0; i < len; i++)
2004 if(cur_str[i] == '>' && cur_str[i+1] != '\0' &&
2005 cur_str[i+1] != '<')
2012 while (jumpcount < len-strlen(ellipsis_string))
2014 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2018 eina_strbuf_free(txtbuf);
2021 txtbuf = eina_strbuf_new();
2022 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
2023 eina_strbuf_append(txtbuf, ellipsis_string);
2024 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
2025 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2026 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2028 if (_is_width_over(obj))
2036 if (txtbuf) eina_strbuf_free(txtbuf);
2041 static int _textinput_control_function(void *data,void *input_data)
2043 /* calculate character count */
2044 Evas_Object *entry = (Evas_Object *)data;
2045 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2048 size_t insert_text_len=0;
2049 char *text = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2051 size_t remain_bytes;
2054 byte_len = strlen(text); /* no of bytes */
2055 remain_bytes = wd->max_no_of_bytes - byte_len;
2056 sprintf(buf,"%d",remain_bytes);
2057 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2060 insert_text = (char *)input_data;
2061 insert_text_len = strlen(insert_text);
2062 if (remain_bytes < insert_text_len)
2064 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2067 if (byte_len >= wd->max_no_of_bytes)
2069 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2078 * This adds an entry to @p parent object.
2080 * @param parent The parent object
2081 * @return The new object or NULL if it cannot be created
2086 elm_entry_add(Evas_Object *parent)
2088 Evas_Object *obj, *top;
2092 wd = ELM_NEW(Widget_Data);
2093 e = evas_object_evas_get(parent);
2094 wd->bgcolor = EINA_FALSE;
2095 wd->bg = evas_object_rectangle_add(e);
2096 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2097 obj = elm_widget_add(e);
2098 ELM_SET_WIDTYPE(widtype, "entry");
2099 elm_widget_type_set(obj, "entry");
2100 elm_widget_sub_object_add(parent, obj);
2101 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2102 elm_widget_data_set(obj, wd);
2103 elm_widget_del_hook_set(obj, _del_hook);
2104 elm_widget_theme_hook_set(obj, _theme_hook);
2105 elm_widget_disable_hook_set(obj, _disable_hook);
2106 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2107 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2108 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2109 elm_widget_can_focus_set(obj, 1);
2110 #ifdef HAVE_CONFORMANT_AUTOSCROLL
2111 elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
2114 wd->linewrap = EINA_TRUE;
2115 wd->ellipsis = EINA_FALSE;
2116 wd->char_linewrap= EINA_FALSE;
2117 wd->editable = EINA_TRUE;
2118 wd->disabled = EINA_FALSE;
2119 wd->context_menu = EINA_TRUE;
2120 wd->autoperiod = EINA_TRUE;
2122 wd->ellipsis_threshold = 0;
2124 wd->ent = edje_object_add(e);
2125 edje_object_item_provider_set(wd->ent, _get_item, obj);
2126 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2127 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2128 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2130 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2132 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2135 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2136 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2137 _signal_entry_changed, obj);
2138 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2139 _signal_handler_move_start, obj);
2140 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2141 _signal_handler_move_end, obj);
2142 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2143 _signal_selection_start, obj);
2144 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2145 _signal_selection_end, obj);
2146 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2147 _signal_selection_changed, obj);
2148 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2149 _signal_selection_cleared, obj);
2150 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2151 _signal_entry_paste_request, obj);
2152 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2153 _signal_entry_copy_notify, obj);
2154 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2155 _signal_entry_cut_notify, obj);
2156 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2157 _signal_cursor_changed, obj);
2158 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2159 _signal_anchor_down, obj);
2160 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2161 _signal_anchor_up, obj);
2162 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2163 _signal_anchor_move, obj);
2164 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2165 _signal_anchor_in, obj);
2166 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2167 _signal_anchor_out, obj);
2168 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2169 _signal_key_enter, obj);
2170 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2171 _signal_mouse_down, obj);
2172 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2173 _signal_mouse_clicked, obj);
2174 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2175 _signal_mouse_double, obj);
2176 edje_object_part_text_set(wd->ent, "elm.text", "");
2177 elm_widget_resize_object_set(obj, wd->ent);
2180 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2182 #ifdef HAVE_ELEMENTARY_X
2183 top = elm_widget_top_get(obj);
2184 if ((top) && (elm_win_xwindow_get(top)))
2186 wd->sel_notify_handler =
2187 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2188 _event_selection_notify, obj);
2189 wd->sel_clear_handler =
2190 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2191 _event_selection_clear, obj);
2194 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2197 entries = eina_list_prepend(entries, obj);
2199 // module - find module for entry
2200 wd->api = _module(obj);
2201 // if found - hook in
2202 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2204 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2205 // TODO: and save some bytes, making descriptions per-class and not instance!
2206 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2210 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2212 ELM_CHECK_WIDTYPE(obj, widtype);
2213 Widget_Data *wd = elm_widget_data_get(obj);
2215 ext_mod->cancel = _cancel;
2216 ext_mod->copy = _copy;
2217 ext_mod->cut = _cut;
2218 ext_mod->paste = _paste;
2219 ext_mod->select = _select;
2220 ext_mod->selectall = _selectall;
2221 ext_mod->ent = wd->ent;
2222 ext_mod->items = wd->items;
2223 ext_mod->longpress_timer = wd->longpress_timer;
2224 ext_mod->editable = wd->editable;
2225 ext_mod->have_selection = wd->have_selection;
2226 ext_mod->password = wd->password;
2227 ext_mod->selmode = wd->selmode;
2228 ext_mod->cnpinit = _cnpinit;
2229 ext_mod->context_menu = wd->context_menu;
2233 * This sets the entry object not to line wrap. All input will
2234 * be on a single line, and the entry box will extend with user input.
2236 * @param obj The entry object
2237 * @param single_line If true, the text in the entry
2238 * will be on a single line.
2243 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2245 ELM_CHECK_WIDTYPE(obj, widtype);
2246 Widget_Data *wd = elm_widget_data_get(obj);
2248 Ecore_IMF_Context *ic;
2250 if (wd->single_line == single_line) return;
2251 wd->single_line = single_line;
2252 wd->linewrap = EINA_FALSE;
2253 wd->char_linewrap = EINA_FALSE;
2254 t = eina_stringshare_add(elm_entry_entry_get(obj));
2255 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2256 elm_entry_entry_set(obj, t);
2257 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2258 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2259 ic = elm_entry_imf_context_get(obj);
2262 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2265 eina_stringshare_del(t);
2270 * This returns true if the entry has been set to single line mode.
2271 * See also elm_entry_single_line_set().
2273 * @param obj The entry object
2274 * @return single_line If true, the text in the entry is set to display
2280 elm_entry_single_line_get(const Evas_Object *obj)
2282 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2283 Widget_Data *wd = elm_widget_data_get(obj);
2284 if (!wd) return EINA_FALSE;
2285 return wd->single_line;
2289 * This set's the maximum bytes that can be added in entry.
2291 * @param obj The entry object
2292 * @param max_no_of_bytes Maximum number of bytes entry can have.
2297 elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
2299 Widget_Data *wd = elm_widget_data_get(obj);
2301 wd->max_no_of_bytes = max_no_of_bytes;
2302 edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
2303 edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
2308 * This sets the entry object to password mode. All text entered
2309 * and/or displayed within the widget will be replaced with asterisks (*).
2311 * @param obj The entry object
2312 * @param password If true, password mode is enabled.
2317 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2319 ELM_CHECK_WIDTYPE(obj, widtype);
2320 Widget_Data *wd = elm_widget_data_get(obj);
2321 Ecore_IMF_Context *ic;
2324 if (wd->password == password) return;
2325 wd->password = password;
2326 wd->single_line = EINA_TRUE;
2327 wd->linewrap = EINA_FALSE;
2328 wd->char_linewrap = EINA_FALSE;
2329 if (_elm_config->password_show_last_character)
2330 wd->show_last_character = EINA_TRUE;
2331 t = eina_stringshare_add(elm_entry_entry_get(obj));
2332 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2333 elm_entry_entry_set(obj, t);
2338 elm_entry_autoperiod_set(obj, EINA_FALSE);
2340 if (wd->autocapital)
2341 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2344 ic = elm_entry_imf_context_get(obj);
2346 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2348 eina_stringshare_del(t);
2353 * This set's the entry in password mode with out masking the last character entered by user,
2354 * and later masking the character after 2 seconds.
2356 * @param obj The entry object
2357 * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character"
2363 elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
2365 Widget_Data *wd = elm_widget_data_get(obj);
2368 if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character)) return;
2369 wd->show_last_character = show_last_character;
2370 wd->password = show_last_character;
2371 wd->single_line = EINA_TRUE;
2372 wd->linewrap = EINA_FALSE;
2373 wd->char_linewrap = EINA_FALSE;
2374 t = eina_stringshare_add(elm_entry_entry_get(obj));
2375 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2376 elm_entry_entry_set(obj, t);
2377 eina_stringshare_del(t);
2382 * This returns whether password mode is enabled.
2383 * See also elm_entry_password_set().
2385 * @param obj The entry object
2386 * @return If true, the entry is set to display all characters
2392 elm_entry_password_get(const Evas_Object *obj)
2394 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2395 Widget_Data *wd = elm_widget_data_get(obj);
2396 if (!wd) return EINA_FALSE;
2397 return wd->password;
2401 * This sets the text displayed within the entry to @p entry.
2403 * @param obj The entry object
2404 * @param entry The text to be displayed
2409 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2411 ELM_CHECK_WIDTYPE(obj, widtype);
2412 Widget_Data *wd = elm_widget_data_get(obj);
2414 if (!entry) entry = "";
2415 if(wd->max_no_of_bytes)
2417 int len = strlen(entry);
2418 if(len > wd->max_no_of_bytes)
2420 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2424 edje_object_part_text_set(wd->ent, "elm.text", entry);
2425 if (wd->text) eina_stringshare_del(wd->text);
2427 wd->changed = EINA_TRUE;
2432 * This returns the text currently shown in object @p entry.
2433 * See also elm_entry_entry_set().
2435 * @param obj The entry object
2436 * @return The currently displayed text or NULL on failure
2441 elm_entry_entry_get(const Evas_Object *obj)
2443 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2444 Widget_Data *wd = elm_widget_data_get(obj);
2446 if (!wd) return NULL;
2448 if ((wd->text)&&(wd->password))
2449 return elm_entry_markup_to_utf8(wd->text);
2451 if (wd->text) return wd->text;
2452 text = edje_object_part_text_get(wd->ent, "elm.text");
2455 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2458 eina_stringshare_replace(&wd->text, text);
2459 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2464 * This returns all selected text within the entry.
2466 * @param obj The entry object
2467 * @return The selected text within the entry or NULL on failure
2472 elm_entry_selection_get(const Evas_Object *obj)
2474 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2475 Widget_Data *wd = elm_widget_data_get(obj);
2476 if (!wd) return NULL;
2477 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2481 * This inserts text in @p entry at the beginning of the entry
2484 * @param obj The entry object
2485 * @param entry The text to insert
2490 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2492 ELM_CHECK_WIDTYPE(obj, widtype);
2493 Widget_Data *wd = elm_widget_data_get(obj);
2495 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2497 if (cnpwidgetdata == obj)
2498 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2500 wd->changed = EINA_TRUE;
2505 * This enables word line wrapping in the entry object. It is the opposite
2506 * of elm_entry_single_line_set(). Additionally, setting this disables
2507 * character line wrapping.
2508 * See also elm_entry_line_char_wrap_set().
2510 * @param obj The entry object
2511 * @param wrap If true, the entry will be wrapped once it reaches the end
2512 * of the object. Wrapping will occur at the end of the word before the end of the
2518 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2520 ELM_CHECK_WIDTYPE(obj, widtype);
2521 Widget_Data *wd = elm_widget_data_get(obj);
2524 if (wd->linewrap == wrap) return;
2525 wd->linewrap = wrap;
2527 wd->char_linewrap = EINA_FALSE;
2528 t = eina_stringshare_add(elm_entry_entry_get(obj));
2529 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2530 elm_entry_entry_set(obj, t);
2531 eina_stringshare_del(t);
2536 * Set wrap width of the entry
2538 * @param obj The entry object
2539 * @param w The wrap width in pixels at a minimum where words need to wrap
2543 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2545 Widget_Data *wd = elm_widget_data_get(obj);
2546 if (wd->wrap_w == w) return;
2552 * get wrap width of the entry
2554 * @param obj The entry object
2555 * @return The wrap width in pixels at a minimum where words need to wrap
2559 elm_entry_wrap_width_get(const Evas_Object *obj)
2561 Widget_Data *wd = elm_widget_data_get(obj);
2566 * This enables character line wrapping in the entry object. It is the opposite
2567 * of elm_entry_single_line_set(). Additionally, setting this disables
2568 * word line wrapping.
2569 * See also elm_entry_line_wrap_set().
2571 * @param obj The entry object
2572 * @param wrap If true, the entry will be wrapped once it reaches the end
2573 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2578 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2580 ELM_CHECK_WIDTYPE(obj, widtype);
2581 Widget_Data *wd = elm_widget_data_get(obj);
2584 if (wd->char_linewrap == wrap) return;
2585 wd->char_linewrap = wrap;
2586 if(wd->char_linewrap)
2587 wd->linewrap = EINA_FALSE;
2588 t = eina_stringshare_add(elm_entry_entry_get(obj));
2589 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2590 elm_entry_entry_set(obj, t);
2591 eina_stringshare_del(t);
2596 * This sets the editable attribute of the entry.
2598 * @param obj The entry object
2599 * @param editable If true, the entry will be editable by the user.
2600 * If false, it will be set to the disabled state.
2605 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2607 ELM_CHECK_WIDTYPE(obj, widtype);
2608 Widget_Data *wd = elm_widget_data_get(obj);
2611 if (wd->editable == editable) return;
2612 wd->editable = editable;
2613 t = eina_stringshare_add(elm_entry_entry_get(obj));
2614 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2615 elm_entry_entry_set(obj, t);
2616 eina_stringshare_del(t);
2619 #ifdef HAVE_ELEMENTARY_X
2621 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2623 elm_drop_target_del(obj);
2628 * This gets the editable attribute of the entry.
2629 * See also elm_entry_editable_set().
2631 * @param obj The entry object
2632 * @return If true, the entry is editable by the user.
2633 * If false, it is not editable by the user
2638 elm_entry_editable_get(const Evas_Object *obj)
2640 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2641 Widget_Data *wd = elm_widget_data_get(obj);
2642 if (!wd) return EINA_FALSE;
2643 return wd->editable;
2647 * This drops any existing text selection within the entry.
2649 * @param obj The entry object
2654 elm_entry_select_none(Evas_Object *obj)
2656 ELM_CHECK_WIDTYPE(obj, widtype);
2657 Widget_Data *wd = elm_widget_data_get(obj);
2661 wd->selmode = EINA_FALSE;
2662 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2663 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2665 wd->have_selection = EINA_FALSE;
2666 edje_object_part_text_select_none(wd->ent, "elm.text");
2670 * This selects all text within the entry.
2672 * @param obj The entry object
2677 elm_entry_select_all(Evas_Object *obj)
2679 ELM_CHECK_WIDTYPE(obj, widtype);
2680 Widget_Data *wd = elm_widget_data_get(obj);
2684 wd->selmode = EINA_FALSE;
2685 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
2686 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
2688 wd->have_selection = EINA_TRUE;
2689 edje_object_part_text_select_all(wd->ent, "elm.text");
2693 * This moves the cursor one place to the right within the entry.
2695 * @param obj The entry object
2696 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2701 elm_entry_cursor_next(Evas_Object *obj)
2703 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2704 Widget_Data *wd = elm_widget_data_get(obj);
2705 if (!wd) return EINA_FALSE;
2706 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2710 * This moves the cursor one place to the left within the entry.
2712 * @param obj The entry object
2713 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2718 elm_entry_cursor_prev(Evas_Object *obj)
2720 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2721 Widget_Data *wd = elm_widget_data_get(obj);
2722 if (!wd) return EINA_FALSE;
2723 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2727 * This moves the cursor one line up within the entry.
2729 * @param obj The entry object
2730 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2735 elm_entry_cursor_up(Evas_Object *obj)
2737 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2738 Widget_Data *wd = elm_widget_data_get(obj);
2739 if (!wd) return EINA_FALSE;
2740 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2744 * This moves the cursor one line down within the entry.
2746 * @param obj The entry object
2747 * @return EINA_TRUE upon success, EINA_FALSE upon failure
2752 elm_entry_cursor_down(Evas_Object *obj)
2754 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2755 Widget_Data *wd = elm_widget_data_get(obj);
2756 if (!wd) return EINA_FALSE;
2757 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2761 * This moves the cursor to the beginning of the entry.
2763 * @param obj The entry object
2768 elm_entry_cursor_begin_set(Evas_Object *obj)
2770 ELM_CHECK_WIDTYPE(obj, widtype);
2771 Widget_Data *wd = elm_widget_data_get(obj);
2773 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2777 * This moves the cursor to the end of the entry.
2779 * @param obj The entry object
2784 elm_entry_cursor_end_set(Evas_Object *obj)
2786 ELM_CHECK_WIDTYPE(obj, widtype);
2787 Widget_Data *wd = elm_widget_data_get(obj);
2789 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2793 * This moves the cursor to the beginning of the current line.
2795 * @param obj The entry object
2800 elm_entry_cursor_line_begin_set(Evas_Object *obj)
2802 ELM_CHECK_WIDTYPE(obj, widtype);
2803 Widget_Data *wd = elm_widget_data_get(obj);
2805 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2809 * This moves the cursor to the end of the current line.
2811 * @param obj The entry object
2816 elm_entry_cursor_line_end_set(Evas_Object *obj)
2818 ELM_CHECK_WIDTYPE(obj, widtype);
2819 Widget_Data *wd = elm_widget_data_get(obj);
2821 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2825 * This begins a selection within the entry as though
2826 * the user were holding down the mouse button to make a selection.
2828 * @param obj The entry object
2833 elm_entry_cursor_selection_begin(Evas_Object *obj)
2835 ELM_CHECK_WIDTYPE(obj, widtype);
2836 Widget_Data *wd = elm_widget_data_get(obj);
2838 edje_object_part_text_select_begin(wd->ent, "elm.text");
2842 * This ends a selection within the entry as though
2843 * the user had just released the mouse button while making a selection.
2845 * @param obj The entry object
2850 elm_entry_cursor_selection_end(Evas_Object *obj)
2852 ELM_CHECK_WIDTYPE(obj, widtype);
2853 Widget_Data *wd = elm_widget_data_get(obj);
2855 edje_object_part_text_select_extend(wd->ent, "elm.text");
2859 * TODO: fill this in
2861 * @param obj The entry object
2862 * @return TODO: fill this in
2867 elm_entry_cursor_is_format_get(const Evas_Object *obj)
2869 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2870 Widget_Data *wd = elm_widget_data_get(obj);
2871 if (!wd) return EINA_FALSE;
2872 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2876 * This returns whether the cursor is visible.
2878 * @param obj The entry object
2879 * @return If true, the cursor is visible.
2884 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
2886 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2887 Widget_Data *wd = elm_widget_data_get(obj);
2888 if (!wd) return EINA_FALSE;
2889 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2893 * TODO: fill this in
2895 * @param obj The entry object
2896 * @return TODO: fill this in
2901 elm_entry_cursor_content_get(const Evas_Object *obj)
2903 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2904 Widget_Data *wd = elm_widget_data_get(obj);
2905 if (!wd) return NULL;
2906 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2910 * This executes a "cut" action on the selected text in the entry.
2912 * @param obj The entry object
2917 elm_entry_selection_cut(Evas_Object *obj)
2919 ELM_CHECK_WIDTYPE(obj, widtype);
2920 Widget_Data *wd = elm_widget_data_get(obj);
2922 _cut(obj, NULL, NULL);
2926 * This executes a "copy" action on the selected text in the entry.
2928 * @param obj The entry object
2933 elm_entry_selection_copy(Evas_Object *obj)
2935 ELM_CHECK_WIDTYPE(obj, widtype);
2936 Widget_Data *wd = elm_widget_data_get(obj);
2938 _copy(obj, NULL, NULL);
2942 * This executes a "paste" action in the entry.
2944 * @param obj The entry object
2949 elm_entry_selection_paste(Evas_Object *obj)
2951 ELM_CHECK_WIDTYPE(obj, widtype);
2952 Widget_Data *wd = elm_widget_data_get(obj);
2954 _paste(obj, NULL, NULL);
2958 * This clears and frees the items in a entry's contextual (right click) menu.
2960 * @param obj The entry object
2965 elm_entry_context_menu_clear(Evas_Object *obj)
2967 ELM_CHECK_WIDTYPE(obj, widtype);
2968 Widget_Data *wd = elm_widget_data_get(obj);
2969 Elm_Entry_Context_Menu_Item *it;
2971 EINA_LIST_FREE(wd->items, it)
2973 eina_stringshare_del(it->label);
2974 eina_stringshare_del(it->icon_file);
2975 eina_stringshare_del(it->icon_group);
2981 * This adds an item to the entry's contextual menu.
2983 * @param obj The entry object
2984 * @param label The item's text label
2985 * @param icon_file The item's icon file
2986 * @param icon_type The item's icon type
2987 * @param func The callback to execute when the item is clicked
2988 * @param data The data to associate with the item for related functions
2993 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)
2995 ELM_CHECK_WIDTYPE(obj, widtype);
2996 Widget_Data *wd = elm_widget_data_get(obj);
2997 Elm_Entry_Context_Menu_Item *it;
2999 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3001 wd->items = eina_list_append(wd->items, it);
3003 it->label = eina_stringshare_add(label);
3004 it->icon_file = eina_stringshare_add(icon_file);
3005 it->icon_type = icon_type;
3007 it->data = (void *)data;
3011 * This disables the entry's contextual (right click) menu.
3013 * @param obj The entry object
3014 * @param disabled If true, the menu is disabled
3019 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3021 ELM_CHECK_WIDTYPE(obj, widtype);
3022 Widget_Data *wd = elm_widget_data_get(obj);
3024 if (wd->context_menu == !disabled) return;
3025 wd->context_menu = !disabled;
3029 * This returns whether the entry's contextual (right click) menu is disabled.
3031 * @param obj The entry object
3032 * @return If true, the menu is disabled
3037 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3039 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3040 Widget_Data *wd = elm_widget_data_get(obj);
3041 if (!wd) return EINA_FALSE;
3042 return !wd->context_menu;
3046 * This appends a custom item provider to the list for that entry
3048 * This appends the given callback. The list is walked from beginning to end
3049 * with each function called given the item href string in the text. If the
3050 * function returns an object handle other than NULL (it should create an
3051 * and object to do this), then this object is used to replace that item. If
3052 * not the next provider is called until one provides an item object, or the
3053 * default provider in entry does.
3055 * @param obj The entry object
3056 * @param func The function called to provide the item object
3057 * @param data The data passed to @p func
3062 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3064 ELM_CHECK_WIDTYPE(obj, widtype);
3065 Widget_Data *wd = elm_widget_data_get(obj);
3068 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3072 wd->item_providers = eina_list_append(wd->item_providers, ip);
3076 * This prepends a custom item provider to the list for that entry
3078 * This prepends the given callback. See elm_entry_item_provider_append() for
3081 * @param obj The entry object
3082 * @param func The function called to provide the item object
3083 * @param data The data passed to @p func
3088 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3090 ELM_CHECK_WIDTYPE(obj, widtype);
3091 Widget_Data *wd = elm_widget_data_get(obj);
3094 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3098 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3102 * This removes a custom item provider to the list for that entry
3104 * This removes the given callback. See elm_entry_item_provider_append() for
3107 * @param obj The entry object
3108 * @param func The function called to provide the item object
3109 * @param data The data passed to @p func
3114 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3116 ELM_CHECK_WIDTYPE(obj, widtype);
3117 Widget_Data *wd = elm_widget_data_get(obj);
3119 Elm_Entry_Item_Provider *ip;
3122 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3124 if ((ip->func == func) && (ip->data == data))
3126 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3134 * This converts a markup (HTML-like) string into UTF-8.
3136 * @param s The string (in markup) to be converted
3137 * @return The converted string (in UTF-8)
3142 elm_entry_markup_to_utf8(const char *s)
3144 char *ss = _mkup_to_text(s);
3145 if (!ss) ss = strdup("");
3150 * This converts a UTF-8 string into markup (HTML-like).
3152 * @param s The string (in UTF-8) to be converted
3153 * @return The converted string (in markup)
3158 elm_entry_utf8_to_markup(const char *s)
3160 char *ss = _text_to_mkup(s);
3161 if (!ss) ss = strdup("");
3166 * Get the input method context in the entry widget
3168 * @param obj The entry object
3169 * @return The input method context
3173 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3175 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3176 Widget_Data *wd = elm_widget_data_get(obj);
3177 if (!wd || !wd->ent) return NULL;
3179 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3183 * Set whether entry should enable the return key on soft keyboard automatically
3185 * @param obj The entry object
3186 * @param on If true, entry enables the return key on soft keyboard automatically.
3191 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3193 ELM_CHECK_WIDTYPE(obj, widtype);
3194 Widget_Data *wd = elm_widget_data_get(obj);
3197 wd->autoreturnkey = on;
3198 _check_enable_returnkey(obj);
3202 * Set whether entry should support auto capitalization
3204 * @param obj The entry object
3205 * @param on If true, entry suports auto capitalization.
3210 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3212 ELM_CHECK_WIDTYPE(obj, widtype);
3213 Widget_Data *wd = elm_widget_data_get(obj);
3217 wd->autocapital = EINA_FALSE;
3219 wd->autocapital = autocap;
3221 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3222 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3223 wd->autocapital = EINA_FALSE;
3225 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3229 * Set whether entry should support auto period
3231 * @param obj The entry object
3232 * @param on If true, entry suports auto period.
3237 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3239 ELM_CHECK_WIDTYPE(obj, widtype);
3240 Widget_Data *wd = elm_widget_data_get(obj);
3244 wd->autoperiod = EINA_FALSE;
3246 wd->autoperiod = autoperiod;
3248 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3249 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3250 wd->autoperiod = EINA_FALSE;
3252 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3256 * Set the font size on the entry object
3258 * @param obj The entry object
3259 * @param size font size
3264 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3266 ELM_CHECK_WIDTYPE(obj, widtype);
3267 Widget_Data *wd = elm_widget_data_get(obj);
3268 Eina_Strbuf *fontbuf = NULL;
3273 t = eina_stringshare_add(elm_entry_entry_get(obj));
3274 fontbuf = eina_strbuf_new();
3275 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3277 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3279 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3281 elm_entry_entry_set(obj, t);
3285 eina_strbuf_free(fontbuf);
3286 eina_stringshare_del(t);
3290 * Set the text align on the entry object
3292 * @param obj The entry object
3293 * @param align align mode
3298 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3300 ELM_CHECK_WIDTYPE(obj, widtype);
3301 Widget_Data *wd = elm_widget_data_get(obj);
3306 t = eina_stringshare_add(elm_entry_entry_get(obj));
3308 if (len <= 0) return;
3310 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3311 elm_entry_entry_set(obj, t);
3315 eina_stringshare_del(t);
3319 * Set the text color on the entry object
3321 * @param obj The entry object
3322 * @param r Red property background color of The entry object
3323 * @param g Green property background color of The entry object
3324 * @param b Blue property background color of The entry object
3325 * @param a Alpha property background alpha of The entry object
3330 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3332 ELM_CHECK_WIDTYPE(obj, widtype);
3333 Widget_Data *wd = elm_widget_data_get(obj);
3334 Eina_Strbuf *colorbuf = NULL;
3339 t = eina_stringshare_add(elm_entry_entry_get(obj));
3341 if (len <= 0) return;
3342 colorbuf = eina_strbuf_new();
3343 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3345 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3347 elm_entry_entry_set(obj, t);
3351 eina_strbuf_free(colorbuf);
3352 eina_stringshare_del(t);
3357 * Set background color of the entry
3359 * @param obj The entry object
3360 * @param r Red property background color of The entry object
3361 * @param g Green property background color of The entry object
3362 * @param b Blue property background color of The entry object
3363 * @param a Alpha property background alpha of The entry object
3367 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3369 ELM_CHECK_WIDTYPE(obj, widtype);
3370 Widget_Data *wd = elm_widget_data_get(obj);
3371 evas_object_color_set(wd->bg, r, g, b, a);
3373 if (wd->bgcolor == EINA_FALSE)
3376 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3381 * Set the ellipsis behavior of the entry
3383 * @param obj The entry object
3384 * @param ellipsis To ellipsis text or not
3388 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3390 ELM_CHECK_WIDTYPE(obj, widtype);
3391 Widget_Data *wd = elm_widget_data_get(obj);
3392 if (wd->ellipsis == ellipsis) return;
3393 wd->ellipsis = ellipsis;
3399 * This sets the attribute to show the input panel automatically.
3401 * @param obj The entry object
3402 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
3407 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3409 ELM_CHECK_WIDTYPE(obj, widtype);
3410 Widget_Data *wd = elm_widget_data_get(obj);
3413 wd->input_panel_enable = enabled;
3414 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
3418 * Set the input panel layout of the entry
3420 * @param obj The entry object
3421 * @param layout the layout to set
3426 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
3428 ELM_CHECK_WIDTYPE(obj, widtype);
3429 Widget_Data *wd = elm_widget_data_get(obj);
3432 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
3435 wd->input_panel_layout = layout;
3437 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
3440 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/