]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/dcmemory.cpp
d9d6a2201f54d3ff1f62d9b7ccac21222e5b25aa
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)
33 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
37 // Create a memory device context
39 hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
42 hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
49 SetBrush(*wxWHITE_BRUSH
);
67 } // end of wxMemoryDC::wxMemoryDC
69 wxMemoryDC::wxMemoryDC(
75 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
78 pOldDC
->BeginDrawing();
81 // Create a memory device context
83 hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, GetHdcOf(*pOldDC
));
86 hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
94 SetBrush(*wxWHITE_BRUSH
);
108 pOldDC
->EndDrawing();
114 } // end of wxMemoryDC::wxMemoryDC
116 wxMemoryDC::~wxMemoryDC()
118 if (m_hPS
!= NULLHANDLE
)
119 ::GpiDestroyPS(m_hPS
);
120 if (m_hDC
!= NULLHANDLE
)
122 } // end of wxMemoryDC::~wxMemoryDC
124 void wxMemoryDC::SelectObject(
125 const wxBitmap
& rBitmap
129 // Select old bitmap out of the device context
133 ::GpiSetBitmap(m_hPS
, NULLHANDLE
);
134 if (m_vSelectedBitmap
.Ok())
136 m_vSelectedBitmap
.SetSelectedInto(NULL
);
137 m_vSelectedBitmap
= wxNullBitmap
;
142 // Check for whether the bitmap is already selected into a device context
144 wxCHECK_RET( !rBitmap
.GetSelectedInto() ||
145 (rBitmap
.GetSelectedInto() == this),
146 wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") );
148 m_vSelectedBitmap
= rBitmap
;
150 WXHBITMAP hBmp
= m_vSelectedBitmap
.GetHBITMAP();
155 m_vSelectedBitmap
.SetSelectedInto(this);
156 hBmp
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, (HBITMAP
)hBmp
);
158 if (hBmp
!= HBM_ERROR
)
160 wxLogLastError(wxT("SelectObject(memDC, bitmap)"));
161 wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC"));
163 else if (!m_hOldBitmap
)
167 } // end of wxMemoryDC::SelectObject
169 void wxMemoryDC::DoGetSize(
174 if (!m_vSelectedBitmap
.Ok())
180 *pWidth
= m_vSelectedBitmap
.GetWidth();
181 *pHeight
= m_vSelectedBitmap
.GetHeight();
182 } // end of wxMemoryDC::DoGetSize