]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dcmemory.cpp | |
3 | // Purpose: wxMemoryDC class | |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 SC |
5 | // Modified by: |
6 | // Created: 01/02/97 | |
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 "dcmemory.h" |
14 | #endif | |
15 | ||
3d1a4878 SC |
16 | #include "wx/wxprec.h" |
17 | ||
e9576ca5 | 18 | #include "wx/dcmemory.h" |
76a5e5d2 | 19 | #include "wx/mac/private.h" |
e9576ca5 SC |
20 | |
21 | //----------------------------------------------------------------------------- | |
22 | // wxMemoryDC | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
25 | IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) | |
26 | ||
27 | wxMemoryDC::wxMemoryDC(void) | |
e40298d5 | 28 | : m_selected() |
e9576ca5 | 29 | { |
e40298d5 | 30 | m_ok = TRUE; |
0a67a93b SC |
31 | SetBackground(*wxWHITE_BRUSH); |
32 | SetBrush(*wxWHITE_BRUSH); | |
33 | SetPen(*wxBLACK_PEN); | |
e40298d5 | 34 | m_ok = FALSE; |
e9576ca5 SC |
35 | }; |
36 | ||
37 | wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) | |
e40298d5 | 38 | : m_selected() |
e9576ca5 | 39 | { |
e40298d5 | 40 | m_ok = TRUE; |
0a67a93b SC |
41 | SetBackground(*wxWHITE_BRUSH); |
42 | SetBrush(*wxWHITE_BRUSH); | |
43 | SetPen(*wxBLACK_PEN); | |
e40298d5 | 44 | m_ok = FALSE; |
e9576ca5 SC |
45 | }; |
46 | ||
3dec57ad | 47 | wxMemoryDC::~wxMemoryDC() |
e9576ca5 | 48 | { |
e40298d5 JS |
49 | if ( m_selected.Ok() ) |
50 | { | |
51 | UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); | |
52 | } | |
e9576ca5 SC |
53 | }; |
54 | ||
55 | void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) | |
56 | { | |
e40298d5 JS |
57 | if ( m_selected.Ok() ) |
58 | { | |
59 | UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); | |
60 | } | |
3dec57ad SC |
61 | m_selected = bitmap; |
62 | if (m_selected.Ok()) | |
63 | { | |
e40298d5 JS |
64 | if ( m_selected.GetHBITMAP() ) |
65 | { | |
66 | m_macPort = (GrafPtr) m_selected.GetHBITMAP() ; | |
67 | LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; | |
68 | wxMask * mask = bitmap.GetMask() ; | |
69 | if ( mask ) | |
70 | { | |
71 | m_macMask = mask->GetMaskBitmap() ; | |
72 | } | |
73 | SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; | |
74 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; | |
75 | m_ok = TRUE ; | |
76 | } | |
77 | else | |
78 | { | |
79 | m_ok = FALSE; | |
80 | } | |
81 | } | |
82 | else | |
83 | { | |
84 | m_ok = FALSE; | |
85 | } | |
3dec57ad | 86 | } |
e9576ca5 | 87 | |
0a67a93b | 88 | void wxMemoryDC::DoGetSize( int *width, int *height ) const |
e9576ca5 | 89 | { |
e40298d5 JS |
90 | if (m_selected.Ok()) |
91 | { | |
92 | if (width) (*width) = m_selected.GetWidth(); | |
93 | if (height) (*height) = m_selected.GetHeight(); | |
94 | } | |
95 | else | |
96 | { | |
97 | if (width) (*width) = 0; | |
98 | if (height) (*height) = 0; | |
99 | } | |
3dec57ad | 100 | } |
e9576ca5 SC |
101 | |
102 |