From 0f94637363457f24e6d52f1ffb48ee0467b89d74 Mon Sep 17 00:00:00 2001 From: tasn Date: Sun, 27 Feb 2011 10:25:45 +0000 Subject: [PATCH] Elementary entry: Added elm_entry_cursor_pos_set/get (for scrolled as well). Added elm_scrolled_entry_cursor_pos_set/get and elm_entry_cursor_pos_set/get Patch by Jihoon Kim. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@57366 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 4 ++++ src/lib/elc_scrolled_entry.c | 34 ++++++++++++++++++++++++++++++++++ src/lib/elm_entry.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 04d6e10..dff0fd8 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -1224,6 +1224,8 @@ extern "C" { EAPI Eina_Bool elm_entry_cursor_is_visible_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI const char *elm_entry_cursor_content_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) EINA_ARG_NONNULL(1); + EAPI void elm_entry_cursor_pos_set(const Evas_Object *obj, int pos) EINA_ARG_NONNULL(1); + EAPI int elm_entry_cursor_pos_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_entry_selection_cut(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_entry_selection_copy(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_entry_selection_paste(Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -2242,6 +2244,8 @@ extern "C" { EAPI Eina_Bool elm_scrolled_entry_cursor_is_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_scrolled_entry_cursor_is_visible_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI const char *elm_scrolled_entry_cursor_content_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI void elm_scrolled_entry_cursor_pos_set(const Evas_Object *obj, int pos) EINA_ARG_NONNULL(1); + EAPI int elm_scrolled_entry_cursor_pos_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_scrolled_entry_selection_cut(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_scrolled_entry_selection_copy(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_scrolled_entry_selection_paste(Evas_Object *obj) EINA_ARG_NONNULL(1); diff --git a/src/lib/elc_scrolled_entry.c b/src/lib/elc_scrolled_entry.c index 09151fe..983eb23 100644 --- a/src/lib/elc_scrolled_entry.c +++ b/src/lib/elc_scrolled_entry.c @@ -1151,6 +1151,40 @@ elm_scrolled_entry_cursor_content_get(const Evas_Object *obj) } /** + * Sets the cursor position in the scrolled entry to the given value + * + * @param obj The scrolled entry object + * @param pos the position of the cursor + * + * @ingroup Scrolled_Entry + */ +EAPI void +elm_scrolled_entry_cursor_pos_set(const Evas_Object *obj, int pos) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + elm_entry_cursor_pos_set(wd->entry, pos); +} + +/** + * Retrieves the current position of the cursor in the scrolled entry + * + * @param obj The entry object + * @return the cursor position + * + * @ingroup Scrolled_Entry + */ +EAPI int +elm_scrolled_entry_cursor_pos_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return 0; + return elm_entry_cursor_pos_get(wd->entry); +} + +/** * This executes a "cut" action on the selected text in the scrolled entry. * * @param obj The scrolled entry object diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index a7cdb14..d56483f 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -2212,6 +2212,40 @@ elm_entry_cursor_content_get(const Evas_Object *obj) } /** + * Sets the cursor position in the entry to the given value + * + * @param obj The entry object + * @param pos The position of the cursor + * + * @ingroup Entry + */ +EAPI void +elm_entry_cursor_pos_set(const Evas_Object *obj, int pos) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, pos); +} + +/** + * Retrieves the current position of the cursor in the entry + * + * @param obj The entry object + * @return The cursor position + * + * @ingroup Entry + */ +EAPI int +elm_entry_cursor_pos_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return 0; + return edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN); +} + +/** * This executes a "cut" action on the selected text in the entry. * * @param obj The entry object -- 2.7.4