misc fixes for wxDirDialog; new wxDD_CHANGE_DIR flag (patch 1478051)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39079 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-05-06 20:10:11 +00:00
parent 4523ebb3f1
commit 141d782d56
12 changed files with 85 additions and 111 deletions

View File

@@ -12,17 +12,16 @@ This class represents the directory chooser dialog.
\wxheading{Include files} \wxheading{Include files}
<wx/dirdlg.h> <wx/dirdlg.h>
<wx/generic/dirdlgg.h>
\wxheading{Window styles} \wxheading{Window styles}
\twocolwidtha{5cm} \begin{twocollist}\itemsep=0pt
\begin{twocollist}
\twocolitem{\windowstyle{wxDD\_DEFAULT\_STYLE}}{Equivalent to a combination of wxDEFAULT\_DIALOG\_STYLE, wxDD\_NEW\_DIR\_BUTTON and wxRESIZE\_BORDER (the last one is not used under wxWinCE).} \twocolitem{\windowstyle{wxDD\_DEFAULT\_STYLE}}{Equivalent to a combination of wxDEFAULT\_DIALOG\_STYLE, wxDD\_NEW\_DIR\_BUTTON and wxRESIZE\_BORDER (the last one is not used under wxWinCE).}
\twocolitem{\windowstyle{wxDD\_NEW\_DIR\_BUTTON}}{Add "Create new \twocolitem{\windowstyle{wxDD\_NEW\_DIR\_BUTTON}}{Add "Create new
directory" button and allow directory names to be editable. On directory" button and allow directory names to be editable. On
Windows the new directory button is only available with recent Windows the new directory button is only available with recent
versions of the common dialogs.} versions of the common dialogs.}
\twocolitem{\windowstyle{wxDD\_CHANGE\_DIR}}{Change the current working directory to the directory chosen by the user.}
\end{twocollist} \end{twocollist}
See also \helpref{Generic window styles}{windowstyles}. See also \helpref{Generic window styles}{windowstyles}.
@@ -78,12 +77,6 @@ Returns the default or user-selected path.
Returns the message that will be displayed on the dialog. Returns the message that will be displayed on the dialog.
\membersection{wxDirDialog::GetStyle}\label{wxdirdialoggetstyle}
\constfunc{long}{GetStyle}{\void}
Returns the dialog style.
\membersection{wxDirDialog::SetMessage}\label{wxdirdialogsetmessage} \membersection{wxDirDialog::SetMessage}\label{wxdirdialogsetmessage}
\func{void}{SetMessage}{\param{const wxString\& }{message}} \func{void}{SetMessage}{\param{const wxString\& }{message}}
@@ -96,12 +89,6 @@ Sets the message that will be displayed on the dialog.
Sets the default path. Sets the default path.
\membersection{wxDirDialog::SetStyle}\label{wxdirdialogsetstyle}
\func{void}{SetStyle}{\param{long }{style}}
Sets the dialog style. This is currently unused.
\membersection{wxDirDialog::ShowModal}\label{wxdirdialogshowmodal} \membersection{wxDirDialog::ShowModal}\label{wxdirdialogshowmodal}
\func{int}{ShowModal}{\void} \func{int}{ShowModal}{\void}

View File

@@ -33,15 +33,12 @@ public:
const wxString& name = wxDirDialogNameStr); const wxString& name = wxDirDialogNameStr);
~wxDirDialog(); ~wxDirDialog();
long GetStyle() const { return m_dialogStyle; }
virtual int ShowModal(); virtual int ShowModal();
inline WX_NSSavePanel GetNSSavePanel() inline WX_NSSavePanel GetNSSavePanel()
{ return (WX_NSSavePanel)m_cocoaNSWindow; } { return (WX_NSSavePanel)m_cocoaNSWindow; }
protected: protected:
long m_dialogStyle;
wxString m_dir; wxString m_dir;
wxWindow * m_parent; wxWindow * m_parent;
wxString m_fileName; wxString m_fileName;

View File

