From 513b47e9b7faf61ed20bb00541c793d163ac307b Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 20 Oct 2006 20:50:48 +0000 Subject: [PATCH] screendc implementation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42179 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/dcscreen.h | 2 +- src/common/dcbase.cpp | 35 ++++++++++++++++++-------- src/mac/carbon/dcclient.cpp | 3 +-- src/mac/carbon/dcscreen.cpp | 43 ++++++++++++-------------------- src/mac/carbon/graphics.cpp | 5 ++++ 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/include/wx/mac/carbon/dcscreen.h b/include/wx/mac/carbon/dcscreen.h index 891444cbf4..052f5fb7b8 100644 --- a/include/wx/mac/carbon/dcscreen.h +++ b/include/wx/mac/carbon/dcscreen.h @@ -30,7 +30,7 @@ class WXDLLEXPORT wxScreenDC: public wxWindowDC static bool EndDrawingOnTop() { return TRUE; } private: #if wxMAC_USE_CORE_GRAPHICS - wxUint32 m_displayId; + void* m_overlayWindow; #endif }; diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 9fcea2c858..77b5894fb9 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -1235,17 +1235,32 @@ OSStatus wxOverlayImpl::CreateOverlayWindow() WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; - m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef(); + if ( m_window ) + { + m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef(); - Rect bounds ; - MacGetBounds(&bounds); - err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow ); - if ( err == noErr ) - { + Rect bounds ; + MacGetBounds(&bounds); + err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow ); + if ( err == noErr ) + { SetWindowGroup( m_overlayWindow, GetWindowGroup(m_overlayParentWindow)); // Put them in the same group so that their window layers are consistent - ShowWindow(m_overlayWindow); - } - return err; + } + } + 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; } void wxOverlayImpl::Init( wxWindowDC* dc, int x , int y , int width , int height ) @@ -1281,7 +1296,7 @@ void wxOverlayImpl::BeginDrawing( wxWindowDC* dc) dc->m_macLocalOrigin.x = 0 ; dc->m_macLocalOrigin.y = 0 ; */ - wxSize size = m_window->GetSize() ; + wxSize size = dc->GetSize() ; dc->SetClippingRegion( 0 , 0 , size.x , size.y ) ; } diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index affb800da1..404feb2056 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -176,14 +176,13 @@ wxWindowDC::~wxWindowDC() 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 ( width ) *width = m_width; if ( height ) *height = m_height; #else + wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); m_window->GetSize(width, height); #endif } diff --git a/src/mac/carbon/dcscreen.cpp b/src/mac/carbon/dcscreen.cpp index a19dc36477..32c38ee4ed 100644 --- a/src/mac/carbon/dcscreen.cpp +++ b/src/mac/carbon/dcscreen.cpp @@ -21,26 +21,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) wxScreenDC::wxScreenDC() { #if wxMAC_USE_CORE_GRAPHICS - CGrafPtr grafptr = CreateNewPort() ; - m_displayId = (UInt32) grafptr; - CGContextRef cg = NULL; - OSStatus status = QDBeginCGContext( grafptr , &cg ); - - CGRect bounds ; - bounds = CGDisplayBounds(CGMainDisplayID()); - - SInt16 height; - GetThemeMenuBarHeight( &height ); - m_minY = height; - m_minX = 0; - m_maxX = bounds.size.width; - 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; + 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; + WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; + OSStatus err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow ); + ShowWindow((WindowRef)m_overlayWindow); + SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) ); + m_width = cgbounds.size.width; + m_height = cgbounds.size.height; #else m_macPort = CreateNewPort() ; GrafPtr port ; @@ -73,13 +66,9 @@ wxScreenDC::wxScreenDC() wxScreenDC::~wxScreenDC() { #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; - m_graphicContext = NULL; + delete m_graphicContext; + m_graphicContext = NULL; + DisposeWindow((WindowRef) m_overlayWindow ); #else if ( m_macPort ) DisposePort( (CGrafPtr) m_macPort ) ; diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index 29c61ab26b..2f778411e3 100755 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -1292,4 +1292,9 @@ wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context ) return new wxMacCoreGraphicsContext((CGContextRef)context); } +wxGraphicsContext* wxGraphicsContext::CreateFromNativeWindow( void * window ) +{ + return new wxMacCoreGraphicsContext((WindowRef)window); +} + #endif // wxMAC_USE_CORE_GRAPHICS -- 2.47.2