From: Vadim Zeitlin Date: Sat, 10 Mar 2007 17:25:36 +0000 (+0000) Subject: added GetTextExtent() overload returning wxSize (patch 1631508) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6b06226335f3deaf7cc5f53cdf7341713a8cdca2 added GetTextExtent() overload returning wxSize (patch 1631508) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44728 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index e170cc92da..249de56779 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -1294,20 +1294,25 @@ Return the sizer associated with the window by a previous call to \membersection{wxWindow::GetTextExtent}\label{wxwindowgettextextent} -\constfunc{virtual void}{GetTextExtent}{\param{const wxString\& }{string}, \param{int* }{x}, \param{int* }{y}, +\constfunc{virtual void}{GetTextExtent}{\param{const wxString\& }{string}, \param{int* }{w}, \param{int* }{h}, \param{int* }{descent = NULL}, \param{int* }{externalLeading = NULL}, \param{const wxFont* }{font = NULL}, \param{bool}{ use16 = {\tt false}}} +\constfunc{wxSize}{GetTextExtent}{\param{const wxString\& }{string}} + Gets the dimensions of the string as it would be drawn on the window with the currently selected font. +The text extent is returned in \arg{w} and \arg{h} pointers (first form) or as a +\helpref{wxSize}{wxsize} object (second form). + \wxheading{Parameters} \docparam{string}{String whose extent is to be measured.} -\docparam{x}{Return value for width.} +\docparam{w}{Return value for width.} -\docparam{y}{Return value for height.} +\docparam{h}{Return value for height.} \docparam{descent}{Return value for descent (optional).} diff --git a/include/wx/window.h b/include/wx/window.h index 04b76e9670..733f3d02da 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -856,6 +856,13 @@ public: const wxFont *theFont = (const wxFont *) NULL) const = 0; + wxSize GetTextExtent(const wxString& string) const + { + wxCoord w, h; + GetTextExtent(string, &w, &h); + return wxSize(w, h); + } + // client <-> screen coords // ------------------------