#include "wx/filectrl.h"
#include "wx/generic/filedlgg.h"
#include "wx/debug.h"
+#include "wx/modalhook.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#endif
+#if wxUSE_CONFIG
+ #include "wx/config.h"
+#endif
#ifndef __WXWINCE__
#include <sys/types.h>
#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)
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)
{
m_bypassGenericImpl = bypassGenericImpl;
- parent = GetParentForModalDialog(parent);
+ parent = GetParentForModalDialog(parent, style);
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile,
wildCard, style, pos, sz, name))
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
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) )
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 );
}
}
+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()
{
+ WX_HOOK_MODAL_DIALOG();
+
+ 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();
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;
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)
{
- event.Enable( !IsTopMostDir(m_filectrl->GetDirectory()) );
+ // 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