OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TColor Class Reference

Class wrapper for management of color values. More...

#include <owl/color.h>

Public Member Functions

 TColor ()
 Construct a null color.
 
 TColor (const TColor &src)
 Construct a color as a copy of another color.
 
 TColor (COLORREF value)
 Construct a color with an existing COLORREF value.
 
 TColor (int r, int g, int b)
 Construct a color given the red, green, and blue components of color.
 
 TColor (int r, int g, int b, int f)
 Construct a color given red, green, blue, and flag components of color.
 
 TColor (const PALETTEENTRY &pe)
 Construct a color based on an existing PALETTEENTRY.
 
 TColor (const RGBQUAD &q)
 Construct a color based on an existing RGBQUAD.
 
 TColor (const RGBTRIPLE &t)
 Construct a color based on an existing RGBTRIPLE.
 
 operator COLORREF () const
 Convert the stored color into a COLORREF.
 
COLORREF GetValue () const
 Get a 32bit COLORREF type from this color object.
 
void SetValue (const COLORREF &value)
 Change the color after it has been constructed.
 
bool operator== (const TColor &other) const
 Return true if two colors are equal.
 
bool operator!= (const TColor &other) const
 Return true if two colors are not equal.
 
bool operator== (COLORREF cr) const
 Return true if this color matches a COLORREF.
 
bool operator!= (COLORREF cr) const
 Return true if this color does not match a COLORREF.
 
TColoroperator= (const TColor &src)
 Set the value of color after it has been constructed.
 
int Index () const
 Return the index of the palette entry.
 
TColor Rgb () const
 Return the RGB color value.
 
TColor PalIndex () const
 Return the palette index.
 
TColor PalRelative () const
 Return the palette relative entry.
 
uint8 Red () const
 Return the color's red component.
 
uint8 Green () const
 Return the color's green component.
 
uint8 Blue () const
 Return the color's blue component.
 
uint8 Flags () const
 Return the flags entry.
 
bool IsSysColor () const
 Return true if the color is a system color.
 
bool IsSpecialColor () const
 Return true if the color is a special color (currently None or Transparent)
 
void Lighten (uint8 val)
 
void Darken (uint8 val)
 
void Merge (const TColor &other)
 
HLSCOLOR Rgb2Hls () const
 
void Hls2Rgb (HLSCOLOR hls)
 
void HlsTransform (int percent_L, int percent_S)
 

Static Public Member Functions

static TColor CreateFromPaletteIndex (int index)
 Construct a color that is an index into a palette.
 

Static Public Attributes

static const TColor Black
 Static TColor object with fixed Value set by RGB(0, 0, 0).
 
static const TColor LtGray
 Static TColor object with fixed Value set by RGB(192, 192, 192).
 
static const TColor Gray
 Static TColor object with fixed Value set by RGB(128, 128, 128).
 
static const TColor LtRed
 Static TColor object with fixed Value set by RGB(255, 0, 0).
 
static const TColor LtGreen
 Static TColor object with fixed Value set by RGB(0, 255, 0).
 
static const TColor LtYellow
 Static TColor object with fixed Value set by RGB(255, 255, 0).
 
static const TColor LtBlue
 Static TColor object with fixed Value set by RGB(0, 0, 255).
 
static const TColor LtMagenta
 Static TColor object with fixed Value set by RGB(255, 0, 255).
 
static const TColor LtCyan
 Static TColor object with fixed Value set by RGB(0, 255, 255).
 
static const TColor White
 Static TColor object with fixed Value set by RGB(255, 255, 255).
 
static const TColor None
 not-a-color
 
static const TColor Transparent
 a non-painting color
 
static const TColor SysScrollbar
 The symbolic system color value for what is usually the gray area of scrollbars.
 
static const TColor SysDesktop
 The symbolic system color value for the desktop.
 
static const TColor SysActiveCaption
 The symbolic system color value for the caption of the active window.
 
static const TColor SysInactiveCaption
 The symbolic system color value for the caption background of every inactive window.
 
static const TColor SysMenu
 The symbolic system color value for the background of menus.
 
