+ m_currentEdit = item.m_pItem;
+
+ wxTreeEvent te( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, GetId() );
+ te.m_item = m_currentEdit;
+ te.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( te );
+
+ if (!te.IsAllowed()) return;
+
+ // We have to call this here because the label in
+ // question might just have been added and no screen
+ // update taken place.
+ if (m_dirty) wxYield();
+
+ wxString s = m_currentEdit->GetText();
+ int x = m_currentEdit->GetX();
+ int y = m_currentEdit->GetY();
+ int w = m_currentEdit->GetWidth();
+ int h = m_currentEdit->GetHeight();
+
+ int image_h = 0;
+ int image_w = 0;
+
+ int image = m_currentEdit->GetCurrentImage();
+ if ( image != NO_IMAGE )
+ {
+ m_imageListNormal->GetSize( image, image_w, image_h );
+ image_w += 4;
+ }
+ x += image_w;
+ w -= image_w + 4; // I don't know why +4 is needed
+
+ wxClientDC dc(this);
+ PrepareDC( dc );
+ x = dc.LogicalToDeviceX( x );
+ y = dc.LogicalToDeviceY( y );
+
+ wxTreeTextCtrl *text = new wxTreeTextCtrl(
+ this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) );
+ text->SetFocus();
+}
+
+void wxTreeCtrl::OnRenameTimer()
+{
+ Edit( m_current );
+}
+
+void wxTreeCtrl::OnRenameAccept()
+{
+ wxTreeEvent le( wxEVT_COMMAND_TREE_END_LABEL_EDIT, GetId() );
+ le.m_item = m_currentEdit;
+ le.SetEventObject( this );
+ le.m_label = m_renameRes;
+ GetEventHandler()->ProcessEvent( le );
+
+ if (!le.IsAllowed()) return;
+
+ SetItemText( m_currentEdit, m_renameRes );
+}
+
+void wxTreeCtrl::OnMouse( wxMouseEvent &event )
+{
+ if ( !(event.LeftUp() || event.RightDown() || event.LeftDClick() || event.Dragging()) ) return;