From 45993d284ff737b8d64a5e87d068273d26beaf6a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 7 Mar 2012 14:02:35 +0000 Subject: [PATCH] Evas textblock: Replaced style_user_set/get with push/pop/peek. SVN revision: 68952 --- legacy/evas/ChangeLog | 8 ++++++++ legacy/evas/src/lib/Evas.h | 20 +++++++++++++++---- .../src/lib/canvas/evas_object_textblock.c | 16 ++++++++++++--- legacy/evas/src/tests/evas_test_textblock.c | 2 +- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog index e0396b9b48..a41306407e 100644 --- a/legacy/evas/ChangeLog +++ b/legacy/evas/ChangeLog @@ -675,3 +675,11 @@ 2012-02-23 Cedric Bail * Remove Software SDL engine. + +2012-01-23 Tom Hacohen (TAsn) + + * Textblock: Replaced evas_object_textblock_style_user_set/get + with evas_object_textblock_style_user_push/peek/pop. + This is used to override the default style set for an evas object. + For example, this can be used to nicely change the font and size + in a text editor. diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h index 0f760327ab..663a469f80 100644 --- a/legacy/evas/src/lib/Evas.h +++ b/legacy/evas/src/lib/Evas.h @@ -8392,7 +8392,9 @@ EAPI void evas_object_textblock_style_set(Evas_Object *o EAPI const Evas_Textblock_Style *evas_object_textblock_style_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * Set the objects user style to ts. + * Push ts to the top of the user style stack. + * + * FIXME: API is solid but currently only supports 1 style in the stack. * * The user style overrides the corresponding elements of the regular style. * This is the proper way to do theme overrides in code. @@ -8402,16 +8404,26 @@ EAPI const Evas_Textblock_Style *evas_object_textblock_style_get(const Evas_Obj * @see evas_object_textblock_style_set * @since 1.2.0 */ -EAPI void evas_object_textblock_style_user_set(Evas_Object *obj, Evas_Textblock_Style *ts) EINA_ARG_NONNULL(1); +EAPI void evas_object_textblock_style_user_push(Evas_Object *obj, Evas_Textblock_Style *ts) EINA_ARG_NONNULL(1); /** - * Return the user style of an object. + * Del the from the top of the user style stack. + * + * @param obj the object to get the style from. + * @see evas_object_textblock_style_get + * @since 1.2.0 + */ +EAPI void evas_object_textblock_style_user_pop(Evas_Object *obj) EINA_ARG_NONNULL(1); + +/** + * Get (don't remove) the style at the top of the user style stack. + * * @param obj the object to get the style from. * @return the style of the object. * @see evas_object_textblock_style_get * @since 1.2.0 */ -EAPI const Evas_Textblock_Style *evas_object_textblock_style_user_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); +EAPI const Evas_Textblock_Style *evas_object_textblock_style_user_peek(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** * @brief Set the "replacement character" to use for the given textblock object. diff --git a/legacy/evas/src/lib/canvas/evas_object_textblock.c b/legacy/evas/src/lib/canvas/evas_object_textblock.c index 892804be46..a5b60f2359 100644 --- a/legacy/evas/src/lib/canvas/evas_object_textblock.c +++ b/legacy/evas/src/lib/canvas/evas_object_textblock.c @@ -4669,19 +4669,26 @@ evas_object_textblock_style_get(const Evas_Object *obj) } EAPI void -evas_object_textblock_style_user_set(Evas_Object *obj, Evas_Textblock_Style *ts) +evas_object_textblock_style_user_push(Evas_Object *obj, Evas_Textblock_Style *ts) { TB_HEAD(); _textblock_style_generic_set(obj, ts, &(o->style_user)); } EAPI const Evas_Textblock_Style * -evas_object_textblock_style_user_get(const Evas_Object *obj) +evas_object_textblock_style_user_peek(const Evas_Object *obj) { TB_HEAD_RETURN(NULL); return o->style_user; } +EAPI void +evas_object_textblock_style_user_pop(Evas_Object *obj) +{ + TB_HEAD(); + _textblock_style_generic_set(obj, NULL, &(o->style_user)); +} + EAPI void evas_object_textblock_replace_char_set(Evas_Object *obj, const char *ch) { @@ -9311,7 +9318,10 @@ evas_object_textblock_free(Evas_Object *obj) evas_object_textblock_clear(obj); evas_object_textblock_style_set(obj, NULL); - evas_object_textblock_style_user_set(obj, NULL); + while (evas_object_textblock_style_user_peek(obj)) + { + evas_object_textblock_style_user_pop(obj); + } o = (Evas_Object_Textblock *)(obj->object_data); free(o->cursor); while (o->cursors) diff --git a/legacy/evas/src/tests/evas_test_textblock.c b/legacy/evas/src/tests/evas_test_textblock.c index 88c4ac8f23..983a2fca6c 100644 --- a/legacy/evas/src/tests/evas_test_textblock.c +++ b/legacy/evas/src/tests/evas_test_textblock.c @@ -2113,7 +2113,7 @@ START_TEST(evas_textblock_size) fail_if(!newst); evas_textblock_style_set(newst, "DEFAULT='left_margin=4 right_margin=4'"); - evas_object_textblock_style_user_set(tb, newst); + evas_object_textblock_style_user_push(tb, newst); evas_object_textblock_size_formatted_get(tb, &w, &h); evas_object_textblock_size_native_get(tb, &nw, &nh);