X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flib%2Felm_entry.c;h=0e114ea15cd012c53bfe8708a7cc78de677fc237;hb=5af2204f4b62940c1e59b767a5597256505d6af5;hp=700dfedbee104f17781d4e4b4150665f09e4820e;hpb=7fe8a6085aeebeb6f4b1fa579e2b11be568bc634;p=framework%2Fuifw%2Felementary.git diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index 700dfed..0e114ea 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -125,7 +125,6 @@ struct _Widget_Data Ecore_Job *deferred_recalc_job; Ecore_Event_Handler *sel_notify_handler; Ecore_Event_Handler *sel_clear_handler; - Ecore_Timer *longpress_timer; Ecore_Timer *delay_write; /* for deferred appending */ Ecore_Idler *append_text_idler; @@ -135,6 +134,7 @@ struct _Widget_Data /* Only for clipboard */ const char *cut_sel; const char *text; + const char *password_text; Evas_Coord wrap_w; const char *file; Elm_Text_Format format; @@ -146,11 +146,13 @@ struct _Widget_Data Eina_List *text_filters; Eina_List *match_list; Ecore_Job *matchlist_job; + int matchlist_threshold; Ecore_Job *hovdeljob; Mod_Api *api; // module api if supplied int cursor_pos; Elm_Scroller_Policy policy_h, policy_v; Elm_Wrap_Type linewrap; + Elm_Input_Panel_Layout input_panel_layout; Eina_Bool changed : 1; Eina_Bool single_line : 1; Eina_Bool password : 1; @@ -174,11 +176,9 @@ struct _Widget_Data Eina_Bool autoreturnkey : 1; Eina_Bool input_panel_enable : 1; Eina_Bool autocapital : 1; - Elm_Input_Panel_Layout input_panel_layout; Eina_Bool autoperiod : 1; Eina_Bool matchlist_list_clicked : 1; Eina_Bool matchlist_case_sensitive : 1; - int matchlist_threshold; }; struct _Elm_Entry_Context_Menu_Item @@ -589,6 +589,7 @@ _del_hook(Evas_Object *obj) #endif if (wd->cut_sel) eina_stringshare_del(wd->cut_sel); if (wd->text) eina_stringshare_del(wd->text); + if (wd->password_text) eina_stringshare_del(wd->password_text); if (wd->bg) evas_object_del(wd->bg); if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job); if (wd->append_text_idler) @@ -599,7 +600,6 @@ _del_hook(Evas_Object *obj) wd->append_text_idler = NULL; } if (wd->matchlist_job) ecore_job_del(wd->matchlist_job); - if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer); if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy); if (wd->mgf_bg) evas_object_del(wd->mgf_bg); if (wd->mgf_clip) evas_object_del(wd->mgf_clip); @@ -711,6 +711,7 @@ _recalc_cursor_geometry(Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; evas_object_smart_callback_call(obj, SIG_CURSOR_CHANGED, NULL); + if (!elm_object_focus_get(obj)) return; if (!wd->deferred_recalc_job) { Evas_Coord cx, cy, cw, ch; @@ -730,7 +731,7 @@ static void _elm_win_recalc_job(void *data) { Widget_Data *wd = elm_widget_data_get(data); - Evas_Coord minh = -1, resw = -1, minw = -1; + Evas_Coord minh = -1, resw = -1, minw = -1, fw = 0, fh = 0; if (!wd) return; wd->deferred_recalc_job = NULL; @@ -748,13 +749,41 @@ _elm_win_recalc_job(void *data) evas_object_size_hint_min_get(data, &ominw, NULL); minw = ominw; } - evas_object_size_hint_min_set(data, minw, minh); - if (wd->single_line) - evas_object_size_hint_max_set(data, -1, minh); + + elm_coords_finger_size_adjust(1, &fw, 1, &fh); + if (wd->scroll) + { + Evas_Coord vmw = 0, vmh = 0; + + edje_object_size_min_calc + (elm_smart_scroller_edje_object_get(wd->scroller), + &vmw, &vmh); + if (wd->single_line) + { + evas_object_size_hint_min_set(data, vmw, minh + vmh); + evas_object_size_hint_max_set(data, -1, minh + vmh); + } + else + { + evas_object_size_hint_min_set(data, vmw, vmh); + evas_object_size_hint_max_set(data, -1, -1); + } + } else - evas_object_size_hint_max_set(data, -1, -1); + { + if (wd->single_line) + { + evas_object_size_hint_min_set(data, minw, minh); + evas_object_size_hint_max_set(data, -1, minh); + } + else + { + evas_object_size_hint_min_set(data, fw, minh); + evas_object_size_hint_max_set(data, -1, -1); + } + } - if (wd->deferred_cur) + if ((wd->deferred_cur) && (elm_object_focus_get(data))) { Evas_Coord cx, cy, cw, ch; edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", @@ -801,6 +830,7 @@ _sizing_eval(Evas_Object *obj) if (wd->single_line) h = vmh + minh; else h = vmh; evas_object_resize(wd->ent, vw, vh); + evas_object_size_hint_min_get(obj, &w, NULL); evas_object_size_hint_min_set(obj, w, h); if (wd->single_line) evas_object_size_hint_max_set(obj, -1, h); @@ -838,6 +868,7 @@ _sizing_eval(Evas_Object *obj) &vmw, &vmh); if (wd->single_line) h = vmh + minh; else h = vmh; + evas_object_size_hint_min_get(obj, &w, NULL); evas_object_size_hint_min_set(obj, w, h); if (wd->single_line) evas_object_size_hint_max_set(obj, -1, h); @@ -888,7 +919,6 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); Evas_Object *top = elm_widget_top_get(obj); if (!wd) return; - if (!wd->editable) return; if (elm_widget_focus_get(obj)) { printf("[Elm_entry::Focused] obj : %p\n", obj); @@ -897,8 +927,7 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj) if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON); evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL); _check_enable_returnkey(obj); - wd->mgf_type = _ENTRY_MAGNIFIER_FILLWIDTH; - _magnifier_create(obj); + wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE; } else { @@ -971,7 +1000,7 @@ _show_region_hook(void *data, Evas_Object *obj) if (!wd) return; elm_widget_show_region_get(obj, &x, &y, &w, &h); if (wd->scroll) - elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h); + elm_smart_scroller_child_region_show(wd->scroller, x, y, w, h); } static void @@ -1127,12 +1156,47 @@ _store_selection(Elm_Sel_Type seltype, Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); const char *sel; + char *sel_str; if (!wd) return; sel = edje_object_part_text_selection_get(wd->ent, "elm.text"); - elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel); + sel_str = strdup(sel); + if (!sel_str) + return; + if (wd->textonly) + { + while (EINA_TRUE) + { + char *startTag = NULL; + char *endTag = NULL; + + startTag = strstr(sel_str, ""); + else + break; + if (!endTag || startTag > endTag) + break; + + size_t sindex = startTag - sel_str; + size_t eindex = endTag - sel_str + 1; + + Eina_Strbuf *buf = eina_strbuf_new(); + if (buf) + { + eina_strbuf_append(buf, sel_str); + eina_strbuf_remove(buf, sindex, eindex); + sel_str = eina_strbuf_string_steal(buf); + eina_strbuf_free(buf); + } + } + } + elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str); if (seltype == ELM_SEL_CLIPBOARD) - eina_stringshare_replace(&wd->cut_sel, sel); + eina_stringshare_replace(&wd->cut_sel, sel_str); + free(sel_str); } static void @@ -1157,15 +1221,13 @@ _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Widget_Data *wd = elm_widget_data_get(data); if (!wd) return; - wd->selmode = EINA_FALSE; + wd->selmode = EINA_TRUE; if (!_elm_config->desktop_entry) { - edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE); edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm"); elm_widget_scroll_hold_pop(data); } _store_selection(ELM_SEL_CLIPBOARD, data); - // edje_object_part_text_select_none(wd->ent, "elm.text"); } static void @@ -1315,6 +1377,9 @@ _magnifier_hide(void *data) evas_object_hide(wd->mgf_bg); evas_object_hide(wd->mgf_clip); + + if (wd->scroll) + elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE); } static void @@ -1336,9 +1401,18 @@ _magnifier_move(void *data) Evas_Coord x, y, w, h, fs; Evas_Coord cx, cy, cw, ch, ox, oy; - evas_object_geometry_get(data, &x, &y, &w, &h); edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch); + if (wd->scroll) + { + evas_object_geometry_get(wd->scroller, &x, &y, &w, &h); + elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy); + cx -= ox; + cy -= oy; + } + else + evas_object_geometry_get(data, &x, &y, &w, &h); + ox = oy = 0; fs = elm_finger_size_get(); @@ -1359,7 +1433,7 @@ static void _magnifier_create(void *data) { Widget_Data *wd = elm_widget_data_get(data); - Evas_Coord x, y, w, h; + Evas_Coord x, y, w, h, mw, mh; const char* key_data = NULL; if (!wd) return; @@ -1375,7 +1449,14 @@ _magnifier_create(void *data) if (wd->mgf_bg) evas_object_del(wd->mgf_bg); if (wd->mgf_clip) evas_object_del(wd->mgf_clip); - evas_object_geometry_get(data, &x, &y, &w, &h); + if (wd->scroll) + evas_object_geometry_get(wd->scroller, &x, &y, &w, &h); + else + evas_object_geometry_get(data, &x, &y, &w, &h); + + if ((w <= 0) || (h <= 0)) + return; + wd->mgf_bg = edje_object_add(evas_object_evas_get(data)); if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE) @@ -1398,12 +1479,24 @@ _magnifier_create(void *data) evas_object_resize(wd->mgf_bg, w, wd->mgf_height); if (wd->scroll) - wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller)); + { + elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE); + wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller)); + evas_object_image_source_set(wd->mgf_proxy, wd->scroller); + } else - wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data)); - evas_object_image_source_set(wd->mgf_proxy, data); - evas_object_resize(wd->mgf_proxy, w * wd->mgf_scale, h * wd->mgf_scale); - evas_object_image_fill_set(wd->mgf_proxy, 0, 0, w * wd->mgf_scale, h * wd->mgf_scale); + { + wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data)); + evas_object_image_source_set(wd->mgf_proxy, data); + } + + mw = (Evas_Coord)((float)w * wd->mgf_scale); + mh = (Evas_Coord)((float)h * wd->mgf_scale); + if ((mw <= 0) || (mh <= 0)) + return; + + evas_object_resize(wd->mgf_proxy, mw, mh); + evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh); evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255); evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE); evas_object_show(wd->mgf_proxy); @@ -1414,19 +1507,13 @@ _magnifier_create(void *data) } static Eina_Bool -_long_press(void *data) +_signal_long_pressed(void *data) { Widget_Data *wd = elm_widget_data_get(data); if (!wd) return ECORE_CALLBACK_CANCEL; wd->long_pressed = EINA_TRUE; - if (wd->longpress_timer) - { - ecore_timer_del(wd->longpress_timer); - wd->longpress_timer = NULL; - } - _cancel(data, NULL, NULL); _magnifier_create(data); @@ -1434,7 +1521,6 @@ _long_press(void *data) _magnifier_show(data); elm_object_scroll_freeze_push(data); - wd->longpress_timer = NULL; evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL); return ECORE_CALLBACK_CANCEL; } @@ -1450,11 +1536,6 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void wd->downx = ev->canvas.x; wd->downy = ev->canvas.y; wd->long_pressed = EINA_FALSE; - if (ev->button == 1) - { - if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer); - wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data); - } } static void @@ -1466,28 +1547,16 @@ _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void * if (wd->disabled) return; if (ev->button == 1) { - if (wd->longpress_timer) - { - ecore_timer_del(wd->longpress_timer); - wd->longpress_timer = NULL; - } - if (!wd->double_clicked) { if ((wd->api) && (wd->api->obj_mouseup)) - { - wd->api->obj_mouseup(data); - } + wd->api->obj_mouseup(data); } - _magnifier_hide(data); elm_object_scroll_freeze_pop(data); if (wd->long_pressed) - { - _menu_press(data); - } - + _menu_press(data); } else if (ev->button == 3) { @@ -1503,49 +1572,6 @@ _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void Evas_Event_Mouse_Move *ev = event_info; if (!wd) return; if (wd->disabled) return; - if (!wd->selmode) - { - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) - { - if (wd->longpress_timer) - { - ecore_timer_del(wd->longpress_timer); - wd->longpress_timer = NULL; - } - } - else if (wd->longpress_timer) - { - Evas_Coord dx, dy; - - dx = wd->downx - ev->cur.canvas.x; - dx *= dx; - dy = wd->downy - ev->cur.canvas.y; - dy *= dy; - if ((dx + dy) > - ((_elm_config->finger_size / 2) * - (_elm_config->finger_size / 2))) - { - ecore_timer_del(wd->longpress_timer); - wd->longpress_timer = NULL; - } - } - } - else if (wd->longpress_timer) - { - Evas_Coord dx, dy; - - dx = wd->downx - ev->cur.canvas.x; - dx *= dx; - dy = wd->downy - ev->cur.canvas.y; - dy *= dy; - if ((dx + dy) > - ((_elm_config->finger_size / 2) * - (_elm_config->finger_size / 2))) - { - ecore_timer_del(wd->longpress_timer); - wd->longpress_timer = NULL; - } - } if (ev->buttons == 1) { @@ -1628,6 +1654,27 @@ _entry_length_get(Evas_Object *obj) return len; } +#ifndef HAVE_STRCASESTR +char* _strcasestr(const char *s, const char *find) +{ + char c, sc; + size_t len; + + if ((c = *find++) != 0) { + c = tolower((unsigned char) c); + len = strlen(find); + do { + do { + if( (sc = *s++) == 0) + return NULL; + } while ((char)tolower((unsigned char)sc) != c); + } while (strncasecmp(s, find, len) != 0); + s--; + } + return ((char*) s); +} +#endif + static void _matchlist_show(void *data) { @@ -1672,7 +1719,11 @@ _matchlist_show(void *data) if (wd->matchlist_case_sensitive) str_result = strstr(str_list, text); else - str_result = strcasestr(str_list, text); +#ifdef HAVE_STRCASESTR + str_result = strcasestr(str_list, text); +#else + str_result = _strcasestr(str_list, text); +#endif if (str_result) { @@ -1739,70 +1790,32 @@ static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_i elm_widget_focus_set(data, EINA_TRUE); } -EAPI void -elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - - if (match_list) - { - Evas_Coord max_w = 9999, max_h = 9999; - const char* key_data = NULL; - - wd->matchlist_threshold = 1; - wd->hover = elm_hover_add(elm_widget_parent_get(obj)); - elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj)); - elm_hover_target_set(wd->hover, obj); - elm_object_style_set(wd->hover, "matchlist"); - - wd->layout = elm_layout_add(wd->hover); - elm_layout_theme_set(wd->layout, "entry", "matchlist", "default"); - wd->list = elm_list_add(wd->layout); - evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_list_mode_set(wd->list, ELM_LIST_EXPAND); - elm_object_style_set(wd->list, "matchlist"); - - key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width"); - if (key_data) max_w = atoi(key_data); - key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height"); - if (key_data) max_h = atoi(key_data); - - elm_list_go(wd->list); - evas_object_size_hint_max_set(wd->list, max_w, max_h); - evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj); - elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list); - elm_hover_content_set(wd->hover, "bottom", wd->layout); - - wd->match_list = match_list; - } - else - { - if (wd->hover) - evas_object_del(wd->hover); - - wd->match_list = NULL; - } - - wd->matchlist_case_sensitive = case_sensitive; -} - static void _entry_changed_common_handling(void *data, const char *event) { Widget_Data *wd = elm_widget_data_get(data); - Evas_Coord minh; + Evas_Coord minw, minh; if (!wd) return; wd->changed = EINA_TRUE; /* Reset the size hints which are no more relevant. * Keep the height, this is a hack, but doesn't really matter * cause we'll re-eval in a moment. */ - evas_object_size_hint_min_get(data, NULL, &minh); - evas_object_size_hint_min_set(data, -1, minh); + if (wd->scroll) + { + evas_object_size_hint_min_get(data, &minw, &minh); + evas_object_size_hint_min_set(data, minw, minh); + } + else + { + evas_object_size_hint_min_get(data, NULL, &minh); + evas_object_size_hint_min_set(data, -1, minh); + } + _sizing_eval(data); if (wd->text) eina_stringshare_del(wd->text); wd->text = NULL; + if (wd->password_text) eina_stringshare_del(wd->password_text); + wd->password_text = NULL; _check_enable_returnkey(data); evas_object_smart_callback_call(data, event, NULL); if (wd->delay_write) @@ -1812,10 +1825,10 @@ _entry_changed_common_handling(void *data, const char *event) } if ((wd->single_line) && (wd->match_list)) - { - if (wd->matchlist_job) ecore_job_del(wd->matchlist_job); - wd->matchlist_job = ecore_job_add(_matchlist_show, data); - } + { + if (wd->matchlist_job) ecore_job_del(wd->matchlist_job); + wd->matchlist_job = ecore_job_add(_matchlist_show, data); + } if ((!wd->autosave) || (!wd->file)) return; wd->delay_write = ecore_timer_add(2.0, _delay_write, data); } @@ -1823,26 +1836,37 @@ _entry_changed_common_handling(void *data, const char *event) static void _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { + Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return; + _entry_changed_common_handling(data, SIG_CHANGED); + + if ((wd->api) && (wd->api->obj_hidemenu)) + wd->api->obj_hidemenu(data); } static void _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { + Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return; + _entry_changed_common_handling(data, SIG_PREEDIT_CHANGED); -} + if ((wd->api) && (wd->api->obj_hidemenu)) + wd->api->obj_hidemenu(data); +} static void _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return; + elm_object_scroll_freeze_push(data); if ((wd->api) && (wd->api->obj_hidemenu)) - { - wd->api->obj_hidemenu(data); - } + wd->api->obj_hidemenu(data); _magnifier_create(data); _magnifier_move(data); @@ -1853,6 +1877,8 @@ static void _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return; + elm_object_scroll_freeze_pop(data); if (wd->have_selection) @@ -1869,6 +1895,39 @@ _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emis _magnifier_show(data); } +static Evas_Object * +_viewport_obj_get(Evas_Object *data) +{ + Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return NULL; + + if(!data || !strlen(elm_widget_type_get(data))) + return NULL; + + Evas_Coord x, y, w, h; + x = y = w = h = -1; + + if (wd->scroll) + { + //evas_object_geometry_get(wd->scroller, &x, &y, &w, &h); + //printf(">>> wd->scroller (%d, %d, %d, %d) \n", x, y, w, h); + return wd->scroller; + } + + Evas_Object *parent_obj = data; + + while(parent_obj = elm_widget_parent_get(parent_obj)) + { + //evas_object_geometry_get(parent_obj, &x, &y, &w, &h); + //printf(">>> %s (%d, %d, %d, %d) \n", elm_widget_type_get(parent_obj), x, y, w, h); + if (!strcmp(elm_widget_type_get(parent_obj), "scroller") || + !strcmp(elm_widget_type_get(parent_obj), "genlist")) + return parent_obj; + } + + return NULL; +} + static void _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { @@ -1901,6 +1960,9 @@ _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emi elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt); } #endif + + if (!_elm_config->desktop_entry) + edje_object_part_text_viewport_object_set(wd->ent, "elm.text", _viewport_obj_get(data)); } static void @@ -1912,7 +1974,7 @@ _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *e edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch); if (!wd->deferred_recalc_job) - elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE); + elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE); else { wd->deferred_cur = EINA_TRUE; @@ -1937,7 +1999,7 @@ _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *e edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch); if (!wd->deferred_recalc_job) - elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE); + elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get(), EINA_FALSE); else { wd->deferred_cur = EINA_TRUE; @@ -2151,9 +2213,7 @@ _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission evas_object_smart_callback_call(data, SIG_PRESS, NULL); if ((wd->api) && (wd->api->obj_hidemenu)) - { - wd->api->obj_hidemenu(data); - } + wd->api->obj_hidemenu(data); } static void @@ -2162,6 +2222,9 @@ _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emiss Widget_Data *wd = elm_widget_data_get(data); if (!wd) return; evas_object_smart_callback_call(data, SIG_CLICKED, NULL); + + if (!_elm_config->desktop_entry && !wd->double_clicked) + _cancel(data, NULL, NULL); } static void @@ -2464,16 +2527,51 @@ _text_append_idler(void *data) Widget_Data *wd = elm_widget_data_get(obj); if (wd->text) eina_stringshare_del(wd->text); wd->text = NULL; + if (wd->password_text) eina_stringshare_del(wd->password_text); + wd->password_text = NULL; wd->changed = EINA_TRUE; start = wd->append_text_position; - if(start + _CHUNK_SIZE < wd->append_text_len) + if (start + _CHUNK_SIZE < wd->append_text_len) { - wd->append_text_position = (start + _CHUNK_SIZE); - /* Go to the start of the nearest codepoint, because we don't want - * to cut it in the middle */ - eina_unicode_utf8_get_prev(wd->append_text_left, - &wd->append_text_position); + int pos = start; + int tag_start, esc_start; + + tag_start = esc_start = -1; + /* Find proper markup cut place */ + while (pos - start < _CHUNK_SIZE) + { + int prev_pos = pos; + Eina_Unicode tmp = + eina_unicode_utf8_get_next(wd->append_text_left, &pos); + if (esc_start == -1) + { + if (tmp == '<') + tag_start = prev_pos; + else if (tmp == '>') + tag_start = -1; + } + else if (tag_start == -1) + { + if (tmp == '&') + esc_start = prev_pos; + else if (tmp == ';') + esc_start = -1; + } + } + + if (tag_start >= 0) + { + wd->append_text_position = tag_start; + } + else if (esc_start >= 0) + { + wd->append_text_position = esc_start; + } + else + { + wd->append_text_position = pos; + } } else { @@ -2581,6 +2679,8 @@ _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry) if (!entry) entry = ""; if (wd->text) eina_stringshare_del(wd->text); wd->text = NULL; + if (wd->password_text) eina_stringshare_del(wd->password_text); + wd->password_text = NULL; wd->changed = EINA_TRUE; /* Clear currently pending job if there is one */ @@ -2623,12 +2723,13 @@ _elm_entry_text_get(const Evas_Object *obj, const char *item) if (item && strcmp(item, "default")) return NULL; const char *text; if (!wd) return NULL; - if (wd->text) + if (wd->password) { - if (wd->password) - return elm_entry_markup_to_utf8(wd->text); - else - return wd->text; + if(wd->password_text) return wd->password_text; + } + else if (wd->text) + { + return wd->text; } text = edje_object_part_text_get(wd->ent, "elm.text"); if (!text) @@ -2637,7 +2738,17 @@ _elm_entry_text_get(const Evas_Object *obj, const char *item) return NULL; } eina_stringshare_replace(&wd->text, text); - if (wd->password) return elm_entry_markup_to_utf8(wd->text); + if (wd->password) + { + const char *pw_text; + pw_text = elm_entry_markup_to_utf8(wd->text); + if (pw_text) + { + eina_stringshare_replace(&wd->password_text, pw_text); + free(pw_text); + return wd->password_text; + } + } return wd->text; } @@ -2686,7 +2797,7 @@ elm_entry_add(Evas_Object *parent) evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); - evas_object_propagate_events_set(wd->scroller, EINA_TRUE); + elm_smart_scroller_propagate_events_set(wd->scroller, EINA_TRUE); wd->linewrap = ELM_WRAP_WORD; wd->editable = EINA_TRUE; @@ -2724,6 +2835,8 @@ elm_entry_add(Evas_Object *parent) _signal_selection_start, obj); edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text", _signal_selection_end, obj); + edje_object_signal_callback_add(wd->ent, "long,pressed", "elm.text", + _signal_long_pressed, obj); edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text", _signal_magnifier_changed, obj); edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text", @@ -2808,8 +2921,8 @@ EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extensi ext_mod->select = _select; ext_mod->selectall = _selectall; ext_mod->ent = wd->ent; + ext_mod->viewport_obj = _viewport_obj_get(obj); ext_mod->items = wd->items; - ext_mod->longpress_timer = wd->longpress_timer; ext_mod->editable = wd->editable; ext_mod->have_selection = wd->have_selection; ext_mod->password = wd->password; @@ -2843,9 +2956,12 @@ elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line) if (wd->scroller) { if (wd->single_line) - elm_smart_scroller_policy_set(wd->scroller, - ELM_SMART_SCROLLER_POLICY_OFF, - ELM_SMART_SCROLLER_POLICY_OFF); + { + elm_smart_scroller_policy_set(wd->scroller, + ELM_SMART_SCROLLER_POLICY_OFF, + ELM_SMART_SCROLLER_POLICY_OFF); + elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); + } else { const Elm_Scroller_Policy map[3] = @@ -2857,6 +2973,7 @@ elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line) elm_smart_scroller_policy_set(wd->scroller, map[wd->policy_h], map[wd->policy_v]); + elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); } _sizing_eval(obj); } @@ -3011,7 +3128,7 @@ elm_entry_is_empty(const Evas_Object *obj) Eina_Bool ret; if (!wd) return EINA_TRUE; -#if 0 +#if 0 /* It's a hack until we get the support suggested above. * We just create a cursor, point it to the begining, and then * try to advance it, if it can advance, the tb is not empty, @@ -3108,36 +3225,6 @@ elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap) } /** - * Set wrap width of the entry - * - * @param obj The entry object - * @param w The wrap width in pixels at a minimum where words need to wrap - * @ingroup Entry - */ -EAPI void -elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (wd->wrap_w == w) return; - wd->wrap_w = w; - _sizing_eval(obj); -} - -/** - * get wrap width of the entry - * - * @param obj The entry object - * @return The wrap width in pixels at a minimum where words need to wrap - * @ingroup Entry - */ -EAPI Evas_Coord -elm_entry_wrap_width_get(const Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - return wd->wrap_w; -} - -/** * Get the wrapping behavior of the entry. * See also elm_entry_line_wrap_set(). * @@ -3892,221 +3979,7 @@ elm_entry_utf8_to_markup(const char *s) } /** - * Get the input method context in the entry widget - * - * @param obj The entry object - * @return The input method context - * - * @ingroup Entry - */ -EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd || !wd->ent) return NULL; - - return edje_object_part_text_imf_context_get(wd->ent, "elm.text"); -} - -/** - * Set whether entry should enable the return key on soft keyboard automatically - * - * @param obj The entry object - * @param on If true, entry enables the return key on soft keyboard automatically. - * - * @ingroup Entry - */ -EAPI void -elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - - wd->autoreturnkey = on; - _check_enable_returnkey(obj); -} - -/** - * Set whether entry should support auto capitalization - * - * @param obj The entry object - * @param on If true, entry suports auto capitalization. - * - * @ingroup Entry - */ -EAPI void -elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - - if (wd->password) - wd->autocapital = EINA_FALSE; - else - wd->autocapital = autocap; - - if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL || - wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL) - wd->autocapital = EINA_FALSE; - - edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital); -} - -/** - * Set whether entry should support auto period - * - * @param obj The entry object - * @param on If true, entry suports auto period. - * - * @ingroup Entry - */ -EAPI void -elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - - if (wd->password) - wd->autoperiod = EINA_FALSE; - else - wd->autoperiod = autoperiod; - - if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL || - wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL) - wd->autoperiod = EINA_FALSE; - - edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod); -} - -/** - * Set the font size on the entry object - * - * @param obj The entry object - * @param size font size - * - * @ingroup Entry - */ -EAPI void -elm_entry_fontsize_set(Evas_Object *obj, int fontsize) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - Eina_Strbuf *fontbuf = NULL; - int removeflag = 0; - const char *t; - - if (!wd) return; - t = eina_stringshare_add(elm_entry_entry_get(obj)); - fontbuf = eina_strbuf_new(); - eina_strbuf_append_printf(fontbuf, "%d", fontsize); - - if (fontsize == 0) removeflag = 1; // remove fontsize tag - - if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0) - { - elm_entry_entry_set(obj, t); - wd->changed = 1; - _sizing_eval(obj); - } - eina_strbuf_free(fontbuf); - eina_stringshare_del(t); -} - -/** - * Set the text align on the entry object - * - * @param obj The entry object - * @param align align mode - * - * @ingroup Entry - */ -EAPI void -elm_entry_text_align_set(Evas_Object *obj, const char *alignmode) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - int len; - const char *t; - - if (!wd) return; - t = eina_stringshare_add(elm_entry_entry_get(obj)); - len = strlen(t); - if (len <= 0) return; - - if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0) - elm_entry_entry_set(obj, t); - - wd->changed = 1; - _sizing_eval(obj); - eina_stringshare_del(t); -} - -/** - * Set the text color on the entry object - * - * @param obj The entry object - * @param r Red property background color of The entry object - * @param g Green property background color of The entry object - * @param b Blue property background color of The entry object - * @param a Alpha property background alpha of The entry object - * - * @ingroup Entry - */ -EAPI void -elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - Eina_Strbuf *colorbuf = NULL; - const char *t; - int len; - - if (!wd) return; - t = eina_stringshare_add(elm_entry_entry_get(obj)); - len = strlen(t); - if (len <= 0) return; - colorbuf = eina_strbuf_new(); - eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a); - - if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0) - { - elm_entry_entry_set(obj, t); - wd->changed = 1; - _sizing_eval(obj); - } - eina_strbuf_free(colorbuf); - eina_stringshare_del(t); -} - -/** - * Set background color of the entry - * - * @param obj The entry object - * @param r Red property background color of The entry object - * @param g Green property background color of The entry object - * @param b Blue property background color of The entry object - * @param a Alpha property background alpha of The entry object - * @ingroup Entry - */ -EAPI void -elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - evas_object_color_set(wd->bg, r, g, b, a); - - if (wd->bgcolor == EINA_FALSE) - { - wd->bgcolor = 1; - edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg); - } -} - -/** - * Filter inserted text based on user defined character and byte limits + * Filter inserted text based on user defined character and byte limits * * Add this filter to an entry to limit the characters that it will accept * based the the contents of the provided Elm_Entry_Filter_Limit_Size. @@ -4427,6 +4300,26 @@ elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll) elm_smart_scroller_child_set(wd->scroller, wd->ent); evas_object_show(wd->scroller); elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj); + if (wd->single_line) + { + elm_smart_scroller_policy_set(wd->scroller, + ELM_SMART_SCROLLER_POLICY_OFF, + ELM_SMART_SCROLLER_POLICY_OFF); + elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); + } + else + { + const Elm_Scroller_Policy map[3] = + { + ELM_SMART_SCROLLER_POLICY_AUTO, + ELM_SMART_SCROLLER_POLICY_ON, + ELM_SMART_SCROLLER_POLICY_OFF + }; + elm_smart_scroller_policy_set(wd->scroller, + map[wd->policy_h], + map[wd->policy_v]); + elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_FALSE, EINA_FALSE); + } } else { @@ -4736,46 +4629,215 @@ elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_b elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce); } +EINA_DEPRECATED EAPI void +elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap) +{ + if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR); +} + /** - * This sets the attribute to show the input panel automatically. + * Set background color of the entry * * @param obj The entry object - * @param enabled If true, the input panel is appeared when entry is clicked or has a focus - * + * @param r Red property background color of The entry object + * @param g Green property background color of The entry object + * @param b Blue property background color of The entry object + * @param a Alpha property background alpha of The entry object * @ingroup Entry */ EAPI void -elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled) +elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; + evas_object_color_set(wd->bg, r, g, b, a); - wd->input_panel_enable = enabled; - edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled); + if (wd->bgcolor == EINA_FALSE) + { + wd->bgcolor = 1; + edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg); + } } /** - * Set the input panel layout of the entry + * Set whether entry should support auto capitalization * * @param obj The entry object - * @param layout the layout to set + * @param on If true, entry suports auto capitalization. * * @ingroup Entry */ EAPI void -elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout) +elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj); - if (!ic) return; - - wd->input_panel_layout = layout; + if (wd->password) + wd->autocapital = EINA_FALSE; + else + wd->autocapital = autocap; - ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout); + if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL || + wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL) + wd->autocapital = EINA_FALSE; + + edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital); +} + +/** + * Set whether entry should support auto period + * + * @param obj The entry object + * @param on If true, entry suports auto period. + * + * @ingroup Entry + */ +EAPI void +elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + if (wd->password) + wd->autoperiod = EINA_FALSE; + else + wd->autoperiod = autoperiod; + + if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL || + wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL) + wd->autoperiod = EINA_FALSE; + + edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod); +} + +/** + * Set whether entry should enable the return key on soft keyboard automatically + * + * @param obj The entry object + * @param on If true, entry enables the return key on soft keyboard automatically. + * + * @ingroup Entry + */ +EAPI void +elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + wd->autoreturnkey = on; + _check_enable_returnkey(obj); +} + +/** + * This sets the attribute to show the input panel automatically. + * + * @param obj The entry object + * @param enabled If true, the input panel is appeared when entry is clicked or has a focus + * + * @ingroup Entry + */ +EAPI void +elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + wd->input_panel_enable = enabled; + edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled); +} + +/** + * Set the input panel layout of the entry + * + * @param obj The entry object + * @param layout the layout to set + * + * @ingroup Entry + */ +EAPI void +elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj); + if (!ic) return; + + wd->input_panel_layout = layout; + + ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout); +} + +/** + * Get the input method context in the entry widget + * + * @param obj The entry object + * @return The input method context + * + * @ingroup Entry + */ +EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd || !wd->ent) return NULL; + + return edje_object_part_text_imf_context_get(wd->ent, "elm.text"); +} + +EAPI void +elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + if (match_list) + { + Evas_Coord max_w = 9999, max_h = 9999; + const char* key_data = NULL; + + wd->matchlist_threshold = 1; + wd->hover = elm_hover_add(elm_widget_parent_get(obj)); + elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj)); + elm_hover_target_set(wd->hover, obj); + elm_object_style_set(wd->hover, "matchlist"); + + wd->layout = elm_layout_add(wd->hover); + elm_layout_theme_set(wd->layout, "entry", "matchlist", "default"); + wd->list = elm_list_add(wd->layout); + evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_list_mode_set(wd->list, ELM_LIST_EXPAND); + elm_object_style_set(wd->list, "matchlist"); + + key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width"); + if (key_data) max_w = atoi(key_data); + key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height"); + if (key_data) max_h = atoi(key_data); + + elm_list_go(wd->list); + evas_object_size_hint_max_set(wd->list, max_w, max_h); + evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj); + elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list); + elm_hover_content_set(wd->hover, "bottom", wd->layout); + + wd->match_list = match_list; + } + else + { + if (wd->hover) + evas_object_del(wd->hover); + + wd->match_list = NULL; + } + + wd->matchlist_case_sensitive = case_sensitive; } /** @@ -4797,8 +4859,134 @@ elm_entry_magnifier_type_set(Evas_Object *obj, int type) _magnifier_create(obj); } -EINA_DEPRECATED EAPI void -elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap) +/** + * Set wrap width of the entry + * + * @param obj The entry object + * @param w The wrap width in pixels at a minimum where words need to wrap + * @ingroup Entry + */ +EAPI void +elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w) { - if (wrap) elm_entry_line_wrap_set(obj, ELM_WRAP_CHAR); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->wrap_w == w) return; + wd->wrap_w = w; + _sizing_eval(obj); +} + +/** + * get wrap width of the entry + * + * @param obj The entry object + * @return The wrap width in pixels at a minimum where words need to wrap + * @ingroup Entry + */ +EAPI Evas_Coord +elm_entry_wrap_width_get(const Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + return wd->wrap_w; +} + +/** + * Set the font size on the entry object + * + * @param obj The entry object + * @param size font size + * + * @ingroup Entry + */ +EAPI void +elm_entry_fontsize_set(Evas_Object *obj, int fontsize) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + Eina_Strbuf *fontbuf = NULL; + int removeflag = 0; + const char *t; + + if (!wd) return; + t = eina_stringshare_add(elm_entry_entry_get(obj)); + fontbuf = eina_strbuf_new(); + eina_strbuf_append_printf(fontbuf, "%d", fontsize); + + if (fontsize == 0) removeflag = 1; // remove fontsize tag + + if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0) + { + elm_entry_entry_set(obj, t); + wd->changed = 1; + _sizing_eval(obj); + } + eina_strbuf_free(fontbuf); + eina_stringshare_del(t); +} + +/** + * Set the text color on the entry object + * + * @param obj The entry object + * @param r Red property background color of The entry object + * @param g Green property background color of The entry object + * @param b Blue property background color of The entry object + * @param a Alpha property background alpha of The entry object + * + * @ingroup Entry + */ +EAPI void +elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + Eina_Strbuf *colorbuf = NULL; + const char *t; + int len; + + if (!wd) return; + t = eina_stringshare_add(elm_entry_entry_get(obj)); + len = strlen(t); + if (len <= 0) return; + colorbuf = eina_strbuf_new(); + eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a); + + if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0) + { + elm_entry_entry_set(obj, t); + wd->changed = 1; + _sizing_eval(obj); + } + eina_strbuf_free(colorbuf); + eina_stringshare_del(t); +} + +/** + * Set the text align on the entry object + * + * @param obj The entry object + * @param align align mode + * + * @ingroup Entry + */ +EAPI void +elm_entry_text_align_set(Evas_Object *obj, const char *alignmode) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + int len; + const char *t; + + if (!wd) return; + t = eina_stringshare_add(elm_entry_entry_get(obj)); + len = strlen(t); + if (len <= 0) return; + + if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0) + elm_entry_entry_set(obj, t); + + wd->changed = 1; + _sizing_eval(obj); + eina_stringshare_del(t); }