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