]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dcscreen.cpp
Add middle-item click support.
[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 #include "wx/graphics.h"
18
19 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
20
21 // Create a DC representing the whole screen
22 wxScreenDC::wxScreenDC()
23 {
24 #if wxMAC_USE_CORE_GRAPHICS
25 CGRect cgbounds ;
26 cgbounds = CGDisplayBounds(CGMainDisplayID());
27 Rect bounds;
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;
38 #else
39 m_macPort = CreateNewPort() ;
40 GrafPtr port ;
41 GetPort( &port ) ;
42 SetPort( (GrafPtr) m_macPort ) ;
43 Point pt = { 0,0 } ;
44 LocalToGlobal( &pt ) ;
45 SetPort( port ) ;
46 m_macLocalOrigin.x = -pt.h ;
47 m_macLocalOrigin.y = -pt.v ;
48
49 BitMap screenBits;
50 GetQDGlobalsScreenBits( &screenBits );
51 m_minX = screenBits.bounds.left ;
52
53 SInt16 height ;
54 GetThemeMenuBarHeight( &height ) ;
55 m_minY = screenBits.bounds.top + height ;
56
57 m_maxX = screenBits.bounds.right ;
58 m_maxY = screenBits.bounds.bottom ;
59
60 MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
61 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
62 CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
63 #endif
64 m_ok = true ;
65 }
66
67 wxScreenDC::~wxScreenDC()
68 {
69 #if wxMAC_USE_CORE_GRAPHICS
70 delete m_graphicContext;
71 m_graphicContext = NULL;
72 DisposeWindow((WindowRef) m_overlayWindow );
73 #else
74 if ( m_macPort )
75 DisposePort( (CGrafPtr) m_macPort ) ;
76 #endif
77 }