]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMemoryDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
14 #pragma implementation "dcmemory.h"
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
27 #include "wx/dcmemory.h"
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_DYNAMIC_CLASS ( wxMemoryDC
, wxDC
)
40 wxMemoryDC :: wxMemoryDC ( void )
42 m_hDC
= ( WXHDC
) :: CreateCompatibleDC ( NULL
);
45 SetBrush (* wxWHITE_BRUSH
);
49 wxMemoryDC :: wxMemoryDC ( wxDC
* old_dc
)
51 old_dc
-> BeginDrawing ();
53 m_hDC
= ( WXHDC
) :: CreateCompatibleDC (( HDC
) old_dc
-> GetHDC ());
58 SetBrush (* wxWHITE_BRUSH
);
62 wxMemoryDC ::~ wxMemoryDC ( void )
66 void wxMemoryDC :: SelectObject ( const wxBitmap
& bitmap
)
68 // Select old bitmap out of the device context
71 :: SelectObject (( HDC
) m_hDC
, ( HBITMAP
) m_oldBitmap
);
72 if ( m_selectedBitmap
. Ok ())
74 m_selectedBitmap
. SetSelectedInto ( NULL
);
75 m_selectedBitmap
= wxNullBitmap
;
79 // Do own check for whether the bitmap is already selected into
81 if ( bitmap
. GetSelectedInto () && ( bitmap
. GetSelectedInto () != this ))
83 wxFatalError ( "Error in wxMemoryDC::SelectObject \n Bitmap is selected in another wxMemoryDC. \n Delete the first wxMemoryDC or use SelectObject(NULL)" );
87 m_selectedBitmap
= bitmap
;
89 if (! m_selectedBitmap
. Ok ())
92 m_selectedBitmap
. SetSelectedInto ( this );
94 wxDebugMsg ( "wxMemoryDC::SelectObject: Selecting HBITMAP %X \n " , m_selectedBitmap
. GetHBITMAP ());
96 HBITMAP bm
= :: SelectObject (( HDC
) m_hDC
, ( HBITMAP
) m_selectedBitmap
. GetHBITMAP ());
100 wxFatalError ( "Error in wxMemoryDC::SelectObject \n Bitmap may not be loaded, or may be selected in another wxMemoryDC. \n Delete the first wxMemoryDC to deselect bitmap." );
102 else if (! m_oldBitmap
)
103 m_oldBitmap
= ( WXHBITMAP
) bm
;
106 void wxMemoryDC :: GetSize ( int * width
, int * height
) const
108 if (! m_selectedBitmap
. Ok ())
110 * width
= 0 ; * height
= 0 ;
113 * width
= m_selectedBitmap
. GetWidth ();
114 * height
= m_selectedBitmap
. GetHeight ();