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

  1. #ifndef _IMSGBOX_
  2. #define _IMSGBOX_
  3. /*******************************************************************************
  4. * FILE NAME: imsgbox.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IMessageBox - the message box class                                      *
  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 _IBASE_
  19.   #include <ibase.hpp>
  20. #endif
  21.  
  22. // Forward declarations for other classes:
  23. class IWindow;
  24. class IResourceId;
  25. class IException;
  26. class IErrorInfo;
  27. #if !defined( _ISTRING_ ) && !defined( I_NO_RELATED_HPP )
  28.   #include <istring.hpp>
  29. #endif
  30. #if !defined( _IBITFLAG_ ) && !defined( I_NO_RELATED_HPP )
  31.   #include <ibitflag.hpp>
  32. #endif
  33.  
  34. /*----------------------------------------------------------------------------*/
  35. /* Align classes on four byte boundary.                                       */
  36. /*----------------------------------------------------------------------------*/
  37. #pragma pack(4)
  38.  
  39. class IMessageBox : public IBase {
  40. /*******************************************************************************
  41. * The IMessageBox class has functions to show different types of Common User   *
  42. * Access (CUA) message boxes.  It shows a message box given a message text,    *
  43. * resource ID, IException, or IErrorInfo object with the specified style, or   *
  44. * using a style defined by the severity of the message.                        *
  45. *******************************************************************************/
  46. typedef IBase
  47.   Inherited;
  48. public:
  49. /*------------------------ Constructor -----------------------------------------
  50. | The only way to construct instances of this class is by using an instance    |
  51. | of IWindow.  The instance of IWindow becomes the owner of the new message    |
  52. | box.  The message box title defaults to the owner's title.                   |
  53. ------------------------------------------------------------------------------*/
  54.   IMessageBox  ( const IWindow* aOwner );
  55.  
  56.   ~IMessageBox ( );
  57.  
  58. /*------------------- Styles ---------------------------------------------------
  59. | The IMessageBox::Style class is a nested class that provides static          |
  60. | members that define the set of valid message box styles.                     |
  61. |                                                                              |
  62. | The following styles specify which push buttons are provided:                |
  63. |    okButton               - Causes the message box to contain an OK push     |
  64. |                             button.                                          |
  65. |    okCancelButton         - Causes the message box to contain both OK and    |
  66. |                             Cancel push buttons.                             |
  67. |    cancelButton           - Causes the message box to contain a Cancel       |
  68. |                             push button.                                     |
  69. |    enterButton            - Causes the message box to contain an Enter       |
  70. |                             push button.                                     |
  71. |    enterCancelButton      - Causes the message box to contain both Enter     |
  72. |                             and Cancel push buttons.                         |
  73. |    retryCancelButton      - Causes the message box to contain both Retry     |
  74. |                             and Cancel push buttons.                         |
  75. |    abortRetryIgnoreButton - Causes the message box to contain Abort,         |
  76. |                             Retry, and Ignore push buttons.                  |
  77. |    yesNoButton            - Causes the message box to contain both Yes and   |
  78. |                             No push buttons.                                 |
  79. |    yesNoCancelButton      - Causes the message box to contain Yes, No, and   |
  80. |                             Cancel push buttons.                             |
  81. |                                                                              |
  82. | The following styles specify default push button actions:                    |
  83. |    defButton1             - Causes the first button to be the default        |
  84. |                             selection.  This is the default action.          |
  85. |    defButton2             - Causes the second button to be the default       |
  86. |                             selection.                                       |
  87. |    defButton3             - Causes the third button to be the default        |
  88. |                             selection.                                       |
  89. |                                                                              |
  90. | The following styles specify which icons are shown:                          |
  91. |    noIcon                 - Causes the message box to contain no icon.       |
  92. |    informationIcon        - Causes the message box to contain a lower case   |
  93. |                             "i" in a circle.                                 |
  94. |    queryIcon              - Causes the message box to contain a question     |
  95. |                             mark (?) in a circle.                            |
  96. |    warningIcon            - Causes the message box to contain an             |
  97. |                             exclamation point (!) in a triangle.             |
  98. |    errorIcon              - Causes the message box to contain a circle with  |
  99. |                             a diagonal line through it.                      |
  100. | The following styles specify modality:                                       |
  101. |    applicationModal       - Causes the message box to be application         |
  102. |                             modal.  This is the default case.  Its owner     |
  103. |                             is disabled; therefore, do not specify the       |
  104. |                             owner as the parent if this option is used.      |
  105. |    systemModal            - Causes the message box to be system modal.       |
  106. |                                                                              |
  107. | The following style specifies mobility:                                      |
  108. |    moveable               - Causes the message box to be moveable.           |
  109. ------------------------------------------------------------------------------*/
  110. INESTEDBITFLAGCLASSDEF0(Style, IMessageBox);
  111. static const Style
  112.   okButton,            // button
  113.   okCancelButton,
  114.   cancelButton,
  115.   enterButton,
  116.   enterCancelButton,
  117.   retryCancelButton,
  118.   abortRetryIgnoreButton,
  119.   yesNoButton,
  120.   yesNoCancelButton,
  121.   defButton1,          // default button action
  122.   defButton2,
  123.   defButton3,
  124.   noIcon,              // icon shown
  125.   informationIcon,
  126.   queryIcon,
  127.   warningIcon,
  128.   errorIcon,
  129.   applicationModal,    // modality
  130.   systemModal,
  131.   moveable;            // mobility
  132.  
  133. /*------------------------------ Severity---------------------------------------
  134. | Severity - Enumerates the different severity levels of a message box.  The   |
  135. |            valid values are:                                                 |
  136. |                                                                              |
  137. |              information  - Displays an information icon with an OK push     |
  138. |                             button.                                          |
  139. |              warning      - Displays a warning icon with Enter and Cancel    |
  140. |                             push buttons.                                    |
  141. |              action       - Displays a query icon with Retry and Cancel      |
  142. |                             push buttons.                                    |
  143. |              critical     - Displays an error icon with Retry and Cancel     |
  144. |                             push buttons.                                    |
  145. |              catastrophic - Displays an error icon with an OK push button.   |
  146. ------------------------------------------------------------------------------*/
  147. enum Severity {
  148.   information,
  149.   warning,
  150.   action,
  151.   critical,
  152.   catastrophic
  153. };
  154.  
  155. /*------------------------------ Response---------------------------------------
  156. | Response - Enumerates the replies possible from a message box.  The valid    |
  157. |            values are:                                                       |
  158. |                                                                              |
  159. |              enter   - Causes the Enter push button to be selected.          |
  160. |              ok      - Causes the OK push button to be selected.             |
  161. |              cancel  - Causes the Cancel push button to be selected.         |
  162. |              abort   - Causes the Abort push button to be selected.          |
  163. |              retry   - Causes the Retry push button to be selected.          |
  164. |              ignore  - Causes the Ignore push button to be selected.         |
  165. |              yes     - Causes the Yes push button to be selected.            |
  166. |              no      - Causes the No push button to be selected.             |
  167. |              unknown - Causes an unknown push button ID to be selected.      |
  168. ------------------------------------------------------------------------------*/
  169. enum Response {
  170.   enter,
  171.   ok,
  172.   cancel,
  173.   abort,
  174.   retry,
  175.   ignore,
  176.   yes,
  177.   no,
  178.   unknown
  179. };
  180.  
  181. /*--------------------------- Set/Show Functions -------------------------------
  182. | These functions provide a means of getting and setting the accessible        |
  183. | attributes of instances of this class:                                       |
  184. |   setTitle - Sets the message box's title.                                   |
  185. |   show     - Shows a message box given one of the following:                 |
  186. |                - Message text and severity                                   |
  187. |                - Resource ID and severity                                    |
  188. |                - Resource ID and style                                       |
  189. |                - Message text and style                                      |
  190. |                - IException object                                           |
  191. |                - IErrorInfo object                                           |
  192. |              A Help push button is displayed if the aHelpId argument is      |
  193. |              specified.                                                      |
  194. ------------------------------------------------------------------------------*/
  195. IMessageBox
  196.   &setTitle(const char* aTitle),
  197.   &setTitle(const IResourceId& aTitle);
  198.  
  199. IMessageBox::Response
  200.   show ( const char*   aMessage,
  201.          Severity      aSeverity,
  202.          unsigned long aHelpId    = 0 ),
  203.  
  204.   show ( const IResourceId& aResId,
  205.          Severity           aSeverity,
  206.          unsigned long      aHelpId    = 0 ),
  207.  
  208.   show ( const IResourceId& resId,
  209.          Style              aStyle,
  210.          unsigned long      aHelpId = 0),
  211.  
  212.   show ( const char*   aMessage,
  213.          Style         aStyle,
  214.          unsigned long aHelpId   = 0),
  215.  
  216.   show ( const IException& aException,
  217.          unsigned long     aHelpId     = 0),
  218.  
  219.   show ( const IErrorInfo& aError,
  220.          unsigned long     aHelpId     = 0);
  221.  
  222. private:
  223. /*--------------------------------- PRIVATE ----------------------------------*/
  224. static unsigned long
  225.   convertSeverity(Severity s);
  226. static IMessageBox::Response
  227.   convertResponse(unsigned long ulId);
  228. IString
  229.   strClTitle;
  230. const IWindow*
  231.   pwndClOwner;
  232. }; // IMessageBox
  233.  
  234. /*----------------------------------------------------------------------------*/
  235. /* Resume compiler default packing.                                           */
  236. /*----------------------------------------------------------------------------*/
  237. #pragma pack()
  238.  
  239. #endif  /* _IMSGBOX_  */
  240.