]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/dcmemory.cpp
   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" 
  23 #include "wx/os2/private.h" 
  25 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxDC
) 
  27 ///////////////////////////////////////////////////////////////////////////// 
  29 ///////////////////////////////////////////////////////////////////////////// 
  31 wxMemoryDC::wxMemoryDC( 
  35     CreateCompatible(pOldDC
); 
  37 } // end of wxMemoryDC::wxMemoryDC 
  39 void wxMemoryDC::Init() 
  43         SetBrush(*wxWHITE_BRUSH
); 
  46         // the background mode is only used for text background and is set in 
  47         // DrawText() to OPAQUE as required, otherwise always TRANSPARENT 
  48         ::GpiSetBackMix( GetHPS(), BM_LEAVEALONE 
); 
  50     memset(&m_vRclPaint
, 0, sizeof(m_vRclPaint
)); 
  51 } // end of wxMemoryDC::Init 
  53 bool wxMemoryDC::CreateCompatible( wxDC
* WXUNUSED(pDC
) ) 
  57     DEVOPENSTRUC  vDOP 
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L}; 
  61     // Create a memory device context 
  63     hDC 
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
); 
  66         hPS 
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS 
| GPIT_MICRO 
| GPIA_ASSOC
); 
  74             // Set the wxWidgets color table 
  76             ::GpiCreateLogColorTable( m_hPS
 
  80                                      ,(LONG
)wxTheColourDatabase
->m_nSize
 
  81                                      ,(PLONG
)wxTheColourDatabase
->m_palTable
 
  83             ::GpiCreateLogColorTable( m_hPS
 
 108     // As we created the DC, we must delete it in the dtor 
 113 } // end of wxMemoryDC::CreateCompatible 
 115 void wxMemoryDC::DoSelect( 
 116   const wxBitmap
&                   rBitmap
 
 120     // Select old bitmap out of the device context 
 124         ::GpiSetBitmap(m_hPS
, NULLHANDLE
); 
 125         if (m_vSelectedBitmap
.Ok()) 
 127             m_vSelectedBitmap
.SetSelectedInto(NULL
); 
 128             m_vSelectedBitmap 
= wxNullBitmap
; 
 133     // Check for whether the bitmap is already selected into a device context 
 135     wxCHECK_RET( !rBitmap
.GetSelectedInto() || 
 136                  (rBitmap
.GetSelectedInto() == this), 
 137                  wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") ); 
 139     WXHBITMAP                       hBmp 
= rBitmap
.GetHBITMAP(); 
 144         // Bmps drawn to are upside down, so flip it before committing 
 146         POINTL                      vPoint
[4] = { {0, m_vSelectedBitmap
.GetHeight()} 
 147                                                  ,{m_vSelectedBitmap
.GetWidth(), 0} 
 149                                                  ,{m_vSelectedBitmap
.GetWidth(), m_vSelectedBitmap
.GetHeight()} 
 160         m_vSelectedBitmap
.SetSelectedInto(NULL
); 
 163     m_vSelectedBitmap 
= rBitmap
; 
 169         m_hOldBitmap 
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, NULLHANDLE
); 
 172     m_vSelectedBitmap
.SetSelectedInto(this); 
 173     m_hOldBitmap 
= (WXHBITMAP
)::GpiSetBitmap(m_hPS
, (HBITMAP
)hBmp
); 
 175     if (m_hOldBitmap 
== HBM_ERROR
) 
 177         wxLogLastError(wxT("SelectObject(memDC, bitmap)")); 
 178         wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC")); 
 180 } // end of wxMemoryDC::SelectObject 
 182 void wxMemoryDC::DoGetSize( 
 187     if (!m_vSelectedBitmap
.Ok()) 
 193     *pWidth 
= m_vSelectedBitmap
.GetWidth(); 
 194     *pHeight 
= m_vSelectedBitmap
.GetHeight(); 
 195 } // end of wxMemoryDC::DoGetSize