]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/dcscreen.cpp
As reported by Chris Elliott some releases of Lesstif crash
[wxWidgets.git] / src / mac / carbon / dcscreen.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcscreen.cpp
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
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e9576ca5
SC
13#pragma implementation "dcscreen.h"
14#endif
15
3d1a4878
SC
16#include "wx/wxprec.h"
17
e9576ca5 18#include "wx/dcscreen.h"
2f1ae414 19#include "wx/mac/uma.h"
e9576ca5 20
e9576ca5 21IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
e9576ca5
SC
22
23// Create a DC representing the whole screen
24wxScreenDC::wxScreenDC()
25{
fa9666fb 26 m_macPort = CreateNewPort() ;
e40298d5
JS
27 GrafPtr port ;
28 GetPort( &port ) ;
29 SetPort( (GrafPtr) m_macPort ) ;
30 Point pt = { 0,0 } ;
31 LocalToGlobal( &pt ) ;
32 SetPort( port ) ;
33 m_macLocalOrigin.x = -pt.h ;
34 m_macLocalOrigin.y = -pt.v ;
ec17cfa9 35#if wxMAC_USE_CORE_GRAPHICS
1181ee3f 36 m_macLocalOriginInPort = m_macLocalOrigin ;
ec17cfa9 37#endif
e40298d5
JS
38 BitMap screenBits;
39 GetQDGlobalsScreenBits( &screenBits );
cc44c710 40 m_minX = screenBits.bounds.left ;
20b69855 41
cc44c710
SC
42 SInt16 height ;
43 GetThemeMenuBarHeight( &height ) ;
44 m_minY = screenBits.bounds.top + height ;
20b69855 45
e40298d5
JS
46 m_maxX = screenBits.bounds.right ;
47 m_maxY = screenBits.bounds.bottom ;
cc44c710
SC
48
49#if wxMAC_USE_CORE_GRAPHICS
50 m_graphicContext = new wxMacCGContext( port ) ;
51#else
e40298d5
JS
52 MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
53 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
54 CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
20b69855 55#endif
cc44c710 56 m_ok = TRUE ;
e9576ca5
SC
57}
58
59wxScreenDC::~wxScreenDC()
fa9666fb 60{
20b69855 61#if wxMAC_USE_CORE_GRAPHICS
cc44c710
SC
62 delete m_graphicContext ;
63 m_graphicContext = NULL ;
20b69855 64#endif
cc44c710
SC
65
66 if ( m_macPort )
67 DisposePort( (CGrafPtr) m_macPort ) ;
e9576ca5
SC
68}
69