Ok, as per the plotter API refactor "plan" I present the first move to
using a style with the fill primative.

This is a first step, next I shall merge the outline rectangle
functionality and create the target single "rectangle" entry point.

I have slightly modified the style API to have a general raster
operation enum for both the stroke and the fill. This is with an eye
to the posibilty of using the style in a more flexible way, this has
emerged as possibly desirable during implementation, please comment if
you feel otherwise.

-- 
Regards Vincent
http://www.kyllikki.org/
Index: render/textplain.c
===================================================================
--- render/textplain.c	(revision 8316)
+++ render/textplain.c	(working copy)
@@ -338,9 +338,9 @@
 	long line0 = clip_y0 / scaled_line_height - 1;
 	long line1 = clip_y1 / scaled_line_height + 1;
 	struct textplain_line *line = c->data.textplain.physical_line;
-	colour hback_col;
 	struct rect clip;
 	size_t length;
+        plot_style_t *plot_style_highlight;
 
 	clip.x0 = clip_x0;
 	clip.y0 = clip_y0;
@@ -358,7 +358,7 @@
 	if (line1 < line0)
 		line1 = line0;
 
-	if (!plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, 0xffffff))
+	if (!plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white))
 		return false;
 
 	if (!line)
@@ -366,9 +366,9 @@
 
 	/* choose a suitable background colour for any highlighted text */
 	if ((background_colour & 0x808080) == 0x808080)
-		hback_col = 0;
-	else
-		hback_col = 0xffffff;
+            plot_style_highlight = plot_style_fill_black;
+        else
+            plot_style_highlight = plot_style_fill_white;
 
 	x += MARGIN * scale;
 	y += MARGIN * scale;
@@ -437,8 +437,9 @@
 
 				if (highlighted) {
 					int sy = y + (lineno * scaled_line_height);
-					if (!plot.fill(tx, sy, ntx, sy + scaled_line_height,
-							hback_col))
+					if (!plot.fill(tx, sy, 
+                                                       ntx, sy + scaled_line_height,
+							plot_style_highlight))
 						return false;
 				}
 			}
Index: render/html_redraw.c
===================================================================
--- render/html_redraw.c	(revision 8316)
+++ render/html_redraw.c	(working copy)
@@ -135,6 +135,10 @@
 {
 	struct box *box;
 	bool result, want_knockout;
+        plot_style_t pstyle_fill_bg = { 
+            .fill_type = PLOT_OP_TYPE_SOLID,
+            .fill_colour = background_colour,
+        };
 
 	box = c->data.html.layout;
 	assert(box);
@@ -145,13 +149,15 @@
 
 	/* clear to background colour */
 	result = plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
+
 	if (c->data.html.background_colour != TRANSPARENT)
-		background_colour = c->data.html.background_colour;
-	result &= plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, background_colour);
+		pstyle_fill_bg.fill_colour = c->data.html.background_colour;
 
+	result &= plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, &pstyle_fill_bg);
+
 	result &= html_redraw_box(box, x, y,
 			clip_x0, clip_y0, clip_x1, clip_y1,
-			scale, background_colour);
+			scale, pstyle_fill_bg.fill_colour);
 
 	if (want_knockout)
 		knockout_plot_end();
@@ -801,10 +807,10 @@
 		/* \todo make search terms visible within selected text */
 		if (highlighted) {
 			unsigned endtxt_idx = end_idx;
-			colour hfore_col, hback_col;
 			bool clip_changed = false;
 			bool text_visible = true;
 			int startx, endx;
+                        plot_style_t *pstyle_fill_hback = plot_style_fill_white; 
 
 			if (end_idx > utf8_len) {
 				/* adjust for trailing space, not present in
@@ -849,14 +855,12 @@
 			/* decide whether highlighted portion is to be
 			 * white-on-black or black-on-white */
 			if ((current_background_color & 0x808080) == 0x808080)
-				hback_col = 0;
-			else
-				hback_col = 0xffffff;
-			hfore_col = hback_col ^ 0xffffff;
+                            pstyle_fill_hback = plot_style_fill_black;
 
 			/* highlighted portion */
 			if (!plot.fill(x + startx, y, x + endx,
-					y + height * scale, hback_col))
+                                       y + height * scale, 
+                                       pstyle_fill_hback))
 				return false;
 
 			if (start_idx > 0) {
@@ -875,8 +879,9 @@
 
 			if (text_visible &&
 				!plot.text(x, y + (int) (height * 0.75 * scale),
-						style, utf8_text, endtxt_idx,
-						hback_col, hfore_col))
+                                           style, utf8_text, endtxt_idx,
+                                           pstyle_fill_hback->fill_colour, 
+                                           pstyle_fill_hback->fill_colour ^ 0xffffff))
 				return false;
 
 			/* draw any text succeeding highlighted portion */
@@ -1277,6 +1282,22 @@
 }
 
 
+
+#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.
  *
@@ -1288,8 +1309,6 @@
  * \return true if successful, false otherwise
  */
 
-#define WIDGET_BASEC 0xd9d9d9
-#define WIDGET_BLOBC 0x000000
 bool html_redraw_checkbox(int x, int y, int width, int height,
 		bool selected)
 {
@@ -1300,7 +1319,7 @@
 	if (z == 0)
 		z = 1;
 
-	if (!(plot.fill(x, y, x + width, y + height, WIDGET_BASEC) &&
+	if (!(plot.fill(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,
@@ -1314,7 +1333,7 @@
 			/* render a solid box instead of a tick */
 			if (!plot.fill(x + z + z, y + z + z,
 				x + width - z, y + height - z,
-				WIDGET_BLOBC))
+				&pstyle_fill_wblobc))
 				return false;
 		} else {
 			/* render a tick, as it'll fit comfortably */
@@ -1448,6 +1467,10 @@
 	int ox = x, oy = y;
 	int width, height;
 	struct box *parent;
+        plot_style_t pstyle_fill_bg = { 
+            .fill_type = PLOT_OP_TYPE_SOLID,
+            .fill_colour = *background_colour,
+        };
 
 	if (html_redraw_printing && option_remove_backgrounds)
 		return true;
@@ -1579,10 +1602,12 @@
 		if (background->style->background_color != TRANSPARENT) {
 			*background_colour =
 				background->style->background_color;
+                        pstyle_fill_bg.fill_colour = 
+                            background->style->background_color;
 			if (plot_colour)
 				if (!plot.fill(clip_x0, clip_y0,
 						clip_x1, clip_y1,
-						*background_colour))
+						&pstyle_fill_bg))
 					return false;
 		}
 		/* and plot the image */
@@ -1662,6 +1687,10 @@
 	bool repeat_y = false;
 	bool plot_colour = true;
 	bool plot_content;
+        plot_style_t pstyle_fill_bg = { 
+            .fill_type = PLOT_OP_TYPE_SOLID,
+            .fill_colour = *background_colour,
+        };
 
 	plot_content = (box->background != NULL);
 
@@ -1741,10 +1770,13 @@
 	if (box->style->background_color != TRANSPARENT) {
 		*background_colour =
 			box->style->background_color;
+                pstyle_fill_bg.fill_colour = 
+			box->style->background_color;
+
 		if (plot_colour)
 			if (!plot.fill(clip_x0, clip_y0,
 					clip_x1, clip_y1,
-					*background_colour))
+					&pstyle_fill_bg))
 				return false;
 	}
 	/* and plot the image */
@@ -1933,6 +1965,14 @@
 	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,
