]> git.saurik.com Git - wxWidgets.git/commitdiff
supporting native background color on wxWindow descendants that are not themselves...
authorStefan Csomor <csomor@advancedconcepts.ch>
Mon, 6 Jun 2011 02:28:56 +0000 (02:28 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Mon, 6 Jun 2011 02:28:56 +0000 (02:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/window.mm

index ccea61277c0c5ba0ca777b36d1767469a2ffa5cc..aba5751431749cbdcc2e0381253705d29fbf8426 100644 (file)
@@ -802,12 +802,31 @@ void wxOSX_drawRect(NSView* self, SEL _cmd, NSRect rect)
     // [NSWindow setAllowsConcurrentViewDrawing:NO] does not affect it.
     if ( !wxThread::IsMain() )
     {
-      // just call the superclass handler, we don't need any custom wx drawing
-      // here and it seems to work fine:
-      wxOSX_DrawRectHandlerPtr
-          superimpl = (wxOSX_DrawRectHandlerPtr)
-                        [[self superclass] instanceMethodForSelector:_cmd];
-      superimpl(self, _cmd, rect);
+        if ( impl->IsUserPane() )
+        {
+            wxWindow* win = impl->GetWXPeer();
+            if ( win->UseBgCol() )
+            {
+                
+                CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
+                CGContextSaveGState( context );
+
+                CGContextSetFillColorWithColor( context, win->GetBackgroundColour().GetCGColor());
+                CGContextFillRect( context, NSRectToCGRect(rect) );
+
+                CGContextRestoreGState( context );
+            }
+        }
+        else 
+        {
+            // just call the superclass handler, we don't need any custom wx drawing
+            // here and it seems to work fine:
+            wxOSX_DrawRectHandlerPtr
+            superimpl = (wxOSX_DrawRectHandlerPtr)
+            [[self superclass] instanceMethodForSelector:_cmd];
+            superimpl(self, _cmd, rect);
+        }
+
       return;
     }
 #endif // wxUSE_THREADS