home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WFILEDLG.HPP < prev    next >
C/C++ Source or Header  |  1996-11-19  |  8KB  |  225 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WFileDialog -- FileDialog class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       FolderChange --
  19.  *
  20.  *       NewFileType --
  21.  *
  22.  *       SharingViolation --
  23.  *
  24.  *************************************************************************/
  25.  
  26. #ifndef _WFILEDIALOG_HPP_INCLUDED
  27. #define _WFILEDIALOG_HPP_INCLUDED
  28.  
  29. #ifndef _WNO_PRAGMA_PUSH
  30. #pragma pack(push,8);
  31. #pragma enum int;
  32. #endif
  33.  
  34. #ifndef _WCOMDLG_HPP_INCLUDED
  35. #  include "wcomdlg.hpp"
  36. #endif
  37.  
  38. // WFileFilter
  39. //
  40. //    Used for building filter lists.
  41.  
  42. struct WFileFilter {
  43.     const WChar *title;
  44.     const WChar *pattern;
  45. };
  46.  
  47. // Styles
  48.  
  49. typedef WULong WFDStyle;
  50.  
  51. #define WFDSReadOnly                 ((WFDStyle)0x00000001L)
  52. #define WFDSOverWritePrompt          ((WFDStyle)0x00000002L)
  53. #define WFDSHideReadOnly             ((WFDStyle)0x00000004L)
  54. #define WFDSNoChangeDir              ((WFDStyle)0x00000008L)
  55. #define WFDSShowHelp                 ((WFDStyle)0x00000010L)
  56. #define WFDSEnableHook               ((WFDStyle)0x00000020L)
  57. #define WFDSEnableTemplate           ((WFDStyle)0x00000040L)
  58. #define WFDSEnableTemplateHandle     ((WFDStyle)0x00000080L)
  59. #define WFDSNoValidate               ((WFDStyle)0x00000100L)
  60. #define WFDSAllowMultiSelect         ((WFDStyle)0x00000200L)
  61. #define WFDSExtensionDifferent       ((WFDStyle)0x00000400L)
  62. #define WFDSPathMustExist            ((WFDStyle)0x00000800L)
  63. #define WFDSFileMustExist            ((WFDStyle)0x00001000L)
  64. #define WFDSCreatePrompt             ((WFDStyle)0x00002000L)
  65. #define WFDSShareAware               ((WFDStyle)0x00004000L)
  66. #define WFDSNoReadOnlyReturn         ((WFDStyle)0x00008000L)
  67. #define WFDSNoTestFileCreate         ((WFDStyle)0x00010000L)
  68. #define WFDSNoNetworkButton          ((WFDStyle)0x00020000L)
  69. #define WFDSNoLongNames              ((WFDStyle)0x00040000L)
  70. #define WFDSExplorer                 ((WFDStyle)0x00080000L)
  71. #define WFDSNoDereferenceLinks       ((WFDStyle)0x00100000L)
  72.  
  73. // WFileDialog
  74. //
  75. //    Used to display open/save dialog.
  76.  
  77. class WCMCLASS WFileDialog : public WCommonDialog {
  78.     WDeclareSubclass( WFileDialog, WCommonDialog );
  79.  
  80.     public:
  81.         WFileDialog();
  82.  
  83.         ~WFileDialog();
  84.  
  85.         /*******************************************************
  86.          * Properties
  87.          *******************************************************/
  88.  
  89.         // BufferSize
  90.         //
  91.         //    Sets the buffer size to be used.
  92.  
  93.         WULong GetBufferSize() const;
  94.         WBool  SetBufferSize( WULong bufferSize );
  95.  
  96.         // ButtonLabel
  97.         //
  98.         //    Sets an alternative label for the Open/Save button.
  99.         //    An empty string means to use the system default.
  100.  
  101.         WString GetButtonLabel() const;
  102.         WBool   SetButtonLabel( const WChar *label );
  103.  
  104.         // FileCount
  105.         //
  106.         //    Number of files selected after dialog returns
  107.         //    or to initially display.  Always at least 1.
  108.  
  109.         WULong  GetFileCount() const;
  110.         WBool   SetFileCount( WULong count=1 );
  111.  
  112.         // FilePath
  113.         //
  114.         //    The path of the file that was selected.  Use this
  115.         //    to set the initial file path as well.  If multiple
  116.         //    files were selected, use the optional parm to GetFilePath
  117.         //    to return the files from 0..FileCount-1.
  118.  
  119.         WFilePath GetFilePath( WULong whichFile=0 ) const;
  120.         WBool     SetFilePath( const WFilePath & path, WULong whichFile=0 );
  121.  
  122.         // FilterList
  123.         //
  124.         //    Sets the list of filters that will be used.  Note
  125.         //    that the dialog does not make a private copy of
  126.         //    the list.  The list is just an array of WFileFilters,
  127.         //    the last one being NULL.
  128.  
  129.         const WFileFilter *GetFilterList() const;
  130.         WBool              SetFilterList( const WFileFilter *list );
  131.  
  132.         // InitialDirectory
  133.         //
  134.         //    Sets the initial directory used by the file dialog.
  135.         //    If empty string, uses the current directory.
  136.  
  137.         WString GetInitialDirectory() const;
  138.         WBool   SetInitialDirectory( const WString & initDir );
  139.  
  140.         // MultiSelect
  141.         //
  142.         //    Sets/gets the multiselect state.  Note that if you
  143.         //    call SetFilePath to set multiple file paths, or set
  144.         //    the file count to > 1, this mode is automatically turned on.
  145.  
  146.         WBool GetMultiSelect() const;
  147.         WBool SetMultiSelect( WBool on );
  148.  
  149.         // Style
  150.         //
  151.         //    Set the styles used by the file dialog.  Note that
  152.         //    the WFDSEnableHook style will ALWAYS be enabled.
  153.  
  154.         WFDStyle GetStyle() const;
  155.         WBool    SetStyle( WFDStyle style );
  156.  
  157.         /*******************************************************
  158.          * Methods
  159.          *******************************************************/
  160.  
  161.         // ChangeStyle
  162.         //
  163.         //    Use to turn a specific style on or off.
  164.  
  165.         WBool ChangeStyle( WFDStyle style, WBool on );
  166.  
  167.         // PromptForOpen
  168.         //
  169.         //    Display the "Open" dialog and wait for it to be dismissed.
  170.         //    The first form uses the current settings.  The second
  171.         //    is a convenience function.
  172.  
  173.         WBool PromptForOpen();
  174.  
  175.         WBool PromptForOpen( WWindow *owner, const WChar *initialPath,
  176.                              const WChar *title,
  177.                              const WFileFilter filterList[] );
  178.  
  179.         // PromptForSave
  180.         //
  181.         //    Display the "Save as" dialog and wait for it to be dismissed.
  182.  
  183.         WBool PromptForSave();
  184.  
  185.         WBool PromptForSave( WWindow *owner, const WChar *initialPath,
  186.                              const WChar *title, 
  187.                              const WFileFilter filterList[] );
  188.  
  189.         /********************************************************
  190.          * Static Properties
  191.          ********************************************************/
  192.  
  193.         // The default filter: "All Files (*.*)"
  194.         
  195.         static const WFileFilter * GetDefaultFilterList();
  196.  
  197.         /********************************************************
  198.          * Notifications
  199.          ********************************************************/
  200.  
  201.         void OnDialogInitialize( WWindowHandle hWnd, WWindowHandle focus );
  202.  
  203.     private:
  204.  
  205.         void  *PackOFN();
  206.         WBool  UnpackOFN( WBool ok );
  207.  
  208.     private:
  209.  
  210.         void              *_ofn;
  211.         const WFileFilter *_filterList;
  212.         WString            _buttonLabel;
  213.         WString            _initialDir;
  214.         WULong             _fileCount;
  215.         WFilePath        **_fileList;
  216.         WULong             _bufferSize;
  217. };
  218.  
  219. #ifndef _WNO_PRAGMA_PUSH
  220. #pragma enum pop;
  221. #pragma pack(pop);
  222. #endif
  223.  
  224. #endif // _WFILEDIALOG_HPP_INCLUDED
  225.