- // 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;
- int 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();
- int 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::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();