wxFileDialog cleanup, extracted common code to fldlgcmn.cpp (patch 754187)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21149 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-06-14 13:31:49 +00:00
parent 30e671a59f
commit b600ed1362
19 changed files with 458 additions and 1326 deletions

View File

@@ -1,8 +1,27 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filedlg.h
// Purpose: wxFileDialog base header
// Author: Robert Roebling
// Modified by:
// Created: 8/17/99
// Copyright: (c) Robert Roebling
// RCS-ID:
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDLG_H_BASE_
#define _WX_FILEDLG_H_BASE_
#if wxUSE_FILEDLG
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "filedlg.h"
#endif
//----------------------------------------------------------------------------
// wxFileDialog data and generic functions
//----------------------------------------------------------------------------
enum
{
wxOPEN = 0x0001,
@@ -14,6 +33,59 @@ enum
wxCHANGE_DIR = 0x0040
};
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
// Parses the filterStr, returning the number of filters.
// Returns 0 if none or if there's a problem, they arrays will contain an equal
// number of items found before the error.
// filterStr is in the form:
// "All files (*.*)|*.*|Image Files (*.jpeg *.png)|*.jpg;*.png"
extern int wxParseFileFilter(const wxString& filterStr,
wxArrayString& descriptions,
wxArrayString& filters);
//----------------------------------------------------------------------------
// wxFileDialog convenience functions
//----------------------------------------------------------------------------
// File selector - backward compatibility
WXDLLEXPORT wxString
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
const wxChar *default_extension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString
wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
int *indexDefaultExtension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// Ask for filename to load
WXDLLEXPORT wxString
wxLoadFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *)NULL,
wxWindow *parent = (wxWindow *) NULL);
// Ask for filename to save
WXDLLEXPORT wxString
wxSaveFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#if defined (__WXUNIVERSAL__)
#include "wx/generic/filedlgg.h"
#elif defined(__WXMSW__)
@@ -36,5 +108,4 @@ enum
#endif // wxUSE_FILEDLG
#endif
// _WX_FILEDLG_H_BASE_
#endif // _WX_FILEDLG_H_BASE_

View File

@@ -39,19 +39,8 @@ class WXDLLEXPORT wxTextCtrl;
#define USE_GENERIC_FILEDIALOG
#endif
#ifdef USE_GENERIC_FILEDIALOG
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorPromptStr;
WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorDefaultWildcardStr;
#endif // USE_GENERIC_FILEDIALOG
//-------------------------------------------------------------------------
// File selector
// wxGenericFileDialog
//-------------------------------------------------------------------------
class WXDLLEXPORT wxGenericFileDialog: public wxDialog
@@ -160,46 +149,10 @@ public:
}
};
// File selector - backward compatibility
WXDLLEXPORT wxString
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
const wxChar *default_extension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString
wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
int *indexDefaultExtension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// Ask for filename to load
WXDLLEXPORT wxString
wxLoadFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *)NULL,
wxWindow *parent = (wxWindow *) NULL);
// Ask for filename to save
WXDLLEXPORT wxString
wxSaveFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif // USE_GENERIC_FILEDIALOG
//-----------------------------------------------------------------------------
// wxFileData
// wxFileData - a class to hold the file info for the wxFileCtrl
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxFileData
@@ -214,29 +167,43 @@ public:
is_drive = 0x0008
};
// Full copy constructor
wxFileData( const wxFileData& fileData );
// Create a filedata from this information
wxFileData( const wxString &filePath, const wxString &fileName,
fileType type, int image_id );
// (re)read the extra data about the file from the system
void ReadData();
// get the name of the file, dir, drive
wxString GetFileName() const { return m_fileName; }
// get the full path + name of the file, dir, path
wxString GetFilePath() const { return m_filePath; }
// Set the path + name and name of the item
void SetNewName( const wxString &filePath, const wxString &fileName );
// Get the size of the file in bytes
long GetSize() const { return m_size; }
// Get the type of file, either file extension or <DIR>, <LINK>, <DRIVE>
wxString GetType() const;
wxString GetFileType() const;
// get the last modification time
wxDateTime GetTime() const { return m_dateTime; }
wxDateTime GetDateTime() const { return m_dateTime; }
// Get the time as a formatted string
wxString GetModificationTime() const;
// in UNIX get rwx for file, in MSW get attributes ARHS
wxString GetPermissions() const { return m_permissions; }
// Get the id of the image used in a wxImageList
int GetImageId() const { return m_image; }
bool IsFile() const { return !IsDir() && !IsLink() && !IsDrive(); }
bool IsDir() const { return (m_type & is_dir ) != 0; }
bool IsLink() const { return (m_type & is_link ) != 0; }
bool IsExe() const { return (m_type & is_exe ) != 0; }
bool IsDrive() const { return (m_type & is_drive) != 0; }
int GetFileType() const { return m_type; }
// Get/Set the type of file, file/dir/drive/link
int GetType() const { return m_type; }
// the wxFileCtrl fields in report view
enum fileListFieldType
@@ -251,12 +218,13 @@ public:
FileList_Max
};
// Get the entry for report view of wxFileCtrl
wxString GetEntry( fileListFieldType num ) const;
// Get a string representation of the file info
wxString GetHint() const;
// initialize a wxListItem attributes
void MakeItem( wxListItem &item );
void SetNewName( const wxString &filePath, const wxString &fileName );
private:
wxString m_fileName;
@@ -294,6 +262,7 @@ public:
bool GetShowHidden() const { return m_showHidden; }
virtual long Add( wxFileData *fd, wxListItem &item );
virtual void UpdateItem(const wxListItem &item);
virtual void UpdateFiles();
virtual void MakeDir();
virtual void GoToParentDir();
@@ -327,7 +296,5 @@ private:
DECLARE_EVENT_TABLE()
};
#endif
// _WX_FILEDLGG_H_
#endif // _WX_FILEDLGG_H_

