#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
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, (LPARAM)text.wx_str(),
+ 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;
}