]> git.saurik.com Git - wxWidgets.git/commitdiff
screendc implementation
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 20 Oct 2006 20:50:48 +0000 (20:50 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 20 Oct 2006 20:50:48 +0000 (20:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42179 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/carbon/dcscreen.h
src/common/dcbase.cpp
src/mac/carbon/dcclient.cpp
src/mac/carbon/dcscreen.cpp
src/mac/carbon/graphics.cpp

index 891444cbf4d9afe1c60d5a5f30ddb88bc0f94980..052f5fb7b857ab1ee4669fbd6ebf8e3b7824dd60 100644 (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
 };
 
index 9fcea2c8581af2394a61bff97a4994018ece52f7..77b5894fb923029e24ce2ac954b064505ee068f5 100644 (file)
@@ -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 ) ;
 }
 
index affb800da12aaecfffae74e99b32bf13fcc7de5d..404feb2056d46d02d53edceeb629a21fb618a338 100644 (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
 }
index a19dc36477a03e1157c1ee9bb04633e9c703436c..32c38ee4edfa4f85af53895d63d6bbbfa1b8e199 100644 (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;
+       delete m_graphicContext;
+       m_graphicContext = NULL;
+       DisposeWindow((WindowRef) m_overlayWindow );
 #else
     if ( m_macPort )
         DisposePort( (CGrafPtr) m_macPort ) ;
index 29c61ab26b5e7d0e399bf01d5b3a03bac7f7ff75..2f778411e3681007d294ccd2a9e4305fc6e7c430 100755 (executable)
@@ -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