]> git.saurik.com Git - wxWidgets.git/blame - src/mac/dcmemory.cpp
Up-ported code to make tree item visible when programmatically
[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"
17
18//-----------------------------------------------------------------------------
19// wxMemoryDC
20//-----------------------------------------------------------------------------
21
22IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
23
24wxMemoryDC::wxMemoryDC(void)
25{
0a67a93b
SC
26 m_ok = TRUE;
27 SetBackground(*wxWHITE_BRUSH);
28 SetBrush(*wxWHITE_BRUSH);
29 SetPen(*wxBLACK_PEN);
e9576ca5
SC
30 m_ok = FALSE;
31};
32
33wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
34{
0a67a93b
SC
35 m_ok = TRUE;
36 SetBackground(*wxWHITE_BRUSH);
37 SetBrush(*wxWHITE_BRUSH);
38 SetPen(*wxBLACK_PEN);
e9576ca5
SC
39 m_ok = FALSE;
40};
41
3dec57ad 42wxMemoryDC::~wxMemoryDC()
e9576ca5 43{
2f1ae414
SC
44 if ( m_selected.Ok() )
45 {
3dec57ad 46 UnlockPixels( GetGWorldPixMap(m_selected.GetHBITMAP()) );
2f1ae414 47 }
e9576ca5
SC
48};
49
50void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
51{
2f1ae414
SC
52 if ( m_selected.Ok() )
53 {
3dec57ad 54 UnlockPixels( GetGWorldPixMap(m_selected.GetHBITMAP()) );
2f1ae414 55 }
3dec57ad
SC
56 m_selected = bitmap;
57 if (m_selected.Ok())
58 {
59 if ( m_selected.GetHBITMAP() )
519cb848 60 {
3dec57ad 61 m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
2f1ae414 62 LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
8208e181
SC
63 wxMask * mask = bitmap.GetMask() ;
64 if ( mask )
65 {
66 m_macMask = mask->GetMaskBitmap() ;
67 }
519cb848 68 m_ok = TRUE ;
519cb848
SC
69 }
70 else
71 {
3dec57ad 72 m_ok = FALSE;
519cb848 73 }
e9576ca5
SC
74 }
75 else
76 {
77 m_ok = FALSE;
3dec57ad
SC
78 }
79}
e9576ca5 80
0a67a93b 81void wxMemoryDC::DoGetSize( int *width, int *height ) const
e9576ca5
SC
82{
83 if (m_selected.Ok())
84 {
85 if (width) (*width) = m_selected.GetWidth();
86 if (height) (*height) = m_selected.GetHeight();
87 }
88 else
89 {
90 if (width) (*width) = 0;
91 if (height) (*height) = 0;
3dec57ad
SC
92 }
93}
e9576ca5
SC
94
95