X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19193a2c85987b595932957e73013e7ea100f0e8..1483041dab88f43563c26405c1e2a41d6babe6a0:/src/msw/dc.cpp?ds=sidebyside diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index dcf230b0b6..e1b2d6966f 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -49,7 +49,7 @@ #include "wx/msw/private.h" // needs to be before #include -#if wxUSE_COMMON_DIALOGS +#if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__) #include #endif @@ -868,7 +868,10 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask height = bmp.GetHeight(); HBITMAP hbmpMask = 0; + +#if wxUSE_PALETTE HPALETTE oldPal = 0; +#endif // wxUSE_PALETTE if ( useMask ) { @@ -883,7 +886,6 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask useMask = FALSE; } } - if ( useMask ) { #ifdef __WIN32__ @@ -899,17 +901,27 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask { HDC cdc = GetHdc(); HDC hdcMem = ::CreateCompatibleDC(GetHdc()); - ::SelectObject(hdcMem, GetHbitmapOf(bmp)); - if (bmp.GetPalette() && (::GetDeviceCaps(cdc,BITSPIXEL) <= 8)) { - oldPal = ::SelectPalette( hdcMem, (HPALETTE)bmp.GetPalette()->GetHPALETTE(), FALSE); + HGDIOBJ hOldBitmap = ::SelectObject(hdcMem, GetHbitmapOf(bmp)); +#if wxUSE_PALETTE + wxPalette *pal = bmp.GetPalette(); + if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 ) + { + oldPal = ::SelectPalette(hdcMem, GetHpaletteOf(pal), FALSE); ::RealizePalette(hdcMem); - } + } +#endif // wxUSE_PALETTE + ok = ::MaskBlt(cdc, x, y, width, height, hdcMem, 0, 0, hbmpMask, 0, 0, MAKEROP4(SRCCOPY, DSTCOPY)) != 0; + +#if wxUSE_PALETTE if (oldPal) ::SelectPalette(hdcMem, oldPal, FALSE); +#endif // wxUSE_PALETTE + + ::SelectObject(hdcMem, hOldBitmap); ::DeleteDC(hdcMem); } @@ -945,14 +957,24 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ::SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() ); } - if (bmp.GetPalette() && (::GetDeviceCaps(cdc,BITSPIXEL) <= 8)) { - oldPal = ::SelectPalette( memdc, (HPALETTE)bmp.GetPalette()->GetHPALETTE(), FALSE); +#if wxUSE_PALETTE + wxPalette *pal = bmp.GetPalette(); + if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 ) + { + oldPal = ::SelectPalette(memdc, GetHpaletteOf(pal), FALSE); ::RealizePalette(memdc); - } - ::SelectObject( memdc, hbitmap ); + } +#endif // wxUSE_PALETTE + + HGDIOBJ hOldBitmap = ::SelectObject( memdc, hbitmap ); ::BitBlt( cdc, x, y, width, height, memdc, 0, 0, SRCCOPY); + +#if wxUSE_PALETTE if (oldPal) ::SelectPalette(memdc, oldPal, FALSE); +#endif // wxUSE_PALETTE + + ::SelectObject( memdc, hOldBitmap ); ::DeleteDC( memdc ); ::SetTextColor(GetHdc(), old_textground); @@ -1227,12 +1249,12 @@ void wxDC::SetBrush(const wxBrush& brush) if ( stipple && stipple->Ok() ) { #ifdef __WIN32__ - ::SetBrushOrgEx(GetHdc(), + ::SetBrushOrgEx(GetHdc(), m_deviceOriginX % stipple->GetWidth(), m_deviceOriginY % stipple->GetHeight(), NULL); // don't need previous brush origin #else - ::SetBrushOrg(GetHdc(), + ::SetBrushOrg(GetHdc(), m_deviceOriginX % stipple->GetWidth(), m_deviceOriginY % stipple->GetHeight()); #endif @@ -1303,14 +1325,6 @@ void wxDC::SetBackgroundMode(int mode) // SetBackgroundColour now only refers to text background // and m_backgroundMode is used there - -/* - if (m_backgroundMode == wxTRANSPARENT) - ::SetBkMode(GetHdc(), TRANSPARENT); - else - ::SetBkMode(GetHdc(), OPAQUE); - Last change: AC 29 Jan 101 8:54 pm -*/ } void wxDC::SetLogicalFunction(int function) @@ -1413,13 +1427,13 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, #ifdef __WXMICROWIN__ if (!GetHDC()) { - if (x) *x = 0; - if (y) *y = 0; - if (descent) *descent = 0; - if (externalLeading) *externalLeading = 0; - return; + if (x) *x = 0; + if (y) *y = 0; + if (descent) *descent = 0; + if (externalLeading) *externalLeading = 0; + return; } -#endif +#endif // __WXMICROWIN__ HFONT hfontOld; if ( font ) @@ -1747,8 +1761,8 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, dc_buffer = ::CreateCompatibleDC(GetHdc()); buffer_bmap = ::CreateCompatibleBitmap(GetHdc(), width, height); #endif // wxUSE_DC_CACHEING/!wxUSE_DC_CACHEING - ::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap()); - ::SelectObject(dc_buffer, buffer_bmap); + HGDIOBJ hOldMaskBitmap = ::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap()); + HGDIOBJ hOldBufferBitmap = ::SelectObject(dc_buffer, buffer_bmap); // copy dest to buffer if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, @@ -1794,8 +1808,8 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, } // tidy up temporary DCs and bitmap - ::SelectObject(dc_mask, 0); - ::SelectObject(dc_buffer, 0); + ::SelectObject(dc_mask, hOldMaskBitmap); + ::SelectObject(dc_buffer, hOldBufferBitmap); #if !wxUSE_DC_CACHEING {