1. Override DoGetTextExtent() in wxMetafileDC instead of redefining (unused)

GetTextExtent()
2. Do use the provided font in it


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-05-18 15:14:44 +00:00
parent 0fb56f7115
commit ce631c0b13
3 changed files with 45 additions and 9 deletions

View File

@@ -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;

View File

@@ -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") );

View File

@@ -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: