]>
Commit | Line | Data |
---|---|---|
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 | #if wxMAC_USE_CORE_GRAPHICS | |
29 | CGRect cgbounds ; | |
30 | cgbounds = CGDisplayBounds(CGMainDisplayID()); | |
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; | |
36 | WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; | |
37 | CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow ); | |
38 | ShowWindow((WindowRef)m_overlayWindow); | |
39 | SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) ); | |
40 | m_width = (wxCoord)cgbounds.size.width; | |
41 | m_height = (wxCoord)cgbounds.size.height; | |
42 | #else | |
43 | m_macPort = CreateNewPort() ; | |
44 | GrafPtr port ; | |
45 | GetPort( &port ) ; | |
46 | SetPort( (GrafPtr) m_macPort ) ; | |
47 | Point pt = { 0,0 } ; | |
48 | LocalToGlobal( &pt ) ; | |
49 | SetPort( port ) ; | |
50 | m_deviceLocalOriginX = -pt.h ; | |
51 | m_deviceLocalOriginY = -pt.v ; | |
52 | ||
53 | BitMap screenBits; | |
54 | GetQDGlobalsScreenBits( &screenBits ); | |
55 | m_minX = screenBits.bounds.left ; | |
56 | ||
57 | SInt16 height ; | |
58 | GetThemeMenuBarHeight( &height ) ; | |
59 | m_minY = screenBits.bounds.top + height ; | |
60 | ||
61 | m_maxX = screenBits.bounds.right ; | |
62 | m_maxY = screenBits.bounds.bottom ; | |
63 | ||
64 | MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; | |
65 | OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_deviceLocalOriginX , m_deviceLocalOriginY ) ; | |
66 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; | |
67 | #endif | |
68 | m_ok = true ; | |
69 | } | |
70 | ||
71 | wxScreenDC::~wxScreenDC() | |
72 | { | |
73 | #if wxMAC_USE_CORE_GRAPHICS | |
74 | delete m_graphicContext; | |
75 | m_graphicContext = NULL; | |
76 | DisposeWindow((WindowRef) m_overlayWindow ); | |
77 | #else | |
78 | if ( m_macPort ) | |
79 | DisposePort( (CGrafPtr) m_macPort ) ; | |
80 | #endif | |
81 | } |