1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "elm_widget_entry.h"
5 #include "elm_module_priv.h" // TIZEN ONLY
7 #ifdef HAVE_ELEMENTARY_X
13 EAPI const char ELM_ENTRY_SMART_NAME[] = "elm_entry";
15 /* Maximum chunk size to be inserted to the entry at once
16 * FIXME: This size is arbitrary, should probably choose a better size.
17 * Possibly also find a way to set it to a low value for weak computers,
18 * and to a big value for better computers. */
19 #define _CHUNK_SIZE 10000
21 static const char SIG_ABORTED[] = "aborted";
22 static const char SIG_ACTIVATED[] = "activated";
23 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
24 static const char SIG_ANCHOR_DOWN[] = "anchor,down";
25 static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened";
26 static const char SIG_ANCHOR_IN[] = "anchor,in";
27 static const char SIG_ANCHOR_OUT[] = "anchor,out";
28 static const char SIG_ANCHOR_UP[] = "anchor,up";
29 static const char SIG_CHANGED[] = "changed";
30 static const char SIG_CHANGED_USER[] = "changed,user";
31 static const char SIG_CLICKED[] = "clicked";
32 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
33 static const char SIG_CLICKED_TRIPLE[] = "clicked,triple";
34 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
35 static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual";
36 static const char SIG_FOCUSED[] = "focused";
37 static const char SIG_LANG_CHANGED[] = "language,changed";
38 static const char SIG_LONGPRESSED[] = "longpressed";
39 static const char SIG_MAX_LENGHT[] = "maxlength,reached";
40 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
41 static const char SIG_PRESS[] = "press";
42 static const char SIG_REDO_REQUEST[] = "redo,request";
43 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
44 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
45 static const char SIG_SELECTION_COPY[] = "selection,copy";
46 static const char SIG_SELECTION_CUT[] = "selection,cut";
47 static const char SIG_SELECTION_PASTE[] = "selection,paste";
48 static const char SIG_SELECTION_START[] = "selection,start";
49 static const char SIG_THEME_CHANGED[] = "theme,changed";
50 static const char SIG_UNDO_REQUEST[] = "undo,request";
51 static const char SIG_UNFOCUSED[] = "unfocused";
52 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
55 {SIG_ANCHOR_CLICKED, ""},
56 {SIG_ANCHOR_DOWN, ""},
57 {SIG_ANCHOR_HOVER_OPENED, ""},
62 {SIG_CHANGED_USER, ""},
64 {SIG_CLICKED_DOUBLE, ""},
65 {SIG_CLICKED_TRIPLE, ""},
66 {SIG_CURSOR_CHANGED, ""},
67 {SIG_CURSOR_CHANGED_MANUAL, ""},
69 {SIG_LANG_CHANGED, ""},
70 {SIG_LONGPRESSED, ""},
72 {SIG_PREEDIT_CHANGED, ""},
74 {SIG_REDO_REQUEST, ""},
75 {SIG_SELECTION_CHANGED, ""},
76 {SIG_SELECTION_CLEARED, ""},
77 {SIG_SELECTION_COPY, ""},
78 {SIG_SELECTION_CUT, ""},
79 {SIG_SELECTION_PASTE, ""},
80 {SIG_SELECTION_START, ""},
81 {SIG_THEME_CHANGED, ""},
82 {SIG_UNDO_REQUEST, ""},
87 static const Elm_Layout_Part_Alias_Description _content_aliases[] =
89 {"icon", "elm.swallow.icon"},
90 {"end", "elm.swallow.end"},
94 static const Evas_Smart_Interface *_smart_interfaces[] =
96 (Evas_Smart_Interface *)&ELM_SCROLLABLE_IFACE, NULL
99 EVAS_SMART_SUBCLASS_IFACE_NEW
100 (ELM_ENTRY_SMART_NAME, _elm_entry, Elm_Entry_Smart_Class,
101 Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks,
104 static Eina_List *entries = NULL;
108 void (*obj_hook)(Evas_Object *obj);
109 void (*obj_unhook)(Evas_Object *obj);
110 void (*obj_longpress)(Evas_Object *obj);
112 void (*obj_hidemenu) (Evas_Object *obj);
113 void (*obj_mouseup) (Evas_Object *obj);
117 ////////////////////////// TIZEN ONLY - START
118 static void _hover_cancel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
119 static void _hover_selected_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
120 static void _copy_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
121 static void _cut_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
122 static void _paste_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
123 static void _menu_call(Evas_Object *obj);
126 _select_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
128 ELM_ENTRY_DATA_GET(data, sd);
130 if (!sd->sel_allow) return;
131 sd->sel_mode = EINA_TRUE;
132 edje_object_part_text_select_none(sd->entry_edje, "elm.text");
133 edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
134 edje_object_part_text_select_all(sd->entry_edje, "elm.text");
135 elm_object_scroll_freeze_pop(data);
139 _select_word(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
141 ELM_ENTRY_DATA_GET(data, sd);
143 if (!sd->sel_allow) return;
144 sd->sel_mode = EINA_TRUE;
146 if (!_elm_config->desktop_entry)
149 edje_object_part_text_select_allow_set
150 (sd->entry_edje, "elm.text", EINA_TRUE);
152 edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
153 edje_object_part_text_select_word(sd->entry_edje, "elm.text");
154 elm_object_scroll_freeze_pop(data);
157 #ifdef HAVE_ELEMENTARY_X
158 static Ecore_X_Window
161 Ecore_X_Atom x_atom_cbhm = ecore_x_atom_get("CBHM_XWIN");
162 Ecore_X_Window x_cbhm_win = 0;
163 unsigned char *buf = NULL;
165 int ret = ecore_x_window_prop_property_get(0, x_atom_cbhm, XA_WINDOW, 0, &buf, &num);
167 memcpy(&x_cbhm_win, buf, sizeof(Ecore_X_Window));
175 _cbhm_msg_send(Evas_Object *obj, char *msg)
177 #ifdef HAVE_ELEMENTARY_X
178 Ecore_X_Window x_cbhm_win = _cbhm_window_get();
179 Ecore_X_Atom x_atom_cbhm_msg = ecore_x_atom_get("CBHM_MSG");
180 Ecore_X_Window xwin = elm_win_xwindow_get(obj);
182 if (!x_cbhm_win || !x_atom_cbhm_msg)
185 XClientMessageEvent m;
186 memset(&m, 0, sizeof(m));
187 m.type = ClientMessage;
188 m.display = ecore_x_display_get();
190 m.message_type = x_atom_cbhm_msg;
192 snprintf(m.data.b, 20, "%s", msg);
194 XSendEvent(ecore_x_display_get(), x_cbhm_win, False, NoEventMask, (XEvent*)&m);
204 _xclient_msg_cb(void *data, int type __UNUSED__, void *event)
206 #ifdef HAVE_ELEMENTARY_X
207 Evas_Object *obj = (Evas_Object *)data;
208 ELM_ENTRY_DATA_GET(data, sd);
209 Ecore_X_Event_Client_Message *ev = event;
211 if (ev->message_type != ecore_x_atom_get("CBHM_MSG"))
212 return ECORE_CALLBACK_PASS_ON;
214 if (!strcmp("SET_OWNER", ev->data.b))
216 if (elm_object_focus_get(obj) == EINA_TRUE)
218 ecore_x_selection_secondary_set(elm_win_xwindow_get(data), "", 1);
220 if (sd->cnp_mode != ELM_CNP_MODE_MARKUP)
221 _cbhm_msg_send(data, "show0");
223 _cbhm_msg_send(data, "show1");
227 return ECORE_CALLBACK_PASS_ON;
231 _magnifier_hide(void *data)
233 ELM_ENTRY_DATA_GET(data, sd);
235 if (sd->magnifier_showing)
237 evas_object_hide(sd->mgf_bg);
238 evas_object_hide(sd->mgf_clip);
242 sd->s_iface->freeze_set(data, EINA_FALSE);
244 sd->magnifier_showing = EINA_FALSE;
248 _magnifier_show(void *data)
250 ELM_ENTRY_DATA_GET(data, sd);
252 if (!sd->magnifier_showing)
254 evas_object_show(sd->mgf_bg);
255 evas_object_show(sd->mgf_clip);
258 sd->magnifier_showing = EINA_TRUE;
262 _magnifier_move(void *data)
264 ELM_ENTRY_DATA_GET(data, sd);
266 Evas_Coord x, y, w, h;
267 Evas_Coord cx, cy, cw, ch, ox, oy;
269 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
273 evas_object_geometry_get(sd->scr_edje, &x, &y, &w, &h);
274 sd->s_iface->content_pos_get(data, &ox, &oy);
279 evas_object_geometry_get(data, &x, &y, &w, &h);
283 if ((cy + y) - sd->mgf_height < 0)
284 oy = -1 * ((cy + y) - sd->mgf_height);
286 if (sd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
287 evas_object_move(sd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - sd->mgf_height + oy);
288 else if (sd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
289 evas_object_move(sd->mgf_bg, x, (cy + y) - sd->mgf_height + oy);
293 evas_object_move(sd->mgf_proxy,
294 (1 - sd->mgf_scale) * cx + x + ox,
295 (1 - sd->mgf_scale) * cy + y - sd->mgf_height/2 - ch/2 - sd->mgf_arrow_height + sd->mgf_scale * oy);
299 _magnifier_create(void *data)
301 ELM_ENTRY_DATA_GET(data, sd);
303 Evas_Coord x, y, w, h, mw, mh;
304 const char* key_data = NULL;
309 evas_object_image_source_unset(sd->mgf_proxy);
310 evas_object_color_set(sd->mgf_proxy, 255, 255, 255, 0);
311 evas_object_hide(sd->mgf_proxy);
312 evas_object_clip_unset(sd->mgf_proxy);
313 evas_object_del(sd->mgf_proxy);
315 if (sd->mgf_bg) evas_object_del(sd->mgf_bg);
316 if (sd->mgf_clip) evas_object_del(sd->mgf_clip);
319 evas_object_geometry_get(sd->scr_edje, &x, &y, &w, &h);
321 evas_object_geometry_get(data, &x, &y, &w, &h);
323 if ((w <= 0) || (h <= 0))
326 sd->mgf_bg = edje_object_add(evas_object_evas_get(data));
328 if (sd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
329 _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier",
331 else if (sd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
332 _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier",
337 sd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
338 evas_object_color_set(sd->mgf_clip, 255, 255, 255, 255);
339 edje_object_part_swallow(sd->mgf_bg, "swallow", sd->mgf_clip);
341 key_data = edje_object_data_get(sd->mgf_bg, "height");
342 if (key_data) sd->mgf_height = atoi(key_data);
343 key_data = edje_object_data_get(sd->mgf_bg, "scale");
344 if (key_data) sd->mgf_scale = atof(key_data);
345 key_data = edje_object_data_get(sd->mgf_bg, "arrow");
347 sd->mgf_arrow_height = atoi(key_data);
349 sd->mgf_arrow_height = 0;
351 elm_scale = elm_config_scale_get();
352 sd->mgf_height = (int)((float)sd->mgf_height * elm_scale);
354 if (sd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
355 evas_object_resize(sd->mgf_bg, w, sd->mgf_height);
359 sd->s_iface->freeze_set(data, EINA_TRUE);
360 sd->mgf_proxy = evas_object_image_add(evas_object_evas_get(sd->scr_edje));
361 evas_object_image_source_set(sd->mgf_proxy, sd->scr_edje);
365 sd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
366 evas_object_image_source_set(sd->mgf_proxy, data);
369 mw = (Evas_Coord)((float)w * sd->mgf_scale);
370 mh = (Evas_Coord)((float)h * sd->mgf_scale);
371 if ((mw <= 0) || (mh <= 0))
374 evas_object_resize(sd->mgf_proxy, mw, mh);
375 evas_object_image_fill_set(sd->mgf_proxy, 0, 0, mw, mh);
376 evas_object_color_set(sd->mgf_proxy, 255, 255, 255, 255);
377 evas_object_pass_events_set(sd->mgf_proxy, EINA_TRUE);
378 evas_object_show(sd->mgf_proxy);
379 evas_object_clip_set(sd->mgf_proxy, sd->mgf_clip);
381 evas_object_layer_set(sd->mgf_bg, EVAS_LAYER_MAX);
382 evas_object_layer_set(sd->mgf_proxy, EVAS_LAYER_MAX);
386 _magnifier_content_resize(void *data)
388 ELM_ENTRY_DATA_GET(data, sd);
389 Evas_Coord w, h, mw, mh;
392 evas_object_geometry_get(sd->scr_edje, NULL, NULL, &w, &h);
394 evas_object_geometry_get(data, NULL, NULL, &w, &h);
396 if ((w <= 0) || (h <= 0))
399 mw = (Evas_Coord)((float)w * sd->mgf_scale);
400 mh = (Evas_Coord)((float)h * sd->mgf_scale);
402 if ((mw <= 0) || (mh <= 0))
405 evas_object_resize(sd->mgf_proxy, mw, mh);
406 evas_object_image_fill_set(sd->mgf_proxy, 0, 0, mw, mh);
410 _signal_long_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
412 ELM_ENTRY_DATA_GET(data, sd);
413 if (sd->disabled) return;
415 sd->long_pressed = EINA_TRUE;
416 _hover_cancel_cb(data, NULL, NULL);
417 if (sd->magnifier_enabled)
419 _magnifier_create(data);
420 _magnifier_move(data);
421 _magnifier_show(data);
422 elm_object_scroll_freeze_push(data);
427 _signal_handler_move_start_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
429 ELM_ENTRY_DATA_GET(data, sd);
431 elm_object_scroll_freeze_push(data);
433 if ((sd->api) && (sd->api->obj_hidemenu))
434 sd->api->obj_hidemenu(data);
436 if (sd->magnifier_enabled)
438 _magnifier_create(data);
439 _magnifier_move(data);
440 _magnifier_show(data);
445 _signal_handler_move_end_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
447 elm_object_scroll_freeze_pop(data);
449 _magnifier_hide(data);
454 _signal_handler_moving_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
456 ELM_ENTRY_DATA_GET(data, sd);
458 if (sd->magnifier_enabled)
460 _magnifier_move(data);
461 _magnifier_show(data);
466 _signal_handler_click_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
468 _select_word(data, NULL, NULL);
471 static Evas_Coord_Rectangle
472 _intersection_region_get(Evas_Coord_Rectangle rect1, Evas_Coord_Rectangle rect2)
474 Evas_Coord_Rectangle ret_rect;
475 Evas_Coord_Point l1, l2, r1, r2, p1, p2;
479 r1.x = rect1.x + rect1.w;
480 r1.y = rect1.y + rect1.h;
484 r2.x = rect2.x + rect2.w;
485 r2.y = rect2.y + rect2.h;
487 p1.x = (l1.x > l2.x) ? l1.x : l2.x;
488 p1.y = (l1.y > l2.y) ? l1.y : l2.y;
489 p2.x = (r1.x < r2.x) ? r1.x : r2.x;
490 p2.y = (r1.y < r2.y) ? r1.y : r2.y;
494 ret_rect.w = (p2.x > p1.x) ? p2.x - p1.x : -1;
495 ret_rect.h = (p2.y > p1.y) ? p2.y - p1.y : -1;
500 static Evas_Coord_Rectangle
501 _viewport_region_get(Evas_Object *data)
503 Evas_Coord_Rectangle geometry, ret_rect;
504 geometry.x = geometry.y = geometry.w = geometry.h = -1;
507 ELM_ENTRY_DATA_GET(data, sd);
508 if (!data || !strlen(elm_widget_type_get(data))) return geometry;
512 evas_object_geometry_get(sd->scr_edje,
521 Evas_Object *parent_obj = data;
523 while ((parent_obj = elm_widget_parent_get(parent_obj)))
525 if (!strcmp(elm_widget_type_get(parent_obj), "elm_scroller") ||
526 !strcmp(elm_widget_type_get(parent_obj), "elm_genlist"))
528 evas_object_geometry_get(parent_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
529 if ((ret_rect.w == -1) && (ret_rect.h == -1)) ret_rect = geometry;
530 ret_rect = _intersection_region_get(geometry, ret_rect);
537 static Evas_Coord_Rectangle
538 _layout_region_get(Evas_Object *data)
540 Evas_Coord_Rectangle geometry;
541 geometry.x = geometry.y = geometry.w = geometry.h = -1;
543 if (!data || !strlen(elm_widget_type_get(data))) return geometry;
545 Evas_Object *child_obj = data;
546 Evas_Object *parent_obj;
548 while ((parent_obj = elm_widget_parent_get(child_obj)))
550 if (!strcmp(elm_widget_type_get(parent_obj), "elm_conformant"))
552 evas_object_geometry_get(child_obj, &geometry.x, &geometry.y, &geometry.w, &geometry.h);
555 child_obj = parent_obj;
562 _region_recalc_job(void *data)
564 ELM_ENTRY_DATA_GET(data, sd);
565 Evas_Coord_Rectangle ret_rect;
567 sd->region_recalc_job = NULL;
569 if (!_elm_config->desktop_entry)
571 ret_rect = _viewport_region_get(data);
572 edje_object_part_text_viewport_region_set(sd->entry_edje, "elm.text",
573 ret_rect.x, ret_rect.y,
574 ret_rect.w, ret_rect.h);
575 ret_rect = _layout_region_get(data);
576 edje_object_part_text_layout_region_set(sd->entry_edje, "elm.text",
577 ret_rect.x, ret_rect.y,
578 ret_rect.w, ret_rect.h);
583 _region_get_job(void *data)
585 ELM_ENTRY_DATA_GET(data, sd);
587 sd->region_get_job = NULL;
589 if (!_elm_config->desktop_entry)
591 if (sd->region_recalc_job) ecore_job_del(sd->region_recalc_job);
592 sd->region_recalc_job = ecore_job_add(_region_recalc_job, data);
594 evas_smart_objects_calculate(evas_object_evas_get(data));
599 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
601 ELM_ENTRY_DATA_GET(data, sd);
602 if (sd->disabled) return;
604 if (sd->magnifier_enabled)
605 _magnifier_hide(data);
610 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
612 ELM_ENTRY_DATA_GET(data, sd);
613 Evas_Coord cx, cy, cw, ch;
615 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
616 if (!sd->deferred_recalc_job)
617 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
620 sd->deferred_cur = EINA_TRUE;
629 _elm_entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
631 Evas_Event_Key_Down *ev = event_info;
632 if (!ev->keyname) return;
634 ELM_ENTRY_DATA_GET(data, sd);
637 if (!_elm_config->desktop_entry)
638 edje_object_part_text_select_allow_set
639 (sd->entry_edje, "elm.text", EINA_TRUE);
641 if ((sd->api) && (sd->api->obj_hidemenu))
642 sd->api->obj_hidemenu(data);
645 void elm_entry_extension_module_data_get(Evas_Object *obj, Elm_Entry_Extension_data *ext_mod)
647 ELM_ENTRY_DATA_GET(obj, sd);
649 ext_mod->cancel = _hover_cancel_cb;
650 ext_mod->copy = _copy_cb;
651 ext_mod->cut = _cut_cb;
652 ext_mod->paste = _paste_cb;
653 ext_mod->select = _select_word;
654 ext_mod->selectall = _select_all;
655 ext_mod->ent = sd->entry_edje;
656 ext_mod->items = sd->items;
657 ext_mod->editable = sd->editable;
658 ext_mod->have_selection = sd->have_selection;
659 ext_mod->password = sd->password;
660 ext_mod->selmode = sd->sel_mode;
661 ext_mod->context_menu = sd->context_menu;
662 ext_mod->cnp_mode = sd->cnp_mode;
663 ext_mod->viewport_rect = _viewport_region_get(obj);
665 ////////////////////////// TIZEN ONLY - END
668 _module_find(Evas_Object *obj __UNUSED__)
670 static Elm_Module *m = NULL;
672 if (m) goto ok; // already found - just use
673 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
675 m->api = malloc(sizeof(Mod_Api));
676 if (!m->api) return NULL;
678 ((Mod_Api *)(m->api))->obj_hook = // called on creation
679 _elm_module_symbol_get(m, "obj_hook");
680 ((Mod_Api *)(m->api))->obj_unhook = // called on deletion
681 _elm_module_symbol_get(m, "obj_unhook");
682 ((Mod_Api *)(m->api))->obj_longpress = // called on long press menu
683 _elm_module_symbol_get(m, "obj_longpress");
685 ((Mod_Api *)(m->api))->obj_hidemenu = // called on hide menu
686 _elm_module_symbol_get(m, "obj_hidemenu");
687 ((Mod_Api *)(m->api))->obj_mouseup = // called on mouseup
688 _elm_module_symbol_get(m, "obj_mouseup");
690 ok: // ok - return api
695 _file_load(const char *file)
701 f = eina_file_open(file, EINA_FALSE);
704 tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
705 if (!tmp) goto on_error;
707 text = malloc(eina_file_size_get(f) + 1);
708 if (!text) goto on_error;
710 memcpy(text, tmp, eina_file_size_get(f));
711 text[eina_file_size_get(f)] = 0;
713 if (eina_file_map_faulted(f, tmp))
720 if (tmp) eina_file_map_free(f, tmp);
727 _plain_load(const char *file)
731 text = _file_load(file);
736 text2 = elm_entry_utf8_to_markup(text);
745 _load_do(Evas_Object *obj)
749 ELM_ENTRY_DATA_GET(obj, sd);
753 elm_object_text_set(obj, "");
759 case ELM_TEXT_FORMAT_PLAIN_UTF8:
760 text = _plain_load(sd->file);
763 case ELM_TEXT_FORMAT_MARKUP_UTF8:
764 text = _file_load(sd->file);
774 elm_object_text_set(obj, text);
781 elm_object_text_set(obj, "");
788 _utf8_markup_save(const char *file,
793 if ((!text) || (!text[0]))
795 ecore_file_unlink(file);
800 f = fopen(file, "wb");
803 // FIXME: report a write error
807 fputs(text, f); // FIXME: catch error
812 _utf8_plain_save(const char *file,
817 text2 = elm_entry_markup_to_utf8(text);
821 _utf8_markup_save(file, text2);
826 _save_do(Evas_Object *obj)
828 ELM_ENTRY_DATA_GET(obj, sd);
830 if (!sd->file) return;
833 case ELM_TEXT_FORMAT_PLAIN_UTF8:
834 _utf8_plain_save(sd->file, elm_object_text_get(obj));
837 case ELM_TEXT_FORMAT_MARKUP_UTF8:
838 _utf8_markup_save(sd->file, elm_object_text_get(obj));
847 _delay_write(void *data)
849 ELM_ENTRY_DATA_GET(data, sd);
852 sd->delay_write = NULL;
854 return ECORE_CALLBACK_CANCEL;
858 _elm_entry_guide_update(Evas_Object *obj,
861 ELM_ENTRY_DATA_GET(obj, sd);
863 if ((has_text) && (!sd->has_text))
864 edje_object_signal_emit(sd->entry_edje, "elm,guide,disabled", "elm");
865 else if ((!has_text) && (sd->has_text))
866 edje_object_signal_emit(sd->entry_edje, "elm,guide,enabled", "elm");
868 sd->has_text = has_text;
871 static Elm_Entry_Markup_Filter *
872 _filter_new(Elm_Entry_Filter_Cb func,
875 Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
877 if (!tf) return NULL;
880 if (func == elm_entry_filter_limit_size)
882 Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
891 lim2 = malloc(sizeof(Elm_Entry_Filter_Limit_Size));
898 memcpy(lim2, lim, sizeof(Elm_Entry_Filter_Limit_Size));
901 else if (func == elm_entry_filter_accept_set)
903 Elm_Entry_Filter_Accept_Set *as = data, *as2;
911 as2 = malloc(sizeof(Elm_Entry_Filter_Accept_Set));
919 as2->accepted = eina_stringshare_add(as->accepted);
921 as2->accepted = NULL;
923 as2->rejected = eina_stringshare_add(as->rejected);
925 as2->rejected = NULL;
934 _filter_free(Elm_Entry_Markup_Filter *tf)
936 if (tf->func == elm_entry_filter_limit_size)
938 Elm_Entry_Filter_Limit_Size *lim = tf->data;
942 else if (tf->func == elm_entry_filter_accept_set)
944 Elm_Entry_Filter_Accept_Set *as = tf->data;
948 if (as->accepted) eina_stringshare_del(as->accepted);
949 if (as->rejected) eina_stringshare_del(as->rejected);
958 _mirrored_set(Evas_Object *obj,
961 ELM_ENTRY_DATA_GET(obj, sd);
963 edje_object_mirrored_set(sd->entry_edje, rtl);
965 if (sd->anchor_hover.hover)
966 elm_widget_mirrored_set(sd->anchor_hover.hover, rtl);
970 _elm_entry_theme_group_get(Evas_Object *obj)
972 ELM_ENTRY_DATA_GET(obj, sd);
976 if (sd->password) return "base-password";
979 if (sd->single_line) return "base-single";
982 switch (sd->line_wrap)
985 return "base-charwrap";
991 return "base-mixedwrap";
995 return "base-nowrap";
1002 if (sd->password) return "base-password";
1005 if (sd->single_line) return "base-single-noedit";
1008 switch (sd->line_wrap)
1011 return "base-noedit-charwrap";
1014 return "base-noedit";
1016 case ELM_WRAP_MIXED:
1017 return "base-noedit-mixedwrap";
1021 return "base-nowrap-noedit";
1028 /* we can't reuse layout's here, because it's on entry_edje only */
1030 _elm_entry_smart_disable(Evas_Object *obj)
1032 ELM_ENTRY_DATA_GET(obj, sd);
1034 if (elm_object_disabled_get(obj))
1036 edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
1037 sd->disabled = EINA_TRUE;
1041 edje_object_signal_emit(sd->entry_edje, "elm,state,enabled", "elm");
1042 sd->disabled = EINA_FALSE;
1048 /* we can't issue the layout's theming code here, cause it assumes an
1049 * unique edje object, always */
1051 _elm_entry_smart_theme(Evas_Object *obj)
1054 Elm_Widget_Smart_Class *parent_parent =
1055 (Elm_Widget_Smart_Class *)((Evas_Smart_Class *)
1056 _elm_entry_parent_sc)->parent;
1058 ELM_ENTRY_DATA_GET(obj, sd);
1060 if (!parent_parent->theme(obj))
1063 evas_event_freeze(evas_object_evas_get(obj));
1065 // TIZEN ONLY(130129) : Currently, for freezing cursor movement only.
1066 edje_object_part_text_freeze(sd->entry_edje, "elm.text");
1069 edje_object_mirrored_set
1070 (ELM_WIDGET_DATA(sd)->resize_obj, elm_widget_mirrored_get(obj));
1072 edje_object_scale_set
1073 (ELM_WIDGET_DATA(sd)->resize_obj,
1074 elm_widget_scale_get(obj) * elm_config_scale_get());
1076 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1078 // TIZEN ONLY(130225) : when password mode, elm_object_text_get returns utf8 string.
1080 t = eina_stringshare_add(elm_entry_utf8_to_markup(elm_object_text_get(obj)));
1082 t = eina_stringshare_add(elm_object_text_get(obj));
1084 elm_widget_theme_object_set
1085 (obj, sd->entry_edje, "entry", _elm_entry_theme_group_get(obj),
1086 elm_widget_style_get(obj));
1088 if (_elm_config->desktop_entry)
1089 edje_object_part_text_select_allow_set
1090 (sd->entry_edje, "elm.text", EINA_TRUE);
1092 elm_object_text_set(obj, t);
1093 eina_stringshare_del(t);
1095 if (elm_widget_disabled_get(obj))
1096 edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
1098 edje_object_part_text_input_panel_layout_set
1099 (sd->entry_edje, "elm.text", sd->input_panel_layout);
1100 edje_object_part_text_autocapital_type_set
1101 (sd->entry_edje, "elm.text", sd->autocapital_type);
1102 edje_object_part_text_prediction_allow_set
1103 (sd->entry_edje, "elm.text", sd->prediction_allow);
1104 edje_object_part_text_input_panel_enabled_set
1105 (sd->entry_edje, "elm.text", sd->input_panel_enable);
1106 edje_object_part_text_input_panel_imdata_set
1107 (sd->entry_edje, "elm.text", sd->input_panel_imdata,
1108 sd->input_panel_imdata_len);
1109 edje_object_part_text_input_panel_return_key_type_set
1110 (sd->entry_edje, "elm.text", sd->input_panel_return_key_type);
1111 edje_object_part_text_input_panel_return_key_disabled_set
1112 (sd->entry_edje, "elm.text", sd->input_panel_return_key_disabled);
1114 if (sd->cursor_pos != 0)
1115 elm_entry_cursor_pos_set(obj, sd->cursor_pos);
1117 if (elm_widget_focus_get(obj))
1118 edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
1120 edje_object_message_signal_process(sd->entry_edje);
1126 sd->s_iface->mirrored_set(obj, elm_widget_mirrored_get(obj));
1128 elm_widget_theme_object_set
1129 (obj, sd->scr_edje, "scroller", "entry", elm_widget_style_get(obj));
1131 str = edje_object_data_get(sd->scr_edje, "focus_highlight");
1132 if ((str) && (!strcmp(str, "on")))
1133 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
1135 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
1138 elm_layout_sizing_eval(obj);
1140 sd->has_text = !sd->has_text;
1141 _elm_entry_guide_update(obj, !sd->has_text);
1142 evas_event_thaw(evas_object_evas_get(obj));
1143 evas_event_thaw_eval(evas_object_evas_get(obj));
1145 // TIZEN ONLY(130129) : Currently, for freezing cursor movement only.
1146 edje_object_part_text_thaw(sd->entry_edje, "elm.text");
1149 evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
1155 _cursor_geometry_recalc(Evas_Object *obj)
1157 ELM_ENTRY_DATA_GET(obj, sd);
1159 evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL);
1161 if (!sd->deferred_recalc_job)
1163 Evas_Coord cx, cy, cw, ch;
1165 edje_object_part_text_cursor_geometry_get
1166 (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1167 if (sd->cur_changed)
1169 elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
1170 sd->cur_changed = EINA_FALSE;
1174 sd->deferred_cur = EINA_TRUE;
1178 _deferred_recalc_job(void *data)
1180 Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0;
1182 ELM_ENTRY_DATA_GET(data, sd);
1184 sd->deferred_recalc_job = NULL;
1186 evas_object_geometry_get(sd->entry_edje, NULL, NULL, &resw, NULL);
1187 edje_object_size_min_restricted_calc(sd->entry_edje, &minw, &minh, resw, 0);
1188 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1190 /* This is a hack to workaround the way min size hints are treated.
1191 * If the minimum width is smaller than the restricted width, it
1192 * means the minimum doesn't matter. */
1195 Evas_Coord ominw = -1;
1197 evas_object_size_hint_min_get(data, &ominw, NULL);
1204 elm_coords_finger_size_adjust(1, &fw, 1, &fh);
1207 Evas_Coord vmw = 0, vmh = 0;
1209 edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
1210 if (sd->single_line)
1212 evas_object_size_hint_min_set(data, vmw, minh + vmh);
1213 evas_object_size_hint_max_set(data, -1, minh + vmh);
1217 evas_object_size_hint_min_set(data, vmw, vmh);
1218 evas_object_size_hint_max_set(data, -1, -1);
1223 if (sd->single_line)
1225 evas_object_size_hint_min_set(data, minw, minh);
1226 evas_object_size_hint_max_set(data, -1, minh);
1230 evas_object_size_hint_min_set(data, fw, minh);
1231 evas_object_size_hint_max_set(data, -1, -1);
1235 if (sd->deferred_cur)
1237 Evas_Coord cx, cy, cw, ch;
1239 edje_object_part_text_cursor_geometry_get
1240 (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1241 if (sd->cur_changed)
1243 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
1244 sd->cur_changed = EINA_FALSE;
1250 _elm_entry_smart_sizing_eval(Evas_Object *obj)
1252 Evas_Coord minw = -1, minh = -1;
1253 Evas_Coord resw, resh;
1255 ELM_ENTRY_DATA_GET(obj, sd);
1257 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh);
1261 if ((resw == sd->last_w) && (!sd->changed))
1265 Evas_Coord vw = 0, vh = 0, w = 0, h = 0;
1267 sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
1271 if (vw > sd->ent_mw) w = vw;
1272 if (vh > sd->ent_mh) h = vh;
1273 evas_object_resize(sd->entry_edje, w, h);
1281 evas_event_freeze(evas_object_evas_get(obj));
1282 sd->changed = EINA_FALSE;
1286 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
1288 evas_object_resize(sd->scr_edje, resw, resh);
1289 edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
1290 sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
1291 edje_object_size_min_restricted_calc
1292 (sd->entry_edje, &minw, &minh, vw, 0);
1293 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1295 /* This is a hack to workaround the way min size hints
1296 * are treated. If the minimum width is smaller than the
1297 * restricted width, it means the minimum doesn't
1301 Evas_Coord ominw = -1;
1303 evas_object_size_hint_min_get(sd->entry_edje, &ominw, NULL);
1309 if ((minw > 0) && (vw < minw)) vw = minw;
1310 if (minh > vh) vh = minh;
1312 if (sd->single_line) h = vmh + minh;
1315 evas_object_resize(sd->entry_edje, vw, vh);
1316 evas_object_size_hint_min_set(obj, w, h);
1318 if (sd->single_line)
1319 evas_object_size_hint_max_set(obj, -1, h);
1321 evas_object_size_hint_max_set(obj, -1, -1);
1325 if (sd->deferred_recalc_job)
1326 ecore_job_del(sd->deferred_recalc_job);
1327 sd->deferred_recalc_job =
1328 ecore_job_add(_deferred_recalc_job, obj);
1331 evas_event_thaw(evas_object_evas_get(obj));
1332 evas_event_thaw_eval(evas_object_evas_get(obj));
1336 if (!sd->changed) return;
1337 evas_event_freeze(evas_object_evas_get(obj));
1338 sd->changed = EINA_FALSE;
1342 Evas_Coord vw = 0, vh = 0, vmw = 0, vmh = 0, w = -1, h = -1;
1344 edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
1347 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1349 sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
1351 if (minw > vw) vw = minw;
1352 if (minh > vh) vh = minh;
1354 evas_object_resize(sd->entry_edje, vw, vh);
1355 edje_object_size_min_calc(sd->scr_edje, &vmw, &vmh);
1356 if (sd->single_line) h = vmh + minh;
1359 evas_object_size_hint_min_set(obj, w, h);
1360 if (sd->single_line)
1361 evas_object_size_hint_max_set(obj, -1, h);
1363 evas_object_size_hint_max_set(obj, -1, -1);
1367 edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
1370 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1371 evas_object_size_hint_min_set(obj, minw, minh);
1373 if (sd->single_line)
1374 evas_object_size_hint_max_set(obj, -1, minh);
1376 evas_object_size_hint_max_set(obj, -1, -1);
1378 evas_event_thaw(evas_object_evas_get(obj));
1379 evas_event_thaw_eval(evas_object_evas_get(obj));
1382 _cursor_geometry_recalc(obj);
1386 _return_key_enabled_check(Evas_Object *obj)
1388 Eina_Bool return_key_disabled = EINA_FALSE;
1390 ELM_ENTRY_DATA_GET(obj, sd);
1392 if (!sd->auto_return_key) return;
1394 if (elm_entry_is_empty(obj) == EINA_TRUE)
1395 return_key_disabled = EINA_TRUE;
1397 elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
1401 _elm_entry_smart_on_focus(Evas_Object *obj)
1404 Eina_Bool top_is_win;
1406 ELM_ENTRY_DATA_GET(obj, sd);
1408 top = elm_widget_top_get(obj);
1409 if (!strcmp(evas_object_type_get(top), "elm_win"))
1410 top_is_win = EINA_TRUE;
1412 // if (!sd->editable) return EINA_FALSE; // TIZEN ONLY
1413 if (elm_widget_focus_get(obj))
1415 printf("[Elm_entry::Focused] obj : %p\n", obj); // TIZEN ONLY
1416 evas_object_focus_set(sd->entry_edje, EINA_TRUE);
1417 edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
1418 sd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE; // TIZEN ONLY
1419 if (sd->editable) // TIZEN ONLY
1421 if (top && top_is_win && sd->input_panel_enable)
1422 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
1423 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
1424 _return_key_enabled_check(obj);
1429 printf("[Elm_entry::Unfocused] obj : %p\n", obj); // TIZEN ONLY
1430 _cbhm_msg_send(obj, "cbhm_hide"); // TIZEN ONLY : Hide clipboard
1431 edje_object_signal_emit(sd->entry_edje, "elm,action,unfocus", "elm");
1432 evas_object_focus_set(sd->entry_edje, EINA_FALSE);
1434 if ((sd->api) && (sd->api->obj_hidemenu))
1435 sd->api->obj_hidemenu(obj);
1437 if (sd->editable) // TIZEN ONLY
1439 if (top && top_is_win && sd->input_panel_enable)
1440 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
1441 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
1444 if (_elm_config->selection_clear_enable)
1446 if ((sd->have_selection) && (!sd->hoversel))
1448 sd->sel_mode = EINA_FALSE;
1449 elm_widget_scroll_hold_pop(obj);
1450 edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", EINA_FALSE);
1451 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1452 edje_object_part_text_select_none(sd->entry_edje, "elm.text");
1461 _elm_entry_smart_translate(Evas_Object *obj)
1463 evas_object_smart_callback_call(obj, SIG_LANG_CHANGED, NULL);
1469 _elm_entry_smart_on_focus_region(const Evas_Object *obj,
1475 ELM_ENTRY_DATA_GET(obj, sd);
1477 edje_object_part_text_cursor_geometry_get
1478 (sd->entry_edje, "elm.text", x, y, w, h);
1484 _elm_entry_smart_event(Evas_Object *obj,
1485 Evas_Object *src __UNUSED__,
1486 Evas_Callback_Type type,
1489 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
1490 Evas_Event_Key_Down *ev = event_info;
1491 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
1492 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
1498 _show_region_hook(void *data,
1501 Evas_Coord x, y, w, h;
1503 ELM_ENTRY_DATA_GET(data, sd);
1505 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1507 sd->s_iface->content_region_show(obj, x, y, w, h);
1511 _elm_entry_smart_sub_object_del(Evas_Object *obj,
1514 /* unfortunately entry doesn't follow the signal pattern
1515 * elm,state,icon,{visible,hidden}, so we have to replicate this
1517 if (sobj == elm_layout_content_get(obj, "elm.swallow.icon"))
1519 elm_layout_signal_emit(obj, "elm,action,hide,icon", "elm");
1521 else if (sobj == elm_layout_content_get(obj, "elm.swallow.end"))
1523 elm_layout_signal_emit(obj, "elm,action,hide,end", "elm");
1526 if (!ELM_WIDGET_CLASS(_elm_entry_parent_sc)->sub_object_del(obj, sobj))
1533 _hoversel_position(Evas_Object *obj)
1535 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
1537 ELM_ENTRY_DATA_GET(obj, sd);
1541 evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
1550 edje_object_part_text_cursor_geometry_get
1551 (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
1553 evas_object_size_hint_min_get(sd->hoversel, &mw, &mh);
1556 cx += (cw - mw) / 2;
1561 cy += (ch - mh) / 2;
1564 evas_object_move(sd->hoversel, x + cx, y + cy);
1565 evas_object_resize(sd->hoversel, cw, ch);
1569 _hover_del_job(void *data)
1571 ELM_ENTRY_DATA_GET(data, sd);
1575 evas_object_del(sd->hoversel);
1576 sd->hoversel = NULL;
1578 sd->hov_deljob = NULL;
1582 _hover_dismissed_cb(void *data,
1583 Evas_Object *obj __UNUSED__,
1584 void *event_info __UNUSED__)
1586 ELM_ENTRY_DATA_GET(data, sd);
1589 if (sd->hoversel) evas_object_hide(sd->hoversel);
1592 if (!_elm_config->desktop_entry)
1595 edje_object_part_text_select_allow_set
1596 (sd->entry_edje, "elm.text", EINA_TRUE);
1599 elm_widget_scroll_freeze_pop(data);
1600 if (sd->hov_deljob) ecore_job_del(sd->hov_deljob);
1601 sd->hov_deljob = ecore_job_add(_hover_del_job, data);
1605 _hover_selected_cb(void *data,
1606 Evas_Object *obj __UNUSED__,
1607 void *event_info __UNUSED__)
1609 ELM_ENTRY_DATA_GET(data, sd);
1611 sd->sel_mode = EINA_TRUE;
1612 edje_object_part_text_select_none(sd->entry_edje, "elm.text");
1614 if (!_elm_config->desktop_entry)
1617 edje_object_part_text_select_allow_set
1618 (sd->entry_edje, "elm.text", EINA_TRUE);
1620 edje_object_signal_emit(sd->entry_edje, "elm,state,select,on", "elm");
1622 if (!_elm_config->desktop_entry)
1623 elm_object_scroll_freeze_pop(data); // TIZEN ONLY
1624 //elm_widget_scroll_hold_push(data); // TIZEN ONLY
1628 _item_tags_remove(const char *str)
1636 buf = eina_strbuf_new();
1640 if (!eina_strbuf_append(buf, str))
1642 eina_strbuf_free(buf);
1648 const char *temp = eina_strbuf_string_get(buf);
1649 char *start_tag = NULL;
1650 char *end_tag = NULL;
1654 start_tag = strstr(temp, "<item");
1656 start_tag = strstr(temp, "</item");
1658 end_tag = strstr(start_tag, ">");
1661 if (!end_tag || start_tag > end_tag)
1664 sindex = start_tag - temp;
1665 eindex = end_tag - temp + 1;
1666 if (!eina_strbuf_remove(buf, sindex, eindex))
1670 ret = eina_strbuf_string_steal(buf);
1671 eina_strbuf_free(buf);
1677 _elm_entry_entry_paste(Evas_Object *obj,
1682 ELM_ENTRY_CHECK(obj);
1683 ELM_ENTRY_DATA_GET(obj, sd);
1685 if (sd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
1687 str = _item_tags_remove(entry);
1688 if (!str) str = strdup(entry);
1691 str = strdup(entry);
1692 if (!str) str = (char *)entry;
1694 edje_object_part_text_user_insert(sd->entry_edje, "elm.text", str);
1696 if (str != entry) free(str);
1699 #ifdef HAVE_ELEMENTARY_X
1700 if (elm_widget_focus_get(obj))
1701 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
1707 _paste_cb(void *data,
1708 Evas_Object *obj __UNUSED__,
1709 void *event_info __UNUSED__)
1711 ELM_ENTRY_DATA_GET(data, sd);
1713 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1714 if (sd->sel_notify_handler)
1716 #ifdef HAVE_ELEMENTARY_X
1717 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1719 sd->selection_asked = EINA_TRUE;
1721 if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1722 formats = ELM_SEL_FORMAT_TEXT;
1723 else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1724 formats |= ELM_SEL_FORMAT_IMAGE;
1726 elm_cnp_selection_get
1727 (data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1732 #ifdef HAVE_ELEMENTARY_WAYLAND
1733 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
1734 sd->selection_asked = EINA_TRUE;
1735 if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
1736 formats = ELM_SEL_FORMAT_TEXT;
1737 else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1738 formats |= ELM_SEL_FORMAT_IMAGE;
1739 elm_cnp_selection_get(data, ELM_SEL_TYPE_CLIPBOARD, formats, NULL, NULL);
1745 _selection_store(Elm_Sel_Type seltype,
1750 ELM_ENTRY_DATA_GET(obj, sd);
1752 sel = edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
1753 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1755 elm_cnp_selection_set
1756 (obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1757 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1758 eina_stringshare_replace(&sd->cut_sel, sel);
1763 Evas_Object *obj __UNUSED__,
1764 void *event_info __UNUSED__)
1766 ELM_ENTRY_DATA_GET(data, sd);
1769 sd->sel_mode = EINA_FALSE;
1770 if (!_elm_config->desktop_entry)
1771 edje_object_part_text_select_allow_set
1772 (sd->entry_edje, "elm.text", EINA_FALSE);
1773 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1775 if (!_elm_config->desktop_entry)
1776 elm_widget_scroll_hold_pop(data);
1778 _selection_store(ELM_SEL_TYPE_CLIPBOARD, data);
1779 edje_object_part_text_user_insert(sd->entry_edje, "elm.text", "");
1780 elm_layout_sizing_eval(data);
1784 _copy_cb(void *data,
1785 Evas_Object *obj __UNUSED__,
1786 void *event_info __UNUSED__)
1788 ELM_ENTRY_DATA_GET(data, sd);
1791 //sd->sel_mode = EINA_FALSE;
1792 sd->sel_mode = EINA_TRUE;
1795 if (!_elm_config->desktop_entry)
1797 //edje_object_part_text_select_allow_set // TIZEN ONLY
1798 // (sd->entry_edje, "elm.text", EINA_FALSE);
1799 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1800 elm_widget_scroll_hold_pop(data);
1802 _selection_store(ELM_SEL_TYPE_CLIPBOARD, data);
1806 _hover_cancel_cb(void *data,
1807 Evas_Object *obj __UNUSED__,
1808 void *event_info __UNUSED__)
1810 ELM_ENTRY_DATA_GET(data, sd);
1812 sd->sel_mode = EINA_FALSE;
1813 if (!_elm_config->desktop_entry)
1814 edje_object_part_text_select_allow_set
1815 (sd->entry_edje, "elm.text", EINA_FALSE);
1816 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
1817 if (!_elm_config->desktop_entry)
1818 elm_widget_scroll_hold_pop(data);
1819 edje_object_part_text_select_none(sd->entry_edje, "elm.text");
1823 _hover_item_clicked_cb(void *data,
1824 Evas_Object *obj __UNUSED__,
1825 void *event_info __UNUSED__)
1827 Elm_Entry_Context_Menu_Item *it = data;
1828 Evas_Object *obj2 = it->obj;
1830 if (it->func) it->func(it->data, obj2, NULL);
1834 _menu_call(Evas_Object *obj)
1838 const Elm_Entry_Context_Menu_Item *it;
1840 ELM_ENTRY_DATA_GET(obj, sd);
1842 if ((sd->api) && (sd->api->obj_longpress))
1844 sd->api->obj_longpress(obj);
1846 else if (sd->context_menu)
1848 const char *context_menu_orientation;
1850 if (sd->hoversel) evas_object_del(sd->hoversel);
1851 else elm_widget_scroll_freeze_push(obj);
1853 sd->hoversel = elm_hoversel_add(obj);
1854 context_menu_orientation = edje_object_data_get
1855 (sd->entry_edje, "context_menu_orientation");
1857 if ((context_menu_orientation) &&
1858 (!strcmp(context_menu_orientation, "horizontal")))
1859 elm_hoversel_horizontal_set(sd->hoversel, EINA_TRUE);
1861 elm_object_style_set(sd->hoversel, "entry");
1862 elm_widget_sub_object_add(obj, sd->hoversel);
1863 elm_object_text_set(sd->hoversel, "Text");
1864 top = elm_widget_top_get(obj);
1866 if (top) elm_hoversel_hover_parent_set(sd->hoversel, top);
1868 evas_object_smart_callback_add
1869 (sd->hoversel, "dismissed", _hover_dismissed_cb, obj);
1870 if (sd->have_selection)
1874 elm_hoversel_item_add
1875 (sd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
1878 elm_hoversel_item_add
1879 (sd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
1881 elm_hoversel_item_add
1882 (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1883 _hover_cancel_cb, obj);
1890 if (!_elm_config->desktop_entry)
1893 elm_hoversel_item_add
1894 (sd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1895 _hover_selected_cb, obj);
1897 if (elm_selection_selection_has_owner(obj))
1900 elm_hoversel_item_add
1901 (sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
1906 elm_hoversel_item_add
1907 (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
1908 _hover_cancel_cb, obj);
1911 EINA_LIST_FOREACH(sd->items, l, it)
1913 elm_hoversel_item_add(sd->hoversel, it->label, it->icon_file,
1914 it->icon_type, _hover_item_clicked_cb, it);
1919 _hoversel_position(obj);
1920 evas_object_show(sd->hoversel);
1921 elm_hoversel_hover_begin(sd->hoversel);
1924 if (!_elm_config->desktop_entry)
1926 edje_object_part_text_select_allow_set
1927 (sd->entry_edje, "elm.text", EINA_FALSE);
1928 edje_object_part_text_select_abort(sd->entry_edje, "elm.text");
1934 _long_press_cb(void *data)
1936 ELM_ENTRY_DATA_GET(data, sd);
1938 if (!_elm_config->desktop_entry && !sd->magnifier_enabled) // TIZEN ONLY
1941 sd->longpress_timer = NULL;
1942 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1944 return ECORE_CALLBACK_CANCEL;
1947 // TIZEN ONLY - START
1949 _click_cb(void *data)
1951 ELM_ENTRY_DATA_GET(data, sd);
1953 sd->click_timer = NULL;
1954 if ((!_elm_config->desktop_entry) && sd->mouse_upped && sd->editable)
1958 return ECORE_CALLBACK_CANCEL;
1963 _mouse_down_cb(void *data,
1964 Evas *evas __UNUSED__,
1965 Evas_Object *obj __UNUSED__,
1968 Evas_Event_Mouse_Down *ev = event_info;
1970 ELM_ENTRY_DATA_GET(data, sd);
1972 if (sd->disabled) return;
1973 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1974 sd->downx = ev->canvas.x;
1975 sd->downy = ev->canvas.y;
1976 sd->long_pressed = EINA_FALSE;
1977 if (ev->button == 1)
1979 if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer);
1980 sd->longpress_timer = ecore_timer_add
1981 (_elm_config->longpress_timeout, _long_press_cb, data);
1983 // TIZEN ONLY - START
1984 if (sd->click_timer)
1986 ecore_timer_del(sd->click_timer); // avoid double click
1987 sd->click_timer = NULL;
1991 if (!sd->have_selection)
1992 sd->click_timer = ecore_timer_add (0.2, _click_cb, data); //FIXME: time out
1994 sd->mouse_upped = EINA_FALSE;
1997 else if (ev->button == 3)
1999 if (_elm_config->desktop_entry)
2004 edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", EINA_TRUE);
2006 else if (!sd->cursor_handler_disabled)
2008 edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", EINA_FALSE);
2013 _mouse_up_cb(void *data,
2014 Evas *evas __UNUSED__,
2015 Evas_Object *obj __UNUSED__,
2018 Evas_Event_Mouse_Up *ev = event_info;
2020 ELM_ENTRY_DATA_GET(data, sd);
2022 if (sd->disabled) return;
2023 if (ev->button == 1)
2026 if (!sd->double_clicked)
2028 if ((sd->api) && (sd->api->obj_mouseup))
2029 sd->api->obj_mouseup(data);
2031 if (sd->magnifier_enabled)
2033 _magnifier_hide(data);
2034 elm_object_scroll_freeze_pop(data);
2035 if (sd->long_pressed) _menu_call(data);
2037 if (sd->click_timer)
2039 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2041 ecore_timer_del(sd->click_timer);
2042 sd->click_timer = NULL;
2045 sd->mouse_upped = EINA_TRUE;
2047 if (sd->longpress_timer)
2049 ecore_timer_del(sd->longpress_timer);
2050 sd->longpress_timer = NULL;
2053 else if ((ev->button == 3) && (!_elm_config->desktop_entry))
2061 _mouse_move_cb(void *data,
2062 Evas *evas __UNUSED__,
2063 Evas_Object *obj __UNUSED__,
2066 Evas_Event_Mouse_Move *ev = event_info;
2068 ELM_ENTRY_DATA_GET(data, sd);
2070 if (sd->disabled) return;
2073 if (ev->buttons == 1)
2075 if ((sd->long_pressed) && (sd->magnifier_enabled))
2077 _magnifier_show(data);
2078 _magnifier_move(data);
2085 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2087 if (sd->longpress_timer)
2089 ecore_timer_del(sd->longpress_timer);
2090 sd->longpress_timer = NULL;
2093 else if (sd->longpress_timer)
2097 dx = sd->downx - ev->cur.canvas.x;
2099 dy = sd->downy - ev->cur.canvas.y;
2102 ((_elm_config->finger_size / 2) *
2103 (_elm_config->finger_size / 2)))
2105 ecore_timer_del(sd->longpress_timer);
2106 sd->longpress_timer = NULL;
2110 else if (sd->longpress_timer)
2114 dx = sd->downx - ev->cur.canvas.x;
2116 dy = sd->downy - ev->cur.canvas.y;
2119 ((_elm_config->finger_size / 2) *
2120 (_elm_config->finger_size / 2)))
2122 ecore_timer_del(sd->longpress_timer);
2123 sd->longpress_timer = NULL;
2129 _entry_changed_handle(void *data,
2135 ELM_ENTRY_DATA_GET(data, sd);
2137 evas_event_freeze(evas_object_evas_get(data));
2138 sd->changed = EINA_TRUE;
2139 /* Reset the size hints which are no more relevant. Keep the
2140 * height, this is a hack, but doesn't really matter cause we'll
2141 * re-eval in a moment. */
2142 evas_object_size_hint_min_get(data, NULL, &minh);
2143 evas_object_size_hint_min_set(data, -1, minh);
2145 elm_layout_sizing_eval(data);
2146 if (sd->text) eina_stringshare_del(sd->text);
2150 if (sd->password_text)
2151 eina_stringshare_del(sd->password_text);
2152 sd->password_text = NULL;
2154 if ((sd->api) && (sd->api->obj_hidemenu))
2155 sd->api->obj_hidemenu(data);
2158 if (sd->delay_write)
2160 ecore_timer_del(sd->delay_write);
2161 sd->delay_write = NULL;
2163 evas_event_thaw(evas_object_evas_get(data));
2164 evas_event_thaw_eval(evas_object_evas_get(data));
2165 if ((sd->auto_save) && (sd->file))
2166 sd->delay_write = ecore_timer_add(2.0, _delay_write, data);
2168 _return_key_enabled_check(data);
2169 text = edje_object_part_text_get(sd->entry_edje, "elm.text");
2173 _elm_entry_guide_update(data, EINA_TRUE);
2175 _elm_entry_guide_update(data, EINA_FALSE);
2177 /* callback - this could call callbacks that delete the
2178 * entry... thus... any access to sd after this could be
2180 evas_object_smart_callback_call(data, event, NULL);
2184 _entry_changed_signal_cb(void *data,
2185 Evas_Object *obj __UNUSED__,
2186 const char *emission __UNUSED__,
2187 const char *source __UNUSED__)
2189 _entry_changed_handle(data, SIG_CHANGED);
2193 _entry_changed_user_signal_cb(void *data,
2194 Evas_Object *obj __UNUSED__,
2195 const char *emission __UNUSED__,
2196 const char *source __UNUSED__)
2198 Elm_Entry_Change_Info info;
2199 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
2200 edje_object_signal_callback_extra_data_get();
2204 memcpy(&info, edje_info, sizeof(info));
2205 evas_object_smart_callback_call(data, SIG_CHANGED_USER, &info);
2209 evas_object_smart_callback_call(data, SIG_CHANGED_USER, NULL);
2214 _entry_preedit_changed_signal_cb(void *data,
2215 Evas_Object *obj __UNUSED__,
2216 const char *emission __UNUSED__,
2217 const char *source __UNUSED__)
2219 _entry_changed_handle(data, SIG_PREEDIT_CHANGED);
2223 _entry_undo_request_signal_cb(void *data,
2224 Evas_Object *obj __UNUSED__,
2225 const char *emission __UNUSED__,
2226 const char *source __UNUSED__)
2228 evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
2232 _entry_redo_request_signal_cb(void *data,
2233 Evas_Object *obj __UNUSED__,
2234 const char *emission __UNUSED__,
2235 const char *source __UNUSED__)
2237 evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
2241 _entry_selection_start_signal_cb(void *data,
2242 Evas_Object *obj __UNUSED__,
2243 const char *emission __UNUSED__,
2244 const char *source __UNUSED__)
2249 ELM_ENTRY_DATA_GET(data, sd);
2251 if (!elm_object_focus_get(data)) elm_object_focus_set(data, EINA_TRUE);
2252 EINA_LIST_FOREACH(entries, l, entry)
2254 if (entry != data) elm_entry_select_none(entry);
2258 sd->sel_mode = EINA_TRUE;
2261 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
2262 #ifdef HAVE_ELEMENTARY_X
2263 if (sd->sel_notify_handler)
2265 const char *txt = elm_entry_selection_get(data);
2268 top = elm_widget_top_get(data);
2269 if (txt && top && (elm_win_xwindow_get(top)))
2270 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2271 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
2277 _entry_selection_all_signal_cb(void *data,
2278 Evas_Object *obj __UNUSED__,
2279 const char *emission __UNUSED__,
2280 const char *source __UNUSED__)
2282 elm_entry_select_all(data);
2286 _entry_selection_none_signal_cb(void *data,
2287 Evas_Object *obj __UNUSED__,
2288 const char *emission __UNUSED__,
2289 const char *source __UNUSED__)
2291 ELM_ENTRY_DATA_GET(data, sd); // TIZEN ONLY
2293 elm_entry_select_none(data);
2296 if ((sd->api) && (sd->api->obj_hidemenu))
2297 sd->api->obj_hidemenu(data);
2303 _entry_selection_changed_signal_cb(void *data,
2304 Evas_Object *obj __UNUSED__,
2305 const char *emission __UNUSED__,
2306 const char *source __UNUSED__)
2308 ELM_ENTRY_DATA_GET(data, sd);
2309 Evas_Coord cx, cy, cw, ch; // TIZEN ONLY
2311 sd->have_selection = EINA_TRUE;
2312 sd->sel_mode = EINA_TRUE; // TIZEN ONLY
2313 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
2314 _selection_store(ELM_SEL_TYPE_PRIMARY, data);
2317 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
2318 if (!sd->deferred_recalc_job)
2319 elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
2322 sd->deferred_cur = EINA_TRUE;
2332 _entry_selection_cleared_signal_cb(void *data,
2333 Evas_Object *obj __UNUSED__,
2334 const char *emission __UNUSED__,
2335 const char *source __UNUSED__)
2337 ELM_ENTRY_DATA_GET(data, sd);
2339 if (!sd->have_selection) return;
2341 sd->have_selection = EINA_FALSE;
2344 sd->sel_mode = EINA_FALSE;
2347 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2348 if (sd->sel_notify_handler)
2352 #ifdef HAVE_ELEMENTARY_X
2355 top = elm_widget_top_get(data);
2356 if ((top) && (elm_win_xwindow_get(top)))
2357 elm_cnp_selection_set
2358 (data, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_MARKUP,
2359 sd->cut_sel, strlen(sd->cut_sel));
2361 eina_stringshare_del(sd->cut_sel);
2366 #ifdef HAVE_ELEMENTARY_X
2369 top = elm_widget_top_get(data);
2370 if ((top) && (elm_win_xwindow_get(top)))
2371 elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
2377 if ((sd->api) && (sd->api->obj_hidemenu))
2379 sd->api->obj_hidemenu(data);
2385 _entry_paste_request_signal_cb(void *data,
2386 Evas_Object *obj __UNUSED__,
2387 const char *emission,
2388 const char *source __UNUSED__)
2390 ELM_ENTRY_DATA_GET(data, sd);
2392 #ifdef HAVE_ELEMENTARY_X
2393 Elm_Sel_Type type = (emission[sizeof("ntry,paste,request,")] == '1') ?
2394 ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD;
2397 if (!sd->editable) return;
2398 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2399 if (sd->sel_notify_handler)
2401 #ifdef HAVE_ELEMENTARY_X
2404 top = elm_widget_top_get(data);
2405 if ((top) && (elm_win_xwindow_get(top)))
2407 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2409 sd->selection_asked = EINA_TRUE;
2411 if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2412 formats = ELM_SEL_FORMAT_TEXT;
2413 else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2414 formats |= ELM_SEL_FORMAT_IMAGE;
2416 elm_cnp_selection_get(data, type, formats, NULL, NULL);
2423 _entry_copy_notify_signal_cb(void *data,
2424 Evas_Object *obj __UNUSED__,
2425 const char *emission __UNUSED__,
2426 const char *source __UNUSED__)
2428 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
2429 _copy_cb(data, NULL, NULL);
2433 _entry_cut_notify_signal_cb(void *data,
2434 Evas_Object *obj __UNUSED__,
2435 const char *emission __UNUSED__,
2436 const char *source __UNUSED__)
2438 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
2439 _cut_cb(data, NULL, NULL);
2443 _entry_cursor_changed_signal_cb(void *data,
2444 Evas_Object *obj __UNUSED__,
2445 const char *emission __UNUSED__,
2446 const char *source __UNUSED__)
2448 ELM_ENTRY_DATA_GET(data, sd);
2449 sd->cursor_pos = edje_object_part_text_cursor_pos_get
2450 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
2451 sd->cur_changed = EINA_TRUE;
2452 _cursor_geometry_recalc(data);
2456 _entry_cursor_changed_manual_signal_cb(void *data,
2457 Evas_Object *obj __UNUSED__,
2458 const char *emission __UNUSED__,
2459 const char *source __UNUSED__)
2461 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED_MANUAL, NULL);
2465 _signal_anchor_geoms_do_things_with_lol(Elm_Entry_Smart_Data *sd,
2466 Elm_Entry_Anchor_Info *ei)
2468 Evas_Textblock_Rectangle *r;
2469 const Eina_List *geoms, *l;
2470 Evas_Coord px, py, x, y;
2472 geoms = edje_object_part_text_anchor_geometry_get
2473 (sd->entry_edje, "elm.text", ei->name);
2477 evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
2478 evas_pointer_canvas_xy_get
2479 (evas_object_evas_get(sd->entry_edje), &px, &py);
2481 EINA_LIST_FOREACH(geoms, l, r)
2483 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2484 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2496 _entry_anchor_down_signal_cb(void *data,
2497 Evas_Object *obj __UNUSED__,
2498 const char *emission __UNUSED__,
2499 const char *source __UNUSED__)
2501 Elm_Entry_Anchor_Info ei;
2505 ELM_ENTRY_DATA_GET(data, sd);
2507 p = emission + sizeof("nchor,mouse,down,");
2508 ei.button = strtol(p, &p2, 10);
2510 ei.x = ei.y = ei.w = ei.h = 0;
2512 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2515 evas_object_smart_callback_call(data, SIG_ANCHOR_DOWN, &ei);
2519 _entry_anchor_up_signal_cb(void *data,
2520 Evas_Object *obj __UNUSED__,
2521 const char *emission __UNUSED__,
2522 const char *source __UNUSED__)
2524 Elm_Entry_Anchor_Info ei;
2528 ELM_ENTRY_DATA_GET(data, sd);
2530 p = emission + sizeof("nchor,mouse,up,");
2531 ei.button = strtol(p, &p2, 10);
2533 ei.x = ei.y = ei.w = ei.h = 0;
2535 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2538 evas_object_smart_callback_call(data, SIG_ANCHOR_UP, &ei);
2542 _anchor_hover_del_cb(void *data,
2544 Evas_Object *obj __UNUSED__,
2545 void *event_info __UNUSED__)
2547 ELM_ENTRY_DATA_GET(data, sd);
2549 if (sd->anchor_hover.pop) evas_object_del(sd->anchor_hover.pop);
2550 sd->anchor_hover.pop = NULL;
2551 evas_object_event_callback_del_full
2552 (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
2556 _anchor_hover_clicked_cb(void *data,
2557 Evas_Object *obj __UNUSED__,
2558 void *event_info __UNUSED__)
2560 elm_entry_anchor_hover_end(data);
2564 _entry_hover_anchor_clicked_do(Evas_Object *obj,
2565 Elm_Entry_Anchor_Info *info)
2567 Evas_Object *hover_parent;
2568 Evas_Coord x, w, y, h, px, py;
2569 Elm_Entry_Anchor_Hover_Info ei;
2571 ELM_ENTRY_DATA_GET(obj, sd);
2573 ei.anchor_info = info;
2575 sd->anchor_hover.pop = elm_icon_add(obj);
2576 evas_object_move(sd->anchor_hover.pop, info->x, info->y);
2577 evas_object_resize(sd->anchor_hover.pop, info->w, info->h);
2579 sd->anchor_hover.hover = elm_hover_add(obj);
2580 evas_object_event_callback_add
2581 (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
2582 elm_widget_mirrored_set
2583 (sd->anchor_hover.hover, elm_widget_mirrored_get(obj));
2584 if (sd->anchor_hover.hover_style)
2585 elm_object_style_set
2586 (sd->anchor_hover.hover, sd->anchor_hover.hover_style);
2588 hover_parent = sd->anchor_hover.hover_parent;
2589 if (!hover_parent) hover_parent = obj;
2590 elm_hover_parent_set(sd->anchor_hover.hover, hover_parent);
2591 elm_hover_target_set(sd->anchor_hover.hover, sd->anchor_hover.pop);
2592 ei.hover = sd->anchor_hover.hover;
2594 evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
2595 ei.hover_parent.x = x;
2596 ei.hover_parent.y = y;
2597 ei.hover_parent.w = w;
2598 ei.hover_parent.h = h;
2599 px = info->x + (info->w / 2);
2600 py = info->y + (info->h / 2);
2602 if (px < (x + (w / 3))) ei.hover_left = 0;
2604 if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
2606 if (py < (y + (h / 3))) ei.hover_top = 0;
2607 ei.hover_bottom = 1;
2608 if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
2610 /* Swap right and left because they switch sides in RTL */
2611 if (elm_widget_mirrored_get(sd->anchor_hover.hover))
2613 Eina_Bool tmp = ei.hover_left;
2615 ei.hover_left = ei.hover_right;
2616 ei.hover_right = tmp;
2619 evas_object_smart_callback_call(obj, SIG_ANCHOR_HOVER_OPENED, &ei);
2620 evas_object_smart_callback_add
2621 (sd->anchor_hover.hover, "clicked", _anchor_hover_clicked_cb, obj);
2623 /* FIXME: Should just check if there's any callback registered to
2624 * the smart events instead. This is used to determine if anyone
2625 * cares about the hover or not. */
2626 if (!elm_layout_content_get(sd->anchor_hover.hover, "middle") &&
2627 !elm_layout_content_get(sd->anchor_hover.hover, "left") &&
2628 !elm_layout_content_get(sd->anchor_hover.hover, "right") &&
2629 !elm_layout_content_get(sd->anchor_hover.hover, "top") &&
2630 !elm_layout_content_get(sd->anchor_hover.hover, "bottom"))
2632 evas_object_del(sd->anchor_hover.hover);
2633 sd->anchor_hover.hover = NULL;
2636 evas_object_show(sd->anchor_hover.hover);
2640 _entry_anchor_clicked_signal_cb(void *data,
2641 Evas_Object *obj __UNUSED__,
2642 const char *emission,
2643 const char *source __UNUSED__)
2645 Elm_Entry_Anchor_Info ei;
2649 ELM_ENTRY_DATA_GET(data, sd);
2651 p = emission + sizeof("nchor,mouse,clicked,");
2652 ei.button = strtol(p, &p2, 10);
2654 ei.x = ei.y = ei.w = ei.h = 0;
2656 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2660 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
2662 _entry_hover_anchor_clicked_do(data, &ei);
2667 _entry_anchor_move_signal_cb(void *data __UNUSED__,
2668 Evas_Object *obj __UNUSED__,
2669 const char *emission __UNUSED__,
2670 const char *source __UNUSED__)
2675 _entry_anchor_in_signal_cb(void *data,
2676 Evas_Object *obj __UNUSED__,
2677 const char *emission __UNUSED__,
2678 const char *source __UNUSED__)
2680 Elm_Entry_Anchor_Info ei;
2682 ELM_ENTRY_DATA_GET(data, sd);
2684 ei.name = emission + sizeof("nchor,mouse,in,");
2686 ei.x = ei.y = ei.w = ei.h = 0;
2688 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2691 evas_object_smart_callback_call(data, SIG_ANCHOR_IN, &ei);
2695 _entry_anchor_out_signal_cb(void *data,
2696 Evas_Object *obj __UNUSED__,
2697 const char *emission __UNUSED__,
2698 const char *source __UNUSED__)
2700 Elm_Entry_Anchor_Info ei;
2702 ELM_ENTRY_DATA_GET(data, sd);
2704 ei.name = emission + sizeof("nchor,mouse,out,");
2706 ei.x = ei.y = ei.w = ei.h = 0;
2708 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2711 evas_object_smart_callback_call(data, SIG_ANCHOR_OUT, &ei);
2715 _entry_key_enter_signal_cb(void *data,
2716 Evas_Object *obj __UNUSED__,
2717 const char *emission __UNUSED__,
2718 const char *source __UNUSED__)
2720 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
2724 _entry_key_escape_signal_cb(void *data,
2725 Evas_Object *obj __UNUSED__,
2726 const char *emission __UNUSED__,
2727 const char *source __UNUSED__)
2729 evas_object_smart_callback_call(data, SIG_ABORTED, NULL);
2733 _entry_mouse_down_signal_cb(void *data,
2734 Evas_Object *obj __UNUSED__,
2735 const char *emission __UNUSED__,
2736 const char *source __UNUSED__)
2739 ELM_ENTRY_DATA_GET(data, sd);
2740 sd->double_clicked = EINA_FALSE;
2741 if ((sd->api) && (sd->api->obj_hidemenu))
2742 sd->api->obj_hidemenu(data);
2744 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
2748 _entry_mouse_clicked_signal_cb(void *data,
2749 Evas_Object *obj __UNUSED__,
2750 const char *emission __UNUSED__,
2751 const char *source __UNUSED__)
2754 ELM_ENTRY_DATA_GET(data, sd);
2755 if (!_elm_config->desktop_entry && !sd->double_clicked)
2756 _hover_cancel_cb(data, NULL, NULL);
2758 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
2762 _entry_mouse_double_signal_cb(void *data,
2763 Evas_Object *obj __UNUSED__,
2764 const char *emission __UNUSED__,
2765 const char *source __UNUSED__)
2768 ELM_ENTRY_DATA_GET(data, sd);
2769 if (sd->disabled) return;
2770 sd->double_clicked = EINA_TRUE;
2771 if (!sd->sel_allow) return;
2773 if (sd->click_timer)
2775 ecore_timer_del(sd->click_timer);
2776 sd->click_timer = NULL;
2779 edje_object_part_text_select_word(sd->entry_edje, "elm.text");
2780 if (!_elm_config->desktop_entry)
2781 edje_object_part_text_select_allow_set
2782 (sd->entry_edje, "elm.text", EINA_TRUE);
2784 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
2788 _entry_mouse_triple_signal_cb(void *data,
2789 Evas_Object *obj __UNUSED__,
2790 const char *emission __UNUSED__,
2791 const char *source __UNUSED__)
2793 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
2796 #ifdef HAVE_ELEMENTARY_X
2798 _event_selection_notify(void *data,
2799 int type __UNUSED__,
2802 Ecore_X_Event_Selection_Notify *ev = event;
2804 ELM_ENTRY_DATA_GET(data, sd);
2806 if ((!sd->selection_asked) && (!sd->drag_selection_asked))
2807 return ECORE_CALLBACK_PASS_ON;
2809 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2810 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2812 Ecore_X_Selection_Data_Text *text_data;
2814 text_data = ev->data;
2815 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2817 if (text_data->text)
2819 char *txt = _elm_util_text_to_mkup(text_data->text);
2823 elm_entry_entry_insert(data, txt);
2828 sd->selection_asked = EINA_FALSE;
2830 else if (ev->selection == ECORE_X_SELECTION_XDND)
2832 Ecore_X_Selection_Data_Text *text_data;
2834 text_data = ev->data;
2835 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2837 if (text_data->text)
2839 char *txt = _elm_util_text_to_mkup(text_data->text);
2843 /* Massive FIXME: this should be at the drag point */
2844 elm_entry_entry_insert(data, txt);
2849 sd->drag_selection_asked = EINA_FALSE;
2851 ecore_x_dnd_send_finished();
2854 return ECORE_CALLBACK_PASS_ON;
2858 _event_selection_clear(void *data __UNUSED__,
2859 int type __UNUSED__,
2860 void *event __UNUSED__)
2863 Ecore_X_Event_Selection_Clear *ev = event;
2865 ELM_ENTRY_DATA_GET(data, sd);
2867 if (!sd->have_selection) return ECORE_CALLBACK_PASS_ON;
2868 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2869 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2871 elm_entry_select_none(data);
2875 Evas_Object *top = elm_widget_top_get(data);
2876 Ecore_X_Event_Selection_Clear *ev = event;
2879 return ECORE_CALLBACK_PASS_ON;
2881 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
2883 return ECORE_CALLBACK_PASS_ON;
2886 if (elm_widget_focus_get(data))
2888 ELM_ENTRY_DATA_GET(data, sd);
2889 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
2890 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
2891 if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
2892 formats = ELM_SEL_FORMAT_TEXT;
2893 else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
2894 formats |= ELM_SEL_FORMAT_IMAGE;
2895 elm_cnp_selection_get(data, ELM_SEL_TYPE_SECONDARY, formats, NULL, NULL);
2897 return ECORE_CALLBACK_DONE;
2901 return ECORE_CALLBACK_PASS_ON;
2905 _drag_drop_cb(void *data __UNUSED__,
2907 Elm_Selection_Data *drop)
2911 ELM_ENTRY_DATA_GET(obj, sd);
2913 edje_object_part_text_cursor_copy
2914 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, /*->*/ EDJE_CURSOR_USER);
2915 rv = edje_object_part_text_cursor_coord_set
2916 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, drop->x, drop->y);
2918 if (!rv) WRN("Warning: Failed to position cursor: paste anyway");
2920 elm_entry_entry_insert(obj, drop->data);
2921 edje_object_part_text_cursor_copy
2922 (sd->entry_edje, "elm.text", EDJE_CURSOR_USER, /*->*/ EDJE_CURSOR_MAIN);
2929 static Evas_Object *
2930 _item_get(void *data,
2931 Evas_Object *edje __UNUSED__,
2932 const char *part __UNUSED__,
2937 Elm_Entry_Item_Provider *ip;
2939 ELM_ENTRY_DATA_GET(data, sd);
2941 EINA_LIST_FOREACH(sd->item_providers, l, ip)
2943 o = ip->func(ip->data, data, item);
2946 if (!strncmp(item, "file://", 7))
2948 const char *fname = item + 7;
2950 o = evas_object_image_filled_add(evas_object_evas_get(data));
2951 evas_object_image_file_set(o, fname, NULL);
2952 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
2954 evas_object_show(o);
2959 o = edje_object_add(evas_object_evas_get(data));
2960 elm_widget_theme_object_set
2961 (data, o, "entry/emoticon", "wtf",
2962 elm_widget_style_get(data));
2967 o = edje_object_add(evas_object_evas_get(data));
2968 if (!elm_widget_theme_object_set
2969 (data, o, "entry", item, elm_widget_style_get(data)))
2970 elm_widget_theme_object_set
2971 (data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
2976 _text_filter_cb(void *data,
2977 Evas_Object *edje __UNUSED__,
2978 const char *part __UNUSED__,
2979 Edje_Text_Filter_Type type,
2983 Elm_Entry_Markup_Filter *tf;
2985 ELM_ENTRY_DATA_GET(data, sd);
2987 if (type == EDJE_TEXT_FILTER_FORMAT)
2990 EINA_LIST_FOREACH(sd->text_filters, l, tf)
2992 tf->func(tf->data, data, text);
2999 _markup_filter_cb(void *data,
3000 Evas_Object *edje __UNUSED__,
3001 const char *part __UNUSED__,
3005 Elm_Entry_Markup_Filter *tf;
3007 ELM_ENTRY_DATA_GET(data, sd);
3009 EINA_LIST_FOREACH(sd->markup_filters, l, tf)
3011 tf->func(tf->data, data, text);
3017 /* This function is used to insert text by chunks in jobs */
3019 _text_append_idler(void *data)
3023 Evas_Object *obj = (Evas_Object *)data;
3025 ELM_ENTRY_DATA_GET(obj, sd);
3027 evas_event_freeze(evas_object_evas_get(obj));
3028 if (sd->text) eina_stringshare_del(sd->text);
3031 if (sd->password_text) eina_stringshare_del(sd->password_text);
3032 sd->password_text = NULL;
3034 sd->changed = EINA_TRUE;
3036 start = sd->append_text_position;
3037 if ((start + _CHUNK_SIZE) < sd->append_text_len)
3040 int tag_start, esc_start;
3042 tag_start = esc_start = -1;
3043 /* Find proper markup cut place */
3044 while (pos - start < _CHUNK_SIZE)
3048 eina_unicode_utf8_get_next(sd->append_text_left, &pos);
3050 if (esc_start == -1)
3053 tag_start = prev_pos;
3054 else if (tmp == '>')
3057 if (tag_start == -1)
3060 esc_start = prev_pos;
3061 else if (tmp == ';')
3068 sd->append_text_position = tag_start;
3070 else if (esc_start >= 0)
3072 sd->append_text_position = esc_start;
3076 sd->append_text_position = pos;
3081 sd->append_text_position = sd->append_text_len;
3084 backup = sd->append_text_left[sd->append_text_position];
3085 sd->append_text_left[sd->append_text_position] = '\0';
3087 edje_object_part_text_append
3088 (sd->entry_edje, "elm.text", sd->append_text_left + start);
3090 sd->append_text_left[sd->append_text_position] = backup;
3092 evas_event_thaw(evas_object_evas_get(obj));
3093 evas_event_thaw_eval(evas_object_evas_get(obj));
3095 _elm_entry_guide_update(obj, EINA_TRUE);
3097 /* If there's still more to go, renew the idler, else, cleanup */
3098 if (sd->append_text_position < sd->append_text_len)
3100 return ECORE_CALLBACK_RENEW;
3104 free(sd->append_text_left);
3105 sd->append_text_left = NULL;
3106 sd->append_text_idler = NULL;
3107 return ECORE_CALLBACK_CANCEL;
3112 _chars_add_till_limit(Evas_Object *obj,
3117 int i = 0, current_len = 0;
3121 if (unit >= LENGTH_UNIT_LAST) return;
3122 if (strstr(*text, "<preedit")) return;
3125 current_len = strlen(*text);
3128 int idx = 0, unit_size = 0;
3129 char *markup, *utfstr;
3131 if (*new_text == '<')
3133 while (*(new_text + idx) != '>')
3136 if (!*(new_text + idx)) break;
3139 else if (*new_text == '&')
3141 while (*(new_text + idx) != ';')
3144 if (!*(new_text + idx)) break;
3147 idx = evas_string_char_next_get(new_text, idx, NULL);
3148 markup = malloc(idx + 1);
3151 strncpy(markup, new_text, idx);
3153 utfstr = elm_entry_markup_to_utf8(markup);
3156 if (unit == LENGTH_UNIT_BYTE)
3157 unit_size = strlen(utfstr);
3158 else if (unit == LENGTH_UNIT_CHAR)
3159 unit_size = evas_string_char_len_get(utfstr);
3166 if (can_add < unit_size)
3170 evas_object_smart_callback_call(obj, SIG_MAX_LENGHT, NULL);
3176 strncpy(new_text, new_text + idx,
3177 current_len - ((new_text + idx) - *text));
3179 (*text)[current_len] = 0;
3184 can_add -= unit_size;
3189 evas_object_smart_callback_call(obj, SIG_MAX_LENGHT, NULL);
3193 _elm_entry_smart_signal(Evas_Object *obj,
3194 const char *emission,
3197 ELM_ENTRY_DATA_GET(obj, sd);
3199 /* always pass to both edje objs */
3200 edje_object_signal_emit(sd->entry_edje, emission, source);
3203 edje_object_signal_emit(sd->scr_edje, emission, source);
3207 _elm_entry_smart_callback_add(Evas_Object *obj,
3208 const char *emission,
3210 Edje_Signal_Cb func_cb,
3215 ELM_ENTRY_DATA_GET(obj, sd);
3217 ro = ELM_WIDGET_DATA(sd)->resize_obj;
3219 ELM_WIDGET_DATA(sd)->resize_obj = sd->entry_edje;
3221 ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_add
3222 (obj, emission, source, func_cb, data);
3226 ELM_WIDGET_DATA(sd)->resize_obj = sd->scr_edje;
3228 ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_add
3229 (obj, emission, source, func_cb, data);
3232 ELM_WIDGET_DATA(sd)->resize_obj = ro;
3236 _elm_entry_smart_callback_del(Evas_Object *obj,
3237 const char *emission,
3239 Edje_Signal_Cb func_cb)
3244 ELM_ENTRY_DATA_GET(obj, sd);
3246 ro = ELM_WIDGET_DATA(sd)->resize_obj;
3248 ELM_WIDGET_DATA(sd)->resize_obj = sd->entry_edje;
3250 data = ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_del
3251 (obj, emission, source, func_cb);
3255 ELM_WIDGET_DATA(sd)->resize_obj = sd->scr_edje;
3257 ELM_LAYOUT_CLASS(_elm_entry_parent_sc)->callback_del
3258 (obj, emission, source, func_cb);
3261 ELM_WIDGET_DATA(sd)->resize_obj = ro;
3267 _elm_entry_smart_content_set(Evas_Object *obj,
3269 Evas_Object *content)
3271 if (!ELM_CONTAINER_CLASS(_elm_entry_parent_sc)->content_set
3272 (obj, part, content))
3275 /* too bad entry does not follow the pattern
3276 * "elm,state,{icon,end},visible", we have to repeat ourselves */
3277 if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
3278 elm_entry_icon_visible_set(obj, EINA_TRUE);
3280 if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
3281 elm_entry_end_visible_set(obj, EINA_TRUE);
3286 static Evas_Object *
3287 _elm_entry_smart_content_unset(Evas_Object *obj,
3292 ret = ELM_CONTAINER_CLASS(_elm_entry_parent_sc)->content_unset(obj, part);
3293 if (!ret) return NULL;
3295 /* too bad entry does not follow the pattern
3296 * "elm,state,{icon,end},hidden", we have to repeat ourselves */
3297 if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
3298 elm_entry_icon_visible_set(obj, EINA_FALSE);
3300 if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
3301 elm_entry_end_visible_set(obj, EINA_FALSE);
3307 _elm_entry_smart_text_set(Evas_Object *obj,
3313 ELM_ENTRY_DATA_GET(obj, sd);
3315 if (!entry) entry = "";
3318 if (!strcmp(item, "guide"))
3319 edje_object_part_text_set(sd->entry_edje, "elm.guide", entry);
3321 edje_object_part_text_set(sd->entry_edje, item, entry);
3326 evas_event_freeze(evas_object_evas_get(obj));
3327 if (sd->text) eina_stringshare_del(sd->text);
3330 if (sd->password_text) eina_stringshare_del(sd->password_text);
3331 sd->password_text = NULL;
3333 sd->changed = EINA_TRUE;
3335 /* Clear currently pending job if there is one */
3336 if (sd->append_text_idler)
3338 ecore_idler_del(sd->append_text_idler);
3339 free(sd->append_text_left);
3340 sd->append_text_left = NULL;
3341 sd->append_text_idler = NULL;
3344 len = strlen(entry);
3345 /* Split to ~_CHUNK_SIZE chunks */
3346 if (len > _CHUNK_SIZE)
3348 sd->append_text_left = (char *)malloc(len + 1);
3351 /* If we decided to use the idler */
3352 if (sd->append_text_left)
3354 /* Need to clear the entry first */
3355 edje_object_part_text_set(sd->entry_edje, "elm.text", "");
3356 memcpy(sd->append_text_left, entry, len + 1);
3357 sd->append_text_position = 0;
3358 sd->append_text_len = len;
3359 sd->append_text_idler = ecore_idler_add(_text_append_idler, obj);
3363 edje_object_part_text_set(sd->entry_edje, "elm.text", entry);
3367 _elm_entry_guide_update(obj, EINA_TRUE);
3369 _elm_entry_guide_update(obj, EINA_FALSE);
3371 evas_event_thaw(evas_object_evas_get(obj));
3372 evas_event_thaw_eval(evas_object_evas_get(obj));
3378 _elm_entry_smart_text_get(const Evas_Object *obj,
3383 ELM_ENTRY_DATA_GET(obj, sd);
3387 if (!strcmp(item, "default")) goto proceed;
3388 else if (!strcmp(item, "guide"))
3389 return edje_object_part_text_get(sd->entry_edje, "elm.guide");
3391 return edje_object_part_text_get(sd->entry_edje, item);
3396 text = edje_object_part_text_get(sd->entry_edje, "elm.text");
3399 ERR("text=NULL for edje %p, part 'elm.text'", sd->entry_edje);
3404 if (sd->append_text_len > 0)
3409 tlen = strlen(text);
3410 tmpbuf = malloc(sd->append_text_len + 1);
3413 ERR("Failed to allocate memory for entry's text %p", obj);
3416 memcpy(tmpbuf, text, tlen);
3418 if (sd->append_text_left)
3419 memcpy(tmpbuf + tlen, sd->append_text_left
3420 + sd->append_text_position, sd->append_text_len
3421 - sd->append_text_position);
3422 tmpbuf[sd->append_text_len] = '\0';
3423 eina_stringshare_replace(&sd->text, tmpbuf);
3428 eina_stringshare_replace(&sd->text, text);
3435 pw_text = elm_entry_markup_to_utf8(sd->text);
3438 eina_stringshare_replace(&sd->password_text, pw_text);
3440 return sd->password_text;
3449 _access_info_cb(void *data __UNUSED__, Evas_Object *obj)
3453 ELM_ENTRY_DATA_GET(obj, sd);
3455 if (sd->password) return NULL;
3457 txt = elm_widget_access_info_get(obj);
3459 if (!txt) txt = _elm_util_mkup_to_text(elm_entry_entry_get(obj));
3460 if (txt) return strdup(txt);
3466 _access_state_cb(void *data __UNUSED__, Evas_Object *obj)
3471 ELM_ENTRY_DATA_GET(obj, sd);
3474 buf = eina_strbuf_new();
3476 if (elm_widget_disabled_get(obj))
3477 eina_strbuf_append(buf, "State: Disabled");
3481 if (!eina_strbuf_length_get(buf))
3482 eina_strbuf_append(buf, "State: Not Editable");
3483 else eina_strbuf_append(buf, ", Not Editable");
3488 if (!eina_strbuf_length_get(buf))
3489 eina_strbuf_append(buf, "State: Password");
3490 else eina_strbuf_append(buf, ", Password");
3493 if (!eina_strbuf_length_get(buf)) goto buf_free;
3495 ret = eina_strbuf_string_steal(buf);
3498 eina_strbuf_free(buf);
3503 _entry_selection_callbacks_unregister(Evas_Object *obj)
3505 ELM_ENTRY_DATA_GET(obj, sd);
3507 edje_object_signal_callback_del_full
3508 (sd->entry_edje, "selection,start", "elm.text",
3509 _entry_selection_start_signal_cb, obj);
3510 edje_object_signal_callback_del_full
3511 (sd->entry_edje, "selection,changed", "elm.text",
3512 _entry_selection_changed_signal_cb, obj);
3513 edje_object_signal_callback_del_full
3514 (sd->entry_edje, "entry,selection,all,request",
3515 "elm.text", _entry_selection_all_signal_cb, obj);
3516 edje_object_signal_callback_del_full
3517 (sd->entry_edje, "entry,selection,none,request",
3518 "elm.text", _entry_selection_none_signal_cb, obj);
3519 edje_object_signal_callback_del_full
3520 (sd->entry_edje, "selection,cleared", "elm.text",
3521 _entry_selection_cleared_signal_cb, obj);
3522 edje_object_signal_callback_del_full
3523 (sd->entry_edje, "entry,paste,request,*", "elm.text",
3524 _entry_paste_request_signal_cb, obj);
3525 edje_object_signal_callback_del_full
3526 (sd->entry_edje, "entry,copy,notify", "elm.text",
3527 _entry_copy_notify_signal_cb, obj);
3528 edje_object_signal_callback_del_full
3529 (sd->entry_edje, "entry,cut,notify", "elm.text",
3530 _entry_cut_notify_signal_cb, obj);
3534 _entry_selection_callbacks_register(Evas_Object *obj)
3536 ELM_ENTRY_DATA_GET(obj, sd);
3538 edje_object_signal_callback_add
3539 (sd->entry_edje, "selection,start", "elm.text",
3540 _entry_selection_start_signal_cb, obj);
3541 edje_object_signal_callback_add
3542 (sd->entry_edje, "selection,changed", "elm.text",
3543 _entry_selection_changed_signal_cb, obj);
3544 edje_object_signal_callback_add
3545 (sd->entry_edje, "entry,selection,all,request",
3546 "elm.text", _entry_selection_all_signal_cb, obj);
3547 edje_object_signal_callback_add
3548 (sd->entry_edje, "entry,selection,none,request",
3549 "elm.text", _entry_selection_none_signal_cb, obj);
3550 edje_object_signal_callback_add
3551 (sd->entry_edje, "selection,cleared", "elm.text",
3552 _entry_selection_cleared_signal_cb, obj);
3553 edje_object_signal_callback_add
3554 (sd->entry_edje, "entry,paste,request,*", "elm.text",
3555 _entry_paste_request_signal_cb, obj);
3556 edje_object_signal_callback_add
3557 (sd->entry_edje, "entry,copy,notify", "elm.text",
3558 _entry_copy_notify_signal_cb, obj);
3559 edje_object_signal_callback_add
3560 (sd->entry_edje, "entry,cut,notify", "elm.text",
3561 _entry_cut_notify_signal_cb, obj);
3565 _resize_cb(void *data,
3567 Evas_Object *obj __UNUSED__,
3568 void *event_info __UNUSED__)
3570 ELM_ENTRY_DATA_GET(data, sd);
3574 elm_layout_sizing_eval(data);
3576 else if (sd->scroll)
3578 Evas_Coord vw = 0, vh = 0;
3580 sd->s_iface->content_viewport_size_get(data, &vw, &vh);
3581 if (vw < sd->ent_mw) vw = sd->ent_mw;
3582 if (vh < sd->ent_mh) vh = sd->ent_mh;
3583 evas_object_resize(sd->entry_edje, vw, vh);
3586 if (sd->hoversel) _hoversel_position(data);
3589 if (!_elm_config->desktop_entry)
3591 if (sd->region_get_job) ecore_job_del(sd->region_get_job);
3592 sd->region_get_job = ecore_job_add(_region_get_job, data);
3594 if (sd->magnifier_showing)
3595 _magnifier_content_resize(data);
3601 _elm_entry_smart_add(Evas_Object *obj)
3603 #ifdef HAVE_ELEMENTARY_X
3607 EVAS_SMART_DATA_ALLOC(obj, Elm_Entry_Smart_Data);
3609 ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.add(obj);
3611 priv->entry_edje = ELM_WIDGET_DATA(priv)->resize_obj;
3613 priv->cnp_mode = ELM_CNP_MODE_MARKUP;
3614 priv->line_wrap = ELM_WRAP_WORD;
3615 priv->context_menu = EINA_TRUE;
3616 priv->disabled = EINA_FALSE;
3617 priv->auto_save = EINA_TRUE;
3618 priv->editable = EINA_TRUE;
3619 priv->scroll = EINA_FALSE;
3621 priv->input_panel_imdata = NULL;
3623 priv->magnifier_enabled = EINA_TRUE;
3624 priv->mouse_upped = EINA_FALSE;
3625 priv->sel_allow = EINA_TRUE;
3626 priv->cursor_handler_disabled = EINA_FALSE;
3629 elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj));
3631 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
3632 evas_object_data_set(priv->hit_rect, "_elm_leaveme", obj);
3633 evas_object_smart_member_add(priv->hit_rect, obj);
3634 elm_widget_sub_object_add(obj, priv->hit_rect);
3636 /* common scroller hit rectangle setup */
3637 evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
3638 evas_object_show(priv->hit_rect);
3639 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
3641 priv->s_iface = evas_object_smart_interface_get
3642 (obj, ELM_SCROLLABLE_IFACE_NAME);
3644 priv->s_iface->objects_set(obj, priv->entry_edje, priv->hit_rect);
3646 edje_object_item_provider_set(priv->entry_edje, _item_get, obj);
3648 edje_object_text_insert_filter_callback_add
3649 (priv->entry_edje, "elm.text", _text_filter_cb, obj);
3650 edje_object_text_markup_filter_callback_add
3651 (priv->entry_edje, "elm.text", _markup_filter_cb, obj);
3653 evas_object_event_callback_add
3654 (priv->entry_edje, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
3655 evas_object_event_callback_add
3656 (priv->entry_edje, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
3657 evas_object_event_callback_add
3658 (priv->entry_edje, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, obj);
3660 /* this code can't go in smart_resize. sizing gets wrong */
3661 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
3663 edje_object_signal_callback_add
3664 (priv->entry_edje, "entry,changed", "elm.text",
3665 _entry_changed_signal_cb, obj);
3666 edje_object_signal_callback_add
3667 (priv->entry_edje, "entry,changed,user", "elm.text",
3668 _entry_changed_user_signal_cb, obj);
3669 edje_object_signal_callback_add
3670 (priv->entry_edje, "preedit,changed", "elm.text",
3671 _entry_preedit_changed_signal_cb, obj);
3673 _entry_selection_callbacks_register(obj);
3675 edje_object_signal_callback_add
3676 (priv->entry_edje, "cursor,changed", "elm.text",
3677 _entry_cursor_changed_signal_cb, obj);
3678 edje_object_signal_callback_add
3679 (priv->entry_edje, "cursor,changed,manual", "elm.text",
3680 _entry_cursor_changed_manual_signal_cb, obj);
3681 edje_object_signal_callback_add
3682 (priv->entry_edje, "anchor,mouse,down,*", "elm.text",
3683 _entry_anchor_down_signal_cb, obj);
3684 edje_object_signal_callback_add
3685 (priv->entry_edje, "anchor,mouse,up,*", "elm.text",
3686 _entry_anchor_up_signal_cb, obj);
3687 edje_object_signal_callback_add
3688 (priv->entry_edje, "anchor,mouse,clicked,*", "elm.text",
3689 _entry_anchor_clicked_signal_cb, obj);
3690 edje_object_signal_callback_add
3691 (priv->entry_edje, "anchor,mouse,move,*", "elm.text",
3692 _entry_anchor_move_signal_cb, obj);
3693 edje_object_signal_callback_add
3694 (priv->entry_edje, "anchor,mouse,in,*", "elm.text",
3695 _entry_anchor_in_signal_cb, obj);
3696 edje_object_signal_callback_add
3697 (priv->entry_edje, "anchor,mouse,out,*", "elm.text",
3698 _entry_anchor_out_signal_cb, obj);
3699 edje_object_signal_callback_add
3700 (priv->entry_edje, "entry,key,enter", "elm.text",
3701 _entry_key_enter_signal_cb, obj);
3702 edje_object_signal_callback_add
3703 (priv->entry_edje, "entry,key,escape", "elm.text",
3704 _entry_key_escape_signal_cb, obj);
3705 edje_object_signal_callback_add
3706 (priv->entry_edje, "mouse,down,1", "elm.text",
3707 _entry_mouse_down_signal_cb, obj);
3708 edje_object_signal_callback_add
3709 (priv->entry_edje, "mouse,clicked,1", "elm.text",
3710 _entry_mouse_clicked_signal_cb, obj);
3711 edje_object_signal_callback_add
3712 (priv->entry_edje, "mouse,down,1,double", "elm.text",
3713 _entry_mouse_double_signal_cb, obj);
3714 edje_object_signal_callback_add
3715 (priv->entry_edje, "mouse,down,1,triple", "elm.text",
3716 _entry_mouse_triple_signal_cb, obj);
3717 edje_object_signal_callback_add
3718 (priv->entry_edje, "entry,undo,request", "elm.text",
3719 _entry_undo_request_signal_cb, obj);
3720 edje_object_signal_callback_add
3721 (priv->entry_edje, "entry,redo,request", "elm.text",
3722 _entry_redo_request_signal_cb, obj);
3725 edje_object_signal_callback_add
3726 (priv->entry_edje, "handler,move,start", "elm.text",
3727 _signal_handler_move_start_cb, obj);
3728 edje_object_signal_callback_add
3729 (priv->entry_edje, "handler,move,end", "elm.text",
3730 _signal_handler_move_end_cb, obj);
3731 edje_object_signal_callback_add
3732 (priv->entry_edje, "handler,moving", "elm.text",
3733 _signal_handler_moving_cb, obj);
3734 edje_object_signal_callback_add
3735 (priv->entry_edje, "selection,end", "elm.text",
3736 _signal_selection_end, obj);
3737 edje_object_signal_callback_add
3738 (priv->entry_edje, "long,pressed", "elm.text",
3739 _signal_long_pressed, obj);
3740 edje_object_signal_callback_add
3741 (priv->entry_edje, "magnifier,changed", "elm.text",
3742 _signal_magnifier_changed, obj);
3743 edje_object_signal_callback_add
3744 (priv->entry_edje, "cursor,handler,move,start", "elm.text",
3745 _signal_handler_move_start_cb, obj);
3746 edje_object_signal_callback_add
3747 (priv->entry_edje, "cursor,handler,move,end", "elm.text",
3748 _signal_handler_move_end_cb, obj);
3749 edje_object_signal_callback_add
3750 (priv->entry_edje, "cursor,handler,moving", "elm.text",
3751 _signal_handler_moving_cb, obj);
3752 edje_object_signal_callback_add
3753 (priv->entry_edje, "cursor,handler,clicked", "elm.text",
3754 _signal_handler_click_cb, obj);
3755 evas_object_event_callback_add(priv->entry_edje, EVAS_CALLBACK_KEY_DOWN,
3756 _elm_entry_key_down_cb, obj);
3759 elm_layout_text_set(obj, "elm.text", "");
3761 elm_object_sub_cursor_set
3762 (ELM_WIDGET_DATA(priv)->resize_obj, obj, ELM_CURSOR_XTERM);
3763 elm_widget_can_focus_set(obj, EINA_TRUE);
3764 if (_elm_config->desktop_entry)
3765 edje_object_part_text_select_allow_set
3766 (priv->entry_edje, "elm.text", EINA_TRUE);
3770 edje_object_part_text_select_allow_set(priv->entry_edje, "elm.text", EINA_TRUE);
3771 edje_object_part_text_viewport_region_set(priv->entry_edje, "elm.text", -1, -1, -1, -1);
3772 edje_object_part_text_layout_region_set(priv->entry_edje, "elm.text", -1, -1, -1, -1);
3776 elm_layout_sizing_eval(obj);
3778 elm_entry_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
3779 elm_entry_input_panel_enabled_set(obj, EINA_TRUE);
3780 elm_entry_prediction_allow_set(obj, EINA_TRUE);
3782 priv->autocapital_type = edje_object_part_text_autocapital_type_get
3783 (priv->entry_edje, "elm.text");
3785 #ifdef HAVE_ELEMENTARY_X
3786 top = elm_widget_top_get(obj);
3787 if ((top) && (elm_win_xwindow_get(top)))
3789 priv->sel_notify_handler =
3790 ecore_event_handler_add
3791 (ECORE_X_EVENT_SELECTION_NOTIFY, _event_selection_notify, obj);
3792 priv->sel_clear_handler =
3793 ecore_event_handler_add
3794 (ECORE_X_EVENT_SELECTION_CLEAR, _event_selection_clear, obj);
3797 priv->client_msg_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _xclient_msg_cb, obj); // TIZEN ONLY
3800 (obj, ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE,
3801 _drag_drop_cb, NULL);
3804 entries = eina_list_prepend(entries, obj);
3806 // module - find module for entry
3807 priv->api = _module_find(obj);
3808 // if found - hook in
3809 if ((priv->api) && (priv->api->obj_hook)) priv->api->obj_hook(obj);
3811 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3814 _elm_access_object_register(obj, priv->entry_edje);
3815 _elm_access_text_set
3816 (_elm_access_object_get(obj), ELM_ACCESS_TYPE, E_("Entry"));
3817 _elm_access_callback_set
3818 (_elm_access_object_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
3819 _elm_access_callback_set
3820 (_elm_access_object_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL);
3824 _elm_entry_smart_del(Evas_Object *obj)
3826 Elm_Entry_Context_Menu_Item *it;
3827 Elm_Entry_Item_Provider *ip;
3828 Elm_Entry_Markup_Filter *tf;
3830 ELM_ENTRY_DATA_GET(obj, sd);
3832 if (sd->delay_write)
3834 ecore_timer_del(sd->delay_write);
3835 sd->delay_write = NULL;
3836 if (sd->auto_save) _save_do(obj);
3839 elm_entry_anchor_hover_end(obj);
3840 elm_entry_anchor_hover_parent_set(obj, NULL);
3842 evas_event_freeze(evas_object_evas_get(obj));
3844 if (sd->file) eina_stringshare_del(sd->file);
3846 if (sd->hov_deljob) ecore_job_del(sd->hov_deljob);
3847 if ((sd->api) && (sd->api->obj_unhook))
3848 sd->api->obj_unhook(obj); // module - unhook
3850 entries = eina_list_remove(entries, obj);
3851 #ifdef HAVE_ELEMENTARY_X
3852 if (sd->sel_notify_handler)
3853 ecore_event_handler_del(sd->sel_notify_handler);
3854 if (sd->sel_clear_handler)
3855 ecore_event_handler_del(sd->sel_clear_handler);
3856 if (sd->client_msg_handler) // TIZEN ONLY
3857 ecore_event_handler_del(sd->client_msg_handler); //
3859 if (sd->cut_sel) eina_stringshare_del(sd->cut_sel);
3860 if (sd->text) eina_stringshare_del(sd->text);
3861 if (sd->deferred_recalc_job)
3862 ecore_job_del(sd->deferred_recalc_job);
3863 if (sd->append_text_idler)
3865 ecore_idler_del(sd->append_text_idler);
3866 free(sd->append_text_left);
3867 sd->append_text_left = NULL;
3868 sd->append_text_idler = NULL;
3870 if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer);
3871 EINA_LIST_FREE (sd->items, it)
3873 eina_stringshare_del(it->label);
3874 eina_stringshare_del(it->icon_file);
3875 eina_stringshare_del(it->icon_group);
3878 EINA_LIST_FREE (sd->item_providers, ip)
3882 EINA_LIST_FREE (sd->text_filters, tf)
3886 EINA_LIST_FREE (sd->markup_filters, tf)
3890 if (sd->delay_write) ecore_timer_del(sd->delay_write);
3891 if (sd->input_panel_imdata) free(sd->input_panel_imdata);
3893 if (sd->anchor_hover.hover_style)
3894 eina_stringshare_del(sd->anchor_hover.hover_style);
3897 if (sd->password_text) eina_stringshare_del(sd->password_text);
3898 if (sd->region_get_job) ecore_job_del(sd->region_get_job);
3899 if (sd->region_recalc_job) ecore_job_del(sd->region_recalc_job);
3900 if (sd->mgf_proxy) evas_object_del(sd->mgf_proxy);
3901 if (sd->mgf_bg) evas_object_del(sd->mgf_bg);
3902 if (sd->mgf_clip) evas_object_del(sd->mgf_clip);
3903 if (sd->click_timer) ecore_timer_del(sd->click_timer);
3905 evas_event_thaw(evas_object_evas_get(obj));
3906 evas_event_thaw_eval(evas_object_evas_get(obj));
3908 ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.del(obj);
3912 _elm_entry_smart_move(Evas_Object *obj,
3916 ELM_ENTRY_DATA_GET(obj, sd);
3918 ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.move(obj, x, y);
3920 evas_object_move(sd->hit_rect, x, y);
3922 if (sd->hoversel) _hoversel_position(obj);
3925 if (!_elm_config->desktop_entry)
3927 if (sd->region_get_job) ecore_job_del(sd->region_get_job);
3928 sd->region_get_job = ecore_job_add(_region_get_job, obj);
3934 _elm_entry_smart_resize(Evas_Object *obj,
3938 ELM_ENTRY_DATA_GET(obj, sd);
3940 ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.resize(obj, w, h);
3942 evas_object_resize(sd->hit_rect, w, h);
3946 _elm_entry_smart_member_add(Evas_Object *obj,
3947 Evas_Object *member)
3949 ELM_ENTRY_DATA_GET(obj, sd);
3951 ELM_WIDGET_CLASS(_elm_entry_parent_sc)->base.member_add(obj, member);
3954 evas_object_raise(sd->hit_rect);
3958 _elm_entry_smart_set_user(Elm_Entry_Smart_Class *sc)
3960 ELM_WIDGET_CLASS(sc)->base.add = _elm_entry_smart_add;
3961 ELM_WIDGET_CLASS(sc)->base.del = _elm_entry_smart_del;
3962 ELM_WIDGET_CLASS(sc)->base.move = _elm_entry_smart_move;
3963 ELM_WIDGET_CLASS(sc)->base.resize = _elm_entry_smart_resize;
3964 ELM_WIDGET_CLASS(sc)->base.member_add = _elm_entry_smart_member_add;
3966 ELM_WIDGET_CLASS(sc)->on_focus_region = _elm_entry_smart_on_focus_region;
3967 ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_entry_smart_sub_object_del;
3968 ELM_WIDGET_CLASS(sc)->on_focus = _elm_entry_smart_on_focus;
3969 ELM_WIDGET_CLASS(sc)->theme = _elm_entry_smart_theme;
3970 ELM_WIDGET_CLASS(sc)->disable = _elm_entry_smart_disable;
3971 ELM_WIDGET_CLASS(sc)->translate = _elm_entry_smart_translate;
3973 ELM_WIDGET_CLASS(sc)->event = _elm_entry_smart_event;
3976 /* not a 'focus chain manager' */
3977 ELM_WIDGET_CLASS(sc)->focus_next = NULL;
3978 ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
3980 ELM_CONTAINER_CLASS(sc)->content_set = _elm_entry_smart_content_set;
3981 ELM_CONTAINER_CLASS(sc)->content_unset = _elm_entry_smart_content_unset;
3983 ELM_LAYOUT_CLASS(sc)->signal = _elm_entry_smart_signal;
3984 ELM_LAYOUT_CLASS(sc)->callback_add = _elm_entry_smart_callback_add;
3985 ELM_LAYOUT_CLASS(sc)->callback_del = _elm_entry_smart_callback_del;
3986 ELM_LAYOUT_CLASS(sc)->text_set = _elm_entry_smart_text_set;
3987 ELM_LAYOUT_CLASS(sc)->text_get = _elm_entry_smart_text_get;
3988 ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_entry_smart_sizing_eval;
3989 ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
3992 EAPI const Elm_Entry_Smart_Class *
3993 elm_entry_smart_class_get(void)
3995 static Elm_Entry_Smart_Class _sc =
3996 ELM_ENTRY_SMART_CLASS_INIT_NAME_VERSION(ELM_ENTRY_SMART_NAME);
3997 static const Elm_Entry_Smart_Class *class = NULL;
3998 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
4003 _elm_entry_smart_set(&_sc);
4004 esc->callbacks = _smart_callbacks;
4011 elm_entry_add(Evas_Object *parent)
4015 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
4017 obj = elm_widget_add(_elm_entry_smart_class_new(), parent);
4018 if (!obj) return NULL;
4020 if (!elm_widget_sub_object_add(parent, obj))
4021 ERR("could not add %p as sub object of %p", obj, parent);
4027 elm_entry_text_style_user_push(Evas_Object *obj,
4030 ELM_ENTRY_CHECK(obj);
4031 ELM_ENTRY_DATA_GET(obj, sd);
4033 edje_object_part_text_style_user_push(sd->entry_edje, "elm.text", style);
4034 _elm_entry_smart_theme(obj);
4038 elm_entry_text_style_user_pop(Evas_Object *obj)
4040 ELM_ENTRY_CHECK(obj);
4041 ELM_ENTRY_DATA_GET(obj, sd);
4043 edje_object_part_text_style_user_pop(sd->entry_edje, "elm.text");
4045 _elm_entry_smart_theme(obj);
4049 elm_entry_text_style_user_peek(const Evas_Object *obj)
4051 ELM_ENTRY_CHECK(obj) NULL;
4052 ELM_ENTRY_DATA_GET(obj, sd);
4054 return edje_object_part_text_style_user_peek(sd->entry_edje, "elm.text");
4058 elm_entry_single_line_set(Evas_Object *obj,
4059 Eina_Bool single_line)
4061 ELM_ENTRY_CHECK(obj);
4062 ELM_ENTRY_DATA_GET(obj, sd);
4064 if (sd->single_line == single_line) return;
4066 sd->single_line = single_line;
4067 sd->line_wrap = ELM_WRAP_NONE;
4068 if (elm_entry_cnp_mode_get(obj) == ELM_CNP_MODE_MARKUP)
4069 elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
4070 _elm_entry_smart_theme(obj);
4074 if (sd->single_line)
4076 sd->s_iface->policy_set
4077 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
4079 sd->s_iface->bounce_allow_set(obj, EINA_FALSE, EINA_FALSE);
4084 sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
4086 sd->s_iface->bounce_allow_set(obj, EINA_FALSE, EINA_FALSE);
4089 elm_layout_sizing_eval(obj);
4094 elm_entry_single_line_get(const Evas_Object *obj)
4096 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4097 ELM_ENTRY_DATA_GET(obj, sd);
4099 return sd->single_line;
4103 elm_entry_password_set(Evas_Object *obj,
4106 ELM_ENTRY_CHECK(obj);
4107 ELM_ENTRY_DATA_GET(obj, sd);
4109 password = !!password;
4111 if (sd->password == password) return;
4112 sd->password = password;
4116 sd->single_line = EINA_TRUE;
4117 sd->line_wrap = ELM_WRAP_NONE;
4118 #ifdef HAVE_ELEMENTARY_X
4119 elm_drop_target_del(obj);
4121 _entry_selection_callbacks_unregister(obj);
4125 #ifdef HAVE_ELEMENTARY_X
4126 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
4128 _entry_selection_callbacks_register(obj);
4131 _elm_entry_smart_theme(obj);
4135 elm_entry_password_get(const Evas_Object *obj)
4137 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4138 ELM_ENTRY_DATA_GET(obj, sd);
4140 return sd->password;
4144 elm_entry_entry_set(Evas_Object *obj,
4147 ELM_ENTRY_CHECK(obj);
4148 _elm_entry_smart_text_set(obj, NULL, entry);
4152 elm_entry_entry_get(const Evas_Object *obj)
4154 ELM_ENTRY_CHECK(obj) NULL;
4155 return _elm_entry_smart_text_get(obj, NULL);
4159 elm_entry_entry_append(Evas_Object *obj,
4164 ELM_ENTRY_CHECK(obj);
4165 ELM_ENTRY_DATA_GET(obj, sd);
4167 if (!entry) entry = "";
4169 sd->changed = EINA_TRUE;
4171 len = strlen(entry);
4172 if (sd->append_text_left)
4176 tmpbuf = realloc(sd->append_text_left, sd->append_text_len + len + 1);
4182 sd->append_text_left = tmpbuf;
4183 memcpy(sd->append_text_left + sd->append_text_len, entry, len + 1);
4184 sd->append_text_len += len;
4188 /* FIXME: Add chunked appending here (like in entry_set) */
4189 edje_object_part_text_append(sd->entry_edje, "elm.text", entry);
4194 elm_entry_is_empty(const Evas_Object *obj)
4196 /* FIXME: until there's support for that in textblock, we just
4197 * check to see if the there is text or not. */
4198 const Evas_Object *tb;
4199 Evas_Textblock_Cursor *cur;
4202 ELM_ENTRY_CHECK(obj) EINA_TRUE;
4203 ELM_ENTRY_DATA_GET(obj, sd);
4205 /* It's a hack until we get the support suggested above. We just
4206 * create a cursor, point it to the begining, and then try to
4207 * advance it, if it can advance, the tb is not empty, otherwise it
4209 tb = edje_object_part_object_get(sd->entry_edje, "elm.text");
4211 /* This is actually, ok for the time being, these hackish stuff
4212 will be removed once evas 1.0 is out */
4213 cur = evas_object_textblock_cursor_new((Evas_Object *)tb);
4214 evas_textblock_cursor_pos_set(cur, 0);
4215 ret = evas_textblock_cursor_char_next(cur);
4216 evas_textblock_cursor_free(cur);
4219 #if 0 // TIZEN ONLY CODES : IF ABOVE CODES HAVE NO PROBLEM, THEN DELETE THESE CODES.
4220 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
4221 if (!str) return EINA_TRUE;
4223 ret = (strlen(str) == 0);
4231 elm_entry_textblock_get(Evas_Object *obj)
4233 ELM_ENTRY_CHECK(obj) NULL;
4234 ELM_ENTRY_DATA_GET(obj, sd);
4236 return (Evas_Object *)edje_object_part_object_get
4237 (sd->entry_edje, "elm.text");
4241 elm_entry_calc_force(Evas_Object *obj)
4243 ELM_ENTRY_CHECK(obj);
4244 ELM_ENTRY_DATA_GET(obj, sd);
4246 edje_object_calc_force(sd->entry_edje);
4247 sd->changed = EINA_TRUE;
4248 elm_layout_sizing_eval(obj);
4252 elm_entry_selection_get(const Evas_Object *obj)
4254 ELM_ENTRY_CHECK(obj) NULL;
4255 ELM_ENTRY_DATA_GET(obj, sd);
4257 if ((sd->password)) return NULL;
4258 return edje_object_part_text_selection_get(sd->entry_edje, "elm.text");
4262 elm_entry_entry_insert(Evas_Object *obj,
4265 ELM_ENTRY_CHECK(obj);
4266 ELM_ENTRY_DATA_GET(obj, sd);
4268 edje_object_part_text_insert(sd->entry_edje, "elm.text", entry);
4270 #ifdef HAVE_ELEMENTARY_X
4271 if (elm_widget_focus_get(obj))
4272 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
4275 sd->changed = EINA_TRUE;
4276 elm_layout_sizing_eval(obj);
4280 elm_entry_line_wrap_set(Evas_Object *obj,
4283 ELM_ENTRY_CHECK(obj);
4284 ELM_ENTRY_DATA_GET(obj, sd);
4286 if (sd->line_wrap == wrap) return;
4288 sd->line_wrap = wrap;
4289 _elm_entry_smart_theme(obj);
4293 elm_entry_line_wrap_get(const Evas_Object *obj)
4295 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4296 ELM_ENTRY_DATA_GET(obj, sd);
4298 return sd->line_wrap;
4302 elm_entry_editable_set(Evas_Object *obj,
4305 ELM_ENTRY_CHECK(obj);
4306 ELM_ENTRY_DATA_GET(obj, sd);
4308 if (sd->editable == editable) return;
4309 sd->editable = editable;
4310 _elm_entry_smart_theme(obj);
4312 #ifdef HAVE_ELEMENTARY_X
4314 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
4316 elm_drop_target_del(obj);
4321 elm_entry_editable_get(const Evas_Object *obj)
4323 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4324 ELM_ENTRY_DATA_GET(obj, sd);
4326 return sd->editable;
4330 elm_entry_select_none(Evas_Object *obj)
4332 ELM_ENTRY_CHECK(obj);
4333 ELM_ENTRY_DATA_GET(obj, sd);
4335 if ((sd->password)) return;
4338 sd->sel_mode = EINA_FALSE;
4339 if (!_elm_config->desktop_entry)
4340 edje_object_part_text_select_allow_set
4341 (sd->entry_edje, "elm.text", EINA_FALSE);
4342 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
4344 sd->have_selection = EINA_FALSE;
4345 edje_object_part_text_select_none(sd->entry_edje, "elm.text");
4349 elm_entry_select_all(Evas_Object *obj)
4351 ELM_ENTRY_CHECK(obj);
4352 ELM_ENTRY_DATA_GET(obj, sd);
4354 if ((sd->password)) return;
4357 sd->sel_mode = EINA_FALSE;
4358 if (!_elm_config->desktop_entry)
4359 edje_object_part_text_select_allow_set
4360 (sd->entry_edje, "elm.text", EINA_FALSE);
4361 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
4363 edje_object_part_text_select_all(sd->entry_edje, "elm.text");
4367 elm_entry_cursor_geometry_get(const Evas_Object *obj,
4373 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4374 ELM_ENTRY_DATA_GET(obj, sd);
4376 edje_object_part_text_cursor_geometry_get
4377 (sd->entry_edje, "elm.text", x, y, w, h);
4382 elm_entry_cursor_next(Evas_Object *obj)
4384 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4385 ELM_ENTRY_DATA_GET(obj, sd);
4387 return edje_object_part_text_cursor_next
4388 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4392 elm_entry_cursor_prev(Evas_Object *obj)
4394 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4395 ELM_ENTRY_DATA_GET(obj, sd);
4397 return edje_object_part_text_cursor_prev
4398 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4402 elm_entry_cursor_up(Evas_Object *obj)
4404 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4405 ELM_ENTRY_DATA_GET(obj, sd);
4407 return edje_object_part_text_cursor_up
4408 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4412 elm_entry_cursor_down(Evas_Object *obj)
4414 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4415 ELM_ENTRY_DATA_GET(obj, sd);
4417 return edje_object_part_text_cursor_down
4418 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4422 elm_entry_cursor_begin_set(Evas_Object *obj)
4424 ELM_ENTRY_CHECK(obj);
4425 ELM_ENTRY_DATA_GET(obj, sd);
4427 edje_object_part_text_cursor_begin_set
4428 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4432 elm_entry_cursor_end_set(Evas_Object *obj)
4434 ELM_ENTRY_CHECK(obj);
4435 ELM_ENTRY_DATA_GET(obj, sd);
4437 edje_object_part_text_cursor_end_set
4438 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4442 elm_entry_cursor_line_begin_set(Evas_Object *obj)
4444 ELM_ENTRY_CHECK(obj);
4445 ELM_ENTRY_DATA_GET(obj, sd);
4447 edje_object_part_text_cursor_line_begin_set
4448 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4452 elm_entry_cursor_line_end_set(Evas_Object *obj)
4454 ELM_ENTRY_CHECK(obj);
4455 ELM_ENTRY_DATA_GET(obj, sd);
4457 edje_object_part_text_cursor_line_end_set
4458 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4462 elm_entry_cursor_selection_begin(Evas_Object *obj)
4464 ELM_ENTRY_CHECK(obj);
4465 ELM_ENTRY_DATA_GET(obj, sd);
4467 edje_object_part_text_select_begin(sd->entry_edje, "elm.text");
4471 elm_entry_cursor_selection_end(Evas_Object *obj)
4473 ELM_ENTRY_CHECK(obj);
4474 ELM_ENTRY_DATA_GET(obj, sd);
4476 edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
4480 elm_entry_cursor_is_format_get(const Evas_Object *obj)
4482 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4483 ELM_ENTRY_DATA_GET(obj, sd);
4485 return edje_object_part_text_cursor_is_format_get
4486 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4490 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
4492 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4493 ELM_ENTRY_DATA_GET(obj, sd);
4495 return edje_object_part_text_cursor_is_visible_format_get
4496 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4500 elm_entry_cursor_content_get(const Evas_Object *obj)
4502 ELM_ENTRY_CHECK(obj) NULL;
4503 ELM_ENTRY_DATA_GET(obj, sd);
4505 return edje_object_part_text_cursor_content_get
4506 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4510 elm_entry_cursor_pos_set(Evas_Object *obj,
4513 ELM_ENTRY_CHECK(obj);
4514 ELM_ENTRY_DATA_GET(obj, sd);
4516 edje_object_part_text_cursor_pos_set
4517 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, pos);
4518 edje_object_message_signal_process(sd->entry_edje);
4522 elm_entry_cursor_pos_get(const Evas_Object *obj)
4524 ELM_ENTRY_CHECK(obj) 0;
4525 ELM_ENTRY_DATA_GET(obj, sd);
4527 return edje_object_part_text_cursor_pos_get
4528 (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
4532 elm_entry_selection_cut(Evas_Object *obj)
4534 ELM_ENTRY_CHECK(obj);
4535 ELM_ENTRY_DATA_GET(obj, sd);
4537 if ((sd->password)) return;
4538 _cut_cb(obj, NULL, NULL);
4542 elm_entry_selection_copy(Evas_Object *obj)
4544 ELM_ENTRY_CHECK(obj);
4545 ELM_ENTRY_DATA_GET(obj, sd);
4547 if ((sd->password)) return;
4548 _copy_cb(obj, NULL, NULL);
4552 elm_entry_selection_paste(Evas_Object *obj)
4554 ELM_ENTRY_CHECK(obj);
4555 ELM_ENTRY_DATA_GET(obj, sd);
4557 if ((sd->password)) return;
4558 _paste_cb(obj, NULL, NULL);
4562 elm_entry_context_menu_clear(Evas_Object *obj)
4564 Elm_Entry_Context_Menu_Item *it;
4566 ELM_ENTRY_CHECK(obj);
4567 ELM_ENTRY_DATA_GET(obj, sd);
4569 EINA_LIST_FREE (sd->items, it)
4571 eina_stringshare_del(it->label);
4572 eina_stringshare_del(it->icon_file);
4573 eina_stringshare_del(it->icon_group);
4579 elm_entry_context_menu_item_add(Evas_Object *obj,
4581 const char *icon_file,
4582 Elm_Icon_Type icon_type,
4586 Elm_Entry_Context_Menu_Item *it;
4588 ELM_ENTRY_CHECK(obj);
4589 ELM_ENTRY_DATA_GET(obj, sd);
4591 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
4594 sd->items = eina_list_append(sd->items, it);
4596 it->label = eina_stringshare_add(label);
4597 it->icon_file = eina_stringshare_add(icon_file);
4598 it->icon_type = icon_type;
4600 it->data = (void *)data;
4604 elm_entry_context_menu_disabled_set(Evas_Object *obj,
4607 ELM_ENTRY_CHECK(obj);
4608 ELM_ENTRY_DATA_GET(obj, sd);
4610 if (sd->context_menu == !disabled) return;
4611 sd->context_menu = !disabled;
4615 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
4617 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4618 ELM_ENTRY_DATA_GET(obj, sd);
4620 return !sd->context_menu;
4623 // TIZEN ONLY - START
4625 elm_entry_select_allow_set(Evas_Object *obj,
4628 ELM_ENTRY_CHECK(obj);
4629 ELM_ENTRY_DATA_GET(obj, sd);
4631 if (sd->sel_allow == allow) return;
4632 sd->sel_allow = allow;
4634 edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", allow);
4638 elm_entry_select_allow_get(const Evas_Object *obj)
4640 ELM_ENTRY_CHECK(obj);
4641 ELM_ENTRY_DATA_GET(obj, sd);
4643 return sd->sel_allow;
4647 elm_entry_cursor_handler_disabled_set(Evas_Object *obj,
4650 ELM_ENTRY_CHECK(obj);
4651 ELM_ENTRY_DATA_GET(obj, sd);
4653 if (sd->cursor_handler_disabled == disabled) return;
4654 sd->cursor_handler_disabled = disabled;
4656 if (!_elm_config->desktop_entry)
4657 edje_object_part_text_cursor_handler_disabled_set(sd->entry_edje, "elm.text", disabled);
4661 elm_entry_cursor_handler_disabled_get(const Evas_Object *obj)
4663 ELM_ENTRY_CHECK(obj);
4664 ELM_ENTRY_DATA_GET(obj, sd);
4665 return sd->cursor_handler_disabled;
4670 elm_entry_item_provider_append(Evas_Object *obj,
4671 Elm_Entry_Item_Provider_Cb func,
4674 Elm_Entry_Item_Provider *ip;
4676 ELM_ENTRY_CHECK(obj);
4677 ELM_ENTRY_DATA_GET(obj, sd);
4678 EINA_SAFETY_ON_NULL_RETURN(func);
4680 ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
4685 sd->item_providers = eina_list_append(sd->item_providers, ip);
4689 elm_entry_item_provider_prepend(Evas_Object *obj,
4690 Elm_Entry_Item_Provider_Cb func,
4693 Elm_Entry_Item_Provider *ip;
4695 ELM_ENTRY_CHECK(obj);
4696 ELM_ENTRY_DATA_GET(obj, sd);
4697 EINA_SAFETY_ON_NULL_RETURN(func);
4699 ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
4704 sd->item_providers = eina_list_prepend(sd->item_providers, ip);
4708 elm_entry_item_provider_remove(Evas_Object *obj,
4709 Elm_Entry_Item_Provider_Cb func,
4713 Elm_Entry_Item_Provider *ip;
4715 ELM_ENTRY_CHECK(obj);
4716 ELM_ENTRY_DATA_GET(obj, sd);
4717 EINA_SAFETY_ON_NULL_RETURN(func);
4719 EINA_LIST_FOREACH(sd->item_providers, l, ip)
4721 if ((ip->func == func) && ((!data) || (ip->data == data)))
4723 sd->item_providers = eina_list_remove_list(sd->item_providers, l);
4731 elm_entry_markup_filter_append(Evas_Object *obj,
4732 Elm_Entry_Filter_Cb func,
4735 Elm_Entry_Markup_Filter *tf;
4737 ELM_ENTRY_CHECK(obj);
4738 ELM_ENTRY_DATA_GET(obj, sd);
4739 EINA_SAFETY_ON_NULL_RETURN(func);
4741 tf = _filter_new(func, data);
4744 sd->markup_filters = eina_list_append(sd->markup_filters, tf);
4748 elm_entry_markup_filter_prepend(Evas_Object *obj,
4749 Elm_Entry_Filter_Cb func,
4752 Elm_Entry_Markup_Filter *tf;
4754 ELM_ENTRY_CHECK(obj);
4755 ELM_ENTRY_DATA_GET(obj, sd);
4756 EINA_SAFETY_ON_NULL_RETURN(func);
4758 tf = _filter_new(func, data);
4761 sd->markup_filters = eina_list_prepend(sd->markup_filters, tf);
4765 elm_entry_markup_filter_remove(Evas_Object *obj,
4766 Elm_Entry_Filter_Cb func,
4770 Elm_Entry_Markup_Filter *tf;
4772 ELM_ENTRY_CHECK(obj);
4773 ELM_ENTRY_DATA_GET(obj, sd);
4774 EINA_SAFETY_ON_NULL_RETURN(func);
4776 EINA_LIST_FOREACH(sd->markup_filters, l, tf)
4778 if ((tf->func == func) && ((!data) || (tf->data == data)))
4780 sd->markup_filters = eina_list_remove_list(sd->markup_filters, l);
4788 elm_entry_markup_to_utf8(const char *s)
4790 char *ss = _elm_util_mkup_to_text(s);
4791 if (!ss) ss = strdup("");
4796 elm_entry_utf8_to_markup(const char *s)
4798 char *ss = _elm_util_text_to_mkup(s);
4799 if (!ss) ss = strdup("");
4804 _text_get(const Evas_Object *obj)
4806 return elm_object_text_get(obj);
4810 elm_entry_filter_limit_size(void *data,
4814 const char *(*text_get)(const Evas_Object *);
4815 Elm_Entry_Filter_Limit_Size *lim = data;
4816 char *current, *utfstr;
4819 EINA_SAFETY_ON_NULL_RETURN(data);
4820 EINA_SAFETY_ON_NULL_RETURN(entry);
4821 EINA_SAFETY_ON_NULL_RETURN(text);
4823 /* hack. I don't want to copy the entire function to work with
4825 text_get = _text_get;
4827 current = elm_entry_markup_to_utf8(text_get(entry));
4828 utfstr = elm_entry_markup_to_utf8(*text);
4830 if (lim->max_char_count > 0)
4832 len = evas_string_char_len_get(current);
4833 newlen = evas_string_char_len_get(utfstr);
4834 if ((len >= lim->max_char_count) && (newlen > 0))
4836 evas_object_smart_callback_call(entry, SIG_MAX_LENGHT, NULL);
4843 if ((len + newlen) > lim->max_char_count)
4844 _chars_add_till_limit
4845 (entry, text, (lim->max_char_count - len), LENGTH_UNIT_CHAR);
4847 else if (lim->max_byte_count > 0)
4849 len = strlen(current);
4850 newlen = strlen(utfstr);
4851 if ((len >= lim->max_byte_count) && (newlen > 0))
4853 evas_object_smart_callback_call(entry, SIG_MAX_LENGHT, NULL);
4860 if ((len + newlen) > lim->max_byte_count)
4861 _chars_add_till_limit
4862 (entry, text, (lim->max_byte_count - len), LENGTH_UNIT_BYTE);
4870 elm_entry_filter_accept_set(void *data,
4871 Evas_Object *entry __UNUSED__,
4874 int read_idx, last_read_idx = 0, read_char;
4875 Elm_Entry_Filter_Accept_Set *as = data;
4880 EINA_SAFETY_ON_NULL_RETURN(data);
4881 EINA_SAFETY_ON_NULL_RETURN(text);
4883 if ((!as->accepted) && (!as->rejected))
4889 goes_in = EINA_TRUE;
4894 goes_in = EINA_FALSE;
4898 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4901 int cmp_idx, cmp_char;
4902 Eina_Bool in_set = EINA_FALSE;
4904 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4907 if (read_char == cmp_char)
4912 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4914 if (in_set == goes_in)
4916 int size = read_idx - last_read_idx;
4917 const char *src = (*text) + last_read_idx;
4919 memcpy(insert, *text + last_read_idx, size);
4922 last_read_idx = read_idx;
4923 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4929 elm_entry_file_set(Evas_Object *obj,
4931 Elm_Text_Format format)
4933 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4934 ELM_ENTRY_DATA_GET(obj, sd);
4936 if (sd->delay_write)
4938 ecore_timer_del(sd->delay_write);
4939 sd->delay_write = NULL;
4942 if (sd->auto_save) _save_do(obj);
4943 eina_stringshare_replace(&sd->file, file);
4944 sd->format = format;
4945 return _load_do(obj);
4949 elm_entry_file_get(const Evas_Object *obj,
4951 Elm_Text_Format *format)
4953 ELM_ENTRY_CHECK(obj);
4954 ELM_ENTRY_DATA_GET(obj, sd);
4956 if (file) *file = sd->file;
4957 if (format) *format = sd->format;
4961 elm_entry_file_save(Evas_Object *obj)
4963 ELM_ENTRY_CHECK(obj);
4964 ELM_ENTRY_DATA_GET(obj, sd);
4966 if (sd->delay_write)
4968 ecore_timer_del(sd->delay_write);
4969 sd->delay_write = NULL;
4972 sd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4976 elm_entry_autosave_set(Evas_Object *obj,
4977 Eina_Bool auto_save)
4979 ELM_ENTRY_CHECK(obj);
4980 ELM_ENTRY_DATA_GET(obj, sd);
4982 sd->auto_save = !!auto_save;
4986 elm_entry_autosave_get(const Evas_Object *obj)
4988 ELM_ENTRY_CHECK(obj) EINA_FALSE;
4989 ELM_ENTRY_DATA_GET(obj, sd);
4991 return sd->auto_save;
4994 EINA_DEPRECATED EAPI void
4995 elm_entry_cnp_textonly_set(Evas_Object *obj,
4998 Elm_Cnp_Mode cnp_mode = ELM_CNP_MODE_MARKUP;
5000 ELM_ENTRY_CHECK(obj);
5003 cnp_mode = ELM_CNP_MODE_NO_IMAGE;
5004 elm_entry_cnp_mode_set(obj, cnp_mode);
5007 EINA_DEPRECATED EAPI Eina_Bool
5008 elm_entry_cnp_textonly_get(const Evas_Object *obj)
5010 ELM_ENTRY_CHECK(obj) EINA_FALSE;
5012 return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
5016 elm_entry_cnp_mode_set(Evas_Object *obj,
5017 Elm_Cnp_Mode cnp_mode)
5019 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
5021 ELM_ENTRY_CHECK(obj);
5022 ELM_ENTRY_DATA_GET(obj, sd);
5024 if (sd->cnp_mode == cnp_mode) return;
5025 sd->cnp_mode = cnp_mode;
5026 if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
5027 format = ELM_SEL_FORMAT_TEXT;
5028 else if (cnp_mode == ELM_CNP_MODE_MARKUP)
5029 format |= ELM_SEL_FORMAT_IMAGE;
5030 #ifdef HAVE_ELEMENTARY_X
5031 elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
5036 elm_entry_cnp_mode_get(const Evas_Object *obj)
5038 ELM_ENTRY_CHECK(obj) ELM_CNP_MODE_MARKUP;
5039 ELM_ENTRY_DATA_GET(obj, sd);
5041 return sd->cnp_mode;
5045 elm_entry_scrollable_set(Evas_Object *obj,
5048 ELM_ENTRY_CHECK(obj);
5049 ELM_ENTRY_DATA_GET(obj, sd);
5052 if (sd->scroll == scroll) return;
5053 sd->scroll = scroll;
5057 /* we now must re-theme ourselves to a scroller decoration
5058 * and move the entry looking object to be the content of the
5059 * scrollable view */
5060 elm_widget_resize_object_set(obj, NULL);
5061 elm_widget_sub_object_add(obj, sd->entry_edje);
5065 sd->scr_edje = edje_object_add(evas_object_evas_get(obj));
5067 elm_widget_theme_object_set
5068 (obj, sd->scr_edje, "scroller", "entry",
5069 elm_widget_style_get(obj));
5071 evas_object_size_hint_weight_set
5072 (sd->scr_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5073 evas_object_size_hint_align_set
5074 (sd->scr_edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
5076 evas_object_propagate_events_set(sd->scr_edje, EINA_TRUE);
5079 elm_widget_resize_object_set(obj, sd->scr_edje);
5081 sd->s_iface->objects_set(obj, sd->scr_edje, sd->hit_rect);
5083 sd->s_iface->bounce_allow_set(obj, sd->h_bounce, sd->v_bounce);
5084 if (sd->single_line)
5085 sd->s_iface->policy_set
5086 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
5088 sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
5089 sd->s_iface->content_set(obj, sd->entry_edje);
5090 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
5096 sd->s_iface->content_set(obj, NULL);
5097 evas_object_hide(sd->scr_edje);
5099 elm_widget_resize_object_set(obj, sd->entry_edje);
5102 elm_widget_sub_object_add(obj, sd->scr_edje);
5104 sd->s_iface->objects_set(obj, sd->entry_edje, sd->hit_rect);
5106 elm_widget_on_show_region_hook_set(obj, NULL, NULL);
5109 _elm_entry_smart_theme(obj);
5113 elm_entry_scrollable_get(const Evas_Object *obj)
5115 ELM_ENTRY_CHECK(obj) EINA_FALSE;
5116 ELM_ENTRY_DATA_GET(obj, sd);
5122 elm_entry_icon_visible_set(Evas_Object *obj,
5125 ELM_ENTRY_CHECK(obj);
5127 if (!elm_layout_content_get(obj, "elm.swallow.icon")) return;
5130 elm_layout_signal_emit(obj, "elm,action,show,icon", "elm");
5132 elm_layout_signal_emit(obj, "elm,action,hide,icon", "elm");
5134 elm_layout_sizing_eval(obj);
5138 elm_entry_end_visible_set(Evas_Object *obj,
5141 ELM_ENTRY_CHECK(obj);
5143 if (!elm_layout_content_get(obj, "elm.swallow.icon")) return;
5146 elm_layout_signal_emit(obj, "elm,action,show,end", "elm");
5148 elm_layout_signal_emit(obj, "elm,action,hide,end", "elm");
5150 elm_layout_sizing_eval(obj);
5154 elm_entry_scrollbar_policy_set(Evas_Object *obj,
5155 Elm_Scroller_Policy h,
5156 Elm_Scroller_Policy v)
5158 ELM_ENTRY_CHECK(obj);
5159 ELM_ENTRY_DATA_GET(obj, sd);
5163 sd->s_iface->policy_set(obj, sd->policy_h, sd->policy_v);
5167 elm_entry_bounce_set(Evas_Object *obj,
5171 ELM_ENTRY_CHECK(obj);
5172 ELM_ENTRY_DATA_GET(obj, sd);
5174 sd->h_bounce = h_bounce;
5175 sd->v_bounce = v_bounce;
5176 sd->s_iface->bounce_allow_set(obj, h_bounce, v_bounce);
5180 elm_entry_bounce_get(const Evas_Object *obj,
5181 Eina_Bool *h_bounce,
5182 Eina_Bool *v_bounce)
5184 ELM_ENTRY_CHECK(obj);
5185 ELM_ENTRY_DATA_GET(obj, sd);
5187 sd->s_iface->bounce_allow_get(obj, h_bounce, v_bounce);
5191 elm_entry_input_panel_layout_set(Evas_Object *obj,
5192 Elm_Input_Panel_Layout layout)
5194 ELM_ENTRY_CHECK(obj);
5195 ELM_ENTRY_DATA_GET(obj, sd);
5197 sd->input_panel_layout = layout;
5199 edje_object_part_text_input_panel_layout_set
5200 (sd->entry_edje, "elm.text", layout);
5203 EAPI Elm_Input_Panel_Layout
5204 elm_entry_input_panel_layout_get(const Evas_Object *obj)
5206 ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_LAYOUT_INVALID;
5207 ELM_ENTRY_DATA_GET(obj, sd);
5209 return sd->input_panel_layout;
5213 elm_entry_autocapital_type_set(Evas_Object *obj,
5214 Elm_Autocapital_Type autocapital_type)
5216 ELM_ENTRY_CHECK(obj);
5217 ELM_ENTRY_DATA_GET(obj, sd);
5219 sd->autocapital_type = autocapital_type;
5220 edje_object_part_text_autocapital_type_set
5221 (sd->entry_edje, "elm.text", autocapital_type);
5224 EAPI Elm_Autocapital_Type
5225 elm_entry_autocapital_type_get(const Evas_Object *obj)
5227 ELM_ENTRY_CHECK(obj) ELM_AUTOCAPITAL_TYPE_NONE;
5228 ELM_ENTRY_DATA_GET(obj, sd);
5230 return sd->autocapital_type;
5234 elm_entry_prediction_allow_set(Evas_Object *obj,
5235 Eina_Bool prediction)
5237 ELM_ENTRY_CHECK(obj);
5238 ELM_ENTRY_DATA_GET(obj, sd);
5240 sd->prediction_allow = prediction;
5241 edje_object_part_text_prediction_allow_set
5242 (sd->entry_edje, "elm.text", prediction);
5246 elm_entry_prediction_allow_get(const Evas_Object *obj)
5248 ELM_ENTRY_CHECK(obj) EINA_TRUE;
5249 ELM_ENTRY_DATA_GET(obj, sd);
5251 return sd->prediction_allow;
5255 elm_entry_imf_context_reset(Evas_Object *obj)
5257 ELM_ENTRY_CHECK(obj);
5258 ELM_ENTRY_DATA_GET(obj, sd);
5260 edje_object_part_text_imf_context_reset(sd->entry_edje, "elm.text");
5264 elm_entry_input_panel_enabled_set(Evas_Object *obj,
5267 ELM_ENTRY_CHECK(obj);
5268 ELM_ENTRY_DATA_GET(obj, sd);
5270 sd->input_panel_enable = enabled;
5271 edje_object_part_text_input_panel_enabled_set
5272 (sd->entry_edje, "elm.text", enabled);
5276 elm_entry_input_panel_enabled_get(const Evas_Object *obj)
5278 ELM_ENTRY_CHECK(obj) EINA_TRUE;
5279 ELM_ENTRY_DATA_GET(obj, sd);
5281 return sd->input_panel_enable;
5285 elm_entry_input_panel_show(Evas_Object *obj)
5287 ELM_ENTRY_CHECK(obj);
5288 ELM_ENTRY_DATA_GET(obj, sd);
5290 edje_object_part_text_input_panel_show(sd->entry_edje, "elm.text");
5294 elm_entry_input_panel_hide(Evas_Object *obj)
5296 ELM_ENTRY_CHECK(obj);
5297 ELM_ENTRY_DATA_GET(obj, sd);
5299 edje_object_part_text_input_panel_hide(sd->entry_edje, "elm.text");
5303 elm_entry_input_panel_language_set(Evas_Object *obj,
5304 Elm_Input_Panel_Lang lang)
5306 ELM_ENTRY_CHECK(obj);
5307 ELM_ENTRY_DATA_GET(obj, sd);
5309 sd->input_panel_lang = lang;
5310 edje_object_part_text_input_panel_language_set
5311 (sd->entry_edje, "elm.text", lang);
5314 EAPI Elm_Input_Panel_Lang
5315 elm_entry_input_panel_language_get(const Evas_Object *obj)
5317 ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_LANG_AUTOMATIC;
5318 ELM_ENTRY_DATA_GET(obj, sd);
5320 return sd->input_panel_lang;
5324 elm_entry_input_panel_imdata_set(Evas_Object *obj,
5328 ELM_ENTRY_CHECK(obj);
5329 ELM_ENTRY_DATA_GET(obj, sd);
5331 if (sd->input_panel_imdata)
5332 free(sd->input_panel_imdata);
5334 sd->input_panel_imdata = calloc(1, len);
5335 sd->input_panel_imdata_len = len;
5336 memcpy(sd->input_panel_imdata, data, len);
5338 edje_object_part_text_input_panel_imdata_set
5339 (sd->entry_edje, "elm.text", sd->input_panel_imdata,
5340 sd->input_panel_imdata_len);
5344 elm_entry_input_panel_imdata_get(const Evas_Object *obj,
5348 ELM_ENTRY_CHECK(obj);
5349 ELM_ENTRY_DATA_GET(obj, sd);
5351 edje_object_part_text_input_panel_imdata_get
5352 (sd->entry_edje, "elm.text", data, len);
5356 elm_entry_input_panel_return_key_type_set(Evas_Object *obj,
5357 Elm_Input_Panel_Return_Key_Type
5360 ELM_ENTRY_CHECK(obj);
5361 ELM_ENTRY_DATA_GET(obj, sd);
5363 sd->input_panel_return_key_type = return_key_type;
5365 edje_object_part_text_input_panel_return_key_type_set
5366 (sd->entry_edje, "elm.text", return_key_type);
5369 EAPI Elm_Input_Panel_Return_Key_Type
5370 elm_entry_input_panel_return_key_type_get(const Evas_Object *obj)
5372 ELM_ENTRY_CHECK(obj) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
5373 ELM_ENTRY_DATA_GET(obj, sd);
5375 return sd->input_panel_return_key_type;
5379 elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj,
5382 ELM_ENTRY_CHECK(obj);
5383 ELM_ENTRY_DATA_GET(obj, sd);
5385 sd->input_panel_return_key_disabled = disabled;
5387 edje_object_part_text_input_panel_return_key_disabled_set
5388 (sd->entry_edje, "elm.text", disabled);
5392 elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
5394 ELM_ENTRY_CHECK(obj) EINA_FALSE;
5395 ELM_ENTRY_DATA_GET(obj, sd);
5397 return sd->input_panel_return_key_disabled;
5401 elm_entry_input_panel_return_key_autoenabled_set(Evas_Object *obj,
5404 ELM_ENTRY_CHECK(obj);
5405 ELM_ENTRY_DATA_GET(obj, sd);
5407 sd->auto_return_key = enabled;
5408 _return_key_enabled_check(obj);
5412 elm_entry_imf_context_get(Evas_Object *obj)
5414 ELM_ENTRY_CHECK(obj) NULL;
5415 ELM_ENTRY_DATA_GET(obj, sd);
5416 if (!sd) return NULL;
5418 return edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text");
5421 /* START - ANCHOR HOVER */
5423 _anchor_parent_del_cb(void *data,
5425 Evas_Object *obj __UNUSED__,
5426 void *event_info __UNUSED__)
5428 ELM_ENTRY_DATA_GET(data, sd);
5430 sd->anchor_hover.hover_parent = NULL;
5434 elm_entry_anchor_hover_parent_set(Evas_Object *obj,
5435 Evas_Object *parent)
5437 ELM_ENTRY_CHECK(obj);
5438 ELM_ENTRY_DATA_GET(obj, sd);
5440 if (sd->anchor_hover.hover_parent)
5441 evas_object_event_callback_del_full
5442 (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
5443 _anchor_parent_del_cb, obj);
5444 sd->anchor_hover.hover_parent = parent;
5445 if (sd->anchor_hover.hover_parent)
5446 evas_object_event_callback_add
5447 (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
5448 _anchor_parent_del_cb, obj);
5452 elm_entry_anchor_hover_parent_get(const Evas_Object *obj)
5454 ELM_ENTRY_CHECK(obj) NULL;
5455 ELM_ENTRY_DATA_GET(obj, sd);
5457 return sd->anchor_hover.hover_parent;
5461 elm_entry_anchor_hover_style_set(Evas_Object *obj,
5464 ELM_ENTRY_CHECK(obj);
5465 ELM_ENTRY_DATA_GET(obj, sd);
5467 eina_stringshare_replace(&sd->anchor_hover.hover_style, style);
5471 elm_entry_anchor_hover_style_get(const Evas_Object *obj)
5473 ELM_ENTRY_CHECK(obj) NULL;
5474 ELM_ENTRY_DATA_GET(obj, sd);
5476 return sd->anchor_hover.hover_style;
5480 elm_entry_anchor_hover_end(Evas_Object *obj)
5482 ELM_ENTRY_CHECK(obj);
5483 ELM_ENTRY_DATA_GET(obj, sd);
5485 if (sd->anchor_hover.hover) evas_object_del(sd->anchor_hover.hover);
5486 if (sd->anchor_hover.pop) evas_object_del(sd->anchor_hover.pop);
5487 sd->anchor_hover.hover = NULL;
5488 sd->anchor_hover.pop = NULL;
5491 /* END - ANCHOR HOVER */
5493 ////////////// TIZEN ONLY APIs
5495 elm_entry_magnifier_disabled_set(Evas_Object *obj, Eina_Bool disabled)
5497 ELM_ENTRY_CHECK(obj);
5498 ELM_ENTRY_DATA_GET(obj, sd);
5500 if (sd->magnifier_enabled == !disabled) return;
5501 sd->magnifier_enabled = !disabled;
5505 elm_entry_magnifier_disabled_get(const Evas_Object *obj)
5507 ELM_ENTRY_CHECK(obj) EINA_FALSE;
5508 ELM_ENTRY_DATA_GET(obj, sd);
5510 return !sd->magnifier_enabled;
5514 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
5516 ELM_ENTRY_CHECK(obj);
5517 ELM_ENTRY_DATA_GET(obj, sd);
5519 sd->mgf_type = type;
5520 _magnifier_create(obj);
5522 ////////////////////////////////