Add m_fsStyle next to m_windowStyle
Add HasFdFlag() Use it for all tests in all variants of wxFileDialogs. That way it will be easier to change again centrally, if required. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -88,6 +88,8 @@ public:
|
||||
const wxSize& sz = wxDefaultSize,
|
||||
const wxString& name = wxFileDialogNameStr);
|
||||
|
||||
bool HasFdFlag(int flag) const { return (m_fdStyle & flag) != 0; }
|
||||
|
||||
virtual void SetMessage(const wxString& message) { m_message = message; }
|
||||
virtual void SetPath(const wxString& path) { m_path = path; }
|
||||
virtual void SetDirectory(const wxString& dir) { m_dir = dir; }
|
||||
@@ -131,6 +133,7 @@ protected:
|
||||
wxString m_fileName;
|
||||
wxString m_wildCard;
|
||||
int m_filterIndex;
|
||||
int m_fdStyle;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
@@ -54,21 +54,21 @@ bool wxFileDialogBase::Create(wxWindow *parent,
|
||||
m_wildCard = wildCard;
|
||||
|
||||
m_parent = parent;
|
||||
m_windowStyle = style;
|
||||
m_fdStyle = style;
|
||||
m_filterIndex = 0;
|
||||
|
||||
if (!HasFlag(wxFD_OPEN) && !HasFlag(wxFD_SAVE))
|
||||
m_windowStyle |= wxFD_OPEN; // wxFD_OPEN is the default
|
||||
if (!HasFdFlag(wxFD_OPEN) && !HasFdFlag(wxFD_SAVE))
|
||||
m_fdStyle |= wxFD_OPEN; // wxFD_OPEN is the default
|
||||
|
||||
// check that the styles are not contradictory
|
||||
wxASSERT_MSG( !(HasFlag(wxFD_SAVE) && HasFlag(wxFD_OPEN)),
|
||||
wxASSERT_MSG( !(HasFdFlag(wxFD_SAVE) && HasFdFlag(wxFD_OPEN)),
|
||||
_T("can't specify both wxFD_SAVE and wxFD_OPEN at once") );
|
||||
|
||||
wxASSERT_MSG( !HasFlag(wxFD_SAVE) ||
|
||||
(!HasFlag(wxFD_MULTIPLE) && !HasFlag(wxFD_FILE_MUST_EXIST)),
|
||||
wxASSERT_MSG( !HasFdFlag(wxFD_SAVE) ||
|
||||
(!HasFdFlag(wxFD_MULTIPLE) && !HasFdFlag(wxFD_FILE_MUST_EXIST)),
|
||||
_T("wxFD_MULTIPLE or wxFD_FILE_MUST_EXIST can't be used with wxFD_SAVE" ) );
|
||||
|
||||
wxASSERT_MSG( !HasFlag(wxFD_OPEN) || !HasFlag(wxFD_OVERWRITE_PROMPT),
|
||||
wxASSERT_MSG( !HasFdFlag(wxFD_OPEN) || !HasFdFlag(wxFD_OVERWRITE_PROMPT),
|
||||
_T("wxFD_OVERWRITE_PROMPT can't be used with wxFD_OPEN") );
|
||||
|
||||
if ( wildCard.empty() || wildCard == wxFileSelectorDefaultWildcardStr )
|
||||
|
@@ -1102,7 +1102,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
|
||||
mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 );
|
||||
|
||||
long style2 = ms_lastViewStyle;
|
||||
if ( style & wxFD_MULTIPLE == 0 )
|
||||
if ( !HasFdFlag(wxFD_MULTIPLE) )
|
||||
style2 |= wxLC_SINGLE_SEL;
|
||||
|
||||
#ifdef __WXWINCE__
|
||||
@@ -1406,7 +1406,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
|
||||
}
|
||||
#endif // __UNIX__
|
||||
|
||||
if (!HasFlag(wxFD_SAVE))
|
||||
if (!HasFdFlag(wxFD_SAVE))
|
||||
{
|
||||
if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
|
||||
(filename.Find(wxT('?')) != wxNOT_FOUND))
|
||||
@@ -1451,13 +1451,13 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
|
||||
// VZ: the logic of testing for !wxFileExists() only for the open file
|
||||
// dialog is not entirely clear to me, why don't we allow saving to a
|
||||
// file without extension as well?
|
||||
if ( !HasFlag(wxFD_OPEN) || !wxFileExists(filename) )
|
||||
if ( !HasFdFlag(wxFD_OPEN) || !wxFileExists(filename) )
|
||||
{
|
||||
filename = AppendExtension(filename, m_filterExtension);
|
||||
}
|
||||
|
||||
// check that the file [doesn't] exist if necessary
|
||||
if ( HasFlag(wxFD_SAVE) && HasFlag(wxFD_OVERWRITE_PROMPT) &&
|
||||
if ( HasFdFlag(wxFD_SAVE) && HasFdFlag(wxFD_OVERWRITE_PROMPT) &&
|
||||
wxFileExists( filename ) )
|
||||
{
|
||||
wxString msg;
|
||||
@@ -1466,7 +1466,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
|
||||
if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
|
||||
return;
|
||||
}
|
||||
else if ( HasFlag(wxFD_OPEN) && HasFlag(wxFD_FILE_MUST_EXIST) &&
|
||||
else if ( HasFdFlag(wxFD_OPEN) && HasFdFlag(wxFD_FILE_MUST_EXIST) &&
|
||||
!wxFileExists(filename) )
|
||||
{
|
||||
wxMessageBox(_("Please choose an existing file."), _("Error"),
|
||||
@@ -1476,7 +1476,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
|
||||
SetPath( filename );
|
||||
|
||||
// change to the directory where the user went if asked
|
||||
if ( HasFlag(wxFD_CHANGE_DIR) )
|
||||
if ( HasFdFlag(wxFD_CHANGE_DIR) )
|
||||
{
|
||||
wxString cwd;
|
||||
wxSplitPath(filename, &cwd, NULL, NULL);
|
||||
|
@@ -404,7 +404,7 @@ void wxFileDialog::SetFilename(const wxString& name)
|
||||
{
|
||||
if (!gtk_check_version(2,4,0))
|
||||
{
|
||||
if (HasFlag(wxFD_SAVE))
|
||||
if (HasFdFlag(wxFD_SAVE))
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), wxGTK_CONV(name));
|
||||
else
|
||||
SetPath(wxFileName(GetDirectory(), name).GetFullPath());
|
||||
|
@@ -330,7 +330,7 @@ int wxFileDialog::ShowModal()
|
||||
}
|
||||
}
|
||||
|
||||
if (HasFlag(wxFD_SAVE))
|
||||
if (HasFdFlag(wxFD_SAVE))
|
||||
{
|
||||
myData.saveMode = true;
|
||||
|
||||
@@ -403,7 +403,7 @@ int wxFileDialog::ShowModal()
|
||||
if (err != noErr)
|
||||
break;
|
||||
|
||||
if (HasFlag(wxFD_SAVE))
|
||||
if (HasFdFlag(wxFD_SAVE))
|
||||
thePath = wxMacFSRefToPath( &theFSRef, navReply.saveFileName );
|
||||
else
|
||||
thePath = wxMacFSRefToPath( &theFSRef );
|
||||
|
@@ -278,13 +278,13 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
long msw_flags = 0;
|
||||
if ( (m_windowStyle & wxHIDE_READONLY) || (m_windowStyle & wxFD_SAVE) )
|
||||
if ( HasFdFlag(wxHIDE_READONLY) || HasFdFlag(wxFD_SAVE) )
|
||||
msw_flags |= OFN_HIDEREADONLY;
|
||||
#else
|
||||
long msw_flags = OFN_HIDEREADONLY;
|
||||
#endif
|
||||
|
||||
if ( m_windowStyle & wxFD_FILE_MUST_EXIST )
|
||||
if ( HasFdFlag(wxFD_FILE_MUST_EXIST) )
|
||||
msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
/*
|
||||
If the window has been moved the programmer is probably
|
||||
@@ -302,7 +302,7 @@ int wxFileDialog::ShowModal()
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_windowStyle & wxFD_MULTIPLE )
|
||||
if ( HasFdFlag(wxFD_MULTIPLE) )
|
||||
{
|
||||
// OFN_EXPLORER must always be specified with OFN_ALLOWMULTISELECT
|
||||
msw_flags |= OFN_EXPLORER | OFN_ALLOWMULTISELECT;
|
||||
@@ -311,12 +311,12 @@ int wxFileDialog::ShowModal()
|
||||
// if wxFD_CHANGE_DIR flag is not given we shouldn't change the CWD which the
|
||||
// standard dialog does by default (notice that under NT it does it anyhow,
|
||||
// OFN_NOCHANGEDIR or not, see below)
|
||||
if ( !(m_windowStyle & wxFD_CHANGE_DIR) )
|
||||
if ( !HasFdFlag(wxFD_CHANGE_DIR) )
|
||||
{
|
||||
msw_flags |= OFN_NOCHANGEDIR;
|
||||
}
|
||||
|
||||
if ( m_windowStyle & wxFD_OVERWRITE_PROMPT )
|
||||
if ( HasFdFlag(wxFD_OVERWRITE_PROMPT) )
|
||||
{
|
||||
msw_flags |= OFN_OVERWRITEPROMPT;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ int wxFileDialog::ShowModal()
|
||||
// user types "foo" and the default extension is ".bar" we should force it
|
||||
// to check for "foo.bar" existence and not "foo")
|
||||
wxString defextBuffer; // we need it to be alive until GetSaveFileName()!
|
||||
if (m_windowStyle & wxFD_SAVE)
|
||||
if (HasFdFlag(wxFD_SAVE))
|
||||
{
|
||||
const wxChar* extension = filterBuffer;
|
||||
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
|
||||
@@ -470,7 +470,7 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
m_fileNames.Empty();
|
||||
|
||||
if ( ( m_windowStyle & wxFD_MULTIPLE ) &&
|
||||
if ( ( HasFdFlag(wxFD_MULTIPLE) ) &&
|
||||
#if defined(OFN_EXPLORER)
|
||||
( fileNameBuffer[of.nFileOffset-1] == wxT('\0') )
|
||||
#else
|
||||
|
Reference in New Issue
Block a user