From ef36be385e5bedc22f5e1da11b5eca4a55d3c0b5 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 11 Apr 2002 10:46:19 +0000 Subject: [PATCH] Redefine FL_ color values to use the color cube. Add FL_BACKGROUND_COLOR, FL_BACKGROUND2_COLOR, and FL_FOREGROUND_COLOR, and use them instead of FL_GRAY, FL_WHITE, and FL_BLACK, respectively. (FL_GRAY defined to FL_BACKGROUND_COLOR for back-compatibility) Add fl_rgb_color(uchar g) inline method to map 8-bit grayscale to 24-bit RGB color. Doco updates for all of this... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2072 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 14 +++ FL/Enumerations.H | 56 ++++++----- documentation/enumerations.html | 159 ++++++++++++++++++++++---------- src/Fl_Browser_.cxx | 9 +- src/Fl_Choice.cxx | 6 +- src/Fl_Color_Chooser.cxx | 8 +- src/Fl_Counter.cxx | 8 +- src/Fl_Dial.cxx | 10 +- src/Fl_Help_View.cxx | 9 +- src/Fl_Input_.cxx | 10 +- src/Fl_Light_Button.cxx | 8 +- src/Fl_Menu.cxx | 8 +- src/Fl_Progress.cxx | 6 +- src/Fl_Slider.cxx | 6 +- src/Fl_Text_Display.cxx | 8 +- src/Fl_get_system_colors.cxx | 11 ++- src/fl_color.cxx | 8 +- src/fl_set_gray.cxx | 12 +-- 18 files changed, 221 insertions(+), 135 deletions(-) diff --git a/CHANGES b/CHANGES index 74585fdb6..dedd18d16 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,17 @@ +CHANGES IN FLTK 1.1.0 + + - Some source files still used the "false" and "true" + C++ keywords, even though several of our "supported" + C++ compilers don't support them. Using 0 and 1 until + FLTK 2.0 (which uses the bool type instead of int for + any boolean values...) + - Minor Fl_Color revamping, so that color constants map + to the color cube and FL_FOREGROUND_COLOR, + FL_BACKGROUND_COLOR, FL_BACKGROUND2_COLOR, + FL_INACTIVE_COLOR, and FL_SELECTION_COLOR map to the + user-defined colors. + + CHANGES IN FLTK 1.1.0b13 - Fixed a bug in the Xft support in Fl_Window::hide() diff --git a/FL/Enumerations.H b/FL/Enumerations.H index 650ac4169..fe76d36d9 100644 --- a/FL/Enumerations.H +++ b/FL/Enumerations.H @@ -1,5 +1,5 @@ // -// "$Id: Enumerations.H,v 1.18.2.14.2.21 2002/03/25 21:08:41 easysw Exp $" +// "$Id: Enumerations.H,v 1.18.2.14.2.22 2002/04/11 10:46:19 easysw Exp $" // // Enumerations for the Fast Light Tool Kit (FLTK). // @@ -272,48 +272,58 @@ enum Fl_Font { // standard fonts extern FL_EXPORT int FL_NORMAL_SIZE; enum Fl_Color { // standard colors - FL_BLACK = 0, - FL_RED = 1, - FL_GREEN = 2, - FL_YELLOW = 3, - FL_BLUE = 4, - FL_MAGENTA = 5, - FL_CYAN = 6, - FL_WHITE = 7, + // These are used as default colors in widgets and altered as necessary + FL_FOREGROUND_COLOR = 0, + FL_BACKGROUND2_COLOR = 7, FL_INACTIVE_COLOR = 8, FL_SELECTION_COLOR = 15, - FL_FREE_COLOR = 16, - FL_NUM_FREE_COLOR = 16, - - FL_GRAY_RAMP = 32, - - // boxtypes limit themselves to these colors so whole ramp is not allocated: + // boxtypes generally limit themselves to these colors so + // the whole ramp is not allocated: FL_GRAY0 = 32, // 'A' FL_DARK3 = 39, // 'H' FL_DARK2 = 45, // 'N' FL_DARK1 = 47, // 'P' - FL_GRAY = 49, // 'R' default color + FL_BACKGROUND_COLOR = 49, // 'R' default background color FL_LIGHT1 = 50, // 'S' FL_LIGHT2 = 52, // 'U' FL_LIGHT3 = 54, // 'W' - FL_COLOR_CUBE = 56 + // FLTK provides a 5x8x5 color cube that is used with colormap visuals + FL_BLACK = 56, + FL_RED = 88, + FL_GREEN = 63, + FL_YELLOW = 95, + FL_BLUE = 216, + FL_MAGENTA = 248, + FL_CYAN = 223, + FL_WHITE = 255 }; +#define FL_FREE_COLOR (Fl_Color)16 +#define FL_NUM_FREE_COLOR 16 +#define FL_GRAY_RAMP (Fl_Color)32 +#define FL_NUM_GRAY 24 +#define FL_GRAY FL_BACKGROUND_COLOR +#define FL_COLOR_CUBE (Fl_Color)56 +#define FL_NUM_RED 5 +#define FL_NUM_GREEN 8 +#define FL_NUM_BLUE 5 + FL_EXPORT Fl_Color fl_inactive(Fl_Color c); FL_EXPORT Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg); FL_EXPORT Fl_Color fl_color_average(Fl_Color c1, Fl_Color c2, float weight); inline Fl_Color fl_lighter(Fl_Color c) { return fl_color_average(c, FL_WHITE, .67f); } inline Fl_Color fl_darker(Fl_Color c) { return fl_color_average(c, FL_BLACK, .67f); } inline Fl_Color fl_rgb_color(uchar r, uchar g, uchar b) { - return (Fl_Color)(((((r << 8) | g) << 8) | b) << 8); + if (!r && !g && !b) return FL_BLACK; + else return (Fl_Color)(((((r << 8) | g) << 8) | b) << 8); +} +inline Fl_Color fl_rgb_color(uchar g) { + if (!g) return FL_BLACK; + else return (Fl_Color)(((((g << 8) | g) << 8) | g) << 8); } -#define FL_NUM_GRAY 24 inline Fl_Color fl_gray_ramp(int i) {return (Fl_Color)(i+FL_GRAY_RAMP);} -#define FL_NUM_RED 5 -#define FL_NUM_GREEN 8 -#define FL_NUM_BLUE 5 inline Fl_Color fl_color_cube(int r, int g, int b) { return (Fl_Color)((b*FL_NUM_RED + r) * FL_NUM_GREEN + g + FL_COLOR_CUBE);} @@ -378,5 +388,5 @@ enum Fl_Damage { #endif // -// End of "$Id: Enumerations.H,v 1.18.2.14.2.21 2002/03/25 21:08:41 easysw Exp $". +// End of "$Id: Enumerations.H,v 1.18.2.14.2.22 2002/04/11 10:46:19 easysw Exp $". // diff --git a/documentation/enumerations.html b/documentation/enumerations.html index 9651a9e22..8c6c98951 100644 --- a/documentation/enumerations.html +++ b/documentation/enumerations.html @@ -1,9 +1,11 @@

