add virtual DoGetTextExtent() to allow calling the overloaded wxWindowBase::GetTextExtent() on wxWindow objects without any ugly casts/scope resolution operators

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60984 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-06-10 16:41:41 +00:00
parent 68d801c8b0
commit 6de7047076
23 changed files with 144 additions and 134 deletions

View File

@ -173,7 +173,7 @@ public:
// Get character size
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string, int *x, int *y,
virtual void DoGetTextExtent(const wxString& string, int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL) const;

View File

@ -81,12 +81,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget(wxDropTarget *dropTarget);
@ -112,6 +106,11 @@ public:
protected:
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL) const;
virtual void DoClientToScreen(int *x, int *y) const;
virtual void DoScreenToClient(int *x, int *y) const;
virtual void DoGetPosition(int *x, int *y) const;

View File

@ -82,12 +82,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = true );
@ -296,6 +290,11 @@ public:
protected:
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -84,16 +84,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = true );
@ -226,6 +216,16 @@ public:
wxInsertChildFunction m_insertCallback;
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL) const;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -74,12 +74,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget(wxDropTarget *dropTarget);
@ -110,6 +104,11 @@ protected:
int m_eraseBackground;
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -71,12 +71,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = true );
@ -280,6 +274,11 @@ protected:
int m_scrollPosY;
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -95,12 +95,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = true );
@ -493,6 +487,11 @@ protected:
int m_yThumbSize;
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -98,19 +98,6 @@ public:
virtual bool SetFont(const wxFont& rFont);
virtual int GetCharHeight(void) const;
virtual int GetCharWidth(void) const;
virtual void GetTextExtent( const wxString& rString
,int* pX
,int* pY
,int* pDescent = NULL
,int* pExternalLeading = NULL
,const wxFont* pTheFont = (const wxFont *)NULL
) const;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu* pMenu
,int nX
,int nY
);
#endif // wxUSE_MENUS_NATIVE
virtual void SetScrollbar( int nOrient
,int nPos
@ -460,6 +447,19 @@ protected:
long m_lDlgCode;
// implement the base class pure virtuals
virtual void GetTextExtent( const wxString& rString
,int* pX
,int* pY
,int* pDescent = NULL
,int* pExternalLeading = NULL
,const wxFont* pTheFont = NULL
) const;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu* pMenu
,int nX
,int nY
);
#endif // wxUSE_MENUS_NATIVE
virtual void DoClientToScreen( int* pX
,int* pY
) const;

View File

@ -82,20 +82,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent( const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL )
const;
protected:
virtual void DoEnable( bool enable );
#if wxUSE_MENUS
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif
virtual void DoFreeze();
virtual void DoThaw();
public:
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
@ -306,6 +292,20 @@ protected:
void MacUpdateControlFont() ;
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL ) const;
virtual void DoEnable( bool enable );
#if wxUSE_MENUS
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif
virtual void DoFreeze();
virtual void DoThaw();
virtual wxSize DoGetBestSize() const;
virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const;
virtual void DoClientToScreen( int *x, int *y ) const;

View File

