X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/74518cea410bc1d8dc8438e81199572eac145a96..ddd7e4307b4a58a21e8a5eb04afe06e1fe65f7d8:/src/osx/cocoa/utils.mm diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 8d32b3a5c7..4c35abe950 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: utils.mm 48805 2007-09-19 14:52:25Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -371,29 +371,32 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const int width = subrect != NULL ? subrect->width : sz.x; int height = subrect != NULL ? subrect->height : sz.y ; - NSView* view = (NSView*) m_window->GetHandle(); - [view lockFocus]; - // we use this method as other methods force a repaint, and this method can be - // called from OnPaint, even with the window's paint dc as source (see wxHTMLWindow) - NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: [view bounds]] retain]; - [view unlockFocus]; - wxBitmap bitmap(width, height); - if ( [rep respondsToSelector:@selector(CGImage)] ) - { - CGImageRef cgImageRef = (CGImageRef)[rep CGImage]; - CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) ); - // since our context is upside down we dont use CGContextDrawImage - wxMacDrawCGImage( (CGContextRef) bitmap.GetHBITMAP() , &r, cgImageRef ) ; - CGImageRelease(cgImageRef); - cgImageRef = NULL; - } - else + NSView* view = (NSView*) m_window->GetHandle(); + if ( [view isHiddenOrHasHiddenAncestor] == NO ) { - // TODO for 10.4 in case we can support this for osx_cocoa + [view lockFocus]; + // we use this method as other methods force a repaint, and this method can be + // called from OnPaint, even with the window's paint dc as source (see wxHTMLWindow) + NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: [view bounds]] retain]; + [view unlockFocus]; + if ( [rep respondsToSelector:@selector(CGImage)] ) + { + CGImageRef cgImageRef = (CGImageRef)[rep CGImage]; + + CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) ); + // since our context is upside down we dont use CGContextDrawImage + wxMacDrawCGImage( (CGContextRef) bitmap.GetHBITMAP() , &r, cgImageRef ) ; + CGImageRelease(cgImageRef); + cgImageRef = NULL; + } + else + { + // TODO for 10.4 in case we can support this for osx_cocoa + } + [rep release]; } - [rep release]; return bitmap; }