]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/classic/dcmemory.cpp
Back to previous call with -1 replacement.
[wxWidgets.git] / src / mac / classic / dcmemory.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/mac/classic/dcmemory.cpp
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/dcmemory.h"
15
16#include "wx/mac/private.h"
17
18//-----------------------------------------------------------------------------
19// wxMemoryDC
20//-----------------------------------------------------------------------------
21
22IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
23
24wxMemoryDC::wxMemoryDC(void)
25 : m_selected()
26{
27 m_ok = true;
28 SetBackground(*wxWHITE_BRUSH);
29 SetBrush(*wxWHITE_BRUSH);
30 SetPen(*wxBLACK_PEN);
31 m_ok = false;
32};
33
34wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
35 : m_selected()
36{
37 m_ok = true;
38 SetBackground(*wxWHITE_BRUSH);
39 SetBrush(*wxWHITE_BRUSH);
40 SetPen(*wxBLACK_PEN);
41 m_ok = false;
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 ) ;
72 m_ok = true ;
73 }
74 else
75 {
76 m_ok = false;
77 }
78 }
79 else
80 {
81 m_ok = false;
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}