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