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
This commit is contained in:
parent
5c80cef4bf
commit
a4609ab847
@ -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() )
|
||||
|
@ -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 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user