home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / iradiobt.hp_ / IRADIOBT.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  11.4 KB  |  210 lines

  1. #ifndef _IRADIOBT_
  2.   #define _IRADIOBT_
  3. /*******************************************************************************
  4. * FILE NAME: iradiobt.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     Iradiobt - This class creates and manages the radio button conrol 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. * $Log:   R:/IBMCLASS/IBASECTL/VCS/IRADIOBT.HPV  $
  18. //
  19. //   Rev 1.6   25 Oct 1992 17:05:58   nunn
  20. //changed library name to ICLUI
  21. //
  22. //   Rev 1.5   25 Oct 1992 10:56:40   boezeman
  23. //Add documentation and converted file to skeleton.hpp format.
  24.  
  25.       Rev 1.4   13 Oct 1992 21:22:30   tsuji
  26.    Correct comments around log directive.
  27.  
  28.       Rev 1.3   13 Oct 1992 20:57:36   tsuji
  29.    Correct log directive, remove IBM Confidential classification.
  30.  
  31.       Rev 1.2   13 Oct 1992 19:06:08   tsuji
  32.    Remove no-op virtual destructor, add Inherited typedef.
  33. *******************************************************************************/
  34. #ifndef _ISETBUT_
  35.   #include <isetbut.hpp>
  36. #endif
  37.  
  38. // Forward declarations for other classes:
  39. class IRadioButton;  /* rb */
  40. class IRectangle;
  41. class ISize;
  42. class IWindowHandle;
  43. #ifndef _IBITFLAG_
  44.   #include <ibitflag.hpp>
  45. #endif
  46.  
  47. class IRadioButton : public ISettingButton  {
  48. /*******************************************************************************
  49. * This class creates and manages the radio button control window.              *
  50. *                                                                              *
  51. * To use this class, create an instance of this class as follows:              *
  52. *   IRadioButton rbChoice(ID_CHOICE, this, IRectangle(10,10,30,12));           *
  53. *   rbChoice.setText("Cold and Bitter");                                       *
  54. * User action or invoking an operation on the radio button will cause an       *
  55. * IControlEvent. Use the id() and notifyCode() operations in IControlEvent to  *
  56. * process the event (e.g. a notification code of BN_CLICKED or BN_DBLCLICKED). *
  57. *                                                                              *
  58. * NOTE:Not sure the following is still true???                                 *
  59. * Because OS/2 PM does not properly implement the BS_NOCURSORSELECT style of   *
  60. * radio buttons on non-dialog template created windows, the application must   *
  61. * add processing to implement this radio button style. The example and         *
  62. * following comments will help the application developer code this.            *
  63. *    case WM_CHAR:                                                             *
  64. *         if (tab or arrow key)                                                *
  65. *            if (the control before the radio button has focus)                *
  66. *               if (rbTest->isCursorSelect())                                  *
  67. *                {                                                             *
  68. *                  if (rb_test->isSelected())                                  *
  69. *                     rb_test->select(FALSE);                                  *
  70. *                  else                                                        *
  71. *                     rb_test->select(TRUE);                                   *
  72. *                }                                                             *
  73. *                                                                              *
  74. * OS/2 PM enumerates the controls in a dialog template as they appear in the   *
  75. * template from the top to the bottom.  In non-template windows, PM enumerates *
  76. * the controls from the last created control to the first created control.     *
  77. * This causes a problem, for example, with the grouping of controls around the *
  78. * WS_GROUP and WS_TABSTOP styles.  As a result, controls on a non-dialog       *
  79. * template window should be created in the opposite order than the controls    *
  80. * would have appeared in a dialog template.  The following illustration of     *
  81. * controls on a window (not in a dialog template) would require that the push  *
  82. * button be created first, the "Radio 2" radio button second, the "Radio 1"    *
  83. * radio button third, and the entry field last.                                *
  84. *                     __________________                                       *
  85. *                    | Entry Field      |                                      *
  86. *                     ------------------                                       *
  87. *                     o Radio 1                                                *
  88. *                     o Radio 2                                                *
  89. *                     ______                                                   *
  90. *                    |______|    <--- Push button                              *
  91. *                                                                              *
  92. * To insure that OS/2 PM's implementation of the radio button control works    *
  93. * properly, create all radio button controls in the same group one after the   *
  94. * other (or place the radio buttons together in a dialog template).            *
  95. *                                                                              *
  96. * Also, invoke the setStyle() function, specifying a style that includes       *
  97. * IControl::group (or place the WS_GROUP style in dialog template) for the     *
  98. * first control in each group and for the first control AFTER each group.      *
  99. *                                                                              *
  100. * User action or invoking an operation on the radio button will cause an       *
  101. * IControlEvent.  The low 2 bytes of the first parameter will be equal to the  *
  102. * radio button ID and the high 2 bytes of the first parameter will equal to    *
  103. * either BN_CLICKED or BN_DBLCLICKED.  The second parameter is not used.       *
  104. *                                                                              *
  105. * EXAMPLE:                                                                     *
  106. *   <sample code>                                                              *
  107. *******************************************************************************/
  108. /*                 *** Like to handle #2 automatically   **    */
  109. /*                 *** Need test case to understand this **    */
  110. /*                 *** better.                           **    */
  111. /*                 ** should we update IControlEvent to  **    */
  112. /*                 ** provide this                       **    */
  113. typedef ISettingButton
  114.   Inherited;
  115. public:
  116. INESTEDBITFLAGCLASSDEF3(Style, IRadioButton,
  117.                         IWindow, IControl, IButton);
  118.                                   // style class definition
  119. static const Style
  120.   autoSelect,
  121.   noCursorSelect;
  122. static const Style&
  123.   defStyle;
  124.  
  125. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  126. | There are 3 ways to construct instances of this class:                       |
  127. |   1. default                                                                 |
  128. |   2. From a Dialog Template                                                  |
  129. |   3. From a Window                                                           |
  130. ------------------------------------------------------------------------------*/
  131.   IRadioButton(unsigned long Id,
  132.                const IWindow* parent,
  133.                const IWindow* owner,
  134.                const IRectangle& initial,
  135.                Style style = defStyle);
  136.  
  137.   IRadioButton(unsigned long ulId,
  138.                const IWindow* parentDialog);
  139.  
  140.   IRadioButton(IWindowHandle handle);
  141.  
  142. /*-------------------------------- STYLES --------------------------------------
  143. | These function provide means of getting and setting the default style        |
  144. | attributes of instances of this class:                                       |
  145. |   defaultStyle    - returns the radio button control default style setting   |
  146. |   setDefaultStyle - sets the radio button control default style              |
  147. ------------------------------------------------------------------------------*/
  148. static Style
  149.    defaultStyle();
  150. static void
  151.    setDefaultStyle(Style style);
  152.  
  153. /*-------------------------------- OVERLOADED AUTOSELECT------------------------
  154. | These operations are overloaded since the actual style setting is different. |
  155. |  enableAutoSelect  - sets/removes the radio button control to/from the       |
  156. |                       autoselect style                                       |
  157. |  disableAutoSelect - removes the autoselect style from the radio button control|
  158. |  isAutoSelect      - returns true is the radio button control has the        |
  159. |                      autoselect style set else it returns false              |
  160. ------------------------------------------------------------------------------*/
  161. virtual void
  162.   enableAutoSelect(),
  163.   disableAutoSelect();
  164. virtual Boolean
  165.   isAutoSelect() const;
  166.  
  167. /*----------------------------- CURSOR SELECT STYLE ----------------------------
  168. | These operation test, enable and disable the radio button cursor select style.|
  169. |   enableCursorSelect  -  Makes the radio button cursor selectable.           |
  170. |   disableCursorSelect -  Adds the non-cursor-selectable radio button style.  |
  171. |   isCursorSelect      -  Return true if the radio button is cursor selectable.|
  172. ------------------------------------------------------------------------------*/
  173. void
  174.   enableCursorSelect(),
  175.   disableCursorSelect();
  176. Boolean
  177.   isCursorSelect() const;
  178.  
  179. /*----------------------------- SELECT BUTTON INDEX ----------------------------
  180. |   selectedIndex  -  Return the 0-based index of the selected radio button in |
  181. |                     a group.  If no radio button is selected, a value of -1  |
  182. |                     is returned.                                             |
  183. ------------------------------------------------------------------------------*/
  184. long
  185.   selectedIndex() const;
  186.  
  187. protected:
  188. /*----------------------------- LAYOUT SIZE ------------------------------------
  189. | calcMinSize - returns the minimum size that this radio button control        |
  190. |               should be.                                                     |
  191. ------------------------------------------------------------------------------*/
  192. virtual ISize
  193.   calcMinSize();
  194.  
  195. static Style
  196.   classDefaultStyle;
  197.  
  198. private:
  199. /*--------------------------------- PRIVATE ----------------------------------*/
  200.   IRadioButton(const IRadioButton&);
  201. //IRadioButton& operator=(const IRadioButton&);
  202.  
  203. static const Style
  204.   radioButton;
  205. };  // class IRadioButton
  206.  
  207. INESTEDBITFLAGCLASSFUNCS(Style, IRadioButton);
  208.                                   // global style functions
  209. #endif  // _IRADIOBT_
  210.