X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a12482a357a2ef5feb50f9ace8e173f9aed680e0..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/osx/carbon/renderer.cpp?ds=sidebyside diff --git a/src/osx/carbon/renderer.cpp b/src/osx/carbon/renderer.cpp index 659b070891..7e5c766acc 100644 --- a/src/osx/carbon/renderer.cpp +++ b/src/osx/carbon/renderer.cpp @@ -39,12 +39,17 @@ #endif // wxHAS_DRAW_TITLE_BAR_BITMAP -// check if we're currently in a paint event -inline bool wxInPaintEvent(wxWindow* win, wxDC& dc) +// check if we're having a CGContext we can draw into +inline bool wxHasCGContext(wxWindow* WXUNUSED(win), wxDC& dc) { - return win->MacGetCGContextRef() != NULL || - // wxMemoryDC's also have a valid CGContext. - dc.IsKindOf( CLASSINFO(wxMemoryDC) ); + wxGCDCImpl* gcdc = wxDynamicCast( dc.GetImpl() , wxGCDCImpl); + + if ( gcdc ) + { + if ( gcdc->GetGraphicsContext()->GetNativeContext() ) + return true; + } + return false; } @@ -62,6 +67,8 @@ public: virtual int GetHeaderButtonHeight(wxWindow *win); + virtual int GetHeaderButtonMargin(wxWindow *win); + // draw the expanded/collapsed icon for a tree control item virtual void DrawTreeItemButton( wxWindow *win, wxDC& dc, @@ -156,7 +163,7 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win, dc.SetBrush( *wxTRANSPARENT_BRUSH ); HIRect headerRect = CGRectMake( x, y, w, h ); - if ( !wxInPaintEvent(win, dc) ) + if ( !wxHasCGContext(win, dc) ) { win->Refresh( &rect ); } @@ -225,6 +232,12 @@ int wxRendererMac::GetHeaderButtonHeight(wxWindow* WXUNUSED(win)) return -1; } +int wxRendererMac::GetHeaderButtonMargin(wxWindow *WXUNUSED(win)) +{ + wxFAIL_MSG( "GetHeaderButtonMargin() not implemented" ); + return -1; +} + void wxRendererMac::DrawTreeItemButton( wxWindow *win, wxDC& dc, const wxRect& rect, @@ -239,7 +252,7 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win, dc.SetBrush( *wxTRANSPARENT_BRUSH ); HIRect headerRect = CGRectMake( x, y, w, h ); - if ( !wxInPaintEvent(win, dc) ) + if ( !wxHasCGContext(win, dc) ) { win->Refresh( &rect ); } @@ -285,7 +298,7 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win, // under compositing we should only draw when called by the OS, otherwise just issue a redraw command // strange redraw errors occur if we don't do this - if ( !wxInPaintEvent(win, dc) ) + if ( !wxHasCGContext(win, dc) ) { wxRect rect( (int) splitterRect.origin.x, (int) splitterRect.origin.y, (int) splitterRect.size.width, (int) splitterRect.size.height ); @@ -304,12 +317,12 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win, if ( hasMetal ) HIThemeDrawBackground(&splitterRect, &bgdrawInfo, cgContext, kHIThemeOrientationNormal); - else + else { CGContextSetFillColorWithColor(cgContext,win->GetBackgroundColour().GetCGColor()); CGContextFillRect(cgContext,splitterRect); } - + HIThemeSplitterDrawInfo drawInfo; drawInfo.version = 0; drawInfo.state = kThemeStateActive; @@ -355,7 +368,7 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win, dc.SetBrush( *wxTRANSPARENT_BRUSH ); HIRect headerRect = CGRectMake( x, y, w, h ); - if ( !wxInPaintEvent(win, dc) ) + if ( !wxHasCGContext(win, dc) ) { win->Refresh( &rect ); } @@ -563,7 +576,7 @@ void wxRendererMac::DrawTextCtrl(wxWindow* win, wxDC& dc, dc.SetBrush( *wxTRANSPARENT_BRUSH ); HIRect hiRect = CGRectMake( x, y, w, h ); - if ( !wxInPaintEvent(win, dc) ) + if ( !wxHasCGContext(win, dc) ) { win->Refresh( &rect ); }