Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1793 lines
88 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef UIEVENT_H
  6. #define UIEVENT_H
  7. #pragma once
  8. #include "tier1/utlsymbol.h"
  9. #include "tier1/utldelegate.h"
  10. #include "controls/panelhandle.h"
  11. #include "controls/panelptr.h"
  12. #include "iuipanel.h"
  13. #include "iuipanelclient.h"
  14. #include "tier1/fmtstr.h"
  15. #include "panoramacxx.h"
  16. // Strict template usage is just a dev-time convenience
  17. // for finding missing template specializations.
  18. // It should never be enabled by default as there are
  19. // types that do not have or need template support by-design.
  20. #if 0
  21. #define PANORAMA_STRICT_EVENT_TEMPLATE_USAGE
  22. #endif
  23. #if 0
  24. #define PANORAMA_STRICT_V8_TEMPLATE_USAGE
  25. #endif
  26. #if defined(PANORAMA_STRICT_EVENT_TEMPLATE_USAGE) || defined(PANORAMA_STRICT_V8_TEMPLATE_USAGE)
  27. #define PANORAMA_ANY_STRICT_EVENT_TEMPLATE_USAGE
  28. #endif
  29. namespace panorama
  30. {
  31. extern void RegisterEventTypesWithEngine( IUIEngine *pEngine );
  32. #ifdef DBGFLAG_VALIDATE
  33. void ValidateGlobalEvents( CValidator &validator );
  34. #endif
  35. inline bool IsEndOfUIEventString( const char *pchEvent, const char **pchEndOfEvent )
  36. {
  37. {
  38. while( pchEvent[0] != '\0' && pchEvent[0] != ')' )
  39. {
  40. if( !V_isspace( pchEvent[0] ) )
  41. return false;
  42. pchEvent++;
  43. }
  44. if( pchEvent[0] == ')' )
  45. ++pchEvent;
  46. *pchEndOfEvent = pchEvent;
  47. return true;
  48. }
  49. }
  50. class IUIEvent;
  51. inline v8::Isolate *GetV8Isolate() { return UIEngine()->GetV8Isolate(); }
  52. inline const char *GetPanelID( const panorama::IUIPanel *pPanel ) { return pPanel->GetID(); }
  53. //-----------------------------------------------------------------------------
  54. // Purpose: Helpers to create an event from string
  55. //-----------------------------------------------------------------------------
  56. template < typename T >
  57. bool ParseUIEventParam( T *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam )
  58. {
  59. #ifdef PANORAMA_STRICT_EVENT_TEMPLATE_USAGE
  60. TEMPLATE_USAGE_INVALID( T );
  61. #else
  62. AssertMsg( false, "ParseUIEventParam not implemented for type" );
  63. // Zero-fill so that the compiler doesn't complain about use
  64. // of uninitialized data, even though this code path is not functional.
  65. memset( pOut, 0, sizeof(*pOut) );
  66. return false;
  67. #endif
  68. }
  69. template <> bool ParseUIEventParam< const char * >( const char **pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  70. template <> bool ParseUIEventParam< uint8 >( uint8 *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  71. template <> bool ParseUIEventParam< uint16 >( uint16 *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  72. template <> bool ParseUIEventParam< uint32 >( uint32 *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  73. template <> bool ParseUIEventParam< uint64 >( uint64 *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  74. template <> bool ParseUIEventParam< int32 >( int32 *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  75. template <> bool ParseUIEventParam< int64 >( int64 *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  76. template <> bool ParseUIEventParam< float >( float *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  77. template <> bool ParseUIEventParam< bool >( bool *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  78. template <> bool ParseUIEventParam< IUIEvent * >( IUIEvent **pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  79. template <> bool ParseUIEventParam< panorama::EPanelEventSource_t >( panorama::EPanelEventSource_t *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  80. template <> bool ParseUIEventParam< panorama::ScrollBehavior_t >( panorama::ScrollBehavior_t *pOut, panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchNextParam );
  81. int CountUIEventParams( const char *pchParams );
  82. bool ParseUIEventParamHelper( CUtlBuffer &bufValue, const char *pchEvent, const char **pchNextParam );
  83. bool IsEndOfUIEventString( const char *pchEvent, const char **pchEndOfEvent );
  84. //-----------------------------------------------------------------------------
  85. // Purpose: Helpers to turn event params in JS params
  86. //-----------------------------------------------------------------------------
  87. // Default, complain not implemented!
  88. template < typename T > typename panorama_enable_if< !panorama_is_enum< T >::value, void>::type
  89. PanoramaTypeToV8Param( T &pIn, v8::Handle<v8::Value> *pValueOut )
  90. {
  91. #ifdef PANORAMA_STRICT_V8_TEMPLATE_USAGE
  92. TEMPLATE_USAGE_INVALID( T );
  93. #else
  94. AssertMsg( false, "EventParamToV8Param not implemented for type" );
  95. #endif
  96. }
  97. // Default for enum types
  98. template < typename T > typename panorama_enable_if< panorama_is_enum< T >::value, void>::type
  99. PanoramaTypeToV8Param( T &pIn, v8::Handle<v8::Value> *pValueOut )
  100. {
  101. COMPILE_TIME_ASSERT( sizeof( pIn ) <= sizeof( int32 ) );
  102. int32 iVal = (int32)pIn;
  103. return PanoramaTypeToV8Param<int32>( iVal, pValueOut );
  104. }
  105. // Basic non pointer specializations
  106. template <> void PanoramaTypeToV8Param< CUtlSymbol >( CUtlSymbol &pIn, v8::Handle<v8::Value> *pValueOut );
  107. template <> void PanoramaTypeToV8Param< panorama::CPanoramaSymbol >( panorama::CPanoramaSymbol &pIn, v8::Handle<v8::Value> *pValueOut );
  108. template <> void PanoramaTypeToV8Param< uint32 >( uint32 &pIn, v8::Handle<v8::Value> *pValueOut );
  109. template <> void PanoramaTypeToV8Param< uint64 >( uint64 &pIn, v8::Handle<v8::Value> *pValueOut );
  110. template <> void PanoramaTypeToV8Param< int32 >( int32 &pIn, v8::Handle<v8::Value> *pValueOut );
  111. template <> void PanoramaTypeToV8Param< int64 >( int64 &pIn, v8::Handle<v8::Value> *pValueOut );
  112. template <> void PanoramaTypeToV8Param< float >( float &pIn, v8::Handle<v8::Value> *pValueOut );
  113. template <> void PanoramaTypeToV8Param< double >( double &pIn, v8::Handle<v8::Value> *pValueOut );
  114. template <> void PanoramaTypeToV8Param< bool >( bool &pIn, v8::Handle<v8::Value> *pValueOut );
  115. template <> void PanoramaTypeToV8Param< CUtlVector< IUIPanel * > const >( CUtlVector< IUIPanel * > const &pIn, v8::Handle<v8::Value> *pValueOut );
  116. template <> void PanoramaTypeToV8Param< panorama::EPanelEventSource_t >( panorama::EPanelEventSource_t &pIn, v8::Handle<v8::Value> *pValueOut );
  117. template <> void PanoramaTypeToV8Param< v8::Local<v8::Value> >( v8::Local<v8::Value> &pIn, v8::Handle<v8::Value> *pValueOut );
  118. template <> void PanoramaTypeToV8Param< v8::Local<v8::Object> >( v8::Local<v8::Object> &pIn, v8::Handle<v8::Value> *pValueOut );
  119. template <> void PanoramaTypeToV8Param< v8::Local<v8::Array> >( v8::Local<v8::Array> &pIn, v8::Handle<v8::Value> *pValueOut );
  120. // Helper for specific pointer types we have special handling for via rules in the base T* specialization
  121. void PanoramaTypeToV8ParamJSObject( IUIJSObject *pJSObj, void *pIn, v8::Handle<v8::Value> *pValueOut );
  122. void PanoramaPanelTypeToV8Param( IUIPanel * &pIn, v8::Handle<v8::Value> *pValueOut );
  123. void PanoramaPanelStyleTypeToV8Param( IUIPanelStyle * &pIn, v8::Handle<v8::Value> *pValueOut );
  124. // Template overload for ptr types, so we can see if we should turn into base CPanel2D, or other special known types,
  125. // otherwise we'll call PanoramaPtrTypeToV8ParamJSObject and let the specialization rules figure it out
  126. template < typename T >
  127. void PanoramaTypeToV8Param( T * pIn, v8::Handle<v8::Value> *pValueOut )
  128. {
  129. if( panorama_is_base_of< IUIPanelClient, T >::value )
  130. {
  131. IUIPanel *pPanel = pIn ? ( (IUIPanelClient*)pIn )->UIPanel() : NULL;
  132. return PanoramaPanelTypeToV8Param( pPanel, pValueOut );
  133. }
  134. else if( panorama_is_base_of< IUIPanel, T >::value )
  135. {
  136. IUIPanel *pPanel = (IUIPanel*)pIn;
  137. return PanoramaPanelTypeToV8Param( pPanel, pValueOut );
  138. }
  139. else if( panorama_is_base_of< IUIPanelStyle, T >::value )
  140. {
  141. IUIPanelStyle *pPanel = (IUIPanelStyle*)pIn;
  142. return PanoramaPanelStyleTypeToV8Param( pPanel, pValueOut );
  143. }
  144. else if( panorama_is_base_of< IUIJSObject, T>::value )
  145. {
  146. IUIJSObject *pObject = (IUIJSObject*)pIn;
  147. return PanoramaTypeToV8ParamJSObject( pObject, (void*)pIn, pValueOut );
  148. }
  149. AssertMsg( false, "PanoramaTypeToV8Param not implemented for type" );
  150. }
  151. // Specialization of above ptr overload
  152. template <> void PanoramaTypeToV8Param<const char>( const char * pIn, v8::Handle<v8::Value> *pValueOut );
  153. template <> void PanoramaTypeToV8Param<char>( char * pIn, v8::Handle<v8::Value> *pValueOut );
  154. // bugbug jmccaskey - add IUIEvent, panel source, panel2d? more?
  155. //-----------------------------------------------------------------------------
  156. // Purpose: Helpers to turn JS params into native params
  157. //-----------------------------------------------------------------------------
  158. template < typename T >
  159. void V8ParamToPanoramaType( const v8::Handle<v8::Value> &pValueIn, T *out )
  160. {
  161. #ifdef PANORAMA_STRICT_V8_TEMPLATE_USAGE
  162. TEMPLATE_USAGE_INVALID( T );
  163. #else
  164. AssertMsg( false, "V8ParamToPanoramaType not implemented for type" );
  165. #endif
  166. }
  167. template <> void V8ParamToPanoramaType< const char *>( const v8::Handle<v8::Value> &pValueIn, const char ** out );
  168. template <> void V8ParamToPanoramaType< CUtlSymbol >( const v8::Handle<v8::Value> &pValueIn, CUtlSymbol* out );
  169. template <> void V8ParamToPanoramaType< panorama::CPanoramaSymbol >( const v8::Handle<v8::Value> &pValueIn, panorama::CPanoramaSymbol* out );
  170. template <> void V8ParamToPanoramaType< float >( const v8::Handle<v8::Value> &pValueIn, float *out );
  171. template <> void V8ParamToPanoramaType< double >( const v8::Handle<v8::Value> &pValueIn, double *out );
  172. template <> void V8ParamToPanoramaType< int >( const v8::Handle<v8::Value> &pValueIn, int *out );
  173. template <> void V8ParamToPanoramaType< uint >( const v8::Handle<v8::Value> &pValueIn, uint *out );
  174. template <> void V8ParamToPanoramaType< bool >( const v8::Handle<v8::Value> &pValueIn, bool *out );
  175. template <> void V8ParamToPanoramaType< IUIPanel * >( const v8::Handle<v8::Value> &pValueIn, IUIPanel **out );
  176. #ifndef PANORAMA_EXPORTS
  177. template <> void V8ParamToPanoramaType< CPanel2D * >( const v8::Handle<v8::Value> &pValueIn, CPanel2D **out );
  178. #endif
  179. template <> void V8ParamToPanoramaType< IUIPanelStyle * >( const v8::Handle<v8::Value> &pValueIn, IUIPanelStyle **out );
  180. #ifdef PANORAMA_EXPORTS
  181. template <> void V8ParamToPanoramaType< CPanelStyle * >( const v8::Handle<v8::Value> &pValueIn, CPanelStyle **out );
  182. #endif
  183. template <> void V8ParamToPanoramaType< v8::Persistent<v8::Function> * >( const v8::Handle<v8::Value> &pValueIn, v8::Persistent<v8::Function> **out );
  184. template <> void V8ParamToPanoramaType< CUtlVector< IUIPanel *> >( const v8::Handle<v8::Value> &pValueIn, CUtlVector< IUIPanel *>*out );
  185. template <> void V8ParamToPanoramaType< v8::Local<v8::Value> >( const v8::Handle<v8::Value> &pValueIn, v8::Local<v8::Value> *out );
  186. template <> void V8ParamToPanoramaType< v8::Local<v8::Object> >( const v8::Handle<v8::Value> &pValueIn, v8::Local<v8::Object> *out );
  187. template <> void V8ParamToPanoramaType< v8::Local<v8::Array> >( const v8::Handle<v8::Value> &pValueIn, v8::Local<v8::Array> *out );
  188. template <typename T> void FreeConvertedParam(T out) { }
  189. template <> void FreeConvertedParam< const char *>( const char *out );
  190. template <> void FreeConvertedParam< v8::Persistent<v8::Function> *>( v8::Persistent<v8::Function> *out );
  191. //-----------------------------------------------------------------------------
  192. // Purpose: Wrappers to handle copying params. const char * is specialized to dup the string
  193. //-----------------------------------------------------------------------------
  194. template < class T >
  195. void UIEventSet( T* pTo, T &pFrom )
  196. {
  197. *pTo = pFrom;
  198. }
  199. template <>
  200. void UIEventSet( const char** pTo, const char *&pFrom );
  201. template <>
  202. void UIEventSet( IUIEvent** pTo, IUIEvent *&pFrom );
  203. template <>
  204. void UIEventSet( v8::Persistent<v8::Function>** pTo, v8::Persistent<v8::Function> *&pFrom );
  205. template < class T >
  206. void UIEventFree( T &p )
  207. {
  208. }
  209. template <>
  210. void UIEventFree( const char *& p );
  211. template <>
  212. void UIEventFree( IUIEvent *& p );
  213. template <>
  214. void UIEventFree( v8::Persistent<v8::Function> *&p );
  215. #ifdef DBGFLAG_VALIDATE
  216. template < class T >
  217. void UIEventValidate( CValidator &validator, T &p )
  218. {
  219. }
  220. template <>
  221. void UIEventValidate( CValidator &validator, const char *& p );
  222. template <>
  223. void UIEventValidate( CValidator &validator, IUIEvent *& p );
  224. template <>
  225. void UIEventValidate( CValidator &validator, v8::Persistent<v8::Function> *& p );
  226. #endif
  227. //-----------------------------------------------------------------------------
  228. // Purpose: Macros to declare a event
  229. // Includes Register/Unregister calls to enforce type safety
  230. //-----------------------------------------------------------------------------
  231. //
  232. // Events with 0 params
  233. //
  234. namespace UIEvent
  235. {
  236. template < class T >
  237. IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchEventEnd )
  238. {
  239. if ( !IsEndOfUIEventString( pchEvent, &pchEvent ) )
  240. return NULL;
  241. *pchEventEnd = pchEvent;
  242. IUIEvent *pEvent = T::MakeEvent( pPanel ? pPanel->ClientPtr() : NULL );
  243. return pEvent;
  244. }
  245. }
  246. #define DECLARE_PANORAMA_EVENT0( name ) \
  247. class name \
  248. { \
  249. public: \
  250. static const int cParams = 0; static const bool bPanelEvent = false; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  251. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  252. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget ) { return new panorama::CUIEvent0( symbol, pTarget ? pTarget->UIPanel() : NULL ); } \
  253. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name >( pPanel, pchEventCreate, pchEventEnd ); } \
  254. }; \
  255. template< class T, class U > void RegisterEventHandler( const name &t, T *pHandlerPanel, bool (U::*memberfunc)() ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pHandlerPanel, UtlMakeDelegate( pHandlerPanel, memberfunc ).GetAbstractDelegate() ); } \
  256. template< class T, class U > void UnregisterEventHandler( const name &t, T *pHandlerPanel, bool (U::*memberfunc)() ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pHandlerPanel, UtlMakeDelegate( pHandlerPanel, memberfunc ).GetAbstractDelegate() ); } \
  257. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)() ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  258. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)() ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  259. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pHandlerObj, bool (U::*memberfunc)() ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pHandlerObj, memberfunc ).GetAbstractDelegate() ); } \
  260. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pHandlerObj, bool (U::*memberfunc)() ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pHandlerObj, memberfunc ).GetAbstractDelegate() ); } \
  261. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool (PanelType::*memberfunc)() ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  262. #define DECLARE_PANEL_EVENT0( name ) \
  263. class name \
  264. { \
  265. public: \
  266. static const int cParams = 0; static const bool bPanelEvent = true; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  267. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  268. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget ) { return new panorama::CUIPanelEvent0( symbol, pTarget ? pTarget->UIPanel() : NULL ); } \
  269. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name >( pPanel, pchEventCreate, pchEventEnd ); } \
  270. }; \
  271. template< class T, class U > void RegisterEventHandler( const name &t, T * pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  272. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  273. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T * pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  274. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  275. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  276. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  277. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( const panorama::CPanelPtr< panorama::IUIPanel > & ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  278. //
  279. // Events with 1 params
  280. //
  281. namespace UIEvent
  282. {
  283. template < class T, typename param1 >
  284. IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchEventEnd )
  285. {
  286. param1 p1;
  287. if ( !ParseUIEventParam< param1 >( &p1, pPanel, pchEvent, &pchEvent ) )
  288. return NULL;
  289. if ( !IsEndOfUIEventString( pchEvent, &pchEvent ) )
  290. return NULL;
  291. *pchEventEnd = pchEvent;
  292. IUIEvent *pEvent = T::MakeEvent( pPanel ? pPanel->ClientPtr() : NULL, p1 );
  293. UIEventFree( p1 );
  294. return pEvent;
  295. }
  296. }
  297. #define DECLARE_PANORAMA_EVENT1( name, param1 ) \
  298. class name \
  299. { \
  300. public: \
  301. typedef param1 TypenameParam1; static const int cParams = 1; static const bool bPanelEvent = false; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  302. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  303. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1 ) { return new panorama::CUIEvent1< param1 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1 ); } \
  304. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1 >( pPanel, pchEventCreate, pchEventEnd ); } \
  305. }; \
  306. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  307. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel->UIPanel(), UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  308. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  309. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  310. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  311. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  312. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( param1 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  313. #define DECLARE_PANEL_EVENT1( name, param1 ) \
  314. class name \
  315. { \
  316. public: \
  317. typedef param1 TypenameParam1; static const int cParams = 1; static const bool bPanelEvent = true; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  318. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  319. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1 ) { return new panorama::CUIPanelEvent1< param1 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1 ); } \
  320. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1 >( pPanel, pchEventCreate, pchEventEnd ); } \
  321. }; \
  322. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  323. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel->UIPanel(), UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  324. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  325. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  326. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  327. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  328. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( const panorama::CPanelPtr< panorama::IUIPanel > &, param1 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  329. //
  330. // Events with 2 params
  331. //
  332. namespace UIEvent
  333. {
  334. template < class T, typename param1, typename param2 >
  335. IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchEventEnd )
  336. {
  337. param1 p1;
  338. if ( !ParseUIEventParam< param1 >( &p1, pPanel, pchEvent, &pchEvent ) )
  339. return NULL;
  340. param2 p2;
  341. if ( !ParseUIEventParam< param2 >( &p2, pPanel, pchEvent, &pchEvent ) )
  342. return NULL;
  343. if ( !IsEndOfUIEventString( pchEvent, &pchEvent ) )
  344. return NULL;
  345. *pchEventEnd = pchEvent;
  346. IUIEvent *pEvent = T::MakeEvent( pPanel ? pPanel->ClientPtr() : NULL, p1, p2 );
  347. UIEventFree( p1 );
  348. UIEventFree( p2 );
  349. return pEvent;
  350. }
  351. }
  352. #define DECLARE_PANORAMA_EVENT2( name, param1, param2 ) \
  353. class name \
  354. { \
  355. public: \
  356. typedef param1 TypenameParam1; typedef param2 TypenameParam2; static const int cParams = 2; static const bool bPanelEvent = false; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  357. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  358. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2 ) { return new panorama::CUIEvent2< param1, param2 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2 ); } \
  359. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2 >( pPanel, pchEventCreate, pchEventEnd ); } \
  360. }; \
  361. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  362. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  363. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  364. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  365. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  366. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  367. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( param1, param2 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  368. #define DECLARE_PANEL_EVENT2( name, param1, param2 ) \
  369. class name \
  370. { \
  371. public: \
  372. typedef param1 TypenameParam1; typedef param2 TypenameParam2; static const int cParams = 2; static const bool bPanelEvent = true; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  373. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  374. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2 ) { return new panorama::CUIPanelEvent2< param1, param2 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2 ); } \
  375. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2 >( pPanel, pchEventCreate, pchEventEnd ); } \
  376. }; \
  377. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  378. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  379. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  380. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  381. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  382. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  383. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  384. //
  385. // Events with 3 params
  386. //
  387. namespace UIEvent
  388. {
  389. template < class T, typename param1, typename param2, typename param3 >
  390. IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchEventEnd )
  391. {
  392. param1 p1;
  393. if ( !ParseUIEventParam< param1 >( &p1, pPanel, pchEvent, &pchEvent ) )
  394. return NULL;
  395. param2 p2;
  396. if ( !ParseUIEventParam< param2 >( &p2, pPanel, pchEvent, &pchEvent ) )
  397. return NULL;
  398. param3 p3;
  399. if ( !ParseUIEventParam< param3 >( &p3, pPanel, pchEvent, &pchEvent ) )
  400. return NULL;
  401. if ( !IsEndOfUIEventString( pchEvent, &pchEvent ) )
  402. return NULL;
  403. *pchEventEnd = pchEvent;
  404. IUIEvent *pEvent = T::MakeEvent( pPanel ? pPanel->ClientPtr() : NULL, p1, p2, p3 );
  405. UIEventFree( p1 );
  406. UIEventFree( p2 );
  407. UIEventFree( p3 );
  408. return pEvent;
  409. }
  410. }
  411. #define DECLARE_PANORAMA_EVENT3( name, param1, param2, param3 ) \
  412. class name \
  413. { \
  414. public: \
  415. typedef param1 TypenameParam1; typedef param2 TypenameParam2; typedef param3 TypenameParam3; static const int cParams = 3; static const bool bPanelEvent = false; static panorama::CPanoramaSymbol symbol; static const char *pchEvent; \
  416. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  417. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2, param3 p3 ) { return new panorama::CUIEvent3< param1, param2, param3 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2, p3 ); } \
  418. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2, param3 >( pPanel, pchEventCreate, pchEventEnd ); } \
  419. }; \
  420. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2, param3 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  421. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2, param3 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  422. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2, param3 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  423. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2, param3 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  424. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2, param3 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  425. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2, param3 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  426. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( param1, param2, param3 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  427. #define DECLARE_PANEL_EVENT3( name, param1, param2, param3 ) \
  428. class name \
  429. { \
  430. public: \
  431. typedef param1 TypenameParam1; typedef param2 TypenameParam2; typedef param3 TypenameParam3; static const int cParams = 3; static const bool bPanelEvent = true; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  432. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  433. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2, param3 p3 ) { return new panorama::CUIPanelEvent3< param1, param2, param3 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2, p3 ); } \
  434. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2, param3 >( pPanel, pchEventCreate, pchEventEnd ); } \
  435. }; \
  436. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  437. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  438. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  439. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  440. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  441. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  442. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  443. //
  444. // Events with 4 params
  445. //
  446. namespace UIEvent
  447. {
  448. template < class T, typename param1, typename param2, typename param3, typename param4 >
  449. IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchEventEnd )
  450. {
  451. param1 p1;
  452. if ( !ParseUIEventParam< param1 >( &p1, pPanel, pchEvent, &pchEvent ) )
  453. return NULL;
  454. param2 p2;
  455. if ( !ParseUIEventParam< param2 >( &p2, pPanel, pchEvent, &pchEvent ) )
  456. return NULL;
  457. param3 p3;
  458. if ( !ParseUIEventParam< param3 >( &p3, pPanel, pchEvent, &pchEvent ) )
  459. return NULL;
  460. param4 p4;
  461. if ( !ParseUIEventParam< param4 >( &p4, pPanel, pchEvent, &pchEvent ) )
  462. return NULL;
  463. if ( !IsEndOfUIEventString( pchEvent, &pchEvent ) )
  464. return NULL;
  465. *pchEventEnd = pchEvent;
  466. IUIEvent *pEvent = T::MakeEvent( pPanel ? pPanel->ClientPtr() : NULL, p1, p2, p3, p4 );
  467. UIEventFree( p1 );
  468. UIEventFree( p2 );
  469. UIEventFree( p3 );
  470. UIEventFree( p4 );
  471. return pEvent;
  472. }
  473. }
  474. #define DECLARE_PANORAMA_EVENT4( name, param1, param2, param3, param4 ) \
  475. class name \
  476. { \
  477. public: \
  478. typedef param1 TypenameParam1; typedef param2 TypenameParam2; typedef param3 TypenameParam3; typedef param4 TypenameParam4; static const int cParams = 4; static const bool bPanelEvent = false; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  479. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  480. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2, param3 p3, param4 p4 ) { return new panorama::CUIEvent4< param1, param2, param3, param4 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2, p3, p4 ); } \
  481. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2, param3, param4 >( pPanel, pchEventCreate, pchEventEnd ); } \
  482. }; \
  483. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  484. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2, param3, param4 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  485. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  486. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2, param3, param4 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  487. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  488. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2, param3, param4 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  489. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  490. #define DECLARE_PANEL_EVENT4( name, param1, param2, param3, param4 ) \
  491. class name \
  492. { \
  493. public: \
  494. typedef param1 TypenameParam1; typedef param2 TypenameParam2; typedef param3 TypenameParam3; typedef param4 TypenameParam4; static const int cParams = 4; static const bool bPanelEvent = true; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  495. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  496. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2, param3 p3, param4 p4 ) { return new panorama::CUIPanelEvent4< param1, param2, param3, param4 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2, p3, p4 ); } \
  497. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2, param3, param4 >( pPanel, pchEventCreate, pchEventEnd ); } \
  498. }; \
  499. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  500. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  501. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  502. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  503. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  504. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  505. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  506. //
  507. // Events with 5 params
  508. //
  509. namespace UIEvent
  510. {
  511. template < class T, typename param1, typename param2, typename param3, typename param4, typename param5 >
  512. IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEvent, const char **pchEventEnd )
  513. {
  514. param1 p1;
  515. if ( !ParseUIEventParam< param1 >( &p1, pPanel, pchEvent, &pchEvent ) )
  516. return NULL;
  517. param2 p2;
  518. if ( !ParseUIEventParam< param2 >( &p2, pPanel, pchEvent, &pchEvent ) )
  519. return NULL;
  520. param3 p3;
  521. if ( !ParseUIEventParam< param3 >( &p3, pPanel, pchEvent, &pchEvent ) )
  522. return NULL;
  523. param4 p4;
  524. if ( !ParseUIEventParam< param4 >( &p4, pPanel, pchEvent, &pchEvent ) )
  525. return NULL;
  526. param5 p5;
  527. if ( !ParseUIEventParam< param5 >( &p5, pPanel, pchEvent, &pchEvent ) )
  528. return NULL;
  529. if ( !IsEndOfUIEventString( pchEvent, &pchEvent ) )
  530. return NULL;
  531. *pchEventEnd = pchEvent;
  532. IUIEvent *pEvent = T::MakeEvent( pPanel ? pPanel->ClientPtr() : NULL, p1, p2, p3, p4, p5 );
  533. UIEventFree( p1 );
  534. UIEventFree( p2 );
  535. UIEventFree( p3 );
  536. UIEventFree( p4 );
  537. UIEventFree( p5 );
  538. return pEvent;
  539. }
  540. }
  541. #define DECLARE_PANORAMA_EVENT5( name, param1, param2, param3, param4, param5 ) \
  542. class name \
  543. { \
  544. public: \
  545. typedef param1 TypenameParam1; typedef param2 TypenameParam2; typedef param3 TypenameParam3; typedef param4 TypenameParam4; typedef param5 TypenameParam5; static const int cParams = 5; static const bool bPanelEvent = false; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  546. static panorama::CPanoramaSymbol GetEventType() { Assert( symbol.IsValid() ); return symbol; } \
  547. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2, param3 p3, param4 p4, param5 p5 ) { return new panorama::CUIEvent5< param1, param2, param3, param4, param5 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2, p3, p4, p5 ); } \
  548. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2, param3, param4, param5 >( pPanel, pchEventCreate, pchEventEnd ); } \
  549. }; \
  550. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  551. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  552. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  553. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  554. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  555. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  556. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  557. #define DECLARE_PANEL_EVENT5( name, param1, param2, param3, param4, param5 ) \
  558. class name \
  559. { \
  560. public: \
  561. typedef param1 TypenameParam1; typedef param2 TypenameParam2; typedef param3 TypenameParam3; typedef param4 TypenameParam4; typedef param5 TypenameParam5; static const int cParams = 5; static const bool bPanelEvent = true; static panorama::CPanoramaSymbol symbol; static const char *pchEvent;\
  562. static panorama::CPanoramaSymbol GetEventType() { return symbol; } \
  563. static panorama::IUIEvent *MakeEvent( const panorama::IUIPanelClient *pTarget, param1 p1, param2 p2, param3 p3, param4 p4, param5 p5 ) { return new panorama::CUIPanelEvent5< param1, param2, param3, param4, param5 >( symbol, pTarget ? pTarget->UIPanel() : NULL, p1, p2, p3, p4, p5 ); } \
  564. static panorama::IUIEvent *CreateEventFromString( panorama::IUIPanel *pPanel, const char *pchEventCreate, const char **pchEventEnd ) { return panorama::UIEvent::CreateEventFromString< name, param1, param2, param3, param4, param5 >( pPanel, pchEventCreate, pchEventEnd ); } \
  565. }; \
  566. template< class T, class U > void RegisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  567. template< class T, class U > void UnregisterEventHandler( const name &t, T *pPanel, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pPanel, memberfunc ).GetAbstractDelegate() ); } \
  568. template< class T, class U > void RegisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  569. template< class T, class U > void UnregisterEventHandlerOnPanel( const name &t, panorama::IUIPanel *pPanel, T *pHandler, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->UnregisterEventHandler( t.GetEventType(), pPanel, UtlMakeDelegate( pHandler, memberfunc ).GetAbstractDelegate() ); } \
  570. template< class T, class U > void RegisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  571. template< class T, class U > void UnregisterForUnhandledEvent( const name &t, T *pObj, bool (U::*memberfunc)( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->UnregisterForUnhandledEvent( t.GetEventType(), UtlMakeDelegate( pObj, memberfunc ).GetAbstractDelegate() ); } \
  572. template< class PanelType > void RegisterEventHandlerOnPanelType( const name &t, bool( PanelType::*memberfunc )( const panorama::CPanelPtr< panorama::IUIPanel > &, param1, param2, param3, param4, param5 ) ) { panorama::UIEngine()->RegisterPanelTypeEventHandler( t.GetEventType(), PanelType::GetPanelSymbol(), UtlMakeDelegate( (PanelType*)NULL, memberfunc ).GetAbstractDelegate() ); }
  573. #define DEFINE_PANORAMA_EVENT( name ) \
  574. panorama::CPanoramaSymbol name::symbol; \
  575. const char *name::pchEvent = #name; \
  576. panorama::CAutoRegisterUIEvent< name, name::cParams > g_##name##_EventAutoRegister( #name );
  577. //-----------------------------------------------------------------------------
  578. // Purpose: Class to automatically register events at startup
  579. //-----------------------------------------------------------------------------
  580. void RegisterUIEvent( panorama::CPanoramaSymbol *pSymEvent, const char *pchEventType, int cParams, bool bPanelEvent,
  581. PFN_ParseUIEvent pfnParseUIEvent, PFN_MakeUIEvent0 pfnMakeUIEvent0, PFN_MakeUIEvent1Repeats pfnMakeUIEvent1Repeats, PFN_MakeUIEvent1Source pfnMakeUIEvent1Source );
  582. template < class T, int N >
  583. class CAutoRegisterUIEvent
  584. {
  585. public:
  586. CAutoRegisterUIEvent( const char *pch )
  587. {
  588. RegisterUIEvent( &T::symbol, T::pchEvent, T::cParams, T::bPanelEvent, T::CreateEventFromString, NULL, NULL, NULL );
  589. }
  590. };
  591. template < class T >
  592. class CAutoRegisterUIEvent<T, 0>
  593. {
  594. public:
  595. CAutoRegisterUIEvent( const char *pch )
  596. {
  597. RegisterUIEvent( &T::symbol, T::pchEvent, T::cParams, T::bPanelEvent, T::CreateEventFromString, T::MakeEvent, NULL, NULL );
  598. }
  599. };
  600. template < class T, typename TParam1 >
  601. class CAutoRegisterUIEventWithParam1
  602. {
  603. public:
  604. CAutoRegisterUIEventWithParam1( const char *pch )
  605. {
  606. RegisterUIEvent( &T::symbol, T::pchEvent, T::cParams, T::bPanelEvent, T::CreateEventFromString, NULL, NULL, NULL );
  607. }
  608. };
  609. template < class T >
  610. class CAutoRegisterUIEventWithParam1< T, panorama::EPanelEventSource_t >
  611. {
  612. public:
  613. CAutoRegisterUIEventWithParam1( const char *pch )
  614. {
  615. RegisterUIEvent( &T::symbol, T::pchEvent, T::cParams, T::bPanelEvent, T::CreateEventFromString, NULL, NULL, T::MakeEvent );
  616. }
  617. };
  618. template < class T >
  619. class CAutoRegisterUIEventWithParam1< T, int >
  620. {
  621. public:
  622. CAutoRegisterUIEventWithParam1( const char *pch )
  623. {
  624. RegisterUIEvent( &T::symbol, T::pchEvent, T::cParams, T::bPanelEvent, T::CreateEventFromString, NULL, T::MakeEvent, NULL );
  625. }
  626. };
  627. template < class T >
  628. class CAutoRegisterUIEvent<T, 1>
  629. {
  630. public:
  631. typedef typename T::TypenameParam1 TTypenameParam1;
  632. CAutoRegisterUIEventWithParam1< T, TTypenameParam1 > m_autoregister;
  633. CAutoRegisterUIEvent( const char *pch ) : m_autoregister( pch )
  634. {
  635. }
  636. };
  637. //-----------------------------------------------------------------------------
  638. // Purpose: Event interface
  639. //-----------------------------------------------------------------------------
  640. class IUIEvent
  641. {
  642. public:
  643. virtual ~IUIEvent() {}
  644. virtual const CPanelPtr< const IUIPanel > &GetTargetPanel() const = 0;
  645. virtual void SetTargetPanel( const IUIPanel *pTarget ) = 0;
  646. virtual panorama::CPanoramaSymbol GetEventType() const = 0;
  647. virtual bool CanBubble() const { return false; }
  648. virtual bool Dispatch( CUtlAbstractDelegate pFunc ) = 0;
  649. virtual IUIEvent *Copy() const = 0;
  650. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs ) = 0;
  651. #ifdef DBGFLAG_VALIDATE
  652. virtual void Validate( CValidator &validator, const tchar *pchName ) = 0;
  653. #endif
  654. };
  655. //-----------------------------------------------------------------------------
  656. // Purpose: Event base class
  657. //-----------------------------------------------------------------------------
  658. class CUIEventBase : public IUIEvent
  659. {
  660. public:
  661. CUIEventBase( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel )
  662. {
  663. m_symEvent = symEvent;
  664. m_pTargetPanel = pTargetPanel;
  665. }
  666. virtual const CPanelPtr< const IUIPanel > &GetTargetPanel() const
  667. {
  668. return m_pTargetPanel;
  669. }
  670. virtual void SetTargetPanel( const IUIPanel *pTarget )
  671. {
  672. m_pTargetPanel = pTarget;
  673. }
  674. virtual panorama::CPanoramaSymbol GetEventType() const
  675. {
  676. return m_symEvent;
  677. }
  678. private:
  679. panorama::CPanoramaSymbol m_symEvent;
  680. CPanelPtr< const IUIPanel > m_pTargetPanel;
  681. };
  682. //-----------------------------------------------------------------------------
  683. // Purpose: UI Event types
  684. //-----------------------------------------------------------------------------
  685. class CUIEvent0 : public CUIEventBase
  686. {
  687. public:
  688. CUIEvent0( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel ) : CUIEventBase( symEvent, pTargetPanel )
  689. {
  690. }
  691. virtual ~CUIEvent0()
  692. {
  693. }
  694. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  695. {
  696. CUtlDelegate< bool ( void ) > del;
  697. del.SetAbstractDelegate( pFunc );
  698. return del();
  699. }
  700. virtual IUIEvent *Copy() const
  701. {
  702. return new CUIEvent0( GetEventType(), GetTargetPanel().Get() );
  703. }
  704. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  705. {
  706. *pCount = 0;
  707. *pArgs = NULL;
  708. }
  709. #ifdef DBGFLAG_VALIDATE
  710. virtual void Validate( CValidator &validator, const tchar *pchName )
  711. {
  712. }
  713. #endif
  714. };
  715. class CUIPanelEvent0 : public CUIEventBase
  716. {
  717. public:
  718. CUIPanelEvent0( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel ) : CUIEventBase( symEvent, pTargetPanel )
  719. {
  720. }
  721. virtual ~CUIPanelEvent0()
  722. {
  723. }
  724. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  725. {
  726. CUtlDelegate< bool( const CPanelPtr< const IUIPanel > & ) > del;
  727. del.SetAbstractDelegate( pFunc );
  728. return del( GetTargetPanel() );
  729. }
  730. virtual IUIEvent *Copy() const
  731. {
  732. return new CUIPanelEvent0( GetEventType(), GetTargetPanel().Get() );
  733. }
  734. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  735. {
  736. *pCount = 1;
  737. *pArgs = new v8::Handle< v8::Value >[1];
  738. *pArgs[0] = v8::String::NewFromUtf8( GetV8Isolate(), GetPanelID( GetTargetPanel().Get() ) );
  739. }
  740. #ifdef DBGFLAG_VALIDATE
  741. virtual void Validate( CValidator &validator, const tchar *pchName )
  742. {
  743. }
  744. #endif
  745. };
  746. template < typename PARAM1_TYPE >
  747. class CUIEvent1 : public CUIEventBase
  748. {
  749. public:
  750. CUIEvent1( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1 ) : CUIEventBase( symEvent, pTargetPanel )
  751. {
  752. UIEventSet( &m_param1, param1 );
  753. }
  754. virtual ~CUIEvent1()
  755. {
  756. UIEventFree( m_param1 );
  757. }
  758. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  759. {
  760. CUtlDelegate< bool ( PARAM1_TYPE ) > del;
  761. del.SetAbstractDelegate( pFunc );
  762. return del( m_param1 );
  763. }
  764. virtual IUIEvent *Copy() const
  765. {
  766. return new CUIEvent1( GetEventType(), GetTargetPanel().Get(), m_param1 );
  767. }
  768. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  769. {
  770. *pCount = 1;
  771. *pArgs = new v8::Handle< v8::Value>[1];
  772. PanoramaTypeToV8Param( m_param1, *pArgs );
  773. }
  774. #ifdef DBGFLAG_VALIDATE
  775. virtual void Validate( CValidator &validator, const tchar *pchName )
  776. {
  777. UIEventValidate( validator, m_param1 );
  778. }
  779. #endif
  780. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  781. private:
  782. PARAM1_TYPE m_param1;
  783. };
  784. template < typename PARAM1_TYPE >
  785. class CUIPanelEvent1 : public CUIEventBase
  786. {
  787. public:
  788. CUIPanelEvent1( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1 ) : CUIEventBase( symEvent, pTargetPanel )
  789. {
  790. UIEventSet( &m_param1, param1 );
  791. }
  792. virtual ~CUIPanelEvent1()
  793. {
  794. UIEventFree( m_param1 );
  795. }
  796. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  797. {
  798. CUtlDelegate< bool( const CPanelPtr< const IUIPanel > &, PARAM1_TYPE ) > del;
  799. del.SetAbstractDelegate( pFunc );
  800. return del( GetTargetPanel(), m_param1 );
  801. }
  802. virtual IUIEvent *Copy() const
  803. {
  804. return new CUIPanelEvent1( GetEventType(), GetTargetPanel().Get(), m_param1 );
  805. }
  806. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  807. {
  808. *pCount = 2;
  809. *pArgs = new v8::Handle< v8::Value >[2];
  810. *pArgs[0] = v8::String::NewFromUtf8( GetV8Isolate(), GetPanelID( GetTargetPanel().Get() ) );
  811. PanoramaTypeToV8Param( m_param1, *pArgs+1 );
  812. }
  813. #ifdef DBGFLAG_VALIDATE
  814. virtual void Validate( CValidator &validator, const tchar *pchName )
  815. {
  816. UIEventValidate( validator, m_param1 );
  817. }
  818. #endif
  819. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  820. private:
  821. PARAM1_TYPE m_param1;
  822. };
  823. template < typename PARAM1_TYPE, typename PARAM2_TYPE >
  824. class CUIPanelEvent2 : public CUIEventBase
  825. {
  826. public:
  827. CUIPanelEvent2( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2 ) : CUIEventBase( symEvent, pTargetPanel )
  828. {
  829. UIEventSet( &m_param1, param1 );
  830. UIEventSet( &m_param2, param2 );
  831. }
  832. virtual ~CUIPanelEvent2()
  833. {
  834. UIEventFree( m_param1 );
  835. UIEventFree( m_param2 );
  836. }
  837. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  838. {
  839. CUtlDelegate< bool( const CPanelPtr< const IUIPanel > &, PARAM1_TYPE, PARAM2_TYPE ) > del;
  840. del.SetAbstractDelegate( pFunc );
  841. return del( GetTargetPanel(), m_param1, m_param2 );
  842. }
  843. virtual IUIEvent *Copy() const
  844. {
  845. return new CUIPanelEvent2( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2 );
  846. }
  847. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  848. {
  849. *pCount = 3;
  850. *pArgs = new v8::Handle< v8::Value >[3];
  851. *pArgs[0] = v8::String::NewFromUtf8( GetV8Isolate(), GetPanelID( GetTargetPanel().Get() ) );
  852. PanoramaTypeToV8Param( m_param1, *pArgs+1 );
  853. PanoramaTypeToV8Param( m_param2, *pArgs+2 );
  854. }
  855. #ifdef DBGFLAG_VALIDATE
  856. virtual void Validate( CValidator &validator, const tchar *pchName )
  857. {
  858. UIEventValidate( validator, m_param1 );
  859. UIEventValidate( validator, m_param2 );
  860. }
  861. #endif
  862. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  863. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  864. private:
  865. PARAM1_TYPE m_param1;
  866. PARAM2_TYPE m_param2;
  867. };
  868. template < typename PARAM1_TYPE, typename PARAM2_TYPE >
  869. class CUIEvent2 : public CUIEventBase
  870. {
  871. public:
  872. CUIEvent2( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2 ) : CUIEventBase( symEvent, pTargetPanel )
  873. {
  874. UIEventSet( &m_param1, param1 );
  875. UIEventSet( &m_param2, param2 );
  876. }
  877. virtual ~CUIEvent2()
  878. {
  879. UIEventFree( m_param1 );
  880. UIEventFree( m_param2 );
  881. }
  882. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  883. {
  884. CUtlDelegate< bool ( PARAM1_TYPE, PARAM2_TYPE ) > del;
  885. del.SetAbstractDelegate( pFunc );
  886. return del( m_param1, m_param2 );
  887. }
  888. virtual IUIEvent *Copy() const
  889. {
  890. return new CUIEvent2( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2 );
  891. }
  892. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  893. {
  894. *pCount = 2;
  895. *pArgs = new v8::Handle< v8::Value >[2];
  896. PanoramaTypeToV8Param( m_param1, *pArgs+0 );
  897. PanoramaTypeToV8Param( m_param2, *pArgs+1 );
  898. }
  899. #ifdef DBGFLAG_VALIDATE
  900. virtual void Validate( CValidator &validator, const tchar *pchName )
  901. {
  902. UIEventValidate( validator, m_param1 );
  903. UIEventValidate( validator, m_param2 );
  904. }
  905. #endif
  906. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  907. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  908. private:
  909. PARAM1_TYPE m_param1;
  910. PARAM2_TYPE m_param2;
  911. };
  912. template < typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  913. class CUIEvent3 : public CUIEventBase
  914. {
  915. public:
  916. CUIEvent3( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 ) : CUIEventBase( symEvent, pTargetPanel )
  917. {
  918. UIEventSet( &m_param1, param1 );
  919. UIEventSet( &m_param2, param2 );
  920. UIEventSet( &m_param3, param3 );
  921. }
  922. virtual ~CUIEvent3()
  923. {
  924. UIEventFree( m_param1 );
  925. UIEventFree( m_param2 );
  926. UIEventFree( m_param3 );
  927. }
  928. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  929. {
  930. CUtlDelegate< bool ( PARAM1_TYPE, PARAM2_TYPE, PARAM3_TYPE ) > del;
  931. del.SetAbstractDelegate( pFunc );
  932. return del( m_param1, m_param2, m_param3 );
  933. }
  934. virtual IUIEvent *Copy() const
  935. {
  936. return new CUIEvent3( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2, m_param3 );
  937. }
  938. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  939. {
  940. *pCount = 3;
  941. *pArgs = new v8::Handle< v8::Value >[3];
  942. PanoramaTypeToV8Param( m_param1, *pArgs+0 );
  943. PanoramaTypeToV8Param( m_param2, *pArgs+1 );
  944. PanoramaTypeToV8Param( m_param3, *pArgs+2 );
  945. }
  946. #ifdef DBGFLAG_VALIDATE
  947. virtual void Validate( CValidator &validator, const tchar *pchName )
  948. {
  949. UIEventValidate( validator, m_param1 );
  950. UIEventValidate( validator, m_param2 );
  951. UIEventValidate( validator, m_param3 );
  952. }
  953. #endif
  954. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  955. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  956. const PARAM3_TYPE &GetParam3() const { return m_param3; }
  957. private:
  958. PARAM1_TYPE m_param1;
  959. PARAM2_TYPE m_param2;
  960. PARAM3_TYPE m_param3;
  961. };
  962. template < typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  963. class CUIPanelEvent3 : public CUIEventBase
  964. {
  965. public:
  966. CUIPanelEvent3( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 ) : CUIEventBase( symEvent, pTargetPanel )
  967. {
  968. UIEventSet( &m_param1, param1 );
  969. UIEventSet( &m_param2, param2 );
  970. UIEventSet( &m_param3, param3 );
  971. }
  972. virtual ~CUIPanelEvent3()
  973. {
  974. UIEventFree( m_param1 );
  975. UIEventFree( m_param2 );
  976. UIEventFree( m_param3 );
  977. }
  978. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  979. {
  980. CUtlDelegate< bool( const CPanelPtr< const IUIPanel > &, PARAM1_TYPE, PARAM2_TYPE, PARAM3_TYPE ) > del;
  981. del.SetAbstractDelegate( pFunc );
  982. return del( GetTargetPanel(), m_param1, m_param2, m_param3 );
  983. }
  984. virtual IUIEvent *Copy() const
  985. {
  986. return new CUIPanelEvent3( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2, m_param3 );
  987. }
  988. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  989. {
  990. *pCount = 4;
  991. *pArgs = new v8::Handle< v8::Value >[4];
  992. *pArgs[0] = v8::String::NewFromUtf8( GetV8Isolate(), GetPanelID( GetTargetPanel().Get() ) );
  993. PanoramaTypeToV8Param( m_param1, *pArgs+1 );
  994. PanoramaTypeToV8Param( m_param2, *pArgs+2 );
  995. PanoramaTypeToV8Param( m_param3, *pArgs+3 );
  996. }
  997. #ifdef DBGFLAG_VALIDATE
  998. virtual void Validate( CValidator &validator, const tchar *pchName )
  999. {
  1000. UIEventValidate( validator, m_param1 );
  1001. UIEventValidate( validator, m_param2 );
  1002. UIEventValidate( validator, m_param3 );
  1003. }
  1004. #endif
  1005. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  1006. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  1007. const PARAM3_TYPE &GetParam3() const { return m_param3; }
  1008. private:
  1009. PARAM1_TYPE m_param1;
  1010. PARAM2_TYPE m_param2;
  1011. PARAM3_TYPE m_param3;
  1012. };
  1013. template < typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE >
  1014. class CUIEvent4 : public CUIEventBase
  1015. {
  1016. public:
  1017. CUIEvent4( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4 ) : CUIEventBase( symEvent, pTargetPanel )
  1018. {
  1019. UIEventSet( &m_param1, param1 );
  1020. UIEventSet( &m_param2, param2 );
  1021. UIEventSet( &m_param3, param3 );
  1022. UIEventSet( &m_param4, param4 );
  1023. }
  1024. virtual ~CUIEvent4()
  1025. {
  1026. UIEventFree( m_param1 );
  1027. UIEventFree( m_param2 );
  1028. UIEventFree( m_param3 );
  1029. UIEventFree( m_param4 );
  1030. }
  1031. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  1032. {
  1033. CUtlDelegate< bool ( PARAM1_TYPE, PARAM2_TYPE, PARAM3_TYPE, PARAM4_TYPE ) > del;
  1034. del.SetAbstractDelegate( pFunc );
  1035. return del( m_param1, m_param2, m_param3, m_param4 );
  1036. }
  1037. virtual IUIEvent *Copy() const
  1038. {
  1039. return new CUIEvent4( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2, m_param3, m_param4 );
  1040. }
  1041. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  1042. {
  1043. *pCount = 4;
  1044. *pArgs = new v8::Handle< v8::Value >[4];
  1045. PanoramaTypeToV8Param( m_param1, *pArgs+0 );
  1046. PanoramaTypeToV8Param( m_param2, *pArgs+1 );
  1047. PanoramaTypeToV8Param( m_param3, *pArgs+2 );
  1048. PanoramaTypeToV8Param( m_param4, *pArgs+3 );
  1049. }
  1050. #ifdef DBGFLAG_VALIDATE
  1051. virtual void Validate( CValidator &validator, const tchar *pchName )
  1052. {
  1053. UIEventValidate( validator, m_param1 );
  1054. UIEventValidate( validator, m_param2 );
  1055. UIEventValidate( validator, m_param3 );
  1056. UIEventValidate( validator, m_param4 );
  1057. }
  1058. #endif
  1059. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  1060. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  1061. const PARAM3_TYPE &GetParam3() const { return m_param3; }
  1062. const PARAM4_TYPE &GetParam4() const { return m_param4; }
  1063. private:
  1064. PARAM1_TYPE m_param1;
  1065. PARAM2_TYPE m_param2;
  1066. PARAM3_TYPE m_param3;
  1067. PARAM4_TYPE m_param4;
  1068. };
  1069. template < typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE >
  1070. class CUIPanelEvent4 : public CUIEventBase
  1071. {
  1072. public:
  1073. CUIPanelEvent4( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4 ) : CUIEventBase( symEvent, pTargetPanel )
  1074. {
  1075. UIEventSet( &m_param1, param1 );
  1076. UIEventSet( &m_param2, param2 );
  1077. UIEventSet( &m_param3, param3 );
  1078. UIEventSet( &m_param4, param4 );
  1079. }
  1080. virtual ~CUIPanelEvent4()
  1081. {
  1082. UIEventFree( m_param1 );
  1083. UIEventFree( m_param2 );
  1084. UIEventFree( m_param3 );
  1085. UIEventFree( m_param4 );
  1086. }
  1087. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  1088. {
  1089. CUtlDelegate< bool( const CPanelPtr< const IUIPanel > &, PARAM1_TYPE, PARAM2_TYPE, PARAM3_TYPE, PARAM4_TYPE ) > del;
  1090. del.SetAbstractDelegate( pFunc );
  1091. return del( GetTargetPanel(), m_param1, m_param2, m_param3, m_param4 );
  1092. }
  1093. virtual IUIEvent *Copy() const
  1094. {
  1095. return new CUIPanelEvent4( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2, m_param3, m_param4 );
  1096. }
  1097. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  1098. {
  1099. *pCount = 5;
  1100. *pArgs = new v8::Handle< v8::Value >[5];
  1101. *pArgs[0] = v8::String::NewFromUtf8( GetV8Isolate(), GetPanelID( GetTargetPanel().Get() ) );
  1102. PanoramaTypeToV8Param( m_param1, *pArgs+1 );
  1103. PanoramaTypeToV8Param( m_param2, *pArgs+2 );
  1104. PanoramaTypeToV8Param( m_param3, *pArgs+3 );
  1105. PanoramaTypeToV8Param( m_param4, *pArgs+4 );
  1106. }
  1107. #ifdef DBGFLAG_VALIDATE
  1108. virtual void Validate( CValidator &validator, const tchar *pchName )
  1109. {
  1110. UIEventValidate( validator, m_param1 );
  1111. UIEventValidate( validator, m_param2 );
  1112. UIEventValidate( validator, m_param3 );
  1113. UIEventValidate( validator, m_param4 );
  1114. }
  1115. #endif
  1116. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  1117. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  1118. const PARAM3_TYPE &GetParam3() const { return m_param3; }
  1119. const PARAM4_TYPE &GetParam4() const { return m_param4; }
  1120. private:
  1121. PARAM1_TYPE m_param1;
  1122. PARAM2_TYPE m_param2;
  1123. PARAM3_TYPE m_param3;
  1124. PARAM4_TYPE m_param4;
  1125. };
  1126. template < typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE, typename PARAM5_TYPE >
  1127. class CUIEvent5 : public CUIEventBase
  1128. {
  1129. public:
  1130. CUIEvent5( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4, PARAM5_TYPE param5 ) : CUIEventBase( symEvent, pTargetPanel )
  1131. {
  1132. UIEventSet( &m_param1, param1 );
  1133. UIEventSet( &m_param2, param2 );
  1134. UIEventSet( &m_param3, param3 );
  1135. UIEventSet( &m_param4, param4 );
  1136. UIEventSet( &m_param5, param5 );
  1137. }
  1138. virtual ~CUIEvent5()
  1139. {
  1140. UIEventFree( m_param1 );
  1141. UIEventFree( m_param2 );
  1142. UIEventFree( m_param3 );
  1143. UIEventFree( m_param4 );
  1144. UIEventFree( m_param5 );
  1145. }
  1146. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  1147. {
  1148. CUtlDelegate< bool ( PARAM1_TYPE, PARAM2_TYPE, PARAM3_TYPE, PARAM4_TYPE, PARAM5_TYPE ) > del;
  1149. del.SetAbstractDelegate( pFunc );
  1150. return del( m_param1, m_param2, m_param3, m_param4, m_param5 );
  1151. }
  1152. virtual IUIEvent *Copy() const
  1153. {
  1154. return new CUIEvent5( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2, m_param3, m_param4, m_param5 );
  1155. }
  1156. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  1157. {
  1158. *pCount = 5;
  1159. *pArgs = new v8::Handle< v8::Value >[5];
  1160. PanoramaTypeToV8Param( m_param1, *pArgs+0 );
  1161. PanoramaTypeToV8Param( m_param2, *pArgs+1 );
  1162. PanoramaTypeToV8Param( m_param3, *pArgs+2 );
  1163. PanoramaTypeToV8Param( m_param4, *pArgs+3 );
  1164. PanoramaTypeToV8Param( m_param5, *pArgs+4 );
  1165. }
  1166. #ifdef DBGFLAG_VALIDATE
  1167. virtual void Validate( CValidator &validator, const tchar *pchName )
  1168. {
  1169. UIEventValidate( validator, m_param1 );
  1170. UIEventValidate( validator, m_param2 );
  1171. UIEventValidate( validator, m_param3 );
  1172. UIEventValidate( validator, m_param4 );
  1173. UIEventValidate( validator, m_param5 );
  1174. }
  1175. #endif
  1176. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  1177. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  1178. const PARAM3_TYPE &GetParam3() const { return m_param3; }
  1179. const PARAM4_TYPE &GetParam4() const { return m_param4; }
  1180. const PARAM5_TYPE &GetParam5() const { return m_param5; }
  1181. private:
  1182. PARAM1_TYPE m_param1;
  1183. PARAM2_TYPE m_param2;
  1184. PARAM3_TYPE m_param3;
  1185. PARAM4_TYPE m_param4;
  1186. PARAM5_TYPE m_param5;
  1187. };
  1188. template < typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE, typename PARAM5_TYPE >
  1189. class CUIPanelEvent5 : public CUIEventBase
  1190. {
  1191. public:
  1192. CUIPanelEvent5( panorama::CPanoramaSymbol symEvent, const IUIPanel *pTargetPanel, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4, PARAM5_TYPE param5 ) : CUIEventBase( symEvent, pTargetPanel )
  1193. {
  1194. UIEventSet( &m_param1, param1 );
  1195. UIEventSet( &m_param2, param2 );
  1196. UIEventSet( &m_param3, param3 );
  1197. UIEventSet( &m_param4, param4 );
  1198. UIEventSet( &m_param5, param5 );
  1199. }
  1200. virtual ~CUIPanelEvent5()
  1201. {
  1202. UIEventFree( m_param1 );
  1203. UIEventFree( m_param2 );
  1204. UIEventFree( m_param3 );
  1205. UIEventFree( m_param4 );
  1206. UIEventFree( m_param5 );
  1207. }
  1208. virtual bool Dispatch( CUtlAbstractDelegate pFunc )
  1209. {
  1210. CUtlDelegate< bool( const CPanelPtr< const IUIPanel > &, PARAM1_TYPE, PARAM2_TYPE, PARAM3_TYPE, PARAM4_TYPE, PARAM5_TYPE ) > del;
  1211. del.SetAbstractDelegate( pFunc );
  1212. return del( GetTargetPanel(), m_param1, m_param2, m_param3, m_param4, m_param5 );
  1213. }
  1214. virtual IUIEvent *Copy() const
  1215. {
  1216. return new CUIPanelEvent5( GetEventType(), GetTargetPanel().Get(), m_param1, m_param2, m_param3, m_param4, m_param5 );
  1217. }
  1218. virtual void GetJavaScriptArgs( int *pCount, v8::Handle<v8::Value> **pArgs )
  1219. {
  1220. *pCount = 6;
  1221. *pArgs = new v8::Handle< v8::Value >[6];
  1222. *pArgs[0] = v8::String::NewFromUtf8( GetV8Isolate(), GetPanelID( GetTargetPanel().Get() ) );
  1223. PanoramaTypeToV8Param( m_param1, *pArgs+1 );
  1224. PanoramaTypeToV8Param( m_param2, *pArgs+2 );
  1225. PanoramaTypeToV8Param( m_param3, *pArgs+3 );
  1226. PanoramaTypeToV8Param( m_param4, *pArgs+4 );
  1227. PanoramaTypeToV8Param( m_param5, *pArgs+5 );
  1228. }
  1229. #ifdef DBGFLAG_VALIDATE
  1230. virtual void Validate( CValidator &validator, const tchar *pchName )
  1231. {
  1232. UIEventValidate( validator, m_param1 );
  1233. UIEventValidate( validator, m_param2 );
  1234. UIEventValidate( validator, m_param3 );
  1235. UIEventValidate( validator, m_param4 );
  1236. UIEventValidate( validator, m_param5 );
  1237. }
  1238. #endif
  1239. const PARAM1_TYPE &GetParam1() const { return m_param1; }
  1240. const PARAM2_TYPE &GetParam2() const { return m_param2; }
  1241. const PARAM3_TYPE &GetParam3() const { return m_param3; }
  1242. const PARAM4_TYPE &GetParam4() const { return m_param4; }
  1243. const PARAM5_TYPE &GetParam5() const { return m_param5; }
  1244. private:
  1245. PARAM1_TYPE m_param1;
  1246. PARAM2_TYPE m_param2;
  1247. PARAM3_TYPE m_param3;
  1248. PARAM4_TYPE m_param4;
  1249. PARAM5_TYPE m_param5;
  1250. };
  1251. //-----------------------------------------------------------------------------
  1252. // Purpose: Dispatch synchronous event helpers
  1253. //-----------------------------------------------------------------------------
  1254. #ifdef PANORAMA_EXPORTS
  1255. template < typename T >
  1256. bool DispatchEvent( T t, const IUIPanel *pTarget )
  1257. {
  1258. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1259. return false;
  1260. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL ) );
  1261. }
  1262. template < typename T, typename PARAM1_TYPE >
  1263. bool DispatchEvent( T t, const IUIPanel *pTarget, PARAM1_TYPE param1 )
  1264. {
  1265. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1266. return false;
  1267. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1 ) );
  1268. }
  1269. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE >
  1270. bool DispatchEvent( T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2 )
  1271. {
  1272. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1273. return false;
  1274. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2 ) );
  1275. }
  1276. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  1277. bool DispatchEvent( T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 )
  1278. {
  1279. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1280. return false;
  1281. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3 ) );
  1282. }
  1283. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE >
  1284. bool DispatchEvent( T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4 )
  1285. {
  1286. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1287. return false;
  1288. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3, param4 ) );
  1289. }
  1290. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE, typename PARAM5_TYPE >
  1291. bool DispatchEvent( T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4, PARAM5_TYPE param5 )
  1292. {
  1293. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1294. return false;
  1295. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3, param4, param5 ) );
  1296. }
  1297. #endif
  1298. //-----------------------------------------------------------------------------
  1299. // Purpose: Dispatch synchronous event helpers
  1300. //-----------------------------------------------------------------------------
  1301. template < typename T >
  1302. bool DispatchEvent( T t, const IUIPanelClient *pTarget )
  1303. {
  1304. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1305. return false;
  1306. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget ) );
  1307. }
  1308. template < typename T, typename PARAM1_TYPE >
  1309. bool DispatchEvent( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1 )
  1310. {
  1311. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1312. return false;
  1313. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget, param1 ) );
  1314. }
  1315. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE >
  1316. bool DispatchEvent( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2 )
  1317. {
  1318. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1319. return false;
  1320. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget, param1, param2 ) );
  1321. }
  1322. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  1323. bool DispatchEvent( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 )
  1324. {
  1325. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1326. return false;
  1327. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget, param1, param2, param3 ) );
  1328. }
  1329. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE >
  1330. bool DispatchEvent( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4 )
  1331. {
  1332. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1333. return false;
  1334. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget, param1, param2, param3, param4 ) );
  1335. }
  1336. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE, typename PARAM5_TYPE >
  1337. bool DispatchEvent( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4, PARAM5_TYPE param5 )
  1338. {
  1339. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1340. return false;
  1341. return UIEngine()->DispatchEvent( t.MakeEvent( pTarget, param1, param2, param3, param4, param5 ) );
  1342. }
  1343. #ifdef PANORAMA_EXPORTS
  1344. //-----------------------------------------------------------------------------
  1345. // Purpose: Dispatch asynchronous event helpers
  1346. //-----------------------------------------------------------------------------
  1347. template < typename T >
  1348. void DispatchEventAsync( T t, const IUIPanel *pTarget )
  1349. {
  1350. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1351. return;
  1352. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL ) );
  1353. }
  1354. template < typename T >
  1355. void DispatchEventAsync( float flDelay, T t, const IUIPanel *pTarget )
  1356. {
  1357. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1358. return;
  1359. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL ) );
  1360. }
  1361. template < typename T, typename PARAM1_TYPE >
  1362. void DispatchEventAsync( T t, const IUIPanel *pTarget, PARAM1_TYPE param1 )
  1363. {
  1364. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1365. return;
  1366. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1 ) );
  1367. }
  1368. template < typename T, typename PARAM1_TYPE >
  1369. void DispatchEventAsync( float flDelay, T t, const IUIPanel *pTarget, PARAM1_TYPE param1 )
  1370. {
  1371. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1372. return;
  1373. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1 ) );
  1374. }
  1375. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE >
  1376. void DispatchEventAsync( T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2 )
  1377. {
  1378. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1379. return;
  1380. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2 ) );
  1381. }
  1382. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  1383. void DispatchEventAsync( T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 )
  1384. {
  1385. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1386. return;
  1387. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3 ) );
  1388. }
  1389. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE >
  1390. void DispatchEventAsync( float flDelay, T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2 )
  1391. {
  1392. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1393. return;
  1394. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2 ) );
  1395. }
  1396. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  1397. void DispatchEventAsync( float flDelay, T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 )
  1398. {
  1399. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1400. return;
  1401. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3 ) );
  1402. }
  1403. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE >
  1404. void DispatchEventAsync( float flDelay, T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4 )
  1405. {
  1406. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1407. return;
  1408. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3, param4 ) );
  1409. }
  1410. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE, typename PARAM5_TYPE >
  1411. void DispatchEventAsync( float flDelay, T t, const IUIPanel *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4, PARAM5_TYPE param5 )
  1412. {
  1413. if ( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1414. return;
  1415. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ? pTarget->ClientPtr() : NULL, param1, param2, param3, param4, param5 ) );
  1416. }
  1417. #endif
  1418. template < typename T >
  1419. void DispatchEventAsync( T t, const IUIPanelClient *pTarget )
  1420. {
  1421. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1422. return;
  1423. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget ) );
  1424. }
  1425. template < typename T >
  1426. void DispatchEventAsync( float flDelay, T t, const IUIPanelClient *pTarget )
  1427. {
  1428. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1429. return;
  1430. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget ) );
  1431. }
  1432. template < typename T, typename PARAM1_TYPE >
  1433. void DispatchEventAsync( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1 )
  1434. {
  1435. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1436. return;
  1437. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget, param1 ) );
  1438. }
  1439. template < typename T, typename PARAM1_TYPE >
  1440. void DispatchEventAsync( float flDelay, T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1 )
  1441. {
  1442. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1443. return;
  1444. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget, param1 ) );
  1445. }
  1446. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE >
  1447. void DispatchEventAsync( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2 )
  1448. {
  1449. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1450. return;
  1451. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget, param1, param2 ) );
  1452. }
  1453. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  1454. void DispatchEventAsync( T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 )
  1455. {
  1456. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1457. return;
  1458. UIEngine()->DispatchEventAsync( 0.0f, t.MakeEvent( pTarget, param1, param2, param3 ) );
  1459. }
  1460. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE >
  1461. void DispatchEventAsync( float flDelay, T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2 )
  1462. {
  1463. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1464. return;
  1465. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget, param1, param2 ) );
  1466. }
  1467. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE >
  1468. void DispatchEventAsync( float flDelay, T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3 )
  1469. {
  1470. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1471. return;
  1472. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget, param1, param2, param3 ) );
  1473. }
  1474. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE >
  1475. void DispatchEventAsync( float flDelay, T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4 )
  1476. {
  1477. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1478. return;
  1479. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget, param1, param2, param3, param4 ) );
  1480. }
  1481. template < typename T, typename PARAM1_TYPE, typename PARAM2_TYPE, typename PARAM3_TYPE, typename PARAM4_TYPE, typename PARAM5_TYPE >
  1482. void DispatchEventAsync( float flDelay, T t, const IUIPanelClient *pTarget, PARAM1_TYPE param1, PARAM2_TYPE param2, PARAM3_TYPE param3, PARAM4_TYPE param4, PARAM5_TYPE param5 )
  1483. {
  1484. if( !UIEngine()->BAnyHandlerRegisteredForEvent( T::symbol ) )
  1485. return;
  1486. UIEngine()->DispatchEventAsync( flDelay, t.MakeEvent( pTarget, param1, param2, param3, param4, param5 ) );
  1487. }
  1488. /*
  1489. IUIEvent *CreateEventFromSymbol( panorama::CPanoramaSymbol symEvent, IUIPanel *pPanel );
  1490. template <typename PARAM1> IUIEvent *CreateEventFromSymbol( panorama::CPanoramaSymbol symEvent, IUIPanel *pPanel, PARAM1 p1 );
  1491. template <typename PARAM1, typename PARAM2> IUIEvent *CreateEventFromSymbol( panorama::CPanoramaSymbol symEvent, IUIPanel *pPanel, PARAM1 p1, PARAM2 p2 );
  1492. template <typename PARAM1, typename PARAM2, typename PARAM3> IUIEvent *CreateEventFromSymbol( panorama::CPanoramaSymbol symEvent, IUIPanel *pPanel, PARAM1 p1, PARAM2 p2, PARAM3 p3 );
  1493. */
  1494. } // namespace panorama
  1495. #endif // UIEVENT_H