View File

@@ -21,9 +21,6 @@
// File selector
//-------------------------------------------------------------------------
extern const wxChar *wxFileSelectorPromptStr;
extern const wxChar *wxFileSelectorDefaultWildcardStr;
class wxFileDialog: public wxDialog
{
public:
@@ -67,47 +64,4 @@ private:
DECLARE_DYNAMIC_CLASS(wxFileDialog)
};
#define wxOPEN 1
#define wxSAVE 2
#define wxOVERWRITE_PROMPT 4
#define wxHIDE_READONLY 8
#define wxFILE_MUST_EXIST 16
// File selector - backward compatibility
WXDLLEXPORT wxString
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
const wxChar *default_extension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString
wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
int *indexDefaultExtension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// Ask for filename to load
WXDLLEXPORT wxString
wxLoadFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *)NULL,
wxWindow *parent = (wxWindow *) NULL);
// Ask for filename to save
WXDLLEXPORT wxString
wxSaveFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif
// __GTKFILEDLGH__
#endif // __GTKFILEDLGH__

View File

@@ -21,9 +21,6 @@
// File selector
//-------------------------------------------------------------------------
extern const wxChar *wxFileSelectorPromptStr;
extern const wxChar *wxFileSelectorDefaultWildcardStr;
class wxFileDialog: public wxDialog
{
public:
@@ -67,47 +64,4 @@ private:
DECLARE_DYNAMIC_CLASS(wxFileDialog)
};
#define wxOPEN 1
#define wxSAVE 2
#define wxOVERWRITE_PROMPT 4
#define wxHIDE_READONLY 8
#define wxFILE_MUST_EXIST 16
// File selector - backward compatibility
WXDLLEXPORT wxString
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
const wxChar *default_extension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString
wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
int *indexDefaultExtension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// Ask for filename to load
WXDLLEXPORT wxString
wxLoadFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *)NULL,
wxWindow *parent = (wxWindow *) NULL);
// Ask for filename to save
WXDLLEXPORT wxString
wxSaveFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif
// __GTKFILEDLGH__
#endif // __GTKFILEDLGH__

View File

