From e5dd66e9d26b7b5a0183a20b78a703ece2e57540 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Sep 2007 12:24:05 +0000 Subject: [PATCH] use update UI handler for the up and new directory buttons instead of manually updating the controls, this fixes a bug where up button wasn't enabled back after selecting a child of top level directory git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/filedlgg.h | 8 +++++--- src/generic/filedlgg.cpp | 18 +++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/wx/generic/filedlgg.h b/include/wx/generic/filedlgg.h index 661d7f88b7..f9dc8267ab 100644 --- a/include/wx/generic/filedlgg.h +++ b/include/wx/generic/filedlgg.h @@ -83,13 +83,14 @@ public: void OnNew( wxCommandEvent &event ); void OnFileActivated( wxFileCtrlEvent &event); - virtual void UpdateControls(); - private: - // Don't use this implementation at all :-) + // if true, don't use this implementation at all bool m_bypassGenericImpl; protected: + // update the state of m_upDirButton and m_newDirButton depending on the + // currently selected directory + void OnUpdateButtonsUI(wxUpdateUIEvent& event); wxString m_filterExtension; wxGenericFileCtrl *m_filectrl; @@ -98,6 +99,7 @@ protected: private: void Init(); + DECLARE_DYNAMIC_CLASS(wxGenericFileDialog) DECLARE_EVENT_TABLE() diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index e9ed4f83f5..e0525766a1 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -112,6 +112,11 @@ BEGIN_EVENT_TABLE(wxGenericFileDialog,wxDialog) EVT_BUTTON(ID_NEW_DIR, wxGenericFileDialog::OnNew) EVT_BUTTON(wxID_OK, wxGenericFileDialog::OnOk) EVT_FILECTRL_FILEACTIVATED(ID_FILE_CTRL, wxGenericFileDialog::OnFileActivated) + + EVT_UPDATE_UI(ID_UP_DIR, wxGenericFileDialog::OnUpdateButtonsUI) +#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) + EVT_UPDATE_UI(ID_NEW_DIR, wxGenericFileDialog::OnUpdateButtonsUI) +#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) END_EVENT_TABLE() long wxGenericFileDialog::ms_lastViewStyle = wxLC_LIST; @@ -328,7 +333,6 @@ wxGenericFileDialog::~wxGenericFileDialog() int wxGenericFileDialog::ShowModal() { m_filectrl->SetDirectory(m_dir); - UpdateControls(); return wxDialog::ShowModal(); } @@ -340,7 +344,6 @@ bool wxGenericFileDialog::Show( bool show ) if (show) { m_filectrl->SetDirectory(m_dir); - UpdateControls(); } #endif @@ -391,14 +394,12 @@ void wxGenericFileDialog::OnUp( wxCommandEvent &WXUNUSED(event) ) { m_filectrl->GoToParentDir(); m_filectrl->GetFileList()->SetFocus(); - UpdateControls(); } void wxGenericFileDialog::OnHome( wxCommandEvent &WXUNUSED(event) ) { m_filectrl->GoToHomeDir(); m_filectrl->SetFocus(); - UpdateControls(); } void wxGenericFileDialog::OnNew( wxCommandEvent &WXUNUSED(event) ) @@ -430,14 +431,9 @@ void wxGenericFileDialog::GetFilenames(wxArrayString& files) const m_filectrl->GetFilenames(files); } -void wxGenericFileDialog::UpdateControls() +void wxGenericFileDialog::OnUpdateButtonsUI(wxUpdateUIEvent& event) { - const bool enable = !IsTopMostDir(m_filectrl->GetDirectory()); - m_upDirButton->Enable(enable); - -#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) - m_newDirButton->Enable(enable); -#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) + event.Enable( !IsTopMostDir(m_filectrl->GetDirectory()) ); } #ifdef wxHAS_GENERIC_FILEDIALOG -- 2.45.2