diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h index 3fb6377b42..88777024fd 100644 --- a/include/wx/msw/metafile.h +++ b/include/wx/msw/metafile.h @@ -88,6 +88,18 @@ public: // Should be called at end of drawing virtual wxMetafile *Close(); virtual void SetMapMode(int mode); + +#if wxABI_VERSION >= 20805 + virtual void DoGetTextExtent(const wxString& string, + wxCoord *x, wxCoord *y, + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + const wxFont *theFont = NULL) const; +#endif // wx ABI 2.8.5+ + + // this method shouldn't have been defined here (DoGetTextExtent() is the + // correct one) but keep it to avoid breaking binary backwards + // compatibility virtual void GetTextExtent(const wxString& string, long *x, long *y, long *descent = NULL, long *externalLeading = NULL, wxFont *theFont = NULL, bool use16bit = false) const; diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp index f1eb74391e..348eb328ea 100644 --- a/src/msw/metafile.cpp +++ b/src/msw/metafile.cpp @@ -209,21 +209,23 @@ wxMetafileDC::~wxMetafileDC() m_hDC = 0; } -void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y, - long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const +void wxMetafileDC::DoGetTextExtent(const wxString& string, + wxCoord *x, wxCoord *y, + wxCoord *descent, + wxCoord *externalLeading, + const wxFont *theFont) const { - wxFont *fontToUse = theFont; + const wxFont *fontToUse = theFont; if (!fontToUse) - fontToUse = (wxFont*) &m_font; + fontToUse = &m_font; - HDC dc = GetDC(NULL); + ScreenHDC dc; + SelectInHDC selFont(dc, GetHfontOf(*fontToUse)); SIZE sizeRect; TEXTMETRIC tm; - ::GetTextExtentPoint32(dc, WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect); - GetTextMetrics(dc, &tm); - - ReleaseDC(NULL, dc); + ::GetTextExtentPoint32(dc, string, string.length(), &sizeRect); + ::GetTextMetrics(dc, &tm); if ( x ) *x = sizeRect.cx; @@ -235,6 +237,22 @@ void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y, *externalLeading = tm.tmExternalLeading; } +void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y, + long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const +{ + wxCoord xc, yc, dc, elc; + DoGetTextExtent(string, &xc, &yc, &dc, &elc, theFont); + + if ( x ) + *x = xc; + if ( y ) + *y = yc; + if ( descent ) + *descent = dc; + if ( externalLeading ) + *externalLeading = elc; +} + void wxMetafileDC::DoGetSize(int *width, int *height) const { wxCHECK_RET( m_refData, _T("invalid wxMetafileDC") ); diff --git a/version-script.in b/version-script.in index 87ba41f5af..4f83eec356 100644 --- a/version-script.in +++ b/version-script.in @@ -24,6 +24,12 @@ # and once released its version cannot be changed. +# public symbols added in 2.8.5 (please keep in alphabetical order): +@WX_VERSION_TAG@.5 { + global: + *wxMetafileDC*DoGetTextExtent*; +}; + # public symbols added in 2.8.4 (please keep in alphabetical order): @WX_VERSION_TAG@.4 { global: