]> git.saurik.com Git - wxWidgets.git/blob - src/mac/dcmemory.cpp
removing dependancy on mac headers from public wx headers (eventually adding wx/mac...
[wxWidgets.git] / src / mac / 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 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