From 738508f314ab366498f8466cbb930027ba0dd887 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Tue, 8 Jul 2008 17:23:17 +0000 Subject: [PATCH] Added accessors to AdgLineStyle --- adg/adg-dim-style.c | 2 +- adg/adg-line-style.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++ adg/adg-line-style.h | 29 +++++++-- 3 files changed, 206 insertions(+), 6 deletions(-) diff --git a/adg/adg-dim-style.c b/adg/adg-dim-style.c index e17fb28a..66592b73 100644 --- a/adg/adg-dim-style.c +++ b/adg/adg-dim-style.c @@ -354,7 +354,7 @@ set_property (GObject *object, * adg_dim_style_from_id: * @id: a dimension style identifier * - * Gets a predefined style by an #AdgDimStyleId identifier. + * Gets a predefined style from an #AdgDimStyleId identifier. * * Return value: the requested style or %NULL if not found **/ diff --git a/adg/adg-line-style.c b/adg/adg-line-style.c index f8575790..9df3f8d6 100644 --- a/adg/adg-line-style.c +++ b/adg/adg-line-style.c @@ -199,6 +199,14 @@ set_property (GObject *object, } +/** + * adg_line_style_from_id: + * @id: a line style identifier + * + * Gets a predefined style from an #AdgLineStyleId identifier. + * + * Return value: the requested style or %NULL if not found + **/ AdgStyle * adg_line_style_from_id (AdgLineStyleId id) { @@ -233,6 +241,13 @@ adg_line_style_from_id (AdgLineStyleId id) return builtins[id]; } +/** + * adg_line_style_apply: + * @line_style: an #AdgLineStyle style + * @cr: the cairo context + * + * Applies @line_style to @cr so the next lines will have this style. + **/ void adg_line_style_apply (const AdgLineStyle *line_style, cairo_t *cr) @@ -260,3 +275,169 @@ adg_line_style_apply (const AdgLineStyle *line_style, line_style->priv->dash_offset); } } + +/** + * adg_line_style_get_width: + * @line_style: an #AdgLineStyle object + * + * Gets the line thickness value (in paper units). + * + * Return value: the requested width + **/ +gdouble +adg_line_style_get_width (AdgLineStyle *line_style) +{ + g_return_val_if_fail (ADG_IS_LINE_STYLE (line_style), 0.); + + return line_style->priv->width; +} + +/** + * adg_line_style_set_width: + * @line_style: an #AdgLineStyle object + * @width: the new width + * + * Sets a new line thickness value. + **/ +void +adg_line_style_set_width (AdgLineStyle *line_style, + gdouble width) +{ + g_return_if_fail (ADG_IS_LINE_STYLE (line_style)); + + line_style->priv->width = width; + g_object_notify ((GObject *) line_style, "width"); +} + +/** + * adg_line_style_get_cap: + * @line_style: an #AdgLineStyle object + * + * Gets the line cap mode. + * + * Return value: the requested line cap mode + **/ +cairo_line_cap_t +adg_line_style_get_cap (AdgLineStyle *line_style) +{ + g_return_val_if_fail (ADG_IS_LINE_STYLE (line_style), CAIRO_LINE_CAP_BUTT); + + return line_style->priv->cap; +} + +/** + * adg_line_style_set_cap: + * @line_style: an #AdgLineStyle object + * @cap: the new cap mode + * + * Sets a new line cap mode. + **/ +void +adg_line_style_set_cap (AdgLineStyle *line_style, + cairo_line_cap_t cap) +{ + g_return_if_fail (ADG_IS_LINE_STYLE (line_style)); + + line_style->priv->cap = cap; + g_object_notify ((GObject *) line_style, "cap"); +} + +/** + * adg_line_style_get_join: + * @line_style: an #AdgLineStyle object + * + * Gets the line join mode. + * + * Return value: the requested line join mode + **/ +cairo_line_join_t +adg_line_style_get_join (AdgLineStyle *line_style) +{ + g_return_val_if_fail (ADG_IS_LINE_STYLE (line_style), CAIRO_LINE_JOIN_MITER); + + return line_style->priv->join; +} + +/** + * adg_line_style_set_join: + * @line_style: an #AdgLineStyle object + * @join: the new join mode + * + * Sets a new line join mode. + **/ +void +adg_line_style_set_join (AdgLineStyle *line_style, + cairo_line_join_t join) +{ + g_return_if_fail (ADG_IS_LINE_STYLE (line_style)); + + line_style->priv->join = join; + g_object_notify ((GObject *) line_style, "join"); +} + +/** + * adg_line_style_get_miter_limit: + * @line_style: an #AdgLineStyle object + * + * Gets the line miter limit value. The miter limit is used to determine + * whether the lines should be joined with a bevel instead of a miter. + * + * Return value: the requested miter limit + **/ +gdouble +adg_line_style_get_miter_limit (AdgLineStyle *line_style) +{ + g_return_val_if_fail (ADG_IS_LINE_STYLE (line_style), 0.); + + return line_style->priv->miter_limit; +} + +/** + * adg_line_style_set_miter_limit: + * @line_style: an #AdgLineStyle object + * @miter_limit: the new miter limit + * + * Sets a new miter limit value. + **/ +void +adg_line_style_set_miter_limit (AdgLineStyle *line_style, + gdouble miter_limit) +{ + g_return_if_fail (ADG_IS_LINE_STYLE (line_style)); + + line_style->priv->miter_limit = miter_limit; + g_object_notify ((GObject *) line_style, "miter-limit"); +} + +/** + * adg_line_style_get_antialias: + * @line_style: an #AdgLineStyle object + * + * Gets the antialias mode used. + * + * Return value: the requested antialias mode + **/ +cairo_antialias_t +adg_line_style_get_antialias (AdgLineStyle *line_style) +{ + g_return_val_if_fail (ADG_IS_LINE_STYLE (line_style), CAIRO_ANTIALIAS_DEFAULT); + + return line_style->priv->antialias; +} + +/** + * adg_line_style_set_antialias: + * @line_style: an #AdgLineStyle object + * @antialias: the new antialias mode + * + * Sets a new antialias mode. + **/ +void +adg_line_style_set_antialias (AdgLineStyle *line_style, + cairo_antialias_t antialias) +{ + g_return_if_fail (ADG_IS_LINE_STYLE (line_style)); + + line_style->priv->antialias = antialias; + g_object_notify ((GObject *) line_style, "antialias"); +} diff --git a/adg/adg-line-style.h b/adg/adg-line-style.h index e366f4de..45afecf2 100644 --- a/adg/adg-line-style.h +++ b/adg/adg-line-style.h @@ -53,11 +53,30 @@ struct _AdgLineStyleClass }; -GType adg_line_style_get_type (void) G_GNUC_CONST; -AdgStyle * adg_line_style_new (void); -AdgStyle * adg_line_style_from_id (AdgLineStyleId id); -void adg_line_style_apply (const AdgLineStyle *line_style, - cairo_t *cr); +GType adg_line_style_get_type (void) G_GNUC_CONST; +AdgStyle * adg_line_style_new (void); +AdgStyle * adg_line_style_from_id (AdgLineStyleId id); +void adg_line_style_apply (const AdgLineStyle *line_style, + cairo_t *cr); + +gdouble adg_line_style_get_width (AdgLineStyle *line_style); +void adg_line_style_set_width (AdgLineStyle *line_style, + gdouble width); +cairo_line_cap_t + adg_line_style_get_cap (AdgLineStyle *line_style); +void adg_line_style_set_cap (AdgLineStyle *line_style, + cairo_line_cap_t cap); +cairo_line_join_t + adg_line_style_get_join (AdgLineStyle *line_style); +void adg_line_style_set_join (AdgLineStyle *line_style, + cairo_line_join_t join); +gdouble adg_line_style_get_miter_limit (AdgLineStyle *line_style); +void adg_line_style_set_miter_limit (AdgLineStyle *line_style, + gdouble miter_limit); +cairo_antialias_t + adg_line_style_get_antialias (AdgLineStyle *line_style); +void adg_line_style_set_antialias (AdgLineStyle *line_style, + cairo_antialias_t antialias); G_END_DECLS -- 2.11.4.GIT