From 1df79078b7992010f8cde6b8915408ac9f6305a2 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 10 Oct 2022 16:58:48 +0200 Subject: Remove duplications between Fl_Graphics_Driver and derived classes. --- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H | 2 -- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 28 +++++++++++----------- src/drivers/PostScript/Fl_PostScript.cxx | 26 ++++++++++---------- .../PostScript/Fl_PostScript_Graphics_Driver.H | 2 -- 4 files changed, 27 insertions(+), 31 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H index 1a9d22e81..3343345a1 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H @@ -58,7 +58,6 @@ protected: public: Fl_Cairo_Graphics_Driver(); virtual ~Fl_Cairo_Graphics_Driver(); - enum SHAPE {NONE=0, LINE, LOOP, POLYGON, POINTS}; class Clip { public: @@ -74,7 +73,6 @@ public: void check_status(void); - enum SHAPE shape_; unsigned char cr_,cg_,cb_; char linedash_[256];//should be enough void concat(); // transform ror scalable dradings... diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 7ac9cee0e..f2f43d753 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -79,7 +79,7 @@ Fl_Cairo_Graphics_Driver::Fl_Cairo_Graphics_Driver() : Fl_Graphics_Driver() { angle = 0; left_margin = top_margin = 0; needs_commit_tag_ = NULL; - shape_ = NONE; + what = NONE; } Fl_Cairo_Graphics_Driver::~Fl_Cairo_Graphics_Driver() { @@ -393,7 +393,7 @@ void Fl_Cairo_Graphics_Driver::begin_points() { concat(); cairo_new_path(cairo_); gap_=1; - shape_=POINTS; + what=POINTS; } void Fl_Cairo_Graphics_Driver::begin_line() { @@ -401,7 +401,7 @@ void Fl_Cairo_Graphics_Driver::begin_line() { concat(); cairo_new_path(cairo_); gap_=1; - shape_=LINE; + what=LINE; } void Fl_Cairo_Graphics_Driver::begin_loop() { @@ -409,7 +409,7 @@ void Fl_Cairo_Graphics_Driver::begin_loop() { concat(); cairo_new_path(cairo_); gap_=1; - shape_=LOOP; + what=LOOP; } void Fl_Cairo_Graphics_Driver::begin_polygon() { @@ -417,11 +417,11 @@ void Fl_Cairo_Graphics_Driver::begin_polygon() { concat(); cairo_new_path(cairo_); gap_=1; - shape_=POLYGON; + what=POLYGON; } void Fl_Cairo_Graphics_Driver::vertex(double x, double y) { - if (shape_==POINTS){ + if (what==POINTS){ cairo_move_to(cairo_, x, y); gap_=1; return; @@ -437,8 +437,8 @@ void Fl_Cairo_Graphics_Driver::vertex(double x, double y) { void Fl_Cairo_Graphics_Driver::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3) { - if(shape_==NONE) return; - if (shape_ == POINTS) Fl_Graphics_Driver::curve(x, y, x1, y1, x2, y2, x3, y3); + if(what==NONE) return; + if (what == POINTS) Fl_Graphics_Driver::curve(x, y, x1, y1, x2, y2, x3, y3); else { if(gap_) cairo_move_to(cairo_, x, y); @@ -451,7 +451,7 @@ void Fl_Cairo_Graphics_Driver::curve(double x, double y, double x1, double y1, d } void Fl_Cairo_Graphics_Driver::circle(double x, double y, double r){ - if (shape_ == NONE) { + if (what == NONE) { cairo_save(cairo_); concat(); cairo_arc(cairo_, x, y, r, 0, 2*M_PI); @@ -465,7 +465,7 @@ void Fl_Cairo_Graphics_Driver::circle(double x, double y, double r){ } void Fl_Cairo_Graphics_Driver::arc(double x, double y, double r, double start, double a){ - if (shape_ == NONE) return; + if (what == NONE) return; gap_ = 0; if (start > a) cairo_arc(cairo_, x, y, r, -start*M_PI/180, -a*M_PI/180); @@ -508,7 +508,7 @@ void Fl_Cairo_Graphics_Driver::end_line() { reconcat(); cairo_stroke(cairo_); cairo_restore(cairo_); - shape_ = NONE; + what = NONE; surface_needs_commit(); } @@ -518,7 +518,7 @@ void Fl_Cairo_Graphics_Driver::end_loop(){ cairo_close_path(cairo_); cairo_stroke(cairo_); cairo_restore(cairo_); - shape_ = NONE; + what = NONE; surface_needs_commit(); } @@ -528,12 +528,12 @@ void Fl_Cairo_Graphics_Driver::end_polygon() { cairo_close_path(cairo_); cairo_fill(cairo_); cairo_restore(cairo_); - shape_ = NONE; + what = NONE; surface_needs_commit(); } void Fl_Cairo_Graphics_Driver::transformed_vertex(double x, double y) { - if (shape_ == POINTS) { + if (what == POINTS) { cairo_move_to(cairo_, x, y); point(x, y); gap_ = 1; diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 5e09e7fec..bd8994c35 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -149,7 +149,7 @@ Fl_PostScript_Graphics_Driver::Fl_PostScript_Graphics_Driver(void) scale_x = scale_y = 1.; bg_r = bg_g = bg_b = 255; clip_ = NULL; - shape_ = NONE; + what = NONE; } /** \brief The destructor. */ @@ -1257,7 +1257,7 @@ void Fl_PostScript_Graphics_Driver::begin_points(){ fprintf(output, "BP\n"); gap_=1; - shape_=POINTS; + what=POINTS; } void Fl_PostScript_Graphics_Driver::begin_line(){ @@ -1265,7 +1265,7 @@ void Fl_PostScript_Graphics_Driver::begin_line(){ concat(); fprintf(output, "BP\n"); gap_=1; - shape_=LINE; + what=LINE; } void Fl_PostScript_Graphics_Driver::begin_loop(){ @@ -1273,7 +1273,7 @@ void Fl_PostScript_Graphics_Driver::begin_loop(){ concat(); fprintf(output, "BP\n"); gap_=1; - shape_=LOOP; + what=LOOP; } void Fl_PostScript_Graphics_Driver::begin_polygon(){ @@ -1281,11 +1281,11 @@ void Fl_PostScript_Graphics_Driver::begin_polygon(){ concat(); fprintf(output, "BP\n"); gap_=1; - shape_=POLYGON; + what=POLYGON; } void Fl_PostScript_Graphics_Driver::vertex(double x, double y){ - if(shape_==POINTS){ + if(what==POINTS){ clocale_printf("%g %g MT\n", x , y); gap_=1; return; @@ -1298,7 +1298,7 @@ void Fl_PostScript_Graphics_Driver::vertex(double x, double y){ } void Fl_PostScript_Graphics_Driver::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3){ - if(shape_==NONE) return; + if(what==NONE) return; if(gap_) clocale_printf("%g %g MT\n", x , y); else @@ -1310,7 +1310,7 @@ void Fl_PostScript_Graphics_Driver::curve(double x, double y, double x1, double void Fl_PostScript_Graphics_Driver::circle(double x, double y, double r){ - if(shape_==NONE){ + if(what==NONE){ fprintf(output, "GS\n"); concat(); // fprintf(output, "BP\n"); @@ -1325,7 +1325,7 @@ void Fl_PostScript_Graphics_Driver::circle(double x, double y, double r){ } void Fl_PostScript_Graphics_Driver::arc(double x, double y, double r, double start, double a){ - if(shape_==NONE) return; + if(what==NONE) return; gap_=0; if(start>a) clocale_printf("%g %g %g %g %g arc\n", x , y , r , -start, -a); @@ -1370,7 +1370,7 @@ void Fl_PostScript_Graphics_Driver::end_points(){ reconcat(); fprintf(output, "ELP\n"); //?? fprintf(output, "GR\n"); - shape_=NONE; + what=NONE; } void Fl_PostScript_Graphics_Driver::end_line(){ @@ -1378,14 +1378,14 @@ void Fl_PostScript_Graphics_Driver::end_line(){ reconcat(); fprintf(output, "ELP\n"); fprintf(output, "GR\n"); - shape_=NONE; + what=NONE; } void Fl_PostScript_Graphics_Driver::end_loop(){ gap_=1; reconcat(); fprintf(output, "ECP\n"); fprintf(output, "GR\n"); - shape_=NONE; + what=NONE; } void Fl_PostScript_Graphics_Driver::end_polygon(){ @@ -1394,7 +1394,7 @@ void Fl_PostScript_Graphics_Driver::end_polygon(){ reconcat(); fprintf(output, "EFP\n"); fprintf(output, "GR\n"); - shape_=NONE; + what=NONE; } void Fl_PostScript_Graphics_Driver::transformed_vertex(double x, double y){ diff --git a/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H b/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H index acba42d9a..52288cdae 100644 --- a/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H +++ b/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H @@ -103,7 +103,6 @@ protected: uchar **mask_bitmap() {return &mask;} public: Fl_PostScript_Graphics_Driver(); - enum SHAPE {NONE=0, LINE, LOOP, POLYGON, POINTS}; class Clip { public: @@ -131,7 +130,6 @@ public: */ int clocale_printf(const char *format, ...); - enum SHAPE shape_; int linewidth_;// need for clipping, lang level 1-2 int linestyle_;// unsigned char cr_,cg_,cb_; -- cgit v1.2.3