// Windows draws the filled rectangles without outline (i.e. drawn with a
// transparent pen) one pixel smaller in both directions and we want them
// to have the same size regardless of which pen is used - adjust
- if ( m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
+ if ( m_pen.IsOk() && m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
{
x2++;
y2++;
#ifdef __WIN32__
// use MaskBlt() with ROP which doesn't do anything to dst in the mask
// points
+ bool ok = false;
+
+#if wxUSE_SYSTEM_OPTIONS
// On some systems, MaskBlt succeeds yet is much much slower
// than the wxWidgets fall-back implementation. So we need
// to be able to switch this on and off at runtime.
- bool ok = false;
-#if wxUSE_SYSTEM_OPTIONS
- if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0)
-#endif
+ //
+ // NB: don't query the value of the option every time but do it only
+ // once as otherwise it can have real (and bad) performance
+ // implications (see #11172)
+ static bool
+ s_maskBltAllowed = wxSystemOptions::GetOptionInt("no-maskblt") == 0;
+ if ( s_maskBltAllowed )
+#endif // wxUSE_SYSTEM_OPTIONS
{
HDC cdc = GetHdc();
HDC hdcMem = ::CreateCompatibleDC(GetHdc());
void wxMSWDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
+ // For compatibility with other ports (notably wxGTK) and because it's
+ // genuinely useful, we allow passing multiline strings to DrawText().
+ // However there is no native MSW function to draw them directly so we
+ // instead reuse the generic DrawLabel() method to render them. Of course,
+ // DrawLabel() itself will call back to us but with single line strings
+ // only so there won't be any infinite recursion here.
+ if ( text.find('\n') != wxString::npos )
+ {
+ GetOwner()->DrawLabel(text, wxRect(x, y, 0, 0));
+ return;
+ }
+
WXMICROWIN_CHECK_HDC
DrawAnyText(text, x, y);
}
#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
- TEXTMETRIC tm;
- ::GetTextMetrics(GetHdc(), &tm);
-
if (x)
*x = sizeRect.cx;
if (y)
*y = sizeRect.cy;
- if (descent)
- *descent = tm.tmDescent;
- if (externalLeading)
- *externalLeading = tm.tmExternalLeading;
+
+ if ( descent || externalLeading )
+ {
+ TEXTMETRIC tm;
+ ::GetTextMetrics(GetHdc(), &tm);
+
+ if (descent)
+ *descent = tm.tmDescent;
+ if (externalLeading)
+ *externalLeading = tm.tmExternalLeading;
+ }
if ( hfontOld )
{