summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.sources3
-rwxr-xr-xamiga/plotters.c57
-rwxr-xr-xamiga/plotters.h3
-rw-r--r--beos/beos_plotters.cpp30
-rw-r--r--desktop/history_core.c18
-rw-r--r--desktop/knockout.c70
-rw-r--r--desktop/plot_style.c121
-rw-r--r--desktop/plot_style.h90
-rw-r--r--desktop/plotters.h30
-rw-r--r--desktop/save_pdf/pdf_plotters.c33
-rw-r--r--desktop/textarea.c8
-rw-r--r--framebuffer/framebuffer.c27
-rw-r--r--gtk/gtk_plotters.c33
-rw-r--r--gtk/gtk_print.c35
-rw-r--r--render/html_redraw.c217
-rw-r--r--riscos/plotters.c22
-rw-r--r--riscos/print.c6
-rw-r--r--riscos/save_draw.c26
18 files changed, 548 insertions, 281 deletions
diff --git a/Makefile.sources b/Makefile.sources
index 458eb8b87..5164068da 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -13,7 +13,8 @@ S_RENDER := box.c box_construct.c box_normalise.c directory.c \
layout.c list.c loosen.c table.c textplain.c
S_UTILS := base64.c filename.c hashtable.c locale.c messages.c talloc.c \
url.c utf8.c utils.c useragent.c
-S_DESKTOP := knockout.c options.c print.c tree.c version.c textarea.c
+S_DESKTOP := knockout.c options.c print.c tree.c version.c textarea.c \
+ plot_style.c
# S_COMMON are sources common to all builds
S_COMMON := $(addprefix content/,$(S_CONTENT)) \
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 5ae0234f5..8f7e525cc 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -260,19 +260,31 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
return true;
}
-bool ami_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
#ifndef NS_AMIGA_CAIRO_ALL
- glob->rp.PenWidth = width;
- glob->rp.PenHeight = width;
+ glob->rp.PenWidth = style->stroke_width;
+ glob->rp.PenHeight = style->stroke_width;
- glob->rp.LinePtrn = PATT_LINE;
- if(dotted) glob->rp.LinePtrn = PATT_DOT;
- if(dashed) glob->rp.LinePtrn = PATT_DASH;
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ glob->rp.LinePtrn = PATT_LINE;
+ break;
- SetRPAttrs(&glob->rp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
- TAG_DONE);
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ glob->rp.LinePtrn = PATT_DOT;
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ glob->rp.LinePtrn = PATT_DASH;
+ break;
+ }
+
+ SetRPAttrs(&glob->rp,
+ RPTAG_APenColor,
+ p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
+ TAG_DONE);
Move(&glob->rp,x0,y0);
Draw(&glob->rp,x1,y1);
@@ -280,15 +292,28 @@ bool ami_line(int x0, int y0, int x1, int y1, int width,
glob->rp.PenHeight = 1;
glob->rp.LinePtrn = PATT_LINE;
#else
- ami_cairo_set_colour(glob->cr,c);
- if (dotted) ami_cairo_set_dotted(glob->cr);
- else if (dashed) ami_cairo_set_dashed(glob->cr);
- else ami_cairo_set_solid(glob->cr);
+ ami_cairo_set_colour(glob->cr, style->stroke_colour);
- if (width == 0)
- width = 1;
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ ami_cairo_set_solid(glob->cr);
+ break;
+
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ ami_cairo_set_dotted(glob->cr);
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ ami_cairo_set_dashed(glob->cr);
+ break;
+ }
+
+ if (style->stroke_width == 0)
+ cairo_set_line_width(glob->cr, 1);
+ else
+ cairo_set_line_width(glob->cr, style->stroke_width);
- cairo_set_line_width(glob->cr, width);
cairo_move_to(glob->cr, x0 + 0.5, y0 + 0.5);
cairo_line_to(glob->cr, x1 + 0.5, y1 + 0.5);
cairo_stroke(glob->cr);
diff --git a/amiga/plotters.h b/amiga/plotters.h
index 486823115..37c892f62 100755
--- a/amiga/plotters.h
+++ b/amiga/plotters.h
@@ -43,8 +43,7 @@ extern const struct plotter_table amiplot;
bool ami_clg(colour c);
bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-bool ami_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
bool ami_polygon(const int *p, unsigned int n, colour fill);
bool ami_clip(int x0, int y0, int x1, int y1);
bool ami_text(int x, int y, const struct css_style *style,
diff --git a/beos/beos_plotters.cpp b/beos/beos_plotters.cpp
index 36ea8b6b0..cbe447ee6 100644
--- a/beos/beos_plotters.cpp
+++ b/beos/beos_plotters.cpp
@@ -62,8 +62,7 @@ cairo_t *current_cr;
*/
static bool nsbeos_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool nsbeos_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool nsbeos_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
@@ -229,16 +228,25 @@ bool nsbeos_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *s
-bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool nsbeos_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- pattern pat = B_SOLID_HIGH;
+ pattern pat;
BView *view;
- if (dotted)
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ pat = B_SOLID_HIGH;
+ break;
+
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
pat = kDottedPattern;
- else if (dashed)
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
pat = kDashedPattern;
+ break;
+ }
view = nsbeos_current_gc/*_lock*/();
if (view == NULL) {
@@ -246,10 +254,10 @@ bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width,
return false;
}
- nsbeos_set_colour(c);
+ nsbeos_set_colour(style->stroke_colour);
float pensize = view->PenSize();
- view->SetPenSize(width);
+ view->SetPenSize(style->stroke_width);
BPoint start(x0, y0);
BPoint end(x1, y1);
@@ -271,8 +279,8 @@ bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width,
cairo_stroke(current_cr);
} else
#endif
- gdk_draw_line(current_drawable, current_gc,
- x0, y0, x1, y1);
+ gdk_draw_line(current_drawable, current_gc,
+ x0, y0, x1, y1);
#endif
return true;
}
diff --git a/desktop/history_core.c b/desktop/history_core.c
index d02820b20..a40d746bd 100644
--- a/desktop/history_core.c
+++ b/desktop/history_core.c
@@ -661,19 +661,19 @@ bool history_redraw_entry(struct history *history,
if (!plot.line(entry->x + WIDTH + xoffset,
entry->y + HEIGHT / 2 + yoffset,
entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset, 1,
- 0x333333, false, false))
+ entry->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
return false;
if (!plot.line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset, 1,
- 0x333333, false, false))
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
return false;
if (!plot.line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y + HEIGHT / 2 + yoffset, 1,
- 0x333333, false, false))
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
return false;
if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y, clip))
return false;
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 807833b8b..7cecb92c8 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -75,47 +75,6 @@
#define KNOCKOUT_BOXES 768 /* 28 bytes each */
#define KNOCKOUT_POLYGONS 3072 /* 4 bytes each */
-/** Global fill styles - used everywhere, should they be here? */
-static plot_style_t plot_style_fill_white_static = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = 0xffffff,
-};
-
-static plot_style_t plot_style_fill_red_static = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = 0x000000ff,
-};
-
-static plot_style_t plot_style_fill_black_static = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = 0x0,
-};
-
-static plot_style_t plot_style_stroke_red_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = 0x000000ff,
- .stroke_width = 1,
-};
-
-static plot_style_t plot_style_stroke_blue_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = 0x00ff0000,
- .stroke_width = 1,
-};
-
-static plot_style_t plot_style_stroke_yellow_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = 0x0000ffff,
- .stroke_width = 1,
-};
-
-plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
-plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
-plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
-plot_style_t *plot_style_stroke_red = &plot_style_stroke_red_static;
-plot_style_t *plot_style_stroke_blue = &plot_style_stroke_blue_static;
-plot_style_t *plot_style_stroke_yellow = &plot_style_stroke_yellow_static;
-
struct knockout_box;
struct knockout_entry;
@@ -126,8 +85,7 @@ static bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t
static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
struct knockout_entry *entry);
-static bool knockout_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
static bool knockout_plot_polygon(const int *p, unsigned int n, colour fill);
static bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *plot_style);
static bool knockout_plot_clip(int clip_x0, int clip_y0,
@@ -208,10 +166,7 @@ struct knockout_entry {
int y0;
int x1;
int y1;
- int width;
- colour c;
- bool dotted;
- bool dashed;
+ plot_style_t plot_style;
} line;
struct {
int *p;
@@ -365,10 +320,7 @@ bool knockout_plot_flush(void)
knockout_entries[i].data.line.y0,
knockout_entries[i].data.line.x1,
knockout_entries[i].data.line.y1,
- knockout_entries[i].data.line.width,
- knockout_entries[i].data.line.c,
- knockout_entries[i].data.line.dotted,
- knockout_entries[i].data.line.dashed);
+ &knockout_entries[i].data.line.plot_style);
break;
case KNOCKOUT_PLOT_POLYGON:
success &= plot.polygon(
@@ -687,18 +639,22 @@ bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t
knockout_entries[knockout_entry_cur].data.fill.x1 = x1;
knockout_entries[knockout_entry_cur].data.fill.y1 = y1;
knockout_entries[knockout_entry_cur].data.fill.plot_style = *pstyle;
+ knockout_entries[knockout_entry_cur].data.fill.plot_style.stroke_type = PLOT_OP_TYPE_NONE; /* ensure we only plot the fill */
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_FILL;
if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) ||
(++knockout_box_cur >= KNOCKOUT_BOXES))
knockout_plot_flush();
- } else if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
- /* not a filled area */
+ }
+
+ if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
+ /* draw outline */
knockout_entries[knockout_entry_cur].data.rectangle.x0 = x0;
knockout_entries[knockout_entry_cur].data.rectangle.y0 = y0;
knockout_entries[knockout_entry_cur].data.rectangle.x1 = x1;
knockout_entries[knockout_entry_cur].data.rectangle.y1 = y1;
knockout_entries[knockout_entry_cur].data.fill.plot_style = *pstyle;
+ knockout_entries[knockout_entry_cur].data.fill.plot_style.fill_type = PLOT_OP_TYPE_NONE; /* ensure we only plot the outline */
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_RECTANGLE;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
@@ -706,17 +662,13 @@ bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t
return true;
}
-bool knockout_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
{
knockout_entries[knockout_entry_cur].data.line.x0 = x0;
knockout_entries[knockout_entry_cur].data.line.y0 = y0;
knockout_entries[knockout_entry_cur].data.line.x1 = x1;
knockout_entries[knockout_entry_cur].data.line.y1 = y1;
- knockout_entries[knockout_entry_cur].data.line.width = width;
- knockout_entries[knockout_entry_cur].data.line.c = c;
- knockout_entries[knockout_entry_cur].data.line.dotted = dotted;
- knockout_entries[knockout_entry_cur].data.line.dashed = dashed;
+ knockout_entries[knockout_entry_cur].data.line.plot_style = *pstyle;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_LINE;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
new file mode 100644
index 000000000..8ed8fb5e6
--- /dev/null
+++ b/desktop/plot_style.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince@kyllikki.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file Plotter global styles.
+ *
+ * These plot styles are globaly available and used in many places.
+ */
+
+#include "desktop/plotters.h"
+
+static plot_style_t plot_style_fill_white_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0xffffff,
+};
+plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
+
+static plot_style_t plot_style_fill_black_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0x0,
+};
+plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
+
+static plot_style_t plot_style_fill_red_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0x000000ff,
+};
+plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
+
+static plot_style_t plot_style_stroke_red_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x000000ff,
+ .stroke_width = 1,
+};
+plot_style_t *plot_style_stroke_red = &plot_style_stroke_red_static;
+
+static plot_style_t plot_style_stroke_blue_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x00ff0000,
+ .stroke_width = 1,
+};
+plot_style_t *plot_style_stroke_blue = &plot_style_stroke_blue_static;
+
+static plot_style_t plot_style_stroke_yellow_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x0000ffff,
+ .stroke_width = 1,
+};
+plot_style_t *plot_style_stroke_yellow = &plot_style_stroke_yellow_static;
+
+/* caret style used in html_redraw_caret */
+static plot_style_t plot_style_caret_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x808080, /* todo - choose a proper colour */
+};
+plot_style_t *plot_style_caret = &plot_style_caret_static;
+
+
+
+/* html redraw widget styles */
+
+/** plot style for widget base. */
+static plot_style_t plot_style_fill_wbasec_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = WIDGET_BASEC,
+};
+plot_style_t *plot_style_fill_wbasec = &plot_style_fill_wbasec_static;
+
+
+/** plot style for widget background. */
+static plot_style_t plot_style_fill_wblobc_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = WIDGET_BLOBC,
+};
+plot_style_t *plot_style_fill_wblobc = &plot_style_fill_wblobc_static;
+
+/** plot style for checkbox cross. */
+static plot_style_t plot_style_stroke_wblobc_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = WIDGET_BLOBC,
+ .stroke_width = 2,
+};
+plot_style_t *plot_style_stroke_wblobc = &plot_style_stroke_wblobc_static;
+
+/** stroke style for widget double dark colour. */
+static plot_style_t plot_style_stroke_darkwbasec_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = double_darken_colour(WIDGET_BASEC),
+};
+plot_style_t *plot_style_stroke_darkwbasec = &plot_style_stroke_darkwbasec_static;
+
+/** stroke style for widget double light colour. */
+static plot_style_t plot_style_stroke_lightwbasec_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = double_lighten_colour(WIDGET_BASEC),
+};
+plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static;
+
+/* history styles */
+
+/** stroke style for history core. */
+static plot_style_t plot_style_stroke_history_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x333333,
+};
+plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static;
+
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
new file mode 100644
index 000000000..03bb69f91
--- /dev/null
+++ b/desktop/plot_style.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Ploter styles.
+ */
+
+#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_
+#define _NETSURF_DESKTOP_PLOT_STYLE_H_
+
+/* html widget colours */
+#define WIDGET_BASEC 0xd9d9d9
+#define WIDGET_BLOBC 0x000000
+
+/* Darken a colour by taking three quaters of each channels intensity */
+#define darken_colour(c1) \
+ ((((3 * (c1 >> 16)) >> 2) << 16) | \
+ (((3 * ((c1 >> 8) & 0xff)) >> 2) << 8) | \
+ (((3 * (c1 & 0xff)) >> 2) << 0))
+
+/* Darken a colour by taking nine sixteenths of each channels intensity */
+#define double_darken_colour(c1) \
+ ((((9 * (c1 >> 16)) >> 4) << 16) | \
+ (((9 * ((c1 >> 8) & 0xff)) >> 4) << 8) | \
+ (((9 * (c1 & 0xff)) >> 4) << 0))
+
+/* Lighten a colour by taking three quaters of each channels intensity
+ * and adding a full quater
+ */
+#define lighten_colour(c1) \
+ (((((3 * (c1 >> 16)) >> 2) + 64) << 16) | \
+ ((((3 * ((c1 >> 8) & 0xff)) >> 2) + 64) << 8) | \
+ ((((3 * (c1 & 0xff)) >> 2) + 64) << 0))
+
+/* Lighten a colour by taking nine sixteenths of each channels intensity and adding a full intensity 7/16ths */
+#define double_lighten_colour(c1) \
+ (((((9 * (c1 >> 16)) >> 4) + 112) << 16) | \
+ ((((9 * ((c1 >> 8) & 0xff)) >> 4) + 112) << 8) | \
+ ((((9 * (c1 & 0xff)) >> 4) + 112) << 0))
+
+typedef enum {
+ PLOT_OP_TYPE_NONE = 0, /**< No operation */
+ PLOT_OP_TYPE_SOLID, /**< Solid colour */
+ PLOT_OP_TYPE_DOT, /**< Doted plot */
+ PLOT_OP_TYPE_DASH, /**< dashed plot */
+} plot_operation_type_t;
+
+typedef struct {
+ plot_operation_type_t stroke_type;
+ int stroke_width;
+ colour stroke_colour;
+ plot_operation_type_t fill_type;
+ colour fill_colour;
+} plot_style_t;
+
+/* global fill styles */
+extern plot_style_t *plot_style_fill_white;
+extern plot_style_t *plot_style_fill_red;
+extern plot_style_t *plot_style_fill_black;
+
+/* global stroke styles */
+extern plot_style_t *plot_style_stroke_red;
+extern plot_style_t *plot_style_stroke_blue;
+extern plot_style_t *plot_style_stroke_yellow;
+
+/* other styles */
+extern plot_style_t *plot_style_caret;
+extern plot_style_t *plot_style_stroke_history;
+extern plot_style_t *plot_style_fill_wbasec;
+extern plot_style_t *plot_style_fill_wblobc;
+extern plot_style_t *plot_style_stroke_wblobc;
+extern plot_style_t *plot_style_stroke_darkwbasec;
+extern plot_style_t *plot_style_stroke_lightwbasec;
+
+#endif
diff --git a/desktop/plotters.h b/desktop/plotters.h
index 3f317b1af..4a6261516 100644
--- a/desktop/plotters.h
+++ b/desktop/plotters.h
@@ -26,7 +26,7 @@
#include <stdbool.h>
#include "css/css.h"
#include "content/content.h"
-
+#include "desktop/plot_style.h"
struct bitmap;
@@ -35,29 +35,6 @@ typedef unsigned long bitmap_flags_t;
#define BITMAPF_REPEAT_X 1
#define BITMAPF_REPEAT_Y 2
-typedef enum {
- PLOT_OP_TYPE_NONE = 0, /**< No operation */
- PLOT_OP_TYPE_SOLID, /**< Solid colour */
- PLOT_OP_TYPE_DOT, /**< Doted plot */
- PLOT_OP_TYPE_DASH, /**< dashed plot */
-} plot_operation_type_t;
-
-
-typedef struct {
- plot_operation_type_t stroke_type;
- int stroke_width;
- colour stroke_colour;
- plot_operation_type_t fill_type;
- colour fill_colour;
-} plot_style_t;
-
-/* global styles */
-extern plot_style_t *plot_style_fill_white;
-extern plot_style_t *plot_style_fill_red;
-extern plot_style_t *plot_style_fill_black;
-extern plot_style_t *plot_style_stroke_red;
-extern plot_style_t *plot_style_stroke_blue;
-extern plot_style_t *plot_style_stroke_yellow;
/** Set of target specific plotting functions.
*
@@ -118,9 +95,8 @@ extern plot_style_t *plot_style_stroke_yellow;
* 3 | | | | | |
*/
struct plotter_table {
- bool (*rectangle)(int x0, int y0, int x1, int y1, const plot_style_t *style);
- bool (*line)(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+ bool (*rectangle)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
+ bool (*line)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
bool (*polygon)(const int *p, unsigned int n, colour fill);
bool (*clip)(int x0, int y0, int x1, int y1);
bool (*text)(int x, int y, const struct css_style *style,
diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c
index 468c19ed1..58df607d6 100644
--- a/desktop/save_pdf/pdf_plotters.c
+++ b/desktop/save_pdf/pdf_plotters.c
@@ -46,8 +46,7 @@
/* #define PDF_DEBUG_DUMPGRID */
static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool pdf_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
static bool pdf_plot_polygon(const int *p, unsigned int n, colour fill);
static bool pdf_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
@@ -200,16 +199,30 @@ bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *psty
return true;
}
-bool pdf_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
{
-#ifdef PDF_DEBUG
- LOG(("."));
-#endif
+ DashPattern_e dash;
+
+ switch (pstyle->stroke_type) {
+ case PLOT_OP_TYPE_DOT:
+ dash = DashPattern_eDotted;
+ break;
+
+ case PLOT_OP_TYPE_DASH:
+ dash = DashPattern_eDash;
+ break;
+
+ default:
+ dash = DashPattern_eNone;
+ break;
+
+ }
- apply_clip_and_mode(false, TRANSPARENT, c, width,
- (dotted) ? DashPattern_eDotted :
- ((dashed) ? DashPattern_eDash : DashPattern_eNone));
+ apply_clip_and_mode(false,
+ TRANSPARENT,
+ pstyle->stroke_colour,
+ pstyle->stroke_width,
+ dash);
HPDF_Page_MoveTo(pdf_page, x0, page_height - y0);
HPDF_Page_LineTo(pdf_page, x1, page_height - y1);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 520b53090..4e08ff549 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -52,6 +52,12 @@ static plot_style_t pstyle_stroke_border = {
.stroke_width = 1,
};
+static plot_style_t pstyle_stroke_caret = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = CARET_COLOR,
+ .stroke_width = 1,
+};
+
struct line_info {
unsigned int b_start; /**< Byte offset of line start */
unsigned int b_length; /**< Byte length of line */
@@ -526,7 +532,7 @@ bool textarea_set_caret(struct text_area *ta, int caret)
y1 = min(y + height + 1, ta->y + ta->vis_height);
plot.clip(x0, y0, x1, y1);
- plot.line(x, y, x, y + height, 1, CARET_COLOR, false, false);
+ plot.line(x, y, x, y + height, &pstyle_stroke_caret);
}
ta->redraw_end_callback(ta->data);
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index 41ede39c6..0e8570211 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -226,6 +226,31 @@ framebuffer_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *s
return true;
}
+static bool
+framebuffer_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
+{
+ nsfb_bbox_t rect;
+ bool dotted = false;
+ bool dashed = false;
+
+ rect.x0 = x0;
+ rect.y0 = y0;
+ rect.x1 = x1;
+ rect.y1 = y1;
+
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ if (style->stroke_type == PLOT_OP_TYPE_DOT)
+ dotted = true;
+
+ if (style->stroke_type == PLOT_OP_TYPE_DASH)
+ dashed = true;
+
+ nsfb_plot_line(nsfb, &rect, style->stroke_width, style->stroke_colour, dotted, dashed);
+ }
+
+ return true;
+}
+
static bool framebuffer_plot_flush(void)
{
LOG(("flush unimplemnted"));
@@ -246,7 +271,7 @@ framebuffer_plot_path(const float *p,
struct plotter_table plot = {
.rectangle = framebuffer_plot_rectangle,
- .line = nsfb_lplot_line,
+ .line = framebuffer_plot_line,
.polygon = nsfb_lplot_polygon,
.clip = nsfb_lplot_clip,
.text = framebuffer_plot_text,
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c
index e323cb590..bc990199b 100644
--- a/gtk/gtk_plotters.c
+++ b/gtk/gtk_plotters.c
@@ -49,8 +49,7 @@ GdkDrawable *current_drawable;
GdkGC *current_gc;
cairo_t *current_cr;
-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_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
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]);
@@ -129,21 +128,31 @@ bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *st
return true;
}
-bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- nsgtk_set_colour(c);
- if (dotted)
+
+ 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();
- else if (dashed)
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
nsgtk_set_dashed();
- else
- nsgtk_set_solid();
+ break;
+ }
- if (width == 0)
- width = 1;
+ if (style->stroke_width == 0)
+ cairo_set_line_width(current_cr, 1);
+ else
+ cairo_set_line_width(current_cr, style->stroke_width);
- cairo_set_line_width(current_cr, width);
cairo_move_to(current_cr, x0 + 0.5, y0 + 0.5);
cairo_line_to(current_cr, x1 + 0.5, y1 + 0.5);
cairo_stroke(current_cr);
diff --git a/gtk/gtk_print.c b/gtk/gtk_print.c
index 851b690ba..0685d2f9e 100644
--- a/gtk/gtk_print.c
+++ b/gtk/gtk_print.c
@@ -46,8 +46,7 @@
#include "utils/utils.h"
static bool nsgtk_print_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool nsgtk_print_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsgtk_print_plot_path(const float *p, unsigned int n, colour fill,
float width, colour c, const float transform[6]);
@@ -160,24 +159,32 @@ bool nsgtk_print_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style
-bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- nsgtk_print_set_colour(c);
+ nsgtk_print_set_colour(style->stroke_colour);
+
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ nsgtk_print_set_solid();
+ break;
- if (dotted)
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
nsgtk_print_set_dotted();
- else if (dashed)
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
nsgtk_print_set_dashed();
- else
- nsgtk_print_set_solid();
+ break;
+ }
- if (width == 0)
- width = 1;
+ if (style->stroke_width == 0)
+ cairo_set_line_width(gtk_print_current_cr, 1);
+ else
+ cairo_set_line_width(gtk_print_current_cr, style->stroke_width);
- cairo_set_line_width(gtk_print_current_cr, width);
- cairo_move_to(gtk_print_current_cr, x0, y0 - 0.5);
- cairo_line_to(gtk_print_current_cr, x1, y1 - 0.5);
+ cairo_move_to(gtk_print_current_cr, x0 + 0.5, y0 + 0.5);
+ cairo_line_to(gtk_print_current_cr, x1 + 0.5, y1 + 0.5);
cairo_stroke(gtk_print_current_cr);
return true;
diff --git a/render/html_redraw.c b/render/html_redraw.c
index ad695158c..a6d900e3a 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -934,20 +934,19 @@ bool text_redraw(const char *utf8_text, size_t utf8_len,
bool html_redraw_caret(struct caret *c, colour current_background_color,
float scale)
{
- colour caret_color = 0x808080; /* todo - choose a proper colour */
int xc = c->x, y = c->y;
int h = c->height - 1;
int w = (h + 7) / 8;
return (plot.line(xc * scale, y * scale,
xc * scale, (y + h) * scale,
- 0, caret_color, false, false) &&
+ plot_style_caret) &&
plot.line((xc - w) * scale, y * scale,
(xc + w) * scale, y * scale,
- 0, caret_color, false, false) &&
+ plot_style_caret) &&
plot.line((xc - w) * scale, (y + h) * scale,
(xc + w) * scale, (y + h) * scale,
- 0, caret_color, false, false));
+ plot_style_caret));
}
@@ -1095,27 +1094,35 @@ bool html_redraw_border_plot(int i, int *p, colour c,
css_border_style style, int thickness)
{
int z[8];
- bool dotted = false;
unsigned int light = i;
colour c_lit;
+ plot_style_t plot_style_bdr = {
+ .stroke_type = PLOT_OP_TYPE_DASH,
+ .stroke_colour = c,
+ .stroke_width = thickness,
+ .fill_type = PLOT_OP_TYPE_NONE,
+ };
if (c == TRANSPARENT)
return true;
switch (style) {
case CSS_BORDER_STYLE_DOTTED:
- dotted = true;
+ plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
+
case CSS_BORDER_STYLE_DASHED:
if (!plot.line((p[i * 4 + 0] + p[i * 4 + 2]) / 2,
(p[i * 4 + 1] + p[i * 4 + 3]) / 2,
(p[i * 4 + 4] + p[i * 4 + 6]) / 2,
(p[i * 4 + 5] + p[i * 4 + 7]) / 2,
- thickness,
- c, dotted, !dotted))
+ &plot_style_bdr))
return false;
- return true;
+ break;
case CSS_BORDER_STYLE_SOLID:
+ default:
+ if (!plot.polygon(p + i * 4, 4, c))
+ return false;
break;
case CSS_BORDER_STYLE_DOUBLE:
@@ -1139,7 +1146,7 @@ bool html_redraw_border_plot(int i, int *p, colour c,
z[7] = p[i * 4 + 5];
if (!plot.polygon(z, 4, c))
return false;
- return true;
+ break;
case CSS_BORDER_STYLE_GROOVE:
light = 3 - light;
@@ -1164,7 +1171,7 @@ bool html_redraw_border_plot(int i, int *p, colour c,
html_redraw_lighter(c) :
html_redraw_darker(c)))
return false;
- return true;
+ break;
case CSS_BORDER_STYLE_INSET:
light = (light + 2) % 4;
@@ -1208,14 +1215,9 @@ bool html_redraw_border_plot(int i, int *p, colour c,
}
if (!plot.polygon(z, 4, c))
return false;
- return true;
-
- default:
break;
}
- if (!plot.polygon(p + i * 4, 4, c))
- return false;
return true;
}
@@ -1282,20 +1284,6 @@ colour html_redraw_aa(colour c0, colour c1)
-#define WIDGET_BASEC 0xd9d9d9
-#define WIDGET_BLOBC 0x000000
-
-/** plot style for checkbox base. */
-static plot_style_t pstyle_fill_wbasec = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = WIDGET_BASEC,
-};
-
-/** plot style for checkbox background. */
-static plot_style_t pstyle_fill_wblobc = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = WIDGET_BLOBC,
-};
/**
* Plot a checkbox.
@@ -1311,42 +1299,37 @@ static plot_style_t pstyle_fill_wblobc = {
bool html_redraw_checkbox(int x, int y, int width, int height,
bool selected)
{
- int dark = html_redraw_darker(html_redraw_darker(WIDGET_BASEC));
- int lite = html_redraw_lighter(html_redraw_lighter(WIDGET_BASEC));
-
double z = width * 0.15;
if (z == 0)
z = 1;
- if (!(plot.rectangle(x, y, x + width, y + height, &pstyle_fill_wbasec) &&
- plot.line(x, y, x + width, y, 1, dark, false, false) &&
- plot.line(x, y, x, y + height, 1, dark, false, false) &&
- plot.line(x + width, y, x + width, y + height, 1, lite,
- false, false) &&
- plot.line(x, y + height, x + width, y + height, 1, lite,
- false, false)))
+ if (!(plot.rectangle(x, y, x + width, y + height, plot_style_fill_wbasec) &&
+ plot.line(x, y, x + width, y, plot_style_stroke_darkwbasec) &&
+ plot.line(x, y, x, y + height, plot_style_stroke_darkwbasec) &&
+ plot.line(x + width, y, x + width, y + height, plot_style_stroke_lightwbasec) &&
+ plot.line(x, y + height, x + width, y + height, plot_style_stroke_lightwbasec)))
return false;
if (selected) {
if (width < 12 || height < 12) {
/* render a solid box instead of a tick */
if (!plot.rectangle(x + z + z, y + z + z,
- x + width - z, y + height - z,
- &pstyle_fill_wblobc))
+ x + width - z, y + height - z,
+ plot_style_fill_wblobc))
return false;
} else {
/* render a tick, as it'll fit comfortably */
if (!(plot.line(x + width - z,
- y + z,
- x + (z * 3),
- y + height - z,
- 2, WIDGET_BLOBC, false, false) &&
-
- plot.line(x + (z * 3),
- y + height - z,
- x + z + z,
- y + (height / 2),
- 2, WIDGET_BLOBC, false, false)))
+ y + z,
+ x + (z * 3),
+ y + height - z,
+ plot_style_stroke_wblobc) &&
+
+ plot.line(x + (z * 3),
+ y + height - z,
+ x + z + z,
+ y + (height / 2),
+ plot_style_stroke_wblobc)))
return false;
}
}
@@ -1889,6 +1872,11 @@ bool html_redraw_text_decoration_inline(struct box *box, int x, int y,
float scale, colour colour, float ratio)
{
struct box *c;
+ plot_style_t plot_style_box = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = colour,
+ };
+
for (c = box->next;
c && c != box->inline_end;
c = c->next) {
@@ -1898,7 +1886,7 @@ bool html_redraw_text_decoration_inline(struct box *box, int x, int y,
(y + c->y + c->height * ratio) * scale,
(x + c->x + c->width) * scale,
(y + c->y + c->height * ratio) * scale,
- 0, colour, false, false))
+ &plot_style_box))
return false;
}
return true;
@@ -1921,6 +1909,11 @@ bool html_redraw_text_decoration_block(struct box *box, int x, int y,
float scale, colour colour, float ratio)
{
struct box *c;
+ plot_style_t plot_style_box = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = colour,
+ };
+
/* draw through text descendants */
for (c = box->children; c; c = c->next) {
if (c->type == BOX_TEXT) {
@@ -1928,7 +1921,7 @@ bool html_redraw_text_decoration_block(struct box *box, int x, int y,
(y + c->y + c->height * ratio) * scale,
(x + c->x + c->width) * scale,
(y + c->y + c->height * ratio) * scale,
- 0, colour, false, false))
+ &plot_style_box))
return false;
} else if (c->type == BOX_INLINE_CONTAINER ||
c->type == BOX_BLOCK) {
@@ -1941,6 +1934,42 @@ bool html_redraw_text_decoration_block(struct box *box, int x, int y,
return true;
}
+static inline bool
+html_redraw_scrollbar_rectangle(int x0, int y0, int x1, int y1, colour c, bool inset)
+{
+ static plot_style_t c0 = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 1,
+ };
+
+ static plot_style_t c1 = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 1,
+ };
+
+ static plot_style_t c2 = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_width = 1,
+ };
+
+ if (inset) {
+ c0.stroke_colour = darken_colour(c);
+ c1.stroke_colour = lighten_colour(c);
+ } else {
+ c0.stroke_colour = lighten_colour(c);
+ c1.stroke_colour = darken_colour(c);
+ }
+ c2.stroke_colour = html_redraw_blend(c0.stroke_colour,
+ c1.stroke_colour);
+
+ if (!plot.line(x0, y0, x1, y0, &c0)) return false;
+ if (!plot.line(x1, y0, x1, y1 + 1, &c1)) return false;
+ if (!plot.line(x1, y0, x1, y0 + 1, &c2)) return false;
+ if (!plot.line(x1, y1, x0, y1, &c1)) return false;
+ if (!plot.line(x0, y1, x0, y0, &c0)) return false;
+ if (!plot.line(x0, y1, x0, y1 + 1, &c2)) return false;
+ return true;
+}
/**
* Plot scrollbars for a scrolling box.
@@ -1962,7 +1991,6 @@ bool html_redraw_scrollbars(struct box *box, float scale,
bool vscroll, hscroll;
int well_height, bar_top, bar_height;
int well_width, bar_left, bar_width;
- colour c0, c1; /* highlight and shadow colours */
int v[6]; /* array of triangle vertices */
plot_style_t pstyle_css_scrollbar_bg_colour = {
.fill_type = PLOT_OP_TYPE_SOLID,
@@ -1978,38 +2006,23 @@ bool html_redraw_scrollbars(struct box *box, float scale,
&well_height, &bar_top, &bar_height,
&well_width, &bar_left, &bar_width);
-#define RECTANGLE(x0, y0, x1, y1, c, inset) \
- c0 = inset ? html_redraw_darker(c) : html_redraw_lighter(c); \
- c1 = inset ? html_redraw_lighter(c) : html_redraw_darker(c); \
- if (!plot.line(x0, y0, x1, y0, 1, c0, false, false)) \
- return false; \
- if (!plot.line(x1, y0, x1, y1 + 1, 1, c1, false, false)) \
- return false; \
- if (!plot.line(x1, y0, x1, y0 + 1, 1, \
- html_redraw_blend(c0, c1), false, false)) \
- return false; \
- if (!plot.line(x1, y1, x0, y1, 1, c1, false, false)) \
- return false; \
- if (!plot.line(x0, y1, x0, y0, 1, c0, false, false)) \
- return false; \
- if (!plot.line(x0, y1, x0, y1 + 1, 1, \
- html_redraw_blend(c0, c1), false, false)) \
- return false;
/* horizontal scrollbar */
if (hscroll) {
/* scrollbar outline */
- RECTANGLE(x,
+ if (!html_redraw_scrollbar_rectangle(x,
y + padding_height - w,
x + padding_width - 1,
y + padding_height - 1,
- css_scrollbar_bg_colour, true);
+ css_scrollbar_bg_colour, true))
+ return false;
/* left arrow icon border */
- RECTANGLE(x + 1,
+ if (!html_redraw_scrollbar_rectangle(x + 1,
y + padding_height - w + 1,
x + w - 2,
y + padding_height - 2,
- css_scrollbar_fg_colour, false);
+ css_scrollbar_fg_colour, false))
+ return false;
/* left arrow icon background */
if (!plot.rectangle(x + 2,
y + padding_height - w + 2,
@@ -2034,11 +2047,12 @@ bool html_redraw_scrollbars(struct box *box, float scale,
&pstyle_css_scrollbar_bg_colour))
return false;
/* scroll position indicator bar */
- RECTANGLE(x + w + bar_left,
+ if (!html_redraw_scrollbar_rectangle(x + w + bar_left,
y + padding_height - w + 1,
x + w + bar_left + bar_width + (vscroll? 1 : 0),
y + padding_height - 2,
- css_scrollbar_fg_colour, false);
+ css_scrollbar_fg_colour, false))
+ return false;
if (!plot.rectangle(x + w + bar_left + 1,
y + padding_height - w + 2,
x + w + bar_left + bar_width + (vscroll? 1 : 0),
@@ -2046,11 +2060,12 @@ bool html_redraw_scrollbars(struct box *box, float scale,
&pstyle_css_scrollbar_fg_colour))
return false;
/* right arrow icon border */
- RECTANGLE(x + w + well_width + 2,
+ if (!html_redraw_scrollbar_rectangle(x + w + well_width + 2,
y + padding_height - w + 1,
x + w + well_width + w - (vscroll ? 1 : 2),
y + padding_height - 2,
- css_scrollbar_fg_colour, false);
+ css_scrollbar_fg_colour, false))
+ return false;
/* right arrow icon background */
if (!plot.rectangle(x + w + well_width + 3,
y + padding_height - w + 2,
@@ -2072,22 +2087,26 @@ bool html_redraw_scrollbars(struct box *box, float scale,
/* vertical scrollbar */
if (vscroll) {
/* outline */
- RECTANGLE(x + padding_width - w,
- y,
- x + padding_width - 1,
- y + padding_height - 1,
- css_scrollbar_bg_colour, true);
+ if (!html_redraw_scrollbar_rectangle(x + padding_width - w,
+ y,
+ x + padding_width - 1,
+ y + padding_height - 1,
+ css_scrollbar_bg_colour,
+ true))
+ return false;
/* top arrow background */
- RECTANGLE(x + padding_width - w + 1,
- y + 1,
- x + padding_width - 2,
- y + w - 2,
- css_scrollbar_fg_colour, false);
+ if (!html_redraw_scrollbar_rectangle(x + padding_width - w + 1,
+ y + 1,
+ x + padding_width - 2,
+ y + w - 2,
+ css_scrollbar_fg_colour,
+ false))
+ return false;
if (!plot.rectangle(x + padding_width - w + 2,
- y + 2,
- x + padding_width - 2,
- y + w - 2,
- &pstyle_css_scrollbar_fg_colour))
+ y + 2,
+ x + padding_width - 2,
+ y + w - 2,
+ &pstyle_css_scrollbar_fg_colour))
return false;
/* up arrow */
v[0] = x + padding_width - w / 2;
@@ -2106,11 +2125,12 @@ bool html_redraw_scrollbars(struct box *box, float scale,
&pstyle_css_scrollbar_bg_colour))
return false;
/* scroll position indicator bar */
- RECTANGLE(x + padding_width - w + 1,
+ if (!html_redraw_scrollbar_rectangle(x + padding_width - w + 1,
y + w + bar_top,
x + padding_width - 2,
y + w + bar_top + bar_height,
- css_scrollbar_fg_colour, false);
+ css_scrollbar_fg_colour, false))
+ return false;
if (!plot.rectangle(x + padding_width - w + 2,
y + w + bar_top + 1,
x + padding_width - 2,
@@ -2118,11 +2138,12 @@ bool html_redraw_scrollbars(struct box *box, float scale,
&pstyle_css_scrollbar_fg_colour))
return false;
/* bottom arrow background */
- RECTANGLE(x + padding_width - w + 1,
+ if (!html_redraw_scrollbar_rectangle(x + padding_width - w + 1,
y + padding_height - w + 1,
x + padding_width - 2,
y + padding_height - 2,
- css_scrollbar_fg_colour, false);
+ css_scrollbar_fg_colour, false))
+ return false;
if (!plot.rectangle(x + padding_width - w + 2,
y + padding_height - w + 2,
x + padding_width - 2,
diff --git a/riscos/plotters.c b/riscos/plotters.c
index 88a3179fd..ec55e81d6 100644
--- a/riscos/plotters.c
+++ b/riscos/plotters.c
@@ -35,8 +35,7 @@
static bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool ro_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool ro_plot_draw_path(const draw_path * const path, int width,
colour c, bool dotted, bool dashed);
static bool ro_plot_polygon(const int *p, unsigned int n, colour fill);
@@ -147,8 +146,7 @@ bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style
}
-bool ro_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
const int path[] = { draw_MOVE_TO,
(ro_plot_origin_x + x0 * 2) * 256,
@@ -157,8 +155,22 @@ bool ro_plot_line(int x0, int y0, int x1, int y1, int width,
(ro_plot_origin_x + x1 * 2) * 256,
(ro_plot_origin_y - y1 * 2 - 1) * 256,
draw_END_PATH };
+ bool dotted = false;
+ bool dashed = false;
+
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ if (style->stroke_type == PLOT_OP_TYPE_DOT)
+ dotted = true;
- return ro_plot_draw_path((const draw_path *) path, width, c, dotted, dashed);
+ if (style->stroke_type == PLOT_OP_TYPE_DASH)
+ dashed = true;
+
+ return ro_plot_draw_path((const draw_path *)path,
+ style->stroke_width,
+ style->stroke_colour,
+ dotted, dashed);
+ }
+ return true;
}
diff --git a/riscos/print.c b/riscos/print.c
index c06b235dd..4cbe97506 100644
--- a/riscos/print.c
+++ b/riscos/print.c
@@ -98,8 +98,7 @@ static bool print_send_printtypeknown(wimp_message *m);
static bool print_document(struct gui_window *g, const char *filename);
static const char *print_declare_fonts(struct content *content);
static bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill);
static bool print_fonts_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
@@ -810,8 +809,7 @@ bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style
}
-bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
return true;
}
diff --git a/riscos/save_draw.c b/riscos/save_draw.c
index 4a8f8d64d..da3e59799 100644
--- a/riscos/save_draw.c
+++ b/riscos/save_draw.c
@@ -38,8 +38,7 @@
#include "utils/utils.h"
static bool ro_save_draw_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool ro_save_draw_polygon(const int *p, unsigned int n, colour fill);
static bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
float width, colour c, const float transform[6]);
@@ -192,19 +191,24 @@ bool ro_save_draw_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *
}
-bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
pencil_code code;
const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1,
- draw_LINE_TO, x1 * 2, -y1 * 2 - 1,
- draw_END_PATH };
+ draw_LINE_TO, x1 * 2, -y1 * 2 - 1,
+ draw_END_PATH };
- code = pencil_path(ro_save_draw_diagram, path,
- sizeof path / sizeof path[0],
- pencil_TRANSPARENT, c << 8, width, pencil_JOIN_MITRED,
- pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
- pencil_SOLID);
+ code = pencil_path(ro_save_draw_diagram,
+ path,
+ sizeof path / sizeof path[0],
+ pencil_TRANSPARENT,
+ style->stroke_colour << 8,
+ style->stroke_width,
+ pencil_JOIN_MITRED,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0, 0, false,
+ pencil_SOLID);
if (code != pencil_OK)
return ro_save_draw_error(code);