File/dir dialog styles and other changes (patch 1488371):

- check invalid combinations of styles in wxFileDialogBase::Create()
- use wxFD_XXX naming convention for wxFileDialog styles
- replaces wxDD_NEW_DIR_BUTTON with wxDD_DIR_MUST_EXIST
- removes #ifdef __WXGTK24__ / #endif blocks from wxGTK code
- removes wxFileDialogBase::Get/SetStyle and wxFileDialogBase::m_fileName
- renames wxDirDialogGTK to wxDirDialog


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39402 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-05-28 23:32:12 +00:00
parent 55325d01e6
commit ff3e84ffdc
53 changed files with 273 additions and 310 deletions

View File

@@ -76,6 +76,7 @@ extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[] =
extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogNameStr[] = wxT("wxDirCtrl");
extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogDefaultFolderStr[] = wxT("/");
extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[] = wxT("filedlg");
#if defined(__WXMSW__) || defined(__OS2__)
WXDLLEXPORT_DATA(const wxChar *) wxUserResourceStr = wxT("TEXT");
#endif

View File

@@ -305,7 +305,7 @@ bool wxDocument::SaveAs()
wxFileNameFromPath(GetFilename()),
docTemplate->GetDefaultExtension(),
filter,
wxSAVE | wxOVERWRITE_PROMPT,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
GetDocumentWindow());
if (tmp.empty())

View File

@@ -35,8 +35,6 @@
// implementation
// ============================================================================
const wxChar wxDirSelectorPromptStr[] = wxT("Select a directory");
wxString wxDirSelector(const wxString& message,
const wxString& defaultPath,
long style,

View File

@@ -35,7 +35,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileDialogBase, wxDialog)
void wxFileDialogBase::Init()
{
m_filterIndex =
m_dialogStyle = 0;
m_windowStyle = 0;
}
bool wxFileDialogBase::Create(wxWindow *parent,
@@ -44,7 +44,9 @@ bool wxFileDialogBase::Create(wxWindow *parent,
const wxString& defaultFile,
const wxString& wildCard,
long style,
const wxPoint& WXUNUSED(pos))
const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(sz),
const wxString& WXUNUSED(name))
{
m_message = message;
m_dir = defaultDir;
@@ -52,9 +54,20 @@ bool wxFileDialogBase::Create(wxWindow *parent,
m_wildCard = wildCard;
m_parent = parent;
m_dialogStyle = style;
m_windowStyle = style;
m_filterIndex = 0;
#ifdef __WXDEBUG__
// check the given styles
wxASSERT_MSG(HasFlag(wxFD_OPEN) || HasFlag(wxFD_SAVE), wxT("You must specify one of wxFD_OPEN and wxFD_SAVE styles"));
if (HasFlag(wxFD_SAVE))
wxASSERT_MSG( !HasFlag(wxFD_OPEN) && !HasFlag(wxFD_MULTIPLE) && !HasFlag(wxFD_FILE_MUST_EXIST),
wxT("wxFileDialog - wxFD_OPEN, wxFD_MULTIPLE or wxFD_FILE_MUST_EXIST used on a save dialog" ) );
if (HasFlag(wxFD_OPEN))
wxASSERT_MSG( !HasFlag(wxFD_SAVE) && !HasFlag(wxFD_OVERWRITE_PROMPT),
wxT("wxFileDialog - wxFD_SAVE or wxFD_OVERWRITE_PROMPT used on a open dialog" ) );
#endif
if ( wildCard.empty() || wildCard == wxFileSelectorDefaultWildcardStr )
{
m_wildCard = wxString::Format(_("All files (%s)|%s"),
@@ -270,7 +283,7 @@ static wxString wxDefaultFileSelector(bool load,
}
return wxFileSelector(prompt, NULL, default_name, ext, wild,
load ? wxOPEN : wxSAVE, parent);
load ? wxFD_OPEN : wxFD_SAVE, parent);
}
//----------------------------------------------------------------------------

View File

@@ -109,7 +109,7 @@ bool wxGenericDirDialog::Create(wxWindow* parent,
wxMenu *dirMenu = new wxMenu;
dirMenu->Append(ID_GO_HOME, _("Home"));
if (style & wxDD_NEW_DIR_BUTTON)
if (!HasFlag(wxDD_DIR_MUST_EXIST))
{
dirMenu->Append(ID_NEW, _("New directory"));
}
@@ -133,7 +133,7 @@ bool wxGenericDirDialog::Create(wxWindow* parent,
// I'm not convinced we need a New button, and we tend to get annoying
// accidental-editing with label editing enabled.
if (style & wxDD_NEW_DIR_BUTTON)
if (!HasFlag(wxDD_DIR_MUST_EXIST))
{
wxBitmapButton* newButton =
new wxBitmapButton(this, ID_NEW,
@@ -158,7 +158,7 @@ bool wxGenericDirDialog::Create(wxWindow* parent,
long dirStyle = wxDIRCTRL_DIR_ONLY | wxDEFAULT_CONTROL_BORDER;
#ifdef __WXMSW__
if (style & wxDD_NEW_DIR_BUTTON)
if (!HasFlag(wxDD_DIR_MUST_EXIST))
{
// Only under Windows do we need the wxTR_EDIT_LABEL tree control style
// before we can call EditLabel (required for "New directory")

View File

@@ -46,7 +46,7 @@
#include "wx/artprov.h"
#include "wx/filefn.h"
#include "wx/file.h" // for wxS_IXXX constants only
#include "wx/filedlg.h" // wxOPEN, wxSAVE...
#include "wx/filedlg.h" // wxFD_OPEN, wxFD_SAVE...
#include "wx/generic/filedlgg.h"
#include "wx/generic/dirctrlg.h" // for wxFileIconsTable
@@ -974,10 +974,12 @@ wxGenericFileDialog::wxGenericFileDialog(wxWindow *parent,
const wxString& wildCard,
long style,
const wxPoint& pos,
const wxSize& sz,
const wxString& name,
bool bypassGenericImpl ) : wxFileDialogBase()
{
Init();
Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, bypassGenericImpl );
Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name, bypassGenericImpl );
}
bool wxGenericFileDialog::Create( wxWindow *parent,
@@ -987,12 +989,14 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
const wxString& wildCard,
long style,
const wxPoint& pos,
const wxSize& sz,
const wxString& name,
bool bypassGenericImpl )
{
m_bypassGenericImpl = bypassGenericImpl;
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile,
wildCard, style, pos))
wildCard, style, pos, sz, name))
{
return false;
}
@@ -1000,8 +1004,8 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
if (m_bypassGenericImpl)
return true;
if (!wxDialog::Create( parent, wxID_ANY, message, pos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
if (!wxDialog::Create( parent, wxID_ANY, message, pos, sz,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, name
))
{
return false;
@@ -1017,11 +1021,6 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
&ms_lastShowHidden);
}
if (m_dialogStyle == 0)
m_dialogStyle = wxOPEN;
if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN))
m_dialogStyle |= wxOPEN;
if ((m_dir.empty()) || (m_dir == wxT(".")))
{
m_dir = wxGetCwd();
@@ -1102,7 +1101,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 );
long style2 = ms_lastViewStyle;
if ( !(m_dialogStyle & wxMULTIPLE) )
if ( !HasFlag(wxFD_MULTIPLE) )
style2 |= wxLC_SINGLE_SEL;
#ifdef __WXWINCE__
@@ -1404,7 +1403,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
}
#endif // __UNIX__
if (!(m_dialogStyle & wxSAVE))
if (!HasFlag(wxFD_SAVE))
{
if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
(filename.Find(wxT('?')) != wxNOT_FOUND))
@@ -1449,14 +1448,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 ( !(m_dialogStyle & wxOPEN) || !wxFileExists(filename) )
if ( !HasFlag(wxFD_OPEN) || !wxFileExists(filename) )
{
filename = AppendExtension(filename, m_filterExtension);
}
// check that the file [doesn't] exist if necessary
if ( (m_dialogStyle & wxSAVE) &&
(m_dialogStyle & wxOVERWRITE_PROMPT) &&
if ( HasFlag(wxFD_SAVE) && HasFlag(wxFD_OVERWRITE_PROMPT) &&
wxFileExists( filename ) )
{
wxString msg;
@@ -1465,8 +1463,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
return;
}
else if ( (m_dialogStyle & wxOPEN) &&
(m_dialogStyle & wxFILE_MUST_EXIST) &&
else if ( HasFlag(wxFD_OPEN) && HasFlag(wxFD_FILE_MUST_EXIST) &&
!wxFileExists(filename) )
{
wxMessageBox(_("Please choose an existing file."), _("Error"),
@@ -1476,7 +1473,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
SetPath( filename );
// change to the directory where the user went if asked
if ( m_dialogStyle & wxCHANGE_DIR )
if ( HasFlag(wxFD_CHANGE_DIR) )
{
wxString cwd;
wxSplitPath(filename, &cwd, NULL, NULL);

View File

@@ -295,7 +295,7 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
wxFileName fname( m_printDialogData.GetPrintData().GetFilename() );
wxFileDialog dialog( this, _("PostScript file"),
fname.GetPath(), fname.GetFullName(), wxT("*.ps"), wxSAVE | wxOVERWRITE_PROMPT );
fname.GetPath(), fname.GetFullName(), wxT("*.ps"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if (dialog.ShowModal() != wxID_OK) return;
m_printDialogData.GetPrintData().SetFilename( dialog.GetPath() );

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/dirdlg.cpp
// Purpose: native implementation of wxDirDialogGTK
// Purpose: native implementation of wxDirDialog
// Author: Robert Roebling, Zbigniew Zagorski, Mart Raudsepp, Francesco Montorsi
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, 2004 Zbigniew Zagorski, 2005 Mart Raudsepp
@@ -13,14 +13,14 @@
/*
NOTE: the GtkFileChooser interface can be used both for wxFileDialog and for wxDirDialogGTK.
NOTE: the GtkFileChooser interface can be used both for wxFileDialog and for wxDirDialog.
Thus following code is very similar (even if not identic) to src/gtk/filedlg.cpp
If you find a problem in this code, remember to check also that file !
*/
#if wxUSE_DIRDLG
#if wxUSE_DIRDLG && defined( __WXGTK24__ )
#include "wx/dirdlg.h"
@@ -29,8 +29,6 @@
#include "wx/filedlg.h"
#endif
#ifdef __WXGTK24__ // only for GTK+ > 2.4 there is GtkFileChooserDialog
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
@@ -48,7 +46,7 @@ extern void wxapp_install_idle_handler();
//-----------------------------------------------------------------------------
extern "C" {
static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialogGTK *dialog)
static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog)
{
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
@@ -70,7 +68,7 @@ static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialogGTK *dialog)
extern "C" {
static void gtk_dirdialog_cancel_callback(GtkWidget *WXUNUSED(w),
wxDirDialogGTK *dialog)
wxDirDialog *dialog)
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject(dialog);
@@ -81,7 +79,7 @@ static void gtk_dirdialog_cancel_callback(GtkWidget *WXUNUSED(w),
extern "C" {
static void gtk_dirdialog_response_callback(GtkWidget *w,
gint response,
wxDirDialogGTK *dialog)
wxDirDialog *dialog)
{
wxapp_install_idle_handler();
@@ -92,24 +90,21 @@ static void gtk_dirdialog_response_callback(GtkWidget *w,
}
}
#endif // __WXGTK24__
//-----------------------------------------------------------------------------
// wxDirDialogGTK
// wxDirDialog
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxDirDialogGTK,wxGenericDirDialog)
IMPLEMENT_DYNAMIC_CLASS(wxDirDialog,wxGenericDirDialog)
BEGIN_EVENT_TABLE(wxDirDialogGTK,wxGenericDirDialog)
EVT_BUTTON(wxID_OK, wxDirDialogGTK::OnFakeOk)
BEGIN_EVENT_TABLE(wxDirDialog,wxGenericDirDialog)
EVT_BUTTON(wxID_OK, wxDirDialog::OnFakeOk)
END_EVENT_TABLE()
wxDirDialogGTK::wxDirDialogGTK(wxWindow* parent, const wxString& title,
wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
const wxString& defaultPath, long style,
const wxPoint& pos, const wxSize& sz,
const wxString& name)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
m_message = title;
@@ -119,7 +114,7 @@ wxDirDialogGTK::wxDirDialogGTK(wxWindow* parent, const wxString& title,
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
wxDefaultValidator, wxT("dirdialog")))
{
wxFAIL_MSG( wxT("wxDirDialogGTK creation failed") );
wxFAIL_MSG( wxT("wxDirDialog creation failed") );
return;
}
@@ -128,8 +123,9 @@ wxDirDialogGTK::wxDirDialogGTK(wxWindow* parent, const wxString& title,
if (parent)
gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
if (HasFlag(wxDD_DIR_MUST_EXIST))
gtk_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
if (style & wxDD_NEW_DIR_BUTTON)
else
gtk_action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
m_widget = gtk_file_chooser_dialog_new(
@@ -169,37 +165,31 @@ wxDirDialogGTK::wxDirDialogGTK(wxWindow* parent, const wxString& title,
wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
}
void wxDirDialogGTK::OnFakeOk( wxCommandEvent &event )
void wxDirDialog::OnFakeOk( wxCommandEvent &event )
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
wxDialog::OnOK( event );
else
#endif
wxGenericDirDialog::OnOK( event );
}
int wxDirDialogGTK::ShowModal()
int wxDirDialog::ShowModal()
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxDialog::ShowModal();
else
#endif
return wxGenericDirDialog::ShowModal();
}
bool wxDirDialogGTK::Show( bool show )
bool wxDirDialog::Show( bool show )
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxDialog::Show( show );
else
#endif
return wxGenericDirDialog::Show( show );
}
void wxDirDialogGTK::DoSetSize(int x, int y, int width, int height, int sizeFlags )
void wxDirDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
if (!m_wxwindow)
return;
@@ -207,9 +197,8 @@ void wxDirDialogGTK::DoSetSize(int x, int y, int width, int height, int sizeFlag
wxGenericDirDialog::DoSetSize( x, y, width, height, sizeFlags );
}
void wxDirDialogGTK::SetPath(const wxString& dir)
void wxDirDialog::SetPath(const wxString& dir)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
if (wxDirExists(dir))
@@ -218,17 +207,14 @@ void wxDirDialogGTK::SetPath(const wxString& dir)
}
}
else
#endif
wxGenericDirDialog::SetPath( dir );
}
wxString wxDirDialogGTK::GetPath() const
wxString wxDirDialog::GetPath() const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxConvFileName->cMB2WX( gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(m_widget) ) );
else
#endif
return wxGenericDirDialog::GetPath();
}

