#elif defined(__WXMOTIF__)
#include "wx/motif/filedlg.h"
#elif defined(__WXGTK__)
-#ifdef __WXGTK24__
#include "wx/gtk/filedlg.h"
-#else
-#include "wx/generic/filedlgg.h"
-#endif
#elif defined(__WXX11__)
#include "wx/generic/filedlgg.h"
#elif defined(__WXMGL__)
class WXDLLEXPORT wxStaticText;
class WXDLLEXPORT wxTextCtrl;
-#if defined(__WXUNIVERSAL__)||defined(__WXGTK__)||defined(__WXX11__)||defined(__WXMGL__)||defined(__WXCOCOA__)
+#if defined(__WXUNIVERSAL__)||defined(__WXX11__)||defined(__WXMGL__)||defined(__WXCOCOA__)
#define USE_GENERIC_FILEDIALOG
#endif
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = 0,
- const wxPoint& pos = wxDefaultPosition);
+ const wxPoint& pos = wxDefaultPosition,
+ bool bypassGenericImpl = false );
+ bool Create( wxWindow *parent,
+ const wxString& message = wxFileSelectorPromptStr,
+ const wxString& defaultDir = wxEmptyString,
+ const wxString& defaultFile = wxEmptyString,
+ const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
+ long style = 0,
+ const wxPoint& pos = wxDefaultPosition );
virtual ~wxGenericFileDialog();
virtual void SetMessage(const wxString& message) { SetTitle(message); }
virtual void HandleAction( const wxString &fn );
virtual void UpdateControls();
+
+private:
+ // Don't use this implementation at all :-)
+ bool m_bypassGenericImpl;
protected:
// use the filter with the given index
class WXDLLEXPORT wxFileDialog: public wxGenericFileDialog
{
- DECLARE_DYNAMIC_CLASS(wxFileDialog)
-
public:
wxFileDialog() {}
:wxGenericFileDialog(parent, message, defaultDir, defaultFile, wildCard, style, pos)
{
}
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxFileDialog)
};
#endif // USE_GENERIC_FILEDIALOG
#pragma interface
#endif
+#include "wx/generic/filedlgg.h"
+
//-------------------------------------------------------------------------
// wxFileDialog
//-------------------------------------------------------------------------
-class wxFileDialog: public wxFileDialogBase
+class wxFileDialog: public wxGenericFileDialog
{
public:
wxFileDialog() { }
virtual void SetWildcard(const wxString& wildCard);
virtual void SetFilterIndex(int filterIndex);
+ virtual int ShowModal();
+ virtual bool Show( bool show = true );
+
+ void OnFakeOk( wxCommandEvent &event );
+
//private:
bool m_destroyed_by_delete;
void UpdateFromDialog();
void UpdateDialog();
-
+
+private:
DECLARE_DYNAMIC_CLASS(wxFileDialog)
+ DECLARE_EVENT_TABLE()
};
#endif // __GTKFILEDLGH__
#pragma interface
#endif
+#include "wx/generic/filedlgg.h"
+
//-------------------------------------------------------------------------
// wxFileDialog
//-------------------------------------------------------------------------
-class wxFileDialog: public wxFileDialogBase
+class wxFileDialog: public wxGenericFileDialog
{
public:
wxFileDialog() { }
virtual void SetWildcard(const wxString& wildCard);
virtual void SetFilterIndex(int filterIndex);
+ virtual int ShowModal();
+ virtual bool Show( bool show = true );
+
+ void OnFakeOk( wxCommandEvent &event );
+
//private:
bool m_destroyed_by_delete;
void UpdateFromDialog();
void UpdateDialog();
-
+
+private:
DECLARE_DYNAMIC_CLASS(wxFileDialog)
+ DECLARE_EVENT_TABLE()
};
#endif // __GTKFILEDLGH__
#pragma hdrstop
#endif
-#if wxUSE_FILEDLG && !defined(__WXGTK24__)
+#if wxUSE_FILEDLG
// NOTE : it probably also supports MAC, untested
#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__)
const wxString& defaultFile,
const wxString& wildCard,
long style,
- const wxPoint& pos )
+ const wxPoint& pos,
+ bool bypassGenericImpl )
:wxFileDialogBase(parent, message, defaultDir, defaultFile, wildCard, style, pos)
{
- wxDialog::Create( parent, wxID_ANY, message, pos, wxDefaultSize,
- wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
+ m_bypassGenericImpl = bypassGenericImpl;
+
+ if (!m_bypassGenericImpl)
+ Create( parent, message, defaultDir, defaultFile, wildCard, style, pos );
+}
+
+bool wxGenericFileDialog::Create( wxWindow *parent,
+ const wxString& message,
+ const wxString& defaultDir,
+ const wxString& defaultFile,
+ const wxString& wildCard,
+ long style,
+ const wxPoint& pos )
+{
+ if (!wxDialog::Create( parent, wxID_ANY, message, pos, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ))
+ {
+ return false;
+ }
if (wxConfig::Get(false))
{
Centre( wxBOTH );
m_text->SetFocus();
+
+ return true;
}
wxGenericFileDialog::~wxGenericFileDialog()
{
- if (wxConfig::Get(false))
+ if (!m_bypassGenericImpl)
{
- wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"),
- ms_lastViewStyle);
- wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"),
- ms_lastShowHidden);
- }
+ if (wxConfig::Get(false))
+ {
+ wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"),
+ ms_lastViewStyle);
+ wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"),
+ ms_lastShowHidden);
+ }
- const int count = m_choice->GetCount();
- for ( int i = 0; i < count; i++ )
- {
- delete (wxString *)m_choice->GetClientData(i);
+ const int count = m_choice->GetCount();
+ for ( int i = 0; i < count; i++ )
+ {
+ delete (wxString *)m_choice->GetClientData(i);
+ }
}
}
#endif // USE_GENERIC_FILEDIALOG
-#endif // wxUSE_FILEDLG && !defined(__WXGTK24__)
+#endif // wxUSE_FILEDLG
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#if wxUSE_FILEDLG && defined(__WXGTK24__)
+#if wxUSE_FILEDLG
#include "wx/filedlg.h"
#include "wx/utils.h"
#include "wx/msgdlg.h"
#include <gtk/gtk.h>
+
+#ifdef __WXGTK24__
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
dialog->m_destroyed_by_delete = TRUE;
}
}
+#endif
//-----------------------------------------------------------------------------
// wxFileDialog
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxFileDialogBase)
+IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxGenericFileDialog)
+
+BEGIN_EVENT_TABLE(wxFileDialog,wxGenericFileDialog)
+ EVT_BUTTON(wxID_OK, wxFileDialog::OnFakeOk)
+END_EVENT_TABLE()
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)
+ : wxGenericFileDialog(parent, message, defaultDir, defaultFileName,
+ wildCard, style, pos, true )
{
+#ifdef __WXGTK24__
m_needParent = FALSE;
m_destroyed_by_delete = FALSE;
SetWildcard(wildCard);
SetFilterIndex(0);
+#else
+ wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos );
+#endif
}
wxFileDialog::~wxFileDialog()
{
+#ifdef __WXGTK24__
if (m_destroyed_by_delete)
m_widget = NULL;
+#endif
+}
+
+void wxFileDialog::OnFakeOk( wxCommandEvent &event )
+{
+#ifdef __WXGTK24__
+ wxDialog::OnOK( event );
+#else
+ wxGenericFileDialog::OnListOk( event );
+#endif
+}
+
+int wxFileDialog::ShowModal()
+{
+#ifdef __WXGTK24__
+ return wxDialog::ShowModal();
+#else
+ return wxGenericFileDialog::ShowModal();
+#endif
+}
+
+bool wxFileDialog::Show( bool show )
+{
+#ifdef __WXGTK24__
+ return wxDialog::Show( show );
+#else
+ return wxGenericFileDialog::Show( show );
+#endif
}
void wxFileDialog::GetFilenames(wxArrayString& files) const
{
+#ifdef __WXGTK24__
GetPaths(files);
for (size_t n = 0; n < files.GetCount(); n++ )
{
}
files[n] = name;
}
+#else
+ wxGenericFileDialog::GetFilenames( files );
+#endif
}
void wxFileDialog::GetPaths(wxArrayString& paths) const
{
+#ifdef __WXGTK24__
paths.Empty();
if (GetWindowStyle() & wxMULTIPLE)
{
{
paths.Add(m_fileName);
}
+#else
+ wxGenericFileDialog::GetPaths( paths );
+#endif
}
void wxFileDialog::SetMessage(const wxString& message)
{
+#ifdef __WXGTK24__
m_message = message;
SetTitle(message);
+#else
+ wxGenericFileDialog::SetMessage( message );
+#endif
}
void wxFileDialog::SetPath(const wxString& path)
{
+#ifdef __WXGTK24__
if (path.empty()) return;
wxFileName fn(path);
m_dir = fn.GetPath();
m_fileName = fn.GetFullName();
UpdateDialog();
+#else
+ wxGenericFileDialog::SetPath( path );
+#endif
}
void wxFileDialog::SetDirectory(const wxString& dir)
{
+#ifdef __WXGTK24__
if (wxDirExists(dir))
{
m_dir = dir;
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
UpdateDialog();
}
+#else
+ wxGenericFileDialog::SetDirectory( dir );
+#endif
}
void wxFileDialog::SetFilename(const wxString& name)
{
+#ifdef __WXGTK24__
m_fileName = name;
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
UpdateDialog();
-}
-
-void wxFileDialog::UpdateDialog()
-{
- // set currently selected directory to match the path:
- if (!m_dir.empty() && wxDirExists(m_dir))
- {
- // NB: This is important -- if we set directory only and not the path,
- // then dialog will still remember old path set using previous
- // call to gtk_chooser_set_filename. If the previous directory
- // was a subdirectory of the directory we want to select now,
- // the dialog would still contain directory selector controls
- // for the subdirectory (with the parent directory selected),
- // instead of showing only the parent directory as expected.
- // This way, we force GtkFileChooser to really change the
- // directory. Finally, it doesn't have to be done if filename
- // is not empty because of the code that sets the filename below.
- if (m_fileName.empty())
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_dir));
-
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_dir));
- }
-
- // if the user set only the directory (e.g. by calling SetDirectory)
- // and not the default filename, then we don't want to set the filename:
- if (!m_fileName.empty())
- {
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_path));
-
- // pre-fill the filename when saving, too (there's no text entry
- // control when opening a file, so it doesn't make sense to
- // do this when opening files):
- if (GetWindowStyle() & wxSAVE)
- {
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_fileName));
- }
- }
+#else
+ wxGenericFileDialog::SetFilename( name );
+#endif
}
void wxFileDialog::SetWildcard(const wxString& wildCard)
{
+#ifdef __WXGTK24__
m_wildCard = wildCard;
GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget);
gtk_file_chooser_add_filter(chooser, filter);
}
}
+#else
+ wxGenericFileDialog::SetWildcard( wildCard );
+#endif
}
void wxFileDialog::SetFilterIndex(int filterIndex)
{
+#ifdef __WXGTK24__
m_filterIndex = filterIndex;
GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget);
fnode = fnode->next;
}
g_slist_free(filters);
+#else
+ wxGenericFileDialog::SetFilterIndex( filterIndex );
+#endif
+}
+
+void wxFileDialog::UpdateDialog()
+{
+#ifdef __WXGTK24__
+ // set currently selected directory to match the path:
+ if (!m_dir.empty() && wxDirExists(m_dir))
+ {
+ // NB: This is important -- if we set directory only and not the path,
+ // then dialog will still remember old path set using previous
+ // call to gtk_chooser_set_filename. If the previous directory
+ // was a subdirectory of the directory we want to select now,
+ // the dialog would still contain directory selector controls
+ // for the subdirectory (with the parent directory selected),
+ // instead of showing only the parent directory as expected.
+ // This way, we force GtkFileChooser to really change the
+ // directory. Finally, it doesn't have to be done if filename
+ // is not empty because of the code that sets the filename below.
+ if (m_fileName.empty())
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_dir));
+
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_dir));
+ }
+
+ // if the user set only the directory (e.g. by calling SetDirectory)
+ // and not the default filename, then we don't want to set the filename:
+ if (!m_fileName.empty())
+ {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_path));
+
+ // pre-fill the filename when saving, too (there's no text entry
+ // control when opening a file, so it doesn't make sense to
+ // do this when opening files):
+ if (GetWindowStyle() & wxSAVE)
+ {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_fileName));
+ }
+ }
+#endif
}
void wxFileDialog::UpdateFromDialog()
{
+#ifdef __WXGTK24__
// update filterIndex
GSList *fnode = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(m_widget));
GSList *filters = fnode;
fnode = fnode->next;
}
g_slist_free(filters);
+#endif
}
-#endif // wxUSE_FILEDLG && defined(__WXGTK24__)
+#endif // wxUSE_FILEDLG
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#if wxUSE_FILEDLG && defined(__WXGTK24__)
+#if wxUSE_FILEDLG
#include "wx/filedlg.h"
#include "wx/utils.h"
#include "wx/msgdlg.h"
#include <gtk/gtk.h>
+
+#ifdef __WXGTK24__
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
dialog->m_destroyed_by_delete = TRUE;
}
}
+#endif
//-----------------------------------------------------------------------------
// wxFileDialog
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxFileDialogBase)
+IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxGenericFileDialog)
+
+BEGIN_EVENT_TABLE(wxFileDialog,wxGenericFileDialog)
+ EVT_BUTTON(wxID_OK, wxFileDialog::OnFakeOk)
+END_EVENT_TABLE()
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)
+ : wxGenericFileDialog(parent, message, defaultDir, defaultFileName,
+ wildCard, style, pos, true )
{
+#ifdef __WXGTK24__
m_needParent = FALSE;
m_destroyed_by_delete = FALSE;
SetWildcard(wildCard);
SetFilterIndex(0);
+#else
+ wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos );
+#endif
}
wxFileDialog::~wxFileDialog()
{
+#ifdef __WXGTK24__
if (m_destroyed_by_delete)
m_widget = NULL;
+#endif
+}
+
+void wxFileDialog::OnFakeOk( wxCommandEvent &event )
+{
+#ifdef __WXGTK24__
+ wxDialog::OnOK( event );
+#else
+ wxGenericFileDialog::OnListOk( event );
+#endif
+}
+
+int wxFileDialog::ShowModal()
+{
+#ifdef __WXGTK24__
+ return wxDialog::ShowModal();
+#else
+ return wxGenericFileDialog::ShowModal();
+#endif
+}
+
+bool wxFileDialog::Show( bool show )
+{
+#ifdef __WXGTK24__
+ return wxDialog::Show( show );
+#else
+ return wxGenericFileDialog::Show( show );
+#endif
}
void wxFileDialog::GetFilenames(wxArrayString& files) const
{
+#ifdef __WXGTK24__
GetPaths(files);
for (size_t n = 0; n < files.GetCount(); n++ )
{
}
files[n] = name;
}
+#else
+ wxGenericFileDialog::GetFilenames( files );
+#endif
}
void wxFileDialog::GetPaths(wxArrayString& paths) const
{
+#ifdef __WXGTK24__
paths.Empty();
if (GetWindowStyle() & wxMULTIPLE)
{
{
paths.Add(m_fileName);
}
+#else
+ wxGenericFileDialog::GetPaths( paths );
+#endif
}
void wxFileDialog::SetMessage(const wxString& message)
{
+#ifdef __WXGTK24__
m_message = message;
SetTitle(message);
+#else
+ wxGenericFileDialog::SetMessage( message );
+#endif
}
void wxFileDialog::SetPath(const wxString& path)
{
+#ifdef __WXGTK24__
if (path.empty()) return;
wxFileName fn(path);
m_dir = fn.GetPath();
m_fileName = fn.GetFullName();
UpdateDialog();
+#else
+ wxGenericFileDialog::SetPath( path );
+#endif
}
void wxFileDialog::SetDirectory(const wxString& dir)
{
+#ifdef __WXGTK24__
if (wxDirExists(dir))
{
m_dir = dir;
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
UpdateDialog();
}
+#else
+ wxGenericFileDialog::SetDirectory( dir );
+#endif
}
void wxFileDialog::SetFilename(const wxString& name)
{
+#ifdef __WXGTK24__
m_fileName = name;
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
UpdateDialog();
-}
-
-void wxFileDialog::UpdateDialog()
-{
- // set currently selected directory to match the path:
- if (!m_dir.empty() && wxDirExists(m_dir))
- {
- // NB: This is important -- if we set directory only and not the path,
- // then dialog will still remember old path set using previous
- // call to gtk_chooser_set_filename. If the previous directory
- // was a subdirectory of the directory we want to select now,
- // the dialog would still contain directory selector controls
- // for the subdirectory (with the parent directory selected),
- // instead of showing only the parent directory as expected.
- // This way, we force GtkFileChooser to really change the
- // directory. Finally, it doesn't have to be done if filename
- // is not empty because of the code that sets the filename below.
- if (m_fileName.empty())
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_dir));
-
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_dir));
- }
-
- // if the user set only the directory (e.g. by calling SetDirectory)
- // and not the default filename, then we don't want to set the filename:
- if (!m_fileName.empty())
- {
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_path));
-
- // pre-fill the filename when saving, too (there's no text entry
- // control when opening a file, so it doesn't make sense to
- // do this when opening files):
- if (GetWindowStyle() & wxSAVE)
- {
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
- wxGTK_CONV(m_fileName));
- }
- }
+#else
+ wxGenericFileDialog::SetFilename( name );
+#endif
}
void wxFileDialog::SetWildcard(const wxString& wildCard)
{
+#ifdef __WXGTK24__
m_wildCard = wildCard;
GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget);
gtk_file_chooser_add_filter(chooser, filter);
}
}
+#else
+ wxGenericFileDialog::SetWildcard( wildCard );
+#endif
}
void wxFileDialog::SetFilterIndex(int filterIndex)
{
+#ifdef __WXGTK24__
m_filterIndex = filterIndex;
GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget);
fnode = fnode->next;
}
g_slist_free(filters);
+#else
+ wxGenericFileDialog::SetFilterIndex( filterIndex );
+#endif
+}
+
+void wxFileDialog::UpdateDialog()
+{
+#ifdef __WXGTK24__
+ // set currently selected directory to match the path:
+ if (!m_dir.empty() && wxDirExists(m_dir))
+ {
+ // NB: This is important -- if we set directory only and not the path,
+ // then dialog will still remember old path set using previous
+ // call to gtk_chooser_set_filename. If the previous directory
+ // was a subdirectory of the directory we want to select now,
+ // the dialog would still contain directory selector controls
+ // for the subdirectory (with the parent directory selected),
+ // instead of showing only the parent directory as expected.
+ // This way, we force GtkFileChooser to really change the
+ // directory. Finally, it doesn't have to be done if filename
+ // is not empty because of the code that sets the filename below.
+ if (m_fileName.empty())
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_dir));
+
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_dir));
+ }
+
+ // if the user set only the directory (e.g. by calling SetDirectory)
+ // and not the default filename, then we don't want to set the filename:
+ if (!m_fileName.empty())
+ {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_path));
+
+ // pre-fill the filename when saving, too (there's no text entry
+ // control when opening a file, so it doesn't make sense to
+ // do this when opening files):
+ if (GetWindowStyle() & wxSAVE)
+ {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_fileName));
+ }
+ }
+#endif
}
void wxFileDialog::UpdateFromDialog()
{
+#ifdef __WXGTK24__
// update filterIndex
GSList *fnode = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(m_widget));
GSList *filters = fnode;
fnode = fnode->next;
}
g_slist_free(filters);
+#endif
}
-#endif // wxUSE_FILEDLG && defined(__WXGTK24__)
+#endif // wxUSE_FILEDLG