From 07edda049fbe3b6ae08daff5ce864543f155bab0 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 1 Jun 2011 20:05:03 +0000 Subject: [PATCH] first stab at supporting custom renderers git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/renderer.cpp | 13 +++++++++++++ src/osx/cocoa/dataview.mm | 21 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/osx/carbon/renderer.cpp b/src/osx/carbon/renderer.cpp index 9fc1a415bf..0f04a383a9 100644 --- a/src/osx/carbon/renderer.cpp +++ b/src/osx/carbon/renderer.cpp @@ -42,9 +42,22 @@ // check if we're currently in a paint event inline bool wxInPaintEvent(wxWindow* win, wxDC& dc) { + if ( win->MacGetCGContextRef() != NULL ) + return true; + + wxGCDCImpl* gcdc = wxDynamicCast( dc.GetImpl() , wxGCDCImpl); + + if ( gcdc ) + { + if ( gcdc->GetGraphicsContext()->GetNativeContext() ) + return true; + } + /* return win->MacGetCGContextRef() != NULL || // wxMemoryDC's also have a valid CGContext. dc.IsKindOf( CLASSINFO(wxMemoryDC) ); + */ + return false; } diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index ac10280f6c..57e4927750 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -25,6 +25,7 @@ #include "wx/osx/cocoa/dataview.h" #include "wx/renderer.h" #include "wx/stopwatch.h" +#include "wx/dcgraph.h" // ============================================================================ // Constants used locally @@ -1164,9 +1165,23 @@ outlineView:(NSOutlineView*)outlineView wxDataViewCustomRenderer * const renderer = obj->customRenderer; - wxDC * const dc = renderer->GetDC(); - renderer->WXCallRender(wxFromNSRect(controlView, cellFrame), dc, 0); - renderer->SetDC(NULL); + CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGContextSaveGState( context ); + + if ( ![controlView isFlipped] ) + { + CGContextTranslateCTM( context, 0, [controlView bounds].size.height ); + CGContextScaleCTM( context, 1, -1 ); + } + + // wxDC * const dc = renderer->GetDC(); + wxGraphicsContext* gc = wxGraphicsContext::CreateFromNative(context); + wxGCDC dc; + dc.SetGraphicsContext(gc); + renderer->WXCallRender(wxFromNSRect(controlView, cellFrame), &dc, 0); + + CGContextRestoreGState( context ); + // renderer->SetDC(NULL); } -(NSRect) imageRectForBounds:(NSRect)cellFrame -- 2.45.2