summaryrefslogtreecommitdiff
path: root/FL/Enumerations.H
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2009-09-27 11:06:56 +0000
committerMatthias Melcher <fltk@matthiasm.com>2009-09-27 11:06:56 +0000
commitc8adc2fdded2081cb8dd8ba4b72b2703fc74889b (patch)
treebb59bec7b0ab67547e857e2a47bb6753684a9e96 /FL/Enumerations.H
parente91ec4b3b300c9c1b1e5b54aded1cab5c7e1a571 (diff)
Fixed a few minor issues with Xcode builds. Fixed all color related call to Fl_Color type (STR #2208). Changed Fl_Color back to typedef unsigned.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6902 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL/Enumerations.H')
-rw-r--r--FL/Enumerations.H107
1 files changed, 63 insertions, 44 deletions
diff --git a/FL/Enumerations.H b/FL/Enumerations.H
index 6e6cd0ef3..e3e53eb36 100644
--- a/FL/Enumerations.H
+++ b/FL/Enumerations.H
@@ -699,7 +699,7 @@ extern FL_EXPORT Fl_Fontsize FL_NORMAL_SIZE; ///< normal font size
/** \name Colors */
/*@{*/
-/** The Fl_Color enumeration type holds a FLTK color value.
+/** The Fl_Color type holds an FLTK color value.
Colors are either 8-bit indexes into a virtual colormap
or 24-bit RGB color values.
@@ -707,75 +707,94 @@ extern FL_EXPORT Fl_Fontsize FL_NORMAL_SIZE; ///< normal font size
Color indices occupy the lower 8 bits of the value, while
RGB colors occupy the upper 24 bits, for a byte organization of RGBI.
- \todo enum Fl_Color needs some more comments for values,
- see Fl/Enumerations.H
+<pre>
+ Fl_Color => 0xrrggbbii
+ | | | |
+ | | | +--- index between 0 and 255
+ | | +----- blue color component (8 bit)
+ | +------- green component (8 bit)
+ +--------- red component (8 bit)
+ </pre>
+
+ A color can have either an index or an rgb value. Colors with rgb set
+ and an index >0 are reserved for special use.
+
*/
-enum Fl_Color { // standard colors
- // These are used as default colors in widgets and altered as necessary
- FL_FOREGROUND_COLOR = 0, ///< the default foreground color (0) used for labels and text
- FL_BACKGROUND2_COLOR = 7, ///< the default background color for text, list, and valuator widgets
- FL_INACTIVE_COLOR = 8, ///< the inactive foreground color
- FL_SELECTION_COLOR = 15, ///< the default selection/highlight color
+typedef unsigned int Fl_Color;
+
+// Standard colors. These are used as default colors in widgets and altered as necessary
+const Fl_Color FL_FOREGROUND_COLOR = 0; ///< the default foreground color (0) used for labels and text
+const Fl_Color FL_BACKGROUND2_COLOR = 7; ///< the default background color for text, list, and valuator widgets
+const Fl_Color FL_INACTIVE_COLOR = 8; ///< the inactive foreground color
+const Fl_Color FL_SELECTION_COLOR = 15; ///< the default selection/highlight color
// 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_BACKGROUND_COLOR = 49, // 'R' default background color
- FL_LIGHT1 = 50, // 'S'
- FL_LIGHT2 = 52, // 'U'
- FL_LIGHT3 = 54, // 'W'
+const Fl_Color FL_GRAY0 = 32; // 'A'
+const Fl_Color FL_DARK3 = 39; // 'H'
+const Fl_Color FL_DARK2 = 45; // 'N'
+const Fl_Color FL_DARK1 = 47; // 'P'
+const Fl_Color FL_BACKGROUND_COLOR = 49; // 'R' default background color
+const Fl_Color FL_LIGHT1 = 50; // 'S'
+const Fl_Color FL_LIGHT2 = 52; // 'U'
+const Fl_Color FL_LIGHT3 = 54; // 'W'
// 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_DARK_RED = 72,
-
- FL_DARK_GREEN = 60,
- FL_DARK_YELLOW = 76,
- FL_DARK_BLUE = 136,
- FL_DARK_MAGENTA = 152,
- FL_DARK_CYAN = 140,
-
- 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
+const Fl_Color FL_BLACK = 56;
+const Fl_Color FL_RED = 88;
+const Fl_Color FL_GREEN = 63;
+const Fl_Color FL_YELLOW = 95;
+const Fl_Color FL_BLUE = 216;
+const Fl_Color FL_MAGENTA = 248;
+const Fl_Color FL_CYAN = 223;
+const Fl_Color FL_DARK_RED = 72;
+
+const Fl_Color FL_DARK_GREEN = 60;
+const Fl_Color FL_DARK_YELLOW = 76;
+const Fl_Color FL_DARK_BLUE = 136;
+const Fl_Color FL_DARK_MAGENTA = 152;
+const Fl_Color FL_DARK_CYAN = 140;
+
+const Fl_Color 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); }
+
/** return 24-bit color value closest to \p r, \p g, \p b. */
inline Fl_Color fl_rgb_color(uchar r, uchar g, uchar b) {
if (!r && !g && !b) return FL_BLACK;
else return (Fl_Color)(((((r << 8) | g) << 8) | b) << 8);
}
+
/** return 24-bit color value closest to \p grayscale */
inline Fl_Color fl_rgb_color(uchar g) {
if (!g) return FL_BLACK;
else return (Fl_Color)(((((g << 8) | g) << 8) | g) << 8);
}
+
inline Fl_Color fl_gray_ramp(int i) {return (Fl_Color)(i+FL_GRAY_RAMP);}
+
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);}