+            .fill_colour = css_scrollbar_bg_colour,
+        };
+        plot_style_t pstyle_css_scrollbar_fg_colour = { 
+            .fill_type = PLOT_OP_TYPE_SOLID,
+            .fill_colour = css_scrollbar_fg_colour,
+        };
 
 	box_scrollbar_dimensions(box, padding_width, padding_height, w,
 			&vscroll, &hscroll,
@@ -1976,7 +2016,7 @@
 				y + padding_height - w + 2,
 				x + w - 2,
 				y + padding_height - 2,
-				css_scrollbar_fg_colour))
+				&pstyle_css_scrollbar_fg_colour))
 			return false;
 		/* left arrow */
 		v[0] = x + w / 4;
@@ -1992,7 +2032,7 @@
 				y + padding_height - w + 1,
 				x + w + well_width + (vscroll ? 2 : 1),
 				y + padding_height - 1,
-				css_scrollbar_bg_colour))
+				&pstyle_css_scrollbar_bg_colour))
 			return false;
 		/* scroll position indicator bar */
 		RECTANGLE(x + w + bar_left,
@@ -2004,7 +2044,7 @@
 				y + padding_height - w + 2,
 				x + w + bar_left + bar_width + (vscroll? 1 : 0),
 				y + padding_height - 2,
-				css_scrollbar_fg_colour))
+				&pstyle_css_scrollbar_fg_colour))
 			return false;
 		/* right arrow icon border */
 		RECTANGLE(x + w + well_width + 2,
@@ -2017,7 +2057,7 @@
 				y + padding_height - w + 2,
 				x + w + well_width + w - (vscroll ? 1 : 2),
 				y + padding_height - 2,
-				css_scrollbar_fg_colour))
+				&pstyle_css_scrollbar_fg_colour))
 			return false;
 		/* right arrow */
 		v[0] = x + w + well_width + w * 3 / 4 + (vscroll ? 1 : 0);
@@ -2048,7 +2088,7 @@
 				y + 2,
 				x + padding_width - 2,
 				y + w - 2,
-				css_scrollbar_fg_colour))
+				&pstyle_css_scrollbar_fg_colour))
 			return false;
 		/* up arrow */
 		v[0] = x + padding_width - w / 2;
@@ -2064,7 +2104,7 @@
 				y + w - 1,
 				x + padding_width - 1,
 				y + padding_height - w + 1,
-				css_scrollbar_bg_colour))
+				&pstyle_css_scrollbar_bg_colour))
 			return false;
 		/* scroll position indicator bar */
 		RECTANGLE(x + padding_width - w + 1,
@@ -2076,7 +2116,7 @@
 				y + w + bar_top + 1,
 				x + padding_width - 2,
 				y + w + bar_top + bar_height,
-				css_scrollbar_fg_colour))
+				&pstyle_css_scrollbar_fg_colour))
 			return false;
 		/* bottom arrow background */
 		RECTANGLE(x + padding_width - w + 1,
@@ -2088,7 +2128,7 @@
 				y + padding_height - w + 2,
 				x + padding_width - 2,
 				y + padding_height - 2,
-				css_scrollbar_fg_colour))
+				&pstyle_css_scrollbar_fg_colour))
 			return false;
 		/* down arrow */
 		v[0] = x + padding_width - w / 2;
Index: framebuffer/framebuffer.c
===================================================================
--- framebuffer/framebuffer.c	(revision 8316)
+++ framebuffer/framebuffer.c	(working copy)
@@ -197,7 +197,19 @@
 	return true;
 }
 
+static bool 
+framebuffer_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
+{
+    nsfb_bbox_t rect;
+    rect.x0 = x0;
+    rect.y0 = y0;
+    rect.x1 = x1;
+    rect.y1 = y1;
 
+    return nsfb_plot_rectangle_fill(nsfb, &rect, style->fill_colour);
+
+}
+
 static bool framebuffer_plot_flush(void)
 {
 	LOG(("flush unimplemnted"));
@@ -220,7 +232,7 @@
 	.rectangle = nsfb_lplot_rectangle,
 	.line = nsfb_lplot_line,
 	.polygon = nsfb_lplot_polygon,
-	.fill = nsfb_lplot_fill,
+	.fill = framebuffer_plot_fill,
 	.clip = nsfb_lplot_clip,
 	.text = framebuffer_plot_text,
 	.disc = nsfb_lplot_disc,
Index: gtk/gtk_print.c
===================================================================
--- gtk/gtk_print.c	(revision 8316)
+++ gtk/gtk_print.c	(working copy)
@@ -52,7 +52,7 @@
 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]);
