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

  1. #ifndef _IRADIOBT_
  2.   #define _IRADIOBT_
  3. /*******************************************************************************
  4. * FILE NAME: iradiobt.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IRadioButton - This class creates and manages the radio button control   *
  9. *                    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 IRadioButton : public ISettingButton  {
  40. typedef ISettingButton Inherited;
  41. /*******************************************************************************
  42. * The IRadioButton class creates and manages the radio button control window.  *
  43. *                                                                              *
  44. * EXAMPLE:                                                                     *
  45. *   IRadioButton rbChoice(ID_CHOICE, this, this, IRectangle(10,10,80,22));     *
  46. *   rbChoice.setText("Cold and Bitter");                                       *
  47. *******************************************************************************/
  48. public:
  49. /*------------------ Style ------------------------------------------------
  50.   The following functions provide a means to set and query radio button
  51.   styles:
  52.  
  53.     Style - Nested class that provides static members that define the set of
  54.             valid radio button styles.  These styles can be used in
  55.             conjunction with the styles defined by the nested classes
  56.             IWindow::Style, IControl::Style, and IButton::Style.  For
  57.             example, you could define an instance of the IRadioButton::Style
  58.             class and initialize it like:
  59.               IRadioButton::Style
  60.                 style = IRadioButton::autoSelect | IControl::tabStop;
  61.             An object of this type is provided when the radio button is
  62.             created.  A customizable default is used if no styles are
  63.             specified.  Once the object is constructed, IRadioButton,
  64.             IWindow, IControl, and IButton member functions can be used to
  65.             set or query the object's style.
  66.  
  67.             The declaration of the IRadioButton::Style nested class is
  68.             generated by the INESTEDBITFLAGCLASSDEF3 macro.
  69.  
  70.   The valid radio button styles are:
  71.     classDefaultStyle - Original default style for this class, which is
  72.                         autoSelect | IWindow::visible.
  73.     autoSelect        - A selection technique in which moving the keyboard
  74.                         cursor automatically changes the current selection.
  75.     noCursorSelect    - Causes the radio button not to select itself when
  76.                         given the focus as the result of an arrow key or tab
  77.                         key.
  78.  
  79.   The following functions provide a means of getting and setting the default
  80.   style for this class:
  81.     defaultStyle    - Returns the current default style.  This is the same as
  82.                       classDefaultStyle unless setDefaultStyle has been
  83.                       called.
  84.     setDefaultStyle - Sets the default style for all subsequent radio
  85.                       buttons.
  86. -------------------------------------------------------------------------*/
  87. INESTEDBITFLAGCLASSDEF3(Style, IRadioButton,
  88.                         IWindow, IControl, IButton);
  89.                                   // style class definition
  90. static const Style
  91.   classDefaultStyle,
  92.   autoSelect,
  93.   noCursorSelect;
  94.  
  95. static Style
  96.    defaultStyle();
  97. static void
  98.    setDefaultStyle(Style style);
  99.  
  100. /*------------------------ Constructors ----------------------------------------
  101. | You can construct instances of this class in the following ways:             |
  102. |    - From a control ID, parent and owner windows, rectangle, and style.      |
  103. |      This creates the specified radio button control and an object for it.   |
  104. |    - From the ID of a radio button control on a dialog window.  This         |
  105. |      creates the object for the specified radio button control.              |
  106. |    - From the window handle of an existing radio button control.  This       |
  107. |      creates the object for the specified radio button control.              |
  108. ------------------------------------------------------------------------------*/
  109.   IRadioButton(unsigned long id,
  110.                IWindow* parent,
  111.                IWindow* owner,
  112.                const IRectangle& initial= IRectangle(),
  113.                const Style& style = defaultStyle() );
  114.  
  115.   IRadioButton(unsigned long id,
  116.                IWindow* parentDialog);
  117.  
  118.   IRadioButton(const IWindowHandle& handle);
  119.  
  120.   virtual ~IRadioButton();
  121.  
  122. /*-------------------------------- Overloaded Auto-select ----------------------
  123. | These operations are overloaded since the actual style setting is different: |
  124. |  enableAutoSelect  - Adds or removes the autoSelect style.                   |
  125. |  disableAutoSelect - Removes the autoSelect style from the radio button      |
  126. |                      control.                                                |
  127. |  isAutoSelect      - Returns true if the radio button control has the        |
  128. |                      autoSelect style set; otherwise, false is returned.     |
  129. ------------------------------------------------------------------------------*/
  130. virtual IRadioButton
  131.   &enableAutoSelect(Boolean enable=true),
  132.   &disableAutoSelect();
  133. virtual Boolean
  134.   isAutoSelect() const;
  135.  
  136. /*----------------------------- Cursor Select Style ----------------------------
  137. | These operations test, enable, and disable the radio button cursor-select    |
  138. | style:                                                                       |
  139. |   enableCursorSelect  - Makes the radio button cursor-selectable.            |
  140. |   disableCursorSelect - Adds the noCursorSelect radio button style.          |
  141. |   isCursorSelect      - Returns true if the radio button is cursor-          |
  142. |                         selectable.                                          |
  143. ------------------------------------------------------------------------------*/
  144. IRadioButton
  145.   &enableCursorSelect(Boolean enable=true),
  146.   &disableCursorSelect();
  147. Boolean
  148.   isCursorSelect() const;
  149.  
  150. /*----------------------------- Select Button Index ----------------------------
  151. |   selectedIndex - Returns the 0-based index of the selected radio button in  |
  152. |                   a group.  If no radio button is selected, a value of -1    |
  153. |                   is returned.                                               |
  154. |                                                                              |
  155. |                   WARNING: If selectedIndex is called without a radio        |
  156. |                            button being selected, some versions of OS/2 may  |
  157. |                            experience system instability.                    |
  158. ------------------------------------------------------------------------------*/
  159. unsigned long
  160.   selectedIndex() const;
  161.  
  162. protected:
  163. /*----------------------------- Layout Size ------------------------------------
  164. | calcMinimumSize - Returns the recommended minimum size of this radio button  |
  165. |                   control.  The size is based on the text string length and  |
  166. |                   the current font.                                          |
  167. ------------------------------------------------------------------------------*/
  168. virtual ISize
  169.   calcMinimumSize() const;
  170.  
  171. private:
  172. /*--------------------------------- PRIVATE ----------------------------------*/
  173.   IRadioButton(const IRadioButton&);
  174.   IRadioButton& operator=(const IRadioButton&);
  175.  
  176. static Style
  177.   currentDefaultStyle;
  178. };  // class IRadioButton
  179.  
  180. INESTEDBITFLAGCLASSFUNCS(Style, IRadioButton);
  181.                                   // global style functions
  182.  
  183. /*----------------------------------------------------------------------------*/
  184. /* Resume compiler default packing.                                           */
  185. /*----------------------------------------------------------------------------*/
  186. #pragma pack()
  187.  
  188. #endif  // _IRADIOBT_
  189.