renamed wxDynamicThisCast to wxDynamicCastThis, removed 1st parameter, and documented

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2001-07-17 08:25:43 +00:00
parent 8e673075f6
commit f763782968
4 changed files with 41 additions and 15 deletions

View File

@ -2437,7 +2437,7 @@ avoid using {\tt \#ifdef}s when creating bitmaps.
\membersection{wxConstCast}\label{wxconstcast}
\func{}{wxConstCast}{ptr, classname}
\func{classname *}{wxConstCast}{ptr, classname}
This macro expands into {\tt const\_cast<classname *>(ptr)} if the compiler
supports {\it const\_cast} or into an old, C-style cast, otherwise.
@ -2466,14 +2466,15 @@ In non-debug mode, this is defined as the normal new operator.
\membersection{wxDynamicCast}\label{wxdynamiccast}
\func{}{wxDynamicCast}{ptr, classname}
\func{classname *}{wxDynamicCast}{ptr, classname}
This macro returns the pointer {\it ptr} cast to the type {\it classname *} if
the pointer is of this type (the check is done during the run-time) or NULL
otherwise. Usage of this macro is preferred over obsoleted wxObject::IsKindOf()
function.
the pointer is of this type (the check is done during the run-time) or
{\tt NULL} otherwise. Usage of this macro is preferred over obsoleted
wxObject::IsKindOf() function.
The {\it ptr} argument may be NULL, in which case NULL will be returned.
The {\it ptr} argument may be {\tt NULL}, in which case {\tt NULL} will be
returned.
Example:
@ -2493,9 +2494,23 @@ Example:
\wxheading{See also}
\helpref{RTTI overview}{runtimeclassoverview}\\
\helpref{wxDynamicCastThis}{wxdynamiccastthis}\\
\helpref{wxConstCast}{wxconstcast}\\
\helpref{wxStatiicCast}{wxstaticcast}
\membersection{wxDynamicCastThis}\label{wxdynamiccastthis}
\func{classname *}{wxDynamicCastThis}{classname}
This macro is equivalent to {\tt wxDynamicCast(this, classname)} but the
latter provokes spurious compilation warnings from some compilers (because it
tests whether {\tt this} pointer is non {\tt NULL} which is always true), so
this macro should be used to avoid them.
\wxheading{See also}
\helpref{wxDynamicCast}{wxdynamiccast}
\membersection{wxICON}\label{wxiconmacro}
\func{}{wxICON}{iconName}
@ -2515,7 +2530,7 @@ avoid using {\tt \#ifdef}s when creating icons.
\membersection{wxStaticCast}\label{wxstaticcast}
\func{}{wxStaticCast}{ptr, classname}
\func{classname *}{wxStaticCast}{ptr, classname}
This macro checks that the cast is valid in debug mode (an assert failure will
result if {\tt wxDynamicCast(ptr, classname) == NULL}) and then returns the

View File

@ -177,9 +177,9 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
// The 'this' pointer is always true, so use this version to cast the this
// pointer and avoid compiler warnings.
#define wxDynamicThisCast(obj, className) \
(((obj)->IsKindOf(&className::sm_class##className)) \
? (className *)(obj) \
#define wxDynamicCastThis(className) \
(IsKindOf(&className::sm_class##className) \
? (className *)(this) \
: (className *)0)
#define wxConstCast(obj, className) ((className *)(obj))

View File

@ -1384,7 +1384,7 @@ void wxWindowBase::UpdateWindowUI()
if ( event.GetSetText() )
{
wxControl *control = wxDynamicThisCast(this, wxControl);
wxControl *control = wxDynamicCastThis(wxControl);
if ( control )
{
#if wxUSE_TEXTCTRL
@ -1398,7 +1398,7 @@ void wxWindowBase::UpdateWindowUI()
}
#if wxUSE_CHECKBOX
wxCheckBox *checkbox = wxDynamicThisCast(this, wxCheckBox);
wxCheckBox *checkbox = wxDynamicCastThis(wxCheckBox);
if ( checkbox )
{
if ( event.GetSetChecked() )
@ -1407,7 +1407,7 @@ void wxWindowBase::UpdateWindowUI()
#endif // wxUSE_CHECKBOX
#if wxUSE_RADIOBTN
wxRadioButton *radiobtn = wxDynamicThisCast(this, wxRadioButton);
wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton);
if ( radiobtn )
{
if ( event.GetSetChecked() )

View File

@ -194,7 +194,7 @@ END_EVENT_TABLE()
wxWindow *wxWindowMSW::FindItem(long id) const
{
#if wxUSE_CONTROLS
wxControl *item = wxDynamicThisCast(this, wxControl);
wxControl *item = wxDynamicCastThis(wxControl);
if ( item )
{
// is it we or one of our "internal" children?
@ -354,6 +354,17 @@ bool wxWindowMSW::Create(wxWindow *parent,
{
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
#if wxUSE_STATBOX
// wxGTK doesn't allow to create controls with static box as the parent so
// this will result in a crash when the program is ported to wxGTK - warn
// about it
//
// the correct solution is to create the controls as siblings of the
// static box
wxASSERT_MSG( !wxDynamicCastThis(wxStaticBox),
_T("wxStaticBox can't be used as a window parent!") );
#endif // wxUSE_STATBOX
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
@ -1777,7 +1788,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
#if wxUSE_BUTTON
else
{
wxPanel *panel = wxDynamicThisCast(this, wxPanel);
wxPanel *panel = wxDynamicCastThis(wxPanel);
wxButton *btn = NULL;
if ( panel )
{