-static bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, colour c);
+static bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 static bool nsgtk_print_plot_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool nsgtk_print_plot_text(int x, int y, const struct css_style *style,
@@ -183,12 +183,12 @@
 }
 
 
-bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 	LOG(("Plotting fill. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", 
 			x0,y0,x1,y1));
 
-	nsgtk_print_set_colour(c);
+	nsgtk_print_set_colour(style->fill_colour);
 	nsgtk_print_set_solid();
 	
 	/* Normalize boundaries of the area - to prevent overflows.
Index: gtk/gtk_plotters.c
===================================================================
--- gtk/gtk_plotters.c	(revision 8316)
+++ gtk/gtk_plotters.c	(working copy)
@@ -56,7 +56,7 @@
 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, colour c);
+static bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, 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,
@@ -87,7 +87,7 @@
 	.arc = nsgtk_plot_arc,
 	.bitmap = nsgtk_plot_bitmap,
 	.path = nsgtk_plot_path,
-	.option_knockout = true
+        .option_knockout = true
 };
 
 
@@ -155,9 +155,9 @@
 }
 
 
-bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
-	nsgtk_set_colour(c);
+	nsgtk_set_colour(style->fill_colour);
 	nsgtk_set_solid();
 
 	cairo_set_line_width(current_cr, 0);
Index: gtk/gtk_thumbnail.c
===================================================================
--- gtk/gtk_thumbnail.c	(revision 8316)
+++ gtk/gtk_thumbnail.c	(working copy)
@@ -95,7 +95,7 @@
 #ifdef CAIRO_VERSION
 	current_cr = gdk_cairo_create(current_drawable);
 #endif
-	plot.fill(0, 0, cwidth, cwidth, 0xffffffff);
+	plot.fill(0, 0, cwidth, cwidth, plot_style_fill_white);
 
 	/* render the content */
 	content_redraw(content, 0, 0, content->width, content->width,
Index: beos/beos_plotters.cpp
===================================================================
--- beos/beos_plotters.cpp	(revision 8316)
+++ beos/beos_plotters.cpp	(working copy)
@@ -68,7 +68,7 @@
 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]);
-static bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c);
+static bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 static bool nsbeos_plot_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool nsbeos_plot_text(int x, int y, const struct css_style *style,
@@ -301,7 +301,7 @@
 }
 
 
-bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 	BView *view;
 
@@ -311,7 +311,7 @@
 		return false;
 	}
 
-	nsbeos_set_colour(c);
+	nsbeos_set_colour(style->fill_colour);
 
 	BRect rect(x0, y0, x1 - 1, y1 - 1);
 	view->FillRect(rect);
@@ -319,7 +319,7 @@
 	//nsbeos_current_gc_unlock();
 
 #if 0 /* GTK */
-	nsbeos_set_colour(c);
+	nsbeos_set_colour(style->fill_colour);
 	nsbeos_set_solid();
 #ifdef CAIRO_VERSION
 	if (option_render_cairo) {
Index: riscos/save_draw.c
===================================================================
--- riscos/save_draw.c	(revision 8316)
+++ riscos/save_draw.c	(working copy)
@@ -44,7 +44,7 @@
 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]);
-static bool ro_save_draw_fill(int x0, int y0, int x1, int y1, colour c);
+static bool ro_save_draw_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 static bool ro_save_draw_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool ro_save_draw_text(int x, int y, const struct css_style *style,
@@ -302,7 +302,7 @@
 }
 
 
