- wxString res = m_dirName + wxT("/*");
- wxString f( wxFindFirstFile( res.GetData(), wxDIR ) );
- while (!f.IsEmpty())
- {
- res = wxFileNameFromPath( f );
- fd = new wxFileData( res, f );
- wxString s = fd->GetName();
- if (m_showHidden || (s[0u] != wxT('.')))
- {
- Add( fd, item );
- item.m_itemId++;
- }
- f = wxFindNextFile();
- }
-
- res = m_dirName + wxT("/") + m_wild;
- f = wxFindFirstFile( res.GetData(), wxFILE );
- while (!f.IsEmpty())
- {
- res = wxFileNameFromPath( f );
- fd = new wxFileData( res, f );
- wxString s = fd->GetName();
- if (m_showHidden || (s[0u] != wxT('.')))
- {
- Add( fd, item );
- item.m_itemId++;
- }
- f = wxFindNextFile();
- }
-
- SortItems( ListCompare, 0 );
-
- if (my_style & wxLC_REPORT)
- {
- SetColumnWidth( 1, wxLIST_AUTOSIZE );
- SetColumnWidth( 2, wxLIST_AUTOSIZE );
- SetColumnWidth( 3, wxLIST_AUTOSIZE );
- }
-}
-
-void wxFileCtrl::SetWild( const wxString &wild )
-{
- m_wild = wild;
- Update();
-}
-
-void wxFileCtrl::MakeDir()
-{
- wxString new_name( wxT("NewName") );
- wxString path( m_dirName );
- path += wxT("/");
- path += new_name;
- if (wxFileExists(path))
- {
- // try NewName0, NewName1 etc.
- int i = 0;
- do {
- new_name = _("NewName");
- wxString num;
- num.Printf( wxT("%d"), i );
- new_name += num;
-
- path = m_dirName;
- path += wxT("/");
- path += new_name;
- i++;
- } while (wxFileExists(path));
- }
-
- wxLogNull log;
- if (!wxMkdir(path))
- {
- wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
- dialog.ShowModal();
- return;
- }
-
- wxFileData *fd = new wxFileData( new_name, path );
- wxListItem item;
- item.m_itemId = 0;
- item.m_col = 0;
- long id = Add( fd, item );
-
- if (id != -1)
- {
- SortItems( ListCompare, 0 );
- id = FindItem( 0, (long)fd );
- EnsureVisible( id );
- EditLabel( id );
- }
-}
-
-void wxFileCtrl::GoToParentDir()
-{
- if (m_dirName != wxT("/"))
- {
- wxString fname( wxFileNameFromPath(m_dirName) );
- m_dirName = wxPathOnly( m_dirName );
- if (m_dirName.IsEmpty()) m_dirName = wxT("/");
- Update();
- long id = FindItem( 0, fname );
- if (id != -1)
- {
- SetItemState( id, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
- EnsureVisible( id );
- }
- }
-}
-
-void wxFileCtrl::GoToHomeDir()
-{
- wxString s = wxGetUserHome( wxString() );
- m_dirName = s;
- Update();
- SetItemState( 0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
- EnsureVisible( 0 );
-}
-
-void wxFileCtrl::GoToDir( const wxString &dir )
-{
- m_dirName = dir;
- Update();
- SetItemState( 0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
- EnsureVisible( 0 );
-}
-
-void wxFileCtrl::GetDir( wxString &dir )
-{
- dir = m_dirName;
-}
-
-void wxFileCtrl::OnListDeleteItem( wxListEvent &event )
-{
- wxFileData *fd = (wxFileData*)event.m_item.m_data;
- delete fd;
-}
-
-void wxFileCtrl::OnListDeleteAllItems( wxListEvent &WXUNUSED(event) )
-{
- wxListItem item;
- item.m_mask = wxLIST_MASK_DATA;
-
- item.m_itemId = GetNextItem( -1, wxLIST_NEXT_ALL );
- while ( item.m_itemId != -1 )
- {
- GetItem( item );
- wxFileData *fd = (wxFileData*)item.m_data;
- delete fd;
- item.m_data = 0;
- SetItem( item );
- item.m_itemId = GetNextItem( item.m_itemId, wxLIST_NEXT_ALL );
- }
-}
-
-void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event )
-{
- wxFileData *fd = (wxFileData*)event.m_item.m_data;
- wxASSERT( fd );
-
- if ((event.GetLabel().IsEmpty()) ||
- (event.GetLabel() == _(".")) ||
- (event.GetLabel() == _("..")) ||
- (event.GetLabel().First( wxT("/") ) != wxNOT_FOUND))
- {
- wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
- dialog.ShowModal();
- event.Veto();
- return;
- }
-
- wxString new_name( wxPathOnly( fd->GetFullName() ) );
- new_name += wxT("/");
- new_name += event.GetLabel();
-
- wxLogNull log;
-
- if (wxFileExists(new_name))
- {
- wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
- dialog.ShowModal();
- event.Veto();
- }
-
- if (wxRenameFile(fd->GetFullName(),new_name))
- {
- fd->SetNewName( new_name, event.GetLabel() );
- SetItemState( event.GetItem(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
- EnsureVisible( event.GetItem() );
- }
- else
- {
- wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
- dialog.ShowModal();
- event.Veto();
- }
-}
-
-//-----------------------------------------------------------------------------
-// wxFileDialog
-//-----------------------------------------------------------------------------
-
-#define ID_LIST_MODE wxID_FILEDLGG
-#define ID_REPORT_MODE wxID_FILEDLGG + 1
-#define ID_UP_DIR wxID_FILEDLGG + 5
-#define ID_PARENT_DIR wxID_FILEDLGG + 6
-#define ID_NEW_DIR wxID_FILEDLGG + 7
-#define ID_CHOICE wxID_FILEDLGG + 8
-#define ID_TEXT wxID_FILEDLGG + 9
-#define ID_LIST_CTRL wxID_FILEDLGG + 10
-#define ID_ACTIVATED wxID_FILEDLGG + 11
-#define ID_CHECK wxID_FILEDLGG + 12
-
-IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxDialog)
-
-BEGIN_EVENT_TABLE(wxFileDialog,wxDialog)
- EVT_BUTTON(ID_LIST_MODE, wxFileDialog::OnList)
- EVT_BUTTON(ID_REPORT_MODE, wxFileDialog::OnReport)
- EVT_BUTTON(ID_UP_DIR, wxFileDialog::OnUp)
- EVT_BUTTON(ID_PARENT_DIR, wxFileDialog::OnHome)
- EVT_BUTTON(ID_NEW_DIR, wxFileDialog::OnNew)
- EVT_BUTTON(wxID_OK, wxFileDialog::OnListOk)
- EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL, wxFileDialog::OnSelected)
- EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL, wxFileDialog::OnActivated)
- EVT_CHOICE(ID_CHOICE,wxFileDialog::OnChoice)
- EVT_TEXT_ENTER(ID_TEXT,wxFileDialog::OnTextEnter)
- EVT_CHECKBOX(ID_CHECK,wxFileDialog::OnCheck)
-END_EVENT_TABLE()
-
-long wxFileDialog::s_lastViewStyle = wxLC_LIST;
-bool wxFileDialog::s_lastShowHidden = FALSE;
-
-wxFileDialog::wxFileDialog(wxWindow *parent,
- const wxString& message,
- const wxString& defaultDir,
- const wxString& defaultFile,
- const wxString& wildCard,
- long style,
- const wxPoint& pos ) :
- wxDialog( parent, -1, message, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
-{
- wxBeginBusyCursor();
-
- if (wxConfig::Get(FALSE))