xtihandler.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/xtihandler.h
  3. // Purpose: XTI handlers
  4. // Author: Stefan Csomor
  5. // Modified by: Francesco Montorsi
  6. // Created: 27/07/03
  7. // Copyright: (c) 1997 Julian Smart
  8. // (c) 2003 Stefan Csomor
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _XTIHANDLER_H_
  12. #define _XTIHANDLER_H_
  13. #include "wx/defs.h"
  14. #if wxUSE_EXTENDED_RTTI
  15. #include "wx/xti.h"
  16. // copied from event.h which cannot be included at this place
  17. class WXDLLIMPEXP_FWD_BASE wxEvent;
  18. #ifdef __VISUALC__
  19. #define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance
  20. #else
  21. #define wxMSVC_FWD_MULTIPLE_BASES
  22. #endif
  23. class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler;
  24. typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
  25. typedef wxEventFunction wxObjectEventFunction;
  26. // ----------------------------------------------------------------------------
  27. // Handler Info
  28. //
  29. // this describes an event sink
  30. // ----------------------------------------------------------------------------
  31. class WXDLLIMPEXP_BASE wxHandlerInfo
  32. {
  33. friend class WXDLLIMPEXP_BASE wxDynamicClassInfo;
  34. public:
  35. wxHandlerInfo(wxHandlerInfo* &iter,
  36. wxClassInfo* itsClass,
  37. const wxString& name,
  38. wxObjectEventFunction address,
  39. const wxClassInfo* eventClassInfo) :
  40. m_eventFunction(address),
  41. m_name(name),
  42. m_eventClassInfo(eventClassInfo),
  43. m_itsClass(itsClass)
  44. {
  45. Insert(iter);
  46. }
  47. ~wxHandlerInfo()
  48. { Remove(); }
  49. // return the name of this handler
  50. const wxString& GetName() const { return m_name; }
  51. // return the class info of the event
  52. const wxClassInfo *GetEventClassInfo() const { return m_eventClassInfo; }
  53. // get the handler function pointer
  54. wxObjectEventFunction GetEventFunction() const { return m_eventFunction; }
  55. // returns NULL if this is the last handler of this class
  56. wxHandlerInfo* GetNext() const { return m_next; }
  57. // return the class this property is declared in
  58. const wxClassInfo* GetDeclaringClass() const { return m_itsClass; }
  59. private:
  60. // inserts this handler at the end of the linked chain which begins
  61. // with "iter" handler.
  62. void Insert(wxHandlerInfo* &iter);
  63. // removes this handler from the linked chain of the m_itsClass handlers.
  64. void Remove();
  65. wxObjectEventFunction m_eventFunction;
  66. wxString m_name;
  67. const wxClassInfo* m_eventClassInfo;
  68. wxHandlerInfo* m_next;
  69. wxClassInfo* m_itsClass;
  70. };
  71. #define wxHANDLER(name,eventClassType) \
  72. static wxHandlerInfo _handlerInfo##name( first, class_t::GetClassInfoStatic(), \
  73. wxT(#name), (wxObjectEventFunction) (wxEventFunction) &name, \
  74. wxCLASSINFO( eventClassType ) );
  75. #define wxBEGIN_HANDLERS_TABLE(theClass) \
  76. wxHandlerInfo *theClass::GetHandlersStatic() \
  77. { \
  78. typedef theClass class_t; \
  79. static wxHandlerInfo* first = NULL;
  80. #define wxEND_HANDLERS_TABLE() \
  81. return first; }
  82. #define wxEMPTY_HANDLERS_TABLE(theClass) \
  83. wxBEGIN_HANDLERS_TABLE(theClass) \
  84. wxEND_HANDLERS_TABLE()
  85. #endif // wxUSE_EXTENDED_RTTI
  86. #endif // _XTIHANDLER_H_