]> git.saurik.com Git - wxWidgets.git/blame - include/wx/xtihandler.h
Move wxColourData and wxFontData into separate files.
[wxWidgets.git] / include / wx / xtihandler.h
CommitLineData
e1d3601a
PC
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// RCS-ID: $Id$
8// Copyright: (c) 1997 Julian Smart
9// (c) 2003 Stefan Csomor
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _XTIHANDLER_H_
14#define _XTIHANDLER_H_
15
16#include "wx/defs.h"
17
18#if wxUSE_EXTENDED_RTTI
19
20#include "wx/string.h"
21
22class WXDLLIMPEXP_BASE wxObject;
23class WXDLLIMPEXP_BASE wxClassInfo;
24class WXDLLIMPEXP_BASE wxDynamicClassInfo;
25class WXDLLIMPEXP_BASE wxHashTable;
26class WXDLLIMPEXP_BASE wxHashTable_Node;
27class WXDLLIMPEXP_BASE wxObjectRefData;
28class WXDLLIMPEXP_BASE wxEvent;
29class WXDLLIMPEXP_BASE wxEvtHandler;
30
31typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
32
33// ----------------------------------------------------------------------------
34// Handler Info
35//
36// this describes an event sink
37// ----------------------------------------------------------------------------
38
39class WXDLLIMPEXP_BASE wxHandlerInfo
40{
41 friend class WXDLLIMPEXP_BASE wxDynamicClassInfo;
42
43public:
44 wxHandlerInfo(wxHandlerInfo* &iter,
45 wxClassInfo* itsClass,
46 const wxString& name,
47 wxObjectEventFunction address,
48 const wxClassInfo* eventClassInfo) :
49 m_eventFunction(address),
50 m_name(name),
51 m_eventClassInfo(eventClassInfo),
52 m_itsClass(itsClass)
53 {
54 Insert(iter);
55 }
56
57 ~wxHandlerInfo()
58 { Remove(); }
59
60 // return the name of this handler
61 const wxString& GetName() const { return m_name; }
62
63 // return the class info of the event
64 const wxClassInfo *GetEventClassInfo() const { return m_eventClassInfo; }
65
66 // get the handler function pointer
67 wxObjectEventFunction GetEventFunction() const { return m_eventFunction; }
68
69 // returns NULL if this is the last handler of this class
70 wxHandlerInfo* GetNext() const { return m_next; }
71
72 // return the class this property is declared in
73 const wxClassInfo* GetDeclaringClass() const { return m_itsClass; }
74
75private:
76
77 // inserts this handler at the end of the linked chain which begins
78 // with "iter" handler.
79 void Insert(wxHandlerInfo* &iter);
80
81 // removes this handler from the linked chain of the m_itsClass handlers.
82 void Remove();
83
84 wxObjectEventFunction m_eventFunction;
85 wxString m_name;
86 const wxClassInfo* m_eventClassInfo;
87 wxHandlerInfo* m_next;
88 wxClassInfo* m_itsClass;
89};
90
91#define wxHANDLER(name,eventClassType) \
92 static wxHandlerInfo _handlerInfo##name( first, class_t::GetClassInfoStatic(), \
93 wxT(#name), (wxObjectEventFunction) (wxEventFunction) &name, \
94 CLASSINFO( eventClassType ) );
95
96#define wxBEGIN_HANDLERS_TABLE(theClass) \
97 wxHandlerInfo *theClass::GetHandlersStatic() \
98 { \
99 typedef theClass class_t; \
100 static wxHandlerInfo* first = NULL;
101
102#define wxEND_HANDLERS_TABLE() \
103 return first; }
104
105#define wxEMPTY_HANDLERS_TABLE(theClass) \
106 wxBEGIN_HANDLERS_TABLE(theClass) \
107 wxEND_HANDLERS_TABLE()
108
109#endif // wxUSE_EXTENDED_RTTI
110#endif // _XTIHANDLER_H_