X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/98fbab9e7bf70ee8af44a78ea2a1d2cbb406880a..cdbd62d6ff290fd58acd1bc5574dfc79db3a6f70:/src/msw/ownerdrw.cpp diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp index 3c70d2408e..de70ac8588 100644 --- a/src/msw/ownerdrw.cpp +++ b/src/msw/ownerdrw.cpp @@ -4,7 +4,6 @@ // Author: Vadim Zeitlin // Modified by: Marcin Malich // Created: 13.11.97 -// RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -22,6 +21,7 @@ #include "wx/msw/dc.h" #include "wx/msw/private.h" #include "wx/msw/private/dc.h" +#include "wx/msw/wrapcctl.h" // for HIMAGELIST #ifndef DSS_HIDEPREFIX #define DSS_HIDEPREFIX 0x0200 @@ -45,50 +45,57 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, if ( !IsOwnerDrawn() ) return true; - // set the font and colors - wxFont font; - GetFontToUse(font); - - wxColour colText, colBack; - GetColourToUse(stat, colText, colBack); - wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDC hdc = GetHdcOf(*impl); - SelectInHDC selFont(hdc, GetHfontOf(font)); + RECT rect; + wxCopyRectToRECT(rc, rect); + + { + // set the font and colors + wxFont font; + GetFontToUse(font); + + wxColour colText, colBack; + GetColourToUse(stat, colText, colBack); + + SelectInHDC selFont(hdc, GetHfontOf(font)); + + wxMSWImpl::wxTextColoursChanger textCol(hdc, colText, colBack); + wxMSWImpl::wxBkModeChanger bkMode(hdc, wxBRUSHSTYLE_TRANSPARENT); + - wxMSWImpl::wxTextColoursChanger textCol(hdc, colText, colBack); - wxMSWImpl::wxBkModeChanger bkMode(hdc, wxBRUSHSTYLE_TRANSPARENT); + AutoHBRUSH hbr(wxColourToPalRGB(colBack)); + SelectInHDC selBrush(hdc, hbr); + ::FillRect(hdc, &rect, hbr); - AutoHBRUSH hbr(wxColourToPalRGB(colBack)); - SelectInHDC selBrush(hdc, hbr); + // using native API because it recognizes '&' - RECT rectFill; - wxCopyRectToRECT(rc, rectFill); - ::FillRect(hdc, &rectFill, hbr); + wxString text = GetName(); - // using native API because it recognizes '&' + SIZE sizeRect; + ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sizeRect); - wxString text = GetName(); + int flags = DST_PREFIXTEXT; + if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) + flags |= DSS_DISABLED; - SIZE sizeRect; - ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sizeRect); + if ( (stat & wxODHidePrefix) ) + flags |= DSS_HIDEPREFIX; - int flags = DST_PREFIXTEXT; - if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) - flags |= DSS_DISABLED; + int x = rc.x + GetMarginWidth(); + int y = rc.y + (rc.GetHeight() - sizeRect.cy) / 2; + int cx = rc.GetWidth() - GetMarginWidth(); + int cy = sizeRect.cy; - if ( (stat & wxODHidePrefix) ) - flags |= DSS_HIDEPREFIX; + ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(text), + text.length(), x, y, cx, cy, flags); - int x = rc.x + GetMarginWidth(); - int y = rc.y + (rc.GetHeight() - sizeRect.cy) / 2; - int cx = rc.GetWidth() - GetMarginWidth(); - int cy = sizeRect.cy; + } // reset to default the font, colors and brush - ::DrawState(hdc, NULL, NULL, (LPARAM)text.wx_str(), - text.length(), x, y, cx, cy, flags); + if (stat & wxODHasFocus) + ::DrawFocusRect(hdc, &rect); return true; }