]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/dcmemory.cpp
Add class factories for filter streams. Also filters now follow the convention
[wxWidgets.git] / src / mac / classic / dcmemory.cpp
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
22 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
23
24 wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
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 if ( bitmap.IsOk() )
34 SelectObject(bitmap);
35 };
36
37 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
38 : m_selected()
39 {
40 m_ok = true;
41 SetBackground(*wxWHITE_BRUSH);
42 SetBrush(*wxWHITE_BRUSH);
43 SetPen(*wxBLACK_PEN);
44 m_ok = false;
45 };
46
47 wxMemoryDC::~wxMemoryDC()
48 {
49 if ( m_selected.Ok() )
50 {
51 UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
52 }
53 };
54
55 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
56 {
57 if ( m_selected.Ok() )
58 {
59 UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
60 }
61 m_selected = bitmap;
62 if (m_selected.Ok())
63 {
64 if ( m_selected.GetHBITMAP() )
65 {
66 m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
67 LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
68 wxMask * mask = bitmap.GetMask() ;
69 if ( mask )
70 {
71 m_macMask = mask->GetMaskBitmap() ;
72 }
73 SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
74 CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
75 m_ok = true ;
76 }
77 else
78 {
79 m_ok = false;
80 }
81 }
82 else
83 {
84 m_ok = false;
85 }
86 }
87
88 void wxMemoryDC::DoGetSize( int *width, int *height ) const
89 {
90 if (m_selected.Ok())
91 {
92 if (width) (*width) = m_selected.GetWidth();
93 if (height) (*height) = m_selected.GetHeight();
94 }
95 else
96 {
97 if (width) (*width) = 0;
98 if (height) (*height) = 0;
99 }
100 }