]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/dcmemory.cpp
Test commit
[wxWidgets.git] / src / mac / classic / dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcmemory.cpp
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/dcmemory.h"
13 #include "wx/mac/private.h"
14
15 //-----------------------------------------------------------------------------
16 // wxMemoryDC
17 //-----------------------------------------------------------------------------
18
19 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
20
21 wxMemoryDC::wxMemoryDC(void)
22 : m_selected()
23 {
24 m_ok = TRUE;
25 SetBackground(*wxWHITE_BRUSH);
26 SetBrush(*wxWHITE_BRUSH);
27 SetPen(*wxBLACK_PEN);
28 m_ok = FALSE;
29 };
30
31 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
32 : m_selected()
33 {
34 m_ok = TRUE;
35 SetBackground(*wxWHITE_BRUSH);
36 SetBrush(*wxWHITE_BRUSH);
37 SetPen(*wxBLACK_PEN);
38 m_ok = FALSE;
39 };
40
41 wxMemoryDC::~wxMemoryDC()
42 {
43 if ( m_selected.Ok() )
44 {
45 UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
46 }
47 };
48
49 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
50 {
51 if ( m_selected.Ok() )
52 {
53 UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
54 }
55 m_selected = bitmap;
56 if (m_selected.Ok())
57 {
58 if ( m_selected.GetHBITMAP() )
59 {
60 m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
61 LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
62 wxMask * mask = bitmap.GetMask() ;
63 if ( mask )
64 {
65 m_macMask = mask->GetMaskBitmap() ;
66 }
67 SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
68 CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
69 m_ok = TRUE ;
70 }
71 else
72 {
73 m_ok = FALSE;
74 }
75 }
76 else
77 {
78 m_ok = FALSE;
79 }
80 }
81
82 void wxMemoryDC::DoGetSize( int *width, int *height ) const
83 {
84 if (m_selected.Ok())
85 {
86 if (width) (*width) = m_selected.GetWidth();
87 if (height) (*height) = m_selected.GetHeight();
88 }
89 else
90 {
91 if (width) (*width) = 0;
92 if (height) (*height) = 0;
93 }
94 }
95
96