-bool ro_save_draw_fill(int x0, int y0, int x1, int y1, colour c)
+bool ro_save_draw_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 	pencil_code code;
 	const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1,
@@ -313,10 +313,11 @@
 			draw_END_PATH };
 
 	code = pencil_path(ro_save_draw_diagram, path,
-			sizeof path / sizeof path[0],
-			c << 8, pencil_TRANSPARENT, 0, pencil_JOIN_MITRED,
-			pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
-			pencil_SOLID);
+                           sizeof path / sizeof path[0],
+                           style->fill_colour << 8, 
+                           pencil_TRANSPARENT, 0, pencil_JOIN_MITRED,
+                           pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
+                           pencil_SOLID);
 	if (code != pencil_OK)
 		return ro_save_draw_error(code);
 
Index: riscos/plotters.c
===================================================================
--- riscos/plotters.c	(revision 8316)
+++ riscos/plotters.c	(working copy)
@@ -43,7 +43,7 @@
 static bool ro_plot_polygon(const int *p, unsigned int n, colour fill);
 static bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
 		colour c, const float transform[6]);
-static bool ro_plot_fill(int x0, int y0, int x1, int y1, colour c);
+static bool ro_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 static bool ro_plot_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool ro_plot_text(int x, int y, const struct css_style *style,
@@ -303,12 +303,13 @@
 }
 
 
-bool ro_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool ro_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 	os_error *error;
 
-	error = xcolourtrans_set_gcol(c << 8, colourtrans_USE_ECFS_GCOL,
-			os_ACTION_OVERWRITE, 0, 0);
+	error = xcolourtrans_set_gcol(style->fill_colour << 8, 
+                                      colourtrans_USE_ECFS_GCOL,
+                                      os_ACTION_OVERWRITE, 0, 0);
 	if (error) {
 		LOG(("xcolourtrans_set_gcol: 0x%x: %s",
 				error->errnum, error->errmess));
Index: riscos/print.c
===================================================================
--- riscos/print.c	(revision 8316)
+++ riscos/print.c	(working copy)
@@ -102,7 +102,7 @@
 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_polygon(const int *p, unsigned int n, colour fill);
-static bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c);
+static bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 static bool print_fonts_plot_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool print_fonts_plot_text(int x, int y, const struct css_style *style,
@@ -824,7 +824,7 @@
 	return true;
 }
 
-bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 	return true;
 }
Index: desktop/save_pdf/pdf_plotters.c
===================================================================
--- desktop/save_pdf/pdf_plotters.c	(revision 8316)
+++ desktop/save_pdf/pdf_plotters.c	(working copy)
@@ -50,7 +50,7 @@
 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_polygon(const int *p, unsigned int n, colour fill);
-static bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c);
+static bool pdf_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 static bool pdf_plot_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool pdf_plot_text(int x, int y, const struct css_style *style,
@@ -214,13 +214,13 @@
 	return true;
 }
 
-bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool pdf_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 #ifdef PDF_DEBUG
-	LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, c));
+	LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, style->fill_colour));
 #endif
 
-	apply_clip_and_mode(false, c, TRANSPARENT, 0., DashPattern_eNone);
+	apply_clip_and_mode(false, style->fill_colour, TRANSPARENT, 0., DashPattern_eNone);
 
 	/*Normalize boundaries of the area - to prevent overflows.
 	  It is needed only in a few functions, where integers are subtracted.
Index: desktop/textarea.c
===================================================================
--- desktop/textarea.c	(revision 8316)
+++ desktop/textarea.c	(working copy)
@@ -41,6 +41,10 @@
 #define BORDER_COLOR 0x000000
 #define SELECTION_COL 0xFFDDDD
 
+static plot_style_t plot_style_fill_selection = { 
+    .fill_type = PLOT_OP_TYPE_SOLID,
+    .fill_colour = SELECTION_COL,
+};
 
 struct line_info {
 	unsigned int b_start;		/**< Byte offset of line start */