View File

@@ -10,7 +10,7 @@
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_FILEDLG
#if wxUSE_FILEDLG && defined(__WXGTK24__)
#include "wx/filedlg.h"
@@ -19,8 +19,6 @@
#include "wx/msgdlg.h"
#endif
#ifdef __WXGTK24__
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
@@ -43,14 +41,14 @@ extern void wxapp_install_idle_handler();
extern "C" {
static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
{
int style = dialog->GetStyle();
int style = dialog->GetWindowStyle();
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
// gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
#if GTK_CHECK_VERSION(2,7,3)
if(gtk_check_version(2,7,3) != NULL)
#endif
if ((style & wxSAVE) && (style & wxOVERWRITE_PROMPT))
if ((style & wxFD_SAVE) && (style & wxFD_OVERWRITE_PROMPT))
{
if ( g_file_test(filename, G_FILE_TEST_EXISTS) )
{
@@ -68,7 +66,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
}
// change to the directory where the user went if asked
if (style & wxCHANGE_DIR)
if (style & wxFD_CHANGE_DIR)
{
// Use chdir to not care about filename encodings
gchar* folder = g_path_get_dirname(filename);
@@ -111,7 +109,6 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
}
}
#endif // __WXGTK24__
//-----------------------------------------------------------------------------
// wxFileDialog
@@ -127,14 +124,14 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxString& defaultDir,
const wxString& defaultFileName,
const wxString& wildCard,
long style, const wxPoint& pos)
long style, const wxPoint& pos,
const wxSize& sz,
const wxString& name)
: wxGenericFileDialog(parent, message, defaultDir, defaultFileName,
wildCard, style, pos, true )
wildCard, style, pos, sz, name, true )
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
wxASSERT_MSG( !( (style & wxSAVE) && (style & wxMULTIPLE) ), wxT("wxFileDialog - wxMULTIPLE used on a save dialog" ) );
m_needParent = false;
if (!PreCreation(parent, pos, wxDefaultSize) ||
@@ -151,7 +148,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
const gchar* ok_btn_stock;
if ( style & wxSAVE )
if ( style & wxFD_SAVE )
{
gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE;
ok_btn_stock = GTK_STOCK_SAVE;
@@ -172,7 +169,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
if ( style & wxMULTIPLE )
if ( style & wxFD_MULTIPLE )
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), true);
// gtk_widget_hide_on_delete is used here to avoid that Gtk automatically destroys
@@ -195,7 +192,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
SetWildcard(wildCard);
if ( style & wxSAVE )
if ( style & wxFD_SAVE )
{
if ( !defaultDir.empty() )
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
@@ -229,37 +226,30 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
}
}
else
#endif
wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos );
}
void wxFileDialog::OnFakeOk( wxCommandEvent &event )
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
wxDialog::OnOK( event );
else
#endif
wxGenericFileDialog::OnListOk( event );
}
int wxFileDialog::ShowModal()
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxDialog::ShowModal();
else
#endif
return wxGenericFileDialog::ShowModal();
}
bool wxFileDialog::Show( bool show )
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxDialog::Show( show );
else
#endif
return wxGenericFileDialog::Show( show );
}
@@ -273,17 +263,14 @@ void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags
wxString wxFileDialog::GetPath() const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
else
#endif
return wxGenericFileDialog::GetPath();
}
void wxFileDialog::GetFilenames(wxArrayString& files) const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
GetPaths(files);
@@ -294,13 +281,11 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
}
}
else
#endif
wxGenericFileDialog::GetFilenames( files );
}
void wxFileDialog::GetPaths(wxArrayString& paths) const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
paths.Empty();
@@ -322,26 +307,22 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
paths.Add(GetPath());
}
else
#endif
wxGenericFileDialog::GetPaths( paths );
}
void wxFileDialog::SetMessage(const wxString& message)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
m_message = message;
SetTitle(message);
}
else
#endif
wxGenericFileDialog::SetMessage( message );
}
void wxFileDialog::SetPath(const wxString& path)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
if (path.empty()) return;
@@ -349,13 +330,11 @@ void wxFileDialog::SetPath(const wxString& path)
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(path));
}
else
#endif
wxGenericFileDialog::SetPath( path );
}
void wxFileDialog::SetDirectory(const wxString& dir)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
if (wxDirExists(dir))
@@ -364,50 +343,42 @@ void wxFileDialog::SetDirectory(const wxString& dir)
}
}
else
#endif
wxGenericFileDialog::SetDirectory( dir );
}
wxString wxFileDialog::GetDirectory() const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxConvFileName->cMB2WX(
gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(m_widget) ) );
else
#endif
return wxGenericFileDialog::GetDirectory();
}
void wxFileDialog::SetFilename(const wxString& name)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
if (GetStyle() & wxSAVE)
if (HasFlag(wxFD_SAVE))
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(name));
else
SetPath(wxFileName(GetDirectory(), name).GetFullPath());
}
else
#endif
wxGenericFileDialog::SetFilename( name );
}
wxString wxFileDialog::GetFilename() const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
return wxFileName(
wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))) ).GetFullName();
else
#endif
return wxGenericFileDialog::GetFilename();
}
void wxFileDialog::SetWildcard(const wxString& wildCard)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
// parse filters
@@ -455,13 +426,12 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
}
}
else
#endif
wxGenericFileDialog::SetWildcard( wildCard );
}
void wxFileDialog::SetFilterIndex(int filterIndex)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
gpointer filter;
@@ -482,13 +452,11 @@ void wxFileDialog::SetFilterIndex(int filterIndex)
g_slist_free(filters);
}
else
#endif
wxGenericFileDialog::SetFilterIndex( filterIndex );
}
int wxFileDialog::GetFilterIndex() const
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget);
@@ -506,8 +474,7 @@ int wxFileDialog::GetFilterIndex() const
return index;
}
else
#endif
return wxGenericFileDialog::GetFilterIndex();
}
#endif // wxUSE_FILEDLG
#endif // wxUSE_FILEDLG && __WXGTK24__

