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

  1. #ifndef _IBUTTON_
  2.   #define _IBUTTON_
  3. /*******************************************************************************
  4. * FILE NAME: ibutton.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *    IButton - The IButton class is the abstract base class for button controls.*
  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 _ITEXTCTL_
  19.   #include <itextctl.hpp>
  20. #endif
  21.  
  22. /*----------------------------------------------------------------------------*/
  23. /* Align classes on four byte boundary.                                       */
  24. /*----------------------------------------------------------------------------*/
  25. #pragma pack(4)
  26.  
  27. // Forward declarations for other classes:
  28. class IColor;
  29.  
  30.  
  31. class IButton : public ITextControl {
  32. typedef ITextControl
  33.   Inherited;
  34. /*******************************************************************************
  35. * The IButton class is the abstract base class for button controls.  This      *
  36. * class contains the common functions for all button controls.  Actual button  *
  37. * controls are created by deriving from this base class.                       *
  38. *******************************************************************************/
  39. public:
  40. /*----------------------- Style -----------------------------------------------
  41.   The following functions provide a means to set and query button styles:
  42.  
  43.     Style - Nested class that provides static members that define the set of
  44.             valid button styles.  These styles can be used in conjunction
  45.             with the styles defined by the nested classes IWindow::Style and
  46.             IControl::Style.  For example, you could define an instance of
  47.             the IButton::Style class and initialize it like:
  48.                IButton::Style
  49.                  style = IControl::tabStop;
  50.             An object of this type is provided when the button is created.  A
  51.             customizable default is used if no styles are specified.  Once
  52.             the object is constructed, IButton, IWindow, and IControl member
  53.             functions can be used to set or query the object's style.
  54.  
  55.             The declaration of the IButton::Style nested class is generated
  56.             by the INESTEDBITFLAGCLASSDEF2 macro.
  57.  
  58.    The valid button styles are:
  59.      noPointerFocus - Buttons with this style do not set the focus to
  60.                       themselves when the user clicks on them using the mouse.
  61.                       This enables the cursor to stay on a control for which
  62.                       information is required, rather than moving to the
  63.                       button.  This has no effect on keyboard interaction.
  64. -----------------------------------------------------------------------------*/
  65. INESTEDBITFLAGCLASSDEF2(Style, IButton, IWindow, IControl);
  66.                                 // style class definition
  67. static const Style
  68.   noPointerFocus;
  69.  
  70. /*-------------------------- Constructor/Destructor ----------------------------
  71. | Instances of this class cannot be created.                                   |
  72. ------------------------------------------------------------------------------*/
  73.   IButton ( );
  74. virtual
  75.  ~IButton ( );
  76.  
  77. /*------------------------------- Mouse Focus ----------------------------------
  78. | The following functions are used to set and query whether the button can     |
  79. | receive the input focus when clicked with the mouse pointer:                 |
  80. |   enableMouseClickFocus  - Enables the button to receive the focus when the  |
  81. |                            user clicks on the button using the mouse.        |
  82. |   disableMouseClickFocus - Prevents the button from receiving the focus      |
  83. |                            when the user clicks on the button using the      |
  84. |                            mouse.                                            |
  85. |   allowsMouseClickFocus  - Queries whether the button can receive the focus. |
  86. ------------------------------------------------------------------------------*/
  87. IButton
  88.  &enableMouseClickFocus  ( Boolean turnOn = true ),
  89.  &disableMouseClickFocus ( );
  90. Boolean
  91.   allowsMouseClickFocus  ( ) const;
  92.  
  93. /*----------------------------- Highlight State --------------------------------
  94. | These operations test and set a button's highlight state.  A highlighted     |
  95. | button will have the same appearance as if the mouse selection button (mouse |
  96. | button 1) was pressed while the mouse pointer was over the button control:   |
  97. |   isHighlighted  -  Returns true if the button's highlight state is set.     |
  98. |   highlight      -  Sets the button's highlight state.                       |
  99. |   unhighlight    -  Turns off the button's highlight state.                  |
  100. ------------------------------------------------------------------------------*/
  101. Boolean
  102.   isHighlighted ( ) const;
  103. virtual IButton
  104.  &highlight     ( ),
  105.  &unhighlight   ( );
  106.  
  107. /*----------------------------- Click the Button -------------------------------
  108. |   click  - Simulates the user clicking on the button control using the       |
  109. |            mouse selection button.                                           |
  110. ------------------------------------------------------------------------------*/
  111. virtual IButton
  112.  &click         ( );
  113.  
  114. /*------------------------------- Enumerations ---------------------------------
  115. | The following enumerations are defined:                                      |
  116. |   ColorArea - Used to replace the color for a particular region.             |
  117. |               Values are:                                                    |
  118. |                 foreground          - Sets the color of the foreground text. |
  119. |                 disabledForeground  - Sets the foreground color for disabled |
  120. |                                       text.                                  |
  121. |                 background          - Sets the color of the background of    |
  122. |                                       the button window.                     |
  123. |                 highlightForeground - Sets the foreground color for          |
  124. |                                       highlighted text.                      |
  125. |                 border              - Sets the color of the border that      |
  126. |                                       surrounds the button window.           |
  127. ------------------------------------------------------------------------------*/
  128. enum ColorArea {
  129.   foreground,
  130.   background,
  131.   disabledForeground,
  132.   highlightForeground,
  133.   border
  134. };
  135.  
  136. /*----------------------------- Color Functions --------------------------------
  137. |  setColor - Changes the color of the given region.                           |
  138. |  color    - Returns the color of the given region.                           |
  139. ------------------------------------------------------------------------------*/
  140. IButton
  141.  &setColor      ( ColorArea value, const IColor& color );
  142. IColor
  143.   color         ( ColorArea value ) const;
  144.  
  145. /*-------------------------------- Overrides -----------------------------------
  146. | This class overrides the following inherited functions:                      |
  147. |   setText - Sets the text for the button and notifies a parent canvas to     |
  148. |             update the layout for its children, if appropriate.              |
  149. ------------------------------------------------------------------------------*/
  150. virtual IButton
  151.  &setText       ( const char* text ),
  152.  &setText       ( const IResourceId& text );
  153.  
  154. protected:
  155.  
  156. private:
  157. /*--------------------------------- Private ----------------------------------*/
  158.   IButton       ( const IButton& );
  159. IButton
  160.  &operator=     ( const IButton& );
  161. };  // class IButton
  162.  
  163. INESTEDBITFLAGCLASSFUNCS(Style, IButton);
  164.                                   // global style functions
  165.  
  166. /*----------------------------------------------------------------------------*/
  167. /* Resume compiler default packing.                                           */
  168. /*----------------------------------------------------------------------------*/
  169. #pragma pack()
  170.  
  171. #endif  /* _IBUTTON_ */
  172.