@@ -713,6 +717,10 @@
 	int chars, offset;
 	unsigned int c_pos, c_len, b_start, b_end, line_len;
 	char *line_text;
+        plot_style_t plot_style_fill_bg = { 
+            .fill_type = PLOT_OP_TYPE_SOLID,
+            .fill_colour = BACKGROUND_COL,
+        };
 
 	
 	if (x1 < ta->x || x0 > ta->x + ta->vis_width || y1 < ta->y ||
@@ -723,6 +731,9 @@
 	if (ta->lines == NULL)
 		/* Nothing to redraw */
 		return;
+
+        if (ta->flags & TEXTAREA_READONLY)
+            plot_style_fill_bg.fill_colour = READONLY_BG;
 	
 	line0 = (y0 - ta->y + ta->scroll_y) / ta->line_height - 1;
 	line1 = (y1 - ta->y + ta->scroll_y) / ta->line_height + 1;
@@ -748,8 +759,7 @@
 		y1 = ta->y + ta->vis_height;
 	
 	plot.clip(x0, y0, x1, y1);
-	plot.fill(x0, y0, x1, y1, (ta->flags & TEXTAREA_READONLY) ?
-			READONLY_BG : BACKGROUND_COL);
+	plot.fill(x0, y0, x1, y1, &plot_style_fill_bg);
 	plot.rectangle(ta->x, ta->y, ta->vis_width - 1, ta->vis_height - 1, 1,
 			BORDER_COLOR, false, false);
 	
@@ -837,7 +847,7 @@
 					x1 - ta->scroll_x,
      					ta->y + (line + 1) * ta->line_height -
 					1 - ta->scroll_y,
-				 	SELECTION_COL);
+				 	&plot_style_fill_selection);
 			
 		}
 		
Index: desktop/plotters.h
===================================================================
--- desktop/plotters.h	(revision 8316)
+++ desktop/plotters.h	(working copy)
@@ -35,6 +35,25 @@
 #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;
