]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/dcscreen.cpp
Border corrections
[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 20
6239ee05
SC
21// TODO : for the Screenshot use case, which doesn't work in Quartz
22// we should do a GetAsBitmap using something like
23// http://www.cocoabuilder.com/archive/message/cocoa/2005/8/13/144256
24
e9576ca5
SC
25// Create a DC representing the whole screen
26wxScreenDC::wxScreenDC()
27{
f7862d3e 28#if wxMAC_USE_CORE_GRAPHICS
a2d6d210 29 CGRect cgbounds ;
513b47e9 30 cgbounds = CGDisplayBounds(CGMainDisplayID());
a2d6d210
VZ
31 Rect bounds;
32 bounds.top = (short)cgbounds.origin.y;
33 bounds.left = (short)cgbounds.origin.x;
34 bounds.bottom = bounds.top + (short)cgbounds.size.height;
35 bounds.right = bounds.left + (short)cgbounds.size.width;
513b47e9 36 WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute;
a2d6d210
VZ
37 CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow );
38 ShowWindow((WindowRef)m_overlayWindow);
513b47e9 39 SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
a2d6d210
VZ
40 m_width = (wxCoord)cgbounds.size.width;
41 m_height = (wxCoord)cgbounds.size.height;
f7862d3e 42#else
fa9666fb 43 m_macPort = CreateNewPort() ;
e40298d5
JS
44 GrafPtr port ;
45 GetPort( &port ) ;
46 SetPort( (GrafPtr) m_macPort ) ;
47 Point pt = { 0,0 } ;
11dbb4bf 48 LocalToGlobal( &pt ) ;
e40298d5 49 SetPort( port ) ;
04ab8b6d
RR
50 m_deviceLocalOriginX = -pt.h ;
51 m_deviceLocalOriginY = -pt.v ;
f7862d3e 52
e40298d5
JS
53 BitMap screenBits;
54 GetQDGlobalsScreenBits( &screenBits );
cc44c710 55 m_minX = screenBits.bounds.left ;
20b69855 56
cc44c710
SC
57 SInt16 height ;
58 GetThemeMenuBarHeight( &height ) ;
59 m_minY = screenBits.bounds.top + height ;
20b69855 60
e40298d5
JS
61 m_maxX = screenBits.bounds.right ;
62 m_maxY = screenBits.bounds.bottom ;
cc44c710 63
e40298d5 64 MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
04ab8b6d 65 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_deviceLocalOriginX , m_deviceLocalOriginY ) ;
e40298d5 66 CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
20b69855 67#endif
a2d6d210 68 m_ok = true ;
e9576ca5
SC
69}
70
71wxScreenDC::~wxScreenDC()
11dbb4bf 72{
20b69855 73#if wxMAC_USE_CORE_GRAPHICS
a2d6d210
VZ
74 delete m_graphicContext;
75 m_graphicContext = NULL;
76 DisposeWindow((WindowRef) m_overlayWindow );
f7862d3e 77#else
cc44c710
SC
78 if ( m_macPort )
79 DisposePort( (CGrafPtr) m_macPort ) ;
4f74e0d1 80#endif
e9576ca5 81}