]>
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 } // end of wxMemoryDC::Init 
  60 bool wxMemoryDC::CreateCompatible( 
  66     DEVOPENSTRUC                    vDOP 
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L}; 
  70     // Create a memory device context 
  72     hDC 
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
); 
  75         hPS 
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS 
| GPIT_MICRO 
| GPIA_ASSOC
); 
  83             // Set the wxWindows color table 
  85             ::GpiCreateLogColorTable( m_hPS
 
  89                                      ,(LONG
)wxTheColourDatabase
->m_nSize
 
  90                                      ,(PLONG
)wxTheColourDatabase
->m_palTable
 
  92             ::GpiCreateLogColorTable( m_hPS
 
 117     // As we created the DC, we must delete it in the dtor 
 122 } // end of wxMemoryDC::CreateCompatible 
 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 
 184 void wxMemoryDC::DoDrawRectangle( 
 191     wxDC::DoDrawRectangle(vX
, vY
, vWidth
, vHeight
); 
 192 } // end of wxMemoryDC::DoDrawRectangle