summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-11-16 19:56:22 +0000
committerManolo Gouy <Manolo>2016-11-16 19:56:22 +0000
commit2baeda448b2680e2cca5cf314dd6430db721feab (patch)
tree1e643118496df481e715b615ec88b3b00c16ec36
parent44ce401d455c7a017993c3a19f1324dc307db2b5 (diff)
Replace global fl_line_width_ used only by X11 platform by Fl_Xlib_Graphics_Driver::line_width_
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12114 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx6
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx7
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx5
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H2
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx1
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx11
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx22
-rw-r--r--src/fl_line_style.cxx37
-rw-r--r--src/fl_rect.cxx6
9 files changed, 16 insertions, 81 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);
}
diff --git a/src/fl_line_style.cxx b/src/fl_line_style.cxx
deleted file mode 100644
index bc69c35d0..000000000
--- a/src/fl_line_style.cxx
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// "$Id$"
-//
-// Line style code for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2012 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-/**
- \file fl_line_style.cxx
- \brief Line style drawing utility hiding different platforms.
-*/
-
-#include <FL/Fl_Export.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::
-FL_EXPORT int fl_line_width_ = 0;
-
-// -----------------------------------------------------------------------------
-// all driver code is now in drivers/XXX/Fl_XXX_Graphics_Driver_xyz.cxx
-// -----------------------------------------------------------------------------
-
-//
-// End of "$Id$".
-//
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index 0b9595dae..751b7b813 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -33,12 +33,6 @@
// all driver code is now in drivers/XXX/Fl_XXX_Graphics_Driver_xyz.cxx
// -----------------------------------------------------------------------------
-// fl_line_width_ must contain the absolute value of the current
-// line width to be used for X11 clipping (see driver code).
-// This is defined in src/fl_line_style.cxx
-extern int fl_line_width_;
-
-
/** see fl_restore_clip() */
void Fl_Graphics_Driver::restore_clip() {
fl_clip_state_number++;