changed wxDC::GetTextExtent() and related methods to take const wxFont pointer, for consistency with wxWindow::GetTextExtent() and because it generally doesn't need a non-const font

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45638 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-04-25 01:49:47 +00:00
parent d2b23b6730
commit c94f845b16
39 changed files with 53 additions and 50 deletions

View File

@ -793,7 +793,7 @@ Gets the current text background colour (see \helpref{wxDC::SetTextBackground}{w
\membersection{wxDC::GetTextExtent}\label{wxdcgettextextent}
\constfunc{void}{GetTextExtent}{\param{const wxString\& }{string}, \param{wxCoord *}{w}, \param{wxCoord *}{h},\\
\param{wxCoord *}{descent = NULL}, \param{wxCoord *}{externalLeading = NULL}, \param{wxFont *}{font = NULL}}
\param{wxCoord *}{descent = NULL}, \param{wxCoord *}{externalLeading = NULL}, \param{const wxFont *}{font = NULL}}
\constfunc{wxSize}{GetTextExtent}{\param{const wxString\& }{string}}

View File

@ -98,7 +98,7 @@ public:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;

View File

@ -457,7 +457,7 @@ public:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const
const wxFont *theFont = NULL) const
{ DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
wxSize GetTextExtent(const wxString& string) const
@ -472,7 +472,7 @@ public:
wxCoord *width,
wxCoord *height,
wxCoord *heightLine = NULL,
wxFont *font = NULL) const;
const wxFont *font = NULL) const;
wxSize GetMultiLineTextExtent(const wxString& string) const
{
@ -640,7 +640,7 @@ public:
long *x, long *y,
long *descent = NULL,
long *externalLeading = NULL,
wxFont *theFont = NULL) const
const wxFont *theFont = NULL) const
{
wxCoord x2, y2, descent2, externalLeading2;
DoGetTextExtent(string, &x2, &y2,
@ -807,7 +807,7 @@ protected:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const = 0;
const wxFont *theFont = NULL) const = 0;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;

View File

@ -173,7 +173,7 @@ protected:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;

View File

@ -269,7 +269,7 @@ protected:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const
const wxFont *theFont = NULL) const
{
// never mirrored
m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont);

View File

@ -86,7 +86,7 @@ class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC
void DoGetSize(int * x, int *y) const { *x = m_width; *y = m_height ; return ; }
void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, wxFont *font = NULL) const ;
void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, const wxFont *font = NULL) const ;
void DoSetClippingRegionAsRegion(const class wxRegion &)
{ wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; }

View File

@ -58,7 +58,7 @@ public:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool CanDrawBitmap() const { return true; }
virtual bool CanGetTextExtent() const { return true; }

View File

@ -124,7 +124,7 @@ protected:
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
void DoGetSize(int* width, int* height) const;
void DoGetSizeMM(int *width, int *height) const;

View File

@ -68,7 +68,7 @@ protected:
wxCoord *width, wxCoord *height,
wxCoord *descent = (wxCoord *) NULL,
wxCoord *externalLeading = (wxCoord *) NULL,
wxFont *theFont = (wxFont *) NULL) const;
const wxFont *theFont = (wxFont *) NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
virtual void DoSetClippingRegionAsRegion( const wxRegion &region );

View File

@ -258,7 +258,7 @@ protected:
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = (wxCoord *) NULL,
wxCoord *externalLeading = (wxCoord *) NULL,
wxFont *theFont = (wxFont *) NULL ) const;
const wxFont *theFont = (wxFont *) NULL ) const;
void DoGetSize(int* width, int* height) const;
void DoGetSizeMM(int *width, int *height) const;
@ -277,7 +277,7 @@ private:
unsigned char m_currentRed;
unsigned char m_currentGreen;
unsigned char m_currentBlue;
int m_deviceOffsetY;
wxGnomePrinter *m_printer;
@ -285,7 +285,7 @@ private:
GnomePrintJob* m_job; // only used and destroyed when created with wxPrintData
void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
private:
wxCoord XDEV2LOG(wxCoord x) const
{

View File

@ -74,7 +74,7 @@ protected:
wxCoord *width, wxCoord *height,
wxCoord *descent = (wxCoord *) NULL,
wxCoord *externalLeading = (wxCoord *) NULL,
wxFont *theFont = (wxFont *) NULL) const;
const wxFont *theFont = (wxFont *) NULL) const;
public:
virtual wxCoord GetCharWidth() const;

View File

@ -211,7 +211,7 @@ protected:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;

View File

@ -79,7 +79,7 @@ public:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;

View File

@ -63,7 +63,7 @@ public:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;

View File

@ -166,7 +166,7 @@ protected:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,

View File

@ -90,7 +90,7 @@ public:
virtual void SetMapMode(int mode);
virtual void GetTextExtent(const wxString& string, long *x, long *y,
long *descent = NULL, long *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = false) const;
const wxFont *theFont = NULL, bool use16bit = false) const;
// Implementation
wxMetafile *GetMetaFile() const { return m_metaFile; }

View File

@ -88,7 +88,7 @@ public:
virtual void SetMapMode(int mode);
virtual void GetTextExtent(const wxString& string, long *x, long *y,
long *descent = NULL, long *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = false) const;
const wxFont *theFont = NULL, bool use16bit = false) const;
// Implementation
inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }

View File

@ -75,7 +75,7 @@ public:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
virtual bool CanDrawBitmap() const;

View File

