Allow using wxTextMeasure::GetLargestStringExtent() with wxArrayString.
Change the signature of this method to take the number of strings and the pointer to the first of them instead of wxVector<wxString> as this allows it to be used with all of wxVector<wxString>, wxArrayString and raw arrays of wxStrings. Also return the computed size from it instead of filling output parameters. Closes #14781. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72802 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -11,8 +11,6 @@
|
|||||||
#ifndef _WX_PRIVATE_TEXTMEASURE_H_
|
#ifndef _WX_PRIVATE_TEXTMEASURE_H_
|
||||||
#define _WX_PRIVATE_TEXTMEASURE_H_
|
#define _WX_PRIVATE_TEXTMEASURE_H_
|
||||||
|
|
||||||
#include "wx/vector.h"
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxDC;
|
class WXDLLIMPEXP_FWD_CORE wxDC;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxFont;
|
class WXDLLIMPEXP_FWD_CORE wxFont;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||||
@@ -48,9 +46,11 @@ public:
|
|||||||
wxCoord *heightOneLine = NULL);
|
wxCoord *heightOneLine = NULL);
|
||||||
|
|
||||||
// Find the dimensions of the largest string.
|
// Find the dimensions of the largest string.
|
||||||
void GetLargestStringExtent(const wxVector<wxString>& strings,
|
wxSize GetLargestStringExtent(size_t n, const wxString* strings);
|
||||||
wxCoord *width,
|
wxSize GetLargestStringExtent(const wxArrayString& strings)
|
||||||
wxCoord *height);
|
{
|
||||||
|
return GetLargestStringExtent(strings.size(), &strings[0]);
|
||||||
|
}
|
||||||
|
|
||||||
// Fill the array with the widths for each "0..N" substrings for N from 1
|
// Fill the array with the widths for each "0..N" substrings for N from 1
|
||||||
// to text.length().
|
// to text.length().
|
||||||
@@ -93,7 +93,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
// The main function of this class, to be implemented in platform-specific
|
// The main function of this class, to be implemented in platform-specific
|
||||||
// way used by all our public methods except GetLargestStringExtents().
|
// way used by all our public methods.
|
||||||
//
|
//
|
||||||
// The width and height pointers here are never NULL and the input string
|
// The width and height pointers here are never NULL and the input string
|
||||||
// is not empty.
|
// is not empty.
|
||||||
|
@@ -158,18 +158,15 @@ void wxTextMeasureBase::GetMultiLineTextExtent(const wxString& text,
|
|||||||
*heightOneLine = heightLine;
|
*heightOneLine = heightLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextMeasureBase::GetLargestStringExtent(const wxVector<wxString>& strings,
|
wxSize wxTextMeasureBase::GetLargestStringExtent(size_t n,
|
||||||
wxCoord *width,
|
const wxString* strings)
|
||||||
wxCoord *height)
|
|
||||||
{
|
{
|
||||||
MeasuringGuard guard(*this);
|
MeasuringGuard guard(*this);
|
||||||
|
|
||||||
wxCoord w, h, widthMax = 0, heightMax = 0;
|
wxCoord w, h, widthMax = 0, heightMax = 0;
|
||||||
for ( wxVector<wxString>::const_iterator i = strings.begin();
|
for ( size_t i = 0; i < n; ++i )
|
||||||
i != strings.end();
|
|
||||||
++i )
|
|
||||||
{
|
{
|
||||||
CallGetTextExtent(*i, &w, &h);
|
CallGetTextExtent(strings[i], &w, &h);
|
||||||
|
|
||||||
if ( w > widthMax )
|
if ( w > widthMax )
|
||||||
widthMax = w;
|
widthMax = w;
|
||||||
@@ -177,10 +174,7 @@ void wxTextMeasureBase::GetLargestStringExtent(const wxVector<wxString>& strings
|
|||||||
heightMax = h;
|
heightMax = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( width )
|
return wxSize(widthMax, heightMax);
|
||||||
*width = widthMax;
|
|
||||||
if ( height )
|
|
||||||
*height = heightMax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextMeasureBase::GetPartialTextExtents(const wxString& text,
|
bool wxTextMeasureBase::GetPartialTextExtents(const wxString& text,
|
||||||
|
Reference in New Issue
Block a user