summaryrefslogtreecommitdiff
path: root/gtk/gtk_plotters.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2009-07-08 22:04:40 +0000
committerVincent Sanders <vince@netsurf-browser.org>2009-07-08 22:04:40 +0000
commitf9ecd56f62f833f21b3475f0d1b59bc8e053a03e (patch)
tree9874485045ec0fc52fccab99ad545bdefb672203 /gtk/gtk_plotters.c
parent651228e64d688e1a565ac88e60b736995ba84012 (diff)
downloadnetsurf-f9ecd56f62f833f21b3475f0d1b59bc8e053a03e.tar.gz
netsurf-f9ecd56f62f833f21b3475f0d1b59bc8e053a03e.tar.bz2
ploter refactor of rectangle handling
svn path=/trunk/netsurf/; revision=8399
Diffstat (limited to 'gtk/gtk_plotters.c')
-rw-r--r--gtk/gtk_plotters.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c
index 6c7306b11..2a843c5b8 100644
--- a/gtk/gtk_plotters.c
+++ b/gtk/gtk_plotters.c
@@ -49,14 +49,12 @@ GdkDrawable *current_drawable;
GdkGC *current_gc;
cairo_t *current_cr;
-static bool nsgtk_plot_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed);
static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed);
static bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
-static bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
+static bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool nsgtk_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool nsgtk_plot_text(int x, int y, const struct css_style *style,
@@ -80,7 +78,6 @@ const struct plotter_table nsgtk_plotters = {
.rectangle = nsgtk_plot_rectangle,
.line = nsgtk_plot_line,
.polygon = nsgtk_plot_polygon,
- .fill = nsgtk_plot_fill,
.clip = nsgtk_plot_clip,
.text = nsgtk_plot_text,
.disc = nsgtk_plot_disc,
@@ -91,28 +88,47 @@ const struct plotter_table nsgtk_plotters = {
};
-bool nsgtk_plot_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed)
+bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- nsgtk_set_colour(c);
- if (dotted)
- nsgtk_set_dotted();
- else if (dashed)
- nsgtk_set_dashed();
- else
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ nsgtk_set_colour(style->fill_colour);
nsgtk_set_solid();
- if (line_width == 0)
- line_width = 1;
-
- cairo_set_line_width(current_cr, line_width);
- cairo_rectangle(current_cr, x0 + 0.5, y0 + 0.5, width, height);
- cairo_stroke(current_cr);
-
+ cairo_set_line_width(current_cr, 0);
+ cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0);
+ cairo_fill(current_cr);
+ cairo_stroke(current_cr);
+ }
+
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ nsgtk_set_colour(style->stroke_colour);
+
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ nsgtk_set_solid();
+ break;
+
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ nsgtk_set_dotted();
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ nsgtk_set_dashed();
+ break;
+ }
+
+ if (style->stroke_width == 0)
+ cairo_set_line_width(current_cr, 1);
+ else
+ cairo_set_line_width(current_cr, style->stroke_width);
+
+ cairo_rectangle(current_cr, x0 + 0.5, y0 + 0.5, x1 - x0, y1 - y0);
+ cairo_stroke(current_cr);
+ }
return true;
}
-
bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
@@ -155,20 +171,6 @@ bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill)
}
-bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
-{
- nsgtk_set_colour(style->fill_colour);
- nsgtk_set_solid();
-
- cairo_set_line_width(current_cr, 0);
- cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0);
- cairo_fill(current_cr);
- cairo_stroke(current_cr);
-
- return true;
-}
-
-
bool nsgtk_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1)
{