chiark / gitweb /
Adopt C99 bool in the printing API.
authorSimon Tatham <anakin@pobox.com>
Tue, 13 Nov 2018 21:38:53 +0000 (21:38 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 13 Nov 2018 21:48:24 +0000 (21:48 +0000)
Not many changes here: the 'dotted' flag passed to print_line_dotted
is bool, and so is the printing_in_colour flag passed to
print_get_colour. Also ps_init() takes a bool.

line_dotted is also a method in the drawing API structure, but it's
not actually filled in for any non-print-oriented implementation of
that API. So only front ends that do platform-specific _printing_
should need to make a corresponding change. In-tree, for example,
windows.c needed a fix because it prints via Windows GDI, but gtk.c
didn't have to do anything, because its CLI-based printing facility
just delegates to ps.c.

devel.but
drawing.c
nullfe.c
ps.c
puzzles.h
windows.c

index 825e57fba0654ae2f79b4471fbc4c6c54f822139..0a0f1cd342050e5f81e2ed60059e45dddf74210e 100644 (file)
--- a/devel.but
+++ b/devel.but
@@ -2394,15 +2394,14 @@ capabilities.
 
 \S{print-line-dotted} \cw{print_line_dotted()}
 
-\c void print_line_dotted(drawing *dr, int dotted);
+\c void print_line_dotted(drawing *dr, bool 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.
+Setting \cq{dotted} to \cw{true} means that future lines drawn by
+\cw{draw_line()}, \cw{draw_circle} and \cw{draw_polygon()} will be
+dotted. Setting it to \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
index caf0b4b43af16036072b39f4d1a80e9387f1486e..a8eb8cfd5fcf35558ab50006720140390ffeb31b 100644 (file)
--- a/drawing.c
+++ b/drawing.c
@@ -264,7 +264,7 @@ void print_end_doc(drawing *dr)
     dr->api->end_doc(dr->handle);
 }
 
-void print_get_colour(drawing *dr, int colour, int printing_in_colour,
+void print_get_colour(drawing *dr, int colour, bool printing_in_colour,
                      int *hatch, float *r, float *g, float *b)
 {
     assert(colour >= 0 && colour < dr->ncolours);
@@ -347,7 +347,7 @@ 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)
+void print_line_dotted(drawing *dr, bool dotted)
 {
     dr->api->line_dotted(dr->handle, dotted);
 }
index 14b6e096c00e91fad306352395e9f2225292599d..7cba4e0c235b7e8a04d8e1d18692215a66f31cd7 100644 (file)
--- a/nullfe.c
+++ b/nullfe.c
@@ -40,7 +40,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 print_line_dotted(drawing *dr, bool dotted) {}
 void midend_supersede_game_desc(midend *me, const char *desc,
                                 const char *privdesc) {}
 void status_bar(drawing *dr, const char *text) {}
diff --git a/ps.c b/ps.c
index ac021aa80a58991d790d88ed34544f5ae2e4f1ce..0e469fb3d31d5af1d88f99ce2f19e21f7267bd1b 100644 (file)
--- a/ps.c
+++ b/ps.c
@@ -232,7 +232,7 @@ 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)
+static void ps_line_dotted(void *handle, bool dotted)
 {
     psdata *ps = (psdata *)handle;
 
@@ -408,7 +408,7 @@ static const struct drawing_api ps_drawing = {
     ps_text_fallback,
 };
 
-psdata *ps_init(FILE *outfile, int colour)
+psdata *ps_init(FILE *outfile, bool colour)
 {
     psdata *ps = snew(psdata);
 
index 1ece2a60be5cb9392fa78d4b1964b7ecc1871a85..379be15a924b2febd9ef482a8d86bf2828536193 100644 (file)
--- a/puzzles.h
+++ b/puzzles.h
@@ -292,7 +292,7 @@ void print_begin_puzzle(drawing *dr, float xm, float xc,
 void print_end_puzzle(drawing *dr);
 void print_end_page(drawing *dr, int number);
 void print_end_doc(drawing *dr);
-void print_get_colour(drawing *dr, int colour, int printing_in_colour,
+void print_get_colour(drawing *dr, int colour, bool printing_in_colour,
                      int *hatch, float *r, float *g, float *b);
 int print_mono_colour(drawing *dr, int grey); /* 0==black, 1==white */
 int print_grey_colour(drawing *dr, float grey);
@@ -302,7 +302,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);
+void print_line_dotted(drawing *dr, bool dotted);
 
 /*
  * midend.c
@@ -538,7 +538,7 @@ void document_print(document *doc, drawing *dr);
 /*
  * ps.c
  */
-psdata *ps_init(FILE *outfile, int colour);
+psdata *ps_init(FILE *outfile, bool colour);
 void ps_free(psdata *ps);
 drawing *ps_drawing_api(psdata *ps);
 
@@ -699,7 +699,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);
+    void (*line_dotted)(void *handle, bool dotted);
     char *(*text_fallback)(void *handle, const char *const *strings,
                           int nstrings);
     void (*draw_thick_line)(void *handle, float thickness,
index 268c8f50e8f68c3a9d8ad37df3a52229a67904ab..557e13f3cbdc4ef0a5cde885c25713e28724ca2f 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -799,7 +799,7 @@ static void win_line_width(void *handle, float width)
     fe->linewidth = (int)(width * fe->printpixelscale);
 }
 
-static void win_line_dotted(void *handle, int dotted)
+static void win_line_dotted(void *handle, bool dotted)
 {
     frontend *fe = (frontend *)handle;