]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dcscreen.cpp
a19dc36477a03e1157c1ee9bb04633e9c703436c
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
24 CGrafPtr grafptr
= CreateNewPort() ;
25 m_displayId
= (UInt32
) grafptr
;
26 CGContextRef cg
= NULL
;
27 OSStatus status
= QDBeginCGContext( grafptr
, &cg
);
30 bounds
= CGDisplayBounds(CGMainDisplayID());
33 GetThemeMenuBarHeight( &height
);
36 m_maxX
= bounds
.size
.width
;
37 m_maxY
= bounds
.size
.height
- height
;
38 CGContextTranslateCTM( cg
, 0 , bounds
.size
.height
);
39 CGContextScaleCTM( cg
, 1 , -1 );
41 SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg
) );
42 m_width
= bounds
.size
.width
;
43 m_height
= bounds
.size
.height
- height
;
45 m_macPort
= CreateNewPort() ;
48 SetPort( (GrafPtr
) m_macPort
) ;
50 LocalToGlobal( &pt
) ;
52 m_macLocalOrigin
.x
= -pt
.h
;
53 m_macLocalOrigin
.y
= -pt
.v
;
56 GetQDGlobalsScreenBits( &screenBits
);
57 m_minX
= screenBits
.bounds
.left
;
60 GetThemeMenuBarHeight( &height
) ;
61 m_minY
= screenBits
.bounds
.top
+ height
;
63 m_maxX
= screenBits
.bounds
.right
;
64 m_maxY
= screenBits
.bounds
.bottom
;
66 MacSetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_minX
, m_minY
, m_maxX
, m_maxY
) ;
67 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
68 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
73 wxScreenDC::~wxScreenDC()
75 #if wxMAC_USE_CORE_GRAPHICS
76 CGrafPtr grafptr
= (CGrafPtr
) m_displayId
;
77 m_displayId
= (UInt32
) grafptr
;
78 CGContextRef cg
= (CGContextRef
) m_graphicContext
->GetNativeContext();
79 QDEndCGContext(grafptr
, &cg
);
81 delete m_graphicContext
;
82 m_graphicContext
= NULL
;
85 DisposePort( (CGrafPtr
) m_macPort
) ;