home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWOSMisc / Include / FWFileOp.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  8.9 KB  |  303 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:        FWFileOp.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWFILEOP_H
  11. #define FWFILEOP_H
  12.  
  13.  
  14. // ----- OS Includes -----
  15.  
  16. #ifndef FWFILESP_H
  17. #include "FWFileSp.h"
  18. #endif
  19.  
  20. // ----- Foundation Includes -----
  21.  
  22. #ifndef FWEXCDEF_H
  23. #include "FWExcDef.h"
  24. #endif
  25.  
  26. #ifndef FWSTRS_H
  27. #include "FWStrs.h"  
  28. #endif
  29.  
  30. //----- Macintosh includes -----
  31.  
  32. #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
  33. #include <Types.h>
  34. #endif
  35.  
  36. #if defined(FW_BUILD_MAC) && !defined(__FILES__)
  37. #include <Files.h>
  38. #endif
  39.  
  40. #if defined(FW_BUILD_MAC) && !defined(__STANDARDFILE__)
  41. #include <StandardFile.h>
  42. #endif
  43.  
  44. #if FW_LIB_EXPORT_PRAGMAS
  45. #pragma lib_export on
  46. #endif
  47.  
  48. //========================================================================================
  49.  
  50. class FW_CLASS_ATTR FW_CWindow;
  51.  
  52. //========================================================================================
  53. //    CLASS FW_COpenFileParameters - parameters for StandardGetFile (Mac) and GetOpenFileName (Windows)
  54. //========================================================================================
  55.  
  56. class FW_CLASS_ATTR FW_COpenFileParameters FW_AUTO_DESTRUCT_OBJECT
  57. {
  58.     public:
  59.         FW_COpenFileParameters();
  60.         virtual ~ FW_COpenFileParameters();
  61.         
  62. #ifdef FW_BUILD_MAC
  63.         FW_COpenFileParameters(OSType* fileType, 
  64.                                FileFilterProcPtr fileFilterProc);
  65.             // Use when there's only one file type
  66.         
  67.         FW_COpenFileParameters(short numTypes, 
  68.                                OSType* fileType, 
  69.                                FileFilterProcPtr fileFilterProc);
  70.             // Use for 2-4 file types
  71.         
  72.         void                Set(short numTypes, 
  73.                                 OSType *fileType, 
  74.                                 FileFilterProcPtr fileFilterProc);
  75.  
  76.         short                MacCountTypes() const;
  77.         FileFilterProcPtr    MacGetFilterProc() const;
  78.         OSType*                GetTypes() const;
  79.  
  80.     private:
  81.         short                fNumTypes;
  82.         OSType                fTypes[4];
  83.         FileFilterProcPtr    fFileFilterProc;
  84. #endif
  85.  
  86. #ifdef FW_BUILD_WIN
  87.         FW_COpenFileParameters(const FW_CString& filterString,
  88.                                const FW_CString& defaultExt,
  89.                                HWND ownerWindow = NULL);
  90.     
  91.         void        Set(const FW_CString& filterString,
  92.                         const FW_CString& defaultExt);
  93.  
  94.         char*        WinGetFilterString() const;
  95.         char*        WinGetDefaultExt() const;
  96.         HWND        WinGetOwnerWindow() const;
  97.                 
  98.     private:
  99.         HWND                fOwnerWindow;        // [KVV] Windows-specific data type!  Temporary!
  100.         char*                fFilterString;
  101.         char                fDefaultExt[4];
  102. #endif
  103.  
  104. };
  105.  
  106. //========================================================================================
  107. //    CLASS FW_CSaveFileParameters - parameters for StandardPutFile (Mac) and GetSaveFileName (Windows)
  108. //========================================================================================
  109.  
  110. class FW_CLASS_ATTR FW_CSaveFileParameters FW_AUTO_DESTRUCT_OBJECT
  111. {
  112.     public:
  113.         FW_CSaveFileParameters();
  114.         ~ FW_CSaveFileParameters();
  115.         
  116. #ifdef FW_BUILD_MAC
  117.     public:
  118.         FW_CSaveFileParameters(const FW_CString& savePrompt,
  119.                                const FW_CString& defaultName);
  120.  
  121.         void MacGetSavePrompt(FW_CString& savePrompt) const;
  122.         void MacGetDefaultName(FW_CString& defaultName) const;
  123.  
  124.     private:
  125.         FW_CDynamicString    fSavePrompt;
  126.         FW_CDynamicString    fDefaultName;
  127.  
  128. #endif
  129.  
  130. #ifdef FW_BUILD_WIN
  131.     public:
  132.         FW_CSaveFileParameters(const FW_CString& filterString,
  133.                                const FW_CString& defaultExt,
  134.                                const FW_CString& defaultName,
  135.                                HWND ownerWindow = NULL);
  136.     
  137.         char* WinGetFilterString() const;
  138.         char* WinGetDefaultExt() const;
  139.         char* WinGetDefaultName() const;
  140.         HWND WinGetOwnerWindow() const;
  141.                 
  142.     private:
  143.         void Set(const FW_CString& filterString,
  144.                  const FW_CString& defaultExt,
  145.                  const FW_CString& defaultName);
  146.  
  147.         HWND                fOwnerWindow;
  148.         char*                fFilterString;
  149.         char                fDefaultExt[4];
  150.         char*                fDefaultName;
  151. #endif
  152.  
  153. };
  154.  
  155. //========================================================================================
  156. //    CLASS FW_CChooseFile - choose a file to open or save
  157. //========================================================================================
  158.  
  159. class FW_CLASS_ATTR FW_CChooseFile
  160. {
  161.   public:
  162.     static FW_CFileSpecification* ChooseFileToOpen(const FW_COpenFileParameters& openFileParam);
  163.     
  164.     static FW_CFileSpecification* ChooseFileToSave(const FW_CSaveFileParameters& saveFileParam);
  165.     
  166.   private:
  167.     FW_CChooseFile();
  168. };
  169.  
  170. //========================================================================================
  171. //    CLASS FW_COpenFileParameters inlines
  172. //========================================================================================
  173.  
  174. #ifdef FW_BUILD_MAC
  175. //----------------------------------------------------------------------------------------
  176. //    FW_COpenFileParameters::MacCountTypes
  177. //----------------------------------------------------------------------------------------
  178. inline short FW_COpenFileParameters::MacCountTypes() const
  179. {
  180.     return fNumTypes;
  181. }
  182. #endif
  183.  
  184. #ifdef FW_BUILD_MAC
  185. //----------------------------------------------------------------------------------------
  186. //    FW_COpenFileParameters::MacGetFilterProc
  187. //----------------------------------------------------------------------------------------
  188. inline FileFilterProcPtr FW_COpenFileParameters::MacGetFilterProc() const
  189. {
  190.     return fFileFilterProc;
  191. }
  192. #endif
  193.  
  194. #ifdef FW_BUILD_MAC
  195. //----------------------------------------------------------------------------------------
  196. //    FW_COpenFileParameters::GetTypes
  197. //----------------------------------------------------------------------------------------
  198. inline OSType* FW_COpenFileParameters::GetTypes() const
  199. {
  200.     return fNumTypes == -1 ? NULL : (OSType*)fTypes;
  201. }
  202. #endif
  203.  
  204. #ifdef FW_BUILD_WIN
  205. //----------------------------------------------------------------------------------------
  206. //    FW_COpenFileParameters::WinGetFilterString
  207. //----------------------------------------------------------------------------------------
  208. inline char* FW_COpenFileParameters::WinGetFilterString() const
  209. {
  210.     return fFilterString;
  211. }
  212. #endif
  213.  
  214. #ifdef FW_BUILD_WIN
  215. //----------------------------------------------------------------------------------------
  216. //    FW_COpenFileParameters::WinGetDefaultExt
  217. //----------------------------------------------------------------------------------------
  218. inline char* FW_COpenFileParameters::WinGetDefaultExt() const
  219. {
  220.     return (char*)fDefaultExt;
  221. }
  222. #endif
  223.  
  224. #ifdef FW_BUILD_WIN
  225. //----------------------------------------------------------------------------------------
  226. //    FW_COpenFileParameters::WinGetOwnerWindow
  227. //----------------------------------------------------------------------------------------
  228. inline HWND FW_COpenFileParameters::WinGetOwnerWindow() const
  229. {
  230.     return fOwnerWindow;
  231. }
  232. #endif
  233.  
  234. //========================================================================================
  235. //    CLASS FW_CSaveFileParameters inlines
  236. //========================================================================================
  237.  
  238. #ifdef FW_BUILD_MAC
  239. //----------------------------------------------------------------------------------------
  240. //    FW_CSaveFileParameters::MacGetSavePrompt
  241. //----------------------------------------------------------------------------------------
  242. inline void    FW_CSaveFileParameters::MacGetSavePrompt(FW_CString& savePrompt) const
  243. {
  244.     savePrompt = fSavePrompt;
  245. }
  246. #endif
  247.  
  248. #ifdef FW_BUILD_MAC
  249. //----------------------------------------------------------------------------------------
  250. //    FW_CSaveFileParameters::MacGetDefaultName
  251. //----------------------------------------------------------------------------------------
  252. inline void    FW_CSaveFileParameters::MacGetDefaultName(FW_CString& defaultName) const
  253. {
  254.     defaultName = fDefaultName;
  255. }
  256. #endif
  257.  
  258. #ifdef FW_BUILD_WIN
  259. //----------------------------------------------------------------------------------------
  260. //    FW_CSaveFileParameters::WinGetFilterString
  261. //----------------------------------------------------------------------------------------
  262. inline char* FW_CSaveFileParameters::WinGetFilterString() const
  263. {
  264.     return fFilterString;
  265. }
  266. #endif
  267.  
  268. #ifdef FW_BUILD_WIN
  269. //----------------------------------------------------------------------------------------
  270. //    FW_CSaveFileParameters::WinGetDefaultExt
  271. //----------------------------------------------------------------------------------------
  272. inline char* FW_CSaveFileParameters::WinGetDefaultExt() const
  273. {
  274.     return (char*)fDefaultExt;
  275. }
  276. #endif
  277.  
  278. #ifdef FW_BUILD_WIN
  279. //----------------------------------------------------------------------------------------
  280. //    FW_CSaveFileParameters::WinGetDefaultName
  281. //----------------------------------------------------------------------------------------
  282. inline char* FW_CSaveFileParameters::WinGetDefaultName() const
  283. {
  284.     return fDefaultName;
  285. }
  286. #endif
  287.  
  288. #ifdef FW_BUILD_WIN
  289. //----------------------------------------------------------------------------------------
  290. //    FW_CSaveFileParameters::WinGetOwnerWindow
  291. //----------------------------------------------------------------------------------------
  292. inline HWND FW_CSaveFileParameters::WinGetOwnerWindow() const
  293. {
  294.     return fOwnerWindow;
  295. }
  296. #endif
  297.  
  298. #if FW_LIB_EXPORT_PRAGMAS
  299. #pragma lib_export off
  300. #endif
  301.  
  302. #endif
  303.