1 | // |
---|
2 | // "$Id: Color.h 3203 2004-01-25 06:55:06Z spitzak $" |
---|
3 | // |
---|
4 | // Color value. These are 32-bit unsigned numbers with RGB as the |
---|
5 | // upper 3 bytes. The lowest-order byte is treated as an "index" |
---|
6 | // for back compatabilty, or as an "alpha", depending on context. |
---|
7 | // |
---|
8 | // Copyright 2002 by Bill Spitzak and others. |
---|
9 | // |
---|
10 | // This library is free software; you can redistribute it and/or |
---|
11 | // modify it under the terms of the GNU Library General Public |
---|
12 | // License as published by the Free Software Foundation; either |
---|
13 | // version 2 of the License, or (at your option) any later version. |
---|
14 | // |
---|
15 | // This library is distributed in the hope that it will be useful, |
---|
16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | // Library General Public License for more details. |
---|
19 | // |
---|
20 | // You should have received a copy of the GNU Library General Public |
---|
21 | // License along with this library; if not, write to the Free Software |
---|
22 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
23 | // USA. |
---|
24 | // |
---|
25 | // Please report all bugs and problems to "fltk-bugs@fltk.org". |
---|
26 | // |
---|
27 | |
---|
28 | #ifndef fltk_Color_h |
---|
29 | #define fltk_Color_h |
---|
30 | |
---|
31 | #include "FL_API.h" |
---|
32 | #include "Flags.h" |
---|
33 | |
---|
34 | namespace fltk { |
---|
35 | |
---|
36 | /*! \addtogroup color |
---|
37 | \{ */ |
---|
38 | |
---|
39 | typedef unsigned Color; |
---|
40 | |
---|
41 | /*! Symbolic names for some of the indexed colors. |
---|
42 | |
---|
43 | The 24-entry "gray ramp" is modified by fltk::set_background() so |
---|
44 | that the color fltk::GRAY75 is the background color, and the others |
---|
45 | are a nice range from black to white. These are used to draw box |
---|
46 | edges. The gray levels are chosen to be evenly spaced, listed here |
---|
47 | is the actual 8-bit and decimal gray level assigned by default. |
---|
48 | Also listed here is the letter used for fltk::FrameBox and the old |
---|
49 | fltk1.1 names used for these levels. |
---|
50 | |
---|
51 | The remiander of the colormap is a 5x8x5 color cube. This cube is |
---|
52 | used to dither images on 8-bit screens X colormaps to reduce the |
---|
53 | number of colors used. |
---|
54 | */ |
---|
55 | enum { |
---|
56 | NO_COLOR = 0, /*!< Black, empty place holder in Style */ |
---|
57 | |
---|
58 | // Hex Decimal FrameBox Old names |
---|
59 | GRAY00 = 32, /*!< 00 .00 A fltk1: GRAY0 GRAY_RAMP */ |
---|
60 | GRAY05 = 33, /*!< 0d .05 B */ |
---|
61 | GRAY10 = 34, /*!< 1a .10 C */ |
---|
62 | GRAY15 = 35, /*!< 26 .15 D */ |
---|
63 | GRAY20 = 36, /*!< 31 .19 E */ |
---|
64 | GRAY25 = 37, /*!< 3d .24 F */ |
---|
65 | GRAY30 = 38, /*!< 48 .28 G */ |
---|
66 | GRAY33 = 39, /*!< 55 .33 H fltk1: DARK3 */ |
---|
67 | GRAY35 = 40, /*!< 5f .37 I */ |
---|
68 | GRAY40 = 41, /*!< 6a .42 J (18% gray card) */ |
---|
69 | GRAY45 = 42, /*!< 75 .46 K */ |
---|
70 | GRAY50 = 43, /*!< 80 .50 L */ |
---|
71 | GRAY55 = 44, /*!< 8a .54 M */ |
---|
72 | GRAY60 = 45, /*!< 95 .58 N fltk1: DARK2 */ |
---|
73 | GRAY65 = 46, /*!< a0 .63 O */ |
---|
74 | GRAY66 = 47, /*!< aa .67 P fltk1: DARK1 INACTIVE_COLOR */ |
---|
75 | GRAY70 = 48, /*!< b5 .71 Q */ |
---|
76 | GRAY75 = 49, /*!< c0 .75 R fltk1: GRAY SELECTION_COLOR */ |
---|
77 | GRAY80 = 50, /*!< cb .80 S */ |
---|
78 | GRAY85 = 51, /*!< d5 .84 T fltk1: LIGHT1 */ |
---|
79 | //unnamed entry e0 .88 U |
---|
80 | GRAY90 = 53, /*!< ea .92 V fltk1: LIGHT2 */ |
---|
81 | GRAY95 = 54, /*!< f5 .96 W */ |
---|
82 | GRAY99 = 55, /*!< ff 1.00 X fltk1: LIGHT3 */ |
---|
83 | |
---|
84 | BLACK = 0x38, /*!< Corner of color cube */ |
---|
85 | RED = 0x58, /*!< Corner of color cube */ |
---|
86 | GREEN = 0x3f, /*!< Corner of color cube */ |
---|
87 | YELLOW = 0x5f, /*!< Corner of color cube */ |
---|
88 | BLUE = 0xd8, /*!< Corner of color cube */ |
---|
89 | MAGENTA = 0xf8, /*!< Corner of color cube */ |
---|
90 | CYAN = 0xdf, /*!< Corner of color cube */ |
---|
91 | WHITE = 0xff, /*!< Corner of color cube */ |
---|
92 | |
---|
93 | WINDOWS_BLUE = 0x88 /*!< default selection_color */ |
---|
94 | }; |
---|
95 | |
---|
96 | inline Color color(unsigned char r, unsigned char g, unsigned char b) { |
---|
97 | return Color((r<<24)+(g<<16)+(b<<8));} |
---|
98 | inline Color color(unsigned char g) { |
---|
99 | return Color(g*0x1010100u);} |
---|
100 | FL_API Color color(const char*); |
---|
101 | FL_API Color lerp(Color c0, Color c1, float f); |
---|
102 | FL_API Color inactive(Color); |
---|
103 | FL_API Color inactive(Color, Flags f); |
---|
104 | FL_API Color contrast(Color fg, Color bg); |
---|
105 | FL_API void split_color(Color c, unsigned char& r, unsigned char& g, unsigned char& b); |
---|
106 | FL_API void set_color_index(Color index, Color); |
---|
107 | FL_API Color get_color_index(Color index); |
---|
108 | FL_API void set_background(Color); |
---|
109 | FL_API Color nearest_index(Color); |
---|
110 | |
---|
111 | /* \} */ |
---|
112 | } |
---|
113 | |
---|
114 | #endif |
---|
115 | |
---|
116 | // |
---|
117 | // End of "$Id: Color.h 3203 2004-01-25 06:55:06Z spitzak $". |
---|
118 | // |
---|