static const TColor SysWindow
 The symbolic system color value for the background of each window.
 
static const TColor SysWindowFrame
 The symbolic system color value for the frame around each window.
 
static const TColor SysMenuText
 The symbolic system color value for the text shown on menus.
 
static const TColor SysWindowText
 The symbolic system color value for text in every window.
 
static const TColor SysCaptionText
 The symbolic system color value for text in captions and size boxes, and for the arrow boxes on scroll bars.
 
static const TColor SysActiveBorder
 The symbolic system color value for the borders of the active window.
 
static const TColor SysInactiveBorder
 The symbolic system color value for the borders of every inactive window.
 
static const TColor SysAppWorkspace
 The symbolic system color value for the background of multiple document interface (MDI) applications.
 
static const TColor SysHighlight
 The symbolic system color value for items selected in a control.
 
static const TColor SysHighlightText
 The symbolic system color value for text selected in a control.
 
static const TColor Sys3dFace
 The symbolic system color value for the face color of 3-dimensional display elements.
 
static const TColor Sys3dShadow
 The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges facing away from the light source).
 
static const TColor SysGrayText
 The symbolic system color value for grayed (disabled) text.
 
static const TColor SysBtnText
 The symbolic system color value for the text on buttons.
 
static const TColor SysInactiveCaptionText
 The symbolic system color value for the caption text of every inactive window.
 
static const TColor Sys3dHilight
 The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the light source).
 
static const TColor Sys3dDkShadow
 The symbolic system color value for dark shadow regions of 3-dimensional display elements.
 
static const TColor Sys3dLight
 The symbolic system color value for the light color for 3-dimensional display elements (for edges facing the light source).
 
static const TColor SysInfoText
 The symbolic system color value for text shown on tooltip controls.
 
static const TColor SysInfoBk
 The symbolic system color value for the background of tooltip controls.
 

Friends

owl::ipstreamoperator>> (owl::ipstream &is, TColor &c)
 Extract the color value from a persistent input stream.
 
owl::opstreamoperator<< (owl::opstream &os, const TColor &c)
 Insert the color value into a persistent output stream.
 

Detailed Description

Class wrapper for management of color values.

TColor is a support class used in conjunction with the classes TPalette, TPaletteEntry, TRgbQuad, and TRgbTriple to simplify all color operations.

Internally, all colors are stored as a COLORREF.

TColor has ten static data members representing the standard RGB COLORREF values, from Black to White. Constructors are provided to create TColor objects from COLORREF and RGB values, palette indexes, palette entries, and RGBQUAD and RGBTRIPLE values.

See the entries for NBits and NColors for a description of TColor-related functions.

Definition at line 244 of file color.h.

Constructor & Destructor Documentation

◆ TColor() [1/8]

owl::TColor::TColor ( )
inline

Construct a null color.

The default constructor sets Value to 0.

Definition at line 509 of file color.h.

◆ TColor() [2/8]

owl::TColor::TColor ( const TColor & src)
inline

Construct a color as a copy of another color.

Definition at line 519 of file color.h.

◆ TColor() [3/8]

owl::TColor::TColor ( COLORREF value)
inline

Construct a color with an existing COLORREF value.

Definition at line 529 of file color.h.

◆ TColor() [4/8]

owl::TColor::TColor ( int r,
int g,
int b )
inline

Construct a color given the red, green, and blue components of color.

Definition at line 539 of file color.h.

◆ TColor() [5/8]

owl::TColor::TColor ( int r,
int g,
int b,
int f )
inline

Construct a color given red, green, blue, and flag components of color.

The flag component is defined in the Windows SDK reference.

Definition at line 551 of file color.h.

◆ TColor() [6/8]

owl::TColor::TColor ( const PALETTEENTRY & pe)
inline

Construct a color based on an existing PALETTEENTRY.

Definition at line 570 of file color.h.

◆ TColor() [7/8]

owl::TColor::TColor ( const RGBQUAD & q)
inline

Construct a color based on an existing RGBQUAD.

