]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/dcscreen.cpp
fixing reset clip
[wxWidgets.git] / src / mac / carbon / dcscreen.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
11dbb4bf 2// Name: src/mac/carbon/dcscreen.cpp
e9576ca5 3// Purpose: wxScreenDC class
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
11dbb4bf 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
e9576ca5 14#include "wx/dcscreen.h"
11dbb4bf 15
2f1ae414 16#include "wx/mac/uma.h"
8acd14d1 17#include "wx/graphics.h"
e9576ca5 18
e9576ca5 19IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
e9576ca5
SC
20
21// Create a DC representing the whole screen
22wxScreenDC::wxScreenDC()
23{
f7862d3e 24#if wxMAC_USE_CORE_GRAPHICS
a2d6d210 25 CGRect cgbounds ;
513b47e9 26 cgbounds = CGDisplayBounds(CGMainDisplayID());
a2d6d210
VZ
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;
513b47e9 32 WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute;
a2d6d210
VZ
33 CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow );
34 ShowWindow((WindowRef)m_overlayWindow);
513b47e9 35 SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
a2d6d210
VZ
36 m_width = (wxCoord)cgbounds.size.width;
37 m_height = (wxCoord)cgbounds.size.height;
f7862d3e 38#else
fa9666fb 39 m_macPort = CreateNewPort() ;
e40298d5
JS
40 GrafPtr port ;
41 GetPort( &port ) ;
42 SetPort( (GrafPtr) m_macPort ) ;
43 Point pt = { 0,0 } ;
11dbb4bf 44 LocalToGlobal( &pt ) ;
e40298d5
JS
45 SetPort( port ) ;
46 m_macLocalOrigin.x = -pt.h ;
47 m_macLocalOrigin.y = -pt.v ;
f7862d3e 48
e40298d5
JS
49 BitMap screenBits;
50 GetQDGlobalsScreenBits( &screenBits );
cc44c710 51 m_minX = screenBits.bounds.left ;
20b69855 52
cc44c710
SC
53 SInt16 height ;
54 GetThemeMenuBarHeight( &height ) ;
55 m_minY = screenBits.bounds.top + height ;
20b69855 56
e40298d5
JS
57 m_maxX = screenBits.bounds.right ;
58 m_maxY = screenBits.bounds.bottom ;
cc44c710 59
e40298d5
JS
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 ) ;
20b69855 63#endif
a2d6d210 64 m_ok = true ;
e9576ca5
SC
65}
66
67wxScreenDC::~wxScreenDC()
11dbb4bf 68{
20b69855 69#if wxMAC_USE_CORE_GRAPHICS
a2d6d210
VZ
70 delete m_graphicContext;
71 m_graphicContext = NULL;
72 DisposeWindow((WindowRef) m_overlayWindow );
f7862d3e 73#else
cc44c710
SC
74 if ( m_macPort )
75 DisposePort( (CGrafPtr) m_macPort ) ;
4f74e0d1 76#endif
e9576ca5 77}