Replaced global variable fl_color_ by a private member of the Fl_Graphics_Driver class,
and a public getter to it: Fl_Graphics_Driver::color(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8384 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
5e7232e776
commit
6a5feafe23
@ -114,6 +114,7 @@ public:
|
||||
class FL_EXPORT Fl_Graphics_Driver : public Fl_Device {
|
||||
Fl_Font font_; // current font
|
||||
Fl_Fontsize size_; // current font size
|
||||
Fl_Color color_; // current color
|
||||
enum {LINE, LOOP, POLYGON, POINT_};
|
||||
int sptr;
|
||||
matrix stack[MATRIX_STACK_SIZE];
|
||||
@ -236,7 +237,7 @@ protected:
|
||||
/** \brief see fl_rtl_draw(const char *str, int n, int x, int y). */
|
||||
virtual void rtl_draw(const char *str, int n, int x, int y) = 0;
|
||||
/** \brief see fl_color(Fl_Color c). */
|
||||
virtual void color(Fl_Color c) = 0;
|
||||
virtual void color(Fl_Color c) {color_ = c;}
|
||||
/** \brief see fl_color(uchar r, uchar g, uchar b). */
|
||||
virtual void color(uchar r, uchar g, uchar b) = 0;
|
||||
/** \brief see fl_point(int x, int y). */
|
||||
@ -350,10 +351,12 @@ public:
|
||||
static const char *class_id;
|
||||
/** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
|
||||
virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = size;}
|
||||
/** \brief see fl_font(). */
|
||||
/** \brief see fl_font(void). */
|
||||
Fl_Font font() {return font_; }
|
||||
/** \brief see fl_size(). */
|
||||
Fl_Fontsize size() {return size_; }
|
||||
/** \brief see fl_color(void). */
|
||||
Fl_Color color() {return color_;}
|
||||
/** \brief The destructor */
|
||||
virtual ~Fl_Graphics_Driver() {};
|
||||
};
|
||||
|
@ -72,13 +72,11 @@ inline void fl_color(int c) {fl_color((Fl_Color)c);}
|
||||
\param[in] r,g,b color components
|
||||
*/
|
||||
inline void fl_color(uchar r, uchar g, uchar b) {fl_graphics_driver->color(r,g,b); } // select actual color
|
||||
/** \brief The current color */
|
||||
extern FL_EXPORT Fl_Color fl_color_;
|
||||
/**
|
||||
Returns the last fl_color() that was set.
|
||||
This can be used for state save/restore.
|
||||
*/
|
||||
inline Fl_Color fl_color() {return fl_color_;}
|
||||
inline Fl_Color fl_color() {return fl_graphics_driver->color();}
|
||||
/** @} */
|
||||
|
||||
/** \addtogroup fl_drawings
|
||||
|
@ -940,7 +940,7 @@ void Fl_PostScript_Graphics_Driver::color(Fl_Color c) {
|
||||
}
|
||||
|
||||
void Fl_PostScript_Graphics_Driver::color(unsigned char r, unsigned char g, unsigned char b) {
|
||||
fl_color_ = fl_rgb_color(r, g, b);
|
||||
Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
|
||||
cr_ = r; cg_ = g; cb_ = b;
|
||||
if (r == g && g == b) {
|
||||
double gray = r/255.0;
|
||||
|
@ -2238,7 +2238,6 @@ void Fl_Window::make_current()
|
||||
}
|
||||
|
||||
// helper function to manage the current CGContext fl_gc
|
||||
extern Fl_Color fl_color_;
|
||||
extern class Fl_Font_Descriptor *fl_fontsize;
|
||||
extern void fl_font(class Fl_Font_Descriptor*);
|
||||
extern void fl_quartz_restore_line_style_();
|
||||
@ -2253,7 +2252,7 @@ void Fl_X::q_fill_context() {
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context
|
||||
}
|
||||
fl_font(fl_fontsize);
|
||||
fl_color(fl_color_);
|
||||
fl_color(fl_graphics_driver->color());
|
||||
fl_quartz_restore_line_style_();
|
||||
}
|
||||
|
||||
|
@ -124,22 +124,19 @@ Fl_XColor fl_xmap[1][256];
|
||||
# define fl_overlay 0
|
||||
# endif
|
||||
|
||||
/** Current color for drawing operations */
|
||||
Fl_Color fl_color_;
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::color(Fl_Color i) {
|
||||
if (i & 0xffffff00) {
|
||||
unsigned rgb = (unsigned)i;
|
||||
fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8));
|
||||
} else {
|
||||
fl_color_ = i;
|
||||
Fl_Graphics_Driver::color(i);
|
||||
if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid
|
||||
XSetForeground(fl_display, fl_gc, fl_xpixel(i));
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::color(uchar r,uchar g,uchar b) {
|
||||
fl_color_ = fl_rgb_color(r, g, b);
|
||||
Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
|
||||
if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid
|
||||
XSetForeground(fl_display, fl_gc, fl_xpixel(r,g,b));
|
||||
}
|
||||
|
@ -47,10 +47,8 @@ Fl_XMap fl_xmap[256];
|
||||
|
||||
Fl_XMap* fl_current_xmap;
|
||||
|
||||
Fl_Color fl_color_;
|
||||
|
||||
void Fl_Quartz_Graphics_Driver::color(Fl_Color i) {
|
||||
fl_color_ = i;
|
||||
Fl_Graphics_Driver::color(i);
|
||||
int index;
|
||||
uchar r, g, b;
|
||||
if (i & 0xFFFFFF00) {
|
||||
@ -75,7 +73,7 @@ void Fl_Quartz_Graphics_Driver::color(Fl_Color i) {
|
||||
}
|
||||
|
||||
void Fl_Quartz_Graphics_Driver::color(uchar r, uchar g, uchar b) {
|
||||
fl_color_ = fl_rgb_color(r, g, b);
|
||||
Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
|
||||
float fr = r/255.0f;
|
||||
float fg = g/255.0f;
|
||||
float fb = b/255.0f;
|
||||
|
@ -92,14 +92,12 @@ static void set_xmap(Fl_XMap& xmap, COLORREF c) {
|
||||
xmap.brush = -1;
|
||||
}
|
||||
|
||||
Fl_Color fl_color_;
|
||||
|
||||
void Fl_GDI_Graphics_Driver::color(Fl_Color i) {
|
||||
if (i & 0xffffff00) {
|
||||
unsigned rgb = (unsigned)i;
|
||||
fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8));
|
||||
} else {
|
||||
fl_color_ = i;
|
||||
Fl_Graphics_Driver::color(i);
|
||||
Fl_XMap &xmap = fl_xmap[i];
|
||||
if (!xmap.pen) {
|
||||
#if USE_COLORMAP
|
||||
@ -121,7 +119,7 @@ void Fl_GDI_Graphics_Driver::color(Fl_Color i) {
|
||||
void Fl_GDI_Graphics_Driver::color(uchar r, uchar g, uchar b) {
|
||||
static Fl_XMap xmap;
|
||||
COLORREF c = RGB(r,g,b);
|
||||
fl_color_ = fl_rgb_color(r, g, b);
|
||||
Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
|
||||
if (!xmap.pen || c != xmap.rgb) {
|
||||
clear_xmap(xmap);
|
||||
set_xmap(xmap, c);
|
||||
|
@ -614,8 +614,8 @@ void Fl_Xlib_Graphics_Driver::draw(const char *str, int n, int x, int y) {
|
||||
// Use fltk's color allocator, copy the results to match what
|
||||
// XftCollorAllocValue returns:
|
||||
XftColor color;
|
||||
color.pixel = fl_xpixel(fl_color_);
|
||||
uchar r,g,b; Fl::get_color(fl_color_, r,g,b);
|
||||
color.pixel = fl_xpixel(fl_graphics_driver->color());
|
||||
uchar r,g,b; Fl::get_color(fl_graphics_driver->color(), r,g,b);
|
||||
color.color.red = ((int)r)*0x101;
|
||||
color.color.green = ((int)g)*0x101;
|
||||
color.color.blue = ((int)b)*0x101;
|
||||
@ -659,8 +659,8 @@ static void fl_drawUCS4(const FcChar32 *str, int n, int x, int y) {
|
||||
// Use fltk's color allocator, copy the results to match what
|
||||
// XftCollorAllocValue returns:
|
||||
XftColor color;
|
||||
color.pixel = fl_xpixel(fl_color_);
|
||||
uchar r,g,b; Fl::get_color(fl_color_, r,g,b);
|
||||
color.pixel = fl_xpixel(fl_graphics_driver->color());
|
||||
uchar r,g,b; Fl::get_color(fl_graphics_driver->color(), r,g,b);
|
||||
color.color.red = ((int)r)*0x101;
|
||||
color.color.green = ((int)g)*0x101;
|
||||
color.color.blue = ((int)b)*0x101;
|
||||
|
Loading…
Reference in New Issue
Block a user