@ -90,7 +90,7 @@ public:
virtual void SetMapMode(int mode);
virtual void GetTextExtent(const wxString& string, long *x, long *y,
long *descent = NULL, long *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = FALSE) const;
const wxFont *theFont = NULL, bool use16bit = FALSE) const;
// Implementation
wxMetafile *GetMetaFile() const { return m_metaFile; }

View File

@ -116,7 +116,7 @@ protected:
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
const wxFont *theFont = NULL) const;
void Init();

View File

@ -230,7 +230,7 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
[bezpath stroke];
}
void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const
void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont) const
{
wxAutoNSAutoreleasePool pool;
// FIXME: Cache this so it can be used for DoDrawText

View File

@ -507,7 +507,7 @@ void wxDCBase::GetMultiLineTextExtent(const wxString& text,
wxCoord *x,
wxCoord *y,
wxCoord *h,
wxFont *font) const
const wxFont *font) const
{
wxCoord widthTextMax = 0, widthLine,
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;

View File

@ -830,7 +830,7 @@ bool wxGCDC::CanGetTextExtent() const
void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading ,
wxFont *theFont ) const
const wxFont *theFont ) const
{
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );

View File

@ -458,7 +458,7 @@ void wxSVGFileDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub
}
void wxSVGFileDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , wxFont *font) const
void wxSVGFileDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , const wxFont *font) const
{
wxScreenDC sDC ;

View File

@ -480,7 +480,7 @@ wxCoord wxDC::GetCharWidth() const
void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont) const
const wxFont *theFont) const
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( m_font.Ok(), wxT("no font selected") );

View File

@ -1835,11 +1835,11 @@ wxCoord wxPostScriptDC::GetCharHeight() const
void wxPostScriptDC::DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont ) const
const wxFont *theFont ) const
{
wxFont *fontToUse = theFont;
const wxFont *fontToUse = theFont;
if (!fontToUse) fontToUse = (wxFont*) &m_font;
if (!fontToUse) fontToUse = &m_font;
wxCHECK_RET( fontToUse, wxT("GetTextExtent: no font defined") );

View File

@ -1719,7 +1719,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
void wxWindowDC::DoGetTextExtent(const wxString &string,
wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont) const
const wxFont *theFont) const
{
if ( width )
*width = 0;

View File

@ -1718,7 +1718,7 @@ wxCoord wxGnomePrintDC::GetCharWidth() const
void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height,
wxCoord *descent,
wxCoord *externalLeading,
wxFont *theFont ) const
const wxFont *theFont ) const
{
if ( width )
*width = 0;

View File

@ -1606,7 +1606,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
void wxWindowDC::DoGetTextExtent(const wxString &string,
wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont) const
const wxFont *theFont) const
{
if ( width )
*width = 0;

View File

@ -1601,7 +1601,7 @@ bool wxDC::CanGetTextExtent() const
void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading ,
wxFont *theFont ) const
const wxFont *theFont ) const
{
wxCHECK_RET(Ok(), wxT("wxDC::DoGetTextExtent - invalid DC"));

View File

@ -2139,7 +2139,7 @@ bool wxDC::CanGetTextExtent() const
void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading ,
wxFont *theFont ) const
const wxFont *theFont ) const
{
wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoGetTextExtent - invalid DC") );

View File

@ -1221,7 +1221,7 @@ wxCoord wxDC::GetCharWidth() const
void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont) const
const wxFont *theFont) const
{
wxFont oldFont;

View File

@ -1297,7 +1297,7 @@ bool wxWindowDC::CanGetTextExtent() const
void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading,
wxFont *font ) const
const wxFont *font ) const
{
wxCHECK_RET( Ok(), "invalid dc" );

View File

@ -1731,7 +1731,7 @@ wxCoord wxDC::GetCharWidth() const
void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
wxFont *font) const
const wxFont *font) const
{
#ifdef __WXMICROWIN__
if (!GetHDC())

View File

@ -210,11 +210,13 @@ wxMetafileDC::~wxMetafileDC()
}
void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const
long *descent, long *externalLeading,
const wxFont *theFont,
bool WXUNUSED(use16bit)) const
{
wxFont *fontToUse = theFont;
const wxFont *fontToUse = theFont;
if (!fontToUse)
fontToUse = (wxFont*) &m_font;
fontToUse = &m_font;
HDC dc = GetDC(NULL);

View File

@ -188,12 +188,12 @@ void wxMetafileDC::GetTextExtent(const wxString& WXUNUSED(string),
long *WXUNUSED(y),
long *WXUNUSED(descent),
long *WXUNUSED(externalLeading),
wxFont *theFont,
const wxFont *theFont,
bool WXUNUSED(use16bit) ) const
{
wxFont *fontToUse = theFont;
const wxFont *fontToUse = theFont;
if (!fontToUse)
fontToUse = (wxFont*) &m_font;
fontToUse = &m_font;
// TODO:
/*

View File

@ -330,7 +330,7 @@ wxCoord wxDC::GetCharWidth() const
void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
wxFont *font) const
const wxFont *font) const
{
}

View File

@ -119,7 +119,8 @@ wxMetafileDC::~wxMetafileDC()
}
void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const
long *descent, long *externalLeading,
const wxFont *theFont, bool WXUNUSED(use16bit)) const
{
}

View File

@ -1612,7 +1612,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading,
wxFont *font ) const
const wxFont *font ) const
{
wxCHECK_RET( Ok(), wxT("invalid dc") );