Definition at line 580 of file color.h.

◆ TColor() [8/8]

owl::TColor::TColor ( const RGBTRIPLE & t)
inline

Construct a color based on an existing RGBTRIPLE.

Definition at line 590 of file color.h.

Member Function Documentation

◆ Blue()

uint8 owl::TColor::Blue ( ) const

Return the color's blue component.

Definition at line 256 of file color.cpp.

References GetValue().

◆ CreateFromPaletteIndex()

TColor owl::TColor::CreateFromPaletteIndex ( int index)
inlinestatic

Construct a color that is an index into a palette.

Definition at line 561 of file color.h.

References TColor().

◆ Darken()

void owl::TColor::Darken ( uint8 val)

Definition at line 278 of file color.cpp.

References Blue(), Green(), and Red().

◆ Flags()

uint8 owl::TColor::Flags ( ) const
inline

Return the flags entry.

Definition at line 729 of file color.h.

◆ GetValue()

COLORREF owl::TColor::GetValue ( ) const

Get a 32bit COLORREF type from this color object.

Performs a GetSysColor() lookup if the object represents a symbolic sys-color index.

Definition at line 222 of file color.cpp.

References Index(), and IsSysColor().

◆ Green()

uint8 owl::TColor::Green ( ) const

Return the color's green component.

Definition at line 247 of file color.cpp.

References GetValue().

◆ Hls2Rgb()

void owl::TColor::Hls2Rgb ( HLSCOLOR hls)

Definition at line 368 of file color.cpp.

References HLS_H, HLS_L, HLS_S, and SetValue().

◆ HlsTransform()

void owl::TColor::HlsTransform ( int percent_L,
int percent_S )

Definition at line 396 of file color.cpp.

References HLS, Hls2Rgb(), HLS_H, HLS_L, HLS_S, and Rgb2Hls().

◆ Index()

int owl::TColor::Index ( ) const
inline

Return the index of the palette entry.

Definition at line 690 of file color.h.

◆ IsSpecialColor()

bool owl::TColor::IsSpecialColor ( ) const
inline

Return true if the color is a special color (currently None or Transparent)

Definition at line 749 of file color.h.

◆ IsSysColor()

bool owl::TColor::IsSysColor ( ) const
inline

Return true if the color is a system color.

Definition at line 738 of file color.h.

◆ Lighten()

void owl::TColor::Lighten ( uint8 val)

Definition at line 264 of file color.cpp.

References Blue(), Green(), and Red().

◆ Merge()

void owl::TColor::Merge ( const TColor & other)

Definition at line 292 of file color.cpp.

References Blue(), Green(), owl::MkRGB(), and Red().

◆ operator COLORREF()

owl::TColor::operator COLORREF ( ) const
inline

Convert the stored color into a COLORREF.

Definition at line 600 of file color.h.

◆ operator!=() [1/2]

bool owl::TColor::operator!= ( COLORREF cr) const
inline

Return true if this color does not match a COLORREF.

See additional comments in TColor::operator ==.

Definition at line 662 of file color.h.

References GetValue().

◆ operator!=() [2/2]

bool owl::TColor::operator!= ( const TColor & other) const
inline

Return true if two colors are not equal.

See additional comments in TColor::operator ==.

Definition at line 640 of file color.h.

◆ operator=()

TColor & owl::TColor::operator= ( const TColor & src)
inline

Set the value of color after it has been constructed.

Definition at line 680 of file color.h.

◆ operator==() [1/2]

bool owl::TColor::operator== ( COLORREF cr) const
inline

Return true if this color matches a COLORREF.

See additional comments in TColor::operator ==.

Definition at line 651 of file color.h.

References GetValue().

◆ operator==() [2/2]

bool owl::TColor::operator== ( const TColor & other) const
inline

Return true if two colors are equal.

This function compares between two binary representation of colors, it does not compare colors logically.

For example, if palette entry 4 is solid red (rgb components (255, 0, 0)), the following will return false:

if (TColor(4) == TColor(255, 0, 0))
/* colors match */
else
/* colors do not match */
TColor()
Construct a null color.
Definition color.h:509

