X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1bce253a23047c6153e130d02e776d3d34b05793..ca77701441e39245dcbfce903049e76f166979e5:/include/wx/private/textmeasure.h diff --git a/include/wx/private/textmeasure.h b/include/wx/private/textmeasure.h index 1270e8ecdc..4788c992ed 100644 --- a/include/wx/private/textmeasure.h +++ b/include/wx/private/textmeasure.h @@ -11,8 +11,6 @@ #ifndef _WX_PRIVATE_TEXTMEASURE_H_ #define _WX_PRIVATE_TEXTMEASURE_H_ -#include "wx/vector.h" - class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxFont; class WXDLLIMPEXP_FWD_CORE wxWindow; @@ -25,7 +23,8 @@ class wxTextMeasureBase { public: // The first ctor argument must be non-NULL, i.e. each object of this class - // is associated with either a valid wxDC or a valid wxWindow. + // is associated with either a valid wxDC or a valid wxWindow. The font can + // be NULL to use the current DC/window font or can be specified explicitly. wxTextMeasureBase(const wxDC *dc, const wxFont *theFont); wxTextMeasureBase(const wxWindow *win, const wxFont *theFont); @@ -48,9 +47,11 @@ public: wxCoord *heightOneLine = NULL); // Find the dimensions of the largest string. - void GetLargestStringExtent(const wxVector& strings, - wxCoord *width, - wxCoord *height); + wxSize GetLargestStringExtent(size_t n, const wxString* strings); + wxSize GetLargestStringExtent(const wxArrayString& strings) + { + return GetLargestStringExtent(strings.size(), &strings[0]); + } // Fill the array with the widths for each "0..N" substrings for N from 1 // to text.length(). @@ -61,18 +62,20 @@ public: wxArrayInt& widths, double scaleX); -protected: + // These functions are called by our public methods before and after each // call to DoGetTextExtent(). Derived classes may override them to prepare // for -- possibly several -- subsequent calls to DoGetTextExtent(). // // As these calls must be always paired, they're never called directly but // only by our friend MeasuringGuard class. + // + // NB: They're public only to allow VC6 to compile this code, there doesn't + // seem to be any way to give MeasuringGuard access to them (FIXME-VC6) virtual void BeginMeasuring() { } virtual void EndMeasuring() { } - friend class MeasuringGuard; - +protected: // RAII wrapper for the two methods above. class MeasuringGuard { @@ -93,7 +96,7 @@ protected: // 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 // is not empty. @@ -121,6 +124,10 @@ protected: wxCoord *descent = NULL, wxCoord *externalLeading = NULL); + // Return a valid font: if one was given to us in the ctor, use this one, + // otherwise use the current font of the associated wxDC or wxWindow. + wxFont GetFont() const; + // Exactly one of m_dc and m_win is non-NULL for any given object of this // class.