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

  1. #ifndef _IFILEHDR_
  2.   #define _IFILEHDR_
  3. /*******************************************************************************
  4. * FILE NAME: ifilehdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IFileDialogHandler                                                       *
  9. *     IFileDialogEvent                                                         *
  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               *
  16. *   disclosure                                                                 *
  17. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  18. *                                                                              *
  19. *******************************************************************************/
  20. class IFileDialog;
  21. class IString;
  22.  
  23. #ifndef _IEVENT_
  24.   #include <ievent.hpp>
  25. #endif
  26.  
  27. #ifndef _IHANDLER_
  28.  #include <ihandler.hpp>
  29. #endif
  30.  
  31. /*----------------------------------------------------------------------------*/
  32. /* Align classes on four byte boundary.                                       */
  33. /*----------------------------------------------------------------------------*/
  34. #pragma pack(4)
  35.  
  36. class IFileDialogEvent : public IEvent {
  37. typedef IEvent
  38.   Inherited;
  39. /*******************************************************************************
  40. * The IFileDialogEvent class encapsulates events used in an                    *
  41. * IFileDialogHandler.  It provides the name and length of the file to which    *
  42. * the event pertains.                                                          *
  43. *******************************************************************************/
  44. public:
  45. /*------------------------------- Constructor/Destructor -----------------------
  46. | The only way to construct an instance of this class is by using a            |
  47. | constructor that takes an IEvent as its only parameter.                      |
  48. ------------------------------------------------------------------------------*/
  49.   IFileDialogEvent ( IEvent& event );
  50. virtual
  51.   ~IFileDialogEvent ( );
  52.  
  53. /*--------------------------- File Name Accessors ------------------------------
  54. | These functions provide means of getting and setting the accessible          |
  55. | instances of this class:                                                     |
  56. |   fileName   - Returns the file name to which the event pertains.            |
  57. |   fileLength - Returns the length of the file name.                          |
  58. ------------------------------------------------------------------------------*/
  59. IString
  60.   fileName         ( ) const;
  61. unsigned long
  62.   fileLength       ( ) const;
  63. }; // IFileDialogEvent
  64.  
  65.  
  66. class IFileDialogHandler : public IHandler {
  67. typedef IHandler
  68.   Inherited;
  69. /*******************************************************************************
  70. * The IFileDialogHandler class handles the various messages that affect        *
  71. * the file dialog.                                                             *
  72. *                                                                              *
  73. * To use it, you must create a handler derived from IFileDialogHandler.        *
  74. * This handler must then be attached to an instance of an IFileDialog.         *
  75. * To attach a handler to a modal IFileDialog, you must pass a pointer to the   *
  76. * handler on the IFileDialog constructor.                                      *
  77. *                                                                              *
  78. *                                                                              *
  79. * Example:                                                                     *
  80. *    // Attaching a handler to a modeless dialog                               *
  81. *    MyFileHandler mfh;                                                        *
  82. *    IFileDialog* filed =                                                      *
  83. *       new IFileDialog(desktopWindow(), pwin, IFileDialog::modeless);         *
  84. *    mfh.handleEventsFor(filed);                                               *
  85. *                                                                              *
  86. *    // Attaching a handler to a modal dialog                                  *
  87. *    MyFileHandler* pmf = new MyFileHandler;                                   *
  88. *    IFileDialog* filed =                                                      *
  89. *       new IFileDialog((desktopWindow(), pwin, pmf);                          *
  90. *                                                                              *
  91. *******************************************************************************/
  92. public:
  93. /*------------------------------- Constructor ----------------------------------
  94. | The only way to construct an instance of this class is by using the          |
  95. | default constructor.                                                         |
  96. ------------------------------------------------------------------------------*/
  97. virtual
  98.   ~IFileDialogHandler ( );
  99.  
  100. protected:
  101. /*----------------------------- Dispatch Events --------------------------------
  102. | This method determines if the event is one of the file dialog events.        |
  103. | If it is, it calls the appropriate virtual function:                         |
  104. |   dispatchHandlerEvent - Checks for file dialog events.                      |
  105. ------------------------------------------------------------------------------*/
  106. virtual Boolean
  107.   dispatchHandlerEvent ( IEvent& event );
  108.  
  109. /*---------------------------- File Dialog Events ------------------------------
  110. | These functions are called when a file dialog event occurs.  Override these  |
  111. | to provide your own processing.                                              |
  112. |   filter          - Lets you determine which file names appear in the list   |
  113. |                     box.  Use the IFileDialogEvent::fileName function to     |
  114. |                     determine the file that is about to be added to the      |
  115. |                     dialog's file list box.  Call IEvent::setResult(false)   |
  116. |                     if you do not want the file to appear in the list box.   |
  117. |                     Return true if you do not want the event to be           |
  118. |                     processed by any other handlers.                         |
  119. |   filterName      - Override this function for an easier way of filtering    |
  120. |                     files.  The IFileDialog* pointer passed as the second    |
  121. |                     argument can be used if you need to access the           |
  122. |                     IFileDialog itself.                                      |
  123. |   validate        - Sent when a user selects a file and presses Enter or     |
  124. |                     double clicks on a file in the list box.  Use the        |
  125. |                     IFileDialogEvent::fileName function to get the name      |
  126. |                     selected by the user.  Call IEvent::setResult(false) if  |
  127. |                     the name is unacceptable.  The dialog will not be        |
  128. |                     dismissed in this case.  Return true if you do not want  |
  129. |                     the event to be processed by any other handlers.         |
  130. |   validateName    - Override this function for an easier way of validating.  |
  131. |                     The IFileDialog* pointer passed as the second argument   |
  132. |                     can be used in an IMessageBox constructor (for           |
  133. |                     informing the user why the name is being rejected.)      |
  134. |   modelessResults - Used when a modeless dialog is dismissed.  This          |
  135. |                     function is used even if the dialog is cancelled.  This  |
  136. |                     is done so that you can destroy the IFileDialog if       |
  137. |                     needed.  Use IFileDialog::pressedOK to determine         |
  138. |                     whether the user dismissed the dialog by pressing the    |
  139. |                     OK push button.                                          |
  140. |                                                                              |
  141. |                     If you need to destroy the IFileDialog object, do not    |
  142. |                     delete the IFileDialog* pointer from within              |
  143. |                     modelessResults.  Instead, use                           |
  144. |                     endingDialog->setAutoDeleteObject().                     |
  145. ------------------------------------------------------------------------------*/
  146. virtual Boolean
  147.   filter          ( IFileDialogEvent& event ),
  148.   filterName      ( const IString& fileName,
  149.                     IFileDialog* dialog ),
  150.   validate        ( IFileDialogEvent& event ),
  151.   validateName    ( const IString& fileName,
  152.                     IFileDialog* dialog ),
  153.   modelessResults ( IFileDialog* endingDialog );
  154. }; // IFileDialogHandler
  155.  
  156. /*----------------------------------------------------------------------------*/
  157. /* Resume compiler default packing.                                           */
  158. /*----------------------------------------------------------------------------*/
  159. #pragma pack()
  160.  
  161. #endif /* _IFILEHDR_ */
  162.