- if (dir_item->m_hasSubDirs) SetItemHasChildren(id);
- }
-}
-
-void wxDirCtrl::OnBeginEditItem(wxTreeEvent &event)
-{
- // don't rename the main entry "Sections"
- if (event.GetItem() == m_rootId)
- {
- event.Veto();
- return;
- }
-
- // don't rename the individual sections
- if (GetParent( event.GetItem() ) == m_rootId)
- {
- event.Veto();
- return;
- }
-}
-
-void wxDirCtrl::OnEndEditItem(wxTreeEvent &event)
-{
- 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;
- }
-
- wxTreeItemId id = event.GetItem();
- wxDirItemData *data = (wxDirItemData*)GetItemData( id );
- wxASSERT( data );
-
- wxString new_name( wxPathOnly( data->m_path ) );
- 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(data->m_path,new_name))
- {
- data->SetNewDirName( new_name );
- }
- else
- {
- wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
- dialog.ShowModal();
- event.Veto();
- }
-}
-
-void wxDirCtrl::OnExpandItem(wxTreeEvent &event)
-{
- if (event.GetItem() == m_rootId)
- {
- SetupSections();
- CreateItems(m_rootId);
- return;
- }
-
- // This may take a longish time. Go to busy cursor
- wxBeginBusyCursor();
-
- wxDirItemData *data = (wxDirItemData *)GetItemData(event.GetItem());
- wxASSERT(data);
-
- m_paths.Clear();
- m_names.Clear();
-
- wxDir dir(data->m_path);
-
- wxString filename;
- bool cont = dir.GetFirst(&filename, "", wxDIR_DIRS | wxDIR_HIDDEN);
- while ( cont )