TColor

Back Up Next

TColor

Header File
    <owl/color.h>

Description:
    TColor is a support class used in conjunction with the classes TPalette, TPaletteEntry, TRgbQuad, and TRgbTriple to simplify all color operations. 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.

Public Data Members

Black
    Syntax
        static const TColor Black;
    Description
        The static TColor object with fixed Value set by RGB(0, 0, 0).
Gray
    Syntax:
        static const TColor Gray;
    Description
        Contains the static TColor object with fixed Value set by RGB(128, 128, 128).
LtBlue
    Syntax
        static const TColor LtBlue;
    Description
        Contains the static TColor object with the fixed Value set by RGB(0, 0, 255).
LtCyan
    Syntax
        static const TColor LtCyan;
    Description
        Contains the static TColor object with the fixed Value set by RGB(0, 255, 255).
LtGray
    Syntax
        static const TColor LtGray;
    Description
        Contains the static TColor object with the fixed Value set by RGB(192, 192, 192).
LtGreen
    Syntax
        static const TColor LtGreen;
    Description
        Contains the static TColor object with the fixed Value set by RGB(0, 255, 0).
LtMagenta
    Syntax
        static const TColor LtMagenta;
    Description
        Contains the static TColor object with the fixed Value set by RGB(255, 0, 255).
LtRed
    Syntax
        static const TColor LtRed;
    Description
        Contains the static TColor object with the fixed Value set by RGB(255, 0, 0).
LtYellow
    Syntax
        static const TColor LtYellow;
    Description
        Contains the static TColor object with the fixed Value set by RGB(255, 255, 0).
None
    Syntax
        static const TColor None;
    Description
        These are special marker colors, using flag bit pattern. Value is never really used. Value must not change for streaming compatibility with OWL's TWindow.
Sys3dDkShadow
    Syntax
        static const TColor Sys3dDkShadow;
    Description
        For Windows 95 only. The symbolic system color value for dark shadow regions of 3-dimensional display elements. Performs GetSysColor() on conversion to COLORREF.
Sys3dFace
    Syntax
        static const TColor Sys3dFace;
    Description
        For Windows 95 only. The symbolic system color value for the face color of 3-dimensional display elements. Performs GetSysColor() on conversion to COLORREF.
Sys3dHilight
    Syntax
        static const TColor Sys3dHilight;
    Description
        For Windows 95 only. The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the light source). Performs GetSysColor() on conversion to COLORREF.
Sys3dLight
    Syntax
        static const TColor Sys3dLight;
    Description
        For Windows 95 only. The symbolic system color value for the light color for 3-dimensional display elements (for edges facing the light source). Performs GetSysColor() on conversion to COLORREF.
Sys3dShadow
    Syntax
        static const TColor Sys3dShadow;
    Description
        For Windows 95 only. 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.
SysActiveBorder
    Syntax
        static const TColor SysActiveBorder;
    Description
        The symbolic system color value for the borders of the active window. Performs GetSysColor() on conversion to COLORREF.
SysActiveCaption
    Syntax
        static const TColor SysActiveCaption;
    Description
        The symbolic system color value for the caption of the active window. Performs GetSysColor() on conversion to COLORREF.
SysAppWorkspace
    Syntax
        static const TColor SysAppWorkspace;
    Description
        The symbolic system color value for the background of multiple document interface (MDI) applications. Performs GetSysColor() on conversion to COLORREF.
SysBtnText
    Syntax
        static const TColor SysBtnText;
    Description
        The symbolic system color value for the text on buttons. Performs GetSysColor() on conversion to COLORREF.
SysCaptionText
    Syntax
        static const TColor SysCaptionText;
    Description
        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.
SysDesktop
    Syntax
        static const TColor SysDesktop;
    Description
        The symbolic system color value for the desktop. Performs GetSysColor() on conversion to COLORREF.
SysGrayText
    Syntax
        static const TColor SysGrayText;
    Description
        The symbolic system color value for grayed (disabled) text. Performs GetSysColor() on conversion to COLORREF.
        This color is set to 0 if the current display driver does not support a solid gray color.
SysHighlight
    Syntax
        static const TColor SysHighlight;
    Description
        The symbolic system color value for items selected in a control. Performs GetSysColor() on conversion to COLORREF.
SysHighlightText
    Syntax
        static const TColor SysHighlightText;
    Description
        The symbolic system color value for text selected in a control. Performs GetSysColor() on conversion to COLORREF.
SysInactiveBorder
    Syntax
        static const TColor SysInactiveBorder;
    Description
        The symbolic system color value for the borders of every inactive window. Performs GetSysColor() on conversion to COLORREF.
SysInactiveCaption
    Syntax
        static const TColor SysInactiveCaption;
    Description
        The symbolic system color value for the caption background of every inactive window. Performs GetSysColor() on conversion to COLORREF.
SysInactiveCaptionText
    Syntax
        static const TColor SysInactiveCaptionText;
    Description
        The symbolic system color value for the caption text of every inactive window. Performs GetSysColor() on conversion to COLORREF.
SysInfoBk
    Syntax
        static const TColor SysInfoBk;
    Description
        For Windows 95 only. The symbolic system color value for the background of tooltip controls. Performs GetSysColor() on conversion to COLORREF.
SysInfoText
    Syntax
        static const TColor SysInfoText;
    Description
        For Windows 95 only. The symbolic system color value for text shown on tooltip controls. Performs GetSysColor() on conversion to COLORREF.
SysMenu
    Syntax
        static const TColor SysMenu;
    Description
        The symbolic system color value for the background of menus. Performs GetSysColor() on conversion to COLORREF.
SysMenuText
    Syntax
        static const TColor SysMenuText;
    Description
        The symbolic system color value for the text shown on menus. Performs GetSysColor() on conversion to COLORREF.
SysScrollbar
    Syntax
        static const TColor SysScrollbar;
    Description
        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.
SysWindow
    Syntax
        static const TColor SysWindow;
    Description
        The symbolic system color value for the background of each window. Performs GetSysColor() on conversion to COLORREF.
SysWindowFrame
    Syntax
        static const TColor SysWindowFrame;
    Description
        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.
SysWindowText
    Syntax
        static const TColor SysWindowText;
    Description
        The symbolic system color value for text in every window. Performs GetSysColor() on conversion to COLORREF.
Transparent
    Syntax
        static const TColor Transparent;
    Description
        Non-painting marker color using the flag bit pattern. This value is never really used. This value must not change, for streaming compatibility with OWL's TWindow.
White
    Syntax
        static const TColor White;
    Description
        Contains the static TColor object with the fixed Value set by RGB(255, 255, 255).

Public Constructors

TColor::TColor
    Syntax 1
        TColor();
    Description
        The default constructor sets Value to 0.

    Syntax 2
        TColor(COLORREF value);
    Description
        Creates a TColor object with Value set to the given value.

    Syntax 3
        TColor(long value);
        TColor(long value) : Value((COLORREF)value) {}
    Description
        Creates a TColor object with Value set to (COLORREF)value.

    Syntax 4
        TColor(int r, int g, int b);
    Description
        Creates a TColor object with Value set to RGB(r,g,b).
   
    Syntax 5
        TColor(int r, int g, int b, int f);
    Description
        Creates a TColor object with Value set to RGB(r,g,b) with the flag byte formed from f.

    Syntax 6
        TColor(int index);
    Description
        Creates a TColor object with Value set to PALETTEINDEX(index).

    Syntax 7
        TColor(const PALETTEENTRY far& pe);
    Description
        Creates a TColor object with Value set to: RGB(pe.peRed, pe.peGreen, pe.peBlue)

    Syntax 8
        TColor(const RGBQUAD far& q);
    Description
        Creates a TColor object with Value set to: RGB(q.rgbRed, q.rgbGreen, q.rgbBlue)

    Syntax 9
        TColor(const RGBTRIPLE far& t);
    Description
        Creates a TColor object with Value set to: RGB(t.rgbtRed, t.rgbtGreen, t.rgbtBlue)

Public Member Functions


Blue
    Syntax
        uint8 Blue() const;
    Description
        Returns the blue component of this color's Value.
Flags
    Syntax
        uint8 Flags() const;
    Description
        Returns the peFlags value of this object's Value.
GetValue
    Syntax
        COLORREF GetValue() const;
    Description
        Gets a 32bit COLORREF type from this color object. Performs a GetSysColor() lookup if the object represents a symbolic sys-color index.
GetSysColor
    Syntax
        static TColor GetSysColor(int uiElement);
    Description
        (Presentation Manager only) Returns the color of the given uiElement.
Green
    Syntax
        uint8 Green() const;
    Description
        Returns the green component of this color's Value.
Index
    Syntax
        int Index() const;
    Description
        Returns the index value corresponding to this color's Value by masking out the two upper bytes. Used when color is a palette index value.
IsSysColor
    Syntax
        bool IsSysColor() const;
    Description
        Returns true if the color is a system color, false otherwise.
operator ==
    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))

    Syntax 1
        bool operator ==(const TColor& other) const;
    Description
        Returns true if two colors are equal.
    Syntax 2
        bool operator ==(COLORREF cr) const;
    Description
        Returns true if this color matches a COLORREF.
operator COLORREF
    Syntax
        operator COLORREF() const;
    Description
        Type-conversion operator that returns Value.
operator =
    Syntax
        TColor& operator =(const TColor& src);
    Description
        Sets the value of color after it has been initialized.
operator !=
    This function compares between two binary representation of colors; it does not compare colors logically.
    Syntax 1
        bool operator !=(const TColor& other) const;
    Description
        Returns true if two colors are not equal.
    Syntax 2
        bool operator !=(COLORREF cr) const;
    Description
        Returns true if this color does not match a COLORREF.
PalIndex
    Syntax
        TColor PalIndex() const;
    Description
        Returns the palette index corresponding to this color's Value. The returned color has the high-order byte set to 1.
PalRelative
    Syntax
        TColor PalRelative() const;
    Description
        Returns the palette-relative RGB corresponding to this color's Value. The returned color has the high-order byte set to 2.
Red
    Syntax
        uint8 Red() const;
    Description
        Returns the red component of this color's Value.
Rgb
    Syntax
        TColor Rgb() const;
    Description
        Returns the explicit RGB color corresponding to this color's Value by masking out the high-order byte.
SetSysColors
    Syntax
        static bool SetSysColors(unsigned nelems, const int uiElementIndices[], const TColor colors[]);
    Description
        (Presentation Manager only) Sets groups of UI element colors. nelems indicates the number of element colors to change and the size of the array parameters, uiElementIndices indicates which elements to change, and colors indicates what color to change the corresponding element to. Returns true if successful.
SetValue
    Syntax
        void SetValue(const COLORREF& value);
    Description
        Changes the color after it has been initialized.

Private Data Members
   Value
    Syntax
        COLORREF Value;
    Description
        The color value of this TColor object. Value can have three different forms, depending on the application:
            Explicit values for RGB (red, green, blue)
            An index into a logical color palette
           A palette-relative RGB value.

 

Revised: February 08, 2000.


Copyright © 1998-2001 Yura Bidus. All rights reserved.