From: tasn Date: Sun, 27 Feb 2011 10:25:22 +0000 (+0000) Subject: Edje entry: Added edje_object_part_text_cursor_pos_get/set. X-Git-Tag: submit/trunk/20120815.180907~712 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=03b75e64c3beba40863d333ecc76ed5ee1a035aa;p=profile%2Fivi%2Fedje.git Edje entry: Added edje_object_part_text_cursor_pos_get/set. This adds the ability to control the text position of an edje_entry. Patch by Jihoon Kim. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@57365 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/ChangeLog b/ChangeLog index abeaabd..b41b55e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,3 +37,7 @@ * fix signal comming from box/table item to include their index or name correctly. + +2011-02-25 Jihoon Kim + + * Add edje_object_part_text_cursor_pos_{set,get} API diff --git a/src/lib/Edje.h b/src/lib/Edje.h index afabab0..74f5635 100644 --- a/src/lib/Edje.h +++ b/src/lib/Edje.h @@ -608,6 +608,8 @@ typedef Evas_Object *(*Edje_Item_Provider_Cb) (void *data, Evas_Object *obj, c EAPI Eina_Bool edje_object_part_text_cursor_is_format_get (const Evas_Object *obj, const char *part, Edje_Cursor cur); EAPI Eina_Bool edje_object_part_text_cursor_is_visible_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur); EAPI const char *edje_object_part_text_cursor_content_get (const Evas_Object *obj, const char *part, Edje_Cursor cur); + EAPI void edje_object_part_text_cursor_pos_set (Evas_Object *obj, const char *part, Edje_Cursor cur, int pos); + EAPI int edje_object_part_text_cursor_pos_get (const Evas_Object *obj, const char *part, Edje_Cursor cur); EAPI void edje_object_text_insert_filter_callback_add (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); EAPI void *edje_object_text_insert_filter_callback_del (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func); diff --git a/src/lib/edje_entry.c b/src/lib/edje_entry.c index c75a738..977e1f9 100644 --- a/src/lib/edje_entry.c +++ b/src/lib/edje_entry.c @@ -2603,6 +2603,37 @@ _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur) return s; } +void +_edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return; + evas_textblock_cursor_pos_set(c, pos); + _curs_update_from_curs(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->entry_data); + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + { + ecore_imf_context_reset(en->imf_context); + ecore_imf_context_cursor_position_set(en->imf_context, + evas_textblock_cursor_pos_get(en->cursor)); + } +#endif + + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +int +_edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return 0; + return evas_textblock_cursor_pos_get(c); +} + #ifdef HAVE_ECORE_IMF static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos) diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index 184958d..16e20e9 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -1776,6 +1776,8 @@ Eina_Bool _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, int Eina_Bool _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur); Eina_Bool _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur); const char *_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos); +int _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur); void _edje_external_init(); void _edje_external_shutdown(); diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index 3c692db..5e5b716 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -2214,6 +2214,57 @@ edje_object_part_text_cursor_content_get(const Evas_Object *obj, const char *par } /** + * @brief Sets the cursor position to the given value + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to move + * @param pos the position of the cursor + * @since 1.1.0 + */ +EAPI void +edje_object_part_text_cursor_pos_set(Evas_Object *obj, const char *part, Edje_Cursor cur, int pos) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_pos_set(rp, cur, pos); + } +} + +/** + * @brief Retrieves the current position of the cursor + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to get the position + * @return The cursor position + * @since 1.1.0 + */ +EAPI int +edje_object_part_text_cursor_pos_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return 0; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return 0; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_pos_get(rp, cur); + } + return 0; +} + +/** * Add a filter function for newly inserted text. * * Whenever text is inserted (not the same as set) into the given @p part,