virtualized Fl::set_color and free_color.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11642 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2016-04-17 15:01:20 +00:00
parent 9ae4a99081
commit c9d3eabf4e
11 changed files with 45 additions and 10 deletions

View File

@ -178,6 +178,8 @@ public:
virtual void line_style(int style, int width=0, char* dashes=0) = 0;
// --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx
virtual void color(Fl_Color c) { color_ = c; }
virtual void set_color(Fl_Color i, unsigned int c);
virtual void free_color(Fl_Color i, int overlay);
virtual Fl_Color color() { return color_; }
virtual void color(uchar r, uchar g, uchar b) = 0;
// --- implementation is in src/fl_font.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_font.cxx

View File

@ -69,21 +69,37 @@ void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen
delete[] img;
}
void Fl_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
// nothing to do
// nothing to do, reimplement in driver if needed
}
void Fl_Graphics_Driver::reset_spot()
{
// nothing to do
// nothing to do, reimplement in driver if needed
}
void Fl_Graphics_Driver::global_gc()
{
// nothing to do
// nothing to do, reimplement in driver if needed
}
void Fl_Graphics_Driver::set_color(Fl_Color i, unsigned int c)
{
// nothing to do, reimplement in driver if needed
}
void Fl_Graphics_Driver::free_color(Fl_Color i, int overlay)
{
// nothing to do, reimplement in driver if needed
}
//
// End of "$Id$".
//

View File

@ -127,6 +127,8 @@ protected:
void color(Fl_Color c);
Fl_Color color() { return color_; }
void color(uchar r, uchar g, uchar b);
void set_color(Fl_Color i, unsigned int c);
void free_color(Fl_Color i, int overlay);
void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
void reset_spot();
protected:

View File

@ -185,12 +185,12 @@ CREATE_BRUSH:
return brushes[i].brush;
}
void Fl::free_color(Fl_Color i, int overlay) {
void Fl_GDI_Graphics_Driver::free_color(Fl_Color i, int overlay) {
if (overlay) return; // do something about GL overlay?
clear_xmap(fl_xmap[i]);
}
void Fl::set_color(Fl_Color i, unsigned c) {
void Fl_GDI_Graphics_Driver::set_color(Fl_Color i, unsigned c) {
if (fl_cmap[i] != c) {
clear_xmap(fl_xmap[i]);
fl_cmap[i] = c;

View File

@ -471,7 +471,6 @@ int Fl::dnd() { return 0; }
void Fl::copy(char const*, int, int, char const*) { }
void Fl::paste(Fl_Widget&, int, char const*) { }
void Fl::get_mouse(int&, int&) { }
void Fl::set_color(Fl_Color, unsigned int) { }
int Fl_X::set_cursor(Fl_Cursor) { return 0; }
int Fl_X::set_cursor(Fl_RGB_Image const*, int, int) { return 0; }

View File

@ -142,7 +142,6 @@ double Fl_PicoSDL_Screen_Driver::wait(double time_to_wait)
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Graphics_Driver.H>
void Fl::set_color(Fl_Color, unsigned int) { }
int Fl_X::set_cursor(Fl_Cursor) { return 0; }
int Fl_X::set_cursor(Fl_RGB_Image const*, int, int) { return 0; }

View File

@ -110,6 +110,7 @@ protected:
void line_style(int style, int width=0, char* dashes=0);
// --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx
void color(Fl_Color c);
void set_color(Fl_Color i, unsigned int c);
Fl_Color color() { return color_; }
void color(uchar r, uchar g, uchar b);
// --- implementation is in src/fl_font.cxx which includes src/cfg_gfx/xxx_font.cxx

View File

@ -72,7 +72,7 @@ void Fl_Quartz_Graphics_Driver::color(uchar r, uchar g, uchar b) {
}
// FIXME: this function should not be here! It's not part of the driver.
void Fl::set_color(Fl_Color i, unsigned c) {
void Fl_Quartz_Graphics_Driver::set_color(Fl_Color i, unsigned c) {
if (fl_cmap[i] != c) {
fl_cmap[i] = c;
}

View File

@ -125,6 +125,8 @@ protected:
void line_style(int style, int width=0, char* dashes=0);
// --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx
void color(Fl_Color c);
void set_color(Fl_Color i, unsigned int c);
void free_color(Fl_Color i, int overlay);
Fl_Color color() { return color_; }
void color(uchar r, uchar g, uchar b);
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s);

View File

@ -308,7 +308,7 @@ ulong fl_xpixel(Fl_Color i) {
\param[in] i color index
\param[in] overlay 0 for normal, 1 for overlay color
*/
void Fl::free_color(Fl_Color i, int overlay) {
void Fl_Xlib_Graphics_Driver::free_color(Fl_Color i, int overlay) {
# if HAVE_OVERLAY
# else
if (overlay) return;
@ -332,7 +332,7 @@ void Fl::free_color(Fl_Color i, int overlay) {
\param[in] i color index
\param[in] c color
*/
void Fl::set_color(Fl_Color i, unsigned c) {
void Fl_Xlib_Graphics_Driver::set_color(Fl_Color i, unsigned c) {
if (fl_cmap[i] != c) {
free_color(i,0);
# if HAVE_OVERLAY

View File

@ -25,6 +25,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Device.H>
#include <FL/Fl_Graphics_Driver.H>
#include <FL/Fl.H>
// fl_cmap needs to be defined globally (here) and is used in the device
@ -65,6 +66,19 @@ void Fl::set_color(Fl_Color i, uchar red, uchar green, uchar blue) {
((unsigned)red<<24)+((unsigned)green<<16)+((unsigned)blue<<8));
}
void Fl::set_color(Fl_Color i, unsigned int c)
{
fl_graphics_driver->set_color(i, c);
}
void Fl::free_color(Fl_Color i, int overlay)
{
fl_graphics_driver->free_color(i, overlay);
}
/**
Returns the RGB value(s) for the given FLTK color index.