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

  1. #ifndef _IGROUPBX_
  2.   #define _IGROUPBX_
  3. /*******************************************************************************
  4. * FILE NAME: igroupbx.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *    IGroupBox - This class creates and manages the group box control window.  *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _ITEXTCTL_
  19.   #include <itextctl.hpp>
  20. #endif
  21. #ifndef _IBITFLAG_
  22.   #include <ibitflag.hpp>
  23. #endif
  24. #ifndef _IRECT_
  25.   #include <irect.hpp>
  26. #endif
  27.  
  28. /*----------------------------------------------------------------------------*/
  29. /* Align classes on four byte boundary.                                       */
  30. /*----------------------------------------------------------------------------*/
  31. #pragma pack(4)
  32.  
  33. // Forward declarations for other classes:
  34. class IColor;
  35. class IRectangle;
  36. class ISize;
  37. class IWindowHandle;
  38.  
  39.  
  40. class IGroupBox : public ITextControl  {
  41. typedef ITextControl
  42.   Inherited;
  43. /*******************************************************************************
  44. * The IGroupBox class creates and manages the group box control window.        *
  45. *                                                                              *
  46. * Example:                                                                     *
  47. *   IGroupBox gbxGroup(ID_GROUPBOX, this, this, IRectangle(10,10,110,210));    *
  48. *   gbxGroup.setText("Colors");                                                *
  49. *******************************************************************************/
  50. public:
  51. /*--------------------- Style ---------------------------------------------
  52.   The following functions provide a means to set and query group box styles:
  53.  
  54.     Style - Nested class that provides static members that define the set of
  55.             valid group box styles.  These styles can be used in conjunction
  56.             with the styles defined by the IWindow::Style nested class.  For
  57.             example, you could define an instance of the IGroupBox::Style
  58.             class and initialize it like:
  59.               IGroupBox::Style
  60.                 style = IWindow::visible;
  61.             An object of this type is provided when the group box is
  62.             created.  A customizable default is used if no styles are
  63.             specified.  Once the object is constructed, IGroupBox and
  64.             IWindow member functions can be used to set or query the
  65.             object's style.
  66.  
  67.             The declaration of the IGroupBox::Style nested class is
  68.             generated by the INESTEDBITFLAGCLASSDEF1 macro.
  69.  
  70.   The valid group box styles are:
  71.     classDefaultStyle - Original default style for this class, which is
  72.                         IWindow::visible.
  73.  
  74.   The following functions provide a means of getting and setting the default
  75.   style for this class:
  76.     defaultStyle    - Returns the current default style.  This is the same as
  77.                       classDefaultStyle unless setDefaultStyle has been
  78.                       called.
  79.     setDefaultStyle - Sets the default style for all subsequent group boxes.
  80. -------------------------------------------------------------------------*/
  81. INESTEDBITFLAGCLASSDEF1(Style, IGroupBox, IWindow);
  82.                                   // style class definition
  83. static const Style
  84.   classDefaultStyle;
  85.  
  86. static Style
  87.   defaultStyle();
  88. static void
  89.   setDefaultStyle(Style style);
  90.  
  91. /*------------------------- Constructors/Destructor ----------------------------
  92. | You can construct an instance of this class in the following ways:           |
  93. |    - From a control ID, parent and owner windows, rectangle, and style.      |
  94. |      This creates the specified group box control and an object for it.      |
  95. |    - From the ID of a group box control on a dialog window.  This creates    |
  96. |      the object for the specified group box control.                         |
  97. |    - From the window handle of an existing group box control.  This creates  |
  98. |      the object for the specified group box control.                         |
  99. ------------------------------------------------------------------------------*/
  100.   IGroupBox ( unsigned long id,
  101.               IWindow* parent,
  102.               IWindow* owner,
  103.               const IRectangle& initial= IRectangle(),
  104.               const Style& style = defaultStyle() );
  105.  
  106.   IGroupBox ( unsigned long id,
  107.               IWindow* parentDialog );
  108.  
  109.   IGroupBox ( const IWindowHandle& handle );
  110.  
  111. virtual
  112.  ~IGroupBox ( );
  113.  
  114. /*------------------------------- Enumerations ---------------------------------
  115. | The following enumeration is defined:                                        |
  116. |   ColorArea - Used to replace the color for a particular region.             |
  117. |               Values are:                                                    |
  118. |                 foreground - Sets the foreground color used for the text.    |
  119. |                 border     - Sets the color of the border that surrounds the |
  120. |                              group box window.                               |
  121. ------------------------------------------------------------------------------*/
  122. enum ColorArea {
  123.   foreground,
  124.   border
  125. };
  126.  
  127. /*----------------------------- Color Functions --------------------------------
  128. | These functions are used to change or return the colors used by the control: |
  129. |  setColor - Changes the color of the displayed text.                         |
  130. |  color    - Returns the color of the displayed text.                         |
  131. ------------------------------------------------------------------------------*/
  132. IGroupBox
  133.  &setColor ( ColorArea value, const IColor& color );
  134.  
  135. IColor
  136.   color    ( ColorArea value ) const;
  137.  
  138. /*-------------------------------- Overrides -----------------------------------
  139. | This class overrides the following inherited function:                       |
  140. |   setText - Sets the text for the group box and notifies a parent canvas to  |
  141. |             update the layout for its children, if appropriate.              |
  142. ------------------------------------------------------------------------------*/
  143. virtual IGroupBox
  144.  &setText  ( const char* text ),
  145.  &setText  ( const IResourceId& text );
  146.  
  147. protected:
  148. /*------------------------------- Layout Size ----------------------------------
  149. | calcMinimumSize - Returns the recommended minimum size of this group box     |
  150. |                   control.  The size is based on the current font and the    |
  151. |                   text string limit.                                         |
  152. ------------------------------------------------------------------------------*/
  153. virtual ISize
  154.   calcMinimumSize() const;
  155.  
  156. private:
  157. /*--------------------------------- Private ----------------------------------*/
  158.   IGroupBox ( const IGroupBox& );
  159. IGroupBox
  160.  &operator= ( const IGroupBox& );
  161.  
  162. static Style
  163.   currentDefaultStyle;
  164. }; // class IGroupBox
  165.  
  166. INESTEDBITFLAGCLASSFUNCS(Style, IGroupBox);
  167.                                   // global style functions
  168.  
  169. /*----------------------------------------------------------------------------*/
  170. /* Resume compiler default packing.                                           */
  171. /*----------------------------------------------------------------------------*/
  172. #pragma pack()
  173.  
  174. #endif  /* _IGROUPBX_ */
  175.