Evas textblock: Replaced style_user_set/get with push/pop/peek.

SVN revision: 68952
This commit is contained in:
Tom Hacohen 2012-03-07 14:02:35 +00:00
parent 44aa4c7e48
commit 45993d284f
4 changed files with 38 additions and 8 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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)

View File

@ -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);