From 9f8d3f61a913c495ae80c8471ea175ab13cd4613 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 3 Mar 2005 10:53:55 +0000
Subject: [PATCH] added wx_dynamic_cast()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 configure.in               |  1 +
 docs/changes.txt           | 10 ++++++----
 docs/latex/wx/function.tex | 23 ++++++++++++++++++++++-
 include/wx/defs.h          |  9 +++++++++
 4 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/configure.in b/configure.in
index 6e2e1ab326..9e5583fad2 100644
--- a/configure.in
+++ b/configure.in
@@ -1882,6 +1882,7 @@ dnl check whether C++ compiler supports C++ casts
 AC_CXX_CONST_CAST
 AC_CXX_REINTERPRET_CAST
 AC_CXX_STATIC_CAST
+AC_CXX_DYNAMIC_CAST
 
 dnl check various STL features
 if test "$wxUSE_STL" = "yes"; then
diff --git a/docs/changes.txt b/docs/changes.txt
index 17d1350f08..11951c0b99 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -7,16 +7,18 @@ wxWidgets 2.5 Change Log - For more verbose changes, see the manual
 
 All:
 
-- wxURI::GetUser and wxURI::HasUser have been renamed to wxURI::GetUserInfo and wxURI::HasUserInfo respectively so that wxURI::GetUser returns the old username that were in the HTTP specification along with wxURI::GetPassword (Note that if you used wxURI::GetUser from 2.5.3 you should rename all instances of it to wxURI::GetUserInfo).
-- Added 
+- wxURI::GetUser() only returns the user name now, use GetUserInfo() to get
+  user and password as in 2.5.4; wxURI::GetPassword() added
+- added wx_dynamic_cast() macro
 
 All (GUI):
 
 - Added GetIcon, GetBitmap to wxImageList. wxGenericImageList's original
   GetBitmap is renamed GetBitmapPtr.
 - Added XPM data constructor to wxImage.
-- Added style parameter to wxBufferedDC to allow buffering just
-  the client, or the whole virtual area.
+- Added style parameter to wxBufferedDC to allow buffering just the client, or
+  the whole virtual area.
+
 
 wxPalmOS:
 
diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index c6808d5e65..122ed0d49f 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -247,6 +247,7 @@ the corresponding topic.
 \helpref{wxWriteResource}{wxwriteresource}\\
 \helpref{wxYield}{wxyield}\\
 \helpref{wx\_const\_cast}{wxconstcastraw}\\
+\helpref{wx\_dynamic\_cast}{wxdynamiccastraw}\\
 \helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw}\\
 \helpref{wx\_static\_cast}{wxstaticcastraw}\\
 \helpref{\_}{underscore}\\
@@ -3500,7 +3501,8 @@ Example:
 \helpref{RTTI overview}{runtimeclassoverview}\\
 \helpref{wxDynamicCastThis}{wxdynamiccastthis}\\
 \helpref{wxConstCast}{wxconstcast}\\
-\helpref{wxStatiicCast}{wxstaticcast}
+\helpref{wxStaticCast}{wxstaticcast}\\
+\helpref{wx\_dynamic\_cast}{wxdynamiccastraw}
 
 
 \membersection{wxDynamicCastThis}\label{wxdynamiccastthis}
@@ -3543,6 +3545,23 @@ arguments is the same as for the standard cast.
 
 \wxheading{See also}
 
+\helpref{wx\_dynamic\_cast}{wxdynamiccastraw},\\
+\helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw},\\
+\helpref{wx\_static\_cast}{wxstaticcastraw}
+
+
+\membersection{wx\_dynamic\_cast}\label{wxdynamiccastraw}
+
+\func{T}{wx\_dynamic\_cast}{T, x}
+
+Same as \texttt{dynamic\_cast<T>(x)} if the compiler supports dynamic cast or
+\texttt{(T)x} for old compilers. Unlike \helpref{wxDynamicCast}{wxdynamiccast},
+the cast it to the type \arg{T} and not to \texttt{T *} and also the order of
+arguments is the same as for the standard cast.
+
+\wxheading{See also}
+
+\helpref{wx\_const\_cast}{wxconstcastraw},\\
 \helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw},\\
 \helpref{wx\_static\_cast}{wxstaticcastraw}
 
@@ -3557,6 +3576,7 @@ Same as \texttt{reinterpret\_cast<T>(x)} if the compiler supports reinterpret ca
 \wxheading{See also}
 
 \helpref{wx\_const\_cast}{wxconstcastraw},\\
+\helpref{wx\_dynamic\_cast}{wxdynamiccastraw},\\
 \helpref{wx\_static\_cast}{wxstaticcastraw}
 
 
@@ -3573,6 +3593,7 @@ star is not appended to it.
 \wxheading{See also}
 
 \helpref{wx\_const\_cast}{wxconstcastraw},\\
+\helpref{wx\_dynamic\_cast}{wxdynamiccastraw},\\
 \helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw}
 
 
diff --git a/include/wx/defs.h b/include/wx/defs.h
index 4203d06ec2..5194f06786 100644
--- a/include/wx/defs.h
+++ b/include/wx/defs.h
@@ -269,6 +269,9 @@ typedef int wxWindowID;
     #ifndef HAVE_STATIC_CAST
         #define HAVE_STATIC_CAST
     #endif
+    #ifndef HAVE_DYNAMIC_CAST
+        #define HAVE_DYNAMIC_CAST
+    #endif
 #endif /*  HAVE_CXX_CASTS */
 
 #ifdef HAVE_STATIC_CAST
@@ -277,6 +280,12 @@ typedef int wxWindowID;
     #define wx_static_cast(t, x) ((t)(x))
 #endif
 
+#ifdef HAVE_DYNAMIC_CAST
+    #define wx_dynamic_cast(t, x) dynamic_cast<t>(x)
+#else
+    #define wx_dynamic_cast(t, x) ((t)(x))
+#endif
+
 #ifdef HAVE_CONST_CAST
     #define wx_const_cast(t, x) const_cast<t>(x)
 #else
-- 
2.50.0

