1. wxWizard appears in the centre of the screen by default

2. the selected brush isn't damaged any more by DrawBitmap()
3. corrected confusion between current and bg brush in DrawBitmap()
4. added wxGetColourFromUser() (to match wxGetTextFromUser() &c)
5. mem leak/crash in wxListCtrl on mode change fixed
6. wxListCtrl::Set{Fore|Back}groundColour() work as expected now


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5896 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-02-08 01:08:51 +00:00
parent 11f26ea0e2
commit 91b4c08d6f
6 changed files with 135 additions and 25 deletions

View File

@@ -657,7 +657,56 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
int width = bmp.GetWidth(),
height = bmp.GetHeight();
if ( !useMask )
HBITMAP hbmpMask = 0;
if ( useMask )
{
wxMask *mask = bmp.GetMask();
if ( mask )
hbmpMask = (HBITMAP)mask->GetMaskBitmap();
if ( !hbmpMask )
{
// don't give assert here because this would break existing
// programs - just silently ignore useMask parameter
useMask = FALSE;
}
}
if ( useMask )
{
#ifdef __WIN32__
HDC hdcMem = ::CreateCompatibleDC(GetHdc());
::SelectObject(hdcMem, GetHbitmapOf(bmp));
// this will only work if the transparent part of our bitmap is black
// because it is combined with the destination rectangle using OR, so
// it won't be really transparent otherwise - I don't know what to do
// about it, may be use MAKEROP4(SRCCOPY, DSTINVERT) twice? Or create a
// copy of the bitmap with the transparent part replaced with black
// pixels?
bool ok = ::MaskBlt(GetHdc(), x, y, width, height,
hdcMem, 0, 0,
hbmpMask, 0, 0,
MAKEROP4(SRCCOPY, SRCPAINT)) != 0;
::DeleteDC(hdcMem);
if ( !ok )
#endif // Win32
{
// VZ: this is incorrect, Blit() doesn't (and can't) draw
// transparently, but it's still better than nothing at all
// Rather than reproduce wxDC::Blit, let's do it at the wxWin API level
wxMemoryDC memDC;
memDC.SelectObject(bmp);
Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap);
}
}
else // no mask, just use BitBlt()
{
HDC cdc = GetHdc();
HDC memdc = ::CreateCompatibleDC( cdc );
@@ -683,16 +732,6 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
::SetTextColor(GetHdc(), old_textground);
::SetBkColor(GetHdc(), old_background);
}
else
{
// Rather than reproduce wxDC::Blit, let's do it at the wxWin API level
wxMemoryDC memDC;
memDC.SelectObject(bmp);
Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap);
}
}
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
@@ -1304,21 +1343,40 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
if (useMask)
{
#ifdef __WIN32__
// prepare the mask bitmap
HBITMAP hbmpMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap());
// select the correct brush: the current one by default, background one
// if none
HBRUSH hbrNew;
if ( m_brush.Ok() )
{
hbrNew = (HBRUSH)m_brush.GetResourceHandle();
}
else if ( m_backgroundBrush.Ok() )
{
hbrNew = (HBRUSH)m_backgroundBrush.GetResourceHandle();
}
else
{
hbrNew = 0;
}
HGDIOBJ hbrOld = hbrNew ? ::SelectObject(GetHdc(), hbrNew) : 0;
// we want the part of the image corresponding to the mask to be
// transparent, i.e. do PATCOPY there and apply dwRop elsewhere
const wxColour& colBg = m_backgroundBrush.GetColour();
HBRUSH hbrBg = (HBRUSH)::CreateSolidBrush(wxColourToRGB(colBg));
HBRUSH hbrOld = (HBRUSH)::SelectObject(GetHdc(), hbrBg);
success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
GetHdcOf(*source), xsrc, ysrc,
hbmpMask, 0, 0,
MAKEROP4(PATCOPY, dwRop)) != 0;
(void)::SelectObject(GetHdc(), hbrOld);
::DeleteObject(hbrOld);
if ( hbrNew )
{
(void)::SelectObject(GetHdc(), hbrOld);
}
::DeleteObject(hbmpMask);
if ( !success )