@ -79,12 +79,6 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
@ -231,6 +225,11 @@ protected:
WXHMENU m_hMenu; // Menu, if any
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -1069,12 +1069,14 @@ public:
// get the width/height/... of the text using current or specified
// font
virtual void GetTextExtent(const wxString& string,
void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const = 0;
const wxFont *font = NULL) const
{
DoGetTextExtent(string, x, y, descent, externalLeading, font);
}
wxSize GetTextExtent(const wxString& string) const
{
@ -1602,6 +1604,13 @@ protected:
// overloaded Something()s in terms of DoSomething() which will be the
// only one to be virtual.
// text extent
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const = 0;
// coordinates translation
virtual void DoClientToScreen( int *x, int *y ) const = 0;
virtual void DoScreenToClient( int *x, int *y ) const = 0;

View File

@ -71,15 +71,8 @@ public:
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
virtual void ScrollWindow( int dx, int dy,
const wxRect* rect = NULL );
virtual void ScrollWindow( int dx, int dy, const wxRect* rect = NULL );
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
@ -165,6 +158,11 @@ protected:
bool m_needsInputFocus; // Input focus set in OnIdle
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;

View File

@ -1713,7 +1713,7 @@ int wxWindow::GetCharWidth() const
return 5;
}
void wxWindow::GetTextExtent(const wxString& string, int *outX, int *outY,
void wxWindow::DoGetTextExtent(const wxString& string, int *outX, int *outY,
int *outDescent, int *outExternalLeading, const wxFont *inFont) const
{
// FIXME: This obviously ignores the window's font (if any) along with any size

View File

@ -557,9 +557,10 @@ int wxWindowDFB::GetCharWidth() const
return dc.GetCharWidth();
}
void wxWindowDFB::GetTextExtent(const wxString& string,
void wxWindowDFB::DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading,
int *descent,
int *externalLeading,
const wxFont *theFont) const
{
wxWindowDC dc((wxWindow*)this);

View File

@ -2922,7 +2922,7 @@ int wxWindowGTK::GetCharWidth() const
return (int) PANGO_PIXELS(rect.width);
}
void wxWindowGTK::GetTextExtent( const wxString& string,
void wxWindowGTK::DoGetTextExtent( const wxString& string,
int *x,
int *y,
int *descent,

View File

@ -3240,7 +3240,7 @@ int wxWindowGTK::GetCharWidth() const
return gdk_string_width( gfont, "g" );
}
void wxWindowGTK::GetTextExtent( const wxString& string,
void wxWindowGTK::DoGetTextExtent(const wxString& string,
int *x,
int *y,
int *descent,

View File

@ -1079,9 +1079,10 @@ int wxWindowMGL::GetCharWidth() const
return dc.GetCharWidth();
}
void wxWindowMGL::GetTextExtent(const wxString& string,
void wxWindowMGL::DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading,
int *descent,
int *externalLeading,
const wxFont *theFont) const
{
wxScreenDC dc;

View File

@ -1478,9 +1478,10 @@ int wxWindow::GetCharWidth() const
return width;
}
void wxWindow::GetTextExtent(const wxString& string,
void wxWindow::DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading,
int *descent,
int *externalLeading,
const wxFont *theFont) const
{
const wxFont *fontToUse = theFont ? theFont : &m_font;

View File

@ -2133,9 +2133,10 @@ int wxWindowMSW::GetCharWidth() const
#endif
}
void wxWindowMSW::GetTextExtent(const wxString& string,
void wxWindowMSW::DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading,
int *descent,
int *externalLeading,
const wxFont *fontToUse) const
{
wxASSERT_MSG( !fontToUse || fontToUse->Ok(),

View File

@ -1661,7 +1661,7 @@ int wxWindowOS2::GetCharWidth() const
return(vFontMetrics.lAveCharWidth);
} // end of wxWindowOS2::GetCharWidth
void wxWindowOS2::GetTextExtent( const wxString& rString,
void wxWindowOS2::DoGetTextExtent( const wxString& rString,
int* pX,
int* pY,
int* pDescent,
@ -1750,7 +1750,7 @@ void wxWindowOS2::GetTextExtent( const wxString& rString,
*pExternalLeading = 0;
}
::WinReleasePS(hPS);
} // end of wxWindow::GetTextExtent
} // end of wxWindow::DoGetTextExtent
bool wxWindowOS2::IsMouseInWindow() const
{

View File

@ -1089,8 +1089,11 @@ int wxWindowMac::GetCharWidth() const
return width;
}
void wxWindowMac::GetTextExtent(const wxString& str, int *x, int *y,
int *descent, int *externalLeading, const wxFont *theFont ) const
void wxWindowMac::DoGetTextExtent(const wxString& str,
int *x, int *y,
int *descent,
int *externalLeading,
const wxFont *theFont) const
{
const wxFont *fontToUse = theFont;
wxFont tempFont;

View File

@ -610,9 +610,10 @@ int wxWindowPalm::GetCharWidth() const
return 0;
}
void wxWindowPalm::GetTextExtent(const wxString& string,
void wxWindowPalm::DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading,
int *descent,
int *externalLeading,
const wxFont *theFont) const
{
}

View File

@ -1076,9 +1076,10 @@ int wxWindowX11::GetCharWidth() const
#endif
}
void wxWindowX11::GetTextExtent(const wxString& string,
void wxWindowX11::DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading,
int *descent,
int *externalLeading,
const wxFont *theFont) const
{
wxFont fontToUse = GetFont();