]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/dcscreen.cpp
Commit patch [ 1559950 ] fix mem leaks in wx{Dir|File}Dialog
[wxWidgets.git] / src / mac / carbon / dcscreen.cpp
... / ...
CommitLineData
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
18IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
19
20// Create a DC representing the whole screen
21wxScreenDC::wxScreenDC()
22{
23 m_macPort = CreateNewPort() ;
24 GrafPtr port ;
25 GetPort( &port ) ;
26 SetPort( (GrafPtr) m_macPort ) ;
27 Point pt = { 0,0 } ;
28 LocalToGlobal( &pt ) ;
29 SetPort( port ) ;
30 m_macLocalOrigin.x = -pt.h ;
31 m_macLocalOrigin.y = -pt.v ;
32#if wxMAC_USE_CORE_GRAPHICS
33 m_macLocalOriginInPort = m_macLocalOrigin ;
34#endif
35 BitMap screenBits;
36 GetQDGlobalsScreenBits( &screenBits );
37 m_minX = screenBits.bounds.left ;
38
39 SInt16 height ;
40 GetThemeMenuBarHeight( &height ) ;
41 m_minY = screenBits.bounds.top + height ;
42
43 m_maxX = screenBits.bounds.right ;
44 m_maxY = screenBits.bounds.bottom ;
45
46#if wxMAC_USE_CORE_GRAPHICS
47 m_graphicContext = new wxMacCGContext( port ) ;
48#else
49 MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
50 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
51 CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
52#endif
53 m_ok = true ;
54}
55
56wxScreenDC::~wxScreenDC()
57{
58#if wxMAC_USE_CORE_GRAPHICS
59 delete m_graphicContext ;
60 m_graphicContext = NULL ;
61#endif
62
63 if ( m_macPort )
64 DisposePort( (CGrafPtr) m_macPort ) ;
65}