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"
18 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
)
20 // Create a DC representing the whole screen
21 wxScreenDC::wxScreenDC()
23 #if wxMAC_USE_CORE_GRAPHICS
25 cgbounds
= CGDisplayBounds(CGMainDisplayID());
27 bounds
.top
= (short)cgbounds
.origin
.y
;
28 bounds
.left
= (short)cgbounds
.origin
.x
;
29 bounds
.bottom
= bounds
.top
+ (short)cgbounds
.size
.height
;
30 bounds
.right
= bounds
.left
+ (short)cgbounds
.size
.width
;
31 WindowAttributes overlayAttributes
= kWindowIgnoreClicksAttribute
;
32 CreateNewWindow( kOverlayWindowClass
, overlayAttributes
, &bounds
, (WindowRef
*) &m_overlayWindow
);
33 ShowWindow((WindowRef
)m_overlayWindow
);
34 SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow
) );
35 m_width
= (wxCoord
)cgbounds
.size
.width
;
36 m_height
= (wxCoord
)cgbounds
.size
.height
;
38 m_macPort
= CreateNewPort() ;
41 SetPort( (GrafPtr
) m_macPort
) ;
43 LocalToGlobal( &pt
) ;
45 m_macLocalOrigin
.x
= -pt
.h
;
46 m_macLocalOrigin
.y
= -pt
.v
;
49 GetQDGlobalsScreenBits( &screenBits
);
50 m_minX
= screenBits
.bounds
.left
;
53 GetThemeMenuBarHeight( &height
) ;
54 m_minY
= screenBits
.bounds
.top
+ height
;
56 m_maxX
= screenBits
.bounds
.right
;
57 m_maxY
= screenBits
.bounds
.bottom
;
59 MacSetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_minX
, m_minY
, m_maxX
, m_maxY
) ;
60 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
61 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
66 wxScreenDC::~wxScreenDC()
68 #if wxMAC_USE_CORE_GRAPHICS
69 delete m_graphicContext
;
70 m_graphicContext
= NULL
;
71 DisposeWindow((WindowRef
) m_overlayWindow
);
74 DisposePort( (CGrafPtr
) m_macPort
) ;