mirror of
https://github.com/fltk/fltk.git
synced 2026-05-22 23:37:02 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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$".
|
||||
//
|
||||
@@ -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++;
|
||||
|
||||
Reference in New Issue
Block a user