]> git.saurik.com Git - wxWidgets.git/blame - src/mac/dcmemory.cpp
removing dependancy on mac headers from public wx headers (eventually adding wx/mac...
[wxWidgets.git] / src / mac / dcmemory.cpp
CommitLineData
e9576ca5
SC
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"
76a5e5d2 17#include "wx/mac/private.h"
e9576ca5
SC
18
19//-----------------------------------------------------------------------------
20// wxMemoryDC
21//-----------------------------------------------------------------------------
22
23IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
24
25wxMemoryDC::wxMemoryDC(void)
26{
0a67a93b
SC
27 m_ok = TRUE;
28 SetBackground(*wxWHITE_BRUSH);
29 SetBrush(*wxWHITE_BRUSH);
30 SetPen(*wxBLACK_PEN);
e9576ca5
SC
31 m_ok = FALSE;
32};
33
34wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
35{
0a67a93b
SC
36 m_ok = TRUE;
37 SetBackground(*wxWHITE_BRUSH);
38 SetBrush(*wxWHITE_BRUSH);
39 SetPen(*wxBLACK_PEN);
e9576ca5
SC
40 m_ok = FALSE;
41};
42
3dec57ad 43wxMemoryDC::~wxMemoryDC()
e9576ca5 44{
2f1ae414
SC
45 if ( m_selected.Ok() )
46 {
76a5e5d2 47 UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
2f1ae414 48 }
e9576ca5
SC
49};
50
51void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
52{
2f1ae414
SC
53 if ( m_selected.Ok() )
54 {
76a5e5d2 55 UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
2f1ae414 56 }
3dec57ad
SC
57 m_selected = bitmap;
58 if (m_selected.Ok())
59 {
60 if ( m_selected.GetHBITMAP() )
519cb848 61 {
3dec57ad 62 m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
2f1ae414 63 LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
8208e181
SC
64 wxMask * mask = bitmap.GetMask() ;
65 if ( mask )
66 {
67 m_macMask = mask->GetMaskBitmap() ;
68 }
519cb848 69 m_ok = TRUE ;
519cb848
SC
70 }
71 else
72 {
3dec57ad 73 m_ok = FALSE;
519cb848 74 }
e9576ca5
SC
75 }
76 else
77 {
78 m_ok = FALSE;
3dec57ad
SC
79 }
80}
e9576ca5 81
0a67a93b 82void wxMemoryDC::DoGetSize( int *width, int *height ) const
e9576ca5
SC
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;
3dec57ad
SC
93 }
94}
e9576ca5
SC
95
96