]>
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"
21 #include "wx/os2/private.h"
23 #include "wx/dcmemory.h"
25 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxDC
)
27 /////////////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////////////
31 wxMemoryDC::wxMemoryDC(void)
33 CreateCompatible(NULL
);
35 } // end of wxMemoryDC::wxMemoryDC
37 wxMemoryDC::wxMemoryDC(
41 pOldDC
->BeginDrawing();
42 CreateCompatible(pOldDC
);
45 } // end of wxMemoryDC::wxMemoryDC
47 void wxMemoryDC::Init()
51 SetBrush(*wxWHITE_BRUSH
);
54 // the background mode is only used for text background and is set in
55 // DrawText() to OPAQUE as required, otherwise always TRANSPARENT
56 ::GpiSetBackMix( GetHPS(), BM_LEAVEALONE
);
58 memset(&m_vRclPaint
, 0, sizeof(m_vRclPaint
));
59 } // end of wxMemoryDC::Init
61 bool wxMemoryDC::CreateCompatible(
67 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
71 // Create a memory device context
73 hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
76 hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
84 // Set the wxWindows color table
86 ::GpiCreateLogColorTable( m_hPS
90 ,(LONG
)wxTheColourDatabase
->m_nSize
91 ,(PLONG
)wxTheColourDatabase
->m_palTable
93 ::GpiCreateLogColorTable( m_hPS
118 // As we created the DC, we must delete it in the dtor
123 } // end of wxMemoryDC::CreateCompatible
125 void wxMemoryDC::SelectObject(
126 const wxBitmap
& rBitmap
130 // Select old bitmap out of the device context
134 ::GpiSetBitmap(m_hPS
, NULLHANDLE
);
135 if (m_vSelectedBitmap
.Ok())
137 m_vSelectedBitmap
.SetSelectedInto(NULL
);
138 m_vSelectedBitmap
= wxNullBitmap
;
143 // Check for whether the bitmap is already selected into a device context
145 wxCHECK_RET( !rBitmap
.GetSelectedInto() ||
146 (rBitmap
.GetSelectedInto() == this),
147 wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") );
149 WXHBITMAP hBmp
= rBitmap
.GetHBITMAP();
153 m_vSelectedBitmap
.SetSelectedInto(NULL
);
155 m_vSelectedBitmap
= rBitmap
;
160 m_hOldBitmap
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, NULLHANDLE
);
163 m_vSelectedBitmap
.SetSelectedInto(this);
164 m_hOldBitmap
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, (HBITMAP
)hBmp
);
166 if (m_hOldBitmap
== HBM_ERROR
)
168 wxLogLastError(wxT("SelectObject(memDC, bitmap)"));
169 wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC"));
171 } // end of wxMemoryDC::SelectObject
173 void wxMemoryDC::DoGetSize(
178 if (!m_vSelectedBitmap
.Ok())
184 *pWidth
= m_vSelectedBitmap
.GetWidth();
185 *pHeight
= m_vSelectedBitmap
.GetHeight();
186 } // end of wxMemoryDC::DoGetSize