aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel.but16
-rw-r--r--drawing.c5
-rw-r--r--nestedvm.c2
-rw-r--r--nullfe.c1
-rw-r--r--ps.c12
-rw-r--r--puzzles.h2
-rw-r--r--windows.c21
7 files changed, 56 insertions, 3 deletions
diff --git a/devel.but b/devel.but
index 134cf13..67c1659 100644
--- a/devel.but
+++ b/devel.but
@@ -2143,6 +2143,22 @@ however, that it is a hint only: the central printing system may
choose to vary line thicknesses at user request or due to printer
capabilities.
+\S{print-line-width} \cw{print_line_dotted()}
+
+\c void print_line_dotted(drawing *dr, int dotted);
+
+This function is called to toggle the drawing of dotted lines during
+printing. It is not supported during drawing.
+
+The parameter \cq{dotted} is a boolean; \cw{TRUE} means that future
+lines drawn by \cw{draw_line()}, \cw{draw_circle} and
+\cw{draw_polygon()} will be dotted, and \cw{FALSE} means that they
+will be solid.
+
+Some front ends may impose restrictions on the width of dotted
+lines. Asking for a dotted line via this front end will override any
+line width request if the front end requires it.
+
\H{drawing-frontend} The drawing API as implemented by the front end
This section describes the drawing API in the function-pointer form
diff --git a/drawing.c b/drawing.c
index b582b8f..26df1ff 100644
--- a/drawing.c
+++ b/drawing.c
@@ -283,3 +283,8 @@ void print_line_width(drawing *dr, int width)
*/
dr->api->line_width(dr->handle, (float)sqrt(dr->scale) * width);
}
+
+void print_line_dotted(drawing *dr, int dotted)
+{
+ dr->api->line_dotted(dr->handle, dotted);
+}
diff --git a/nestedvm.c b/nestedvm.c
index 757b65f..2bbf4e3 100644
--- a/nestedvm.c
+++ b/nestedvm.c
@@ -184,7 +184,7 @@ const struct drawing_api nestedvm_drawing = {
nestedvm_blitter_save,
nestedvm_blitter_load,
NULL, NULL, NULL, NULL, NULL, NULL, /* {begin,end}_{doc,page,puzzle} */
- NULL, /* line_width */
+ NULL, NULL, /* line_width, line_dotted */
};
int jcallback_key_event(int x, int y, int keyval)
diff --git a/nullfe.c b/nullfe.c
index 2ecd238..325fd5a 100644
--- a/nullfe.c
+++ b/nullfe.c
@@ -36,6 +36,7 @@ int print_rgb_grey_colour(drawing *dr, float r, float g, float b, float grey)
int print_rgb_hatched_colour(drawing *dr, float r, float g, float b, int hatch)
{ return 0; }
void print_line_width(drawing *dr, int width) {}
+void print_line_dotted(drawing *dr, int dotted) {}
void midend_supersede_game_desc(midend *me, char *desc, char *privdesc) {}
void status_bar(drawing *dr, char *text) {}
diff --git a/ps.c b/ps.c
index 9f2c17f..f6a71bb 100644
--- a/ps.c
+++ b/ps.c
@@ -231,6 +231,17 @@ static void ps_line_width(void *handle, float width)
ps_printf(ps, "%g setlinewidth\n", width);
}
+static void ps_line_dotted(void *handle, int dotted)
+{
+ psdata *ps = (psdata *)handle;
+
+ if (dotted) {
+ ps_printf(ps, "[ currentlinewidth 3 mul ] 0 setdash\n");
+ } else {
+ ps_printf(ps, "[ ] 0 setdash\n");
+ }
+}
+
static void ps_begin_doc(void *handle, int pages)
{
psdata *ps = (psdata *)handle;
@@ -321,6 +332,7 @@ static const struct drawing_api ps_drawing = {
ps_end_page,
ps_end_doc,
ps_line_width,
+ ps_line_dotted,
};
psdata *ps_init(FILE *outfile, int colour)
diff --git a/puzzles.h b/puzzles.h
index a1acada..0e0cf97 100644
--- a/puzzles.h
+++ b/puzzles.h
@@ -217,6 +217,7 @@ int print_rgb_grey_colour(drawing *dr, float r, float g, float b, float grey);
int print_rgb_hatched_colour(drawing *dr, float r, float g, float b,
int hatch);
void print_line_width(drawing *dr, int width);
+void print_line_dotted(drawing *dr, int dotted);
/*
* midend.c
@@ -505,6 +506,7 @@ struct drawing_api {
void (*end_page)(void *handle, int number);
void (*end_doc)(void *handle);
void (*line_width)(void *handle, float width);
+ void (*line_dotted)(void *handle, int dotted);
};
/*
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)