]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dcmemory.cpp
Got rid of some wierd VisualAge debug nonsense that had appeared in this after the...
[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
18 //-----------------------------------------------------------------------------
19 // wxMemoryDC
20 //-----------------------------------------------------------------------------
21
22 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
23
24 wxMemoryDC::wxMemoryDC(void)
25 {
26 m_ok = FALSE;
27 };
28
29 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
30 {
31 m_ok = FALSE;
32 };
33
34 wxMemoryDC::~wxMemoryDC(void)
35 {
36 if ( m_selected.Ok() )
37 {
38 wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
39 UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
40 }
41 };
42
43 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
44 {
45 if ( m_selected.Ok() )
46 {
47 wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
48 UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
49 }
50 m_selected = bitmap;
51 if (m_selected.Ok())
52 {
53 wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
54 if ( bmap->m_hBitmap )
55 {
56 m_macPort = (GrafPtr) bmap->m_hBitmap ;
57 LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
58 wxMask * mask = bitmap.GetMask() ;
59 if ( mask )
60 {
61 m_macMask = mask->GetMaskBitmap() ;
62 }
63 MacSetupPort() ;
64 m_ok = TRUE ;
65 // SetBackground(wxBrush(*wxWHITE, wxSOLID));
66 }
67 else
68 {
69 m_ok = FALSE;
70 }
71 }
72 else
73 {
74 m_ok = FALSE;
75 };
76 };
77
78 void wxMemoryDC::GetSize( int *width, int *height ) const
79 {
80 if (m_selected.Ok())
81 {
82 if (width) (*width) = m_selected.GetWidth();
83 if (height) (*height) = m_selected.GetHeight();
84 }
85 else
86 {
87 if (width) (*width) = 0;
88 if (height) (*height) = 0;
89 };
90 };
91
92