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 // TODO : for the Screenshot use case, which doesn't work in Quartz
22 // we should do a GetAsBitmap using something like
23 // http://www.cocoabuilder.com/archive/message/cocoa/2005/8/13/144256
25 // Create a DC representing the whole screen
26 wxScreenDC::wxScreenDC()
28 #if wxMAC_USE_CORE_GRAPHICS
30 cgbounds
= CGDisplayBounds(CGMainDisplayID());
32 bounds
.top
= (short)cgbounds
.origin
.y
;
33 bounds
.left
= (short)cgbounds
.origin
.x
;
34 bounds
.bottom
= bounds
.top
+ (short)cgbounds
.size
.height
;
35 bounds
.right
= bounds
.left
+ (short)cgbounds
.size
.width
;
36 WindowAttributes overlayAttributes
= kWindowIgnoreClicksAttribute
;
37 CreateNewWindow( kOverlayWindowClass
, overlayAttributes
, &bounds
, (WindowRef
*) &m_overlayWindow
);
38 ShowWindow((WindowRef
)m_overlayWindow
);
39 SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow
) );
40 m_width
= (wxCoord
)cgbounds
.size
.width
;
41 m_height
= (wxCoord
)cgbounds
.size
.height
;
43 m_macPort
= CreateNewPort() ;
46 SetPort( (GrafPtr
) m_macPort
) ;
48 LocalToGlobal( &pt
) ;
50 m_deviceLocalOriginX
= -pt
.h
;
51 m_deviceLocalOriginY
= -pt
.v
;
54 GetQDGlobalsScreenBits( &screenBits
);
55 m_minX
= screenBits
.bounds
.left
;
58 GetThemeMenuBarHeight( &height
) ;
59 m_minY
= screenBits
.bounds
.top
+ height
;
61 m_maxX
= screenBits
.bounds
.right
;
62 m_maxY
= screenBits
.bounds
.bottom
;
64 MacSetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_minX
, m_minY
, m_maxX
, m_maxY
) ;
65 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_deviceLocalOriginX
, m_deviceLocalOriginY
) ;
66 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
71 wxScreenDC::~wxScreenDC()
73 #if wxMAC_USE_CORE_GRAPHICS
74 delete m_graphicContext
;
75 m_graphicContext
= NULL
;
76 DisposeWindow((WindowRef
) m_overlayWindow
);
79 DisposePort( (CGrafPtr
) m_macPort
) ;