X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1db2c81b632c1de13442cc031eb5cc8b8fb18910..68ca12fef650ce4622e05ba4eb21a7aa23849107:/src/generic/filedlgg.cpp diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index e9ed4f83f5..066131180f 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; @@ -193,9 +198,6 @@ bool wxGenericFileDialog::Create( wxWindow *parent, if ((len > 1) && (wxEndsWithPathSeparator(m_dir))) m_dir.Remove( len-1, 1 ); - m_path = m_dir; - m_path += wxFILE_SEP_PATH; - m_path += defaultFile; m_filterExtension = wxEmptyString; // layout @@ -328,7 +330,6 @@ wxGenericFileDialog::~wxGenericFileDialog() int wxGenericFileDialog::ShowModal() { m_filectrl->SetDirectory(m_dir); - UpdateControls(); return wxDialog::ShowModal(); } @@ -340,23 +341,12 @@ bool wxGenericFileDialog::Show( bool show ) if (show) { m_filectrl->SetDirectory(m_dir); - UpdateControls(); } #endif return wxDialog::Show( show ); } -void wxGenericFileDialog::SetWildcard(const wxString& wildCard) -{ - m_filectrl->SetWildcard(wildCard); -} - -void wxGenericFileDialog::SetFilterIndex( int filterindex ) -{ - m_filectrl->SetFilterIndex(filterindex); -} - void wxGenericFileDialog::OnOk( wxCommandEvent &WXUNUSED(event) ) { wxArrayString selectedFiles; @@ -391,14 +381,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) ) @@ -412,32 +400,12 @@ void wxGenericFileDialog::OnFileActivated( wxFileCtrlEvent &WXUNUSED(event) ) OnOk( dummy ); } -void wxGenericFileDialog::SetPath( const wxString& path ) -{ - // not only set the full path but also update filename and dir - m_path = path; - - m_filectrl->SetPath(path); -} - -void wxGenericFileDialog::GetPaths( wxArrayString& paths ) const -{ - m_filectrl->GetPaths(paths); -} - -void wxGenericFileDialog::GetFilenames(wxArrayString& files) const +void wxGenericFileDialog::OnUpdateButtonsUI(wxUpdateUIEvent& event) { - m_filectrl->GetFilenames(files); -} - -void wxGenericFileDialog::UpdateControls() -{ - 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__) + // surprisingly, we can be called before m_filectrl is set in Create() as + // wxFileCtrl ctor itself can generate idle events, so we need this test + if ( m_filectrl ) + event.Enable( !IsTopMostDir(m_filectrl->GetShownDirectory()) ); } #ifdef wxHAS_GENERIC_FILEDIALOG