From: Kevin Ollivier Date: Sun, 19 Nov 2006 06:28:47 +0000 (+0000) Subject: Implement wxRendererMac::DrawItemSelectionRect and move the generic wxTreeCtrl to... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a4609ab847819b47c996674420871f4514d50625 Implement wxRendererMac::DrawItemSelectionRect and move the generic wxTreeCtrl to using it to draw selected items. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index bfd43b7dc8..a20a4fabe2 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -754,13 +754,6 @@ void wxGenericTreeCtrl::Init() m_indent = 15; m_spacing = 18; -#ifdef __WXMAC__ - // OS X sel item highlight color differs from text highlight color, which is - // what wxSYS_COLOUR_HIGHLIGHT returns. - RGBColor hilight; - GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &hilight); - m_hilightBrush = new wxBrush( wxColour(hilight.red, hilight.green, hilight.blue ), wxSOLID ); -#else m_hilightBrush = new wxBrush ( wxSystemSettings::GetColour @@ -769,14 +762,7 @@ void wxGenericTreeCtrl::Init() ), wxSOLID ); -#endif -#ifdef __WXMAC__ - // on Mac, this color also differs from the wxSYS_COLOUR_BTNSHADOW, enough to be noticable. - // I don't know if BTNSHADOW is appropriate in other contexts, so I'm just changing it here. - GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &hilight); - m_hilightUnfocusedBrush = new wxBrush( wxColour(hilight.red, hilight.green, hilight.blue ), wxSOLID ); -#else m_hilightUnfocusedBrush = new wxBrush ( wxSystemSettings::GetColour @@ -785,7 +771,7 @@ void wxGenericTreeCtrl::Init() ), wxSOLID ); -#endif + m_imageListButtons = NULL; m_ownsImageListButtons = false; @@ -2236,7 +2222,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) x=0; GetVirtualSize(&w, &h); wxRect rect( x, item->GetY()+offset, w, total_h-offset); -#ifndef __WXGTK20__ +#if !defined(__WXGTK20__) && !defined(__WXMAC__) dc.DrawRectangle(rect); #else if (!item->IsSelected()) @@ -2263,7 +2249,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) // background colour. wxRect rect( item->GetX() + image_w - 2, item->GetY()+offset, item->GetWidth() - image_w + 2, total_h-offset ); -#ifndef __WXGTK20__ +#if !defined(__WXGTK20__) && !defined(__WXMAC__) dc.DrawRectangle( rect ); #else rect.x -= 1; @@ -2284,7 +2270,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { wxRect rect( item->GetX()-2, item->GetY()+offset, item->GetWidth()+2, total_h-offset ); -#ifndef __WXGTK20__ +#if !defined(__WXGTK20__) && !defined(__WXMAC__) dc.DrawRectangle( rect ); #else if ( attr && attr->HasBackgroundColour() ) diff --git a/src/mac/carbon/renderer.cpp b/src/mac/carbon/renderer.cpp index 8cc6fae7dd..71bb87221e 100644 --- a/src/mac/carbon/renderer.cpp +++ b/src/mac/carbon/renderer.cpp @@ -56,6 +56,11 @@ public: wxCoord position, wxOrientation orient, int flags = 0 ); + + virtual void DrawItemSelectionRect(wxWindow *win, + wxDC& dc, + const wxRect& rect, + int flags = 0); private: // the tree buttons @@ -341,3 +346,25 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win, #endif } } + +void +wxRendererMac::DrawItemSelectionRect(wxWindow *win, + wxDC& dc, + const wxRect& rect, + int flags ) +{ + RGBColor selColor; + if (flags & wxCONTROL_SELECTED) + { + if (flags & wxCONTROL_FOCUSED) + GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &selColor); + else + GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &selColor); + } + + wxBrush selBrush = wxBrush( wxColour( selColor.red, selColor.green, selColor.blue ), wxSOLID ); + + dc.SetPen( *wxTRANSPARENT_PEN ); + dc.SetBrush( selBrush ); + dc.DrawRectangle( rect ); +}