ref: 64e114cce121e55f0f90cb5692c5020d917aa202
parent: 8dd7ee300726872072075a5cdb35ebe9497e3adb
author: Simon Tatham <anakin@pobox.com>
date: Sun Jul 3 05:35:29 EDT 2005
draw_polygon() and draw_circle() have always had a portability constraint: because some front ends interpret `draw filled shape' to mean `including its boundary' while others interpret it to mean `not including its boundary' (and X seems to vacillate between the two opinions as it moves around the shape!), you MUST NOT draw a filled shape only. You can fill in one colour and outline in another, you can fill or outline in the same colour, or you can just outline, but just filling is a no-no. This leads to a _lot_ of double calls to these functions, so I've changed the interface. draw_circle() and draw_polygon() now each take two colour arguments, a fill colour (which can be -1 for none) and an outline colour (which must be valid). This should simplify code in the game back ends, while also reducing the possibility for coding error. [originally from svn r6047]
--- a/cube.c
+++ b/cube.c
@@ -1568,9 +1568,9 @@
+ ds->oy);
}
- draw_polygon(fe, coords, state->squares[i].npoints, TRUE,
- state->squares[i].blue ? COL_BLUE : COL_BACKGROUND);
- draw_polygon(fe, coords, state->squares[i].npoints, FALSE, COL_BORDER);
+ draw_polygon(fe, coords, state->squares[i].npoints,
+ state->squares[i].blue ? COL_BLUE : COL_BACKGROUND,
+ COL_BORDER);
}
/*
@@ -1650,9 +1650,9 @@
continue;
}
- draw_polygon(fe, coords, poly->order, TRUE,
- state->facecolours[i] ? COL_BLUE : COL_BACKGROUND);
- draw_polygon(fe, coords, poly->order, FALSE, COL_BORDER);
+ draw_polygon(fe, coords, poly->order,
+ state->facecolours[i] ? COL_BLUE : COL_BACKGROUND,
+ COL_BORDER);
}
sfree(poly);
--- a/fifteen.c
+++ b/fifteen.c
@@ -654,13 +654,11 @@
coords[3] = y;
coords[4] = x;
coords[5] = y + TILE_SIZE - 1;
- draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 3, COL_LOWLIGHT, COL_LOWLIGHT);
coords[0] = x;
coords[1] = y;
- draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);
draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -709,13 +707,11 @@
coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
coords[6] = coords[8] + TILE_SIZE;
coords[7] = coords[9] - TILE_SIZE;
- draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
- draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
ds->started = TRUE;
}
--- a/flip.c
+++ b/flip.c
@@ -1059,8 +1059,7 @@
if (animtime < 0.5)
colour = COL_WRONG + COL_RIGHT - colour;
- draw_polygon(fe, coords, 4, TRUE, colour);
- draw_polygon(fe, coords, 4, FALSE, COL_GRID);
+ draw_polygon(fe, coords, 4, colour, COL_GRID);
}
/*
--- a/gtk.c
+++ b/gtk.c
@@ -348,7 +348,7 @@
}
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
GdkPoint *points = snewn(npoints, GdkPoint);
int i;
@@ -358,19 +358,32 @@
points[i].y = coords[i*2+1];
}
- gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
- gdk_draw_polygon(fe->pixmap, fe->gc, fill, points, npoints);
+ if (fillcolour >= 0) {
+ gdk_gc_set_foreground(fe->gc, &fe->colours[fillcolour]);
+ gdk_draw_polygon(fe->pixmap, fe->gc, TRUE, points, npoints);
+ }
+ assert(outlinecolour >= 0);
+ gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
+ gdk_draw_polygon(fe->pixmap, fe->gc, FALSE, points, npoints);
sfree(points);
}
void draw_circle(frontend *fe, int cx, int cy, int radius,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
- gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
- gdk_draw_arc(fe->pixmap, fe->gc, fill,
- cx - radius, cy - radius,
- 2 * radius, 2 * radius, 0, 360 * 64);
+ if (fillcolour >= 0) {
+ gdk_gc_set_foreground(fe->gc, &fe->colours[fillcolour]);
+ gdk_draw_arc(fe->pixmap, fe->gc, TRUE,
+ cx - radius, cy - radius,
+ 2 * radius, 2 * radius, 0, 360 * 64);
+ }
+
+ assert(outlinecolour >= 0);
+ gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
+ gdk_draw_arc(fe->pixmap, fe->gc, FALSE,
+ cx - radius, cy - radius,
+ 2 * radius, 2 * radius, 0, 360 * 64);
}
struct blitter {
--- a/guess.c
+++ b/guess.c
@@ -1021,8 +1021,8 @@
draw_rect(fe, cx-CGAP, cy-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2,
COL_BACKGROUND);
if (PEGRAD > 0) {
- draw_circle(fe, cx+PEGRAD, cy+PEGRAD, PEGRAD, 1, COL_EMPTY + col);
- draw_circle(fe, cx+PEGRAD, cy+PEGRAD, PEGRAD, 0, COL_EMPTY + col);
+ draw_circle(fe, cx+PEGRAD, cy+PEGRAD, PEGRAD,
+ COL_EMPTY + col, COL_EMPTY + col);
} else
draw_rect(fe, cx, cy, PEGSZ, PEGSZ, COL_EMPTY + col);
draw_update(fe, cx-CGAP, cy-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2);
@@ -1030,7 +1030,7 @@
static void draw_cursor(frontend *fe, game_drawstate *ds, int x, int y)
{
- draw_circle(fe, x+PEGRAD, y+PEGRAD, PEGRAD+CGAP, 0, COL_CURSOR);
+ draw_circle(fe, x+PEGRAD, y+PEGRAD, PEGRAD+CGAP, -1, COL_CURSOR);
draw_update(fe, x-CGAP, y-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2);
}
@@ -1129,8 +1129,7 @@
rowy += HINTOFF;
}
if (HINTRAD > 0) {
- draw_circle(fe, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, 1, col);
- draw_circle(fe, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, 0, col);
+ draw_circle(fe, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, col, col);
} else {
draw_rect(fe, rowx, rowy, HINTSZ, HINTSZ, col);
}
--- a/mines.c
+++ b/mines.c
@@ -2751,13 +2751,12 @@
coords[3] = y;
coords[4] = x;
coords[5] = y + TILE_SIZE - 1;
- draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT ^ hl);
- draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT ^ hl);
+ draw_polygon(fe, coords, 3, COL_LOWLIGHT ^ hl, COL_LOWLIGHT ^ hl);
coords[0] = x;
coords[1] = y;
- draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT ^ hl);
- draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT ^ hl);
+ draw_polygon(fe, coords, 3, COL_HIGHLIGHT ^ hl,
+ COL_HIGHLIGHT ^ hl);
draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -2778,14 +2777,12 @@
SETCOORD(3, 0.25, 0.8);
SETCOORD(4, 0.55, 0.7);
SETCOORD(5, 0.55, 0.35);
- draw_polygon(fe, coords, 6, TRUE, COL_FLAGBASE);
- draw_polygon(fe, coords, 6, FALSE, COL_FLAGBASE);
+ draw_polygon(fe, coords, 6, COL_FLAGBASE, COL_FLAGBASE);
SETCOORD(0, 0.6, 0.2);
SETCOORD(1, 0.6, 0.5);
SETCOORD(2, 0.2, 0.35);
- draw_polygon(fe, coords, 3, TRUE, COL_FLAG);
- draw_polygon(fe, coords, 3, FALSE, COL_FLAG);
+ draw_polygon(fe, coords, 3, COL_FLAG, COL_FLAG);
#undef SETCOORD
} else if (v == -3) {
@@ -2863,8 +2860,7 @@
xdy = -tdy;
}
- draw_polygon(fe, coords, 5*4, TRUE, COL_MINE);
- draw_polygon(fe, coords, 5*4, FALSE, COL_MINE);
+ draw_polygon(fe, coords, 5*4, COL_MINE, COL_MINE);
draw_rect(fe, cx-r/3, cy-r/3, r/3, r/4, COL_HIGHLIGHT);
}
@@ -2929,13 +2925,11 @@
coords[9] = COORD(state->h) + OUTER_HIGHLIGHT_WIDTH - 1;
coords[6] = coords[8] + TILE_SIZE;
coords[7] = coords[9] - TILE_SIZE;
- draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
coords[1] = COORD(0) - OUTER_HIGHLIGHT_WIDTH;
coords[0] = COORD(0) - OUTER_HIGHLIGHT_WIDTH;
- draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
ds->started = TRUE;
}
@@ -3091,7 +3085,7 @@
void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) {}
void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) {}
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour) {}
+ int fillcolour, int outlinecolour) {}
void clip(frontend *fe, int x, int y, int w, int h) {}
void unclip(frontend *fe) {}
void start_draw(frontend *fe) {}
--- a/net.c
+++ b/net.c
@@ -2405,8 +2405,7 @@
points[i+1] = by+(int)(cy+ty);
}
- draw_polygon(fe, points, 4, TRUE, col);
- draw_polygon(fe, points, 4, FALSE, COL_WIRE);
+ draw_polygon(fe, points, 4, col, COL_WIRE);
}
/*
--- a/netslide.c
+++ b/netslide.c
@@ -1436,8 +1436,7 @@
points[i+1] = by+(int)(cy+ey);
}
- draw_polygon(fe, points, 4, TRUE, col);
- draw_polygon(fe, points, 4, FALSE, COL_WIRE);
+ draw_polygon(fe, points, 4, col, COL_WIRE);
}
/*
@@ -1533,8 +1532,7 @@
POINT(5, 3 * TILE_SIZE / 8, TILE_SIZE / 2); /* left concave */
POINT(6, TILE_SIZE / 4, TILE_SIZE / 2); /* left corner */
- draw_polygon(fe, coords, 7, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 7, FALSE, COL_TEXT);
+ draw_polygon(fe, coords, 7, COL_LOWLIGHT, COL_TEXT);
}
static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
--- a/osx.m
+++ b/osx.m
@@ -1216,7 +1216,7 @@
* Drawing routines called by the midend.
*/
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
NSBezierPath *path = [NSBezierPath bezierPath];
int i;
@@ -1223,9 +1223,6 @@
[[NSGraphicsContext currentContext] setShouldAntialias:YES];
- assert(colour >= 0 && colour < fe->ncolours);
- [fe->colours[colour] set];
-
for (i = 0; i < npoints; i++) {
NSPoint p = { coords[i*2] + 0.5, coords[i*2+1] + 0.5 };
if (i == 0)
@@ -1236,30 +1233,37 @@
[path closePath];
- if (fill)
+ if (fillcolour >= 0) {
+ assert(fillcolour >= 0 && fillcolour < fe->ncolours);
+ [fe->colours[fillcolour] set];
[path fill];
- else
- [path stroke];
+ }
+
+ assert(outlinecolour >= 0 && outlinecolour < fe->ncolours);
+ [fe->colours[outlinecolour] set];
+ [path stroke];
}
void draw_circle(frontend *fe, int cx, int cy, int radius,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
NSBezierPath *path = [NSBezierPath bezierPath];
[[NSGraphicsContext currentContext] setShouldAntialias:YES];
- assert(colour >= 0 && colour < fe->ncolours);
- [fe->colours[colour] set];
-
[path appendBezierPathWithArcWithCenter:NSMakePoint(cx + 0.5, cy + 0.5)
radius:radius startAngle:0.0 endAngle:360.0];
[path closePath];
- if (fill)
+ if (fillcolour >= 0) {
+ assert(fillcolour >= 0 && fillcolour < fe->ncolours);
+ [fe->colours[fillcolour] set];
[path fill];
- else
- [path stroke];
+ }
+
+ assert(outlinecolour >= 0 && outlinecolour < fe->ncolours);
+ [fe->colours[outlinecolour] set];
+ [path stroke];
}
void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
{
--- a/pattern.c
+++ b/pattern.c
@@ -1215,8 +1215,6 @@
int align, int colour, char *text) {}
void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) {}
void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) {}
-void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour) {}
void clip(frontend *fe, int x, int y, int w, int h) {}
void unclip(frontend *fe) {}
void start_draw(frontend *fe) {}
--- a/puzzles.h
+++ b/puzzles.h
@@ -136,9 +136,9 @@
void draw_rect(frontend *fe, int x, int y, int w, int h, int colour);
void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour);
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour);
+ int fillcolour, int outlinecolour);
void draw_circle(frontend *fe, int cx, int cy, int radius,
- int fill, int colour);
+ int fillcolour, int outlinecolour);
void clip(frontend *fe, int x, int y, int w, int h);
void unclip(frontend *fe);
void start_draw(frontend *fe);
--- a/samegame.c
+++ b/samegame.c
@@ -883,13 +883,11 @@
coords[9] = COORD(state->params.h) + HIGHLIGHT_WIDTH - 1 - TILE_GAP;
coords[6] = coords[8] + TILE_SIZE;
coords[7] = coords[9] - TILE_SIZE;
- draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
- draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
ds->started = 1;
}
--- a/sixteen.c
+++ b/sixteen.c
@@ -778,13 +778,11 @@
coords[3] = y;
coords[4] = x;
coords[5] = y + TILE_SIZE - 1;
- draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 3, COL_LOWLIGHT, COL_LOWLIGHT);
coords[0] = x;
coords[1] = y;
- draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);
draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -816,8 +814,7 @@
POINT(5, 3 * TILE_SIZE / 8, TILE_SIZE / 2); /* left concave */
POINT(6, TILE_SIZE / 4, TILE_SIZE / 2); /* left corner */
- draw_polygon(fe, coords, 7, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 7, FALSE, COL_TEXT);
+ draw_polygon(fe, coords, 7, COL_LOWLIGHT, COL_TEXT);
}
static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
@@ -855,13 +852,11 @@
coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
coords[6] = coords[8] + TILE_SIZE;
coords[7] = coords[9] - TILE_SIZE;
- draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
- draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
/*
* Arrows for making moves.
--- a/solo.c
+++ b/solo.c
@@ -2215,7 +2215,7 @@
coords[3] = cy;
coords[4] = cx;
coords[5] = cy+ch/2;
- draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);
}
/* new number needs drawing? */
@@ -2438,7 +2438,7 @@
void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) {}
void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) {}
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour) {}
+ int fillcolour, int outlinecolour) {}
void clip(frontend *fe, int x, int y, int w, int h) {}
void unclip(frontend *fe) {}
void start_draw(frontend *fe) {}
--- a/twiddle.c
+++ b/twiddle.c
@@ -880,29 +880,29 @@
coords[2] = x + TILE_SIZE - 1;
coords[3] = y;
rotate(coords+2, rot);
- draw_polygon(fe, coords, 3, TRUE, rot ? rot->rc : COL_LOWLIGHT);
- draw_polygon(fe, coords, 3, FALSE, rot ? rot->rc : COL_LOWLIGHT);
+ draw_polygon(fe, coords, 3, rot ? rot->rc : COL_LOWLIGHT,
+ rot ? rot->rc : COL_LOWLIGHT);
/* Bottom side. */
coords[2] = x;
coords[3] = y + TILE_SIZE - 1;
rotate(coords+2, rot);
- draw_polygon(fe, coords, 3, TRUE, rot ? rot->bc : COL_LOWLIGHT);
- draw_polygon(fe, coords, 3, FALSE, rot ? rot->bc : COL_LOWLIGHT);
+ draw_polygon(fe, coords, 3, rot ? rot->bc : COL_LOWLIGHT,
+ rot ? rot->bc : COL_LOWLIGHT);
/* Left side. */
coords[0] = x;
coords[1] = y;
rotate(coords+0, rot);
- draw_polygon(fe, coords, 3, TRUE, rot ? rot->lc : COL_HIGHLIGHT);
- draw_polygon(fe, coords, 3, FALSE, rot ? rot->lc : COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 3, rot ? rot->lc : COL_HIGHLIGHT,
+ rot ? rot->lc : COL_HIGHLIGHT);
/* Top side. */
coords[2] = x + TILE_SIZE - 1;
coords[3] = y;
rotate(coords+2, rot);
- draw_polygon(fe, coords, 3, TRUE, rot ? rot->tc : COL_HIGHLIGHT);
- draw_polygon(fe, coords, 3, FALSE, rot ? rot->tc : COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 3, rot ? rot->tc : COL_HIGHLIGHT,
+ rot ? rot->tc : COL_HIGHLIGHT);
/*
* Now the main blank area in the centre of the tile.
@@ -920,8 +920,7 @@
coords[6] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
coords[7] = y + HIGHLIGHT_WIDTH;
rotate(coords+6, rot);
- draw_polygon(fe, coords, 4, TRUE, flash_colour);
- draw_polygon(fe, coords, 4, FALSE, flash_colour);
+ draw_polygon(fe, coords, 4, flash_colour, flash_colour);
} else {
draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -967,8 +966,7 @@
coords[4] = cx - displ * ydx;
coords[5] = cy - displ * ydy;
rotate(coords+4, rot);
- draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT_GENTLE);
- draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT_GENTLE);
+ draw_polygon(fe, coords, 3, COL_LOWLIGHT_GENTLE, COL_LOWLIGHT_GENTLE);
}
coords[0] = x + TILE_SIZE/2;
@@ -1082,13 +1080,11 @@
coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
coords[6] = coords[8] + TILE_SIZE;
coords[7] = coords[9] - TILE_SIZE;
- draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+ draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
- draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+ draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
ds->started = TRUE;
}
--- a/windows.c
+++ b/windows.c
@@ -333,26 +333,28 @@
}
void draw_circle(frontend *fe, int cx, int cy, int radius,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
- if (fill) {
- HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[colour]);
- HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
+ assert(outlinecolour >= 0);
+
+ if (fillcolour >= 0) {
+ HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[fillcolour]);
+ HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
Ellipse(fe->hdc_bm, cx - radius, cy - radius,
cx + radius + 1, cy + radius + 1);
SelectObject(fe->hdc_bm, oldbrush);
SelectObject(fe->hdc_bm, oldpen);
} else {
- HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
- Arc(fe->hdc_bm, cx - radius, cy - radius,
- cx + radius + 1, cy + radius + 1,
- cx - radius, cy, cx - radius, cy);
+ HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
+ Arc(fe->hdc_bm, cx - radius, cy - radius,
+ cx + radius + 1, cy + radius + 1,
+ cx - radius, cy, cx - radius, cy);
SelectObject(fe->hdc_bm, oldpen);
}
}
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
POINT *pts = snewn(npoints+1, POINT);
int i;
@@ -363,14 +365,16 @@
pts[i].y = coords[j*2+1];
}
- if (fill) {
- HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[colour]);
- HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
+ assert(outlinecolour >= 0);
+
+ if (fillcolour >= 0) {
+ HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[fillcolour]);
+ HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
Polygon(fe->hdc_bm, pts, npoints);
SelectObject(fe->hdc_bm, oldbrush);
SelectObject(fe->hdc_bm, oldpen);
} else {
- HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
+ HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
Polyline(fe->hdc_bm, pts, npoints+1);
SelectObject(fe->hdc_bm, oldpen);
}