From 46ad4606c682f4fc288962f177a26cfd1aec3458 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 15 Feb 2012 08:42:46 +0000 Subject: [PATCH] elm_entry: add elm_entry_input_panel_language_set/get add elm_entry_input_panel_imdata_set/get add elm_entry_input_panel_return_key_type_set/get add elm_entry_input_panel_return_key_disabled_set/get SVN revision: 67967 --- legacy/elementary/src/lib/elm_entry.c | 101 ++++++++++++++++++++++++++ legacy/elementary/src/lib/elm_entry.h | 99 +++++++++++++++++++++++++ 2 files changed, 200 insertions(+) diff --git a/legacy/elementary/src/lib/elm_entry.c b/legacy/elementary/src/lib/elm_entry.c index a53a4c31a4..8aca46adb2 100644 --- a/legacy/elementary/src/lib/elm_entry.c +++ b/legacy/elementary/src/lib/elm_entry.c @@ -49,6 +49,10 @@ struct _Widget_Data Elm_Wrap_Type linewrap; Elm_Input_Panel_Layout input_panel_layout; Elm_Autocapital_Type autocapital_type; + Elm_Input_Panel_Lang input_panel_lang; + Elm_Input_Panel_Return_Key_Type input_panel_return_key_type; + void *input_panel_imdata; + int input_panel_imdata_len; Eina_Bool changed : 1; Eina_Bool single_line : 1; Eina_Bool password : 1; @@ -70,6 +74,7 @@ struct _Widget_Data Eina_Bool v_bounce : 1; Eina_Bool input_panel_enable : 1; Eina_Bool prediction_allow : 1; + Eina_Bool input_panel_return_key_disabled : 1; }; struct _Elm_Entry_Context_Menu_Item @@ -502,6 +507,7 @@ _del_hook(Evas_Object *obj) _filter_free(tf); } if (wd->delay_write) ecore_timer_del(wd->delay_write); + if (wd->input_panel_imdata) free(wd->input_panel_imdata); free(wd); evas_event_thaw(evas_object_evas_get(obj)); @@ -537,6 +543,9 @@ _theme_hook(Evas_Object *obj) edje_object_part_text_autocapital_type_set(wd->ent, "elm.text", wd->autocapital_type); edje_object_part_text_prediction_allow_set(wd->ent, "elm.text", wd->prediction_allow); edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable); + edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len); + edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", wd->input_panel_return_key_type); + edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", wd->input_panel_return_key_disabled); if (wd->cursor_pos != 0) elm_entry_cursor_pos_set(obj, wd->cursor_pos); @@ -2307,6 +2316,7 @@ elm_entry_add(Evas_Object *parent) wd->autosave = EINA_TRUE; wd->textonly = EINA_FALSE; wd->scroll = EINA_FALSE; + wd->input_panel_imdata = NULL; wd->ent = edje_object_add(e); edje_object_item_provider_set(wd->ent, _get_item, obj); @@ -3630,4 +3640,95 @@ elm_entry_input_panel_hide(Evas_Object *obj) edje_object_part_text_input_panel_hide(wd->ent, "elm.text"); } +EAPI void +elm_entry_input_panel_language_set(Evas_Object *obj, Elm_Input_Panel_Lang lang) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + wd->input_panel_lang = lang; + edje_object_part_text_input_panel_language_set(wd->ent, "elm.text", lang); +} + +EAPI Elm_Input_Panel_Lang +elm_entry_input_panel_language_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_LANG_AUTOMATIC; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return ELM_INPUT_PANEL_LANG_AUTOMATIC; + + return wd->input_panel_lang; +} + +EAPI void +elm_entry_input_panel_imdata_set(Evas_Object *obj, const void *data, int len) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + if (wd->input_panel_imdata) + free(wd->input_panel_imdata); + + wd->input_panel_imdata = calloc(1, len); + wd->input_panel_imdata_len = len; + memcpy(wd->input_panel_imdata, data, len); + + edje_object_part_text_input_panel_imdata_set(wd->ent, "elm.text", wd->input_panel_imdata, wd->input_panel_imdata_len); +} + +EAPI void +elm_entry_input_panel_imdata_get(const Evas_Object *obj, void *data, int *len) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + edje_object_part_text_input_panel_imdata_get(wd->ent, "elm.text", data, len); +} + +EAPI void +elm_text_input_panel_return_key_type_set(Evas_Object *obj, Elm_Input_Panel_Return_Key_Type return_key_type) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + wd->input_panel_return_key_type = return_key_type; + + edje_object_part_text_input_panel_return_key_type_set(wd->ent, "elm.text", return_key_type); +} + +EAPI Elm_Input_Panel_Return_Key_Type +elm_entry_input_panel_return_key_type_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + + return wd->input_panel_return_key_type; +} + +EAPI void +elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj, Eina_Bool disabled) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + wd->input_panel_return_key_disabled = disabled; + + edje_object_part_text_input_panel_return_key_disabled_set(wd->ent, "elm.text", disabled); +} + +EAPI Eina_Bool +elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + + return wd->input_panel_return_key_disabled; +} diff --git a/legacy/elementary/src/lib/elm_entry.h b/legacy/elementary/src/lib/elm_entry.h index e7c0f38289..ff5f933e3e 100644 --- a/legacy/elementary/src/lib/elm_entry.h +++ b/legacy/elementary/src/lib/elm_entry.h @@ -32,6 +32,12 @@ typedef enum ELM_INPUT_PANEL_LAYOUT_PASSWORD /**< Like normal, but no auto-correct, no auto-capitalization etc. */ } Elm_Input_Panel_Layout; /**< Type of input panel (virtual keyboard) to use - this is a hint and may not provide exactly what is desired. */ +typedef enum +{ + ELM_INPUT_PANEL_LANG_AUTOMATIC, /**< Automatic */ + ELM_INPUT_PANEL_LANG_ALPHABET /**< Alphabet */ +} Elm_Input_Panel_Lang; + typedef enum { ELM_AUTOCAPITAL_TYPE_NONE, /**< No auto-capitalization when typing */ @@ -40,6 +46,18 @@ typedef enum ELM_AUTOCAPITAL_TYPE_ALLCHARACTER, /**< Autocapitalize all letters */ } Elm_Autocapital_Type; /**< Choose method of auto-capitalization */ +typedef enum +{ + ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_GO, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_JOIN, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEND +} Elm_Input_Panel_Return_Key_Type; + /** * @defgroup Entry Entry * @@ -1132,6 +1150,87 @@ EAPI void elm_entry_input_panel_show(Evas_Object *obj); */ EAPI void elm_entry_input_panel_hide(Evas_Object *obj); +/** + * Set the language mode of the input panel. + * + * This API can be used if you want to show the alphabet keyboard mode. + * + * @param obj The entry object + * @param lang language to be set to the input panel. + */ +EAPI void elm_entry_input_panel_language_set(Evas_Object *obj, Elm_Input_Panel_Lang lang); + +/** + * Get the language mode of the input panel. + * + * See @ref elm_entry_input_panel_language_set for more details. + * + * @param obj The entry object + * @return input panel language type + */ +EAPI Elm_Input_Panel_Lang elm_entry_input_panel_language_get(const Evas_Object *obj); + +/** + * Set the input panel-specific data to deliver to the input panel. + * + * This API is used by applications to deliver specific data to the input panel. + * The data format MUST be negotiated by both application and the input panel. + * The size and format of data are defined by the input panel. + * + * @param obj The entry object + * @param data The specific data to be set to the input panel. + * @param len the length of data, in bytes, to send to the input panel + */ +EAPI void elm_entry_input_panel_imdata_set(Evas_Object *obj, const void *data, int len); + +/** + * Get the specific data of the current input panel. + * + * See @ref elm_entry_input_panel_imdata_set for more details. + * + * @param obj The entry object + * @param data The specific data to be got from the input panel + * @param len The length of data + */ +EAPI void elm_entry_input_panel_imdata_get(const Evas_Object *obj, void *data, int *len); + +/** + * Set the "return" key type. This type is used to set string or icon on the "return" key of the input panel. + * + * An input panel displays the string or icon associated with this type + * + * @param obj The entry object + * @param return_key_type The type of "return" key on the input panel + */ +EAPI void elm_text_input_panel_return_key_type_set(Evas_Object *obj, Elm_Input_Panel_Return_Key_Type return_key_type); + +/** + * Get the "return" key type. + * + * @see elm_entry_input_panel_return_key_type_set() for more details + * + * @param obj The entry object + * @return The type of "return" key on the input panel + */ +EAPI Elm_Input_Panel_Return_Key_Type elm_entry_input_panel_return_key_type_get(const Evas_Object *obj); + +/** + * Set the return key on the input panel to be disabled. + * + * @param obj The entry object + * @param disabled The state to put in in: @c EINA_TRUE for + * disabled, @c EINA_FALSE for enabled + */ +EAPI void elm_entry_input_panel_return_key_disabled_set(Evas_Object *obj, Eina_Bool disabled); + +/** + * Get whether the return key on the input panel should be disabled or not. + * + * @param obj The entry object + * @return EINA_TRUE if it should be disabled + */ +EAPI Eina_Bool elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj); + /** * Reset the input method context of the entry if needed. *