@@ -1711,6 +1711,8 @@ enum wxBorder
*/ */
#define wxDD_NEW_DIR_BUTTON 0x0080 #define wxDD_NEW_DIR_BUTTON 0x0080
#define wxDD_CHANGE_DIR 0x0100
/* /*
* extended dialog specifiers. these values are stored in a different * extended dialog specifiers. these values are stored in a different

View File

@@ -40,6 +40,7 @@ extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[];
class WXDLLEXPORT wxDirDialogBase : public wxDialog class WXDLLEXPORT wxDirDialogBase : public wxDialog
{ {
public: public:
wxDirDialogBase() {}
wxDirDialogBase(wxWindow *parent, wxDirDialogBase(wxWindow *parent,
const wxString& title = wxDirSelectorPromptStr, const wxString& title = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString, const wxString& defaultPath = wxEmptyString,
@@ -47,20 +48,34 @@ public:
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
const wxString& name = wxDirDialogNameStr) const wxString& name = wxDirDialogNameStr)
: wxDialog(parent, wxID_ANY, title, pos, sz, style, name) {
, m_path(defaultPath) Create(parent, title, defaultPath, style, pos, sz, name);
{} }
wxDirDialogBase() {}
virtual ~wxDirDialogBase() {} virtual ~wxDirDialogBase() {}
bool Create(wxWindow *parent,
const wxString& title = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxDirDialogNameStr)
{
if (!wxDialog::Create(parent, wxID_ANY, title, pos, sz, style, name))
return false;
m_path = defaultPath;
m_message = title;
return true;
}
virtual void SetMessage(const wxString& message) { m_message = message; } virtual void SetMessage(const wxString& message) { m_message = message; }
virtual void SetPath(const wxString& path) { m_path = path; } virtual void SetPath(const wxString& path) { m_path = path; }
virtual void SetStyle(long style) { SetWindowStyle(style); }
virtual wxString GetMessage() const { return m_message; } virtual wxString GetMessage() const { return m_message; }
virtual wxString GetPath() const { return m_path; } virtual wxString GetPath() const { return m_path; }
virtual long GetStyle() const { return GetWindowStyle(); }
protected: protected:
wxString m_message; wxString m_message;

View File

@@ -22,8 +22,8 @@ class WXDLLEXPORT wxTreeEvent;
// we may be included directly as well as from wx/dirdlg.h (FIXME) // we may be included directly as well as from wx/dirdlg.h (FIXME)
extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogNameStr[]; extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogNameStr[];
extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[]; extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[];
#ifndef wxDD_DEFAULT_STYLE
#ifndef wxDD_DEFAULT_STYLE
#ifdef __WXWINCE__ #ifdef __WXWINCE__
#define wxDD_DEFAULT_STYLE \ #define wxDD_DEFAULT_STYLE \
(wxDEFAULT_DIALOG_STYLE | wxDD_NEW_DIR_BUTTON) (wxDEFAULT_DIALOG_STYLE | wxDD_NEW_DIR_BUTTON)
@@ -62,13 +62,11 @@ public:
//// Accessors //// Accessors
void SetPath(const wxString& path); void SetPath(const wxString& path);
void SetStyle(long style) { m_dialogStyle = style; }
wxString GetPath() const; wxString GetPath() const;
long GetStyle() const { return m_dialogStyle; }
//// Overrides //// Overrides
virtual int ShowModal(); virtual int ShowModal();
virtual void EndModal(int retCode);
// this one is specific to wxGenericDirDialog // this one is specific to wxGenericDirDialog
wxTextCtrl* GetInputCtrl() const { return m_input; } wxTextCtrl* GetInputCtrl() const { return m_input; }
@@ -83,7 +81,6 @@ protected:
void OnGoHome(wxCommandEvent& event); void OnGoHome(wxCommandEvent& event);
void OnShowHidden(wxCommandEvent& event); void OnShowHidden(wxCommandEvent& event);
long m_dialogStyle;
wxGenericDirCtrl* m_dirCtrl; wxGenericDirCtrl* m_dirCtrl;
wxTextCtrl* m_input; wxTextCtrl* m_input;

View File

@@ -23,7 +23,7 @@ public:
wxDirDialogGTK(wxWindow *parent, wxDirDialogGTK(wxWindow *parent,
const wxString& message = wxDirSelectorPromptStr, const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = _T(""), const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE, long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,

View File

@@ -23,13 +23,9 @@ public:
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
const wxString& name = wxDirDialogNameStr); const wxString& name = wxDirDialogNameStr);
void SetStyle(long style) { m_dialogStyle = style; }
long GetStyle() const { return m_dialogStyle; }
virtual int ShowModal(); virtual int ShowModal();
protected: protected:
long m_dialogStyle;
wxWindow * m_parent; wxWindow * m_parent;
DECLARE_DYNAMIC_CLASS(wxDirDialog) DECLARE_DYNAMIC_CLASS(wxDirDialog)

View File

@@ -23,13 +23,9 @@ public:
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
const wxString& name = wxDirDialogNameStr); const wxString& name = wxDirDialogNameStr);
void SetStyle(long style) { m_dialogStyle = style; }
long GetStyle() const { return m_dialogStyle; }
virtual int ShowModal(); virtual int ShowModal();
protected: protected:
long m_dialogStyle;
wxWindow * m_parent; wxWindow * m_parent;
DECLARE_DYNAMIC_CLASS(wxDirDialog) DECLARE_DYNAMIC_CLASS(wxDirDialog)

View File

@@ -24,13 +24,9 @@ public:
const wxString& defaultPath = "", const wxString& defaultPath = "",
long style = 0, const wxPoint& pos = wxDefaultPosition); long style = 0, const wxPoint& pos = wxDefaultPosition);
inline void SetStyle(long style) { m_dialogStyle = style; }
inline long GetStyle() const { return m_dialogStyle; }
int ShowModal(); int ShowModal();
protected: protected:
long m_dialogStyle;
wxWindow * m_parent; wxWindow * m_parent;
}; };

View File

@@ -78,21 +78,23 @@ END_EVENT_TABLE()
wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title, wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
const wxString& defaultPath, long style, const wxString& defaultPath, long style,
const wxPoint& pos, const wxSize& sz, const wxPoint& pos, const wxSize& sz,
const wxString& name): const wxString& name)
wxDirDialogBase(parent, title, defaultPath, style, pos, sz, name)
{ {
Create(parent, title, defaultPath, style, pos, sz, name); Create(parent, title, defaultPath, style, pos, sz, name);
} }
bool wxGenericDirDialog::Create(wxWindow* WXUNUSED(parent), bool wxGenericDirDialog::Create(wxWindow* parent,
const wxString& WXUNUSED(title), const wxString& title,
const wxString& defaultPath, long style, const wxString& defaultPath, long style,
const wxPoint& WXUNUSED(pos), const wxPoint& pos,
const wxSize& WXUNUSED(sz), const wxSize& sz,
const wxString& WXUNUSED(name)) const wxString& name)
{ {
wxBusyCursor cursor; wxBusyCursor cursor;
if (!wxDirDialogBase::Create(parent, title, defaultPath, style, pos, sz, name))
return false;
m_path = defaultPath; m_path = defaultPath;
if (m_path == wxT("~")) if (m_path == wxT("~"))
wxGetHomeDir(&m_path); wxGetHomeDir(&m_path);
@@ -211,6 +213,15 @@ bool wxGenericDirDialog::Create(wxWindow* WXUNUSED(parent),
return true; return true;
} }
void wxGenericDirDialog::EndModal(int retCode)
{
// before proceeding, change the current working directory if user asked so
if (retCode == wxID_OK && HasFlag(wxDD_CHANGE_DIR))
wxSetWorkingDirectory(m_path);
wxDialog::EndModal(retCode);
}
void wxGenericDirDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) void wxGenericDirDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{ {
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
@@ -219,12 +230,15 @@ void wxGenericDirDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
void wxGenericDirDialog::OnOK(wxCommandEvent& WXUNUSED(event)) void wxGenericDirDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{ {
m_path = m_input->GetValue(); m_path = m_input->GetValue();
// Does the path exist? (User may have typed anything in m_input) // Does the path exist? (User may have typed anything in m_input)
if (wxDirExists(m_path)) { if (wxDirExists(m_path))
{
// OK, path exists, we're done. // OK, path exists, we're done.
EndModal(wxID_OK); EndModal(wxID_OK);
return; return;
} }
// Interact with user, find out if the dir is a typo or to be created // Interact with user, find out if the dir is a typo or to be created
wxString msg; wxString msg;
msg.Printf(_("The directory '%s' does not exist\nCreate it now?"), msg.Printf(_("The directory '%s' does not exist\nCreate it now?"),
@@ -232,15 +246,18 @@ void wxGenericDirDialog::OnOK(wxCommandEvent& WXUNUSED(event))
wxMessageDialog dialog(this, msg, _("Directory does not exist"), wxMessageDialog dialog(this, msg, _("Directory does not exist"),
wxYES_NO | wxICON_WARNING); wxYES_NO | wxICON_WARNING);
if ( dialog.ShowModal() == wxID_YES ) { if ( dialog.ShowModal() == wxID_YES )
{
// Okay, let's make it // Okay, let's make it
wxLogNull log; wxLogNull log;
if (wxMkdir(m_path)) { if (wxMkdir(m_path))
{
// The new dir was created okay. // The new dir was created okay.
EndModal(wxID_OK); EndModal(wxID_OK);
return; return;
} }
else { else
{
// Trouble... // Trouble...
msg.Printf(_("Failed to create directory '%s'\n(Do you have the required permissions?)"), msg.Printf(_("Failed to create directory '%s'\n(Do you have the required permissions?)"),
m_path.c_str()); m_path.c_str());

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/dirdlg.cpp // Name: src/gtk/dirdlg.cpp
// Purpose: native implementation of wxDirDialog // Purpose: native implementation of wxDirDialogGTK
// Author: Robert Roebling, Zbigniew Zagorski, Mart Raudsepp, Francesco Montorsi // Author: Robert Roebling, Zbigniew Zagorski, Mart Raudsepp, Francesco Montorsi
// Id: $Id$ // Id: $Id$
// Copyright: (c) 1998 Robert Roebling, 2004 Zbigniew Zagorski, 2005 Mart Raudsepp // Copyright: (c) 1998 Robert Roebling, 2004 Zbigniew Zagorski, 2005 Mart Raudsepp
@@ -13,7 +13,7 @@
/* /*
NOTE: the GtkFileChooser interface can be used both for wxFileDialog and for wxDirDialog. NOTE: the GtkFileChooser interface can be used both for wxFileDialog and for wxDirDialogGTK.
Thus following code is very similar (even if not identic) to src/gtk/filedlg.cpp 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 you find a problem in this code, remember to check also that file !
*/ */
@@ -29,17 +29,13 @@
#include "wx/filedlg.h" #include "wx/filedlg.h"
#endif #endif
#ifdef __WXGTK24__ #ifdef __WXGTK24__ // only for GTK+ > 2.4 there is GtkFileChooserDialog
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include <unistd.h> // chdir #include <unistd.h> // chdir
#include "wx/filename.h" // wxFilename
#include "wx/tokenzr.h" // wxStringTokenizer
#include "wx/filefn.h" // ::wxGetCwd
#include "wx/msgdlg.h" // wxMessageDialog
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -52,43 +48,13 @@ extern void wxapp_install_idle_handler();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" { extern "C" {
static void gtk_filedialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog) static void gtk_filedialog_ok_callback(GtkWidget *widget, wxDirDialogGTK *dialog)
{ {
int style = dialog->GetStyle();
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); 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 ( g_file_test(filename, G_FILE_TEST_EXISTS) )
{
wxString msg;
msg.Printf(
_("File '%s' already exists, do you really want to overwrite it?"),
wxString(wxConvFileName->cMB2WX(filename)).c_str());
wxMessageDialog dlg(dialog, msg, _("Confirm"),
wxYES_NO | wxICON_QUESTION);
if (dlg.ShowModal() != wxID_YES)
{
g_free(filename);
return;
}
}
}
// change to the directory where the user went if asked // change to the directory where the user went if asked
if (style & wxCHANGE_DIR) if (dialog->HasFlag(wxDD_CHANGE_DIR))
{ chdir(filename);
// Use chdir to not care about filename encodings
gchar* folder = g_path_get_dirname(filename);
chdir(folder);
g_free(folder);
}
g_free(filename); g_free(filename);
@@ -104,7 +70,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog)
extern "C" { extern "C" {
static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w),
wxDirDialog *dialog) wxDirDialogGTK *dialog)
{ {
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject(dialog); event.SetEventObject(dialog);
@@ -115,7 +81,7 @@ static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w),
extern "C" { extern "C" {
static void gtk_filedialog_response_callback(GtkWidget *w, static void gtk_filedialog_response_callback(GtkWidget *w,
gint response, gint response,
wxDirDialog *dialog) wxDirDialogGTK *dialog)
{ {
wxapp_install_idle_handler(); wxapp_install_idle_handler();
@@ -134,16 +100,16 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
#endif // __WXGTK24__ #endif // __WXGTK24__
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxDirDialog // wxDirDialogGTK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxDirDialog,wxGenericDirDialog) IMPLEMENT_DYNAMIC_CLASS(wxDirDialogGTK,wxGenericDirDialog)
BEGIN_EVENT_TABLE(wxDirDialog,wxGenericDirDialog) BEGIN_EVENT_TABLE(wxDirDialogGTK,wxGenericDirDialog)
EVT_BUTTON(wxID_OK, wxDirDialog::OnFakeOk) EVT_BUTTON(wxID_OK, wxDirDialogGTK::OnFakeOk)
END_EVENT_TABLE() END_EVENT_TABLE()
wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title, wxDirDialogGTK::wxDirDialogGTK(wxWindow* parent, const wxString& title,
const wxString& defaultPath, long style, const wxString& defaultPath, long style,
const wxPoint& pos, const wxSize& sz, const wxPoint& pos, const wxSize& sz,
const wxString& name) const wxString& name)
@@ -159,7 +125,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
wxDefaultValidator, wxT("filedialog"))) wxDefaultValidator, wxT("filedialog")))
{ {
wxFAIL_MSG( wxT("wxDirDialog creation failed") ); wxFAIL_MSG( wxT("wxDirDialogGTK creation failed") );
return; return;
} }
@@ -199,7 +165,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name); wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
} }
wxDirDialog::~wxDirDialog() wxDirDialogGTK::~wxDirDialogGTK()
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -210,7 +176,7 @@ wxDirDialog::~wxDirDialog()
#endif #endif
} }
void wxDirDialog::OnFakeOk( wxCommandEvent &event ) void wxDirDialogGTK::OnFakeOk( wxCommandEvent &event )
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -220,7 +186,7 @@ void wxDirDialog::OnFakeOk( wxCommandEvent &event )
wxGenericDirDialog::OnOK( event ); wxGenericDirDialog::OnOK( event );
} }
int wxDirDialog::ShowModal() int wxDirDialogGTK::ShowModal()
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -230,7 +196,7 @@ int wxDirDialog::ShowModal()
return wxGenericDirDialog::ShowModal(); return wxGenericDirDialog::ShowModal();
} }
bool wxDirDialog::Show( bool show ) bool wxDirDialogGTK::Show( bool show )
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -240,7 +206,7 @@ bool wxDirDialog::Show( bool show )
return wxGenericDirDialog::Show( show ); return wxGenericDirDialog::Show( show );
} }
void wxDirDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags ) void wxDirDialogGTK::DoSetSize(int x, int y, int width, int height, int sizeFlags )
{ {
if (!m_wxwindow) if (!m_wxwindow)
return; return;
@@ -248,7 +214,7 @@ void wxDirDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags )
wxGenericDirDialog::DoSetSize( x, y, width, height, sizeFlags ); wxGenericDirDialog::DoSetSize( x, y, width, height, sizeFlags );
} }
void wxDirDialog::SetPath(const wxString& dir) void wxDirDialogGTK::SetPath(const wxString& dir)
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -263,7 +229,7 @@ void wxDirDialog::SetPath(const wxString& dir)
wxGenericDirDialog::SetPath( dir ); wxGenericDirDialog::SetPath( dir );
} }
wxString wxDirDialog::GetPath() const wxString wxDirDialogGTK::GetPath() const
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))

View File

@@ -26,7 +26,8 @@
#if wxUSE_DIRDLG #if wxUSE_DIRDLG
#if wxUSE_OLE && !defined(__GNUWIN32_OLD__) && (!defined(__WXWINCE__) || (defined(__HANDHELDPC__) && (_WIN32_WCE >= 500))) #if wxUSE_OLE && !defined(__GNUWIN32_OLD__) && (!defined(__WXWINCE__) || \
(defined(__HANDHELDPC__) && (_WIN32_WCE >= 500)))
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/utils.h" #include "wx/utils.h"
@@ -89,7 +90,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent,
m_message = message; m_message = message;
m_parent = parent; m_parent = parent;
SetStyle(style); SetWindowStyle(style);
SetPath(defaultPath); SetPath(defaultPath);
} }
@@ -181,6 +182,10 @@ int wxDirDialog::ShowModal()
m_path = pidl.GetPath(); m_path = pidl.GetPath();
// change current working directory if asked so
if (HasFlag(wxDD_CHANGE_DIR))
wxSetWorkingDirectory(m_path);
return m_path.empty() ? wxID_CANCEL : wxID_OK; return m_path.empty() ? wxID_CANCEL : wxID_OK;
} }