X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/91a865a4fa39ac6c911d537af12169e53eb43314..9c805dec6caf3c98a3797898cffe795b5b56e606:/src/generic/filedlgg.cpp diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index bad3e2c6ec..f34ff0a9ed 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -19,7 +19,7 @@ #if wxUSE_FILEDLG // NOTE : it probably also supports MAC, untested -#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__) +#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__) && !defined(__PALMOS__) #error wxGenericFileDialog currently only supports Unix, win32 and DOS #endif @@ -53,7 +53,11 @@ #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif +#if wxUSE_CONFIG + #include "wx/config.h" +#endif +#ifndef __WXPALMOS5__ #ifndef __WXWINCE__ #include #include @@ -82,6 +86,7 @@ #if defined(__UNIX__) || defined(__DOS__) #include #endif +#endif // ! __WXPALMOS5__ #if defined(__WXWINCE__) #define IsTopMostDir(dir) (dir == wxT("\\") || dir == wxT("/")) @@ -98,7 +103,7 @@ #define ID_LIST_MODE (wxID_FILEDLGG ) #define ID_REPORT_MODE (wxID_FILEDLGG + 1) #define ID_UP_DIR (wxID_FILEDLGG + 2) -#define ID_PARENT_DIR (wxID_FILEDLGG + 3) +#define ID_HOME_DIR (wxID_FILEDLGG + 3) #define ID_NEW_DIR (wxID_FILEDLGG + 4) #define ID_FILE_CTRL (wxID_FILEDLGG + 5) @@ -108,7 +113,7 @@ BEGIN_EVENT_TABLE(wxGenericFileDialog,wxDialog) EVT_BUTTON(ID_LIST_MODE, wxGenericFileDialog::OnList) EVT_BUTTON(ID_REPORT_MODE, wxGenericFileDialog::OnReport) EVT_BUTTON(ID_UP_DIR, wxGenericFileDialog::OnUp) - EVT_BUTTON(ID_PARENT_DIR, wxGenericFileDialog::OnHome) + EVT_BUTTON(ID_HOME_DIR, wxGenericFileDialog::OnHome) EVT_BUTTON(ID_NEW_DIR, wxGenericFileDialog::OnNew) EVT_BUTTON(wxID_OK, wxGenericFileDialog::OnOk) EVT_FILECTRL_FILEACTIVATED(ID_FILE_CTRL, wxGenericFileDialog::OnFileActivated) @@ -159,7 +164,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent, { m_bypassGenericImpl = bypassGenericImpl; - parent = GetParentForModalDialog(parent); + parent = GetParentForModalDialog(parent, style); if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name)) @@ -198,9 +203,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 @@ -210,54 +212,28 @@ bool wxGenericFileDialog::Create( wxWindow *parent, wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *buttonsizer = new wxBoxSizer( wxHORIZONTAL ); - - wxBitmapButton *but; - - but = new wxBitmapButton(this, ID_LIST_MODE, - wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_BUTTON)); -#if wxUSE_TOOLTIPS - but->SetToolTip( _("View files as a list view") ); -#endif - buttonsizer->Add( but, 0, wxALL, 5 ); - - but = new wxBitmapButton(this, ID_REPORT_MODE, - wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_BUTTON)); -#if wxUSE_TOOLTIPS - but->SetToolTip( _("View files as a detailed view") ); -#endif - buttonsizer->Add( but, 0, wxALL, 5 ); - + AddBitmapButton( ID_LIST_MODE, wxART_LIST_VIEW, + _("View files as a list view"), buttonsizer ); + AddBitmapButton( ID_REPORT_MODE, wxART_REPORT_VIEW, + _("View files as a detailed view"), buttonsizer ); buttonsizer->Add( 30, 5, 1 ); - - m_upDirButton = new wxBitmapButton(this, ID_UP_DIR, - wxArtProvider::GetBitmap(wxART_GO_DIR_UP, wxART_BUTTON)); -#if wxUSE_TOOLTIPS - m_upDirButton->SetToolTip( _("Go to parent directory") ); -#endif - buttonsizer->Add( m_upDirButton, 0, wxALL, 5 ); + m_upDirButton = AddBitmapButton( ID_UP_DIR, wxART_GO_DIR_UP, + _("Go to parent directory"), buttonsizer ); #ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS... - but = new wxBitmapButton(this, ID_PARENT_DIR, - wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_BUTTON)); -#if wxUSE_TOOLTIPS - but->SetToolTip( _("Go to home directory") ); -#endif - buttonsizer->Add( but, 0, wxALL, 5); - + AddBitmapButton( ID_HOME_DIR, wxART_GO_HOME, + _("Go to home directory"), buttonsizer ); buttonsizer->Add( 20, 20 ); #endif //!__DOS__ - m_newDirButton = new wxBitmapButton(this, ID_NEW_DIR, - wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_BUTTON)); -#if wxUSE_TOOLTIPS - m_newDirButton->SetToolTip( _("Create new directory") ); -#endif - buttonsizer->Add( m_newDirButton, 0, wxALL, 5 ); + m_newDirButton = AddBitmapButton( ID_NEW_DIR, wxART_NEW_DIR, + _("Create new directory"), buttonsizer ); if (is_pda) - mainsizer->Add( buttonsizer, 0, wxALL | wxEXPAND, 0 ); + mainsizer->Add( buttonsizer, wxSizerFlags().Expand() ); else - mainsizer->Add( buttonsizer, 0, wxALL | wxEXPAND, 5 ); + mainsizer->Add( buttonsizer, wxSizerFlags().Expand() + .Border( wxLEFT | wxRIGHT | wxTOP ) ); long style2 = 0; if ( HasFdFlag(wxFD_MULTIPLE) ) @@ -281,31 +257,21 @@ bool wxGenericFileDialog::Create( wxWindow *parent, m_filectrl->ChangeToReportMode(); } - if (is_pda) - { - // PDAs have a different screen layout - mainsizer->Add(m_filectrl, wxSizerFlags(1).Expand().HorzBorder()); + mainsizer->Add(m_filectrl, wxSizerFlags(1).Expand().HorzBorder()); - wxSizer *bsizer = CreateButtonSizer(wxOK | wxCANCEL); - if ( bsizer ) + wxSizer *bsizer = CreateButtonSizer(wxOK | wxCANCEL); + if ( bsizer ) + { + if (is_pda) mainsizer->Add(bsizer, wxSizerFlags().Expand().Border()); + else + mainsizer->Add(bsizer, wxSizerFlags().Expand().DoubleBorder()); } - else // !is_pda - { - mainsizer->Add(m_filectrl, wxSizerFlags(1).Expand().DoubleHorzBorder()); - - wxBoxSizer *okcancelsizer = new wxBoxSizer( wxHORIZONTAL ); - okcancelsizer->Add(new wxButton(this, wxID_OK), wxSizerFlags().DoubleBorder().Centre()); - okcancelsizer->Add(new wxButton(this, wxID_CANCEL), wxSizerFlags().DoubleBorder().Centre()); - mainsizer->Add(okcancelsizer, wxSizerFlags().Center()); - } - SetAutoLayout( true ); SetSizer( mainsizer ); if (!is_pda) { - mainsizer->Fit( this ); mainsizer->SetSizeHints( this ); Centre( wxBOTH ); @@ -330,8 +296,28 @@ wxGenericFileDialog::~wxGenericFileDialog() } } +wxBitmapButton* wxGenericFileDialog::AddBitmapButton( wxWindowID winId, + const wxArtID& artId, + const wxString& tip, + wxSizer *sizer) +{ + wxBitmapButton *but = new wxBitmapButton(this, winId, + wxArtProvider::GetBitmap(artId, wxART_BUTTON)); + but->SetToolTip(tip); + sizer->Add(but, wxSizerFlags().Border()); + return but; +} + int wxGenericFileDialog::ShowModal() { + if (CreateExtraControl()) + { + wxSizer *sizer = GetSizer(); + sizer->Insert(2 /* after m_filectrl */, m_extraControl, + wxSizerFlags().Expand().HorzBorder()); + sizer->Fit(this); + } + m_filectrl->SetDirectory(m_dir); return wxDialog::ShowModal(); @@ -350,16 +336,6 @@ bool wxGenericFileDialog::Show( bool show ) 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; @@ -413,30 +389,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 -{ - m_filectrl->GetFilenames(files); -} - void wxGenericFileDialog::OnUpdateButtonsUI(wxUpdateUIEvent& event) { // 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->GetDirectory()) ); + event.Enable( !IsTopMostDir(m_filectrl->GetShownDirectory()) ); } #ifdef wxHAS_GENERIC_FILEDIALOG