]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dcscreen.cpp
fix warnings (double to int conversions and unused variables); removed hard TABs...
[wxWidgets.git] / src / mac / carbon / dcscreen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/dcscreen.cpp
3 // Purpose: wxScreenDC class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/dcscreen.h"
15
16 #include "wx/mac/uma.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
19
20 // Create a DC representing the whole screen
21 wxScreenDC::wxScreenDC()
22 {
23 #if wxMAC_USE_CORE_GRAPHICS
24 CGRect cgbounds ;
25 cgbounds = CGDisplayBounds(CGMainDisplayID());
26 Rect bounds;
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;
37 #else
38 m_macPort = CreateNewPort() ;
39 GrafPtr port ;
40 GetPort( &port ) ;
41 SetPort( (GrafPtr) m_macPort ) ;
42 Point pt = { 0,0 } ;
43 LocalToGlobal( &pt ) ;
44 SetPort( port ) ;
45 m_macLocalOrigin.x = -pt.h ;
46 m_macLocalOrigin.y = -pt.v ;
47
48 BitMap screenBits;
49 GetQDGlobalsScreenBits( &screenBits );
50 m_minX = screenBits.bounds.left ;
51
52 SInt16 height ;
53 GetThemeMenuBarHeight( &height ) ;
54 m_minY = screenBits.bounds.top + height ;
55
56 m_maxX = screenBits.bounds.right ;
57 m_maxY = screenBits.bounds.bottom ;
58
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 ) ;
62 #endif
63 m_ok = true ;
64 }
65
66 wxScreenDC::~wxScreenDC()
67 {
68 #if wxMAC_USE_CORE_GRAPHICS
69 delete m_graphicContext;
70 m_graphicContext = NULL;
71 DisposeWindow((WindowRef) m_overlayWindow );
72 #else
73 if ( m_macPort )
74 DisposePort( (CGrafPtr) m_macPort ) ;
75 #endif
76 }