X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/06b466c74fae8f27544f143abdcabcd2385602e4..fb0de762f3e019e4d0c3a5816d10b934500833db:/src/generic/treectrl.cpp diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index 656560dec3..64b87f0b13 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -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