]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMemoryDC class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/os2/private.h"
21 #include "wx/dcmemory.h"
23 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxDC
)
25 /////////////////////////////////////////////////////////////////////////////
27 /////////////////////////////////////////////////////////////////////////////
29 wxMemoryDC::wxMemoryDC(void)
31 CreateCompatible(NULL
);
33 } // end of wxMemoryDC::wxMemoryDC
35 wxMemoryDC::wxMemoryDC(
39 pOldDC
->BeginDrawing();
40 CreateCompatible(pOldDC
);
43 } // end of wxMemoryDC::wxMemoryDC
45 void wxMemoryDC::Init()
49 SetBrush(*wxWHITE_BRUSH
);
52 // the background mode is only used for text background and is set in
53 // DrawText() to OPAQUE as required, otherwise always TRANSPARENT
54 ::GpiSetBackMix( GetHPS(), BM_LEAVEALONE
);
56 } // end of wxMemoryDC::Init
58 bool wxMemoryDC::CreateCompatible(
64 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
68 // Create a memory device context
70 hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
73 hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
81 // Set the wxWindows color table
83 ::GpiCreateLogColorTable( m_hPS
87 ,(LONG
)wxTheColourDatabase
->m_nSize
88 ,(PLONG
)wxTheColourDatabase
->m_palTable
90 ::GpiCreateLogColorTable( m_hPS
115 // As we created the DC, we must delete it in the dtor
120 } // end of wxMemoryDC::CreateCompatible
122 void wxMemoryDC::SelectObject(
123 const wxBitmap
& rBitmap
127 // Select old bitmap out of the device context
131 ::GpiSetBitmap(m_hPS
, NULLHANDLE
);
132 if (m_vSelectedBitmap
.Ok())
134 m_vSelectedBitmap
.SetSelectedInto(NULL
);
135 m_vSelectedBitmap
= wxNullBitmap
;
140 // Check for whether the bitmap is already selected into a device context
142 wxCHECK_RET( !rBitmap
.GetSelectedInto() ||
143 (rBitmap
.GetSelectedInto() == this),
144 wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") );
146 m_vSelectedBitmap
= rBitmap
;
148 WXHBITMAP hBmp
= m_vSelectedBitmap
.GetHBITMAP();
153 m_vSelectedBitmap
.SetSelectedInto(this);
154 hBmp
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, (HBITMAP
)hBmp
);
156 if (hBmp
== HBM_ERROR
)
158 wxLogLastError(wxT("SelectObject(memDC, bitmap)"));
159 wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC"));
161 else if (!m_hOldBitmap
)
165 } // end of wxMemoryDC::SelectObject
167 void wxMemoryDC::DoGetSize(
172 if (!m_vSelectedBitmap
.Ok())
178 *pWidth
= m_vSelectedBitmap
.GetWidth();
179 *pHeight
= m_vSelectedBitmap
.GetHeight();
180 } // end of wxMemoryDC::DoGetSize
182 void wxMemoryDC::DoDrawRectangle(
189 wxDC::DoDrawRectangle(vX
, vY
, vWidth
, vHeight
);
190 } // end of wxMemoryDC::DoDrawRectangle