View File

@@ -29,11 +29,13 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxString& defaultDir,
const wxString& defaultFileName,
const wxString& wildCard,
long style, const wxPoint& pos)
long style, const wxPoint& pos,
const wxSize& sz,
const wxString& name)
: wxGenericFileDialog(parent, message, defaultDir, defaultFileName,
wildCard, style, pos, true )
wildCard, style, pos, sz, name, true )
{
wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos );
wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name );
}
wxFileDialog::~wxFileDialog()

View File

@@ -1533,7 +1533,7 @@ void wxHtmlHelpWindow::OnToolbar(wxCommandEvent& event)
wxEmptyString,
wxEmptyString,
filemask,
wxOPEN | wxFILE_MUST_EXIST,
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
this);
if (!s.empty())
{

View File

@@ -259,8 +259,8 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
wxFileDialog::wxFileDialog(
wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos)
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
{
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
}
@@ -338,7 +338,7 @@ int wxFileDialog::ShowModal()
}
}
if (m_dialogStyle & wxSAVE)
if (HasFlag(wxFD_SAVE))
{
myData.saveMode = true;
@@ -352,7 +352,7 @@ int wxFileDialog::ShowModal()
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
#if TARGET_API_MAC_OSX
if (!(m_dialogStyle & wxOVERWRITE_PROMPT))
if (!(m_windowStyle & wxOVERWRITE_PROMPT))
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
#endif
@@ -413,7 +413,7 @@ int wxFileDialog::ShowModal()
if (err != noErr)
break;
if (m_dialogStyle & wxSAVE)
if (HasFlag(wxFD_SAVE))
thePath = wxMacFSRefToPath( &theFSRef, navReply.saveFileName );
else
thePath = wxMacFSRefToPath( &theFSRef );

View File

@@ -43,7 +43,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent,
{
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
m_message = message;
m_dialogStyle = style;
m_windowStyle = style;
m_parent = parent;
m_path = defaultPath;
}

View File

@@ -292,8 +292,8 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
{
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
}
@@ -372,7 +372,7 @@ int wxFileDialog::ShowModal()
OpenUserDataRec myData;
myData.defaultLocation = m_dir;
if (m_dialogStyle & wxSAVE)
if (HasFlag(wxFD_SAVE))
{
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
@@ -445,7 +445,7 @@ int wxFileDialog::ShowModal()
break;
CFURLRef fullURLRef;
if (m_dialogStyle & wxSAVE)
if (HasFlag(wxFD_SAVE))
{
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
@@ -562,7 +562,7 @@ int wxFileDialog::ShowModal()
wxMacStringToPascal( myData.name[i] , (StringPtr)(*mNavOptions.popupExtension)[i].menuItemName ) ;
}
}
if ( m_dialogStyle & wxSAVE )
if ( HasFlag(wxFD_SAVE) )
{
myData.saveMode = true ;
@@ -584,7 +584,7 @@ int wxFileDialog::ShowModal()
myData.saveMode = false ;
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
if ( m_dialogStyle & wxMULTIPLE )
if ( m_windowStyle & wxMULTIPLE )
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
else
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;

View File

@@ -117,8 +117,8 @@ static wxString ParseWildCard( const wxString& wild )
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
{
m_filterIndex = 1;
}

View File

@@ -148,7 +148,7 @@ int wxDirDialog::ShowModal()
// is also the only way to have a resizable dialog
//
// "new" style is only available in the version 5.0+ of comctl32.dll
const bool needNewDir = HasFlag(wxDD_NEW_DIR_BUTTON);
const bool needNewDir = !HasFlag(wxDD_DIR_MUST_EXIST);
if ( (needNewDir || HasFlag(wxRESIZE_BORDER)) && (verComCtl32 >= 500) )
{
if (needNewDir)

View File

@@ -129,13 +129,15 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
const wxString& defaultFileName,
const wxString& wildCard,
long style,
const wxPoint& pos)
const wxPoint& pos,
const wxSize& sz,
const wxString& name)
: wxFileDialogBase(parent, message, defaultDir, defaultFileName,
wildCard, style, pos)
wildCard, style, pos, sz, name)
{
if ( ( m_dialogStyle & wxMULTIPLE ) && ( m_dialogStyle & wxSAVE ) )
m_dialogStyle &= ~wxMULTIPLE;
if ( ( m_windowStyle & wxMULTIPLE ) && ( m_windowStyle & wxSAVE ) )
m_windowStyle &= ~wxMULTIPLE;
m_bMovedWindow = false;
@@ -278,13 +280,13 @@ int wxFileDialog::ShowModal()
#if WXWIN_COMPATIBILITY_2_4
long msw_flags = 0;
if ( (m_dialogStyle & wxHIDE_READONLY) || (m_dialogStyle & wxSAVE) )
if ( (m_windowStyle & wxHIDE_READONLY) || (m_windowStyle & wxSAVE) )
msw_flags |= OFN_HIDEREADONLY;
#else
long msw_flags = OFN_HIDEREADONLY;
#endif
if ( m_dialogStyle & wxFILE_MUST_EXIST )
if ( m_windowStyle & wxFILE_MUST_EXIST )
msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
/*
If the window has been moved the programmer is probably
@@ -302,7 +304,7 @@ int wxFileDialog::ShowModal()
#endif
}
if (m_dialogStyle & wxMULTIPLE )
if (m_windowStyle & wxMULTIPLE )
{
// OFN_EXPLORER must always be specified with OFN_ALLOWMULTISELECT
msw_flags |= OFN_EXPLORER | OFN_ALLOWMULTISELECT;
@@ -311,12 +313,12 @@ int wxFileDialog::ShowModal()
// if wxCHANGE_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_dialogStyle & wxCHANGE_DIR) )
if ( !(m_windowStyle & wxCHANGE_DIR) )
{
msw_flags |= OFN_NOCHANGEDIR;
}
if ( m_dialogStyle & wxOVERWRITE_PROMPT )
if ( m_windowStyle & wxOVERWRITE_PROMPT )
{
msw_flags |= OFN_OVERWRITEPROMPT;
}
@@ -413,7 +415,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_dialogStyle & wxSAVE)
if (m_windowStyle & wxSAVE)
{
const wxChar* extension = filterBuffer;
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
@@ -436,7 +438,7 @@ int wxFileDialog::ShowModal()
//== Execute FileDialog >>=================================================
DWORD errCode;
bool success = DoShowCommFileDialog(&of, m_dialogStyle, &errCode);
bool success = DoShowCommFileDialog(&of, m_windowStyle, &errCode);
#ifdef wxTRY_SMALLER_OPENFILENAME
// the system might be too old to support the new version file dialog
@@ -446,7 +448,7 @@ int wxFileDialog::ShowModal()
{
of.lStructSize = wxOPENFILENAME_V4_SIZE;
success = DoShowCommFileDialog(&of, m_dialogStyle, &errCode);
success = DoShowCommFileDialog(&of, m_windowStyle, &errCode);
if ( success || !errCode )
{
@@ -470,7 +472,7 @@ int wxFileDialog::ShowModal()
m_fileNames.Empty();
if ( ( m_dialogStyle & wxMULTIPLE ) &&
if ( ( m_windowStyle & wxMULTIPLE ) &&
#if defined(OFN_EXPLORER)
( fileNameBuffer[of.nFileOffset-1] == wxT('\0') )
#else

View File

@@ -70,9 +70,9 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
const wxPoint& WXUNUSED(pos))
{
m_message = message;
m_dialogStyle = style;
if ( ( m_dialogStyle & wxMULTIPLE ) && ( m_dialogStyle & wxSAVE ) )
m_dialogStyle &= ~wxMULTIPLE;
m_windowStyle = style;
if ( ( m_windowStyle & wxMULTIPLE ) && ( m_windowStyle & wxSAVE ) )
m_windowStyle &= ~wxMULTIPLE;
m_parent = parent;
m_path = wxEmptyString;
m_fileName = defaultFileName;

View File

@@ -36,7 +36,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
long style, const wxPoint& pos)
{
m_message = message;
m_dialogStyle = style;
m_windowStyle = style;
m_parent = parent;
m_path = defaultPath;
}

View File

@@ -71,13 +71,15 @@ wxFileDialog::wxFileDialog (
, const wxString& rsDefaultFileName
, const wxString& rsWildCard
, long lStyle
, const wxPoint& rPos
, const wxPoint& rPos,
const wxSize& sz,
const wxString& name
)
:wxFileDialogBase(pParent, rsMessage, rsDefaultDir, rsDefaultFileName, rsWildCard, lStyle, rPos)
:wxFileDialogBase(pParent, rsMessage, rsDefaultDir, rsDefaultFileName, rsWildCard, lStyle, rPos, sz, name)
{
if ((m_dialogStyle & wxMULTIPLE) && (m_dialogStyle & wxSAVE))
m_dialogStyle &= ~wxMULTIPLE;
if ((m_windowStyle & wxMULTIPLE) && (m_windowStyle & wxSAVE))
m_windowStyle &= ~wxMULTIPLE;
m_filterIndex = 1;
} // end of wxFileDialog::wxFileDialog
@@ -124,19 +126,19 @@ int wxFileDialog::ShowModal()
*zFileNameBuffer = wxT('\0');
*zTitleBuffer = wxT('\0');
if (m_dialogStyle & wxSAVE)
if (m_windowStyle & wxSAVE)
lFlags = FDS_SAVEAS_DIALOG;
else
lFlags = FDS_OPEN_DIALOG;
#if WXWIN_COMPATIBILITY_2_4
if (m_dialogStyle & wxHIDE_READONLY)
if (m_windowStyle & wxHIDE_READONLY)
lFlags |= FDS_SAVEAS_DIALOG;
#endif
if (m_dialogStyle & wxSAVE)
if (m_windowStyle & wxSAVE)
lFlags |= FDS_SAVEAS_DIALOG;
if (m_dialogStyle & wxMULTIPLE )
if (m_windowStyle & wxMULTIPLE )
lFlags |= FDS_OPEN_DIALOG | FDS_MULTIPLESEL;
vFileDlg.cbSize = sizeof(FILEDLG);
@@ -222,7 +224,7 @@ int wxFileDialog::ShowModal()
if (hWnd && vFileDlg.lReturn == DID_OK)
{
m_fileNames.Empty();
if ((m_dialogStyle & wxMULTIPLE ) && vFileDlg.ulFQFCount > 1)
if ((m_windowStyle & wxMULTIPLE ) && vFileDlg.ulFQFCount > 1)
{
for (int i = 0; i < (int)vFileDlg.ulFQFCount; i++)
{
@@ -236,7 +238,7 @@ int wxFileDialog::ShowModal()
}
::WinFreeFileDlgList(vFileDlg.papszFQFilename);
}
else if (!(m_dialogStyle & wxSAVE))
else if (!(m_windowStyle & wxSAVE))
{
m_path = (wxChar*)vFileDlg.szFullFile;
m_fileName = wxFileNameFromPath(wxString((const wxChar*)vFileDlg.szFullFile));
@@ -301,8 +303,8 @@ int wxFileDialog::ShowModal()
//
// === Simulating the wxOVERWRITE_PROMPT >>============================
//
if ((m_dialogStyle & wxOVERWRITE_PROMPT) &&
(m_dialogStyle & wxSAVE) &&
if ((m_windowStyle & wxOVERWRITE_PROMPT) &&
(m_windowStyle & wxSAVE) &&
(wxFileExists(m_path.c_str())))
{
wxString sMessageText;

View File

@@ -75,8 +75,10 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
const wxString& defaultFileName,
const wxString& wildCard,
long style,
const wxPoint& pos)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
const wxPoint& pos,
const wxSize& sz,
const wxString& name)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
{
}