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;
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
int wxGenericFileDialog::ShowModal()
{
m_filectrl->SetDirectory(m_dir);
- UpdateControls();
return wxDialog::ShowModal();
}
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;
{
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) )
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