From 407f29c46f35910ce3d7ddd41f13e94213c2597e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 22 Feb 2009 12:05:38 +0000 Subject: Introduce some infrastructure to permit games' print functions to draw dotted lines. No puzzle yet uses this, but one's about to. [originally from svn r8453] --- windows.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'windows.c') diff --git a/windows.c b/windows.c index 6bcf895..6249d55 100644 --- a/windows.c +++ b/windows.c @@ -225,7 +225,7 @@ struct frontend { int printoffsetx, printoffsety; float printpixelscale; int fontstart; - int linewidth; + int linewidth, linedotted; drawing *dr; int xmin, ymin; float puzz_scale; @@ -493,12 +493,16 @@ static void win_set_pen(frontend *fe, int colour, int thin) float r, g, b; int width = thin ? 0 : fe->linewidth; + if (fe->linedotted) + width = 0; + print_get_colour(fe->dr, colour, fe->printcolour, &hatch, &r, &g, &b); /* * Stroking in hatched colours is not permitted. */ assert(hatch < 0); - pen = CreatePen(PS_SOLID, width, RGB(r * 255, g * 255, b * 255)); + pen = CreatePen(fe->linedotted ? PS_DOT : PS_SOLID, + width, RGB(r * 255, g * 255, b * 255)); } else { pen = fe->pens[colour]; } @@ -792,6 +796,17 @@ static void win_line_width(void *handle, float width) fe->linewidth = (int)(width * fe->printpixelscale); } +static void win_line_dotted(void *handle, int dotted) +{ + frontend *fe = (frontend *)handle; + + assert(fe->drawstatus != DRAWING); + if (fe->drawstatus == NOTHING) + return; + + fe->linedotted = dotted; +} + static void win_begin_doc(void *handle, int pages) { frontend *fe = (frontend *)handle; @@ -882,6 +897,7 @@ static void win_begin_puzzle(void *handle, float xm, float xc, fe->printpixelscale = scale; fe->linewidth = 1; + fe->linedotted = FALSE; } static void win_end_puzzle(void *handle) @@ -963,6 +979,7 @@ const struct drawing_api win_drawing = { win_end_page, win_end_doc, win_line_width, + win_line_dotted, }; void print(frontend *fe) -- cgit v1.1