+
+extern plot_style_t *plot_style_fill_white;
+extern plot_style_t *plot_style_fill_black;
+
 /** Set of target specific plotting functions.
  *
  * The functions are:
@@ -99,7 +118,7 @@
 	bool (*line)(int x0, int y0, int x1, int y1, int width,
 			colour c, bool dotted, bool dashed);
 	bool (*polygon)(const int *p, unsigned int n, colour fill);
-	bool (*fill)(int x0, int y0, int x1, int y1, colour c);
+	bool (*fill)(int x0, int y0, int x1, int y1, plot_style_t *style);
 	bool (*clip)(int x0, int y0, int x1, int y1);
 	bool (*text)(int x, int y, const struct css_style *style,
 			const char *text, size_t length, colour bg, colour c);
Index: desktop/knockout.c
===================================================================
--- desktop/knockout.c	(revision 8316)
+++ desktop/knockout.c	(working copy)
@@ -75,14 +75,27 @@
 #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_black_static = { 
+    .fill_type = PLOT_OP_TYPE_SOLID,
+    .fill_colour = 0x0,
+};
+
+plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
+plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
+
 struct knockout_box;
 struct knockout_entry;
 
 
 static void knockout_set_plotters(void);
 static void knockout_calculate(int x0, int y0, int x1, int y1, struct knockout_box *box);
-static bool knockout_plot_fill_recursive(struct knockout_box *box, colour c);
+static bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t *plot_style);
 static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
 		struct knockout_entry *entry);
 
@@ -91,7 +104,7 @@
 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_polygon(const int *p, unsigned int n, colour fill);
-static bool knockout_plot_fill(int x0, int y0, int x1, int y1, colour c);
+static bool knockout_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *plot_style);
 static bool knockout_plot_clip(int clip_x0, int clip_y0,
 		int clip_x1, int clip_y1);
 static bool knockout_plot_text(int x, int y, const struct css_style *style,
@@ -189,7 +202,7 @@
 			int y0;
 			int x1;
 			int y1;
-			colour c;
+			plot_style_t plot_style;
 		} fill;
 		struct {
 			int x0;
@@ -349,14 +362,14 @@
 			box = knockout_entries[i].box->child;
 			if (box)
 				success &= knockout_plot_fill_recursive(box,
-						knockout_entries[i].data.fill.c);
+						&knockout_entries[i].data.fill.plot_style);
 			else if (!knockout_entries[i].box->deleted)
 				success &= plot.fill(
 						knockout_entries[i].data.fill.x0,
 						knockout_entries[i].data.fill.y0,
 						knockout_entries[i].data.fill.x1,
 						knockout_entries[i].data.fill.y1,
-						knockout_entries[i].data.fill.c);
+						&knockout_entries[i].data.fill.plot_style);
 			break;
 		case KNOCKOUT_PLOT_CLIP:
 			success &= plot.clip(
@@ -575,7 +588,7 @@
 }
 
 
-bool knockout_plot_fill_recursive(struct knockout_box *box, colour c)
+bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t *plot_style)
 {
 	bool success = true;
 	struct knockout_box *parent;
@@ -584,13 +597,13 @@
 		if (parent->deleted)
 			continue;
 		if (parent->child)
-			knockout_plot_fill_recursive(parent->child, c);
+			knockout_plot_fill_recursive(parent->child, plot_style);
 		else
 			success &= plot.fill(parent->bbox.x0,
 					parent->bbox.y0,
 					parent->bbox.x1,
 					parent->bbox.y1,
-					c);
+					plot_style);
 	}
 	return success;
 }
@@ -700,7 +713,7 @@
 }
 
 
-bool knockout_plot_fill(int x0, int y0, int x1, int y1, colour c)
+bool knockout_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *plot_style)
 {
 	int kx0, ky0, kx1, ky1;
 
@@ -728,7 +741,7 @@
 	knockout_entries[knockout_entry_cur].data.fill.y0 = y0;
 	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.c = c;
+	knockout_entries[knockout_entry_cur].data.fill.plot_style = *plot_style;
 	knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_FILL;
 	if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) ||
 			(++knockout_box_cur >= KNOCKOUT_BOXES))
Index: amiga/plotters.c
===================================================================
--- amiga/plotters.c	(revision 8316)
+++ amiga/plotters.c	(working copy)
@@ -235,13 +235,13 @@
 	return true;
 }
 
-bool ami_fill(int x0, int y0, int x1, int y1, colour c)
+bool ami_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
 {
 #ifndef NS_AMIGA_CAIRO_ALL
 	p96RectFill(currp,x0,y0,x1-1,y1-1,
-		p96EncodeColor(RGBFB_A8B8G8R8,c));
+		p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour));
 #else
-	ami_cairo_set_colour(glob.cr,c);
+	ami_cairo_set_colour(glob.cr, style->fill_colour);
 	ami_cairo_set_solid(glob.cr);
 
 	cairo_set_line_width(glob.cr, 0);
Index: amiga/plotters.h
===================================================================
--- amiga/plotters.h	(revision 8316)
+++ amiga/plotters.h	(working copy)
@@ -28,7 +28,7 @@
 bool ami_line(int x0, int y0, int x1, int y1, int width,
 			colour c, bool dotted, bool dashed);
 bool ami_polygon(const int *p, unsigned int n, colour fill);
-bool ami_fill(int x0, int y0, int x1, int y1, colour c);
+bool ami_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
 bool ami_clip(int x0, int y0, int x1, int y1);
 bool ami_text(int x, int y, const struct css_style *style,
 			const char *text, size_t length, colour bg, colour c);

Attachment: signature.asc
Description: Digital signature

Reply via email to