[goffice] add go_style_set_cairo_line
- From: Jean Bréfort <jbrefort src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] add go_style_set_cairo_line
- Date: Fri, 25 Sep 2009 17:15:46 +0000 (UTC)
commit 6a1b30e3b30fd55a0ea48b409f2979b8a941027c
Author: Jean Brefort <jean brefort normalesup org>
Date: Fri Sep 25 19:15:25 2009 +0200
add go_style_set_cairo_line
ChangeLog | 8 ++++
docs/reference/goffice-0.8-sections.txt | 3 ++
goffice/utils/go-style.c | 55 +++++++++++++++++++++++++++++++
goffice/utils/go-style.h | 1 +
goffice/utils/go-styled-object.c | 49 +---------------------------
5 files changed, 68 insertions(+), 48 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fd64fe3..251f526 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-25 Jean Brefort <jean brefort normalesup org>
+
+ * docs/reference/goffice-0.8-sections.txt: added a few more entries.
+ * goffice/utils/go-style.c (go_style_set_cairo_line): new function.
+ * goffice/utils/go-style.h: ditto.
+ * goffice/utils/go-styled-object.c
+ (go_styled_object_set_cairo_line): use go_style_set_cairo_line.
+
2009-09-24 Jean Brefort <jean brefort normalesup org>
* goffice/canvas/goc-circle.c (goc_circle_init_style): crrectly set
diff --git a/docs/reference/goffice-0.8-sections.txt b/docs/reference/goffice-0.8-sections.txt
index 9e47d92..55ac648 100644
--- a/docs/reference/goffice-0.8-sections.txt
+++ b/docs/reference/goffice-0.8-sections.txt
@@ -1904,6 +1904,7 @@ go_style_force_auto
go_style_get_editor
go_style_populate_editor
go_style_create_cairo_pattern
+go_style_set_cairo_line
go_style_get_marker
<SUBSECTION Standard>
GO_TYPE_STYLE
@@ -1924,6 +1925,8 @@ go_styled_object_set_style
go_styled_object_apply_theme
go_styled_object_style_changed
go_styled_object_get_document
+go_styled_object_set_cairo_fill
+go_styled_object_set_cairo_line
<SUBSECTION Standard>
GO_TYPE_STYLED_OBJECT
GO_STYLED_OBJECT
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index 0b1bfe0..9ba7d91 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -2128,3 +2128,58 @@ go_style_create_cairo_pattern (GOStyle const *style, cairo_t *cr)
return NULL;
}
+
+gboolean
+go_style_set_cairo_line (GOStyle const *style, cairo_t *cr)
+{
+ double width;
+ GOLineDashSequence *line_dash;
+
+ g_return_val_if_fail (GO_IS_STYLE (style) && cr != NULL, FALSE);
+ if (style->line.dash_type == GO_LINE_NONE)
+ return FALSE;
+ width = (style->line.width)? style->line.width: 1.;
+ cairo_set_line_width (cr, width);
+ cairo_set_line_cap (cr, style->line.cap);
+ cairo_set_line_join (cr, style->line.join);
+ cairo_set_miter_limit (cr, style->line.miter_limit);
+ line_dash = go_line_dash_get_sequence (style->line.dash_type, width);
+ if (style->line.cap == CAIRO_LINE_CAP_BUTT && style->line.dash_type != GO_LINE_SOLID) {
+ unsigned i;
+ for (i = 0; i < line_dash->n_dash; i++)
+ if (line_dash->dash[i] == 0.)
+ line_dash->dash[i] = width;
+ }
+ if (line_dash != NULL)
+ cairo_set_dash (cr,
+ line_dash->dash,
+ line_dash->n_dash,
+ line_dash->offset);
+ else
+ cairo_set_dash (cr, NULL, 0, 0);
+ switch (style->line.pattern) {
+ case GO_PATTERN_SOLID:
+ cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.color));
+ break;
+ case GO_PATTERN_FOREGROUND_SOLID:
+ cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.fore));
+ break;
+ default: {
+ GOPattern pat;
+ double scalex = 1., scaley = 1.;
+ cairo_pattern_t *cp;
+ cairo_matrix_t mat;
+ pat.fore = style->line.fore;
+ pat.back = style->line.color;
+ pat.pattern = style->line.pattern;
+ cp = go_pattern_create_cairo_pattern (&pat, cr);
+ cairo_user_to_device_distance (cr, &scalex, &scaley);
+ cairo_matrix_init_scale (&mat, scalex, scaley);
+ cairo_pattern_set_matrix (cp, &mat);
+ cairo_set_source (cr, cp);
+ cairo_pattern_destroy (cp);
+ break;
+ }
+ }
+ return TRUE;
+}
diff --git a/goffice/utils/go-style.h b/goffice/utils/go-style.h
index 5a8b151..c141c9e 100644
--- a/goffice/utils/go-style.h
+++ b/goffice/utils/go-style.h
@@ -151,6 +151,7 @@ gpointer go_style_get_editor (GOStyle *style,
GObject *object_with_style);
cairo_pattern_t *go_style_create_cairo_pattern (GOStyle const *style, cairo_t *cr);
+gboolean go_style_set_cairo_line (GOStyle const *style, cairo_t *cr);
G_END_DECLS
diff --git a/goffice/utils/go-styled-object.c b/goffice/utils/go-styled-object.c
index 1658b48..a0977c6 100644
--- a/goffice/utils/go-styled-object.c
+++ b/goffice/utils/go-styled-object.c
@@ -144,57 +144,10 @@ gboolean
go_styled_object_set_cairo_line (GOStyledObject const *so, cairo_t *cr)
{
GOStyle const *style;
- double width;
- GOLineDashSequence *line_dash;
g_return_val_if_fail (GO_IS_STYLED_OBJECT (so), FALSE);
style = go_styled_object_get_style (GO_STYLED_OBJECT (so));
- if (style->line.dash_type == GO_LINE_NONE)
- return FALSE;
- width = (style->line.width)? style->line.width: 1.;
- cairo_set_line_width (cr, width);
- cairo_set_line_cap (cr, style->line.cap);
- cairo_set_line_join (cr, style->line.join);
- cairo_set_miter_limit (cr, style->line.miter_limit);
- line_dash = go_line_dash_get_sequence (style->line.dash_type, width);
- if (style->line.cap == CAIRO_LINE_CAP_BUTT && style->line.dash_type != GO_LINE_SOLID) {
- unsigned i;
- for (i = 0; i < line_dash->n_dash; i++)
- if (line_dash->dash[i] == 0.)
- line_dash->dash[i] = width;
- }
- if (line_dash != NULL)
- cairo_set_dash (cr,
- line_dash->dash,
- line_dash->n_dash,
- line_dash->offset);
- else
- cairo_set_dash (cr, NULL, 0, 0);
- switch (style->line.pattern) {
- case GO_PATTERN_SOLID:
- cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.color));
- break;
- case GO_PATTERN_FOREGROUND_SOLID:
- cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.fore));
- break;
- default: {
- GOPattern pat;
- double scalex = 1., scaley = 1.;
- cairo_pattern_t *cp;
- cairo_matrix_t mat;
- pat.fore = style->line.fore;
- pat.back = style->line.color;
- pat.pattern = style->line.pattern;
- cp = go_pattern_create_cairo_pattern (&pat, cr);
- cairo_user_to_device_distance (cr, &scalex, &scaley);
- cairo_matrix_init_scale (&mat, scalex, scaley);
- cairo_pattern_set_matrix (cp, &mat);
- cairo_set_source (cr, cp);
- cairo_pattern_destroy (cp);
- break;
- }
- }
- return TRUE;
+ return go_style_set_cairo_line (style, cr);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]