diff options
Diffstat (limited to 'src/drivers')
7 files changed, 16 insertions, 38 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx index 28422599a..26dd842d9 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx @@ -34,15 +34,9 @@ #include "Fl_GDI_Graphics_Driver.H" -extern int fl_line_width_; // defined in src/fl_line_style.cxx - void Fl_GDI_Graphics_Driver::line_style(int style, int width, char* dashes) { - // save line width in global variable for X11 clipping - if (width == 0) fl_line_width_ = 1; - else fl_line_width_ = width>0 ? width : -width; - // According to Bill, the "default" cap and join should be the // "fastest" mode supported for the platform. I don't know why // they should be different (same graphics cards, etc., right?) MRS diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx index a5f9a3f96..c5698bb4d 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx @@ -33,18 +33,11 @@ #include <FL/Fl.H> #include <FL/fl_draw.H> -extern int fl_line_width_; - // OpenGL implementation does not support custom patterns // OpenGL implementation does not support cap and join types void Fl_OpenGL_Graphics_Driver::line_style(int style, int width, char* dashes) { - // save line width in global variable for X11 clipping - // FIXME: what does this code do? - if (width == 0) fl_line_width_ = 1; - else fl_line_width_ = width>0 ? width : -width; - if (width<1) width = 1; if (style==FL_SOLID) { diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx index a48bbf6d4..54a92725c 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx @@ -22,7 +22,6 @@ #include <FL/fl_draw.H> #include <FL/x.H> -extern int fl_line_width_; /** \file quartz_line_style.cxx @@ -40,10 +39,6 @@ void Fl_Quartz_Graphics_Driver::quartz_restore_line_style() { void Fl_Quartz_Graphics_Driver::line_style(int style, int width, char* dashes) { - // save line width in global variable for X11 clipping - if (width == 0) fl_line_width_ = 1; - else fl_line_width_ = width>0 ? width : -width; - static CGLineCap Cap[4] = { kCGLineCapButt, kCGLineCapButt, kCGLineCapRound, kCGLineCapSquare }; static CGLineJoin Join[4] = { kCGLineJoinMiter, kCGLineJoinMiter, diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index 7bd8793c0..b13446827 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -57,6 +57,8 @@ protected: int p_size; typedef struct {short x, y;} XPOINT; XPOINT *p; + int line_width_; + int clip_x(int x); public: Fl_Xlib_Graphics_Driver(void); virtual ~Fl_Xlib_Graphics_Driver() { if (p) free(p); } diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index cff7f1f2b..a8a5509fd 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -56,6 +56,7 @@ Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) { mask_bitmap_ = NULL; p_size = 0; p = NULL; + line_width_ = 0; } void Fl_Xlib_Graphics_Driver::gc(void *value) { diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx index 012b21f5c..a10ce7972 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx @@ -34,16 +34,11 @@ #include "Fl_Xlib_Graphics_Driver.H" -// We save the current line width (absolute value) here. -// This is currently used only for X11 clipping, see src/fl_rect.cxx. -// FIXME: this would probably better be in class Fl:: -extern int fl_line_width_; - void Fl_Xlib_Graphics_Driver::line_style(int style, int width, char* dashes) { - // save line width in global variable for X11 clipping - if (width == 0) fl_line_width_ = 1; - else fl_line_width_ = width>0 ? width : -width; + // save line width for X11 clipping + if (width == 0) line_width_ = 1; + else line_width_ = width>0 ? width : -width; int ndashes = dashes ? strlen(dashes) : 0; // emulate the WIN32 dash patterns on X diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx index 0df68049b..3b0a0cae2 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx @@ -41,10 +41,8 @@ #define SHRT_MAX (32767) #endif -// fl_line_width_ must contain the absolute value of the current +// line_width_ must contain the absolute value of the current // line width to be used for X11 clipping (see below). -// This is defined in src/fl_line_style.cxx -extern int fl_line_width_; /* We need to check some coordinates for areas for clipping before we @@ -71,7 +69,7 @@ extern int fl_line_width_; In this example case, no clipping would be done, because X can handle it and clip unneeded pixels. - Note that we must also take care of the case where fl_line_width_ + Note that we must also take care of the case where line_width_ is zero (maybe unitialized). If this is the case, we assume a line width of 1. @@ -109,9 +107,9 @@ extern int fl_line_width_; Use this for clipping rectangles, as used in fl_rect() and fl_rectf(). */ -static int clip_to_short(int &x, int &y, int &w, int &h) { +static int clip_to_short(int &x, int &y, int &w, int &h, int line_width) { - int lw = (fl_line_width_ > 0) ? fl_line_width_ : 1; + int lw = (line_width > 0) ? line_width : 1; int kmin = -lw; int kmax = SHRT_MAX - lw; @@ -135,9 +133,9 @@ static int clip_to_short(int &x, int &y, int &w, int &h) { in fl_xyline() and fl_yxline(). Note that this can't be used for arbitrary lines (not horizontal or vertical). */ -static int clip_x (int x) { +int Fl_Xlib_Graphics_Driver::clip_x (int x) { - int lw = (fl_line_width_ > 0) ? fl_line_width_ : 1; + int lw = (line_width_ > 0) ? line_width_ : 1; int kmin = -lw; int kmax = SHRT_MAX - lw; @@ -152,7 +150,7 @@ static int clip_x (int x) { // MSWindows equivalent exists, implemented inline in win32.H Fl_Region Fl_Xlib_Graphics_Driver::XRectangleRegion(int x, int y, int w, int h) { XRectangle R; - clip_to_short(x, y, w, h); + clip_to_short(x, y, w, h, line_width_); R.x = x; R.y = y; R.width = w; R.height = h; Fl_Region r = XCreateRegion(); XUnionRectWithRegion(&R, r, r); @@ -171,13 +169,13 @@ void Fl_Xlib_Graphics_Driver::point(int x, int y) { void Fl_Xlib_Graphics_Driver::rect(int x, int y, int w, int h) { if (w<=0 || h<=0) return; - if (!clip_to_short(x, y, w, h)) + if (!clip_to_short(x, y, w, h, line_width_)) XDrawRectangle(fl_display, fl_window, gc_, x, y, w-1, h-1); } void Fl_Xlib_Graphics_Driver::rectf(int x, int y, int w, int h) { if (w<=0 || h<=0) return; - if (!clip_to_short(x, y, w, h)) + if (!clip_to_short(x, y, w, h, line_width_)) XFillRectangle(fl_display, fl_window, gc_, x, y, w, h); } @@ -321,7 +319,7 @@ int Fl_Xlib_Graphics_Driver::not_clipped(int x, int y, int w, int h) { Fl_Region r = rstack[rstackptr]; if (!r) return 1; // get rid of coordinates outside the 16-bit range the X calls take. - if (clip_to_short(x,y,w,h)) return 0; // clipped + if (clip_to_short(x,y,w,h, line_width_)) return 0; // clipped return XRectInRegion(r, x, y, w, h); } |
