### IColor

  The IColor class allows you to query and set the color of various areas of windows represented by Open Class Library window objects. IColor is also a base class for other color classes.

#### AIX Considerations

  The color intensities of this class are 8-bit quantities and are represented as an unsigned char, resulting in intensity values from 0 to 255, with 255 the maximum intensity. X supports color intensities that are an unsigned short or 16 bits, and recognizes values from 0 to 65535.

  Use the asPixel and the constructor that takes a pixel.

### IColor - Member Functions and Data by Group

### Constructors & Destructor

Use the constructors and destructor in this group to create and destroy objects of class IColor.

~IColor

      public:
      virtual ~IColor()

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

IColor
  This constructor creates an IColor object.

  Overload 1
  Constructor for a system preset GUI color, lazy evaluated RGBA values

      public:
      IColor(ESystemColor value)

  Use this constructor to create an IColor object using the given value.

  value
    A system preset GUI color enum value.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

AIX Considerations
  ESystemColor only returns the color values of the default system color scheme.

  Overload 2
  Copy constructor.

      public:
      IColor(const IColor& color)

  Use this constructor to create an IColor object that is copied from the given one.

  IColor
    A constant reference to the color object to copy from.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 3

      public:
      IColor( unsigned long index,
              const IColorMap* referencedColorMap = NULL )

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 4
  Constructor for a predefined RGBA color

      public:
      IColor(EPredefinedColor color)

  Use this constructor to create an IColor object using the given color.

  color
    A predefined color enum value.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 5

      public:
      IColor( CharIntensity red,
              CharIntensity green,
              CharIntensity blue,
              CharIntensity opacity = 255 )

  Use this constructor to create a color from the given component values.

  red
    The red component of the color.
  green
    The green component of the color.
  blue
    The blue component of the color.
  opacity
    The opacity. The default value is 255.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Assignment Operator

Use the operator in this group to assign the given IColor object to the target one.

operator =

      public:
      IColor& operator =(const IColor& color)

  This assignment operator replaces the color. If the IColor object on the right hand side of the = was created using the constructor that accepts a ESystemColor value and still is linked to the system color area, the link is copied also.

  source
    The source color to be copied.

Return
  A reference to the color object.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Comparing Two IColor Objects for Equality

Use the function in this group to compare two IColor objects for equality.

operator ==
  Tests two IBaseColor objects for equality.

      public:
      virtual bool operator ==(const IBaseColor& color) const

  Returns true if the colors are identical. The current red, green, and blue values are compared to determine identity.

  color
    The IBaseColor to be compared with this one.

Return
  True if the two colors have the same RGB values and opacity.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Converting Across Color Spaces

Use the function in this group to convert an RGB color to XYZ.

elementsInXYZColorSpace

      public:
      virtual void
        elementsInXYZColorSpace( GIntensity& x,
                                 GIntensity& y,
                                 GIntensity& z ) const

  Converts a RGB color to XYZ color space.

  x
    The returned x-component of the XYZ color.
  y
    The returned y-component of the XYZ color.
  z
    The returned z-component of the XYZ color.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Getting Color Values

Use the functions in this group to obtain a color component value or intensity value.

asRGBLong
  Getter for the native color representation in a long.

      public:
      long asRGBLong() const

  Returns the red, green, and blue color values combined into a long integer.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

AIX Considerations

  You can use this function to obtain the color as a long value and; then convert it to the hexadecimal format #RRGGBB. X11 recognizes this format; however, this format has been discouraged as of Release 5 of XLib (X11R5).

blueMix

  Overload 1
  Gets the blue component of a floating-point RGB color by scaling into range of 0-1.

      public:
      virtual void blueMix(GIntensity& blue) const

  blue
    The returned blue component.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2
  Returns the blue component of the compact RGB color.

      public:
      virtual CharIntensity blueMix() const

Return
  The value of the blue component.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

gray

      public:
      virtual CharIntensity gray() const

  Returns the intensity of a gray color.

Return
  The intensity.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

greenMix

  Overload 1
  Returns the green component of the compact RGB color.

      public:
      virtual CharIntensity greenMix() const

Return
  The value of the green component.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2
  Gets the green component of a floating-point RGB color by scaling into range of 0-1.

      public:
      virtual void greenMix(GIntensity& green) const

  green
    The returned green component.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

opacity

  Overload 1
  Gets the opacity value of a floating-point RGB color by scaling into range of 0-1.

      public:
      virtual void opacity(GIntensity& opacity) const

  opacity
    The returned opacity value.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2
  Returns the opacity of the compact RGB color.

      public:
      virtual CharIntensity opacity() const

Return
  The value of the opacity.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

predefinedColor

      public:
      IBaseColor::EPredefinedColor predefinedColor() const

  Getter for the predefined color enum.

  None

Return
  IBaseColor::EPredefinedColor enum

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

redMix

  Returns the value of the red component.

  Overload 1

      public:
      virtual void redMix(GIntensity& red) const

  Gets the red component of a floating-point RGB color by scaling into range of 0-1.

  red
    The returned red component.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2

      public:
      virtual CharIntensity redMix() const

  Returns the red component of the compact RGB color.

Return
  The value of the red component.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

runtimeGuiColor

      public:
      ESystemColor runtimeGuiColor() const

  Getter for the system preset gui color enum

  None

Return
  ESystemColor enum

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Setting Color Values

Use the functions in this group to set color component values or intensity values.

setBlue

      public:
      virtual IBaseColor& setBlue(CharIntensity blue)

  Sets the blue component of the compact RGB color.

  blue
    The new blue.

Return
  reference of self

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setElementsInXYZColorSpace

      public:
      virtual void
        setElementsInXYZColorSpace( GIntensity x,
                                    GIntensity y,
                                    GIntensity z )

  Sets the color by converting an XYZ color to a index color. If the value of the color does not match any color in the color map, the closist color index will be used.

  x
    The new x-component of the XYZ color.
  y
    The new y-component of the XYZ color.
  z
    The new z-component of the XYZ color.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setGreen

      public:
      virtual IBaseColor& setGreen(CharIntensity green)

  Sets the green component of the compact RGB color.

  green
    The new green.

Return
  reference of self

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setOpacity

      public:
      virtual IBaseColor& setOpacity(CharIntensity opacity)

  Sets the opacity of the compact RGB color.

  opacity
    The new opacity.

Return
  reference of self

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setRed

      public:
      virtual IBaseColor& setRed(CharIntensity red)

  Sets the red component of the compact RGB color.

  red
    The new red.

Return
  reference of self

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Streaming an Object In and Out

Use the functions in this group to read an IColor object in from the specified stream or write it out to it.

readFromStream

      protected:
      virtual void readFromStream(IDataStream& fromWhere)

  Stream in this object from the stream for polymorphic streaming

  fromWhere
    The steam for streaming in this object

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

writeToStream

      protected:
      virtual void writeToStream(IDataStream& toWhere) const

  Stream out this object to the stream for polymorphic streaming

  toWhere
    The steam for streaming out this object

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Miscellaneous Members

#### AIX Considerations

  The color intensities of this class are 8-bit quantities and are represented as an unsigned char, resulting in intensity values from 0 to 255, with 255 the maximum intensity. X supports color intensities that are an unsigned short or 16 bits, and recognizes values from 0 to 65535.

  Use the asPixel and the constructor that takes a pixel.

index
  Returns the logical color table index closest to the red, green, and blue values.

      public:
      virtual long index() const

  This function returns the logical color table index closest to the red, green, and blue values.

Exception

  IInvalidRequest | The object cannot be represented by a color table index.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

AIX Considerations

  The following list contains the index values and colors found in a logical color table. The values in parentheses show the corresponding color from the file rgb.txt.

  Index :ddhd.Color
  0
    White (white)
  1
    Blue (blue)
  2
    Red (red)
  3
    Pink (pink)
  4
    Green (green)
  5
    Cyan (cyan)
  6
    Yellow (yellow)
  7
    Black (black)
  8
    Dark gray (dark slate gray)
  9
    Dark blue (dark slate blue)
  10
    Dark red (red4)
  11
    Dark pink (deep pink)
  12
    Dark green (dark green)
  13
    Dark cyan (cyan4)
  14
    Brown (brown)
  15
    Pale gray (light gray)

OS/2 Considerations

  The following list contains the index values and colors found in a logical color table:

  Index :ddhd.Color
  -2
    White
  -1
    Black
  0
    Background color of the device (white)
  1
    Blue
  2
    Red
  3
    Pink
  4
    Green
  5
    Cyan
  6
    Yellow
  7
    Neutral (black)
  8
    Dark gray
  9
    Dark blue
  10
    Dark red
  11
    Dark pink
  12
    Dark green
  13
    Dark cyan
  14
    Brown
  15
    Pale gray

Windows Considerations

  The following list contains the index values and colors found in the default system palette:

  Index :ddhd.Color
  0
    Black
  1
    Dark red
  2
    Dark green
  3
    Brown
  4
    Dark blue
  5
    Dark pink
  6
    Dark cyan
  7
    Pale gray
  12
    Dark gray
  13
    Red
  14
    Green
  15
    Yellow
  16
    Blue
  17
    Pink
  18
    Cyan
  19
    White

### IColor - Enumerations

ESystemColor

      enum ESystemColor { kShadowIconHiliteBgnd=0,
                          kShadowIconHiliteFgnd,
                          kShadowIconText,
                          kEntryFieldBgnd,
                          kListBoxBgnd,
                          kDisableMenuText,
                          kMenuHiliteText,
                          kMenuHiliteBgnd,
                          kNotebookPageBgnd,
                          kInactiveScrollBar,
                          kDefaultControl,
                          kButtonLight,
                          kButtonMiddle,
                          kButtonDark,
                          kDefaultButton,
                          kTitleLine,
                          kMenuShadow,
                          kDialogShadow,
                          kIconText,
                          kDialogBgnd,
                          kHiliteFgnd,
                          kHiliteBgnd,
                          kInactiveTitleTextBgnd,
                          kActiveTitleTextBgnd,
                          kInactiveTitleText,
                          kActiveTitleText,
                          kOutputText,
                          kWindowStaticText,
                          kScrollBar,
                          kDesktopBgnd,
                          kActiveTitleBgnd,
                          kInactiveTitleBgnd,
                          kMenuBgnd,
                          kWindowBgnd,
                          kFrameBorder,
                          kMenuText,
                          kWindowText,
                          kTitleText,
                          kSizeBar,
                          kScrollArrow,
                          kActiveFrameBorder,
                          kInactiveFrameBorder,
                          kMainWindowBgnd,
                          kHelpWindowBgnd,
                          kHelpText,
                          kHelpHiliteText,
                          shadowIconHiliteBgnd=0,
                          shadowIconHiliteFgnd=1,
                          shadowIconText=2,
                          entryFieldBgnd=3,
                          listBoxBgnd=4,
                          disableMenuText=5,
                          menuHiliteText=6,
                          menuHiliteBgnd=7,
                          notebookPageBgnd=8,
                          inactiveScrollBar=9,
                          defaultControl=10,
                          buttonLight=11,
                          buttonMiddle=12,
                          buttonDark=13,
                          defaultButton=14,
                          titleLine=15,
                          menuShadow=16,
                          dialogShadow=17,
                          iconText=18,
                          dialogBgnd=19,
                          hiliteFgnd=20,
                          hiliteBgnd=21,
                          inactiveTitleTextBgnd=22,
                          activeTitleTextBgnd=23,
                          inactiveTitleText=24,
                          activeTitleText=25,
                          outputText=26,
                          windowStaticText=27,
                          scrollBar=28,
                          desktopBgnd=29,
                          activeTitleBgnd=30,
                          inactiveTitleBgnd=31,
                          menuBgnd=32,
                          windowBgnd=33,
                          frameBorder=34,
                          menuText=35,
                          windowText=36,
                          titleText=37,
                          sizeBar=38,
                          scrollArrow=39,
                          activeFrameBorder=40,
                          inactiveFrameBorder=41,
                          mainWindowBgnd=42,
                          helpWindowBgnd=43,
                          helpText=44,
                          helpHiliteText=45 }

  ESystemColor enumerates constants for system GUI colors.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### IColor - Inherited Member Functions and Data

#### Inherited Public Functions

  IBaseColor

  -     virtual ~IBaseColor()

  -     IBaseColor()

  -     IBaseColor(const IBaseColor&)

  -     IBaseColor(EPredefinedColor commonlyUsedColor)

  -     IBaseColor(CharIntensity gray, CharIntensity opacity = 255)

  -     IBaseColor( CharIntensity red,
                    CharIntensity green,
                    CharIntensity blue,
                    CharIntensity opacity = 255 )

  -     bool operator !=(const IBaseColor&) const

  -     IBaseColor& operator =(const IBaseColor& source)

  -     virtual bool operator ==(const IBaseColor&) const

  IMStreamable

  -     virtual ~IMStreamable()

  -     void externalizeToStream(IDataStream& towhere) const

  -     void internalizeFromStream(IDataStream& fromwhere)

  -     virtual const ITypeRepresentation&
          typeRepresentation() const = 0

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  IBaseColor

  -     const IColorProfile* colorProfile() const

  -     IBaseColor& copyRGBA(const IBaseColor& source)

  -     long
          createIndex( CharIntensity r,
                       CharIntensity g,
                       CharIntensity b )

  -     void rgbFromIndex(unsigned long index)

  -     void
          setRGB( CharIntensity r,
                  CharIntensity g,
                  CharIntensity b,
                  CharIntensity o = 255 )

  IMStreamable

  -     IMStreamable()

  -     IMStreamable(const IMStreamable& other)

  -     virtual void readFromStream(IDataStream& fromwhere) = 0

  -     virtual void writeToStream(IDataStream& towhere) const = 0

#### Inherited Protected Data

  IBaseColor

  -     CharIntensity fBlue

  -     static const IColorProfile* fgColorProfile

  -     CharIntensity fGreen

  -     CharIntensity fOpacity

  -     CharIntensity fRed