]>
Commit | Line | Data |
---|---|---|
2646f485 | 1 | ///////////////////////////////////////////////////////////////////////////// |
f38924e8 | 2 | // Name: src/mac/classic/dcmemory.cpp |
2646f485 SC |
3 | // Purpose: wxMemoryDC class |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
f38924e8 | 9 | // Licence: wxWindows licence |
2646f485 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
f38924e8 WS |
12 | #include "wx/wxprec.h" |
13 | ||
2646f485 | 14 | #include "wx/dcmemory.h" |
f38924e8 | 15 | |
2646f485 SC |
16 | #include "wx/mac/private.h" |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // wxMemoryDC | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) | |
23 | ||
432efcb0 | 24 | wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) |
f38924e8 | 25 | : m_selected() |
2646f485 | 26 | { |
f38924e8 | 27 | m_ok = true; |
2646f485 SC |
28 | SetBackground(*wxWHITE_BRUSH); |
29 | SetBrush(*wxWHITE_BRUSH); | |
30 | SetPen(*wxBLACK_PEN); | |
f38924e8 | 31 | m_ok = false; |
432efcb0 RD |
32 | |
33 | if ( bitmap.IsOk() ) | |
34 | SelectObject(bitmap); | |
2646f485 SC |
35 | }; |
36 | ||
37 | wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) | |
f38924e8 | 38 | : m_selected() |
2646f485 | 39 | { |
f38924e8 | 40 | m_ok = true; |
2646f485 SC |
41 | SetBackground(*wxWHITE_BRUSH); |
42 | SetBrush(*wxWHITE_BRUSH); | |
43 | SetPen(*wxBLACK_PEN); | |
f38924e8 | 44 | m_ok = false; |
2646f485 SC |
45 | }; |
46 | ||
47 | wxMemoryDC::~wxMemoryDC() | |
48 | { | |
49 | if ( m_selected.Ok() ) | |
50 | { | |
51 | UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); | |
52 | } | |
53 | }; | |
54 | ||
55 | void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) | |
56 | { | |
57 | if ( m_selected.Ok() ) | |
58 | { | |
59 | UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); | |
60 | } | |
61 | m_selected = bitmap; | |
62 | if (m_selected.Ok()) | |
63 | { | |
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 ) ; | |
f38924e8 | 75 | m_ok = true ; |
2646f485 SC |
76 | } |
77 | else | |
78 | { | |
f38924e8 | 79 | m_ok = false; |
2646f485 SC |
80 | } |
81 | } | |
82 | else | |
83 | { | |
f38924e8 | 84 | m_ok = false; |
2646f485 SC |
85 | } |
86 | } | |
87 | ||
88 | void wxMemoryDC::DoGetSize( int *width, int *height ) const | |
89 | { | |
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 | } | |
100 | } |