1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/mac/carbon/dcscreen.cpp 
   3 // Purpose:     wxScreenDC class 
   4 // Author:      Stefan Csomor 
   8 // Copyright:   (c) Stefan Csomor 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 #include "wx/wxprec.h" 
  14 #include "wx/dcscreen.h" 
  16 #include "wx/mac/uma.h" 
  17 #include "wx/graphics.h" 
  19 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
) 
  21 // Create a DC representing the whole screen 
  22 wxScreenDC::wxScreenDC() 
  24 #if wxMAC_USE_CORE_GRAPHICS 
  26     cgbounds 
= CGDisplayBounds(CGMainDisplayID()); 
  28     bounds
.top 
= (short)cgbounds
.origin
.y
; 
  29     bounds
.left 
= (short)cgbounds
.origin
.x
; 
  30     bounds
.bottom 
= bounds
.top 
+ (short)cgbounds
.size
.height
; 
  31     bounds
.right 
= bounds
.left  
+ (short)cgbounds
.size
.width
; 
  32     WindowAttributes overlayAttributes  
= kWindowIgnoreClicksAttribute
; 
  33     CreateNewWindow( kOverlayWindowClass
, overlayAttributes
, &bounds
, (WindowRef
*) &m_overlayWindow 
); 
  34     ShowWindow((WindowRef
)m_overlayWindow
); 
  35     SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow 
) ); 
  36     m_width 
= (wxCoord
)cgbounds
.size
.width
; 
  37     m_height 
= (wxCoord
)cgbounds
.size
.height
; 
  39     m_macPort 
= CreateNewPort() ; 
  42     SetPort( (GrafPtr
) m_macPort 
) ; 
  44     LocalToGlobal( &pt 
) ; 
  46     m_deviceLocalOriginX 
= -pt
.h 
; 
  47     m_deviceLocalOriginY 
= -pt
.v 
; 
  50     GetQDGlobalsScreenBits( &screenBits 
); 
  51     m_minX 
= screenBits
.bounds
.left 
; 
  54     GetThemeMenuBarHeight( &height 
) ; 
  55     m_minY 
= screenBits
.bounds
.top 
+ height 
; 
  57     m_maxX 
= screenBits
.bounds
.right  
; 
  58     m_maxY 
= screenBits
.bounds
.bottom 
; 
  60     MacSetRectRgn( (RgnHandle
) m_macBoundaryClipRgn 
, m_minX 
, m_minY 
, m_maxX 
, m_maxY 
) ; 
  61     OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn 
, m_deviceLocalOriginX 
, m_deviceLocalOriginY 
) ; 
  62     CopyRgn( (RgnHandle
) m_macBoundaryClipRgn 
, (RgnHandle
) m_macCurrentClipRgn 
) ; 
  67 wxScreenDC::~wxScreenDC() 
  69 #if wxMAC_USE_CORE_GRAPHICS 
  70     delete m_graphicContext
; 
  71     m_graphicContext 
= NULL
; 
  72     DisposeWindow((WindowRef
) m_overlayWindow 
); 
  75         DisposePort( (CGrafPtr
) m_macPort 
) ;