OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of windowing system color classes
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_COLOR_H)
10#define OWL_COLOR_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/objstrm.h> // Need persist streaming classes & operators
18#include <owl/wsysinc.h>
19
20//Hue/Lumination/Saturation Color definition, thanks to Luigi Bianchi
21///////////////////////////////////////////////////////////////////////////////
23#define HLS(h,l,s) (static_cast<HLSCOLOR>((static_cast<BYTE>(h)|(static_cast<WORD>(static_cast<BYTE>(l))<<8))|((static_cast<DWORD>(static_cast<BYTE>(s)))<<16)))
24#define HLS_H(hls) (static_cast<BYTE>(hls))
25#define HLS_L(hls) (static_cast<BYTE>((static_cast<WORD>(hls)) >> 8))
26#define HLS_S(hls) (static_cast<BYTE>((hls)>>16))
27
28
29
30namespace owl {
31
32//
33/// Functions to convert number of bits to number of palette colors and back,
34/// and build an RGB COLORREF
35//
38
39//
40// Convert the red, green, and blue components into a COLORREF.
41//
43{
44 return COLORREF((r & 0xFF) |
45 ((g & 0xFF) << 8) |
46 ((uint32(b) & 0xFF) << 16)
47 );
48}
49
50// 125 predefined COLORREF color definitions for OWL programs.
51// Comments : Many of these colors were converted from the
52// color definitions in the POVRAY 2.2 include file
53// COLORS.INC. Thanks POV-Team!
54// Author : Rob McGregor, rob_mcgregor@compuserve.com
55
56//
57// Define RGB macros for various colors
58//
59
60// A
61#define CLR_AQUAMARINE RGB(112, 219, 147)
62
63// B
64#define CLR_BAKERSCHOC RGB(92, 51, 23)
65#define CLR_BLACK RGB(0, 0, 0)
66#define CLR_BLUE RGB(0, 0, 255)
67#define CLR_BLUEVIOLET RGB(159, 95, 159)
68#define CLR_BRIGHTGOLD RGB(217, 217, 26)
69#define CLR_BRONZE1 RGB(140, 120, 36)
70#define CLR_BRONZE2 RGB(166, 125, 61)
71#define CLR_BROWN RGB(165, 42, 42)
72
73// C
74#define CLR_CADETBLUE RGB(95, 159, 159)
75#define CLR_CLEAR RGB(255, 255, 255)
76#define CLR_COOLCOPPER RGB(217, 135, 26)
77#define CLR_COPPER RGB(184, 115, 51)
78#define CLR_CORAL RGB(255, 127, 0)
79#define CLR_CORNFLOWERBLUE RGB(66, 66, 111)
80#define CLR_CYAN RGB(0, 255, 255)
81
82// D
83#define CLR_DARKBROWN RGB(92, 64, 51)
84#define CLR_DARKGREEN RGB(47, 79, 47)
85#define CLR_DARKOLIVEGREEN RGB(79, 79, 47)
86#define CLR_DARKORCHID RGB(153, 50, 204)
87#define CLR_DARKPURPLE RGB(135, 31, 120)
88#define CLR_DARKSLATEBLUE RGB(107, 35, 142)
89#define CLR_DARKSLATEGRAY RGB(47, 79, 79)
90#define CLR_DARKSLATEGREY RGB(47, 79, 79)
91#define CLR_DARKTAN RGB(150, 105, 79)
92#define CLR_DARKTURQUOISE RGB(112, 147, 219)
93#define CLR_DARKWOOD RGB(133, 94, 66)
94#define CLR_DIMGRAY RGB(84, 84, 84)
95#define CLR_DIMGREY RGB(84, 84, 84)
96#define CLR_DKGREENCOPPER RGB(74, 117, 110)
97#define CLR_DUSTYROSE RGB(133, 99, 99)
98
99// F
100#define CLR_FELDSPAR RGB(209, 145, 117)
101#define CLR_FIREBRICK RGB(142, 35, 35)
102#define CLR_FLESH RGB(245, 204, 176)
103#define CLR_FORESTGREEN RGB(35, 142, 35)
104
105// G
106#define CLR_GOLD RGB(204, 127, 50)
107#define CLR_GOLDENROD RGB(219, 219, 112)
108#define CLR_GRAY RGB(192, 192, 192)
109#define CLR_GRAY05 RGB(13, 13, 13)
110#define CLR_GRAY10 RGB(26, 26, 26)
111#define CLR_GRAY15 RGB(38, 38, 38)
112#define CLR_GRAY20 RGB(51, 51, 51)
113#define CLR_GRAY25 RGB(64, 64, 64)
114#define CLR_GRAY30 RGB(77, 77, 77)
115#define CLR_GRAY35 RGB(89, 89, 89)
116#define CLR_GRAY40 RGB(102, 102, 102)
117#define CLR_GRAY45 RGB(115, 115, 115)
118#define CLR_GRAY50 RGB(128, 128, 128)
119#define CLR_GRAY55 RGB(140, 140, 140)
120#define CLR_GRAY60 RGB(153, 153, 153)
121#define CLR_GRAY65 RGB(166, 166, 166)
122#define CLR_GRAY70 RGB(178, 178, 178)
123#define CLR_GRAY75 RGB(191, 191, 191)
124#define CLR_GRAY80 RGB(204, 204, 204)
125#define CLR_GRAY85 RGB(217, 217, 217)
126#define CLR_GRAY90 RGB(229, 229, 229)
127#define CLR_GRAY95 RGB(242, 242, 242)
128#define CLR_GREEN RGB(0, 255, 0)
129#define CLR_GREENCOPPER RGB(82, 125, 117)
130#define CLR_GREENYELLOW RGB(147, 219, 112)
131#define CLR_GREY RGB(192, 192, 192)
132
133// H
134#define CLR_HUNTERSGREEN RGB(33, 94, 79)
135
136// I
137#define CLR_INDIANRED RGB(79, 47, 47)
138
139// K
140#define CLR_KHAKI RGB(159, 159, 95)
141
142// L
143#define CLR_LIGHTBLUE RGB(191, 216, 216)
144#define CLR_LIGHTGRAY RGB(168, 168, 168)
145#define CLR_LIGHTGREY RGB(168, 168, 168)
146#define CLR_LIGHTSTEELBLUE RGB(143, 143, 188)
147#define CLR_LIGHTWOOD RGB(232, 194, 166)
148#define CLR_LIMEGREEN RGB(50, 204, 50)
149
150// M
151#define CLR_MAGENTA RGB(255, 0, 255)
152#define CLR_MANDARINORANGE RGB(227, 120, 51)
153#define CLR_MAROON RGB(142, 35, 107)
154#define CLR_MEDIUMAQUAMARINE RGB(50, 204, 153)
155#define CLR_MEDIUMBLUE RGB(50, 50, 204)
156#define CLR_MEDIUMFORESTGREEN RGB(107, 142, 35)
157#define CLR_MEDIUMGOLDENROD RGB(234, 234, 173)
158#define CLR_MEDIUMORCHID RGB(147, 112, 219)
159#define CLR_MEDIUMSEAGREEN RGB(66, 111, 66)
160#define CLR_MEDIUMSLATEBLUE RGB(127, 0, 255)
161#define CLR_MEDIUMSPRINGGREEN RGB(127, 255, 0)
162#define CLR_MEDIUMTURQUOISE RGB(112, 219, 219)
163#define CLR_MEDIUMVIOLETRED RGB(219, 112, 147)
164#define CLR_MEDIUMWOOD RGB(166, 128, 99)
165#define CLR_MICA RGB(0, 0, 0)
166#define CLR_MIDNIGHTBLUE RGB(47, 47, 79)
167
168// N
169#define CLR_NAVY RGB(35, 35, 142)
170#define CLR_NAVYBLUE RGB(35, 35, 142)
171#define CLR_NEONBLUE RGB(77, 77, 255)
172#define CLR_NEONPINK RGB(255, 110, 199)
173#define CLR_NEWMIDNIGHTBLUE RGB(0, 0, 156)
174#define CLR_NEWTAN RGB(235, 199, 158)
175
176// O
177#define CLR_OFFWHITE RGB(240, 240, 240)
178#define CLR_ORANGE RGB(255, 128, 0)
179#define CLR_ORANGERED RGB(255, 0, 127)
180#define CLR_ORCHID RGB(219, 112, 219)
181
182// P
183#define CLR_PALEGREEN RGB(143, 188, 143)
184#define CLR_PINK RGB(188, 143, 143)
185#define CLR_PLUM RGB(234, 173, 234)
186
187// Q
188#define CLR_QUARTZ RGB(217, 217, 242)
189
190// R
191#define CLR_RED RGB(255, 0, 0)
192#define CLR_RICHBLUE RGB(89, 89, 171)
193
194// S
195#define CLR_SALMON RGB(111, 66, 66)
196#define CLR_SCARLET RGB(140, 23, 23)
197#define CLR_SEAGREEN RGB(35, 142, 107)
198#define CLR_SEMISWEETCHOC RGB(107, 66, 38)
199#define CLR_SIENNA RGB(142, 107, 35)
200#define CLR_SILVER RGB(229, 232, 250)
201#define CLR_SKYBLUE RGB(50, 153, 204)
202#define CLR_SLATEBLUE RGB(0, 127, 255)
203#define CLR_SPICYPINK RGB(255, 28, 173)
204#define CLR_SPRINGGREEN RGB(0, 255, 127)
205#define CLR_STEELBLUE RGB(35, 107, 142)
206#define CLR_SUMMERSKY RGB(56, 176, 222)
207
208// T
209#define CLR_TAN RGB(219, 147, 112)
210#define CLR_THISTLE RGB(216, 191, 216)
211#define CLR_TURQUOISE RGB(173, 234, 234)
212
213// V
214#define CLR_VERYDARKBROWN RGB(89, 41, 36)
215#define CLR_VIOLET RGB(79, 47, 79)
216#define CLR_VIOLETRED RGB(204, 50, 153)
217#define CLR_VLIGHTGREY RGB(204, 204, 204)
218
219// W
220#define CLR_WHEAT RGB(216, 216, 191)
221#define CLR_WHITE RGB(255, 255, 255)
222
223// Y
224#define CLR_YELLOW RGB(255, 255, 0)
225#define CLR_YELLOWGREEN RGB(153, 204, 50)
226
227///////////////////////////////////////////////////////////////////
228class _OWLCLASS TColor;
229
230//
231// forward definitions
233owl::opstream& operator <<(owl::opstream& os, const TColor& c);
234
235#include <owl/preclass.h>
236
237/// \addtogroup graphics
238/// @{
239/// \class TColor
240// ~~~~~ ~~~~~~
241/// \brief Class wrapper for management of color values.
242/// \brief Internally, all colors are stored as a COLORREF.
243//
245{
246 public:
247 // Constructors
248 //
249 TColor();
250 TColor(const TColor& src);
251
253
254 TColor(int r, int g, int b);
255 TColor(int r, int g, int b, int f);
256
257 TColor(const PALETTEENTRY & pe);
258 TColor(const RGBQUAD & q);
259 TColor(const RGBTRIPLE & t);
260
261 static TColor CreateFromPaletteIndex(int index);
262
263 // Conversion operator & value accessor
264 //
265 operator COLORREF() const;
266 COLORREF GetValue() const;
267 void SetValue(const COLORREF& value);
268
269 // Comparison operators
270 //
271 bool operator ==(const TColor& other) const;
272 bool operator !=(const TColor& other) const;
273 bool operator ==(COLORREF cr) const;
274 bool operator !=(COLORREF cr) const;
275
276 TColor& operator =(const TColor& src);
277
278 // Accessors
279 //
280 int Index() const;
281 TColor Rgb() const;
282 TColor PalIndex() const;
283 TColor PalRelative() const;
284
285 uint8 Red() const;
286 uint8 Green() const;
287 uint8 Blue() const;
288 uint8 Flags() const;
289 bool IsSysColor() const;
290 bool IsSpecialColor() const;
291
292 // Additional methods
293 //
294 void Lighten(uint8 val);
295 void Darken(uint8 val);
296 void Merge(const TColor& other);
297
298 //HLS conversion methods
299 HLSCOLOR Rgb2Hls() const;
300 void Hls2Rgb(HLSCOLOR hls);
301 void HlsTransform(int percent_L, int percent_S);
302
303 // Common RGB color values
304 //
305 static const TColor Black;
306 static const TColor LtGray;
307 static const TColor Gray;
308 static const TColor LtRed;
309 static const TColor LtGreen;
310 static const TColor LtYellow;
311 static const TColor LtBlue;
312 static const TColor LtMagenta;
313 static const TColor LtCyan;
314 static const TColor White;
315
316 // Special color values
317 //
318 static const TColor None; ///< not-a-color
319 static const TColor Transparent; ///< a non-painting color
320
321 // Symbolic system color values. Perform GetSysColor() on conversion to
322 // COLORREF
323 //
324 static const TColor SysScrollbar;
325 static const TColor SysDesktop;
328 static const TColor SysMenu;
329 static const TColor SysWindow;
330 static const TColor SysWindowFrame;
331 static const TColor SysMenuText;
332 static const TColor SysWindowText;
333 static const TColor SysCaptionText;
337 static const TColor SysHighlight;
339 static const TColor Sys3dFace;
340 static const TColor Sys3dShadow;
341 static const TColor SysGrayText;
342 static const TColor SysBtnText;
344 static const TColor Sys3dHilight;
345 static const TColor Sys3dDkShadow;
346 static const TColor Sys3dLight;
347 static const TColor SysInfoText;
348 static const TColor SysInfoBk;
349
350 private:
351 COLORREF Value; // The 32bit color value type (not a struct)
352
353 TColor(int index); // = delete; // Obsolete. Use CreateFromPaletteIndex instead.
354
357};
358
359
360//
361/// \class TPaletteEntry
362// ~~~~~ ~~~~~~~~~~~~~
363/// Wrapper for Windows' PALETTEENTRY type
364//
365/// TPaletteEntry is a support class derived from the structure tagPALETTEENTRY. The
366/// latter is defined as follows:
367/// \code
368/// typedef struct tagPALETTEENTRY {
369/// uint8 peRed;
370/// uint8 peGreen;
371/// uint8 peBlue;
372/// uint8 peFlags;
373/// } PALETTEENTRY;
374/// \endcode
375/// The members peRed, peGreen, and peBlue specify the red, green, and blue
376/// intensity-values for a palette entry.
377///
378/// The peFlags member can be set to NULL or one of the following values:
379/// - \c \b PC_EXPLICIT Specifies that the low-order word of the logical palette entry
380/// designates a hardware palette index. This flag allows the application to show
381/// the contents of the display device palette.
382/// - \c \b PC_NOCOLLAPSE Specifies that the color be placed in an unused entry in the
383/// system palette instead of being matched to an existing color in the system
384/// palette. If there are no unused entries in the system palette, the color is
385/// matched normally. Once this color is in the system palette, colors in other
386/// logical palettes can be matched to this color.
387/// - \c \b PC_RESERVED Specifies that the logical palette entry be used for palette
388/// animation; this prevents other windows from matching colors to this palette
389/// entry since the color frequently changes. If an unused system-palette entry is
390/// available, this color is placed in that entry. Otherwise, the color is available
391/// for animation.
392///
393/// TPaletteEntry is used in conjunction with the classes TPalette and TColor to
394/// simplify logical color-palette operations. Constructors are provided to create
395/// TPaletteEntry objects from explicit COLORREF and RGB values, or from TColor
396/// objects.
397//
398class TPaletteEntry : public tagPALETTEENTRY {
399 public:
400 TPaletteEntry(int r, int g, int b, int f = 0);
401 TPaletteEntry(const TColor& c);
402
403 bool operator ==(COLORREF cr) const;
404};
405
406
407//
408/// \class TRgbQuad
409// ~~~~~ ~~~~~~~~
410/// Wrapper for Windows' RBGQUAD type
411//
412/// TRgbQuad is a support class derived from the structure tagRGBQUAD, which is
413/// defined as follows:
414/// \code
415/// typedef struct tagRGBQUAD {
416/// uint8 rgbBlue;
417/// uint8 rgbGreen;
418/// uint8 rgbRed;
419/// uint8 rgbReserved;
420/// } RGBQUAD;
421/// \endcode
422/// The elements rgbBlue, rgbGreen, and rgbRed specify the relative blue, green, and
423/// red intensities of a color. rgbReserved is not used and must be set to 0.
424///
425/// TRgbQuad is used in conjunction with the classes TPalette and TColor to simplify
426/// RGBQUAD-based color operations. Constructors are provided to create TRgbQuad
427/// objects from explicit RGB values, from TColor objects, or from other TRgbQuad
428/// objects.
429//JJH
430#ifdef WINELIB
431class TRgbQuad : public RGBQUAD {
432#else
433class TRgbQuad : public tagRGBQUAD {
434#endif
435 public:
436 TRgbQuad(int r, int g, int b);
437 TRgbQuad(const TColor& c);
438 TRgbQuad(const RGBQUAD & q);
439
440 bool operator ==(COLORREF cr) const;
441};
442
443
444//
445/// \class TRgbTriple
446// ~~~~~ ~~~~~~~~~~
447/// Wrapper for Windows' RBGTRIPLE type
448//
449/// TRgbTriple is a support class derived from the structure tagRgbTriple, which is
450/// defined as follows:
451/// \code
452/// typedef struct tagRGBTRIPLE {
453/// uint8 rgbBlue;
454/// uint8 rgbGreen;
455/// uint8 rgbRed;
456/// } RGBTRIPLE;
457/// \endcode
458/// The members rgbBlue, rgbGreen, and rgbRed specify the relative blue, green, and
459/// red intensities for a color.
460/// TRgbTriple is used in conjunction with the classes TPalette and TColor to
461/// simplify bmci-color-based operations. Constructors are provided to create
462/// TRgbTriple objects from explicit RGB values, from TColor objects, or from other
463/// TRgbTriple objects.
464//JJH
465#ifdef WINELIB
466class TRgbTriple : public RGBTRIPLE {
467#else
468class TRgbTriple : public tagRGBTRIPLE {
469#endif
470 public:
471 TRgbTriple(int r, int g, int b);
472 TRgbTriple(const TColor& c);
473 TRgbTriple(const RGBTRIPLE & t);
474
475 bool operator ==(COLORREF cr) const;
476};
477/// @}
478
479#include <owl/posclass.h>
480
481
482//----------------------------------------------------------------------------
483// Inline Implementations
484//
485
486//
487/// Extract the color value from a persistent input stream.
488//
490{
491 is >> c.Value;
492 return is;
493}
494
495//
496/// Insert the color value into a persistent output stream.
497//
499{
500 os << c.Value;
501 return os;
502}
503
504//
505/// Construct a null color.
506/// The default constructor sets Value to 0.
507//
508inline
509TColor::TColor()
510:
511 Value(0)
512{
513}
514
515//
516/// Construct a color as a copy of another color.
517//
518inline
520:
521 Value(src.Value)
522{
523}
524
525//
526/// Construct a color with an existing COLORREF value.
527//
528inline
530:
531 Value(value)
532{
533}
534
535//
536/// Construct a color given the red, green, and blue components of color.
537//
538inline
539TColor::TColor(int r, int g, int b)
540:
541 Value(MkRGB(r, g, b))
542{
543}
544
545//
546/// Construct a color given red, green, blue, and flag components of color.
547//
548/// The flag component is defined in the Windows SDK reference.
549//
550inline
551TColor::TColor(int r, int g, int b, int f)
552:
553 Value(((uint32) f << 24) | MkRGB(r, g, b))
554{
555}
556
557//
558/// Construct a color that is an index into a palette.
559//
560inline
562{
563 return TColor(PALETTEINDEX(index));
564}
565
566//
567/// Construct a color based on an existing PALETTEENTRY.
568//
569inline
571:
572 Value(MkRGB(pe.peRed, pe.peGreen, pe.peBlue))
573{
574}
575
576//
577/// Construct a color based on an existing RGBQUAD.
578//
579inline
581:
582 Value(MkRGB(q.rgbRed, q.rgbGreen, q.rgbBlue))
583{
584}
585
586//
587/// Construct a color based on an existing RGBTRIPLE.
588//
589inline
591:
592 Value(MkRGB(t.rgbtRed, t.rgbtGreen, t.rgbtBlue))
593{
594}
595
596//
597/// Convert the stored color into a COLORREF.
598//
599inline
600TColor::operator COLORREF() const
601{
602 return GetValue();
603}
604
605//
606/// Return true if two colors are equal.
607//
608/// This function compares between two binary representation of colors, it
609/// does not compare colors logically.
610///
611/// For example, if palette entry 4 is solid red (rgb components (255, 0, 0)),
612/// the following will return false:
613/// \code
614/// if (TColor(4) == TColor(255, 0, 0))
615/// /* colors match */
616/// else
617/// /* colors do not match */
618/// \endcode
619/// To actually compare the RGB values of two TColor objects, use the
620/// operator == (COLORREF). For example,
621/// \code
622/// TColor colorA, colorB;
623/// if (colorA == colorB.GetValue()) {
624/// // ColorA & ColorB
625/// }
626/// \endcode
627//
628inline bool
630{
631 return Value == other.Value;
632}
633
634//
635/// Return true if two colors are not equal.
636//
637/// See additional comments in TColor::operator ==.
638//
639inline bool
641{
642 return Value != other.Value;
643}
644
645//
646/// Return true if this color matches a COLORREF.
647//
648/// See additional comments in TColor::operator ==.
649//
650inline bool
652{
653 return GetValue() == cr;
654}
655
656//
657/// Return true if this color does not match a COLORREF.
658//
659/// See additional comments in TColor::operator ==.
660//
661inline bool
663{
664 return GetValue() != cr;
665}
666
667//
668/// Change the color after it has been constructed.
669//
670inline void
672{
673 Value = value;
674}
675
676//
677/// Set the value of color after it has been constructed.
678//
679inline TColor&
681{
682 Value = src.Value;
683 return *this;
684}
685
686//
687/// Return the index of the palette entry.
688//
689inline int
691{
692 return (int)Value & 0xFFFF;
693}
694
695//
696/// Return the RGB color value.
697//
698inline TColor
700{
701 return GetValue();
702}
703
704//
705/// Return the palette index.
706// Assumes that the color really is a palette index
707//
708inline TColor
710{
711// return (COLORREF)Index() | 0x01000000UL;
712 return (COLORREF) ((COLORREF)Index() | 0x01000000UL);
713}
714
715//
716/// Return the palette relative entry.
717//
718inline TColor
720{
721// return Rgb() | 0x02000000UL;
722 return (COLORREF) ((COLORREF)Rgb() | 0x02000000UL);
723}
724
725//
726/// Return the flags entry.
727//
728inline uint8
730{
731 return static_cast<uint8>(static_cast<uint16>((Value >> 24)));
732}
733
734//
735/// Return true if the color is a system color.
736//
737inline bool
739{
740 return (Value & 0xF0000000UL) == 0x80000000UL;
741//DLN UNIX change because MainWin uses high byte too return (Value & 0xFF000000UL) == 0x80000000UL;
742
743}
744
745//
746/// Return true if the color is a special color (currently None or Transparent)
747//
748inline bool
750{
751 return (Value & 0xF0000000UL) == 0xF0000000UL;
752}
753
754//
755/// Creates a palette entry object with peRed, peGreen, peBlue, and peFlags set to
756/// r, g, b, and f, respectively.
757//
758inline
759TPaletteEntry::TPaletteEntry(int r, int g, int b, int f)
760{
761 peRed = static_cast<uint8>(static_cast<uint16>(r));
762 peGreen = static_cast<uint8>(static_cast<uint16>(g));
763 peBlue = static_cast<uint8>(static_cast<uint16>(b));
764 peFlags = static_cast<uint8>(static_cast<uint16>(f));
765}
766
767//
768/// Construct a palette entry from a TColor.
769//
770inline
772{
773 peRed = c.Red();
774 peGreen = c.Green();
775 peBlue = c.Blue();
776 peFlags = c.Flags();
777}
778
779//
780/// Returns true if the palette entries have the same color components.
781//
782inline bool
784{
785 return peRed == GetRValue(cr) &&
786 peGreen == GetGValue(cr) &&
787 peBlue == GetBValue(cr);
788}
789
790//
791/// Creates a TRgbQuad object with rgbRed, rgbGreen, and rgbBlue set to r, g, and b
792/// respectively. Sets rgbReserved to 0.
793//
794inline
795TRgbQuad::TRgbQuad(int r, int g, int b)
796{
797 rgbRed = static_cast<uint8>(static_cast<uint16>(r));
798 rgbGreen = static_cast<uint8>(static_cast<uint16>(g));
799 rgbBlue = static_cast<uint8>(static_cast<uint16>(b));
800 rgbReserved = 0;
801}
802
803//
804/// Creates a TRgbQuad object with rgbRed, rgbGreen, rgbBlue set to c.Red, c.Green,
805/// c.Blue respectively. Sets rgbReserved to 0.
806//
807inline
809{
810 rgbRed = c.Red();
811 rgbGreen = c.Green();
812 rgbBlue = c.Blue();
813 rgbReserved = 0;
814}
815
816//
817/// Creates a TRgbQuad object with the same values as the referenced RGBQUAD object.
818//
819inline
821{
822 *(RGBQUAD*)this = q;
823}
824
825//
826/// Return true if the RGBQUAD has the same color components.
827//
828inline bool
830{
831 return rgbRed == GetRValue(cr) &&
832 rgbGreen == GetGValue(cr) &&
833 rgbBlue == GetBValue(cr);
834}
835
836//
837/// Creates a TRgbTriple object with rgbRed, rgbGreen, and rgbBlue set to r, g, and
838/// b respectively.
839//
840inline
842{
843 rgbtRed = static_cast<uint8>(static_cast<uint16>(r));
844 rgbtGreen = static_cast<uint8>(static_cast<uint16>(g));
845 rgbtBlue = static_cast<uint8>(static_cast<uint16>(b));
846}
847
848//
849/// Creates a TRgbTriple object with rgbRed, rgbGreen, rgbBlue set to c.Red,
850/// c.Green, and c.Blue respectively.
851//
852inline
854{
855 rgbtRed = c.Red();
856 rgbtGreen = c.Green();
857 rgbtBlue = c.Blue();
858}
859
860//
861/// Creates a TRgbTriple object with the same values as the referenced RGBTRIPLE
862/// object.
863//
864inline
866{
867 *(RGBTRIPLE*)this = t;
868}
869
870//
871/// Return true if the triple match color components.
872//
873inline bool
875{
876 return rgbtRed == GetRValue(cr) &&
877 rgbtGreen == GetGValue(cr) &&
879}
880
881} // OWL namespace
882
883#endif // OWL_COLOR_H
Class wrapper for management of color values.
Definition color.h:245
static const TColor SysGrayText
The symbolic system color value for grayed (disabled) text.
Definition color.h:341
COLORREF GetValue() const
Get a 32bit COLORREF type from this color object.
Definition color.cpp:222
static const TColor LtBlue
Static TColor object with fixed Value set by RGB(0, 0, 255).
Definition color.h:311
static const TColor SysInfoBk
The symbolic system color value for the background of tooltip controls.
Definition color.h:348
TColor PalRelative() const
Return the palette relative entry.
Definition color.h:719
static const TColor SysMenuText
The symbolic system color value for the text shown on menus.
Definition color.h:331
static const TColor SysHighlightText
The symbolic system color value for text selected in a control.
Definition color.h:338
static const TColor LtMagenta
Static TColor object with fixed Value set by RGB(255, 0, 255).
Definition color.h:312
static const TColor SysBtnText
The symbolic system color value for the text on buttons.
Definition color.h:342
static const TColor Transparent
a non-painting color
Definition color.h:319
static const TColor SysHighlight
The symbolic system color value for items selected in a control.
Definition color.h:337
static const TColor SysActiveCaption
The symbolic system color value for the caption of the active window.
Definition color.h:326
static const TColor Sys3dHilight
The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the ...
Definition color.h:344
static const TColor SysCaptionText
The symbolic system color value for text in captions and size boxes, and for the arrow boxes on scrol...
Definition color.h:333
static const TColor None
not-a-color
Definition color.h:318
static const TColor SysActiveBorder
The symbolic system color value for the borders of the active window.
Definition color.h:334
static const TColor LtCyan
Static TColor object with fixed Value set by RGB(0, 255, 255).
Definition color.h:313
bool operator!=(const TColor &other) const
Return true if two colors are not equal.
Definition color.h:640
static const TColor SysDesktop
The symbolic system color value for the desktop.
Definition color.h:325
bool operator==(const TColor &other) const
Return true if two colors are equal.
Definition color.h:629
static const TColor Sys3dDkShadow
The symbolic system color value for dark shadow regions of 3-dimensional display elements.
Definition color.h:345
TColor & operator=(const TColor &src)
Set the value of color after it has been constructed.
Definition color.h:680
static const TColor SysInactiveCaption
The symbolic system color value for the caption background of every inactive window.
Definition color.h:327
static const TColor SysInactiveCaptionText
The symbolic system color value for the caption text of every inactive window.
Definition color.h:343
int Index() const
Return the index of the palette entry.
Definition color.h:690
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
Definition color.h:330
void SetValue(const COLORREF &value)
Change the color after it has been constructed.
Definition color.h:671
TColor Rgb() const
Return the RGB color value.
Definition color.h:699
static const TColor SysScrollbar
The symbolic system color value for what is usually the gray area of scrollbars.
Definition color.h:324
TColor()
Construct a null color.
Definition color.h:509
static const TColor LtYellow
Static TColor object with fixed Value set by RGB(255, 255, 0).
Definition color.h:310
TColor PalIndex() const
Return the palette index.
Definition color.h:709
static const TColor SysInfoText
The symbolic system color value for text shown on tooltip controls.
Definition color.h:347
bool IsSysColor() const
Return true if the color is a system color.
Definition color.h:738
static const TColor LtGray
Static TColor object with fixed Value set by RGB(192, 192, 192).
Definition color.h:306
static const TColor SysWindowText
The symbolic system color value for text in every window.
Definition color.h:332
static const TColor Sys3dShadow
The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges f...
Definition color.h:340
static const TColor SysAppWorkspace
The symbolic system color value for the background of multiple document interface (MDI) applications.
Definition color.h:336
uint8 Flags() const
Return the flags entry.
Definition color.h:729
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
Definition color.h:339
static const TColor LtGreen
Static TColor object with fixed Value set by RGB(0, 255, 0).
Definition color.h:309
static const TColor SysMenu
The symbolic system color value for the background of menus.
Definition color.h:328
static const TColor SysInactiveBorder
The symbolic system color value for the borders of every inactive window.
Definition color.h:335
static const TColor Gray
Static TColor object with fixed Value set by RGB(128, 128, 128).
Definition color.h:307
static const TColor Sys3dLight
The symbolic system color value for the light color for 3-dimensional display elements (for edges fac...
Definition color.h:346
static const TColor White
Static TColor object with fixed Value set by RGB(255, 255, 255).
Definition color.h:314
static TColor CreateFromPaletteIndex(int index)
Construct a color that is an index into a palette.
Definition color.h:561
static const TColor SysWindow
The symbolic system color value for the background of each window.
Definition color.h:329
static const TColor LtRed
Static TColor object with fixed Value set by RGB(255, 0, 0).
Definition color.h:308
bool IsSpecialColor() const
Return true if the color is a special color (currently None or Transparent)
Definition color.h:749
static const TColor Black
Static TColor object with fixed Value set by RGB(0, 0, 0).
Definition color.h:305
Wrapper for Windows' PALETTEENTRY type.
Definition color.h:398
TPaletteEntry(int r, int g, int b, int f=0)
Creates a palette entry object with peRed, peGreen, peBlue, and peFlags set to r, g,...
Definition color.h:759
bool operator==(COLORREF cr) const
Returns true if the palette entries have the same color components.
Definition color.h:783
Wrapper for Windows' RBGQUAD type.
Definition color.h:433
bool operator==(COLORREF cr) const
Return true if the RGBQUAD has the same color components.
Definition color.h:829
TRgbQuad(int r, int g, int b)
Creates a TRgbQuad object with rgbRed, rgbGreen, and rgbBlue set to r, g, and b respectively.
Definition color.h:795
Wrapper for Windows' RBGTRIPLE type.
Definition color.h:468
TRgbTriple(int r, int g, int b)
Creates a TRgbTriple object with rgbRed, rgbGreen, and rgbBlue set to r, g, and b respectively.
Definition color.h:841
bool operator==(COLORREF cr) const
Return true if the triple match color components.
Definition color.h:874
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
Base class for writing streamable objects.
Definition objstrm.h:480
DWORD HLSCOLOR
Definition color.h:22
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
COLORREF MkRGB(uint r, uint g, uint b)
Definition color.h:42
owl::opstream & operator<<(owl::opstream &os, const TColor &c)
Insert the color value into a persistent output stream.
Definition color.h:498
long NColors(uint16 bitCount)
Functions to convert number of bits to number of palette colors and back, and build an RGB COLORREF.
Definition color.cpp:188
unsigned char uint8
Definition number.h:32
unsigned long uint32
Definition number.h:34
uint16 NBits(long colors)
Return the number of bits required to represent a given number of colors.
Definition color.cpp:201
unsigned short uint16
Definition number.h:33
unsigned int uint
Definition number.h:25
owl::ipstream & operator>>(owl::ipstream &is, TColor &c)
Extract the color value from a persistent input stream.
Definition color.h:489
#define _OWLFUNC(p)
Definition defs.h:341
#define _OWLCLASS
Definition defs.h:338
Includes windowing system headers, with necessary macros defined.