Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / include / wx / xtihandler.h
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
12 #ifndef _XTIHANDLER_H_
13 #define _XTIHANDLER_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_EXTENDED_RTTI
18
19 #include "wx/xti.h"
20
21 // copied from event.h which cannot be included at this place
22
23 class WXDLLIMPEXP_FWD_BASE wxEvent;
24
25 #ifdef __VISUALC__
26 #define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance
27 #else
28 #define wxMSVC_FWD_MULTIPLE_BASES
29 #endif
30
31 class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler;
32 typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
33 typedef wxEventFunction wxObjectEventFunction;
34
35 // ----------------------------------------------------------------------------
36 // Handler Info
37 //
38 // this describes an event sink
39 // ----------------------------------------------------------------------------
40
41 class WXDLLIMPEXP_BASE wxHandlerInfo
42 {
43 friend class WXDLLIMPEXP_BASE wxDynamicClassInfo;
44
45 public:
46 wxHandlerInfo(wxHandlerInfo* &iter,
47 wxClassInfo* itsClass,
48 const wxString& name,
49 wxObjectEventFunction address,
50 const wxClassInfo* eventClassInfo) :
51 m_eventFunction(address),
52 m_name(name),
53 m_eventClassInfo(eventClassInfo),
54 m_itsClass(itsClass)
55 {
56 Insert(iter);
57 }
58
59 ~wxHandlerInfo()
60 { Remove(); }
61
62 // return the name of this handler
63 const wxString& GetName() const { return m_name; }
64
65 // return the class info of the event
66 const wxClassInfo *GetEventClassInfo() const { return m_eventClassInfo; }
67
68 // get the handler function pointer
69 wxObjectEventFunction GetEventFunction() const { return m_eventFunction; }
70
71 // returns NULL if this is the last handler of this class
72 wxHandlerInfo* GetNext() const { return m_next; }
73
74 // return the class this property is declared in
75 const wxClassInfo* GetDeclaringClass() const { return m_itsClass; }
76
77 private:
78
79 // inserts this handler at the end of the linked chain which begins
80 // with "iter" handler.
81 void Insert(wxHandlerInfo* &iter);
82
83 // removes this handler from the linked chain of the m_itsClass handlers.
84 void Remove();
85
86 wxObjectEventFunction m_eventFunction;
87 wxString m_name;
88 const wxClassInfo* m_eventClassInfo;
89 wxHandlerInfo* m_next;
90 wxClassInfo* m_itsClass;
91 };
92
93 #define wxHANDLER(name,eventClassType) \
94 static wxHandlerInfo _handlerInfo##name( first, class_t::GetClassInfoStatic(), \
95 wxT(#name), (wxObjectEventFunction) (wxEventFunction) &name, \
96 wxCLASSINFO( eventClassType ) );
97
98 #define wxBEGIN_HANDLERS_TABLE(theClass) \
99 wxHandlerInfo *theClass::GetHandlersStatic() \
100 { \
101 typedef theClass class_t; \
102 static wxHandlerInfo* first = NULL;
103
104 #define wxEND_HANDLERS_TABLE() \
105 return first; }
106
107 #define wxEMPTY_HANDLERS_TABLE(theClass) \
108 wxBEGIN_HANDLERS_TABLE(theClass) \
109 wxEND_HANDLERS_TABLE()
110
111 #endif // wxUSE_EXTENDED_RTTI
112 #endif // _XTIHANDLER_H_