@@ -22,9 +22,6 @@
* File selector
*/
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
class WXDLLEXPORT wxFileDialog: public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxFileDialog)
@@ -71,29 +68,4 @@ public:
};
#define wxOPEN 0x0001
#define wxSAVE 0x0002
#define wxOVERWRITE_PROMPT 0x0004
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility
WXDLLEXPORT wxString wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, const wxChar *default_path = NULL,
const wxChar *default_filename = NULL, const wxChar *default_extension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, const wxChar *default_path = NULL,
const wxChar *default_filename = NULL, int *indexDefaultExtension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// Generic file load dialog
WXDLLEXPORT wxString wxLoadFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name = NULL, wxWindow *parent = NULL);
// Generic file save dialog
WXDLLEXPORT wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name = NULL, wxWindow *parent = NULL);
#endif
// _WX_FILEDLG_H_
#endif // _WX_FILEDLG_H_

View File

@@ -22,9 +22,6 @@
* File selector
*/
WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr;
WXDLLEXPORT_DATA(extern const char*) wxFileSelectorDefaultWildcardStr;
class WXDLLEXPORT wxFileDialog: public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxFileDialog)
@@ -70,29 +67,4 @@ public:
int ShowModal();
};
#define wxOPEN 0x0001
#define wxSAVE 0x0002
#define wxOVERWRITE_PROMPT 0x0004
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility
WXDLLEXPORT wxString wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, const char *default_extension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, int *indexDefaultExtension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// Generic file load dialog
WXDLLEXPORT wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
// Generic file save dialog
WXDLLEXPORT wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
#endif
// _WX_FILEDLG_H_
#endif // _WX_FILEDLG_H_

View File

@@ -22,9 +22,6 @@
* File selector
*/
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
class WXDLLEXPORT wxFileDialog: public wxDialog
{
public:
@@ -72,42 +69,5 @@ private:
DECLARE_NO_COPY_CLASS(wxFileDialog)
};
// File selector - backward compatibility
WXDLLEXPORT wxString
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
const wxChar *default_extension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString
wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
const wxChar *default_path = NULL,
const wxChar *default_filename = NULL,
int *indexDefaultExtension = NULL,
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// Ask for filename to load
WXDLLEXPORT wxString
wxLoadFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *)NULL,
wxWindow *parent = (wxWindow *) NULL);
// Ask for filename to save
WXDLLEXPORT wxString
wxSaveFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = (const wxChar *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif
// _WX_FILEDLG_H_
#endif // _WX_FILEDLG_H_

View File

@@ -64,58 +64,4 @@ protected:
wxPoint m_vPos;
}; // end of CLASS wxFileDialog
#define wxOPEN 0x0001
#define wxSAVE 0x0002
#define wxOVERWRITE_PROMPT 0x0004
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
//
// File selector - backward compatibility
//
WXDLLEXPORT wxString wxFileSelector( const char* pzMessage = wxFileSelectorPromptStr
,const char* pzDefaultPath = NULL
,const char* pzDefaultFilename = NULL
,const char* pzDefaultExtension = NULL
,const char* pzWildcard = wxFileSelectorDefaultWildcardStr
,int nFlags = 0
,wxWindow* pParent = NULL
,int nX = -1
,int nY = -1
);
//
// An extended version of wxFileSelector
WXDLLEXPORT wxString wxFileSelectorEx( const char* pzMessage = wxFileSelectorPromptStr
,const char* pzDefaultPath = NULL
,const char* pzDefaultFilename = NULL
,int* pnIndexDefaultExtension = NULL
,const char* pzWildcard = wxFileSelectorDefaultWildcardStr
,int nFlags = 0
,wxWindow* pParent = NULL
,int nX = -1
,int nY = -1
);
//
// Generic file load dialog
//
WXDLLEXPORT wxString wxLoadFileSelector( const char* pzWhat
,const char* pzExtension
,const char* pzDefaultName = NULL
,wxWindow* pParent = NULL
);
//
// Generic file save dialog
//
WXDLLEXPORT wxString wxSaveFileSelector( const char* pzWhat
,const char* pzExtension
,const char* pzDefaultName = NULL
,wxWindow* pParent = NULL
);
#endif
// _WX_FILEDLG_H_
#endif // _WX_FILEDLG_H_