]> git.saurik.com Git - wxWidgets.git/commitdiff
first stab at supporting custom renderers
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 1 Jun 2011 20:05:03 +0000 (20:05 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 1 Jun 2011 20:05:03 +0000 (20:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/renderer.cpp
src/osx/cocoa/dataview.mm

index 9fc1a415bfb27914420bf0506760178b7b6b8d65..0f04a383a952c0b6e6f1db74fb22f8111a468819 100644 (file)
 // 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;
 }
 
 
index ac10280f6c25c58d1990b85eacc2d61807f6cf09..57e49277507ca8bbd264bd9ecd3c1b2bd2a5ce37 100644 (file)
@@ -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