home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ivbfiled.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  14.6 KB  |  295 lines

  1. #ifndef _IVBFILED_
  2.   #define _IVBFILED_
  3. /*******************************************************************************
  4. * FILE NAME: ivbfiled.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IVBFileDialog - A surrogate of the IFileDialog class.                    *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM(R) VisualAge(TM) for C++                                               *
  12. *   (C) Copyright International Business Machines Corporation 1991, 1996       *
  13. *   Licensed Material - Program-Property of IBM - 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. *   This program will not run in DOS mode.                                     *
  18. *                                                                              *
  19. *******************************************************************************/
  20. #ifndef _IVBDEFS__
  21. #include <ivbdefs.h>
  22. #endif
  23.  
  24. #ifndef _ISTDNTFY_
  25.   #include <istdntfy.hpp>
  26. #endif
  27.  
  28. #ifndef _IFILEHDR_
  29.   #include <ifilehdr.hpp>
  30. #endif
  31.  
  32. #ifndef _IFILEDLG_
  33.   #include <ifiledlg.hpp>
  34. #endif
  35.  
  36. /*-------------------------- Pragma Library Support --------------------------*/
  37. #ifndef __NO_DEFAULT_LIBS__
  38.   #ifdef __OS2__
  39.     #ifdef __IMPORTLIB__
  40.        #pragma library("CPPOOV3I.LIB")
  41.     #else
  42.        #pragma library("CPPOOV3.LIB")
  43.     #endif
  44.   #endif
  45.   #ifdef __WINDOWS__
  46.     #ifdef __IMPORTLIB__
  47.        #pragma library("CPPWOV3I.LIB")
  48.     #else
  49.        #pragma library("CPPWOV3.LIB")
  50.     #endif
  51.   #endif
  52. #endif
  53.  
  54. //Forward declarations for other classes:
  55. class IVBFileDialogData;
  56.  
  57. /*----------------------------------------------------------------------------*/
  58. /* Align classes on four byte boundary.                                       */
  59. /*----------------------------------------------------------------------------*/
  60. #pragma pack(4)
  61.  
  62. class IVBFileDialog : public IStandardNotifier
  63. {
  64. typedef IStandardNotifier
  65.   Inherited;
  66. /*******************************************************************************
  67. *                                                                              *
  68. * A surrogate of the IFileDialog class.                                        *
  69. *                                                                              *
  70. * An instance of this class provides an instance of the IFileDialog::Settings  *
  71. * and a protocol to set the member data.                                       *
  72. * Calling either IFileDialog::show or showModally will construct a new         *
  73. * instance of IFileDialog using the instance settings and owner together       *
  74. * with the member function parameters parent, style and handler.               *
  75. *                                                                              *
  76. * Accessor methods are provided to the instance of either IFileDialog or       *
  77. * IFileDialog::Settings. Instances of this class do not forward notifications  *
  78. * of either IFileDialog or IFileDialog::Settings.                              *
  79. *                                                                              *
  80. * Example:                                                                     *
  81. *   IVBFileDialog  fd( owner );                                                *
  82. *   fd.setTitle( "Select a file" ).setOKButtonText( "Select" );                *
  83. *   do {     //wait for user to press "Select"                                 *
  84. *      fd.showModally( );               //default style = single select        *
  85. *      } while ( !fd.pressedOK());                                             *
  86. *   processFile( fd.fileName());        //member function to process file      *
  87. *                                                                              *
  88. ********************************************************************************/
  89. public:
  90.  
  91. /*------------------------ Constructors/Destructor -----------------------------
  92. | You can construct an instance of this class in one way:                      |
  93. |     - Using a constructor that takes an owner.                               |
  94. |                                                                              |
  95. |------------------------------------------------------------------------------*/
  96.   IVBFileDialog(IWindow*    owner);
  97. virtual
  98.  ~IVBFileDialog( );
  99.  
  100. /*------------------------------ Display dialog --------------------------------
  101. |   showModally - Causes a application-modal dialog to be displayed.           |
  102. |   show        - Causes the dialog to be made visible.   The default mode is  |
  103. |                 modal.  If you require a modeless dialog, you must set the   |
  104. |                 modeless style bit in the Style argument.                    |
  105. |   Note: Only one instance of IFileDialog may be showing at any time,         |
  106. |         showModally or show may not be called a second time until the first  |
  107. |         called instance of the dialog has been dismissed.                    |
  108. |         A modal dialog has been dismissed when the caller is returned        |
  109. |         control after a showModally or show.                                 |
  110. |         The results from showing a dialog are loss when showModally or       |
  111. |         show are called again.                                               |
  112. |                                                                              |
  113. ------------------------------------------------------------------------------*/
  114. virtual unsigned long
  115.   showModally   ( IWindow*                   parent  = NULL
  116.                 , const IFileDialog::Style   style   = IFileDialog::defaultStyle()
  117.                 , IHandler*                  handler = 0 );
  118. virtual IVBFileDialog
  119.  &show          ( IWindow*                   parent
  120.                 , const IFileDialog::Style   style   = IFileDialog::defaultStyle()
  121.                 , IHandler*                  handler = 0 );
  122.  
  123. /*---------------- Getting Information About the Dialog ------------------------
  124. | These functions provide ways to get information about the dialog:            |
  125. |    isModeless      - Returns true if this is a modeless dialog.              |
  126. |    pressedOK       - Returns true if the user ended the dialog by pressing   |
  127. |                      the OK push button.                                     |
  128. |    buttonPressedId - Returns the ID of the push button that was used to      |
  129. |                      dismiss the dialog.                                     |
  130. |    returnValue     - Returns the return code, if an error occurred.          |
  131. |      Note: These member functions are valid only after a dialog is           |
  132. |            dismissed.                                                        |
  133. |                                                                              |
  134. ------------------------------------------------------------------------------*/
  135. Boolean
  136.   isModeless              ( ) const,
  137.   pressedOK               ( ) const;
  138.  
  139. long
  140.   buttonPressedId         ( ) const,
  141.   returnValue             ( ) const;
  142.  
  143. /*----------- Getting Information About the Chosen File ------------------------
  144. | These functions provide ways to get information about the file that was      |
  145. | selected in the file dialog:                                                 |
  146. |    selectedFileCount - Returns the number of files selected by the user.     |
  147. |                        This number can be more than one if the dialog was    |
  148. |                        created with IFileDialog::multiSelection.             |
  149. |    fileName          - Returns the fully qualified file name selected by     |
  150. |                        the user.  When multiSelection is used, you should    |
  151. |                        call this function with the fileNumber parameter set  |
  152. |                        from 0 to selectedFileCount - 1, to ensure the        |
  153. |                        correct number of files is returned.                  |
  154. |    saveAsEAType      - Returns the extended-attribute for a Save As dialog.  |
  155. |                        This is the type the user chose from the drop-down    |
  156. |                        list of EA types.  If <All Files> was the chosen EA   |
  157. |                        type, then this returns a 0-length IString.           |
  158. |      Note: These member functions are valid only after a dialog is           |
  159. |            dismissed.                                                        |
  160. ------------------------------------------------------------------------------*/
  161. unsigned long
  162.   selectedFileCount       ( ) const;
  163.  
  164. IString
  165.   fileName                (unsigned long fileNumber = 0) const;
  166.  
  167. #ifdef __OS2__
  168. IString
  169.   saveAsEAType            ( ) const;
  170. #endif
  171.  
  172. /*---------------- Setting Information About the Dialog ------------------------
  173. |  See the IFileDialog for specifics on any member function.                   |
  174. ------------------------------------------------------------------------------*/
  175. virtual  IVBFileDialog
  176.  &setOpenDialog           ( ),
  177.  &setSaveAsDialog         ( ),
  178.  &setTitle                ( const char*        newTitle   ),
  179.  &setTitle                ( const IResourceId& resId      ),
  180.  &setOKButtonText         ( const char*        newText    ),
  181.  &setOKButtonText         ( const IResourceId& resId      ),
  182.  &setInitialFileType      ( const char*        fileType   ),
  183.  &setFileName             ( const char*        fileName   ),
  184.  &setInitialDrive         ( const char*        drive      ),
  185.  &setDialogTemplate       ( const IResourceId& resourceId ),
  186.  &setPosition             ( const IPoint&      position   );
  187.  
  188. #ifdef __OS2__
  189. virtual  IVBFileDialog
  190.  &addFileType             ( const char*        fileType   ),
  191.  &addDrive                ( const char*        drive      );
  192. #endif
  193.  
  194. /*----------------------- Access to Settings and Dialog ------------------------
  195. | These functions provide ways to get addressability to the IFileDialog and    |
  196. | it's Settings (useful with tear-off attributes or access to methods not      |
  197. | externalized by this class):                                                 |
  198. |    fileDialog        - Returns a pointer to the IFileDialog instance         |
  199. |    fileDialogSettings- Returns a pointer to the IFileDialog::Settings        |
  200. |                        instance.                                             |
  201. ------------------------------------------------------------------------------*/
  202. IFileDialog
  203.  *fileDialog( );
  204. IFileDialog::Settings
  205.  *fileDialogSettings( );
  206.  
  207. /*----------------------- Notification Event Descriptions ----------------------
  208. | These INotificationId strings are used for all notifications that            |
  209. | IVBFileDialog provides to its observers:                                     |
  210. |   createdId   - Notification identifier provided to observers when a new     |
  211. |                 IFileDialog has been created.                                |
  212. |   dismissedId - Notification identifier provided to observers when the       |
  213. |                 showing IFileDialog has been dismissed.                      |
  214. |   pressedOkId - Notification identifier provided to observers when the       |
  215. |                 showing IFileDialog has been dismissed with ok button.       |
  216. ------------------------------------------------------------------------------*/
  217. static INotificationId const
  218.   IVB_IMPORT createdId,
  219.   IVB_IMPORT pressedOkId,
  220.   IVB_IMPORT dismissedId;
  221.  
  222. private:
  223. /*------------------------------- PRIVATE ------------------------------------*/
  224. class IDismissFileDialogDetector;
  225.  
  226. IWindow
  227.  *pOwner;
  228. IFileDialog::Settings
  229.   settings;
  230. IFileDialog
  231.  *pFileDialog;
  232. IDismissFileDialogDetector
  233.  *pDismissHandler;
  234. Boolean
  235.   bShowing;
  236. IVBFileDialogData
  237.  *fileDialogProxyData;
  238.  
  239. /*--------------------------- Blocked class methods ----------------------------
  240. | Both the copy constructor and assignment operator are not supported.         |
  241. |                                                                              |
  242. ------------------------------------------------------------------------------*/
  243.   IVBFileDialog( const IVBFileDialog & rhs );     // copy ctor
  244. IVBFileDialog
  245.  &operator=( const IVBFileDialog& rhs );             // assignment
  246.  
  247. /*--------------------- Report detection of dialog end -------------------------
  248. | This function provides a means to notify observers when a modeless           |
  249. | IFileDialog is dismissed.                                                    |
  250. |   dialogEndDetected     - cause notification when a dialog is dismissed.     |
  251. ------------------------------------------------------------------------------*/
  252. virtual IVBFileDialog
  253.  &dialogEndDetected( );
  254.  
  255.  
  256. class  IDismissFileDialogDetector : public IFileDialogHandler
  257. {
  258. public:
  259. /*------------------------------- Constructor ----------------------------------
  260. | The only way to construct an instance of this class is by using the          |
  261. | default constructor.                                                         |
  262. ------------------------------------------------------------------------------*/
  263.   IDismissFileDialogDetector( );
  264. virtual
  265.  ~IDismissFileDialogDetector( );
  266.  
  267. /*------------------------- Detection of dialog end ----------------------------
  268. | This function provides a means to notify observers when a modeless           |
  269. | IFileDialog ends.                                                            |
  270. |    listenForResults     - begin listening for dimissal of a modeless dialog  |
  271. |    modelessResults      - detect the dimissal of a modeless dialog           |
  272. ------------------------------------------------------------------------------*/
  273. virtual IDismissFileDialogDetector
  274.  &listenForResults( IVBFileDialog* pFileDialogProxy );
  275. virtual Boolean
  276.   modelessResults( IFileDialog* endingDialog );
  277.  
  278. private:
  279.  
  280. IVBFileDialog
  281.  *proxy;
  282.  
  283. };   // end IDismissFileDialogDetector
  284.  
  285. friend IDismissFileDialogDetector::modelessResults( IFileDialog* );
  286.  
  287. };  // end IVBFileDialog
  288.  
  289. /*----------------------------------------------------------------------------*/
  290. /* Resume compiler default packing and warning messages.                      */
  291. /*----------------------------------------------------------------------------*/
  292. #pragma pack()
  293.  
  294. #endif /* _IVBFILED_ */
  295.