]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: dcmemory.cpp | |
3 | // Purpose: wxMemoryDC class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "dcmemory.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/dcmemory.h" | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // wxMemoryDC | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) | |
23 | ||
24 | wxMemoryDC::wxMemoryDC(void) | |
25 | { | |
26 | m_ok = TRUE; | |
27 | SetBackground(*wxWHITE_BRUSH); | |
28 | SetBrush(*wxWHITE_BRUSH); | |
29 | SetPen(*wxBLACK_PEN); | |
30 | m_ok = FALSE; | |
31 | }; | |
32 | ||
33 | wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) | |
34 | { | |
35 | m_ok = TRUE; | |
36 | SetBackground(*wxWHITE_BRUSH); | |
37 | SetBrush(*wxWHITE_BRUSH); | |
38 | SetPen(*wxBLACK_PEN); | |
39 | m_ok = FALSE; | |
40 | }; | |
41 | ||
42 | wxMemoryDC::~wxMemoryDC(void) | |
43 | { | |
44 | if ( m_selected.Ok() ) | |
45 | { | |
46 | wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ; | |
47 | UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ; | |
48 | } | |
49 | }; | |
50 | ||
51 | void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) | |
52 | { | |
53 | if ( m_selected.Ok() ) | |
54 | { | |
55 | wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ; | |
56 | UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ; | |
57 | } | |
58 | m_selected = bitmap; | |
59 | if (m_selected.Ok()) | |
60 | { | |
61 | wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ; | |
62 | if ( bmap->m_hBitmap ) | |
63 | { | |
64 | m_macPort = (GrafPtr) bmap->m_hBitmap ; | |
65 | LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; | |
66 | wxMask * mask = bitmap.GetMask() ; | |
67 | if ( mask ) | |
68 | { | |
69 | m_macMask = mask->GetMaskBitmap() ; | |
70 | } | |
71 | MacSetupPort() ; | |
72 | m_ok = TRUE ; | |
73 | // SetBackground(wxBrush(*wxWHITE, wxSOLID)); | |
74 | } | |
75 | else | |
76 | { | |
77 | m_ok = FALSE; | |
78 | } | |
79 | } | |
80 | else | |
81 | { | |
82 | m_ok = FALSE; | |
83 | }; | |
84 | }; | |
85 | ||
86 | void wxMemoryDC::DoGetSize( int *width, int *height ) const | |
87 | { | |
88 | if (m_selected.Ok()) | |
89 | { | |
90 | if (width) (*width) = m_selected.GetWidth(); | |
91 | if (height) (*height) = m_selected.GetHeight(); | |
92 | } | |
93 | else | |
94 | { | |
95 | if (width) (*width) = 0; | |
96 | if (height) (*height) = 0; | |
97 | }; | |
98 | }; | |
99 | ||
100 |