X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a62f32af0050ab4907ab2771a40875a0eb27a452..80a779275ae04443c568dca919adb26cf6f5002c:/src/mac/carbon/renderer.cpp diff --git a/src/mac/carbon/renderer.cpp b/src/mac/carbon/renderer.cpp index ad3be942d7..802ff8a81e 100644 --- a/src/mac/carbon/renderer.cpp +++ b/src/mac/carbon/renderer.cpp @@ -36,8 +36,12 @@ public: virtual void DrawHeaderButton( wxWindow *win, wxDC& dc, const wxRect& rect, - int flags = 0 ); + int flags = 0, + wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE, + wxHeaderButtonParams* params = NULL ); + virtual int GetHeaderButtonHeight(wxWindow *win); + // draw the expanded/collapsed icon for a tree control item virtual void DrawTreeItemButton( wxWindow *win, wxDC& dc, @@ -125,14 +129,12 @@ wxRendererNative& wxRendererNative::GetDefault() void wxRendererMac::DrawHeaderButton( wxWindow *win, wxDC& dc, const wxRect& rect, - int flags ) + int flags, + wxHeaderSortIconType sortArrow, + wxHeaderButtonParams* params ) { - int major, minor; - - wxGetOsVersion( &major, &minor ); - - const wxCoord x = dc.XLOG2DEV(rect.x - 1); - const wxCoord y = dc.YLOG2DEV(rect.y - 1); + const wxCoord x = dc.XLOG2DEV(rect.x /*- 1*/); + const wxCoord y = dc.YLOG2DEV(rect.y /*- 1*/); const wxCoord w = dc.XLOG2DEVREL(rect.width); const wxCoord h = dc.YLOG2DEVREL(rect.height); @@ -179,11 +181,28 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win, memset( &drawInfo, 0, sizeof(drawInfo) ); drawInfo.version = 0; - drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive; drawInfo.kind = kThemeListHeaderButton; - drawInfo.value = 0; + drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive; + drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff; drawInfo.adornment = kThemeAdornmentNone; + + // The down arrow is drawn automatically, change it to an up arrow if needed. + if ( sortArrow == wxHDR_SORT_ICON_UP ) + drawInfo.adornment = kThemeAdornmentHeaderButtonSortUp; + HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect ); + + // If we don't want any arrows we need to draw over the one already there + if ( (flags & wxCONTROL_SELECTED) && (sortArrow == wxHDR_SORT_ICON_NONE) ) + { + // clip to the header rectangle + CGContextSaveGState( cgContext ); + CGContextClipToRect( cgContext, headerRect ); + // but draw bigger than that so the arrow will get clipped off + headerRect.size.width += 25; + HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect ); + CGContextRestoreGState( cgContext ); + } } #if wxMAC_USE_CORE_GRAPHICS @@ -191,8 +210,35 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win, QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext ); #endif } + + // Reserve room for the arrows before writing the label, and turn off the + // flags we've already handled + wxRect newRect(rect); + if ( (flags & wxCONTROL_SELECTED) && (sortArrow != wxHDR_SORT_ICON_NONE) ) + { + newRect.width -= 12; + sortArrow = wxHDR_SORT_ICON_NONE; + } + flags &= ~wxCONTROL_SELECTED; + + DrawHeaderButtonContents(win, dc, newRect, flags, sortArrow, params); +} + + +int wxRendererMac::GetHeaderButtonHeight(wxWindow* WXUNUSED(win)) +{ + SInt32 standardHeight; + OSStatus errStatus; + + errStatus = GetThemeMetric( kThemeMetricListHeaderHeight, &standardHeight ); + if (errStatus == noErr) + { + return standardHeight; + } + return -1; } + void wxRendererMac::DrawTreeItemButton( wxWindow *win, wxDC& dc, const wxRect& rect,