wxFD_* constants without 2.6 compatibility (heavily extended and modified patch #1497305).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39469 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba 2006-05-30 07:25:35 +00:00
parent 4c9a69c19a
commit e031f1df56
10 changed files with 76 additions and 77 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filedlg.h
// Name: wx/filedlg.h
// Purpose: wxFileDialog base header
// Author: Robert Roebling
// Modified by:
@ -23,21 +23,6 @@
// wxFileDialog data
//----------------------------------------------------------------------------
#if WXWIN_COMPATIBILITY_2_6
enum
{
wxOPEN = 0x0001,
wxSAVE = 0x0002,
wxOVERWRITE_PROMPT = 0x0004,
#if WXWIN_COMPATIBILITY_2_4
wxHIDE_READONLY = 0x0008,
#endif
wxFILE_MUST_EXIST = 0x0010,
wxMULTIPLE = 0x0020,
wxCHANGE_DIR = 0x0040
};
#endif
enum
{
wxFD_OPEN = 0x0001,
@ -48,6 +33,21 @@ enum
wxFD_CHANGE_DIR = 0x0040
};
#if WXWIN_COMPATIBILITY_2_6
enum
{
wxOPEN = wxFD_OPEN,
wxSAVE = wxFD_SAVE,
wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT,
#if WXWIN_COMPATIBILITY_2_4
wxHIDE_READONLY = 0x0008,
#endif
wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST,
wxMULTIPLE = wxFD_MULTIPLE,
wxCHANGE_DIR = wxFD_CHANGE_DIR
};
#endif
#define wxFD_DEFAULT_STYLE wxFD_OPEN
extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[];

View File

@ -369,7 +369,7 @@ bool MyApp::OnInit()
wxMenu *sheet_menu = new wxMenu;
sheet_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Standard property sheet\tShift-Ctrl-P"));
sheet_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("&Toolbook sheet\tShift-Ctrl-T"));
if (wxPlatformIs(wxMac))
sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
/*
@ -840,7 +840,7 @@ void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) )
wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"),
wxEmptyString, wxEmptyString, wildcards,
wxMULTIPLE);
wxFD_MULTIPLE);
if (dialog.ShowModal() == wxID_OK)
{
@ -876,7 +876,7 @@ void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) )
wxEmptyString,
_T("myletter.doc"),
_T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
wxSAVE|wxOVERWRITE_PROMPT);
wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
dialog.SetFilterIndex(1);
@ -1423,7 +1423,7 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
int tabImage1 = -1;
int tabImage2 = -1;
bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
int resizeBorder = wxRESIZE_BORDER;
@ -1432,13 +1432,13 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
resizeBorder = 0;
tabImage1 = 0;
tabImage2 = 1;
int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK)
sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
else
sheetStyle |= wxPROPSHEET_TOOLBOOK;
SetSheetStyle(sheetStyle);
SetSheetInnerBorder(0);
SetSheetOuterBorder(0);

View File

@ -28,6 +28,7 @@
#include "wx/dirdlg.h"
#include "wx/app.h"
#endif
#include "wx/filename.h"
#include "wx/cocoa/autorelease.h"
@ -52,8 +53,8 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
const wxSize& size, const wxString& name)
{
wxTopLevelWindows.Append(this);
m_message = message;
m_message = message;
m_dialogStyle = style;
m_parent = parent;
m_path = defaultPath;
@ -68,7 +69,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
//If the user requests to save - use a NSSavePanel
//else use a NSOpenPanel
if (m_dialogStyle & wxSAVE)
if (m_dialogStyle & wxFD_SAVE)
{
SetNSPanel([NSSavePanel savePanel]);
@ -78,7 +79,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
[GetNSSavePanel() setTreatsFilePackagesAsDirectories:YES];
[GetNSSavePanel() setCanSelectHiddenExtension:YES];
}
else //m_dialogStyle & wxOPEN
else //m_dialogStyle & wxFD_OPEN
{
SetNSPanel([NSOpenPanel openPanel]);
[m_cocoaNSWindow setTitle:wxNSStringWithWxString(message)];
@ -89,10 +90,10 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
[GetNSSavePanel() setPrompt:@"Open"];
}
if (m_dialogStyle & wxDD_NEW_DIR_BUTTON) //m_dialogStyle & wxDD_NEW_DIR_BUTTON
{
if (m_dialogStyle & wxDD_NEW_DIR_BUTTON) //m_dialogStyle & wxDD_NEW_DIR_BUTTON
{
[(NSOpenPanel*)m_cocoaNSWindow setCanCreateDirectories:YES];
}
}
}
wxDirDialog::~wxDirDialog()
@ -107,7 +108,7 @@ int wxDirDialog::ShowModal()
int nResult;
if (m_dialogStyle & wxSAVE)
if (m_dialogStyle & wxFD_SAVE)
{
nResult = [GetNSSavePanel()
runModalForDirectory:wxNSStringWithWxString(m_dir)
@ -119,7 +120,7 @@ int wxDirDialog::ShowModal()
m_path = m_fileNames[0];
}
}
else //m_dialogStyle & wxOPEN
else //m_dialogStyle & wxFD_OPEN
{
nResult = [(NSOpenPanel*)m_cocoaNSWindow
runModalForDirectory:wxNSStringWithWxString(m_dir)
@ -141,4 +142,3 @@ int wxDirDialog::ShowModal()
}
#endif // wxUSE_DIRDLG

View File

@ -27,6 +27,7 @@
#include "wx/filedlg.h"
#include "wx/app.h"
#endif
#include "wx/filename.h"
#include "wx/cocoa/autorelease.h"
@ -67,7 +68,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
//If the user requests to save - use a NSSavePanel
//else use a NSOpenPanel
if (m_dialogStyle & wxSAVE)
if (m_dialogStyle & wxFD_SAVE)
{
SetNSPanel([NSSavePanel savePanel]);
@ -86,12 +87,12 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
// dialogs are all that useful, anyway :)
//
}
else //m_dialogStyle & wxOPEN
else //m_dialogStyle & wxFD_OPEN
{
SetNSPanel([NSOpenPanel openPanel]);
[m_cocoaNSWindow setTitle:wxNSStringWithWxString(message)];
[(NSOpenPanel*)m_cocoaNSWindow setAllowsMultipleSelection:(m_dialogStyle & wxMULTIPLE)];
[(NSOpenPanel*)m_cocoaNSWindow setAllowsMultipleSelection:(m_dialogStyle & wxFD_MULTIPLE)];
[(NSOpenPanel*)m_cocoaNSWindow setResolvesAliases:YES];
[(NSOpenPanel*)m_cocoaNSWindow setCanChooseFiles:YES];
[(NSOpenPanel*)m_cocoaNSWindow setCanChooseDirectories:NO];
@ -194,7 +195,7 @@ int wxFileDialog::ShowModal()
int nResult;
if (m_dialogStyle & wxSAVE)
if (m_dialogStyle & wxFD_SAVE)
{
nResult = [GetNSSavePanel()
runModalForDirectory:wxNSStringWithWxString(m_dir)
@ -206,7 +207,7 @@ int wxFileDialog::ShowModal()
m_path = m_fileNames[0];
}
}
else //m_dialogStyle & wxOPEN
else //m_dialogStyle & wxFD_OPEN
{
nResult = [(NSOpenPanel*)m_cocoaNSWindow
runModalForDirectory:wxNSStringWithWxString(m_dir)
@ -228,4 +229,3 @@ int wxFileDialog::ShowModal()
}
#endif // wxUSE_FILEDLG

View File

@ -202,7 +202,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
wxConvFileName->cWX2MB(defaultFileName));
#if GTK_CHECK_VERSION(2,7,3)
if ((style & wxOVERWRITE_PROMPT) && !gtk_check_version(2,7,3))
if ((style & wxFD_OVERWRITE_PROMPT) && !gtk_check_version(2,7,3))
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(m_widget), TRUE);
#endif
}

View File

@ -135,7 +135,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
bool isName = true ;
wxString current ;
for ( unsigned int i = 0; i < filter2.Len() ; i++ )
for ( unsigned int i = 0; i < filter2.length() ; i++ )
{
if ( filter2.GetChar(i) == wxT('|') )
{
@ -215,7 +215,7 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
if ( extension.GetChar(0) == '*' )
extension = extension.Mid(1) ;
if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
if ( file.length() >= extension.length() && extension == file.Right(extension.length() ) )
return true ;
}
}
@ -352,7 +352,7 @@ int wxFileDialog::ShowModal()
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
#if TARGET_API_MAC_OSX
if (!(m_windowStyle & wxOVERWRITE_PROMPT))
if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT))
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
#endif

View File

@ -169,7 +169,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
int filterIndex = 0;
bool isName = true ;
wxString current ;
for( unsigned int i = 0; i < filter2.Len() ; i++ )
for( unsigned int i = 0; i < filter2.length() ; i++ )
{
if( filter2.GetChar(i) == wxT('|') )
{
@ -251,7 +251,7 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
if ( extension.GetChar(0) == '*' )
extension = extension.Mid(1) ;
if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
if ( file.length() >= extension.length() && extension == file.Right(extension.length() ) )
return true ;
}
}
@ -584,7 +584,7 @@ int wxFileDialog::ShowModal()
myData.saveMode = false ;
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
if ( m_windowStyle & wxMULTIPLE )
if ( m_windowStyle & wxFD_MULTIPLE )
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
else
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;

View File

@ -136,8 +136,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
wildCard, style, pos, sz, name)
{
if ( ( m_windowStyle & wxMULTIPLE ) && ( m_windowStyle & wxSAVE ) )
m_windowStyle &= ~wxMULTIPLE;
if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
m_windowStyle &= ~wxFD_MULTIPLE;
m_bMovedWindow = false;
@ -208,12 +208,12 @@ void wxFileDialog::DoMoveWindow(int x, int y, int WXUNUSED(w), int WXUNUSED(h))
}
// helper used below in ShowModal(): style is used to determine whether to show
// the "Save file" dialog (if it contains wxSAVE bit) or "Open file" one;
// the "Save file" dialog (if it contains wxFD_SAVE bit) or "Open file" one;
// returns true on success or false on failure in which case err is filled with
// the CDERR_XXX constant
static bool DoShowCommFileDialog(OPENFILENAME *of, long style, DWORD *err)
{
if ( style & wxSAVE ? GetSaveFileName(of) : GetOpenFileName(of) )
if ( style & wxFD_SAVE ? GetSaveFileName(of) : GetOpenFileName(of) )
return true;
if ( err )
@ -280,13 +280,13 @@ int wxFileDialog::ShowModal()
#if WXWIN_COMPATIBILITY_2_4
long msw_flags = 0;
if ( (m_windowStyle & wxHIDE_READONLY) || (m_windowStyle & wxSAVE) )
if ( (m_windowStyle & wxHIDE_READONLY) || (m_windowStyle & wxFD_SAVE) )
msw_flags |= OFN_HIDEREADONLY;
#else
long msw_flags = OFN_HIDEREADONLY;
#endif
if ( m_windowStyle & wxFILE_MUST_EXIST )
if ( m_windowStyle & wxFD_FILE_MUST_EXIST )
msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
/*
If the window has been moved the programmer is probably
@ -304,21 +304,21 @@ int wxFileDialog::ShowModal()
#endif
}
if (m_windowStyle & wxMULTIPLE )
if (m_windowStyle & wxFD_MULTIPLE )
{
// OFN_EXPLORER must always be specified with OFN_ALLOWMULTISELECT
msw_flags |= OFN_EXPLORER | OFN_ALLOWMULTISELECT;
}
// if wxCHANGE_DIR flag is not given we shouldn't change the CWD which the
// 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 & wxCHANGE_DIR) )
if ( !(m_windowStyle & wxFD_CHANGE_DIR) )
{
msw_flags |= OFN_NOCHANGEDIR;
}
if ( m_windowStyle & wxOVERWRITE_PROMPT )
if ( m_windowStyle & wxFD_OVERWRITE_PROMPT )
{
msw_flags |= OFN_OVERWRITEPROMPT;
}
@ -393,7 +393,7 @@ int wxFileDialog::ShowModal()
}
// Replace | with \0
for (i = 0; i < filterBuffer.Len(); i++ ) {
for (i = 0; i < filterBuffer.length(); i++ ) {
if ( filterBuffer.GetChar(i) == wxT('|') ) {
filterBuffer[i] = wxT('\0');
}
@ -411,11 +411,11 @@ int wxFileDialog::ShowModal()
of.nMaxFile = wxMAXPATH;
// we must set the default extension because otherwise Windows would check
// for the existing of a wrong file with wxOVERWRITE_PROMPT (i.e. if the
// for the existing of a wrong file with wxFD_OVERWRITE_PROMPT (i.e. if the
// 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 & wxSAVE)
if (m_windowStyle & wxFD_SAVE)
{
const wxChar* extension = filterBuffer;
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
@ -463,7 +463,7 @@ int wxFileDialog::ShowModal()
// GetOpenFileName will always change the current working directory on
// (according to MSDN) "Windows NT 4.0/2000/XP" because the flag
// OFN_NOCHANGEDIR has no effect. If the user did not specify
// wxCHANGE_DIR let's restore the current working directory to what it
// wxFD_CHANGE_DIR let's restore the current working directory to what it
// was before the dialog was shown.
if ( msw_flags & OFN_NOCHANGEDIR )
{
@ -472,7 +472,7 @@ int wxFileDialog::ShowModal()
m_fileNames.Empty();
if ( ( m_windowStyle & wxMULTIPLE ) &&
if ( ( m_windowStyle & wxFD_MULTIPLE ) &&
#if defined(OFN_EXPLORER)
( fileNameBuffer[of.nFileOffset-1] == wxT('\0') )
#else
@ -485,7 +485,7 @@ int wxFileDialog::ShowModal()
i = of.nFileOffset;
m_fileName = &fileNameBuffer[i];
m_fileNames.Add(m_fileName);
i += m_fileName.Len() + 1;
i += m_fileName.length() + 1;
while (fileNameBuffer[i] != wxT('\0'))
{
@ -526,8 +526,8 @@ int wxFileDialog::ShowModal()
extension = extension + wxStrlen( extension ) + 1;
m_fileName = AppendExtension(fileNameBuffer, extension);
wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.Len(), wxMAXPATH-1));
fileNameBuffer[wxMin(m_fileName.Len(), wxMAXPATH-1)] = wxT('\0');
wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.length(), wxMAXPATH-1));
fileNameBuffer[wxMin(m_fileName.length(), wxMAXPATH-1)] = wxT('\0');
}
m_path = fileNameBuffer;
@ -555,4 +555,3 @@ int wxFileDialog::ShowModal()
}
#endif // wxUSE_FILEDLG && !(__SMARTPHONE__ && __WXWINCE__)

View File

@ -73,8 +73,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
{
m_message = message;
m_windowStyle = style;
if ( ( m_windowStyle & wxMULTIPLE ) && ( m_windowStyle & wxSAVE ) )
m_windowStyle &= ~wxMULTIPLE;
if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
m_windowStyle &= ~wxFD_MULTIPLE;
m_parent = parent;
m_path = wxEmptyString;
m_fileName = defaultFileName;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filedlg.cpp
// Name: src/os2/filedlg.cpp
// Purpose: wxFileDialog
// Author: David Webster
// Modified by:
@ -78,8 +78,8 @@ wxFileDialog::wxFileDialog (
:wxFileDialogBase(pParent, rsMessage, rsDefaultDir, rsDefaultFileName, rsWildCard, lStyle, rPos, sz, name)
{
if ((m_windowStyle & wxMULTIPLE) && (m_windowStyle & wxSAVE))
m_windowStyle &= ~wxMULTIPLE;
if ((m_windowStyle & wxFD_MULTIPLE) && (m_windowStyle & wxFD_SAVE))
m_windowStyle &= ~wxFD_MULTIPLE;
m_filterIndex = 1;
} // end of wxFileDialog::wxFileDialog
@ -126,7 +126,7 @@ int wxFileDialog::ShowModal()
*zFileNameBuffer = wxT('\0');
*zTitleBuffer = wxT('\0');
if (m_windowStyle & wxSAVE)
if (m_windowStyle & wxFD_SAVE)
lFlags = FDS_SAVEAS_DIALOG;
else
lFlags = FDS_OPEN_DIALOG;
@ -136,9 +136,9 @@ int wxFileDialog::ShowModal()
lFlags |= FDS_SAVEAS_DIALOG;
#endif
if (m_windowStyle & wxSAVE)
if (m_windowStyle & wxFD_SAVE)
lFlags |= FDS_SAVEAS_DIALOG;
if (m_windowStyle & wxMULTIPLE )
if (m_windowStyle & wxFD_MULTIPLE)
lFlags |= FDS_OPEN_DIALOG | FDS_MULTIPLESEL;
vFileDlg.cbSize = sizeof(FILEDLG);
@ -224,7 +224,7 @@ int wxFileDialog::ShowModal()
if (hWnd && vFileDlg.lReturn == DID_OK)
{
m_fileNames.Empty();
if ((m_windowStyle & wxMULTIPLE ) && vFileDlg.ulFQFCount > 1)
if ((m_windowStyle & wxFD_MULTIPLE ) && vFileDlg.ulFQFCount > 1)
{
for (int i = 0; i < (int)vFileDlg.ulFQFCount; i++)
{
@ -238,7 +238,7 @@ int wxFileDialog::ShowModal()
}
::WinFreeFileDlgList(vFileDlg.papszFQFilename);
}
else if (!(m_windowStyle & wxSAVE))
else if (!(m_windowStyle & wxFD_SAVE))
{
m_path = (wxChar*)vFileDlg.szFullFile;
m_fileName = wxFileNameFromPath(wxString((const wxChar*)vFileDlg.szFullFile));
@ -301,10 +301,10 @@ int wxFileDialog::ShowModal()
m_dir = wxPathOnly((const wxChar*)vFileDlg.szFullFile);
//
// === Simulating the wxOVERWRITE_PROMPT >>============================
// === Simulating the wxFD_OVERWRITE_PROMPT >>============================
//
if ((m_windowStyle & wxOVERWRITE_PROMPT) &&
(m_windowStyle & wxSAVE) &&
if ((m_windowStyle & wxFD_OVERWRITE_PROMPT) &&
(m_windowStyle & wxFD_SAVE) &&
(wxFileExists(m_path.c_str())))
{
wxString sMessageText;