C - FLTK Enumerations

- This appendix lists the enumerations provided in the -<FL/Enumerations.H> header file, organized by section. -Constants whose value is zero are marked with "(0)", this is often -useful to know when programming. + +

This appendix lists the enumerations provided in the +<FL/Enumerations.H> header file, organized by +section. Constants whose value is zero are marked with "(0)", +this is often useful to know when programming. +

Version Numbers

The FLTK version number is stored in a number of compile-time constants: @@ -177,42 +179,93 @@ bold-oblique.

Colors

- The following color constants can be used to access the colors in the -FLTK standard color palette: + +

The Fl_Color enumeration type holds a FLTK color value. +Colors are either 8-bit indexes into a virtual colormap or 24-bit RGB +color values. Color indices occupy the lower 8 bits of the value, while +RGB colors occupy the upper 24 bits, for a byte organization of RGBI. + +

Color Constants

+ +

Constants are defined for the user-defined foreground and background +colors, as well as specific colors and the start of the grayscale ramp +and color cube in the virtual colormap. Inline functions are provided to +retrieve specific grayscale, color cube, or RGB color values. + +

The following color constants can be used to access the user-defined +colors: +

-In addition there are two inline functions to allow you to select -grays or colors from the FLTK colormap: +

The following color constants can be used to access the colors from the +FLTK standard color cube: -

Fl_Color fl_gray_ramp(int i) -
Returns a gray color. Returns black for zero, returns white for -FL_NUM_GRAY (which is 24) minus 1. To get the closest to an -8-bit gray value 'I' use -fl_gray_ramp(I*FL_NUM_GRAY/256) +

+ +

The inline methods for getting a grayscale, color cube, or RGB color +value are described next. + +

Color Functions

+ +

Fl_Color fl_gray_ramp(int i)

+ +

Returns a gray color value from black (i == 0) to +white (i == FL_NUM_GRAY - 1). FL_NUM_GRAY is +defined to be 24 in the current FLTK release. To get the closest +FLTK gray value to an 8-bit grayscale color 'I' use: + +

+ +

Fl_Color fl_color_cube(int r, int g, int b)

+ +

Returns a color out of the color cube. r must be in the range 0 to FL_NUM_RED (5) minus 1. g must be in the range 0 to FL_NUM_GREEN (8) minus 1. b must be in the range 0 to FL_NUM_BLUE (5) minus 1. -To get the closest color to a 8-bit set of R,G,B values use -fl_color_cube(R*FL_NUM_RED/256, G*FL_NUM_GREEN/256, -B*FL_NUM_BLUE/256); +

To get the closest color to a 8-bit set of R,G,B values use: -

Fl_Color fl_rgb_color(uchar r, uchar g, uchar b) +

+ +

Fl_Color fl_rgb_color(uchar r, uchar g, uchar b)
+Fl_Color fl_rgb_color(uchar g)

+ +

Returns the 24-bit RGB color value for the specified 8-bit +RGB or grayscale values.

Cursors

@@ -220,30 +273,40 @@ B*FL_NUM_BLUE/256); FLTK. The double-headed arrows are bitmaps provided by FLTK on X, the others are provided by system-defined cursors.

+ +

FD "When" Conditions

+ +

Damage Masks

The following damage mask bits are used by the standard FLTK widgets: