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

  1. #ifndef _ICHECKBX_
  2.   #define _ICHECKBX_
  3. /*******************************************************************************
  4. * FILE NAME: icheckbx.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *    ICheckBox - This class creates and manages the check 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 _ISETBUT_
  19.   #include <isetbut.hpp>
  20. #endif
  21.  
  22. // Forward declarations for other classes:
  23. class IRectangle;
  24. class ISize;
  25. class IWindowHandle;
  26. #ifndef _IRECT_
  27.   #include <irect.hpp>
  28. #endif
  29. #ifndef _IBITFLAG_
  30.   #include <ibitflag.hpp>
  31. #endif
  32.  
  33. /*----------------------------------------------------------------------------*/
  34. /* Align classes on four byte boundary.                                       */
  35. /*----------------------------------------------------------------------------*/
  36. #pragma pack(4)
  37.  
  38. class ICheckBox : public ISettingButton  {
  39. typedef ISettingButton Inherited;
  40. /*******************************************************************************
  41. * The ICheckBox class creates and operates on a check box.  A check box is a   *
  42. * square box with associated text that represents a choice.  When a user       *
  43. * selects the choice, the check box is filled to indicate that the choice is   *
  44. * selected.  The user can clear the check box by selecting the choice again,   *
  45. * thereby deselecting the choice.                                              *
  46. *                                                                              *
  47. * Selection of a check box can be processed by subclassing the ISelectHandler  *
  48. * class and adding the handler either to the check box or to its owner window. *
  49. *                                                                              *
  50. *                                                                              *
  51. * EXAMPLE:                                                                     *
  52. *   ICheckBox chkbxChoice(ID_CHOICE, this, this, IRectangle(10,10,80,22));     *
  53. *   chkbxChoice.setText("Hot and Spicy");                                      *
  54. *******************************************************************************/
  55. public:
  56. /*--------------- Style ---------------------------------------------------
  57.   The following functions provide a means to set and query check box styles:
  58.  
  59.     Style - Nested class that provides static members that define the set of
  60.             valid check box styles.  These styles can be used in conjunction
  61.             with the styles defined by the nested classes IWindow::Style,
  62.             IControl::Style, and IButton::Style.  For example, you could
  63.             define an instance of the ICheckBox::Style class and initialize
  64.             it like:
  65.               ICheckBox::Style
  66.                 style = ICheckBox::autoSelect | IControl::tabStop;
  67.             An object of this type is provided when the check box is created.
  68.             A customizable default is used if no styles are specified.  Once
  69.             the object is constructed, ICheckBox, IWindow, IControl, and
  70.             IButton member functions can be used to set or query the
  71.             object's style.
  72.  
  73.             The declaration of the ICheckBox::Style nested class is
  74.             generated by the INESTEDBITFLAGCLASSDEF3 macro.
  75.  
  76.   The valid check box styles are:
  77.     classDefaultStyle - Original default style for this class, which is
  78.                         autoSelect | IWindow::visible.
  79.     autoSelect        - A selection technique in which moving the keyboard
  80.                         cursor automatically changes the current selection.
  81.  
  82.   The following functions provide a means of getting and setting the default
  83.   style for this class:
  84.     defaultStyle    - Returns the current default style.  This is the same as
  85.                       classDefaultStyle unless setDefaultStyle has been
  86.                       called.
  87.     setDefaultStyle - Sets the default style for all subsequent check boxes.
  88. -------------------------------------------------------------------------*/
  89. INESTEDBITFLAGCLASSDEF3(Style, ICheckBox, IWindow,
  90.                         IControl, IButton);
  91.                                   // style class definition
  92. static const Style
  93.   classDefaultStyle,
  94.   autoSelect;
  95.  
  96. static Style
  97.   defaultStyle();
  98. static void
  99.   setDefaultStyle(Style style);
  100.  
  101. /*------------------------ Constructors ----------------------------------------
  102. | You can construct instances of this class in the following ways:             |
  103. |    - From a control ID, parent and owner windows, rectangle, and style.      |
  104. |      This creates the specified check box control and an object for it.      |
  105. |    - From the ID of a check box control on a dialog window.                  |
  106. |      This creates the object for the specified check box control.            |
  107. |    - From the window handle of an existing check box control.                |
  108. |      This creates the object for the specified check box control.            |
  109. ------------------------------------------------------------------------------*/
  110.   ICheckBox(unsigned long id,
  111.             IWindow* parent,
  112.             IWindow* owner,
  113.             const IRectangle& initial= IRectangle(),
  114.             const Style& style = defaultStyle() );
  115.  
  116.   ICheckBox(unsigned long id,
  117.             IWindow* parentDialog);
  118.  
  119.   ICheckBox(const IWindowHandle& handle);
  120.  
  121.   virtual ~ICheckBox();
  122. /*-------------------------------- Overloaded AutoSelect -----------------------
  123. | The following operations are overloaded since the actual style setting is    |
  124. | different:                                                                   |
  125. |  enableAutoSelect  - Sets the check box control to the autoSelect style, or  |
  126. |                      removes the autoSelect style from the control.          |
  127. |  disableAutoSelect - Removes the autoSelect style from the check box control.|
  128. |  isAutoSelect      - Returns true if the check box control has the           |
  129. |                      autoSelect style set; otherwise, it returns false.      |
  130. ------------------------------------------------------------------------------*/
  131. virtual ICheckBox
  132.   &enableAutoSelect(Boolean turnOn=true),
  133.   &disableAutoSelect();
  134. virtual Boolean
  135.   isAutoSelect() const;
  136. protected:
  137. /*----------------------------- Layout Size ------------------------------------
  138. | calcMinimumSize - Returns the recommended minimum size of this check box     |
  139. |                   control.  The size is based on the text string length      |
  140. |                   and the current font.                                      |
  141. ------------------------------------------------------------------------------*/
  142. virtual ISize
  143.   calcMinimumSize() const;
  144.  
  145. private:
  146. /*--------------------------------- Private ----------------------------------*/
  147.   ICheckBox(const ICheckBox&);
  148.   ICheckBox& operator=(const ICheckBox&);
  149. static Style
  150.   currentDefaultStyle;
  151. };  // class ICheckBox
  152.  
  153. INESTEDBITFLAGCLASSFUNCS(Style, ICheckBox);
  154.                                   // global style functions
  155.  
  156. /*----------------------------------------------------------------------------*/
  157. /* Resume compiler default packing.                                           */
  158. /*----------------------------------------------------------------------------*/
  159. #pragma pack()
  160.  
  161. #endif  /* _ICHECKBX_ */
  162.