To actually compare the RGB values of two TColor objects, use the operator == (COLORREF). For example,

if (colorA == colorB.GetValue()) {
// ColorA & ColorB
}
Class wrapper for management of color values.
Definition color.h:245

Definition at line 629 of file color.h.

◆ PalIndex()

TColor owl::TColor::PalIndex ( ) const
inline

Return the palette index.

Definition at line 709 of file color.h.

References Index().

◆ PalRelative()

TColor owl::TColor::PalRelative ( ) const
inline

Return the palette relative entry.

Definition at line 719 of file color.h.

References Rgb().

◆ Red()

uint8 owl::TColor::Red ( ) const

Return the color's red component.

Definition at line 238 of file color.cpp.

References GetValue().

◆ Rgb()

TColor owl::TColor::Rgb ( ) const
inline

Return the RGB color value.

Definition at line 699 of file color.h.

References GetValue().

◆ Rgb2Hls()

HLSCOLOR owl::TColor::Rgb2Hls ( ) const

Definition at line 303 of file color.cpp.

References Blue(), Green(), HLS, and Red().

◆ SetValue()

void owl::TColor::SetValue ( const COLORREF & value)
inline

Change the color after it has been constructed.

Definition at line 671 of file color.h.

Friends And Related Symbol Documentation

◆ operator<<

owl::opstream & operator<< ( owl::opstream & os,
const TColor & c )
friend

Insert the color value into a persistent output stream.

Definition at line 498 of file color.h.

◆ operator>>

owl::ipstream & operator>> ( owl::ipstream & is,
TColor & c )
friend

Extract the color value from a persistent input stream.

Definition at line 489 of file color.h.

Member Data Documentation

◆ Black

const TColor owl::TColor::Black
static

Static TColor object with fixed Value set by RGB(0, 0, 0).

Definition at line 305 of file color.h.

◆ Gray

const TColor owl::TColor::Gray
static

Static TColor object with fixed Value set by RGB(128, 128, 128).

Definition at line 307 of file color.h.

◆ LtBlue

const TColor owl::TColor::LtBlue
static

Static TColor object with fixed Value set by RGB(0, 0, 255).

Definition at line 311 of file color.h.

◆ LtCyan

const TColor owl::TColor::LtCyan
static

Static TColor object with fixed Value set by RGB(0, 255, 255).

Definition at line 313 of file color.h.

◆ LtGray

const TColor owl::TColor::LtGray
static

Static TColor object with fixed Value set by RGB(192, 192, 192).

Definition at line 306 of file color.h.

◆ LtGreen

const TColor owl::TColor::LtGreen
static

Static TColor object with fixed Value set by RGB(0, 255, 0).

Definition at line 309 of file color.h.

◆ LtMagenta

const TColor owl::TColor::LtMagenta
static

Static TColor object with fixed Value set by RGB(255, 0, 255).

Definition at line 312 of file color.h.

◆ LtRed

const TColor owl::TColor::LtRed
static

Static TColor object with fixed Value set by RGB(255, 0, 0).

Definition at line 308 of file color.h.

◆ LtYellow

const TColor owl::TColor::LtYellow
static

Static TColor object with fixed Value set by RGB(255, 255, 0).

Definition at line 310 of file color.h.

◆ None

const TColor owl::TColor::None
static

not-a-color

Definition at line 318 of file color.h.

◆ Sys3dDkShadow

const TColor owl::TColor::Sys3dDkShadow
static

The symbolic system color value for dark shadow regions of 3-dimensional display elements.

Definition at line 345 of file color.h.

◆ Sys3dFace

const TColor owl::TColor::Sys3dFace
static

The symbolic system color value for the face color of 3-dimensional display elements.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 339 of file color.h.

◆ Sys3dHilight

const TColor owl::TColor::Sys3dHilight
static

The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the light source).

Definition at line 344 of file color.h.

◆ Sys3dLight

const TColor owl::TColor::Sys3dLight
static

The symbolic system color value for the light color for 3-dimensional display elements (for edges facing the light source).

