home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / ICOLOR.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  10KB  |  204 lines

  1. #ifndef _ICOLOR_
  2. #define _ICOLOR_
  3. /*******************************************************************************
  4. * FILE NAME: icolor.hpp                                                        *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IColor - color class                                                     *
  9. *     IDeviceColor - color class                                               *
  10. *     IGUIColor - color class                                                  *
  11. *                                                                              *
  12. * COPYRIGHT:                                                                   *
  13. *   Licensed Materials - Property of IBM                                       *
  14. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  15. *   All Rights Reserved                                                        *
  16. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  17. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  18. *                                                                              *
  19. *******************************************************************************/
  20. #ifndef _IBASE_
  21.   #include <ibase.hpp>
  22. #endif
  23.  
  24. /*----------------------------------------------------------------------------*/
  25. /* Align classes on four byte boundary.                                       */
  26. /*----------------------------------------------------------------------------*/
  27. #pragma pack(4)
  28.  
  29. // Forward declarations for other classes:
  30. class IColor;
  31. class IColorIndex;
  32. class IGUIColor;
  33.  
  34. class IColor : public IBase {
  35. /*******************************************************************************
  36. * The IColor class is used to query and set the color of various areas of the  *
  37. * User Interface Class Library controls.  This class is the base for the other *
  38. * color classes.                                                               *
  39. *******************************************************************************/
  40. public:
  41. /*------------------------ Constructors ----------------------------------------
  42. | You can construct instances of this class in the following ways:             |
  43. |                                                                              |
  44. |   - From the default constructor (protected).                                |
  45. |     The resulting instance represents black because the red, green, and      |
  46. |     blue components are all set to 0.                                        |
  47. |   - From a Color enumerator value.                                           |
  48. |     A specified color enumerator value is used to set the red, green, and    |
  49. |     blue components.                                                         |
  50. |   - From separate red, green, and blue values.                               |
  51. |     The separate component values are stored.                                |
  52. ------------------------------------------------------------------------------*/
  53.   enum Color {white, black, blue, red, pink, green,
  54.               cyan, yellow, darkGray, darkBlue,
  55.               darkRed, darkPink, darkGreen, darkCyan,
  56.               brown, paleGray };
  57.   IColor(Color value);
  58.   IColor(unsigned char red, unsigned char green,
  59.          unsigned char blue);
  60.  
  61. /*-------------------------------- Accessors -----------------------------------
  62. | These function provide means of getting and setting the accessible           |
  63. | attributes of instances of this class:                                       |
  64. |   redMix    - Returns the value of the red component.                        |
  65. |   greenMix  - Returns the value of the green component.                      |
  66. |   blueMix   - Returns the value of the blue component.                       |
  67. |   asRGBLong - Returns the red, green, and blue color value as a long.        |
  68. |   index     - Returns the logical color table index closest to the red,      |
  69. |               green, and blue values.                                        |
  70. |   value     - Determines the color enumerator value given a color index.     |
  71. ------------------------------------------------------------------------------*/
  72. unsigned char
  73.   redMix() const,
  74.   greenMix() const,
  75.   blueMix() const;
  76. long
  77.   asRGBLong() const;
  78. virtual long
  79.   index() const;
  80. IColor::Color
  81.   value() const;
  82.  
  83. /*--------------------------- Set Functions ------------------------------------
  84. |The following functions are used to change the color value:                   |
  85. |  setRed   - Sets the red color mix.                                          |
  86. |  setGreen - Sets the green color mix.                                        |
  87. |  setBlue  - Sets the blue color mix.                                         |
  88. ------------------------------------------------------------------------------*/
  89. IColor
  90.   &setRed(unsigned char redMix),
  91.   &setGreen(unsigned char greenMix),
  92.   &setBlue(unsigned char blueMix);
  93.  
  94.  
  95. protected:
  96. /*--------------------------- Default Constructor ------------------------------
  97. |  IColor - Default constructor.                                               |
  98. ------------------------------------------------------------------------------*/
  99.   IColor();
  100.  
  101. private:
  102. unsigned char
  103.   ucClRed,
  104.   ucClGreen,
  105.   ucClBlue;
  106. }; // IColor
  107.  
  108. class IDeviceColor : public IColor {
  109. /*******************************************************************************
  110. * The IDeviceColor class deals with device-independent color indices.          *
  111. *******************************************************************************/
  112. typedef IColor inherited;
  113. public:
  114. /*------------------------ Constructor -----------------------------------------
  115. | The only way to construct instances of this class is from a DeviceColor      |
  116. | value.  The internal device color is set from the DeviceColor provided.      |
  117. |                                                                              |
  118. | DeviceColor - Determines the device-independent color of the object being    |
  119. |               constructed (defaultColor, background, neutral).               |
  120. ------------------------------------------------------------------------------*/
  121.   enum DeviceColor { defaultColor, background, neutral };
  122.   IDeviceColor(DeviceColor);
  123.  
  124. /*-------------------------------- Accessor ------------------------------------
  125. | This function provides a means of getting and setting the accessible         |
  126. | attributes of instances of this class:                                       |
  127. |   index - Returns the index value of DeviceColor.                            |
  128. ------------------------------------------------------------------------------*/
  129. virtual long
  130.   index() const;
  131.  
  132. private:
  133. /*--------------------------------- Private ----------------------------------*/
  134. long
  135.   lClDeviceColor;
  136. }; // IDeviceColor
  137.  
  138. class IGUIColor : public IColor {
  139. /*******************************************************************************
  140. * The IGUIColor class's instances correspond to one of the system SYSCLR_*     *
  141. * colors in Presentation Manager.                                              *
  142. *******************************************************************************/
  143. typedef IColor inherited;
  144. public:
  145. /*------------------------ Constructor -----------------------------------------
  146. | The only way to construct instances of this class is from a system           |
  147. | color-index (SysColor) value.  The internal system color value is set from   |
  148. | the SysColor provided.                                                       |
  149. ------------------------------------------------------------------------------*/
  150.   enum SysColor {shadowIconHiliteBgnd, shadowIconHiliteFgnd,
  151.                  shadowIconText,
  152.                  entryFieldBgnd, listBoxBgnd,
  153.                  disableMenuText, menuHiliteText,
  154.                  menuHiliteBgnd, notebookPageBgnd,
  155.                  inactiveScrollBar, defaultControl,
  156.                  buttonLight, buttonMiddle,
  157.                  buttonDark, defaultButton,
  158.                  titleLine,
  159.                  menuShadow, dialogShadow,
  160.                  iconText,
  161.                  dialogBgnd, hiliteFgnd,
  162.                  hiliteBgnd, inactiveTitleTextBgnd,
  163.                  activeTitleTextBgnd, inactiveTitleText,
  164.                  activeTitleText, outputText, windowStaticText,
  165.                  scrollBar, desktopBgnd, activeTitleBgnd,
  166.                  inactiveTitleBgnd, menuBgnd, windowBgnd,
  167.                  frameBorder, menuText, windowText,
  168.                  titleText, sizeBar, scrollArrow,
  169.                  activeFrameBorder, inactiveFrameBorder,
  170.                  mainWindowBgnd, helpWindowBgnd,
  171.                  helpText, helpHiliteText };
  172.   IGUIColor(SysColor value);
  173.  
  174. /*-------------------------------- Accessors -----------------------------------
  175. | These functions provide means of getting and setting the accessible          |
  176. | attributes of instances of this class:                                       |
  177. |   setColor - Changes a system color for all windows.                         |
  178. |   index    - Returns a system color-index (SysColor) value for the object.   |
  179. ------------------------------------------------------------------------------*/
  180. void
  181.   setColor(const IColor& newColor);
  182. virtual long
  183.   index() const;
  184.  
  185. private:
  186. /*--------------------------------- PRIVATE ----------------------------------*/
  187. static long
  188.   index(IGUIColor::SysColor cValue);
  189. long
  190.   lClSysColor;
  191. }; // IGUIColor
  192.  
  193. /*----------------------------------------------------------------------------*/
  194. /* Resume compiler default packing.                                           */
  195. /*----------------------------------------------------------------------------*/
  196. #pragma pack()
  197.  
  198. /*--------------------------------- INLINES ----------------------------------*/
  199. #ifndef I_NO_INLINES
  200.   #include <icolor.inl>
  201. #endif
  202.  
  203. #endif /* _ICOLOR_ */
  204.