]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectrl.cpp
disable edit control before insert/delete row/col
[wxWidgets.git] / src / generic / treectrl.cpp
index 656560dec35e9259d4dd3c9a597852ab325ddcfa..64b87f0b13cfcd041e6447d685598a31ecae6add 100644 (file)
@@ -252,14 +252,23 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
     {
         (*m_accept) = TRUE;
         (*m_res) = GetValue();
-        m_owner->SetFocus();
+        
+        if (!wxPendingDelete.Member(this))
+            wxPendingDelete.Append(this);
+
+        if ((*m_accept) && ((*m_res) != m_startValue))
+            m_owner->OnRenameAccept();
+            
         return;
     }
     if (event.m_keyCode == WXK_ESCAPE)
     {
         (*m_accept) = FALSE;
         (*m_res) = "";
-        m_owner->SetFocus();
+        
+        if (!wxPendingDelete.Member(this))
+            wxPendingDelete.Append(this);
+            
         return;
     }
     event.Skip();
@@ -267,9 +276,8 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
 
 void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
-    if (wxPendingDelete.Member(this)) return;
-
-    wxPendingDelete.Append(this);
+    if (!wxPendingDelete.Member(this))
+        wxPendingDelete.Append(this);
 
     if ((*m_accept) && ((*m_res) != m_startValue))
         m_owner->OnRenameAccept();
@@ -550,6 +558,11 @@ void wxTreeCtrl::Init()
       wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT),
       wxSOLID
     );
+    m_normalBrush = new wxBrush
+    (
+      wxSystemSettings::GetSystemColour(wxSYS_COLOUR_LISTBOX),
+      wxSOLID
+    );
 
     m_imageListNormal =
     m_imageListState = (wxImageList *) NULL;
@@ -580,7 +593,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
     SetValidator( validator );
 #endif
 
-    SetBackgroundColour( *wxWHITE );
+    SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
 //  m_dottedPen = wxPen( "grey", 0, wxDOT );  too slow under XFree86
     m_dottedPen = wxPen( "grey", 0, 0 );
 
@@ -590,6 +603,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
 wxTreeCtrl::~wxTreeCtrl()
 {
     wxDELETE( m_hilightBrush );
+    wxDELETE( m_normalBrush );
 
     DeleteAllItems();
 
@@ -1523,6 +1537,13 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
 
     int total_h = GetLineHeight(item);
 
+    wxColour colBg;
+    if ( attr && attr->HasBackgroundColour() )
+        colBg = attr->GetBackgroundColour();
+    else
+        colBg = m_backgroundColour;
+    dc.SetBrush(wxBrush(colBg, wxSOLID));
+
     dc.DrawRectangle( item->GetX()-2, item->GetY(), item->GetWidth()+2, total_h );
 
     if ( image != NO_IMAGE )
@@ -1535,10 +1556,7 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
         dc.DestroyClippingRegion();
     }
 
-    bool hasBgCol = attr && attr->HasBackgroundColour();
-    dc.SetBackgroundMode(hasBgCol ? wxSOLID : wxTRANSPARENT);
-    if ( hasBgCol )
-        dc.SetTextBackground(attr->GetBackgroundColour());
+    dc.SetBackgroundMode(wxTRANSPARENT);
     dc.DrawText( item->GetText(), image_w + item->GetX(), item->GetY()
                  + ((total_h > text_h) ? (total_h - text_h)/2 : 0));
 
@@ -1609,7 +1627,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
             else
                 colText = *wxBLACK;
 
-            brush = wxWHITE_BRUSH;
+            brush = m_normalBrush;
         }
 
         // prepare to draw