Definition at line 346 of file color.h.

◆ Sys3dShadow

const TColor owl::TColor::Sys3dShadow
static

The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges facing away from the light source).

Performs GetSysColor() on conversion to COLORREF.

Definition at line 340 of file color.h.

◆ SysActiveBorder

const TColor owl::TColor::SysActiveBorder
static

The symbolic system color value for the borders of the active window.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 334 of file color.h.

◆ SysActiveCaption

const TColor owl::TColor::SysActiveCaption
static

The symbolic system color value for the caption of the active window.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 326 of file color.h.

◆ SysAppWorkspace

const TColor owl::TColor::SysAppWorkspace
static

The symbolic system color value for the background of multiple document interface (MDI) applications.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 336 of file color.h.

◆ SysBtnText

const TColor owl::TColor::SysBtnText
static

The symbolic system color value for the text on buttons.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 342 of file color.h.

◆ SysCaptionText

const TColor owl::TColor::SysCaptionText
static

The symbolic system color value for text in captions and size boxes, and for the arrow boxes on scroll bars.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 333 of file color.h.

◆ SysDesktop

const TColor owl::TColor::SysDesktop
static

The symbolic system color value for the desktop.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 325 of file color.h.

◆ SysGrayText

const TColor owl::TColor::SysGrayText
static

The symbolic system color value for grayed (disabled) text.

This color is set to 0 if the current display driver does not support a solid gray color. Performs GetSysColor() on conversion to COLORREF.

Definition at line 341 of file color.h.

◆ SysHighlight

const TColor owl::TColor::SysHighlight
static

The symbolic system color value for items selected in a control.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 337 of file color.h.

◆ SysHighlightText

const TColor owl::TColor::SysHighlightText
static

The symbolic system color value for text selected in a control.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 338 of file color.h.

◆ SysInactiveBorder

const TColor owl::TColor::SysInactiveBorder
static

The symbolic system color value for the borders of every inactive window.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 335 of file color.h.

◆ SysInactiveCaption

const TColor owl::TColor::SysInactiveCaption
static

The symbolic system color value for the caption background of every inactive window.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 327 of file color.h.

◆ SysInactiveCaptionText

const TColor owl::TColor::SysInactiveCaptionText
static

The symbolic system color value for the caption text of every inactive window.

Definition at line 343 of file color.h.

◆ SysInfoBk

const TColor owl::TColor::SysInfoBk
static

The symbolic system color value for the background of tooltip controls.

Definition at line 348 of file color.h.

◆ SysInfoText

const TColor owl::TColor::SysInfoText
static

The symbolic system color value for text shown on tooltip controls.

Definition at line 347 of file color.h.

◆ SysMenu

const TColor owl::TColor::SysMenu
static

The symbolic system color value for the background of menus.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 328 of file color.h.

◆ SysMenuText

const TColor owl::TColor::SysMenuText
static

The symbolic system color value for the text shown on menus.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 331 of file color.h.

◆ SysScrollbar

const TColor owl::TColor::SysScrollbar
static

The symbolic system color value for what is usually the gray area of scrollbars.

This is the region that the scrollbar slider slides upon.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 324 of file color.h.

◆ SysWindow

const TColor owl::TColor::SysWindow
static

The symbolic system color value for the background of each window.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 329 of file color.h.

◆ SysWindowFrame

const TColor owl::TColor::SysWindowFrame
static

The symbolic system color value for the frame around each window.

The frame is not the same as the border.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 330 of file color.h.

◆ SysWindowText

const TColor owl::TColor::SysWindowText
static

The symbolic system color value for text in every window.

Performs GetSysColor() on conversion to COLORREF.

Definition at line 332 of file color.h.

◆ Transparent

const TColor owl::TColor::Transparent
static

a non-painting color

Definition at line 319 of file color.h.

◆ White

const TColor owl::TColor::White
static

Static TColor object with fixed Value set by RGB(255, 255, 255).

Definition at line 314 of file color.h.


The documentation for this class was generated from the following files: