]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dcscreen.cpp
1de302dadeb0d7108d8f76185a0c1b78c70ebf51
[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 // 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
25 // Create a DC representing the whole screen
26 wxScreenDC::wxScreenDC()
27 {
28 CGRect cgbounds ;
29 cgbounds = CGDisplayBounds(CGMainDisplayID());
30 Rect bounds;
31 bounds.top = (short)cgbounds.origin.y;
32 bounds.left = (short)cgbounds.origin.x;
33 bounds.bottom = bounds.top + (short)cgbounds.size.height;
34 bounds.right = bounds.left + (short)cgbounds.size.width;
35 WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute;
36 CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow );
37 ShowWindow((WindowRef)m_overlayWindow);
38 SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
39 m_width = (wxCoord)cgbounds.size.width;
40 m_height = (wxCoord)cgbounds.size.height;
41 m_ok = true ;
42 }
43
44 wxScreenDC::~wxScreenDC()
45 {
46 delete m_graphicContext;
47 m_graphicContext = NULL;
48 DisposeWindow((WindowRef) m_overlayWindow );
49 }