From: tasn Date: Mon, 14 Nov 2011 13:56:06 +0000 (+0000) Subject: Elm entry: Expose the internal textblock object. X-Git-Tag: REL_F_I9500_20111128_2~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3bf199000e70d981b430b20941fdfe65586cd9bd;p=framework%2Fuifw%2Felementary.git Elm entry: Expose the internal textblock object. This commit introduces two new API: elm_entry_textblock_get and elm_entry_calc_force. These two APIs can be used to manipulate the textblock object inside the entry in a safe manner. This exposes an interface that wasn't available before letting do new and cool things with entries. git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@65169 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 90c12bf..7a4d05d 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -11237,6 +11237,39 @@ extern "C" { */ EAPI const char *elm_entry_selection_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** + * Returns the actual textblock object of the entry. + * + * This function exposes the internal textblock object that actually + * contains and draws the text. This should be used for low-level + * manipulations that are otherwise not possible. + * + * Changing the textblock directly from here will not notify edje/elm to + * recalculate the textblock size automatically, so any modifications + * done to the textblock returned by this function should be followed by + * a call to elm_entry_calc_force(). + * + * The return value is marked as const as an additional warning. + * One should not use the returned object with any of the generic evas + * functions (geometry_get/resize/move and etc), but only with the textblock + * functions; The former will either not work at all, or break the correct + * functionality. + * + * @param obj The entry object + * @return The textblock object. + */ + EAPI const Evas_Object *elm_entry_textblock_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + /** + * Forces calculation of the entry size and text layouting. + * + * This should be used after modifying the textblock object directly. See + * elm_entry_textblock_get() for more information. + * + * @param obj The entry object + * + * @see elm_entry_textblock_get() + */ + EAPI void elm_entry_calc_force(const Evas_Object *obj) EINA_ARG_NONNULL(1); + /** * Inserts the given text into the entry at the current cursor position. * * This inserts text at the cursor position as if it was typed diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index 719fabb..d4de4a3 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -3196,7 +3196,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, @@ -3210,7 +3210,7 @@ if (0) { evas_textblock_cursor_free(cur); return !ret; -} + } char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj)); if (!str) return EINA_TRUE; @@ -3221,6 +3221,27 @@ if (0) { return ret; } +EAPI const Evas_Object * +elm_entry_textblock_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + return edje_object_part_object_get(wd->ent, "elm.text"); +} + +EAPI void +elm_entry_calc_force(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + edje_object_calc_force(wd->ent); +} + + EAPI const char * elm_entry_selection_get(const Evas_Object *obj) {