X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4e7c2aa5822f9a6e97d8d7848b95ea2eadcd98b..23aa4f09d26bd1eb5df7f7170276744a293cbe19:/src/msw/dcmemory.cpp diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index a89b217bcb..03e89a1c91 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -10,7 +10,6 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation #pragma implementation "dcmemory.h" #endif @@ -22,11 +21,12 @@ #endif #ifndef WX_PRECOMP +#include "wx/utils.h" #endif -#include "wx/dcmemory.h" +#include "wx/msw/private.h" -#include +#include "wx/dcmemory.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) @@ -39,12 +39,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) wxMemoryDC::wxMemoryDC(void) { - m_hDC = (WXHDC) ::CreateCompatibleDC(NULL); + m_hDC = (WXHDC) ::CreateCompatibleDC((HDC) NULL); m_ok = (m_hDC != 0); m_bOwnsDC = TRUE; SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); + + // the background mode is only used for text background + // and is set in DrawText() to OPAQUE as required, other- + // wise always TRANSPARENT, RR + ::SetBkMode( GetHdc(), TRANSPARENT ); + } wxMemoryDC::wxMemoryDC(wxDC *old_dc) @@ -58,6 +64,12 @@ wxMemoryDC::wxMemoryDC(wxDC *old_dc) SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); + + // the background mode is only used for text background + // and is set in DrawText() to OPAQUE as required, other- + // wise always TRANSPARENT, RR + ::SetBkMode( GetHdc(), TRANSPARENT ); + } wxMemoryDC::~wxMemoryDC(void) @@ -81,30 +93,42 @@ void wxMemoryDC::SelectObject(const wxBitmap& bitmap) // a device context if (bitmap.GetSelectedInto() && (bitmap.GetSelectedInto() != this)) { - wxFatalError("Error in wxMemoryDC::SelectObject\nBitmap is selected in another wxMemoryDC.\nDelete the first wxMemoryDC or use SelectObject(NULL)"); + wxFatalError(_T("Error in wxMemoryDC::SelectObject\nBitmap is selected in another wxMemoryDC.\nDelete the first wxMemoryDC or use SelectObject(NULL)")); return; } - - m_selectedBitmap = bitmap; + + // Check if the bitmap has the correct depth for this device context +// if (bitmap.Ok() && (bitmap.GetDepth() != GetDepth())) + // JACS 11/12/98: disabling this since the Forty Thieves sample + // shows this not working properly. In fact, if loading from a resource, + // the depth should become the screen depth, so why was it being called? +// if (0) +// { +// // Make a new bitmap that has the correct depth. +// wxBitmap newBitmap = bitmap.GetBitmapForDC(* this); +// +// m_selectedBitmap = newBitmap ; +// } +// else +// { + m_selectedBitmap = bitmap; +// } if (!m_selectedBitmap.Ok()) return; m_selectedBitmap.SetSelectedInto(this); -#if WXDEBUG > 1 - wxDebugMsg("wxMemoryDC::SelectObject: Selecting HBITMAP %X\n", m_selectedBitmap.GetHBITMAP()); -#endif HBITMAP bm = (HBITMAP) ::SelectObject((HDC) m_hDC, (HBITMAP) m_selectedBitmap.GetHBITMAP()); if (bm == ERROR) { - wxFatalError("Error in wxMemoryDC::SelectObject\nBitmap may not be loaded, or may be selected in another wxMemoryDC.\nDelete the first wxMemoryDC to deselect bitmap."); + wxFatalError(_T("Error in wxMemoryDC::SelectObject\nBitmap may not be loaded, or may be selected in another wxMemoryDC.\nDelete the first wxMemoryDC to deselect bitmap.")); } else if (!m_oldBitmap) m_oldBitmap = (WXHBITMAP) bm; } -void wxMemoryDC::GetSize(int *width, int *height) const +void wxMemoryDC::DoGetSize(int *width, int *height) const { if (!m_selectedBitmap.Ok()) {