Added wxDC:GetPartialTextExtents

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-02-11 23:49:43 +00:00
parent 42bf070c7e
commit 0919e93e52
5 changed files with 164 additions and 1 deletions

View File

@@ -365,6 +365,36 @@ void wxDCBase::DoDrawSpline( wxList *points )
#endif // wxUSE_SPLINES
// ----------------------------------------------------------------------------
// Partial Text Extents
// ----------------------------------------------------------------------------
// Each element of the array will be the width of the string up to and
// including the coresoponding character in text. This is the generic
// implementation, the port-specific classes should do this with native APIs
// if available.
bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
{
int totalWidth = 0;
size_t i;
widths.Empty();
widths.Add(0, text.Length());
// Calculate the position of each character based on the widths of
// the previous characters
for (i=0; i<text.Length(); i++) {
int w, h;
GetTextExtent(text[i], &w, &h);
totalWidth += w;
widths[i] = totalWidth;
}
return true;
}
// ----------------------------------------------------------------------------
// enhanced text drawing
// ----------------------------------------------------------------------------