screendc implementation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42179 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2006-10-20 20:50:48 +00:00
parent bf2185eb8b
commit 513b47e9b7
5 changed files with 48 additions and 40 deletions

View File

@@ -30,7 +30,7 @@ class WXDLLEXPORT wxScreenDC: public wxWindowDC
static bool EndDrawingOnTop() { return TRUE; } static bool EndDrawingOnTop() { return TRUE; }
private: private:
#if wxMAC_USE_CORE_GRAPHICS #if wxMAC_USE_CORE_GRAPHICS
wxUint32 m_displayId; void* m_overlayWindow;
#endif #endif
}; };

View File

@@ -1235,6 +1235,8 @@ OSStatus wxOverlayImpl::CreateOverlayWindow()
WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute;
if ( m_window )
{
m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef(); m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef();
Rect bounds ; Rect bounds ;
@@ -1243,8 +1245,21 @@ OSStatus wxOverlayImpl::CreateOverlayWindow()
if ( err == noErr ) if ( err == noErr )
{ {
SetWindowGroup( m_overlayWindow, GetWindowGroup(m_overlayParentWindow)); // Put them in the same group so that their window layers are consistent SetWindowGroup( m_overlayWindow, GetWindowGroup(m_overlayParentWindow)); // Put them in the same group so that their window layers are consistent
ShowWindow(m_overlayWindow);
} }
}
else
{
m_overlayParentWindow = NULL ;
CGRect cgbounds ;
cgbounds = CGDisplayBounds(CGMainDisplayID());
Rect bounds;
bounds.top = cgbounds.origin.y;
bounds.left = cgbounds.origin.x;
bounds.bottom = bounds.top + cgbounds.size.height;
bounds.right = bounds.left + cgbounds.size.width;
err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow );
}
ShowWindow(m_overlayWindow);
return err; return err;
} }
@@ -1281,7 +1296,7 @@ void wxOverlayImpl::BeginDrawing( wxWindowDC* dc)
dc->m_macLocalOrigin.x = 0 ; dc->m_macLocalOrigin.x = 0 ;
dc->m_macLocalOrigin.y = 0 ; dc->m_macLocalOrigin.y = 0 ;
*/ */
wxSize size = m_window->GetSize() ; wxSize size = dc->GetSize() ;
dc->SetClippingRegion( 0 , 0 , size.x , size.y ) ; dc->SetClippingRegion( 0 , 0 , size.x , size.y ) ;
} }

View File

@@ -176,14 +176,13 @@ wxWindowDC::~wxWindowDC()
void wxWindowDC::DoGetSize( int* width, int* height ) const void wxWindowDC::DoGetSize( int* width, int* height ) const
{ {
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
#if wxMAC_USE_CORE_GRAPHICS #if wxMAC_USE_CORE_GRAPHICS
if ( width ) if ( width )
*width = m_width; *width = m_width;
if ( height ) if ( height )
*height = m_height; *height = m_height;
#else #else
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
m_window->GetSize(width, height); m_window->GetSize(width, height);
#endif #endif
} }

View File

@@ -21,26 +21,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
wxScreenDC::wxScreenDC() wxScreenDC::wxScreenDC()
{ {
#if wxMAC_USE_CORE_GRAPHICS #if wxMAC_USE_CORE_GRAPHICS
CGrafPtr grafptr = CreateNewPort() ; CGRect cgbounds ;
m_displayId = (UInt32) grafptr; cgbounds = CGDisplayBounds(CGMainDisplayID());
CGContextRef cg = NULL; Rect bounds;
OSStatus status = QDBeginCGContext( grafptr , &cg ); bounds.top = cgbounds.origin.y;
bounds.left = cgbounds.origin.x;
CGRect bounds ; bounds.bottom = bounds.top + cgbounds.size.height;
bounds = CGDisplayBounds(CGMainDisplayID()); bounds.right = bounds.left + cgbounds.size.width;
WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute;
SInt16 height; OSStatus err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow );
GetThemeMenuBarHeight( &height ); ShowWindow((WindowRef)m_overlayWindow);
m_minY = height; SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
m_minX = 0; m_width = cgbounds.size.width;
m_maxX = bounds.size.width; m_height = cgbounds.size.height;
m_maxY = bounds.size.height - height;
CGContextTranslateCTM( cg , 0 , bounds.size.height );
CGContextScaleCTM( cg , 1 , -1 );
SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
m_width = bounds.size.width;
m_height = bounds.size.height - height;
#else #else
m_macPort = CreateNewPort() ; m_macPort = CreateNewPort() ;
GrafPtr port ; GrafPtr port ;
@@ -73,13 +66,9 @@ wxScreenDC::wxScreenDC()
wxScreenDC::~wxScreenDC() wxScreenDC::~wxScreenDC()
{ {
#if wxMAC_USE_CORE_GRAPHICS #if wxMAC_USE_CORE_GRAPHICS
CGrafPtr grafptr = (CGrafPtr) m_displayId;
m_displayId = (UInt32) grafptr;
CGContextRef cg = (CGContextRef) m_graphicContext->GetNativeContext();
QDEndCGContext(grafptr, &cg );
delete m_graphicContext; delete m_graphicContext;
m_graphicContext = NULL; m_graphicContext = NULL;
DisposeWindow((WindowRef) m_overlayWindow );
#else #else
if ( m_macPort ) if ( m_macPort )
DisposePort( (CGrafPtr) m_macPort ) ; DisposePort( (CGrafPtr) m_macPort ) ;

View File

@@ -1292,4 +1292,9 @@ wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
return new wxMacCoreGraphicsContext((CGContextRef)context); return new wxMacCoreGraphicsContext((CGContextRef)context);
} }
wxGraphicsContext* wxGraphicsContext::CreateFromNativeWindow( void * window )
{
return new wxMacCoreGraphicsContext((WindowRef)window);
}
#endif // wxMAC_USE_CORE_GRAPHICS #endif // wxMAC_USE_CORE_GRAPHICS