#include <wx/wx.h>
#include <wx/stdpaths.h>
+#include <wx/filepicker.h>
#include <boost/filesystem.hpp>
#include "dir_picker_ctrl.h"
#include "wx_util.h"
SetSizerAndFit (_sizer);
- _browse->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (DirPickerCtrl::browse_clicked), 0, this);
-
- /* Do this after the fit so that our folder label stays long */
- SetPath (wxStandardPaths::Get().GetDocumentsDir());
+ _browse->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DirPickerCtrl::browse_clicked, this));
}
void
if (_path == wxStandardPaths::Get().GetDocumentsDir()) {
_folder->SetLabel (_("My Documents"));
} else {
-#if BOOST_FILESYSTEM_VERSION == 3
_folder->SetLabel (std_to_wx (filesystem::path (wx_to_std (_path)).leaf().string()));
-#else
- _folder->SetLabel (std_to_wx (filesystem::path (wx_to_std (_path)).leaf()));
-#endif
}
+
+ wxCommandEvent ev (wxEVT_COMMAND_DIRPICKER_CHANGED, wxID_ANY);
+ GetEventHandler()->ProcessEvent (ev);
}
wxString
}
void
-DirPickerCtrl::browse_clicked (wxCommandEvent &)
+DirPickerCtrl::browse_clicked ()
{
wxDirDialog* d = new wxDirDialog (this);
- d->ShowModal ();
- SetPath (d->GetPath ());
+ if (d->ShowModal () == wxID_OK) {
+ SetPath (d->GetPath ());
+ }
d->Destroy ();
}