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:
@@ -754,13 +754,6 @@ void wxGenericTreeCtrl::Init()
|
|||||||
m_indent = 15;
|
m_indent = 15;
|
||||||
m_spacing = 18;
|
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
|
m_hilightBrush = new wxBrush
|
||||||
(
|
(
|
||||||
wxSystemSettings::GetColour
|
wxSystemSettings::GetColour
|
||||||
@@ -769,14 +762,7 @@ void wxGenericTreeCtrl::Init()
|
|||||||
),
|
),
|
||||||
wxSOLID
|
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
|
m_hilightUnfocusedBrush = new wxBrush
|
||||||
(
|
(
|
||||||
wxSystemSettings::GetColour
|
wxSystemSettings::GetColour
|
||||||
@@ -785,7 +771,7 @@ void wxGenericTreeCtrl::Init()
|
|||||||
),
|
),
|
||||||
wxSOLID
|
wxSOLID
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
m_imageListButtons = NULL;
|
m_imageListButtons = NULL;
|
||||||
m_ownsImageListButtons = false;
|
m_ownsImageListButtons = false;
|
||||||
|
|
||||||
@@ -2236,7 +2222,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
x=0;
|
x=0;
|
||||||
GetVirtualSize(&w, &h);
|
GetVirtualSize(&w, &h);
|
||||||
wxRect rect( x, item->GetY()+offset, w, total_h-offset);
|
wxRect rect( x, item->GetY()+offset, w, total_h-offset);
|
||||||
#ifndef __WXGTK20__
|
#if !defined(__WXGTK20__) && !defined(__WXMAC__)
|
||||||
dc.DrawRectangle(rect);
|
dc.DrawRectangle(rect);
|
||||||
#else
|
#else
|
||||||
if (!item->IsSelected())
|
if (!item->IsSelected())
|
||||||
@@ -2263,7 +2249,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
// background colour.
|
// background colour.
|
||||||
wxRect rect( item->GetX() + image_w - 2, item->GetY()+offset,
|
wxRect rect( item->GetX() + image_w - 2, item->GetY()+offset,
|
||||||
item->GetWidth() - image_w + 2, total_h-offset );
|
item->GetWidth() - image_w + 2, total_h-offset );
|
||||||
#ifndef __WXGTK20__
|
#if !defined(__WXGTK20__) && !defined(__WXMAC__)
|
||||||
dc.DrawRectangle( rect );
|
dc.DrawRectangle( rect );
|
||||||
#else
|
#else
|
||||||
rect.x -= 1;
|
rect.x -= 1;
|
||||||
@@ -2284,7 +2270,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
{
|
{
|
||||||
wxRect rect( item->GetX()-2, item->GetY()+offset,
|
wxRect rect( item->GetX()-2, item->GetY()+offset,
|
||||||
item->GetWidth()+2, total_h-offset );
|
item->GetWidth()+2, total_h-offset );
|
||||||
#ifndef __WXGTK20__
|
#if !defined(__WXGTK20__) && !defined(__WXMAC__)
|
||||||
dc.DrawRectangle( rect );
|
dc.DrawRectangle( rect );
|
||||||
#else
|
#else
|
||||||
if ( attr && attr->HasBackgroundColour() )
|
if ( attr && attr->HasBackgroundColour() )
|
||||||
|
@@ -57,6 +57,11 @@ public:
|
|||||||
wxOrientation orient,
|
wxOrientation orient,
|
||||||
int flags = 0 );
|
int flags = 0 );
|
||||||
|
|
||||||
|
virtual void DrawItemSelectionRect(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// the tree buttons
|
// the tree buttons
|
||||||
wxBitmap m_bmpTreeExpanded;
|
wxBitmap m_bmpTreeExpanded;
|
||||||
@@ -341,3 +346,25 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
|
|||||||
#endif
|
#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 );
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user