]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/dcmemory.cpp
64acc9f90dadbba6274f1228b2bfa35fcb02ec32
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/dcmemory.cpp
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"
15 #include "wx/dcmemory.h"
16 #include "wx/os2/dcmemory.h"
24 #include "wx/os2/private.h"
26 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxPMDCImpl
)
28 /////////////////////////////////////////////////////////////////////////////
30 /////////////////////////////////////////////////////////////////////////////
32 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
)
35 CreateCompatible(NULL
);
39 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxBitmap
& bitmap
)
42 CreateCompatible(NULL
);
47 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxDC
*pOldDC
)
50 wxCHECK_RET( pOldDC
, wxT("NULL dc in wxMemoryDC ctor") );
52 CreateCompatible(pOldDC
);
54 } // end of wxMemoryDC::wxMemoryDC
56 void wxMemoryDCImpl::Init()
60 SetBrush(*wxWHITE_BRUSH
);
63 // the background mode is only used for text background and is set in
64 // DrawText() to OPAQUE as required, otherwise always TRANSPARENT
65 ::GpiSetBackMix( GetHPS(), BM_LEAVEALONE
);
67 memset(&m_vRclPaint
, 0, sizeof(m_vRclPaint
));
68 } // end of wxMemoryDC::Init
70 bool wxMemoryDCImpl::CreateCompatible( wxDC
* WXUNUSED(pDC
) )
74 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
78 // Create a memory device context
80 hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
83 hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
91 // Set the wxWidgets color table
93 ::GpiCreateLogColorTable( m_hPS
97 ,(LONG
)wxTheColourDatabase
->m_nSize
98 ,(PLONG
)wxTheColourDatabase
->m_palTable
100 ::GpiCreateLogColorTable( m_hPS
125 // As we created the DC, we must delete it in the dtor
130 } // end of wxMemoryDC::CreateCompatible
132 void wxMemoryDCImpl::DoSelect(
133 const wxBitmap
& rBitmap
137 // Select old bitmap out of the device context
141 ::GpiSetBitmap(m_hPS
, NULLHANDLE
);
142 if (m_vSelectedBitmap
.IsOk())
144 m_vSelectedBitmap
.SetSelectedInto(NULL
);
145 m_vSelectedBitmap
= wxNullBitmap
;
150 // Check for whether the bitmap is already selected into a device context
152 wxCHECK_RET( !rBitmap
.GetSelectedInto() ||
153 (rBitmap
.GetSelectedInto() == GetOwner()),
154 wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") );
156 WXHBITMAP hBmp
= rBitmap
.GetHBITMAP();
161 // Bmps drawn to are upside down, so flip it before committing
163 POINTL vPoint
[4] = { {0, m_vSelectedBitmap
.GetHeight()}
164 ,{m_vSelectedBitmap
.GetWidth(), 0}
166 ,{m_vSelectedBitmap
.GetWidth(), m_vSelectedBitmap
.GetHeight()}
177 m_vSelectedBitmap
.SetSelectedInto(NULL
);
180 m_vSelectedBitmap
= rBitmap
;
186 m_hOldBitmap
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, NULLHANDLE
);
189 m_vSelectedBitmap
.SetSelectedInto(GetOwner());
190 m_hOldBitmap
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, (HBITMAP
)hBmp
);
192 if (m_hOldBitmap
== HBM_ERROR
)
194 wxLogLastError(wxT("SelectObject(memDC, bitmap)"));
195 wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC"));
197 } // end of wxMemoryDC::SelectObject
199 void wxMemoryDCImpl::DoGetSize(
204 if (!m_vSelectedBitmap
.IsOk())
210 *pWidth
= m_vSelectedBitmap
.GetWidth();
211 *pHeight
= m_vSelectedBitmap
.GetHeight();
212 } // end of wxMemoryDC::DoGetSize