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

  1. #ifndef _IPUSHBUT_
  2.   #define _IPUSHBUT_
  3. /*******************************************************************************
  4. * FILE NAME: ipushbut.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     Ipushbut - This class creates and manages the pushbutton 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. * $Log:   R:/IBMCLASS/IBASECTL/VCS/IPUSHBUT.HPV  $
  18. //
  19. //   Rev 1.6   25 Oct 1992 17:05:54   nunn
  20. //changed library name to ICLUI
  21. //
  22. //   Rev 1.5   25 Oct 1992 10:56:28   boezeman
  23. //Add documentation and converted file to skeleton.hpp format.
  24.  
  25.       Rev 1.4   13 Oct 1992 21:22:24   tsuji
  26.    Correct comments around log directive.
  27.  
  28.       Rev 1.3   13 Oct 1992 20:57:22   tsuji
  29.    Correct log directive, remove IBM Confidential classification.
  30.  
  31.       Rev 1.2   13 Oct 1992 19:06:04   tsuji
  32.    Remove no-op virtual destructor, add Inherited typedef.
  33. *******************************************************************************/
  34. #ifndef _IBUTTON_
  35.   #include <ibutton.hpp>
  36. #endif
  37.  
  38. // Forward declarations for other classes:
  39. class IPushButton;  /* pb */
  40. class IRectangle;
  41. class ISize;
  42. class IWindowHandle;
  43. #ifndef _IBITFLAG_
  44.   #include <ibitflag.hpp>
  45. #endif
  46.  
  47.  
  48. class IPushButton : public IButton  {
  49. /*******************************************************************************
  50. * This class creates and manages the pushbutton control window.                *
  51. *                                                                              *
  52. * To use this class, create an instance of this class as follows:              *
  53.     IPushButton pbCancel(ID_CANCEL, this, IRectangle(10,10,30,12));            *
  54.     pbCancel.setText("Cancel");                                                *
  55. * The standard pushbutton will generate an ICommandEvent. The application can  *
  56. * change the window style value to generate a help event or ISysCommandEvent.  *
  57. *                                                                              *
  58. * The class user of this control can change the push button event (message)    *
  59. * processing by calling the setStyle(IPushButton::Style) function with a style *
  60. * including IPushButton::help or IPushButton::systemCommand to cause an IEvent *
  61. * with a WM_HELP or a WM_SYSCOMMAND message, respectively.                     *
  62. *    Valid styles for a push button control are:                               *
  63. *       IPushButton::help,                                                     *
  64. *       IPushButton::systemCommand,                                            *
  65. *       IPushButton::defaultButton,                                            *
  66. *       IPushButton::noBorder,                                                 *
  67. *       IPushButton::defStyle,                                                 *
  68. *       any of the IButton styles,                                             *
  69. *       any of the IControl styles, and                                        *
  70. *       any of the IWindow styles.                                             *
  71. *                                                                              *
  72. * If the push button was not created from a dialog template, then the          *
  73. * application is responsible for processing the Enter key and calling the push *
  74. * button's inherited click() function.                                         *
  75. *                                                                              *
  76. * EXAMPLE:                                                                     *
  77. *   <sample code>                                                              *
  78. *******************************************************************************/
  79. typedef IButton
  80.   Inherited;
  81. public:
  82. INESTEDBITFLAGCLASSDEF3(Style, IPushButton, IWindow,
  83.                         IControl, IButton);
  84.                                   // style class definition
  85. static const Style
  86. //    userButton,                               add later?  $HT!!
  87.   help,
  88.   systemCommand,
  89.   defaultButton,
  90.   noBorder;
  91. static const Style&
  92.   defStyle;
  93.  
  94. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  95. | There are 3 ways to construct instances of this class:                       |
  96. |   1. default                                                                 |
  97. |   2. From a Dialog Template                                                  |
  98. |   3. From a Window                                                           |
  99. ------------------------------------------------------------------------------*/
  100.   IPushButton(unsigned long Id,
  101.               const IWindow* parent,
  102.               const IWindow* owner,
  103.               const IRectangle& initial,
  104.               Style style = defStyle);
  105.  
  106.   IPushButton(unsigned long Id,
  107.               const IWindow* parentDialog);
  108.  
  109.   IPushButton(IWindowHandle handle);
  110.  
  111. /*-------------------------------- STYLES --------------------------------------
  112. | These function provide means of getting and setting the default style        |
  113. | attributes of instances of this class:                                       |
  114. |   defaultStyle    - returns the pushbutton control default style setting     |
  115. |   setDefaultStyle - sets the pushbutton control default style                |
  116. ------------------------------------------------------------------------------*/
  117. static Style
  118.   defaultStyle();
  119. static void
  120.   setDefaultStyle(Style style);
  121.  
  122. /*-------------------------------- TEST/SET DEFAULT STYLE-----------------------
  123. | These operations test and set the default state of a pushbutton.  Making a   |
  124. | pushbutton the default allows it to be selected with the enter key without   |
  125. | having the cursor on the pushbutton.  Visually a default pushbutton has a    |
  126. | darker and thicker border.                                                   |
  127. |   isDefault       - Return true if the BS_DEFAULT style is set.              |
  128. |   setDefault      - Adds a BS_DEFAULT style to the pushbutton.               |
  129. |   unsetDefault    - Removes a BS_DEFAULT style to the pushbutton.            |
  130. ------------------------------------------------------------------------------*/
  131. Boolean
  132.   isDefault() const;
  133. void
  134.   setDefault(),
  135.   unsetDefault();
  136.     /***********************************************************/
  137.     /* Ideally, only one push button should be made a default  */
  138.     /* push button.  Don't know whether PM handles this        */
  139.     /* automatically (I'd guess it doesn't).                   */
  140.     /* Should test this out, and maybe add code to do this if  */
  141.     /* it's not handled by PM (have unsetDefault() called for  */
  142.     /* all other push buttons owned by the window?).           */
  143.     /***********************************************************/
  144.  
  145. protected:
  146. /*----------------------------- LAYOUT SIZE ------------------------------------
  147. | calcMinSize - returns the minimum size that this pushbutton control should be|
  148. ------------------------------------------------------------------------------*/
  149. virtual ISize
  150.   calcMinSize();
  151.  
  152. static Style
  153.   classDefaultStyle;
  154.  
  155. private:
  156. /*--------------------------------- PRIVATE ----------------------------------*/
  157.   IPushButton(const IPushButton&);
  158. //IPushButton& operator=(const IPushButton&);
  159.  
  160. static const Style
  161.   pushButton;
  162. };  // class IPushButton
  163.  
  164. INESTEDBITFLAGCLASSFUNCS(Style, IPushButton);
  165.                                   // global style functions
  166. #endif  // _IPUSHBUT_
  167.