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; }
private:
#if wxMAC_USE_CORE_GRAPHICS
wxUint32 m_displayId;
void* m_overlayWindow;
#endif
};

View File

@@ -1235,6 +1235,8 @@ OSStatus wxOverlayImpl::CreateOverlayWindow()
WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute;
if ( m_window )
{
m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef();
Rect bounds ;
@@ -1243,8 +1245,21 @@ OSStatus wxOverlayImpl::CreateOverlayWindow()
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);
}
}
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;
}
@@ -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 ) ;
}

View File

@@ -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
}

View File

@@ -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;
DisposeWindow((WindowRef) m_overlayWindow );
#else
if ( m_macPort )
DisposePort( (CGrafPtr) m_macPort ) ;

View File

@@ -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