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

  1. #ifndef _I3STATBX_
  2.   #define _I3STATBX_
  3. /*******************************************************************************
  4. * FILE NAME: i3statbx.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     I3stateCheckBox - This class creates and manages the three-state check   *
  9. *                       box control window.                                    *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   Licensed Materials - Property of IBM                                       *
  13. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  14. *   All Rights Reserved                                                        *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #ifndef _ISETBUT_
  20.   #include <isetbut.hpp>
  21. #endif
  22.  
  23. // Forward declarations for other classes:
  24. class IRectangle;
  25. class ISize;
  26. class IWindowHandle;
  27. #ifndef _IRECT_
  28.   #include <irect.hpp>
  29. #endif
  30. #ifndef _IBITFLAG_
  31.   #include <ibitflag.hpp>
  32. #endif
  33.  
  34. /*----------------------------------------------------------------------------*/
  35. /* Align classes on four byte boundary.                                       */
  36. /*----------------------------------------------------------------------------*/
  37. #pragma pack(4)
  38.  
  39. class I3StateCheckBox : public ISettingButton {
  40. typedef ISettingButton Inherited;
  41. /*******************************************************************************
  42. * The I3StateCheckBox class creates and manages the three-state check box      *
  43. * control window.                                                              *
  44. *                                                                              *
  45. * Selection of a three-state check box can be processed by subclassing the     *
  46. * ISelectHandler class and adding the handler to either the three-state check  *
  47. * box or its owner window.                                                     *
  48. *                                                                              *
  49. *                                                                              *
  50. * EXAMPLE:                                                                     *
  51. * To use this control, create an instance of its class as follows:             *
  52. *   I3StateCheckBox s3bxChoice(ID_CHOICE, this, this,                          *
  53. *                              IRectangle(10,10,80,22));                       *
  54. *   s3bxChoice.setText("Sweet and Sour");                                      *
  55. *******************************************************************************/
  56. public:
  57. /*--------------- Style ---------------------------------------------------
  58.   The following functions provide a means to set or query three-state check
  59.   box styles:
  60.  
  61.     Style - Nested class that provides static members that define the set of
  62.             valid three-state check box styles.  These styles can be used in
  63.             conjunction with the styles defined by the nested classes
  64.             IWindow::Style, IControl::Style, and IButton::Style.  For
  65.             example, you could define an instance of the
  66.             I3StateCheckBox::Style class and initialize it like:
  67.               I3StateCheckBox::Style
  68.                 style = I3StateCheckBox::autoSelect | IControl::tabStop;
  69.             An object of this type is provided when the three-state check
  70.             box is created.  A customizable default is used if no styles are
  71.             specified.  Once the object is constructed, I3StateCheckBox,
  72.             IWindow, IControl, and IButton member functions can be used to
  73.             set or query the object's style.
  74.  
  75.             The declaration of the I3StateCheckBox::Style nested class is
  76.             generated by the INESTEDBITFLAGCLASSDEF3 macro.
  77.  
  78.   The valid three-state check box styles are:
  79.     classDefaultStyle - Original default style for this class.  This
  80.                         style is autoSelect | IWindow::visible.
  81.     autoSelect        - A selection technique in which moving the keyboard
  82.                         cursor automatically changes the current selection.
  83.  
  84.   The following functions provide a means of getting and setting the default
  85.   style for this class:
  86.     defaultStyle    - Returns the current default style.  This is the same as
  87.                       classDefaultStyle unless setDefaultStyle has been
  88.                       called.
  89.     setDefaultStyle - Sets the default style for all subsequent three-state
  90.                       check boxes.
  91. -------------------------------------------------------------------------*/
  92. INESTEDBITFLAGCLASSDEF3(Style, I3StateCheckBox,
  93.                                  IWindow, IControl, IButton);
  94.                                 // style class definition
  95. static const Style
  96.   classDefaultStyle,
  97.   autoSelect;
  98.  
  99. static Style
  100.    defaultStyle();
  101. static void
  102.    setDefaultStyle(Style style);
  103.  
  104. /*------------------------ Constructors ----------------------------------------
  105. | You can construct instances of this class in the following ways:             |
  106. |    - From a control ID, parent and owner windows, rectangle, and style.      |
  107. |      Creates the specified three-state check box control and an object for it.|
  108. |    - From the ID of a three-state check box control on a dialog window.      |
  109. |      Creates the object for the specified three-state check box control.     |
  110. |    - From the window handle of an existing three-state check box control.    |
  111. |      Creates the object for the specified three-state check box control.     |
  112. ------------------------------------------------------------------------------*/
  113.   I3StateCheckBox(unsigned long id,
  114.                   IWindow* parent,
  115.                   IWindow* owner,
  116.                   const IRectangle& initial= IRectangle(),
  117.                   const Style& style = defaultStyle() );
  118.  
  119.   I3StateCheckBox(unsigned long id,
  120.                   IWindow* parentDialog);
  121.  
  122.   I3StateCheckBox(const IWindowHandle& handle);
  123.  
  124.   virtual ~I3StateCheckBox();
  125.  
  126. /*-------------------------------- Overloaded AutoSelect -----------------------
  127. | The following operations are overloaded since the actual style setting is    |
  128. | different:                                                                   |
  129. |  enableAutoSelect  - Sets the three-state check box control to the autoSelect|
  130. |                      style.                                                  |
  131. |  disableAutoSelect - Removes the autoSelect style from the three-state check |
  132. |                      box control.                                            |
  133. |  isAutoSelect      - Returns true if the three-state check box control has   |
  134. |                      the autoSelect style set; otherwise, it returns false.  |
  135. ------------------------------------------------------------------------------*/
  136. virtual I3StateCheckBox
  137.   &enableAutoSelect(Boolean turnOn=true),
  138.   &disableAutoSelect();
  139. virtual Boolean
  140.   isAutoSelect() const;
  141.  
  142. /*-------------------------------- Halftone Operations -------------------------
  143. |  selectHalftone   - Selects a halftone three-state check box control.        |
  144. |  isHalftone       - Returns true if the three-state check box control has    |
  145. |                     been selected as halftone.                               |
  146. ------------------------------------------------------------------------------*/
  147. I3StateCheckBox&
  148.   selectHalftone();
  149. Boolean
  150.   isHalftone() const;
  151.  
  152. protected:
  153. /*----------------------------- Layout Size ------------------------------------
  154. | calcMinimumSize - Returns the recommended minimum size of this three-state   |
  155. |                   check box control.  The size is based on the text string   |
  156. |                   length and the current font.                               |
  157. ------------------------------------------------------------------------------*/
  158. virtual ISize
  159.   calcMinimumSize() const;
  160.  
  161. private:
  162. /*--------------------------------- Private ----------------------------------*/
  163.   I3StateCheckBox(const I3StateCheckBox&);
  164.   I3StateCheckBox& operator=(const I3StateCheckBox&);
  165.  
  166. static Style
  167.   currentDefaultStyle;
  168. };  // I3StateCheckBox
  169.  
  170. INESTEDBITFLAGCLASSFUNCS(Style, I3StateCheckBox);
  171.                                   // global style functions
  172.  
  173. /*----------------------------------------------------------------------------*/
  174. /* Resume compiler default packing.                                           */
  175. /*----------------------------------------------------------------------------*/
  176. #pragma pack()
  177.  
  178. #endif  /* _I3STATBX_ */
  179.