1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/core/dcmemory.cpp
3 // Purpose: wxMemoryDC class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/dcmemory.h"
15 #include "wx/graphics.h"
16 #include "wx/osx/dcmemory.h"
18 #include "wx/osx/private.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
,wxPaintDCImpl
)
27 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
)
28 : wxPaintDCImpl( owner
)
33 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxBitmap
& bitmap
)
34 : wxPaintDCImpl( owner
)
40 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxDC
* WXUNUSED(dc
) )
41 : wxPaintDCImpl( owner
)
46 void wxMemoryDCImpl::Init()
49 SetBackground(*wxWHITE_BRUSH
);
50 SetBrush(*wxWHITE_BRUSH
);
52 SetFont(*wxNORMAL_FONT
);
56 wxMemoryDCImpl::~wxMemoryDCImpl()
58 if ( m_selected
.Ok() )
60 m_selected
.EndRawAccess() ;
61 wxDELETE(m_graphicContext
);
65 void wxMemoryDCImpl::DoSelect( const wxBitmap
& bitmap
)
67 if ( m_selected
.Ok() )
69 m_selected
.EndRawAccess() ;
70 wxDELETE(m_graphicContext
);
76 if ( m_selected
.GetDepth() != 1 )
77 m_selected
.UseAlpha() ;
78 m_selected
.BeginRawAccess() ;
79 m_width
= bitmap
.GetWidth();
80 m_height
= bitmap
.GetHeight();
81 CGColorSpaceRef genericColorSpace
= wxMacGetGenericRGBColorSpace();
82 CGContextRef bmCtx
= (CGContextRef
) m_selected
.GetHBITMAP();
86 CGContextSetFillColorSpace( bmCtx
, genericColorSpace
);
87 CGContextSetStrokeColorSpace( bmCtx
, genericColorSpace
);
88 SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx
) );
90 m_ok
= (m_graphicContext
!= NULL
) ;
98 void wxMemoryDCImpl::DoGetSize( int *width
, int *height
) const
103 (*width
) = m_selected
.GetWidth();
105 (*height
) = m_selected
.GetHeight();