Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members

FXFileDialogEx.h

Go to the documentation of this file.
00001 /***********************************-*- mode: c++; tab-width: 2 -*-*\
00002  *
00003  * NAME:     
00004  *   FXFileDialogEx - File dialog using native dialog
00005  *
00006  * AUTHOR:
00007  *   Daniel Gehriger (gehriger@linkcad.com)
00008  *
00009  * Copyright (c) 1999 by Daniel Gehriger.  All Rights Reserved.
00010  *
00011  * PUPROSE:
00012  *   File dialog using native Common Controls dialog
00013  *
00014  * NOTE
00015  * This library is free software; you can redistribute it and/or 
00016  * modify it under the terms of the GNU Library General Public   
00017  * License as published by the Free Software Foundation; either  
00018  * version 2 of the License, or (at your option) any later version.
00019  *                                                                 
00020  * This library is distributed in the hope that it will be useful, 
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of  
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023  * Library General Public License for more details.                 
00024  *                                                                  
00025  * You should have received a copy of the GNU Library General Public
00026  * License along with this library; if not, write to the Free       
00027  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00028  * 
00029  * $Id: FXFileDialogEx.h,v 1.6 1999/12/15 09:39:41 dgehrige Exp $
00030  *
00031  * HISTORY:
00032  *        dgehrige - Dec, 10 1999: Created.
00033  *
00034 \*******************************************************************/
00035 #ifndef FXFILEDIALOGEX_H
00036 #define FXFILEDIALOGEX_H
00037 
00038 // use commctl32 dialog on Win32, or normal FXFileDialog for other platforms
00039 #if !defined(WIN32) && !defined (WIN32_COMDLG)
00040 #include <fox/fx.h>
00041 #define FXFileDialogEx FXFileDialog
00042 #else
00043 #include <fox/FXObject.h>
00044 using namespace FX;
00045 #include <commdlg.h>
00046 namespace FXEX {
00047 
00048 /// File dialog options
00049 #define DLGEX_SAVE              0x00100000  // "Save" dialog box
00050 #define DLGEX_CREATEPROMPT      0x00400000  // -> OFN_CREATEPROMPT
00051 #define DLGEX_READONLY          0x00800000  // -> OFN_READONLY
00052 #define DLGEX_PATHMUSTEXIST     0x01000000  // -> OFN_PATHMUSTEXIST
00053 #define DLGEX_FILEMUSTEXIST     0x02000000  // -> OFN_FILEMUSTEXIST
00054 #define DLGEX_HIDEREADONLY      0x04000000  // -> OFN_HIDEREADONLY
00055 #define DLGEX_OVERWRITEPROMPT   0x08000000  // -> OFN_OVERWRITEPROMPT
00056 
00057 /**
00058  * Use comctl32 dialog under WIN32 for file dialog cases
00059  */
00060 class FXAPI FXFileDialogEx : public FXObject {
00061   FXDECLARE(FXFileDialogEx)
00062 
00063 public:
00064   OPENFILENAME   m_ofn;   // low-level access to OPENFILENAME
00065   FXuint         m_opts;
00066   FXchar       **m_pszFoxPats;
00067   FXchar        *m_pszFoxCustomPat;
00068   FXint          m_nFoxPats;
00069 
00070 private:
00071   FXFileDialogEx(const FXFileDialogEx&);
00072   FXFileDialogEx& operator=(const FXFileDialogEx&);
00073 
00074   // get FOX patterns into Win32 patterns
00075   void getWinPattern(FXchar*& pszWinPat, const FXchar* pszFoxPat) const;
00076 
00077 protected:
00078   FXFileDialogEx();
00079 
00080 public:
00081   // ctor
00082   FXFileDialogEx(FXWindow* owner,const FXString& title,FXuint opts=0,FXint x=0,FXint y=0,FXint w=500,FXint h=300);
00083 
00084   /// Run modal invocation of the dialog
00085   FXuint execute();
00086 
00087   /// set the initial file name/path
00088   void setFilename(const FXString& path);
00089 
00090   /// set the initial directory
00091   void setDirectory(const FXString& path);
00092 
00093   /// set the inital pattern
00094   void setPattern(const FXString& ptrn);
00095 
00096   /// set the pattern list
00097   void setPatternList(const FXchar* ptrns[]);
00098 
00099   /// select the inital pattern from the list  (zero based)
00100   void setCurrentPattern(FXint n);
00101 
00102   /// modify pattern list
00103   void setPatternText(FXint patno,const FXString& text);
00104 
00105   /// get the selected file path
00106   FXString getFilename() const;
00107 
00108   /// get the selected file extension 
00109   FXString getPattern() const;
00110   
00111   /// get the selected directory
00112   FXString getDirectory() const;
00113 
00114   /// get index of selected pattern in the list (zero based)
00115   FXint getCurrentPattern() const;
00116 
00117   /// get a pattern by index
00118   FXString getPatternText(FXint patno) const;
00119 
00120   /// set the title of the dialog
00121   void setTitle(const FXString& name);
00122 
00123   /// get the title of the dialog
00124   FXString getTitle() const;
00125 
00126   // dtor
00127   virtual ~FXFileDialogEx();
00128   };
00129 
00130 } // namespace FXEX
00131 #endif /* use commctl32 dialog */
00132 #endif /* FXFILEDIALOGEX_H */