]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
bd83cb56 | 2 | // Name: wx/event.h |
c801d85f KB |
3 | // Purpose: Event classes |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
204abcd4 PC |
12 | #ifndef _WX_EVENT_H_ |
13 | #define _WX_EVENT_H_ | |
c801d85f | 14 | |
c801d85f | 15 | #include "wx/defs.h" |
bde626ce | 16 | #include "wx/cpp.h" |
c801d85f | 17 | #include "wx/object.h" |
341050e2 | 18 | #include "wx/clntdata.h" |
e90c1d2a VZ |
19 | |
20 | #if wxUSE_GUI | |
21 | #include "wx/gdicmn.h" | |
43b5058d | 22 | #include "wx/cursor.h" |
0e097789 | 23 | #include "wx/mousestate.h" |
e90c1d2a | 24 | #endif |
42e69d6b | 25 | |
b5a98acd | 26 | #include "wx/dynarray.h" |
8ebec7dc | 27 | #include "wx/thread.h" |
2ef989c9 | 28 | #include "wx/tracker.h" |
700dcf1e | 29 | #include "wx/typeinfo.h" |
dae60aee | 30 | #include "wx/any.h" |
b5a98acd | 31 | |
890d70eb | 32 | #ifdef wxHAS_EVENT_BIND |
f3ff831f VZ |
33 | #include "wx/meta/convertible.h" |
34 | #endif | |
35 | ||
f0facad0 VZ |
36 | // Currently VC6 and VC7 are known to not be able to compile CallAfter() code, |
37 | // so disable it for them. | |
38 | #if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(8) | |
39 | #include "wx/meta/removeref.h" | |
cf222762 | 40 | |
8f6bb260 VZ |
41 | #define wxHAS_CALL_AFTER |
42 | #endif | |
43 | ||
e90c1d2a VZ |
44 | // ---------------------------------------------------------------------------- |
45 | // forward declarations | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
b5dbe15d | 48 | class WXDLLIMPEXP_FWD_BASE wxList; |
3c778901 | 49 | class WXDLLIMPEXP_FWD_BASE wxEvent; |
58cc1587 | 50 | class WXDLLIMPEXP_FWD_BASE wxEventFilter; |
e90c1d2a | 51 | #if wxUSE_GUI |
b5dbe15d VS |
52 | class WXDLLIMPEXP_FWD_CORE wxDC; |
53 | class WXDLLIMPEXP_FWD_CORE wxMenu; | |
54 | class WXDLLIMPEXP_FWD_CORE wxWindow; | |
55 | class WXDLLIMPEXP_FWD_CORE wxWindowBase; | |
e90c1d2a VZ |
56 | #endif // wxUSE_GUI |
57 | ||
d1a64f69 VZ |
58 | // We operate with pointer to members of wxEvtHandler (such functions are used |
59 | // as event handlers in the event tables or as arguments to Connect()) but by | |
60 | // default MSVC uses a restricted (but more efficient) representation of | |
61 | // pointers to members which can't deal with multiple base classes. To avoid | |
62 | // mysterious (as the compiler is not good enough to detect this and give a | |
63 | // sensible error message) errors in the user code as soon as it defines | |
64 | // classes inheriting from both wxEvtHandler (possibly indirectly, e.g. via | |
65 | // wxWindow) and something else (including our own wxTrackable but not limited | |
66 | // to it), we use the special MSVC keyword telling the compiler to use a more | |
67 | // general pointer to member representation for the classes inheriting from | |
68 | // wxEvtHandler. | |
69 | #ifdef __VISUALC__ | |
70 | #define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance | |
71 | #else | |
72 | #define wxMSVC_FWD_MULTIPLE_BASES | |
73 | #endif | |
74 | ||
75 | class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler; | |
cc6ceca7 | 76 | class wxEventConnectionRef; |
432968bf | 77 | |
e90c1d2a VZ |
78 | // ---------------------------------------------------------------------------- |
79 | // Event types | |
80 | // ---------------------------------------------------------------------------- | |
64693098 | 81 | |
cbee8f8d VZ |
82 | typedef int wxEventType; |
83 | ||
c4fa5aa7 VZ |
84 | #define wxEVT_ANY ((wxEventType)-1) |
85 | ||
3a818b15 | 86 | // this is used to make the event table entry type safe, so that for an event |
111d41b2 VZ |
87 | // handler only a function with proper parameter list can be given. See also |
88 | // the wxEVENT_HANDLER_CAST-macro. | |
5c33522f | 89 | #define wxStaticCastEvent(type, val) static_cast<type>(val) |
3a818b15 | 90 | |
a0e9a5df | 91 | #define wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ |
0fe243db | 92 | wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj) |
3c778901 | 93 | |
a0e9a5df | 94 | #define wxDECLARE_EVENT_TABLE_TERMINATOR() \ |
3c778901 | 95 | wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0) |
cbee8f8d | 96 | |
cbee8f8d | 97 | // generate a new unique event type |
bddd7a8d | 98 | extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); |
cbee8f8d | 99 | |
54a9471a VZ |
100 | // define macros to create new event types: |
101 | #ifdef wxHAS_EVENT_BIND | |
102 | // events are represented by an instance of wxEventTypeTag and the | |
103 | // corresponding type must be specified for type-safety checks | |
111d41b2 | 104 | |
54a9471a VZ |
105 | // define a new custom event type, can be used alone or after event |
106 | // declaration in the header using one of the macros below | |
3c778901 | 107 | #define wxDEFINE_EVENT( name, type ) \ |
54a9471a | 108 | const wxEventTypeTag< type > name( wxNewEventType() ) |
3c778901 | 109 | |
54a9471a VZ |
110 | // the general version allowing exporting the event type from DLL, used by |
111 | // wxWidgets itself | |
3c778901 | 112 | #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \ |
54a9471a | 113 | extern const expdecl wxEventTypeTag< type > name |
111d41b2 | 114 | |
54a9471a | 115 | // this is the version which will normally be used in the user code |
579e0559 | 116 | #define wxDECLARE_EVENT( name, type ) \ |
ff3fd98a | 117 | wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) |
3c778901 | 118 | |
111d41b2 | 119 | |
54a9471a VZ |
120 | // these macros are only used internally for backwards compatibility and |
121 | // allow to define an alias for an existing event type (this is used by | |
122 | // wxEVT_SPIN_XXX) | |
dca94103 | 123 | #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ |
9b11752c | 124 | const wxEventTypeTag< type > name( value ) |
3c778901 | 125 | |
dca94103 | 126 | #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ |
9b11752c | 127 | extern const expdecl wxEventTypeTag< type > name |
54a9471a VZ |
128 | #else // !wxHAS_EVENT_BIND |
129 | // the macros are the same ones as above but defined differently as we only | |
130 | // use the integer event type values to identify events in this case | |
3c778901 | 131 | |
54a9471a VZ |
132 | #define wxDEFINE_EVENT( name, type ) \ |
133 | const wxEventType name( wxNewEventType() ) | |
111d41b2 | 134 | |
54a9471a VZ |
135 | #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \ |
136 | extern const expdecl wxEventType name | |
579e0559 | 137 | #define wxDECLARE_EVENT( name, type ) \ |
ff3fd98a | 138 | wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) |
3c778901 | 139 | |
54a9471a VZ |
140 | #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ |
141 | const wxEventType name = value | |
142 | #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ | |
143 | extern const expdecl wxEventType name | |
144 | #endif // wxHAS_EVENT_BIND/!wxHAS_EVENT_BIND | |
3c778901 | 145 | |
5293e4b7 VZ |
146 | // Try to cast the given event handler to the correct handler type: |
147 | ||
148 | #define wxEVENT_HANDLER_CAST( functype, func ) \ | |
149 | ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func ) | |
150 | ||
3c778901 | 151 | |
890d70eb | 152 | #ifdef wxHAS_EVENT_BIND |
3c778901 | 153 | |
f3ff831f VZ |
154 | // The tag is a type associated to the event type (which is an integer itself, |
155 | // in spite of its name) value. It exists in order to be used as a template | |
156 | // parameter and provide a mapping between the event type values and their | |
157 | // corresponding wxEvent-derived classes. | |
158 | template <typename T> | |
159 | class wxEventTypeTag | |
3c778901 VZ |
160 | { |
161 | public: | |
f3ff831f VZ |
162 | // The class of wxEvent-derived class carried by the events of this type. |
163 | typedef T EventClass; | |
3c778901 | 164 | |
f3ff831f | 165 | wxEventTypeTag(wxEventType type) { m_type = type; } |
3c778901 | 166 | |
111d41b2 VZ |
167 | // Return a wxEventType reference for the initialization of the static |
168 | // event tables. See wxEventTableEntry::m_eventType for a more thorough | |
169 | // explanation. | |
3c778901 VZ |
170 | operator const wxEventType&() const { return m_type; } |
171 | ||
172 | private: | |
173 | wxEventType m_type; | |
174 | }; | |
175 | ||
890d70eb | 176 | #endif // wxHAS_EVENT_BIND |
3c778901 VZ |
177 | |
178 | // These are needed for the functor definitions | |
179 | typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); | |
180 | ||
181 | // We had some trouble (specifically with eVC for ARM WinCE build) with using | |
182 | // wxEventFunction in the past so we had introduced wxObjectEventFunction which | |
183 | // used to be a typedef for a member of wxObject and not wxEvtHandler to work | |
184 | // around this but as eVC is not really supported any longer we now only keep | |
185 | // this for backwards compatibility and, despite its name, this is a typedef | |
186 | // for wxEvtHandler member now -- but if we have the same problem with another | |
187 | // compiler we can restore its old definition for it. | |
188 | typedef wxEventFunction wxObjectEventFunction; | |
189 | ||
111d41b2 | 190 | // The event functor which is stored in the static and dynamic event tables: |
3c778901 VZ |
191 | class WXDLLIMPEXP_BASE wxEventFunctor |
192 | { | |
193 | public: | |
194 | virtual ~wxEventFunctor(); | |
195 | ||
111d41b2 | 196 | // Invoke the actual event handler: |
f3ff831f | 197 | virtual void operator()(wxEvtHandler *, wxEvent&) = 0; |
3c778901 | 198 | |
03f3617b | 199 | // this function tests whether this functor is matched, for the purpose of |
890d70eb VZ |
200 | // finding it in an event table in Unbind(), by the given functor: |
201 | virtual bool IsMatching(const wxEventFunctor& functor) const = 0; | |
3c778901 | 202 | |
890d70eb VZ |
203 | // If the functor holds an wxEvtHandler, then get access to it and track |
204 | // its lifetime with wxEventConnectionRef: | |
205 | virtual wxEvtHandler *GetEvtHandler() const | |
206 | { return NULL; } | |
207 | ||
208 | // This is only used to maintain backward compatibility in | |
209 | // wxAppConsoleBase::CallEventHandler and ensures that an overwritten | |
210 | // wxAppConsoleBase::HandleEvent is still called for functors which hold an | |
211 | // wxEventFunction: | |
212 | virtual wxEventFunction GetEvtMethod() const | |
213 | { return NULL; } | |
7db064f6 JS |
214 | |
215 | private: | |
216 | WX_DECLARE_ABSTRACT_TYPEINFO(wxEventFunctor) | |
3c778901 VZ |
217 | }; |
218 | ||
890d70eb | 219 | // A plain method functor for the untyped legacy event types: |
3c778901 VZ |
220 | class WXDLLIMPEXP_BASE wxObjectEventFunctor : public wxEventFunctor |
221 | { | |
222 | public: | |
223 | wxObjectEventFunctor(wxObjectEventFunction method, wxEvtHandler *handler) | |
890d70eb VZ |
224 | : m_handler( handler ), m_method( method ) |
225 | { } | |
226 | ||
8cb2c49f | 227 | virtual void operator()(wxEvtHandler *handler, wxEvent& event); |
3c778901 | 228 | |
890d70eb | 229 | virtual bool IsMatching(const wxEventFunctor& functor) const |
3c778901 | 230 | { |
7db064f6 | 231 | if ( wxTypeId(functor) == wxTypeId(*this) ) |
890d70eb VZ |
232 | { |
233 | const wxObjectEventFunctor &other = | |
234 | static_cast< const wxObjectEventFunctor & >( functor ); | |
3c778901 | 235 | |
1b4bff82 VZ |
236 | // FIXME-VC6: amazing but true: replacing "m_method == 0" here |
237 | // with "!m_method" makes VC6 crash with an ICE in DLL build (only!) | |
238 | // Also notice that using "NULL" instead of "0" results in warnings | |
239 | // about "using NULL in arithmetics" from arm-linux-androideabi-g++ | |
240 | // 4.4.3 used for wxAndroid build. | |
abb7d8a3 | 241 | |
1b4bff82 | 242 | return ( m_method == other.m_method || other.m_method == 0 ) && |
890d70eb VZ |
243 | ( m_handler == other.m_handler || other.m_handler == NULL ); |
244 | } | |
245 | else | |
246 | return false; | |
3c778901 VZ |
247 | } |
248 | ||
890d70eb VZ |
249 | virtual wxEvtHandler *GetEvtHandler() const |
250 | { return m_handler; } | |
251 | ||
252 | virtual wxEventFunction GetEvtMethod() const | |
253 | { return m_method; } | |
3c778901 VZ |
254 | |
255 | private: | |
256 | wxEvtHandler *m_handler; | |
abb7d8a3 | 257 | wxEventFunction m_method; |
3c778901 | 258 | |
7db064f6 JS |
259 | // Provide a dummy default ctor for type info purposes |
260 | wxObjectEventFunctor() { } | |
261 | ||
262 | WX_DECLARE_TYPEINFO_INLINE(wxObjectEventFunctor) | |
890d70eb | 263 | }; |
f3ff831f | 264 | |
e1614128 | 265 | // Create a functor for the legacy events: used by Connect() |
03f3617b | 266 | inline wxObjectEventFunctor * |
48def411 | 267 | wxNewEventFunctor(const wxEventType& WXUNUSED(evtType), |
03f3617b | 268 | wxObjectEventFunction method, |
e1614128 | 269 | wxEvtHandler *handler) |
03f3617b VZ |
270 | { |
271 | return new wxObjectEventFunctor(method, handler); | |
272 | } | |
273 | ||
a0e9a5df | 274 | // This version is used by wxDECLARE_EVENT_TABLE_ENTRY() |
e1614128 | 275 | inline wxObjectEventFunctor * |
ac26ed15 VZ |
276 | wxNewEventTableFunctor(const wxEventType& WXUNUSED(evtType), |
277 | wxObjectEventFunction method) | |
e1614128 VZ |
278 | { |
279 | return new wxObjectEventFunctor(method, NULL); | |
280 | } | |
281 | ||
03f3617b | 282 | inline wxObjectEventFunctor |
f3ff831f | 283 | wxMakeEventFunctor(const wxEventType& WXUNUSED(evtType), |
03f3617b VZ |
284 | wxObjectEventFunction method, |
285 | wxEvtHandler *handler) | |
286 | { | |
287 | return wxObjectEventFunctor(method, handler); | |
288 | } | |
289 | ||
890d70eb | 290 | #ifdef wxHAS_EVENT_BIND |
f3ff831f | 291 | |
f3ff831f VZ |
292 | namespace wxPrivate |
293 | { | |
294 | ||
a01ada05 VZ |
295 | // helper template defining nested "type" typedef as the event class |
296 | // corresponding to the given event type | |
297 | template <typename T> struct EventClassOf; | |
298 | ||
299 | // the typed events provide the information about the class of the events they | |
300 | // carry themselves: | |
301 | template <typename T> | |
302 | struct EventClassOf< wxEventTypeTag<T> > | |
303 | { | |
304 | typedef typename wxEventTypeTag<T>::EventClass type; | |
305 | }; | |
306 | ||
307 | // for the old untyped events we don't have information about the exact event | |
308 | // class carried by them | |
309 | template <> | |
310 | struct EventClassOf<wxEventType> | |
311 | { | |
312 | typedef wxEvent type; | |
313 | }; | |
314 | ||
315 | ||
316 | // helper class defining operations different for method functors using an | |
317 | // object of wxEvtHandler-derived class as handler and the others | |
f3ff831f VZ |
318 | template <typename T, typename A, bool> struct HandlerImpl; |
319 | ||
320 | // specialization for handlers deriving from wxEvtHandler | |
321 | template <typename T, typename A> | |
322 | struct HandlerImpl<T, A, true> | |
323 | { | |
324 | static bool IsEvtHandler() | |
325 | { return true; } | |
326 | static T *ConvertFromEvtHandler(wxEvtHandler *p) | |
327 | { return static_cast<T *>(p); } | |
328 | static wxEvtHandler *ConvertToEvtHandler(T *p) | |
329 | { return p; } | |
890d70eb | 330 | static wxEventFunction ConvertToEvtMethod(void (T::*f)(A&)) |
a01ada05 VZ |
331 | { return static_cast<wxEventFunction>( |
332 | reinterpret_cast<void (T::*)(wxEvent&)>(f)); } | |
3c778901 VZ |
333 | }; |
334 | ||
f3ff831f VZ |
335 | // specialization for handlers not deriving from wxEvtHandler |
336 | template <typename T, typename A> | |
337 | struct HandlerImpl<T, A, false> | |
338 | { | |
339 | static bool IsEvtHandler() | |
340 | { return false; } | |
341 | static T *ConvertFromEvtHandler(wxEvtHandler *) | |
342 | { return NULL; } | |
343 | static wxEvtHandler *ConvertToEvtHandler(T *) | |
344 | { return NULL; } | |
890d70eb | 345 | static wxEventFunction ConvertToEvtMethod(void (T::*)(A&)) |
f3ff831f VZ |
346 | { return NULL; } |
347 | }; | |
348 | ||
349 | } // namespace wxPrivate | |
3c778901 | 350 | |
f3ff831f VZ |
351 | // functor forwarding the event to a method of the given object |
352 | // | |
353 | // notice that the object class may be different from the class in which the | |
354 | // method is defined but it must be convertible to this class | |
a01ada05 VZ |
355 | // |
356 | // also, the type of the handler parameter doesn't need to be exactly the same | |
357 | // as EventTag::EventClass but it must be its base class -- this is explicitly | |
358 | // allowed to handle different events in the same handler taking wxEvent&, for | |
359 | // example | |
360 | template | |
4c802fdc | 361 | <typename EventTag, typename Class, typename EventArg, typename EventHandler> |
f3ff831f VZ |
362 | class wxEventFunctorMethod |
363 | : public wxEventFunctor, | |
364 | private wxPrivate::HandlerImpl | |
365 | < | |
366 | Class, | |
a01ada05 | 367 | EventArg, |
c4021a79 | 368 | wxConvertibleTo<Class, wxEvtHandler>::value != 0 |
f3ff831f | 369 | > |
3c778901 | 370 | { |
a01ada05 VZ |
371 | private: |
372 | static void CheckHandlerArgument(EventArg *) { } | |
373 | ||
3c778901 | 374 | public: |
a01ada05 VZ |
375 | // the event class associated with the given event tag |
376 | typedef typename wxPrivate::EventClassOf<EventTag>::type EventClass; | |
377 | ||
f3ff831f | 378 | |
4c802fdc | 379 | wxEventFunctorMethod(void (Class::*method)(EventArg&), EventHandler *handler) |
890d70eb | 380 | : m_handler( handler ), m_method( method ) |
3c778901 | 381 | { |
361ba943 | 382 | wxASSERT_MSG( handler || this->IsEvtHandler(), |
f3ff831f VZ |
383 | "handlers defined in non-wxEvtHandler-derived classes " |
384 | "must be connected with a valid sink object" ); | |
385 | ||
a01ada05 VZ |
386 | // if you get an error here it means that the signature of the handler |
387 | // you're trying to use is not compatible with (i.e. is not the same as | |
388 | // or a base class of) the real event class used for this event type | |
389 | CheckHandlerArgument(static_cast<EventClass *>(NULL)); | |
3c778901 VZ |
390 | } |
391 | ||
f3ff831f | 392 | virtual void operator()(wxEvtHandler *handler, wxEvent& event) |
3c778901 | 393 | { |
f3ff831f VZ |
394 | Class * realHandler = m_handler; |
395 | if ( !realHandler ) | |
3c778901 | 396 | { |
361ba943 | 397 | realHandler = this->ConvertFromEvtHandler(handler); |
3c778901 | 398 | |
f3ff831f VZ |
399 | // this is not supposed to happen but check for it nevertheless |
400 | wxCHECK_RET( realHandler, "invalid event handler" ); | |
3c778901 VZ |
401 | } |
402 | ||
a01ada05 VZ |
403 | // the real (run-time) type of event is EventClass and we checked in |
404 | // the ctor that EventClass can be converted to EventArg, so this cast | |
405 | // is always valid | |
f3ff831f | 406 | (realHandler->*m_method)(static_cast<EventArg&>(event)); |
3c778901 VZ |
407 | } |
408 | ||
890d70eb | 409 | virtual bool IsMatching(const wxEventFunctor& functor) const |
3c778901 | 410 | { |
7db064f6 | 411 | if ( wxTypeId(functor) != wxTypeId(*this) ) |
f3ff831f | 412 | return false; |
3c778901 | 413 | |
890d70eb VZ |
414 | typedef wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler> |
415 | ThisFunctor; | |
416 | ||
7db064f6 | 417 | // the cast is valid because wxTypeId()s matched above |
890d70eb VZ |
418 | const ThisFunctor& other = static_cast<const ThisFunctor &>(functor); |
419 | ||
420 | return (m_method == other.m_method || other.m_method == NULL) && | |
421 | (m_handler == other.m_handler || other.m_handler == NULL); | |
3c778901 VZ |
422 | } |
423 | ||
890d70eb VZ |
424 | virtual wxEvtHandler *GetEvtHandler() const |
425 | { return this->ConvertToEvtHandler(m_handler); } | |
426 | ||
427 | virtual wxEventFunction GetEvtMethod() const | |
428 | { return this->ConvertToEvtMethod(m_method); } | |
429 | ||
430 | private: | |
431 | EventHandler *m_handler; | |
432 | void (Class::*m_method)(EventArg&); | |
433 | ||
7db064f6 JS |
434 | // Provide a dummy default ctor for type info purposes |
435 | wxEventFunctorMethod() { } | |
436 | ||
437 | typedef wxEventFunctorMethod<EventTag, Class, | |
438 | EventArg, EventHandler> thisClass; | |
439 | WX_DECLARE_TYPEINFO_INLINE(thisClass) | |
890d70eb VZ |
440 | }; |
441 | ||
442 | ||
443 | // functor forwarding the event to function (function, static method) | |
444 | template <typename EventTag, typename EventArg> | |
445 | class wxEventFunctorFunction : public wxEventFunctor | |
446 | { | |
447 | private: | |
448 | static void CheckHandlerArgument(EventArg *) { } | |
449 | ||
450 | public: | |
451 | // the event class associated with the given event tag | |
452 | typedef typename wxPrivate::EventClassOf<EventTag>::type EventClass; | |
453 | ||
454 | wxEventFunctorFunction( void ( *handler )( EventArg & )) | |
455 | : m_handler( handler ) | |
3c778901 | 456 | { |
890d70eb VZ |
457 | // if you get an error here it means that the signature of the handler |
458 | // you're trying to use is not compatible with (i.e. is not the same as | |
459 | // or a base class of) the real event class used for this event type | |
460 | CheckHandlerArgument(static_cast<EventClass *>(NULL)); | |
3c778901 VZ |
461 | } |
462 | ||
890d70eb | 463 | virtual void operator()(wxEvtHandler *WXUNUSED(handler), wxEvent& event) |
3c778901 | 464 | { |
890d70eb VZ |
465 | // If you get an error here like "must use .* or ->* to call |
466 | // pointer-to-member function" then you probably tried to call | |
467 | // Bind/Unbind with a method pointer but without a handler pointer or | |
468 | // NULL as a handler e.g.: | |
469 | // Unbind( wxEVT_XXX, &EventHandler::method ); | |
470 | // or | |
471 | // Unbind( wxEVT_XXX, &EventHandler::method, NULL ) | |
472 | m_handler(static_cast<EventArg&>(event)); | |
f3ff831f VZ |
473 | } |
474 | ||
890d70eb | 475 | virtual bool IsMatching(const wxEventFunctor &functor) const |
f3ff831f | 476 | { |
7db064f6 | 477 | if ( wxTypeId(functor) != wxTypeId(*this) ) |
890d70eb VZ |
478 | return false; |
479 | ||
480 | typedef wxEventFunctorFunction<EventTag, EventArg> ThisFunctor; | |
481 | ||
482 | const ThisFunctor& other = static_cast<const ThisFunctor&>( functor ); | |
483 | ||
484 | return m_handler == other.m_handler; | |
3c778901 VZ |
485 | } |
486 | ||
487 | private: | |
890d70eb VZ |
488 | void (*m_handler)(EventArg&); |
489 | ||
7db064f6 JS |
490 | // Provide a dummy default ctor for type info purposes |
491 | wxEventFunctorFunction() { } | |
492 | ||
493 | typedef wxEventFunctorFunction<EventTag, EventArg> thisClass; | |
494 | WX_DECLARE_TYPEINFO_INLINE(thisClass) | |
3c778901 VZ |
495 | }; |
496 | ||
f3ff831f | 497 | |
890d70eb VZ |
498 | template <typename EventTag, typename Functor> |
499 | class wxEventFunctorFunctor : public wxEventFunctor | |
500 | { | |
501 | public: | |
502 | typedef typename EventTag::EventClass EventArg; | |
503 | ||
ca6911c3 | 504 | wxEventFunctorFunctor(const Functor& handler) |
890d70eb VZ |
505 | : m_handler(handler), m_handlerAddr(&handler) |
506 | { } | |
507 | ||
508 | virtual void operator()(wxEvtHandler *WXUNUSED(handler), wxEvent& event) | |
509 | { | |
510 | // If you get an error here like "must use '.*' or '->*' to call | |
511 | // pointer-to-member function" then you probably tried to call | |
512 | // Bind/Unbind with a method pointer but without a handler pointer or | |
513 | // NULL as a handler e.g.: | |
514 | // Unbind( wxEVT_XXX, &EventHandler::method ); | |
515 | // or | |
516 | // Unbind( wxEVT_XXX, &EventHandler::method, NULL ) | |
517 | m_handler(static_cast<EventArg&>(event)); | |
518 | } | |
519 | ||
520 | virtual bool IsMatching(const wxEventFunctor &functor) const | |
521 | { | |
7db064f6 | 522 | if ( wxTypeId(functor) != wxTypeId(*this) ) |
890d70eb VZ |
523 | return false; |
524 | ||
525 | typedef wxEventFunctorFunctor<EventTag, Functor> FunctorThis; | |
526 | ||
527 | const FunctorThis& other = static_cast<const FunctorThis&>(functor); | |
528 | ||
529 | // The only reliable/portable way to compare two functors is by | |
530 | // identity: | |
531 | return m_handlerAddr == other.m_handlerAddr; | |
532 | } | |
533 | ||
890d70eb VZ |
534 | private: |
535 | // Store a copy of the functor to prevent using/calling an already | |
536 | // destroyed instance: | |
537 | Functor m_handler; | |
538 | ||
539 | // Use the address of the original functor for comparison in IsMatching: | |
540 | const void *m_handlerAddr; | |
541 | ||
7db064f6 JS |
542 | // Provide a dummy default ctor for type info purposes |
543 | wxEventFunctorFunctor() { } | |
544 | ||
545 | typedef wxEventFunctorFunctor<EventTag, Functor> thisClass; | |
546 | WX_DECLARE_TYPEINFO_INLINE(thisClass) | |
890d70eb VZ |
547 | }; |
548 | ||
f3ff831f | 549 | // Create functors for the templatized events, either allocated on the heap for |
03ae811e | 550 | // wxNewXXX() variants (this is needed in wxEvtHandler::Bind<>() to store them |
c0f02dab | 551 | // in dynamic event table) or just by returning them as temporary objects (this |
03ae811e | 552 | // is enough for Unbind<>() and we avoid unnecessary heap allocation like this). |
3c778901 | 553 | |
3c778901 | 554 | |
890d70eb VZ |
555 | // Create functors wrapping functions: |
556 | template <typename EventTag, typename EventArg> | |
557 | inline wxEventFunctorFunction<EventTag, EventArg> * | |
558 | wxNewEventFunctor(const EventTag&, void (*func)(EventArg &)) | |
3c778901 | 559 | { |
890d70eb | 560 | return new wxEventFunctorFunction<EventTag, EventArg>(func); |
3c778901 VZ |
561 | } |
562 | ||
890d70eb VZ |
563 | template <typename EventTag, typename EventArg> |
564 | inline wxEventFunctorFunction<EventTag, EventArg> | |
565 | wxMakeEventFunctor(const EventTag&, void (*func)(EventArg &)) | |
566 | { | |
567 | return wxEventFunctorFunction<EventTag, EventArg>(func); | |
568 | } | |
569 | ||
570 | // Create functors wrapping other functors: | |
f3ff831f | 571 | template <typename EventTag, typename Functor> |
890d70eb | 572 | inline wxEventFunctorFunctor<EventTag, Functor> * |
ca6911c3 | 573 | wxNewEventFunctor(const EventTag&, const Functor &func) |
3c778901 | 574 | { |
890d70eb | 575 | return new wxEventFunctorFunctor<EventTag, Functor>(func); |
3c778901 VZ |
576 | } |
577 | ||
890d70eb VZ |
578 | template <typename EventTag, typename Functor> |
579 | inline wxEventFunctorFunctor<EventTag, Functor> | |
ca6911c3 | 580 | wxMakeEventFunctor(const EventTag&, const Functor &func) |
890d70eb VZ |
581 | { |
582 | return wxEventFunctorFunctor<EventTag, Functor>(func); | |
583 | } | |
3c778901 | 584 | |
890d70eb | 585 | // Create functors wrapping methods: |
f3ff831f | 586 | template |
4c802fdc VZ |
587 | <typename EventTag, typename Class, typename EventArg, typename EventHandler> |
588 | inline wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler> * | |
f3ff831f VZ |
589 | wxNewEventFunctor(const EventTag&, |
590 | void (Class::*method)(EventArg&), | |
4c802fdc | 591 | EventHandler *handler) |
3c778901 | 592 | { |
4c802fdc | 593 | return new wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>( |
a01ada05 | 594 | method, handler); |
3c778901 VZ |
595 | } |
596 | ||
f3ff831f | 597 | template |
4c802fdc VZ |
598 | <typename EventTag, typename Class, typename EventArg, typename EventHandler> |
599 | inline wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler> | |
f3ff831f VZ |
600 | wxMakeEventFunctor(const EventTag&, |
601 | void (Class::*method)(EventArg&), | |
4c802fdc | 602 | EventHandler *handler) |
3c778901 | 603 | { |
4c802fdc | 604 | return wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>( |
a01ada05 | 605 | method, handler); |
3c778901 VZ |
606 | } |
607 | ||
a0e9a5df | 608 | // Create an event functor for the event table via wxDECLARE_EVENT_TABLE_ENTRY: |
0fe243db VZ |
609 | // in this case we don't have the handler (as it's always the same as the |
610 | // object which generated the event) so we must use Class as its type | |
f3ff831f | 611 | template <typename EventTag, typename Class, typename EventArg> |
a01ada05 | 612 | inline wxEventFunctorMethod<EventTag, Class, EventArg, Class> * |
0fe243db | 613 | wxNewEventTableFunctor(const EventTag&, void (Class::*method)(EventArg&)) |
3c778901 | 614 | { |
a01ada05 VZ |
615 | return new wxEventFunctorMethod<EventTag, Class, EventArg, Class>( |
616 | method, NULL); | |
3c778901 VZ |
617 | } |
618 | ||
890d70eb | 619 | #endif // wxHAS_EVENT_BIND |
3c778901 | 620 | |
f3ff831f | 621 | |
c058cafa VZ |
622 | // many, but not all, standard event types |
623 | ||
624 | // some generic events | |
625 | extern WXDLLIMPEXP_BASE const wxEventType wxEVT_NULL; | |
626 | extern WXDLLIMPEXP_BASE const wxEventType wxEVT_FIRST; | |
627 | extern WXDLLIMPEXP_BASE const wxEventType wxEVT_USER_FIRST; | |
628 | ||
3c778901 | 629 | // Need events declared to do this |
c1b293bb VS |
630 | class WXDLLIMPEXP_FWD_BASE wxIdleEvent; |
631 | class WXDLLIMPEXP_FWD_BASE wxThreadEvent; | |
cf222762 | 632 | class WXDLLIMPEXP_FWD_BASE wxAsyncMethodCallEvent; |
3c778901 VZ |
633 | class WXDLLIMPEXP_FWD_CORE wxCommandEvent; |
634 | class WXDLLIMPEXP_FWD_CORE wxMouseEvent; | |
635 | class WXDLLIMPEXP_FWD_CORE wxFocusEvent; | |
636 | class WXDLLIMPEXP_FWD_CORE wxChildFocusEvent; | |
637 | class WXDLLIMPEXP_FWD_CORE wxKeyEvent; | |
638 | class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent; | |
639 | class WXDLLIMPEXP_FWD_CORE wxSetCursorEvent; | |
640 | class WXDLLIMPEXP_FWD_CORE wxScrollEvent; | |
dca94103 | 641 | class WXDLLIMPEXP_FWD_CORE wxSpinEvent; |
3c778901 VZ |
642 | class WXDLLIMPEXP_FWD_CORE wxScrollWinEvent; |
643 | class WXDLLIMPEXP_FWD_CORE wxSizeEvent; | |
644 | class WXDLLIMPEXP_FWD_CORE wxMoveEvent; | |
645 | class WXDLLIMPEXP_FWD_CORE wxCloseEvent; | |
646 | class WXDLLIMPEXP_FWD_CORE wxActivateEvent; | |
647 | class WXDLLIMPEXP_FWD_CORE wxWindowCreateEvent; | |
648 | class WXDLLIMPEXP_FWD_CORE wxWindowDestroyEvent; | |
649 | class WXDLLIMPEXP_FWD_CORE wxShowEvent; | |
650 | class WXDLLIMPEXP_FWD_CORE wxIconizeEvent; | |
651 | class WXDLLIMPEXP_FWD_CORE wxMaximizeEvent; | |
652 | class WXDLLIMPEXP_FWD_CORE wxMouseCaptureChangedEvent; | |
653 | class WXDLLIMPEXP_FWD_CORE wxMouseCaptureLostEvent; | |
654 | class WXDLLIMPEXP_FWD_CORE wxPaintEvent; | |
655 | class WXDLLIMPEXP_FWD_CORE wxEraseEvent; | |
656 | class WXDLLIMPEXP_FWD_CORE wxNcPaintEvent; | |
657 | class WXDLLIMPEXP_FWD_CORE wxMenuEvent; | |
658 | class WXDLLIMPEXP_FWD_CORE wxContextMenuEvent; | |
659 | class WXDLLIMPEXP_FWD_CORE wxSysColourChangedEvent; | |
660 | class WXDLLIMPEXP_FWD_CORE wxDisplayChangedEvent; | |
661 | class WXDLLIMPEXP_FWD_CORE wxQueryNewPaletteEvent; | |
662 | class WXDLLIMPEXP_FWD_CORE wxPaletteChangedEvent; | |
663 | class WXDLLIMPEXP_FWD_CORE wxJoystickEvent; | |
664 | class WXDLLIMPEXP_FWD_CORE wxDropFilesEvent; | |
665 | class WXDLLIMPEXP_FWD_CORE wxInitDialogEvent; | |
3c778901 VZ |
666 | class WXDLLIMPEXP_FWD_CORE wxUpdateUIEvent; |
667 | class WXDLLIMPEXP_FWD_CORE wxClipboardTextEvent; | |
668 | class WXDLLIMPEXP_FWD_CORE wxHelpEvent; | |
669 | ||
670 | ||
c058cafa | 671 | // Command events |
ce7fe42e VZ |
672 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_BUTTON, wxCommandEvent); |
673 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHECKBOX, wxCommandEvent); | |
674 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHOICE, wxCommandEvent); | |
675 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LISTBOX, wxCommandEvent); | |
676 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LISTBOX_DCLICK, wxCommandEvent); | |
677 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHECKLISTBOX, wxCommandEvent); | |
678 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU, wxCommandEvent); | |
679 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SLIDER, wxCommandEvent); | |
680 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RADIOBOX, wxCommandEvent); | |
681 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RADIOBUTTON, wxCommandEvent); | |
682 | ||
683 | // wxEVT_SCROLLBAR is deprecated, use wxEVT_SCROLL... events | |
684 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLBAR, wxCommandEvent); | |
685 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_VLBOX, wxCommandEvent); | |
686 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX, wxCommandEvent); | |
687 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_RCLICKED, wxCommandEvent); | |
688 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_DROPDOWN, wxCommandEvent); | |
689 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_ENTER, wxCommandEvent); | |
690 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_DROPDOWN, wxCommandEvent); | |
691 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent); | |
c058cafa | 692 | |
cf222762 | 693 | // Thread and asynchronous method call events |
c1b293bb | 694 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_THREAD, wxThreadEvent); |
cf222762 | 695 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_ASYNC_METHOD_CALL, wxAsyncMethodCallEvent); |
d48b06bd | 696 | |
c058cafa | 697 | // Mouse event types |
9b11752c VZ |
698 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DOWN, wxMouseEvent); |
699 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_UP, wxMouseEvent); | |
700 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DOWN, wxMouseEvent); | |
701 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_UP, wxMouseEvent); | |
702 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DOWN, wxMouseEvent); | |
703 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_UP, wxMouseEvent); | |
704 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOTION, wxMouseEvent); | |
705 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ENTER_WINDOW, wxMouseEvent); | |
706 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEAVE_WINDOW, wxMouseEvent); | |
707 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DCLICK, wxMouseEvent); | |
708 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DCLICK, wxMouseEvent); | |
709 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DCLICK, wxMouseEvent); | |
710 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_FOCUS, wxFocusEvent); | |
711 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KILL_FOCUS, wxFocusEvent); | |
712 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHILD_FOCUS, wxChildFocusEvent); | |
713 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSEWHEEL, wxMouseEvent); | |
714 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DOWN, wxMouseEvent); | |
715 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_UP, wxMouseEvent); | |
716 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent); | |
717 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent); | |
718 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent); | |
719 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent); | |
c058cafa VZ |
720 | |
721 | // Character input event type | |
9b11752c VZ |
722 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent); |
723 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR_HOOK, wxKeyEvent); | |
724 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent); | |
725 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_DOWN, wxKeyEvent); | |
726 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent); | |
5048c832 | 727 | #if wxUSE_HOTKEY |
9b11752c | 728 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent); |
5048c832 | 729 | #endif |
1afe4f9b VZ |
730 | // This is a private event used by wxMSW code only and subject to change or |
731 | // disappear in the future. Don't use. | |
732 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AFTER_CHAR, wxKeyEvent); | |
733 | ||
c058cafa | 734 | // Set cursor event |
9b11752c | 735 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent); |
c058cafa VZ |
736 | |
737 | // wxScrollBar and wxSlider event identifiers | |
9b11752c VZ |
738 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_TOP, wxScrollEvent); |
739 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_BOTTOM, wxScrollEvent); | |
740 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEUP, wxScrollEvent); | |
741 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEDOWN, wxScrollEvent); | |
742 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEUP, wxScrollEvent); | |
743 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEDOWN, wxScrollEvent); | |
744 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBTRACK, wxScrollEvent); | |
745 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBRELEASE, wxScrollEvent); | |
746 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent); | |
c058cafa | 747 | |
dca94103 VZ |
748 | // Due to a bug in older wx versions, wxSpinEvents were being sent with type of |
749 | // wxEVT_SCROLL_LINEUP, wxEVT_SCROLL_LINEDOWN and wxEVT_SCROLL_THUMBTRACK. But | |
750 | // with the type-safe events in place, these event types are associated with | |
751 | // wxScrollEvent. To allow handling of spin events, new event types have been | |
752 | // defined in spinbutt.h/spinnbuttcmn.cpp. To maintain backward compatibility | |
753 | // the spin event types are being initialized with the scroll event types. | |
754 | ||
755 | #if wxUSE_SPINBTN | |
756 | ||
9b11752c VZ |
757 | wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent ); |
758 | wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent ); | |
759 | wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent ); | |
dca94103 VZ |
760 | |
761 | #endif | |
762 | ||
c058cafa | 763 | // Scroll events from wxWindow |
9b11752c VZ |
764 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_TOP, wxScrollWinEvent); |
765 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEvent); | |
766 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEUP, wxScrollWinEvent); | |
767 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEvent); | |
768 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEvent); | |
769 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEvent); | |
770 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEvent); | |
771 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEvent); | |
c058cafa VZ |
772 | |
773 | // System events | |
9b11752c VZ |
774 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZE, wxSizeEvent); |
775 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE, wxMoveEvent); | |
776 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CLOSE_WINDOW, wxCloseEvent); | |
777 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_END_SESSION, wxCloseEvent); | |
778 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_END_SESSION, wxCloseEvent); | |
779 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE_APP, wxActivateEvent); | |
780 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE, wxActivateEvent); | |
781 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CREATE, wxWindowCreateEvent); | |
782 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DESTROY, wxWindowDestroyEvent); | |
783 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SHOW, wxShowEvent); | |
784 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ICONIZE, wxIconizeEvent); | |
785 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAXIMIZE, wxMaximizeEvent); | |
786 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEvent); | |
787 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEvent); | |
788 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PAINT, wxPaintEvent); | |
789 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ERASE_BACKGROUND, wxEraseEvent); | |
790 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NC_PAINT, wxNcPaintEvent); | |
791 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_OPEN, wxMenuEvent); | |
792 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_CLOSE, wxMenuEvent); | |
793 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_HIGHLIGHT, wxMenuEvent); | |
794 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CONTEXT_MENU, wxContextMenuEvent); | |
795 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEvent); | |
796 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DISPLAY_CHANGED, wxDisplayChangedEvent); | |
797 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEvent); | |
798 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PALETTE_CHANGED, wxPaletteChangedEvent); | |
799 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_DOWN, wxJoystickEvent); | |
800 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_UP, wxJoystickEvent); | |
801 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_MOVE, wxJoystickEvent); | |
802 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_ZMOVE, wxJoystickEvent); | |
803 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DROP_FILES, wxDropFilesEvent); | |
804 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_INIT_DIALOG, wxInitDialogEvent); | |
805 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_IDLE, wxIdleEvent); | |
806 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_UPDATE_UI, wxUpdateUIEvent); | |
807 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZING, wxSizeEvent); | |
808 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVING, wxMoveEvent); | |
809 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_START, wxMoveEvent); | |
810 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_END, wxMoveEvent); | |
811 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HIBERNATE, wxActivateEvent); | |
c058cafa VZ |
812 | |
813 | // Clipboard events | |
ce7fe42e VZ |
814 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_COPY, wxClipboardTextEvent); |
815 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_CUT, wxClipboardTextEvent); | |
816 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_PASTE, wxClipboardTextEvent); | |
c058cafa VZ |
817 | |
818 | // Generic command events | |
819 | // Note: a click is a higher-level event than button down/up | |
9b11752c VZ |
820 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_CLICK, wxCommandEvent); |
821 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_DCLICK, wxCommandEvent); | |
822 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEvent); | |
823 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_DCLICK, wxCommandEvent); | |
824 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SET_FOCUS, wxCommandEvent); | |
825 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_KILL_FOCUS, wxCommandEvent); | |
826 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_ENTER, wxCommandEvent); | |
c058cafa VZ |
827 | |
828 | // Help events | |
9b11752c VZ |
829 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HELP, wxHelpEvent); |
830 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent); | |
96f6c703 | 831 | |
cbee8f8d | 832 | // these 2 events are the same |
ce7fe42e | 833 | #define wxEVT_TOOL wxEVT_MENU |
96f6c703 | 834 | |
ad0bae85 | 835 | // ---------------------------------------------------------------------------- |
77d4384e | 836 | // Compatibility |
ad0bae85 VZ |
837 | // ---------------------------------------------------------------------------- |
838 | ||
839 | // this event is also used by wxComboBox and wxSpinCtrl which don't include | |
840 | // wx/textctrl.h in all ports [yet], so declare it here as well | |
841 | // | |
842 | // still, any new code using it should include wx/textctrl.h explicitly | |
ce7fe42e | 843 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT, wxCommandEvent); |
c801d85f | 844 | |
d48b06bd FM |
845 | |
846 | // ---------------------------------------------------------------------------- | |
847 | // wxEvent(-derived) classes | |
848 | // ---------------------------------------------------------------------------- | |
849 | ||
1648d51b VZ |
850 | // the predefined constants for the number of times we propagate event |
851 | // upwards window child-parent chain | |
d48b06bd | 852 | enum wxEventPropagation |
1648d51b VZ |
853 | { |
854 | // don't propagate it at all | |
855 | wxEVENT_PROPAGATE_NONE = 0, | |
856 | ||
857 | // propagate it until it is processed | |
858 | wxEVENT_PROPAGATE_MAX = INT_MAX | |
859 | }; | |
860 | ||
d48b06bd | 861 | // The different categories for a wxEvent; see wxEvent::GetEventCategory. |
dde19c21 | 862 | // NOTE: they are used as OR-combinable flags by wxEventLoopBase::YieldFor |
d48b06bd FM |
863 | enum wxEventCategory |
864 | { | |
865 | // this is the category for those events which are generated to update | |
866 | // the appearance of the GUI but which (usually) do not comport data | |
867 | // processing, i.e. which do not provide input or output data | |
868 | // (e.g. size events, scroll events, etc). | |
869 | // They are events NOT directly generated by the user's input devices. | |
870 | wxEVT_CATEGORY_UI = 1, | |
871 | ||
872 | // this category groups those events which are generated directly from the | |
873 | // user through input devices like mouse and keyboard and usually result in | |
874 | // data to be processed from the application. | |
875 | // (e.g. mouse clicks, key presses, etc) | |
876 | wxEVT_CATEGORY_USER_INPUT = 2, | |
877 | ||
878 | // this category is for wxSocketEvent | |
879 | wxEVT_CATEGORY_SOCKET = 4, | |
880 | ||
881 | // this category is for wxTimerEvent | |
882 | wxEVT_CATEGORY_TIMER = 8, | |
883 | ||
884 | // this category is for any event used to send notifications from the | |
885 | // secondary threads to the main one or in general for notifications among | |
886 | // different threads (which may or may not be user-generated) | |
887 | wxEVT_CATEGORY_THREAD = 16, | |
888 | ||
889 | ||
890 | // implementation only | |
891 | ||
dde19c21 | 892 | // used in the implementations of wxEventLoopBase::YieldFor |
d48b06bd FM |
893 | wxEVT_CATEGORY_UNKNOWN = 32, |
894 | ||
dde19c21 | 895 | // a special category used as an argument to wxEventLoopBase::YieldFor to indicate that |
d48b06bd FM |
896 | // Yield() should leave all wxEvents on the queue while emptying the native event queue |
897 | // (native events will be processed but the wxEvents they generate will be queued) | |
898 | wxEVT_CATEGORY_CLIPBOARD = 64, | |
899 | ||
900 | ||
901 | // shortcut masks | |
902 | ||
903 | // this category groups those events which are emitted in response to | |
904 | // events of the native toolkit and which typically are not-"delayable". | |
905 | wxEVT_CATEGORY_NATIVE_EVENTS = wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT, | |
906 | ||
dde19c21 | 907 | // used in wxEventLoopBase::YieldFor to specify all event categories should be processed: |
d48b06bd FM |
908 | wxEVT_CATEGORY_ALL = |
909 | wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_SOCKET| \ | |
6547c6ba FM |
910 | wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD|wxEVT_CATEGORY_UNKNOWN| \ |
911 | wxEVT_CATEGORY_CLIPBOARD | |
d48b06bd FM |
912 | }; |
913 | ||
c801d85f | 914 | /* |
77ffb593 | 915 | * wxWidgets events, covering all interesting things that might happen |
c801d85f KB |
916 | * (button clicking, resizing, setting text in widgets, etc.). |
917 | * | |
918 | * For each completely new event type, derive a new event class. | |
919 | * An event CLASS represents a C++ class defining a range of similar event TYPES; | |
920 | * examples are canvas events, panel item command events. | |
921 | * An event TYPE is a unique identifier for a particular system event, | |
922 | * such as a button press or a listbox deselection. | |
923 | * | |
924 | */ | |
925 | ||
bddd7a8d | 926 | class WXDLLIMPEXP_BASE wxEvent : public wxObject |
c801d85f | 927 | { |
c801d85f | 928 | public: |
d9e2e4c2 | 929 | wxEvent(int winid = 0, wxEventType commandType = wxEVT_NULL ); |
2b854a32 VZ |
930 | |
931 | void SetEventType(wxEventType typ) { m_eventType = typ; } | |
932 | wxEventType GetEventType() const { return m_eventType; } | |
d48b06bd | 933 | |
2b854a32 VZ |
934 | wxObject *GetEventObject() const { return m_eventObject; } |
935 | void SetEventObject(wxObject *obj) { m_eventObject = obj; } | |
d48b06bd | 936 | |
2b854a32 VZ |
937 | long GetTimestamp() const { return m_timeStamp; } |
938 | void SetTimestamp(long ts = 0) { m_timeStamp = ts; } | |
d48b06bd | 939 | |
2b854a32 VZ |
940 | int GetId() const { return m_id; } |
941 | void SetId(int Id) { m_id = Id; } | |
942 | ||
685d0d73 VZ |
943 | // Returns the user data optionally associated with the event handler when |
944 | // using Connect() or Bind(). | |
945 | wxObject *GetEventUserData() const { return m_callbackUserData; } | |
946 | ||
2b854a32 VZ |
947 | // Can instruct event processor that we wish to ignore this event |
948 | // (treat as if the event table entry had not been found): this must be done | |
949 | // to allow the event processing by the base classes (calling event.Skip() | |
a0d9c6cb WS |
950 | // is the analog of calling the base class version of a virtual function) |
951 | void Skip(bool skip = true) { m_skipped = skip; } | |
47b378bd | 952 | bool GetSkipped() const { return m_skipped; } |
c801d85f | 953 | |
29de6f40 | 954 | // This function is used to create a copy of the event polymorphically and |
acd15a3f VZ |
955 | // all derived classes must implement it because otherwise wxPostEvent() |
956 | // for them wouldn't work (it needs to do a copy of the event) | |
957 | virtual wxEvent *Clone() const = 0; | |
a737331d | 958 | |
dde19c21 | 959 | // this function is used to selectively process events in wxEventLoopBase::YieldFor |
d48b06bd FM |
960 | // NOTE: by default it returns wxEVT_CATEGORY_UI just because the major |
961 | // part of wxWidgets events belong to that category. | |
962 | virtual wxEventCategory GetEventCategory() const | |
963 | { return wxEVT_CATEGORY_UI; } | |
964 | ||
87b6002d | 965 | // Implementation only: this test is explicitly anti OO and this function |
1648d51b VZ |
966 | // exists only for optimization purposes. |
967 | bool IsCommandEvent() const { return m_isCommandEvent; } | |
968 | ||
969 | // Determine if this event should be propagating to the parent window. | |
970 | bool ShouldPropagate() const | |
971 | { return m_propagationLevel != wxEVENT_PROPAGATE_NONE; } | |
972 | ||
973 | // Stop an event from propagating to its parent window, returns the old | |
974 | // propagation level value | |
975 | int StopPropagation() | |
976 | { | |
977 | int propagationLevel = m_propagationLevel; | |
978 | m_propagationLevel = wxEVENT_PROPAGATE_NONE; | |
979 | return propagationLevel; | |
980 | } | |
981 | ||
982 | // Resume the event propagation by restoring the propagation level | |
983 | // (returned by StopPropagation()) | |
984 | void ResumePropagation(int propagationLevel) | |
985 | { | |
986 | m_propagationLevel = propagationLevel; | |
987 | } | |
988 | ||
5ac5e40e VZ |
989 | // This method is for internal use only and allows to get the object that |
990 | // is propagating this event upwards the window hierarchy, if any. | |
991 | wxEvtHandler* GetPropagatedFrom() const { return m_propagatedFrom; } | |
29de6f40 VZ |
992 | |
993 | // This is for internal use only and is only called by | |
994 | // wxEvtHandler::ProcessEvent() to check whether it's the first time this | |
995 | // event is being processed | |
996 | bool WasProcessed() | |
997 | { | |
998 | if ( m_wasProcessed ) | |
999 | return true; | |
1000 | ||
1001 | m_wasProcessed = true; | |
1002 | ||
1003 | return false; | |
1004 | } | |
1005 | ||
3bad8c39 VZ |
1006 | // This is for internal use only and is used for setting, testing and |
1007 | // resetting of m_willBeProcessedAgain flag. | |
1008 | void SetWillBeProcessedAgain() | |
1009 | { | |
1010 | m_willBeProcessedAgain = true; | |
1011 | } | |
1012 | ||
1013 | bool WillBeProcessedAgain() | |
1014 | { | |
1015 | if ( m_willBeProcessedAgain ) | |
1016 | { | |
1017 | m_willBeProcessedAgain = false; | |
1018 | return true; | |
1019 | } | |
1020 | ||
1021 | return false; | |
1022 | } | |
1023 | ||
3cbb9df8 VZ |
1024 | // This is also used only internally by ProcessEvent() to check if it |
1025 | // should process the event normally or only restrict the search for the | |
1026 | // event handler to this object itself. | |
bbdee10d VZ |
1027 | bool ShouldProcessOnlyIn(wxEvtHandler *h) const |
1028 | { | |
1029 | return h == m_handlerToProcessOnlyIn; | |
1030 | } | |
1031 | ||
1032 | // Called to indicate that the result of ShouldProcessOnlyIn() wasn't taken | |
1033 | // into account. The existence of this function may seem counterintuitive | |
1034 | // but unfortunately it's needed by wxScrollHelperEvtHandler, see comments | |
1035 | // there. Don't even think of using this in your own code, this is a gross | |
1036 | // hack and is only needed because of wx complicated history and should | |
1037 | // never be used anywhere else. | |
1038 | void DidntHonourProcessOnlyIn() | |
1039 | { | |
1040 | m_handlerToProcessOnlyIn = NULL; | |
1041 | } | |
3cbb9df8 | 1042 | |
b4b76d61 | 1043 | protected: |
2b854a32 | 1044 | wxObject* m_eventObject; |
2b854a32 VZ |
1045 | wxEventType m_eventType; |
1046 | long m_timeStamp; | |
1047 | int m_id; | |
b4b76d61 KH |
1048 | |
1049 | public: | |
1050 | // m_callbackUserData is for internal usage only | |
2b854a32 | 1051 | wxObject* m_callbackUserData; |
1648d51b | 1052 | |
bbdee10d VZ |
1053 | private: |
1054 | // If this handler | |
1055 | wxEvtHandler *m_handlerToProcessOnlyIn; | |
1056 | ||
1648d51b VZ |
1057 | protected: |
1058 | // the propagation level: while it is positive, we propagate the event to | |
1059 | // the parent window (if any) | |
1648d51b VZ |
1060 | int m_propagationLevel; |
1061 | ||
5ac5e40e VZ |
1062 | // The object that the event is being propagated from, initially NULL and |
1063 | // only set by wxPropagateOnce. | |
1064 | wxEvtHandler* m_propagatedFrom; | |
1065 | ||
42e69d6b | 1066 | bool m_skipped; |
193bf013 | 1067 | bool m_isCommandEvent; |
1c624631 | 1068 | |
29de6f40 VZ |
1069 | // initially false but becomes true as soon as WasProcessed() is called for |
1070 | // the first time, as this is done only by ProcessEvent() it explains the | |
1071 | // variable name: it becomes true after ProcessEvent() was called at least | |
1072 | // once for this event | |
1073 | bool m_wasProcessed; | |
1074 | ||
3bad8c39 VZ |
1075 | // This one is initially false too, but can be set to true to indicate that |
1076 | // the event will be passed to another handler if it's not processed in | |
1077 | // this one. | |
1078 | bool m_willBeProcessedAgain; | |
1079 | ||
0e097789 VZ |
1080 | protected: |
1081 | wxEvent(const wxEvent&); // for implementing Clone() | |
1082 | wxEvent& operator=(const wxEvent&); // for derived classes operator=() | |
1083 | ||
8e72b8b5 | 1084 | private: |
5ac5e40e | 1085 | // It needs to access our m_propagationLevel and m_propagatedFrom fields. |
b5dbe15d | 1086 | friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce; |
1648d51b | 1087 | |
bbdee10d VZ |
1088 | // and this one needs to access our m_handlerToProcessOnlyIn |
1089 | friend class WXDLLIMPEXP_FWD_BASE wxEventProcessInHandlerOnly; | |
3cbb9df8 VZ |
1090 | |
1091 | ||
8e72b8b5 | 1092 | DECLARE_ABSTRACT_CLASS(wxEvent) |
c801d85f KB |
1093 | }; |
1094 | ||
1648d51b VZ |
1095 | /* |
1096 | * Helper class to temporarily change an event not to propagate. | |
1097 | */ | |
1098 | class WXDLLIMPEXP_BASE wxPropagationDisabler | |
1099 | { | |
1100 | public: | |
1101 | wxPropagationDisabler(wxEvent& event) : m_event(event) | |
1102 | { | |
1103 | m_propagationLevelOld = m_event.StopPropagation(); | |
1104 | } | |
1105 | ||
1106 | ~wxPropagationDisabler() | |
1107 | { | |
1108 | m_event.ResumePropagation(m_propagationLevelOld); | |
1109 | } | |
1110 | ||
1111 | private: | |
1112 | wxEvent& m_event; | |
1113 | int m_propagationLevelOld; | |
fc7a2a60 | 1114 | |
c0c133e1 | 1115 | wxDECLARE_NO_COPY_CLASS(wxPropagationDisabler); |
1648d51b VZ |
1116 | }; |
1117 | ||
1118 | /* | |
5ac5e40e VZ |
1119 | * Helper used to indicate that an event is propagated upwards the window |
1120 | * hierarchy by the given window. | |
1648d51b VZ |
1121 | */ |
1122 | class WXDLLIMPEXP_BASE wxPropagateOnce | |
1123 | { | |
1124 | public: | |
5ac5e40e VZ |
1125 | // The handler argument should normally be non-NULL to allow the parent |
1126 | // event handler to know that it's being used to process an event coming | |
1127 | // from the child, it's only NULL by default for backwards compatibility. | |
1128 | wxPropagateOnce(wxEvent& event, wxEvtHandler* handler = NULL) | |
1129 | : m_event(event), | |
1130 | m_propagatedFromOld(event.m_propagatedFrom) | |
1648d51b VZ |
1131 | { |
1132 | wxASSERT_MSG( m_event.m_propagationLevel > 0, | |
9a83f860 | 1133 | wxT("shouldn't be used unless ShouldPropagate()!") ); |
1648d51b VZ |
1134 | |
1135 | m_event.m_propagationLevel--; | |
5ac5e40e | 1136 | m_event.m_propagatedFrom = handler; |
1648d51b VZ |
1137 | } |
1138 | ||
1139 | ~wxPropagateOnce() | |
1140 | { | |
5ac5e40e | 1141 | m_event.m_propagatedFrom = m_propagatedFromOld; |
1648d51b VZ |
1142 | m_event.m_propagationLevel++; |
1143 | } | |
1144 | ||
1145 | private: | |
1146 | wxEvent& m_event; | |
5ac5e40e | 1147 | wxEvtHandler* const m_propagatedFromOld; |
fc7a2a60 | 1148 | |
c0c133e1 | 1149 | wxDECLARE_NO_COPY_CLASS(wxPropagateOnce); |
1648d51b VZ |
1150 | }; |
1151 | ||
bbdee10d VZ |
1152 | // A helper object used to temporarily make wxEvent::ShouldProcessOnlyIn() |
1153 | // return true for the handler passed to its ctor. | |
1154 | class wxEventProcessInHandlerOnly | |
3cbb9df8 VZ |
1155 | { |
1156 | public: | |
bbdee10d VZ |
1157 | wxEventProcessInHandlerOnly(wxEvent& event, wxEvtHandler *handler) |
1158 | : m_event(event), | |
1159 | m_handlerToProcessOnlyInOld(event.m_handlerToProcessOnlyIn) | |
3cbb9df8 | 1160 | { |
bbdee10d | 1161 | m_event.m_handlerToProcessOnlyIn = handler; |
3cbb9df8 VZ |
1162 | } |
1163 | ||
bbdee10d | 1164 | ~wxEventProcessInHandlerOnly() |
3cbb9df8 | 1165 | { |
bbdee10d | 1166 | m_event.m_handlerToProcessOnlyIn = m_handlerToProcessOnlyInOld; |
3cbb9df8 VZ |
1167 | } |
1168 | ||
1169 | private: | |
1170 | wxEvent& m_event; | |
bbdee10d | 1171 | wxEvtHandler * const m_handlerToProcessOnlyInOld; |
3cbb9df8 | 1172 | |
bbdee10d | 1173 | wxDECLARE_NO_COPY_CLASS(wxEventProcessInHandlerOnly); |
3cbb9df8 | 1174 | }; |
c4fa5aa7 | 1175 | |
c1b293bb VS |
1176 | |
1177 | class WXDLLIMPEXP_BASE wxEventBasicPayloadMixin | |
1178 | { | |
1179 | public: | |
1180 | wxEventBasicPayloadMixin() | |
1181 | : m_commandInt(0), | |
1182 | m_extraLong(0) | |
1183 | { | |
1184 | } | |
1185 | ||
1186 | void SetString(const wxString& s) { m_cmdString = s; } | |
1187 | const wxString& GetString() const { return m_cmdString; } | |
1188 | ||
1189 | void SetInt(int i) { m_commandInt = i; } | |
1190 | int GetInt() const { return m_commandInt; } | |
1191 | ||
1192 | void SetExtraLong(long extraLong) { m_extraLong = extraLong; } | |
1193 | long GetExtraLong() const { return m_extraLong; } | |
1194 | ||
1195 | protected: | |
1196 | // Note: these variables have "cmd" or "command" in their name for backward compatibility: | |
1197 | // they used to be part of wxCommandEvent, not this mixin. | |
1198 | wxString m_cmdString; // String event argument | |
1199 | int m_commandInt; | |
1200 | long m_extraLong; // Additional information (e.g. select/deselect) | |
1201 | ||
1202 | wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin); | |
1203 | }; | |
1204 | ||
1205 | class WXDLLIMPEXP_BASE wxEventAnyPayloadMixin : public wxEventBasicPayloadMixin | |
1206 | { | |
1207 | public: | |
1208 | wxEventAnyPayloadMixin() : wxEventBasicPayloadMixin() {} | |
1209 | ||
1210 | #if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) | |
1211 | template<typename T> | |
1212 | void SetPayload(const T& payload) | |
1213 | { | |
1214 | m_payload = payload; | |
1215 | } | |
1216 | ||
1217 | template<typename T> | |
1218 | T GetPayload() const | |
1219 | { | |
1220 | return m_payload.As<T>(); | |
1221 | } | |
1222 | ||
1223 | protected: | |
1224 | wxAny m_payload; | |
1225 | #endif // wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) | |
1226 | ||
1227 | wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin); | |
1228 | }; | |
1229 | ||
1230 | ||
1231 | // Idle event | |
1232 | /* | |
1233 | wxEVT_IDLE | |
1234 | */ | |
1235 | ||
1236 | // Whether to always send idle events to windows, or | |
1237 | // to only send update events to those with the | |
1238 | // wxWS_EX_PROCESS_IDLE style. | |
1239 | ||
1240 | enum wxIdleMode | |
1241 | { | |
1242 | // Send idle events to all windows | |
1243 | wxIDLE_PROCESS_ALL, | |
1244 | ||
1245 | // Send idle events to windows that have | |
1246 | // the wxWS_EX_PROCESS_IDLE flag specified | |
1247 | wxIDLE_PROCESS_SPECIFIED | |
1248 | }; | |
1249 | ||
1250 | class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent | |
1251 | { | |
1252 | public: | |
1253 | wxIdleEvent() | |
1254 | : wxEvent(0, wxEVT_IDLE), | |
1255 | m_requestMore(false) | |
1256 | { } | |
1257 | wxIdleEvent(const wxIdleEvent& event) | |
1258 | : wxEvent(event), | |
1259 | m_requestMore(event.m_requestMore) | |
1260 | { } | |
1261 | ||
1262 | void RequestMore(bool needMore = true) { m_requestMore = needMore; } | |
1263 | bool MoreRequested() const { return m_requestMore; } | |
1264 | ||
1265 | virtual wxEvent *Clone() const { return new wxIdleEvent(*this); } | |
1266 | ||
1267 | // Specify how wxWidgets will send idle events: to | |
1268 | // all windows, or only to those which specify that they | |
1269 | // will process the events. | |
1270 | static void SetMode(wxIdleMode mode) { sm_idleMode = mode; } | |
1271 | ||
1272 | // Returns the idle event mode | |
1273 | static wxIdleMode GetMode() { return sm_idleMode; } | |
1274 | ||
1275 | protected: | |
1276 | bool m_requestMore; | |
1277 | static wxIdleMode sm_idleMode; | |
1278 | ||
1279 | private: | |
1280 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent) | |
1281 | }; | |
1282 | ||
1283 | ||
1284 | // Thread event | |
1285 | ||
1286 | class WXDLLIMPEXP_BASE wxThreadEvent : public wxEvent, | |
1287 | public wxEventAnyPayloadMixin | |
1288 | { | |
1289 | public: | |
1290 | wxThreadEvent(wxEventType eventType = wxEVT_THREAD, int id = wxID_ANY) | |
1291 | : wxEvent(id, eventType) | |
1292 | { } | |
1293 | ||
1294 | wxThreadEvent(const wxThreadEvent& event) | |
1295 | : wxEvent(event), | |
1296 | wxEventAnyPayloadMixin(event) | |
1297 | { | |
1298 | // make sure our string member (which uses COW, aka refcounting) is not | |
1299 | // shared by other wxString instances: | |
9bd5c5fc | 1300 | SetString(GetString().Clone()); |
c1b293bb VS |
1301 | } |
1302 | ||
1303 | virtual wxEvent *Clone() const | |
1304 | { | |
1305 | return new wxThreadEvent(*this); | |
1306 | } | |
1307 | ||
1308 | // this is important to avoid that calling wxEventLoopBase::YieldFor thread events | |
1309 | // gets processed when this is unwanted: | |
1310 | virtual wxEventCategory GetEventCategory() const | |
1311 | { return wxEVT_CATEGORY_THREAD; } | |
1312 | ||
1313 | private: | |
1314 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxThreadEvent) | |
1315 | }; | |
1316 | ||
1317 | ||
cf222762 VZ |
1318 | // Asynchronous method call events: these event are processed by wxEvtHandler |
1319 | // itself and result in a call to its Execute() method which simply calls the | |
1320 | // specified method. The difference with a simple method call is that this is | |
1321 | // done asynchronously, i.e. at some later time, instead of immediately when | |
1322 | // the event object is constructed. | |
1323 | ||
8f6bb260 VZ |
1324 | #ifdef wxHAS_CALL_AFTER |
1325 | ||
cf222762 VZ |
1326 | // This is a base class used to process all method calls. |
1327 | class wxAsyncMethodCallEvent : public wxEvent | |
1328 | { | |
1329 | public: | |
1330 | wxAsyncMethodCallEvent(wxObject* object) | |
1331 | : wxEvent(wxID_ANY, wxEVT_ASYNC_METHOD_CALL) | |
1332 | { | |
1333 | SetEventObject(object); | |
1334 | } | |
1335 | ||
1336 | wxAsyncMethodCallEvent(const wxAsyncMethodCallEvent& other) | |
1337 | : wxEvent(other) | |
1338 | { | |
1339 | } | |
1340 | ||
1341 | virtual void Execute() = 0; | |
1342 | }; | |
1343 | ||
1344 | // This is a version for calling methods without parameters. | |
1345 | template <typename T> | |
1346 | class wxAsyncMethodCallEvent0 : public wxAsyncMethodCallEvent | |
1347 | { | |
1348 | public: | |
1349 | typedef T ObjectType; | |
1350 | typedef void (ObjectType::*MethodType)(); | |
1351 | ||
1352 | wxAsyncMethodCallEvent0(ObjectType* object, | |
1353 | MethodType method) | |
1354 | : wxAsyncMethodCallEvent(object), | |
1355 | m_object(object), | |
1356 | m_method(method) | |
1357 | { | |
1358 | } | |
1359 | ||
1360 | wxAsyncMethodCallEvent0(const wxAsyncMethodCallEvent0& other) | |
1361 | : wxAsyncMethodCallEvent(other), | |
1362 | m_object(other.m_object), | |
1363 | m_method(other.m_method) | |
1364 | { | |
1365 | } | |
1366 | ||
1367 | virtual wxEvent *Clone() const | |
1368 | { | |
1369 | return new wxAsyncMethodCallEvent0(*this); | |
1370 | } | |
1371 | ||
1372 | virtual void Execute() | |
1373 | { | |
1374 | (m_object->*m_method)(); | |
1375 | } | |
1376 | ||
1377 | private: | |
1378 | ObjectType* const m_object; | |
1379 | const MethodType m_method; | |
1380 | }; | |
1381 | ||
1382 | // This is a version for calling methods with a single parameter. | |
1383 | template <typename T, typename T1> | |
1384 | class wxAsyncMethodCallEvent1 : public wxAsyncMethodCallEvent | |
1385 | { | |
1386 | public: | |
1387 | typedef T ObjectType; | |
1388 | typedef void (ObjectType::*MethodType)(T1 x1); | |
1389 | typedef typename wxRemoveRef<T1>::type ParamType1; | |
1390 | ||
1391 | wxAsyncMethodCallEvent1(ObjectType* object, | |
1392 | MethodType method, | |
1393 | const ParamType1& x1) | |
1394 | : wxAsyncMethodCallEvent(object), | |
1395 | m_object(object), | |
1396 | m_method(method), | |
1397 | m_param1(x1) | |
1398 | { | |
1399 | } | |
1400 | ||
1401 | wxAsyncMethodCallEvent1(const wxAsyncMethodCallEvent1& other) | |
1402 | : wxAsyncMethodCallEvent(other), | |
1403 | m_object(other.m_object), | |
1404 | m_method(other.m_method), | |
1405 | m_param1(other.m_param1) | |
1406 | { | |
1407 | } | |
1408 | ||
1409 | virtual wxEvent *Clone() const | |
1410 | { | |
1411 | return new wxAsyncMethodCallEvent1(*this); | |
1412 | } | |
1413 | ||
1414 | virtual void Execute() | |
1415 | { | |
1416 | (m_object->*m_method)(m_param1); | |
1417 | } | |
1418 | ||
1419 | private: | |
1420 | ObjectType* const m_object; | |
1421 | const MethodType m_method; | |
1422 | const ParamType1 m_param1; | |
1423 | }; | |
1424 | ||
1425 | // This is a version for calling methods with two parameters. | |
1426 | template <typename T, typename T1, typename T2> | |
1427 | class wxAsyncMethodCallEvent2 : public wxAsyncMethodCallEvent | |
1428 | { | |
1429 | public: | |
1430 | typedef T ObjectType; | |
1431 | typedef void (ObjectType::*MethodType)(T1 x1, T2 x2); | |
1432 | typedef typename wxRemoveRef<T1>::type ParamType1; | |
1433 | typedef typename wxRemoveRef<T2>::type ParamType2; | |
1434 | ||
1435 | wxAsyncMethodCallEvent2(ObjectType* object, | |
1436 | MethodType method, | |
1437 | const ParamType1& x1, | |
1438 | const ParamType2& x2) | |
1439 | : wxAsyncMethodCallEvent(object), | |
1440 | m_object(object), | |
1441 | m_method(method), | |
1442 | m_param1(x1), | |
1443 | m_param2(x2) | |
1444 | { | |
1445 | } | |
1446 | ||
1447 | wxAsyncMethodCallEvent2(const wxAsyncMethodCallEvent2& other) | |
1448 | : wxAsyncMethodCallEvent(other), | |
1449 | m_object(other.m_object), | |
1450 | m_method(other.m_method), | |
1451 | m_param1(other.m_param1), | |
1452 | m_param2(other.m_param2) | |
1453 | { | |
1454 | } | |
1455 | ||
1456 | virtual wxEvent *Clone() const | |
1457 | { | |
1458 | return new wxAsyncMethodCallEvent2(*this); | |
1459 | } | |
1460 | ||
1461 | virtual void Execute() | |
1462 | { | |
1463 | (m_object->*m_method)(m_param1, m_param2); | |
1464 | } | |
1465 | ||
1466 | private: | |
1467 | ObjectType* const m_object; | |
1468 | const MethodType m_method; | |
1469 | const ParamType1 m_param1; | |
1470 | const ParamType2 m_param2; | |
1471 | }; | |
1472 | ||
8f6bb260 VZ |
1473 | #endif // wxHAS_CALL_AFTER |
1474 | ||
1475 | ||
e90c1d2a VZ |
1476 | #if wxUSE_GUI |
1477 | ||
1648d51b | 1478 | |
c801d85f KB |
1479 | // Item or menu event class |
1480 | /* | |
ce7fe42e VZ |
1481 | wxEVT_BUTTON |
1482 | wxEVT_CHECKBOX | |
1483 | wxEVT_CHOICE | |
1484 | wxEVT_LISTBOX | |
1485 | wxEVT_LISTBOX_DCLICK | |
1486 | wxEVT_TEXT | |
1487 | wxEVT_TEXT_ENTER | |
1488 | wxEVT_MENU | |
1489 | wxEVT_SLIDER | |
1490 | wxEVT_RADIOBOX | |
1491 | wxEVT_RADIOBUTTON | |
1492 | wxEVT_SCROLLBAR | |
1493 | wxEVT_VLBOX | |
1494 | wxEVT_COMBOBOX | |
1495 | wxEVT_TOGGLEBUTTON | |
c801d85f KB |
1496 | */ |
1497 | ||
c1b293bb VS |
1498 | class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent, |
1499 | public wxEventBasicPayloadMixin | |
c801d85f | 1500 | { |
2b854a32 | 1501 | public: |
d9e2e4c2 | 1502 | wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); |
c801d85f | 1503 | |
e6a6feba | 1504 | wxCommandEvent(const wxCommandEvent& event) |
497dbbd3 | 1505 | : wxEvent(event), |
c1b293bb | 1506 | wxEventBasicPayloadMixin(event), |
497dbbd3 VZ |
1507 | m_clientData(event.m_clientData), |
1508 | m_clientObject(event.m_clientObject) | |
34af6cfc VZ |
1509 | { |
1510 | // Because GetString() can retrieve the string text only on demand, we | |
1511 | // need to copy it explicitly. | |
1512 | if ( m_cmdString.empty() ) | |
1513 | m_cmdString = event.GetString(); | |
1514 | } | |
e6a6feba | 1515 | |
2b854a32 VZ |
1516 | // Set/Get client data from controls |
1517 | void SetClientData(void* clientData) { m_clientData = clientData; } | |
1518 | void *GetClientData() const { return m_clientData; } | |
c801d85f | 1519 | |
2b854a32 VZ |
1520 | // Set/Get client object from controls |
1521 | void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; } | |
88eadcf2 | 1522 | wxClientData *GetClientObject() const { return m_clientObject; } |
f5e27805 | 1523 | |
c1b293bb VS |
1524 | // Note: this shadows wxEventBasicPayloadMixin::GetString(), because it does some |
1525 | // GUI-specific hacks | |
1526 | wxString GetString() const; | |
1527 | ||
2b854a32 VZ |
1528 | // Get listbox selection if single-choice |
1529 | int GetSelection() const { return m_commandInt; } | |
c801d85f | 1530 | |
2b854a32 | 1531 | // Get checkbox value |
3ca6a5f0 | 1532 | bool IsChecked() const { return m_commandInt != 0; } |
c801d85f | 1533 | |
a0d9c6cb | 1534 | // true if the listbox event was a selection. |
2b854a32 | 1535 | bool IsSelection() const { return (m_extraLong != 0); } |
c801d85f | 1536 | |
8e72b8b5 | 1537 | virtual wxEvent *Clone() const { return new wxCommandEvent(*this); } |
d48b06bd | 1538 | virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; } |
aadbdf11 | 1539 | |
b4b76d61 | 1540 | protected: |
2b854a32 VZ |
1541 | void* m_clientData; // Arbitrary client data |
1542 | wxClientData* m_clientObject; // Arbitrary client object | |
f97500b8 | 1543 | |
8e72b8b5 | 1544 | private: |
fc7a2a60 | 1545 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent) |
c801d85f KB |
1546 | }; |
1547 | ||
fd3f686c VZ |
1548 | // this class adds a possibility to react (from the user) code to a control |
1549 | // notification: allow or veto the operation being reported. | |
bddd7a8d | 1550 | class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent |
fd3f686c VZ |
1551 | { |
1552 | public: | |
d9e2e4c2 DE |
1553 | wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) |
1554 | : wxCommandEvent(commandType, winid) | |
a0d9c6cb | 1555 | { m_bAllow = true; } |
e6a6feba GD |
1556 | |
1557 | wxNotifyEvent(const wxNotifyEvent& event) | |
1558 | : wxCommandEvent(event) | |
497dbbd3 | 1559 | { m_bAllow = event.m_bAllow; } |
fd3f686c | 1560 | |
23f681ec | 1561 | // veto the operation (usually it's allowed by default) |
a0d9c6cb | 1562 | void Veto() { m_bAllow = false; } |
fd3f686c | 1563 | |
23f681ec | 1564 | // allow the operation if it was disabled by default |
a0d9c6cb | 1565 | void Allow() { m_bAllow = true; } |
23f681ec | 1566 | |
fd3f686c VZ |
1567 | // for implementation code only: is the operation allowed? |
1568 | bool IsAllowed() const { return m_bAllow; } | |
1569 | ||
8e72b8b5 | 1570 | virtual wxEvent *Clone() const { return new wxNotifyEvent(*this); } |
924ef850 | 1571 | |
fd3f686c VZ |
1572 | private: |
1573 | bool m_bAllow; | |
1574 | ||
8e72b8b5 | 1575 | private: |
fc7a2a60 | 1576 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent) |
fd3f686c VZ |
1577 | }; |
1578 | ||
d48b06bd | 1579 | |
d1367c3d | 1580 | // Scroll event class, derived form wxCommandEvent. wxScrollEvents are |
e8b669d3 | 1581 | // sent by wxSlider and wxScrollBar. |
c801d85f KB |
1582 | /* |
1583 | wxEVT_SCROLL_TOP | |
1584 | wxEVT_SCROLL_BOTTOM | |
1585 | wxEVT_SCROLL_LINEUP | |
1586 | wxEVT_SCROLL_LINEDOWN | |
1587 | wxEVT_SCROLL_PAGEUP | |
1588 | wxEVT_SCROLL_PAGEDOWN | |
1589 | wxEVT_SCROLL_THUMBTRACK | |
7d56fb8f | 1590 | wxEVT_SCROLL_THUMBRELEASE |
cbc85508 | 1591 | wxEVT_SCROLL_CHANGED |
c801d85f KB |
1592 | */ |
1593 | ||
bddd7a8d | 1594 | class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent |
c801d85f | 1595 | { |
2b854a32 VZ |
1596 | public: |
1597 | wxScrollEvent(wxEventType commandType = wxEVT_NULL, | |
d9e2e4c2 | 1598 | int winid = 0, int pos = 0, int orient = 0); |
2b854a32 | 1599 | |
a7bc03c9 VZ |
1600 | int GetOrientation() const { return (int) m_extraLong; } |
1601 | int GetPosition() const { return m_commandInt; } | |
2b854a32 VZ |
1602 | void SetOrientation(int orient) { m_extraLong = (long) orient; } |
1603 | void SetPosition(int pos) { m_commandInt = pos; } | |
f97500b8 | 1604 | |
8e72b8b5 | 1605 | virtual wxEvent *Clone() const { return new wxScrollEvent(*this); } |
f97500b8 | 1606 | |
8e72b8b5 | 1607 | private: |
fc7a2a60 | 1608 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent) |
c801d85f KB |
1609 | }; |
1610 | ||
d1367c3d RR |
1611 | // ScrollWin event class, derived fom wxEvent. wxScrollWinEvents |
1612 | // are sent by wxWindow. | |
1613 | /* | |
1614 | wxEVT_SCROLLWIN_TOP | |
1615 | wxEVT_SCROLLWIN_BOTTOM | |
1616 | wxEVT_SCROLLWIN_LINEUP | |
1617 | wxEVT_SCROLLWIN_LINEDOWN | |
1618 | wxEVT_SCROLLWIN_PAGEUP | |
1619 | wxEVT_SCROLLWIN_PAGEDOWN | |
1620 | wxEVT_SCROLLWIN_THUMBTRACK | |
7d56fb8f | 1621 | wxEVT_SCROLLWIN_THUMBRELEASE |
d1367c3d RR |
1622 | */ |
1623 | ||
bddd7a8d | 1624 | class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent |
d1367c3d | 1625 | { |
d1367c3d RR |
1626 | public: |
1627 | wxScrollWinEvent(wxEventType commandType = wxEVT_NULL, | |
1628 | int pos = 0, int orient = 0); | |
f3ff831f | 1629 | wxScrollWinEvent(const wxScrollWinEvent& event) : wxEvent(event) |
b2697d42 VZ |
1630 | { m_commandInt = event.m_commandInt; |
1631 | m_extraLong = event.m_extraLong; } | |
d1367c3d | 1632 | |
a7bc03c9 VZ |
1633 | int GetOrientation() const { return (int) m_extraLong; } |
1634 | int GetPosition() const { return m_commandInt; } | |
d1367c3d RR |
1635 | void SetOrientation(int orient) { m_extraLong = (long) orient; } |
1636 | void SetPosition(int pos) { m_commandInt = pos; } | |
1637 | ||
8e72b8b5 | 1638 | virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); } |
1e6feb95 | 1639 | |
b4b76d61 | 1640 | protected: |
8e72b8b5 | 1641 | int m_commandInt; |
20947e08 | 1642 | long m_extraLong; |
1e6feb95 | 1643 | |
8e72b8b5 | 1644 | private: |
fc7a2a60 | 1645 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent) |
d1367c3d RR |
1646 | }; |
1647 | ||
d48b06bd FM |
1648 | |
1649 | ||
c801d85f KB |
1650 | // Mouse event class |
1651 | ||
1652 | /* | |
1653 | wxEVT_LEFT_DOWN | |
1654 | wxEVT_LEFT_UP | |
1655 | wxEVT_MIDDLE_DOWN | |
1656 | wxEVT_MIDDLE_UP | |
1657 | wxEVT_RIGHT_DOWN | |
1658 | wxEVT_RIGHT_UP | |
1659 | wxEVT_MOTION | |
1660 | wxEVT_ENTER_WINDOW | |
1661 | wxEVT_LEAVE_WINDOW | |
1662 | wxEVT_LEFT_DCLICK | |
1663 | wxEVT_MIDDLE_DCLICK | |
1664 | wxEVT_RIGHT_DCLICK | |
c801d85f KB |
1665 | */ |
1666 | ||
41469c9e VZ |
1667 | enum wxMouseWheelAxis |
1668 | { | |
1669 | wxMOUSE_WHEEL_VERTICAL, | |
1670 | wxMOUSE_WHEEL_HORIZONTAL | |
1671 | }; | |
1672 | ||
0e097789 VZ |
1673 | class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent, |
1674 | public wxMouseState | |
c801d85f | 1675 | { |
2b854a32 VZ |
1676 | public: |
1677 | wxMouseEvent(wxEventType mouseType = wxEVT_NULL); | |
0e097789 VZ |
1678 | wxMouseEvent(const wxMouseEvent& event) |
1679 | : wxEvent(event), | |
1680 | wxMouseState(event) | |
1681 | { | |
1682 | Assign(event); | |
1683 | } | |
c801d85f | 1684 | |
2b854a32 | 1685 | // Was it a button event? (*doesn't* mean: is any button *down*?) |
497dbbd3 | 1686 | bool IsButton() const { return Button(wxMOUSE_BTN_ANY); } |
c801d85f | 1687 | |
3e89999c | 1688 | // Was it a down event from this (or any) button? |
497dbbd3 | 1689 | bool ButtonDown(int but = wxMOUSE_BTN_ANY) const; |
c801d85f | 1690 | |
3e89999c | 1691 | // Was it a dclick event from this (or any) button? |
497dbbd3 | 1692 | bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const; |
c801d85f | 1693 | |
3e89999c | 1694 | // Was it a up event from this (or any) button? |
497dbbd3 | 1695 | bool ButtonUp(int but = wxMOUSE_BTN_ANY) const; |
c801d85f | 1696 | |
ab826fd8 | 1697 | // Was this event generated by the given button? |
2b854a32 | 1698 | bool Button(int but) const; |
c801d85f | 1699 | |
497dbbd3 | 1700 | // Get the button which is changing state (wxMOUSE_BTN_NONE if none) |
1e6feb95 VZ |
1701 | int GetButton() const; |
1702 | ||
2b854a32 VZ |
1703 | // Find which event was just generated |
1704 | bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); } | |
1705 | bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); } | |
1706 | bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); } | |
01101e2d VZ |
1707 | bool Aux1Down() const { return (m_eventType == wxEVT_AUX1_DOWN); } |
1708 | bool Aux2Down() const { return (m_eventType == wxEVT_AUX2_DOWN); } | |
c801d85f | 1709 | |
2b854a32 VZ |
1710 | bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); } |
1711 | bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); } | |
1712 | bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); } | |
01101e2d VZ |
1713 | bool Aux1Up() const { return (m_eventType == wxEVT_AUX1_UP); } |
1714 | bool Aux2Up() const { return (m_eventType == wxEVT_AUX2_UP); } | |
c801d85f | 1715 | |
2b854a32 VZ |
1716 | bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); } |
1717 | bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); } | |
1718 | bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); } | |
4e32015c VZ |
1719 | bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); } |
1720 | bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); } | |
c801d85f | 1721 | |
2b854a32 VZ |
1722 | // True if a button is down and the mouse is moving |
1723 | bool Dragging() const | |
1724 | { | |
5b66d31a | 1725 | return (m_eventType == wxEVT_MOTION) && ButtonIsDown(wxMOUSE_BTN_ANY); |
2b854a32 | 1726 | } |
c801d85f | 1727 | |
2b854a32 | 1728 | // True if the mouse is moving, and no button is down |
6f63704f VZ |
1729 | bool Moving() const |
1730 | { | |
5b66d31a | 1731 | return (m_eventType == wxEVT_MOTION) && !ButtonIsDown(wxMOUSE_BTN_ANY); |
6f63704f | 1732 | } |
c801d85f | 1733 | |
2b854a32 VZ |
1734 | // True if the mouse is just entering the window |
1735 | bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); } | |
c801d85f | 1736 | |
2b854a32 VZ |
1737 | // True if the mouse is just leaving the window |
1738 | bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); } | |
c801d85f | 1739 | |
8866abbb VZ |
1740 | // Returns the number of mouse clicks associated with this event. |
1741 | int GetClickCount() const { return m_clickCount; } | |
1742 | ||
2b854a32 | 1743 | // Find the logical position of the event given the DC |
a7bc03c9 | 1744 | wxPoint GetLogicalPosition(const wxDC& dc) const; |
c801d85f | 1745 | |
d2c52078 RD |
1746 | // Get wheel rotation, positive or negative indicates direction of |
1747 | // rotation. Current devices all send an event when rotation is equal to | |
1748 | // +/-WheelDelta, but this allows for finer resolution devices to be | |
1749 | // created in the future. Because of this you shouldn't assume that one | |
1750 | // event is equal to 1 line or whatever, but you should be able to either | |
1751 | // do partial line scrolling or wait until +/-WheelDelta rotation values | |
1752 | // have been accumulated before scrolling. | |
1753 | int GetWheelRotation() const { return m_wheelRotation; } | |
1754 | ||
1755 | // Get wheel delta, normally 120. This is the threshold for action to be | |
1756 | // taken, and one such action (for example, scrolling one increment) | |
1757 | // should occur for each delta. | |
1758 | int GetWheelDelta() const { return m_wheelDelta; } | |
1759 | ||
41469c9e VZ |
1760 | // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL |
1761 | // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling | |
1762 | // using e.g. a trackpad). | |
1763 | wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; } | |
aea37008 | 1764 | |
d2c52078 | 1765 | // Returns the configured number of lines (or whatever) to be scrolled per |
5833988c | 1766 | // wheel action. Defaults to three. |
d2c52078 | 1767 | int GetLinesPerAction() const { return m_linesPerAction; } |
aa767a45 | 1768 | |
5833988c VZ |
1769 | // Returns the configured number of columns (or whatever) to be scrolled per |
1770 | // wheel action. Defaults to three. | |
1771 | int GetColumnsPerAction() const { return m_columnsPerAction; } | |
1772 | ||
9b9337da | 1773 | // Is the system set to do page scrolling? |
c2bbeff0 | 1774 | bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); } |
9b9337da | 1775 | |
8e72b8b5 | 1776 | virtual wxEvent *Clone() const { return new wxMouseEvent(*this); } |
d48b06bd | 1777 | virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; } |
aadbdf11 | 1778 | |
0e097789 VZ |
1779 | wxMouseEvent& operator=(const wxMouseEvent& event) |
1780 | { | |
1781 | if (&event != this) | |
1782 | Assign(event); | |
1783 | return *this; | |
1784 | } | |
c7d176e2 | 1785 | |
c801d85f | 1786 | public: |
8866abbb VZ |
1787 | int m_clickCount; |
1788 | ||
41469c9e | 1789 | wxMouseWheelAxis m_wheelAxis; |
d2c52078 RD |
1790 | int m_wheelRotation; |
1791 | int m_wheelDelta; | |
1792 | int m_linesPerAction; | |
5833988c | 1793 | int m_columnsPerAction; |
1e6feb95 | 1794 | |
abcbaea7 VZ |
1795 | protected: |
1796 | void Assign(const wxMouseEvent& evt); | |
1797 | ||
1e6feb95 VZ |
1798 | private: |
1799 | DECLARE_DYNAMIC_CLASS(wxMouseEvent) | |
c801d85f KB |
1800 | }; |
1801 | ||
43b5058d VZ |
1802 | // Cursor set event |
1803 | ||
1804 | /* | |
1805 | wxEVT_SET_CURSOR | |
1806 | */ | |
1807 | ||
bddd7a8d | 1808 | class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent |
43b5058d VZ |
1809 | { |
1810 | public: | |
8e72b8b5 | 1811 | wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0) |
497dbbd3 VZ |
1812 | : wxEvent(0, wxEVT_SET_CURSOR), |
1813 | m_x(x), m_y(y), m_cursor() | |
e6a6feba | 1814 | { } |
43b5058d | 1815 | |
f3ff831f | 1816 | wxSetCursorEvent(const wxSetCursorEvent& event) |
b2697d42 VZ |
1817 | : wxEvent(event), |
1818 | m_x(event.m_x), | |
1819 | m_y(event.m_y), | |
1820 | m_cursor(event.m_cursor) | |
1821 | { } | |
1d2eddff | 1822 | |
43b5058d VZ |
1823 | wxCoord GetX() const { return m_x; } |
1824 | wxCoord GetY() const { return m_y; } | |
1825 | ||
1826 | void SetCursor(const wxCursor& cursor) { m_cursor = cursor; } | |
1827 | const wxCursor& GetCursor() const { return m_cursor; } | |
a1b806b9 | 1828 | bool HasCursor() const { return m_cursor.IsOk(); } |
43b5058d | 1829 | |
8e72b8b5 | 1830 | virtual wxEvent *Clone() const { return new wxSetCursorEvent(*this); } |
f97500b8 | 1831 | |
43b5058d VZ |
1832 | private: |
1833 | wxCoord m_x, m_y; | |
1834 | wxCursor m_cursor; | |
f97500b8 | 1835 | |
8e72b8b5 | 1836 | private: |
fc7a2a60 | 1837 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent) |
43b5058d VZ |
1838 | }; |
1839 | ||
c801d85f KB |
1840 | // Keyboard input event class |
1841 | ||
1842 | /* | |
1843 | wxEVT_CHAR | |
1844 | wxEVT_CHAR_HOOK | |
4ce81a75 | 1845 | wxEVT_KEY_DOWN |
c801d85f | 1846 | wxEVT_KEY_UP |
5048c832 | 1847 | wxEVT_HOTKEY |
c801d85f KB |
1848 | */ |
1849 | ||
7a34307e VZ |
1850 | // key categories: the bit flags for IsKeyInCategory() function |
1851 | // | |
1852 | // the enum values used may change in future version of wx | |
1853 | // use the named constants only, or bitwise combinations thereof | |
1854 | enum wxKeyCategoryFlags | |
1855 | { | |
1856 | // arrow keys, on and off numeric keypads | |
1857 | WXK_CATEGORY_ARROW = 1, | |
1858 | ||
1859 | // page up and page down keys, on and off numeric keypads | |
1860 | WXK_CATEGORY_PAGING = 2, | |
1861 | ||
1862 | // home and end keys, on and off numeric keypads | |
1863 | WXK_CATEGORY_JUMP = 4, | |
1864 | ||
4f742042 | 1865 | // tab key, on and off numeric keypads |
7a34307e VZ |
1866 | WXK_CATEGORY_TAB = 8, |
1867 | ||
1868 | // backspace and delete keys, on and off numeric keypads | |
1869 | WXK_CATEGORY_CUT = 16, | |
1870 | ||
1871 | // all keys usually used for navigation | |
1872 | WXK_CATEGORY_NAVIGATION = WXK_CATEGORY_ARROW | | |
1873 | WXK_CATEGORY_PAGING | | |
1874 | WXK_CATEGORY_JUMP | |
1875 | }; | |
1876 | ||
0e097789 VZ |
1877 | class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent, |
1878 | public wxKeyboardState | |
c801d85f | 1879 | { |
c801d85f | 1880 | public: |
2b854a32 | 1881 | wxKeyEvent(wxEventType keyType = wxEVT_NULL); |
e45d9090 VZ |
1882 | |
1883 | // Normal copy ctor and a ctor creating a new event for the same key as the | |
1884 | // given one but a different event type (this is used in implementation | |
1885 | // code only, do not use outside of the library). | |
b2697d42 | 1886 | wxKeyEvent(const wxKeyEvent& evt); |
e45d9090 | 1887 | wxKeyEvent(wxEventType eventType, const wxKeyEvent& evt); |
c801d85f | 1888 | |
f6bcfd97 BP |
1889 | // get the key code: an ASCII7 char or an element of wxKeyCode enum |
1890 | int GetKeyCode() const { return (int)m_keyCode; } | |
c801d85f | 1891 | |
7a34307e VZ |
1892 | // returns true iff this event's key code is of a certain type |
1893 | bool IsKeyInCategory(int category) const; | |
1894 | ||
a3db5254 VZ |
1895 | #if wxUSE_UNICODE |
1896 | // get the Unicode character corresponding to this key | |
1897 | wxChar GetUnicodeKey() const { return m_uniChar; } | |
1898 | #endif // wxUSE_UNICODE | |
1899 | ||
9c7df356 VZ |
1900 | // get the raw key code (platform-dependent) |
1901 | wxUint32 GetRawKeyCode() const { return m_rawCode; } | |
1902 | ||
1903 | // get the raw key flags (platform-dependent) | |
1904 | wxUint32 GetRawKeyFlags() const { return m_rawFlags; } | |
1905 | ||
2b854a32 | 1906 | // Find the position of the event |
b02da6b1 VZ |
1907 | void GetPosition(wxCoord *xpos, wxCoord *ypos) const |
1908 | { | |
e0e6f3dc VZ |
1909 | if (xpos) |
1910 | *xpos = GetX(); | |
1911 | if (ypos) | |
1912 | *ypos = GetY(); | |
b02da6b1 VZ |
1913 | } |
1914 | ||
e0e6f3dc | 1915 | // This version if provided only for backwards compatiblity, don't use. |
bf57d1ad | 1916 | void GetPosition(long *xpos, long *ypos) const |
b02da6b1 | 1917 | { |
e0e6f3dc VZ |
1918 | if (xpos) |
1919 | *xpos = GetX(); | |
1920 | if (ypos) | |
1921 | *ypos = GetY(); | |
b02da6b1 | 1922 | } |
803ef874 JS |
1923 | |
1924 | wxPoint GetPosition() const | |
e0e6f3dc | 1925 | { return wxPoint(GetX(), GetY()); } |
c801d85f | 1926 | |
2b854a32 | 1927 | // Get X position |
2f7baaec | 1928 | wxCoord GetX() const; |
c801d85f | 1929 | |
2b854a32 | 1930 | // Get Y position |
2f7baaec | 1931 | wxCoord GetY() const; |
c801d85f | 1932 | |
4cf1a9bf VZ |
1933 | // Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal |
1934 | // key events even though the event had been handled (by default they would | |
1935 | // not be generated in this case). | |
1936 | void DoAllowNextEvent() { m_allowNext = true; } | |
1937 | ||
1938 | // Return the value of the "allow next" flag, for internal use only. | |
1939 | bool IsNextEventAllowed() const { return m_allowNext; } | |
1940 | ||
1941 | ||
8e72b8b5 | 1942 | virtual wxEvent *Clone() const { return new wxKeyEvent(*this); } |
d48b06bd | 1943 | virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; } |
f97500b8 VZ |
1944 | |
1945 | // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for | |
1946 | // example) | |
1947 | wxKeyEvent& operator=(const wxKeyEvent& evt) | |
1948 | { | |
3232da9d | 1949 | if ( &evt != this ) |
162e998c | 1950 | { |
0e097789 | 1951 | wxEvent::operator=(evt); |
3232da9d VZ |
1952 | |
1953 | // Borland C++ 5.82 doesn't compile an explicit call to an | |
1954 | // implicitly defined operator=() so need to do it this way: | |
1955 | *static_cast<wxKeyboardState *>(this) = evt; | |
0e097789 | 1956 | |
dfc7216d | 1957 | DoAssignMembers(evt); |
162e998c | 1958 | } |
f97500b8 VZ |
1959 | return *this; |
1960 | } | |
1961 | ||
2b854a32 | 1962 | public: |
e0e6f3dc VZ |
1963 | // Do not use these fields directly, they are initialized on demand, so |
1964 | // call GetX() and GetY() or GetPosition() instead. | |
b02da6b1 VZ |
1965 | wxCoord m_x, m_y; |
1966 | ||
2b854a32 | 1967 | long m_keyCode; |
b02da6b1 | 1968 | |
2b5f62a0 VZ |
1969 | #if wxUSE_UNICODE |
1970 | // This contains the full Unicode character | |
1971 | // in a character events in Unicode mode | |
1972 | wxChar m_uniChar; | |
1973 | #endif | |
1974 | ||
1975 | // these fields contain the platform-specific information about | |
1976 | // key that was pressed | |
9c7df356 VZ |
1977 | wxUint32 m_rawCode; |
1978 | wxUint32 m_rawFlags; | |
1979 | ||
8e72b8b5 | 1980 | private: |
3a95f73c VZ |
1981 | // Set the event to propagate if necessary, i.e. if it's of wxEVT_CHAR_HOOK |
1982 | // type. This is used by all ctors. | |
1983 | void InitPropagation() | |
1984 | { | |
1985 | if ( m_eventType == wxEVT_CHAR_HOOK ) | |
1986 | m_propagationLevel = wxEVENT_PROPAGATE_MAX; | |
4cf1a9bf VZ |
1987 | |
1988 | m_allowNext = false; | |
3a95f73c VZ |
1989 | } |
1990 | ||
dfc7216d VZ |
1991 | // Copy only the event data present in this class, this is used by |
1992 | // AssignKeyData() and copy ctor. | |
1993 | void DoAssignMembers(const wxKeyEvent& evt) | |
1994 | { | |
1995 | m_x = evt.m_x; | |
1996 | m_y = evt.m_y; | |
2f7baaec | 1997 | m_hasPosition = evt.m_hasPosition; |
dfc7216d VZ |
1998 | |
1999 | m_keyCode = evt.m_keyCode; | |
2000 | ||
2001 | m_rawCode = evt.m_rawCode; | |
2002 | m_rawFlags = evt.m_rawFlags; | |
2003 | #if wxUSE_UNICODE | |
2004 | m_uniChar = evt.m_uniChar; | |
2005 | #endif | |
2006 | } | |
2007 | ||
2f7baaec VZ |
2008 | // Initialize m_x and m_y using the current mouse cursor position if |
2009 | // necessary. | |
2010 | void InitPositionIfNecessary() const; | |
2011 | ||
4cf1a9bf VZ |
2012 | // If this flag is true, the normal key events should still be generated |
2013 | // even if wxEVT_CHAR_HOOK had been handled. By default it is false as | |
2014 | // handling wxEVT_CHAR_HOOK suppresses all the subsequent events. | |
2015 | bool m_allowNext; | |
2016 | ||
2f7baaec VZ |
2017 | // If true, m_x and m_y were already initialized. If false, try to get them |
2018 | // when they're requested. | |
2019 | bool m_hasPosition; | |
2020 | ||
8e72b8b5 | 2021 | DECLARE_DYNAMIC_CLASS(wxKeyEvent) |
c801d85f KB |
2022 | }; |
2023 | ||
2024 | // Size event class | |
2025 | /* | |
2026 | wxEVT_SIZE | |
2027 | */ | |
2028 | ||
bddd7a8d | 2029 | class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent |
c801d85f | 2030 | { |
2b854a32 | 2031 | public: |
497dbbd3 | 2032 | wxSizeEvent() : wxEvent(0, wxEVT_SIZE) |
e6a6feba | 2033 | { } |
d9e2e4c2 DE |
2034 | wxSizeEvent(const wxSize& sz, int winid = 0) |
2035 | : wxEvent(winid, wxEVT_SIZE), | |
497dbbd3 | 2036 | m_size(sz) |
e6a6feba | 2037 | { } |
f3ff831f | 2038 | wxSizeEvent(const wxSizeEvent& event) |
b2697d42 | 2039 | : wxEvent(event), |
5706de1c | 2040 | m_size(event.m_size), m_rect(event.m_rect) |
b2697d42 | 2041 | { } |
5706de1c | 2042 | wxSizeEvent(const wxRect& rect, int id = 0) |
e00865fa | 2043 | : m_size(rect.GetSize()), m_rect(rect) |
5706de1c | 2044 | { m_eventType = wxEVT_SIZING; m_id = id; } |
c2bbeff0 | 2045 | |
2b854a32 | 2046 | wxSize GetSize() const { return m_size; } |
b702a833 | 2047 | void SetSize(wxSize size) { m_size = size; } |
5706de1c | 2048 | wxRect GetRect() const { return m_rect; } |
fbfb8bcc | 2049 | void SetRect(const wxRect& rect) { m_rect = rect; } |
aadbdf11 | 2050 | |
8e72b8b5 RR |
2051 | virtual wxEvent *Clone() const { return new wxSizeEvent(*this); } |
2052 | ||
2053 | public: | |
b4b76d61 | 2054 | // For internal usage only. Will be converted to protected members. |
8e72b8b5 | 2055 | wxSize m_size; |
5706de1c | 2056 | wxRect m_rect; // Used for wxEVT_SIZING |
8e72b8b5 | 2057 | |
f97500b8 | 2058 | private: |
fc7a2a60 | 2059 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent) |
c801d85f KB |
2060 | }; |
2061 | ||
2062 | // Move event class | |
2063 | ||
2064 | /* | |
2065 | wxEVT_MOVE | |
2066 | */ | |
2067 | ||
bddd7a8d | 2068 | class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent |
c801d85f | 2069 | { |
2b854a32 | 2070 | public: |
e6a6feba GD |
2071 | wxMoveEvent() |
2072 | : wxEvent(0, wxEVT_MOVE) | |
e6a6feba | 2073 | { } |
d9e2e4c2 DE |
2074 | wxMoveEvent(const wxPoint& pos, int winid = 0) |
2075 | : wxEvent(winid, wxEVT_MOVE), | |
497dbbd3 | 2076 | m_pos(pos) |
e6a6feba | 2077 | { } |
1d2eddff JS |
2078 | wxMoveEvent(const wxMoveEvent& event) |
2079 | : wxEvent(event), | |
b2697d42 VZ |
2080 | m_pos(event.m_pos) |
2081 | { } | |
5706de1c JS |
2082 | wxMoveEvent(const wxRect& rect, int id = 0) |
2083 | : m_pos(rect.GetPosition()), m_rect(rect) | |
2084 | { m_eventType = wxEVT_MOVING; m_id = id; } | |
c2bbeff0 | 2085 | |
2b854a32 | 2086 | wxPoint GetPosition() const { return m_pos; } |
d7f03cae | 2087 | void SetPosition(const wxPoint& pos) { m_pos = pos; } |
5706de1c | 2088 | wxRect GetRect() const { return m_rect; } |
fbfb8bcc | 2089 | void SetRect(const wxRect& rect) { m_rect = rect; } |
aadbdf11 | 2090 | |
8e72b8b5 | 2091 | virtual wxEvent *Clone() const { return new wxMoveEvent(*this); } |
f97500b8 | 2092 | |
b4b76d61 | 2093 | protected: |
8e72b8b5 | 2094 | wxPoint m_pos; |
5706de1c | 2095 | wxRect m_rect; |
f97500b8 | 2096 | |
8e72b8b5 | 2097 | private: |
fc7a2a60 | 2098 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent) |
c801d85f KB |
2099 | }; |
2100 | ||
2101 | // Paint event class | |
2102 | /* | |
2103 | wxEVT_PAINT | |
2104 | wxEVT_NC_PAINT | |
c801d85f KB |
2105 | */ |
2106 | ||
657a8a35 VZ |
2107 | #if wxDEBUG_LEVEL && (defined(__WXMSW__) || defined(__WXPM__)) |
2108 | #define wxHAS_PAINT_DEBUG | |
2109 | ||
b078fa02 | 2110 | // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined |
bddd7a8d | 2111 | extern WXDLLIMPEXP_CORE int g_isPainting; |
edccf428 VZ |
2112 | #endif // debug |
2113 | ||
bddd7a8d | 2114 | class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent |
c801d85f | 2115 | { |
2b854a32 | 2116 | public: |
edccf428 | 2117 | wxPaintEvent(int Id = 0) |
e6a6feba | 2118 | : wxEvent(Id, wxEVT_PAINT) |
edccf428 | 2119 | { |
657a8a35 VZ |
2120 | #ifdef wxHAS_PAINT_DEBUG |
2121 | // set the internal flag for the duration of redrawing | |
edccf428 VZ |
2122 | g_isPainting++; |
2123 | #endif // debug | |
2124 | } | |
2125 | ||
4e689ecd VZ |
2126 | // default copy ctor and dtor are normally fine, we only need them to keep |
2127 | // g_isPainting updated in debug build | |
657a8a35 | 2128 | #ifdef wxHAS_PAINT_DEBUG |
4e689ecd VZ |
2129 | wxPaintEvent(const wxPaintEvent& event) |
2130 | : wxEvent(event) | |
2131 | { | |
2132 | g_isPainting++; | |
2133 | } | |
2134 | ||
d3c7fc99 | 2135 | virtual ~wxPaintEvent() |
edccf428 VZ |
2136 | { |
2137 | g_isPainting--; | |
2138 | } | |
2139 | #endif // debug | |
8e72b8b5 RR |
2140 | |
2141 | virtual wxEvent *Clone() const { return new wxPaintEvent(*this); } | |
f97500b8 | 2142 | |
8e72b8b5 | 2143 | private: |
fc7a2a60 | 2144 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent) |
c801d85f KB |
2145 | }; |
2146 | ||
bddd7a8d | 2147 | class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent |
1e6feb95 VZ |
2148 | { |
2149 | public: | |
d9e2e4c2 DE |
2150 | wxNcPaintEvent(int winid = 0) |
2151 | : wxEvent(winid, wxEVT_NC_PAINT) | |
e6a6feba | 2152 | { } |
f97500b8 | 2153 | |
8e72b8b5 | 2154 | virtual wxEvent *Clone() const { return new wxNcPaintEvent(*this); } |
1e6feb95 VZ |
2155 | |
2156 | private: | |
fc7a2a60 | 2157 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent) |
1e6feb95 VZ |
2158 | }; |
2159 | ||
c801d85f KB |
2160 | // Erase background event class |
2161 | /* | |
2162 | wxEVT_ERASE_BACKGROUND | |
2163 | */ | |
2164 | ||
bddd7a8d | 2165 | class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent |
c801d85f | 2166 | { |
2b854a32 | 2167 | public: |
03f3617b | 2168 | wxEraseEvent(int Id = 0, wxDC *dc = NULL) |
497dbbd3 VZ |
2169 | : wxEvent(Id, wxEVT_ERASE_BACKGROUND), |
2170 | m_dc(dc) | |
e6a6feba GD |
2171 | { } |
2172 | ||
2173 | wxEraseEvent(const wxEraseEvent& event) | |
497dbbd3 VZ |
2174 | : wxEvent(event), |
2175 | m_dc(event.m_dc) | |
e6a6feba | 2176 | { } |
f97500b8 | 2177 | |
2b854a32 | 2178 | wxDC *GetDC() const { return m_dc; } |
aadbdf11 | 2179 | |
8e72b8b5 | 2180 | virtual wxEvent *Clone() const { return new wxEraseEvent(*this); } |
f97500b8 | 2181 | |
b4b76d61 | 2182 | protected: |
8e72b8b5 RR |
2183 | wxDC *m_dc; |
2184 | ||
2185 | private: | |
fc7a2a60 | 2186 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent) |
c801d85f KB |
2187 | }; |
2188 | ||
2189 | // Focus event class | |
2190 | /* | |
2191 | wxEVT_SET_FOCUS | |
2192 | wxEVT_KILL_FOCUS | |
2193 | */ | |
2194 | ||
bddd7a8d | 2195 | class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent |
c801d85f | 2196 | { |
2b854a32 | 2197 | public: |
d9e2e4c2 DE |
2198 | wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0) |
2199 | : wxEvent(winid, type) | |
497dbbd3 | 2200 | { m_win = NULL; } |
e6a6feba GD |
2201 | |
2202 | wxFocusEvent(const wxFocusEvent& event) | |
2203 | : wxEvent(event) | |
497dbbd3 | 2204 | { m_win = event.m_win; } |
1e6feb95 | 2205 | |
8e72b8b5 | 2206 | // The window associated with this event is the window which had focus |
1e6feb95 | 2207 | // before for SET event and the window which will have focus for the KILL |
8e72b8b5 | 2208 | // one. NB: it may be NULL in both cases! |
1e6feb95 VZ |
2209 | wxWindow *GetWindow() const { return m_win; } |
2210 | void SetWindow(wxWindow *win) { m_win = win; } | |
2211 | ||
8e72b8b5 | 2212 | virtual wxEvent *Clone() const { return new wxFocusEvent(*this); } |
f97500b8 | 2213 | |
1e6feb95 VZ |
2214 | private: |
2215 | wxWindow *m_win; | |
2216 | ||
8e72b8b5 | 2217 | private: |
fc7a2a60 | 2218 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent) |
c801d85f KB |
2219 | }; |
2220 | ||
456bc6d9 | 2221 | // wxChildFocusEvent notifies the parent that a child has got the focus: unlike |
1648d51b | 2222 | // wxFocusEvent it is propagated upwards the window chain |
bddd7a8d | 2223 | class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent |
456bc6d9 VZ |
2224 | { |
2225 | public: | |
2226 | wxChildFocusEvent(wxWindow *win = NULL); | |
2227 | ||
2228 | wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } | |
2229 | ||
8e72b8b5 | 2230 | virtual wxEvent *Clone() const { return new wxChildFocusEvent(*this); } |
f97500b8 | 2231 | |
8e72b8b5 | 2232 | private: |
fc7a2a60 | 2233 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent) |
456bc6d9 VZ |
2234 | }; |
2235 | ||
c801d85f KB |
2236 | // Activate event class |
2237 | /* | |
2238 | wxEVT_ACTIVATE | |
2239 | wxEVT_ACTIVATE_APP | |
afafd942 | 2240 | wxEVT_HIBERNATE |
c801d85f KB |
2241 | */ |
2242 | ||
bddd7a8d | 2243 | class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent |
c801d85f | 2244 | { |
2b854a32 | 2245 | public: |
a0d9c6cb | 2246 | wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, int Id = 0) |
e6a6feba | 2247 | : wxEvent(Id, type) |
497dbbd3 | 2248 | { m_active = active; } |
1d2eddff JS |
2249 | wxActivateEvent(const wxActivateEvent& event) |
2250 | : wxEvent(event) | |
b2697d42 | 2251 | { m_active = event.m_active; } |
c2bbeff0 | 2252 | |
2b854a32 | 2253 | bool GetActive() const { return m_active; } |
c801d85f | 2254 | |
8e72b8b5 | 2255 | virtual wxEvent *Clone() const { return new wxActivateEvent(*this); } |
aadbdf11 | 2256 | |
2b854a32 VZ |
2257 | private: |
2258 | bool m_active; | |
8e72b8b5 RR |
2259 | |
2260 | private: | |
fc7a2a60 | 2261 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent) |
c801d85f KB |
2262 | }; |
2263 | ||
2264 | // InitDialog event class | |
2265 | /* | |
2266 | wxEVT_INIT_DIALOG | |
2267 | */ | |
2268 | ||
bddd7a8d | 2269 | class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent |
c801d85f | 2270 | { |
2b854a32 VZ |
2271 | public: |
2272 | wxInitDialogEvent(int Id = 0) | |
e6a6feba GD |
2273 | : wxEvent(Id, wxEVT_INIT_DIALOG) |
2274 | { } | |
8e72b8b5 RR |
2275 | |
2276 | virtual wxEvent *Clone() const { return new wxInitDialogEvent(*this); } | |
f97500b8 VZ |
2277 | |
2278 | private: | |
fc7a2a60 | 2279 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent) |
c801d85f KB |
2280 | }; |
2281 | ||
2282 | // Miscellaneous menu event class | |
2283 | /* | |
ccef86c7 VZ |
2284 | wxEVT_MENU_OPEN, |
2285 | wxEVT_MENU_CLOSE, | |
c801d85f | 2286 | wxEVT_MENU_HIGHLIGHT, |
c801d85f KB |
2287 | */ |
2288 | ||
bddd7a8d | 2289 | class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent |
c801d85f | 2290 | { |
c801d85f | 2291 | public: |
92f1a59c | 2292 | wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL) |
d9e2e4c2 | 2293 | : wxEvent(winid, type) |
fc7a2a60 | 2294 | { m_menuId = winid; m_menu = menu; } |
f3ff831f | 2295 | wxMenuEvent(const wxMenuEvent& event) |
1d2eddff | 2296 | : wxEvent(event) |
92f1a59c | 2297 | { m_menuId = event.m_menuId; m_menu = event.m_menu; } |
c2bbeff0 | 2298 | |
ccef86c7 | 2299 | // only for wxEVT_MENU_HIGHLIGHT |
aadbdf11 | 2300 | int GetMenuId() const { return m_menuId; } |
c801d85f | 2301 | |
ccef86c7 | 2302 | // only for wxEVT_MENU_OPEN/CLOSE |
1a18887b | 2303 | bool IsPopup() const { return m_menuId == wxID_ANY; } |
ccef86c7 | 2304 | |
92f1a59c JS |
2305 | // only for wxEVT_MENU_OPEN/CLOSE |
2306 | wxMenu* GetMenu() const { return m_menu; } | |
2307 | ||
8e72b8b5 | 2308 | virtual wxEvent *Clone() const { return new wxMenuEvent(*this); } |
f97500b8 | 2309 | |
2b854a32 | 2310 | private: |
92f1a59c JS |
2311 | int m_menuId; |
2312 | wxMenu* m_menu; | |
f97500b8 | 2313 | |
fc7a2a60 | 2314 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent) |
c801d85f KB |
2315 | }; |
2316 | ||
2317 | // Window close or session close event class | |
2318 | /* | |
2319 | wxEVT_CLOSE_WINDOW, | |
2320 | wxEVT_END_SESSION, | |
2321 | wxEVT_QUERY_END_SESSION | |
2322 | */ | |
2323 | ||
bddd7a8d | 2324 | class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent |
c801d85f | 2325 | { |
c801d85f | 2326 | public: |
d9e2e4c2 DE |
2327 | wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0) |
2328 | : wxEvent(winid, type), | |
a0d9c6cb WS |
2329 | m_loggingOff(true), |
2330 | m_veto(false), // should be false by default | |
2331 | m_canVeto(true) {} | |
a3bf7524 | 2332 | |
f3ff831f | 2333 | wxCloseEvent(const wxCloseEvent& event) |
1d2eddff | 2334 | : wxEvent(event), |
b2697d42 VZ |
2335 | m_loggingOff(event.m_loggingOff), |
2336 | m_veto(event.m_veto), | |
a3bf7524 | 2337 | m_canVeto(event.m_canVeto) {} |
c2bbeff0 | 2338 | |
2b854a32 | 2339 | void SetLoggingOff(bool logOff) { m_loggingOff = logOff; } |
4bcfcdef VZ |
2340 | bool GetLoggingOff() const |
2341 | { | |
2342 | // m_loggingOff flag is only used by wxEVT_[QUERY_]END_SESSION, it | |
2343 | // doesn't make sense for wxEVT_CLOSE_WINDOW | |
2344 | wxASSERT_MSG( m_eventType != wxEVT_CLOSE_WINDOW, | |
9a83f860 | 2345 | wxT("this flag is for end session events only") ); |
4bcfcdef VZ |
2346 | |
2347 | return m_loggingOff; | |
2348 | } | |
2b854a32 | 2349 | |
a0d9c6cb | 2350 | void Veto(bool veto = true) |
fe4e9e6c | 2351 | { |
a0d9c6cb | 2352 | // GetVeto() will return false anyhow... |
fe4e9e6c | 2353 | wxCHECK_RET( m_canVeto, |
223d09f6 | 2354 | wxT("call to Veto() ignored (can't veto this event)") ); |
fe4e9e6c VZ |
2355 | |
2356 | m_veto = veto; | |
2357 | } | |
2b854a32 VZ |
2358 | void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } |
2359 | bool CanVeto() const { return m_canVeto; } | |
fe4e9e6c | 2360 | bool GetVeto() const { return m_canVeto && m_veto; } |
c801d85f | 2361 | |
8e72b8b5 | 2362 | virtual wxEvent *Clone() const { return new wxCloseEvent(*this); } |
aadbdf11 | 2363 | |
2b854a32 | 2364 | protected: |
4bcfcdef VZ |
2365 | bool m_loggingOff, |
2366 | m_veto, | |
2367 | m_canVeto; | |
2b854a32 | 2368 | |
8e72b8b5 | 2369 | private: |
fc7a2a60 | 2370 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent) |
c801d85f KB |
2371 | }; |
2372 | ||
2373 | /* | |
2374 | wxEVT_SHOW | |
2375 | */ | |
2376 | ||
bddd7a8d | 2377 | class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent |
c801d85f | 2378 | { |
c801d85f | 2379 | public: |
a0d9c6cb | 2380 | wxShowEvent(int winid = 0, bool show = false) |
d9e2e4c2 | 2381 | : wxEvent(winid, wxEVT_SHOW) |
497dbbd3 | 2382 | { m_show = show; } |
f3ff831f | 2383 | wxShowEvent(const wxShowEvent& event) |
1d2eddff | 2384 | : wxEvent(event) |
b2697d42 | 2385 | { m_show = event.m_show; } |
c2bbeff0 | 2386 | |
2b854a32 | 2387 | void SetShow(bool show) { m_show = show; } |
d317fdeb VZ |
2388 | |
2389 | // return true if the window was shown, false if hidden | |
2390 | bool IsShown() const { return m_show; } | |
2391 | ||
831b64f3 | 2392 | #if WXWIN_COMPATIBILITY_2_8 |
d317fdeb VZ |
2393 | wxDEPRECATED( bool GetShow() const { return IsShown(); } ) |
2394 | #endif | |
c801d85f | 2395 | |
8e72b8b5 | 2396 | virtual wxEvent *Clone() const { return new wxShowEvent(*this); } |
aadbdf11 | 2397 | |
c801d85f | 2398 | protected: |
2b854a32 | 2399 | bool m_show; |
3dd9b88a | 2400 | |
8e72b8b5 | 2401 | private: |
fc7a2a60 | 2402 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent) |
c801d85f KB |
2403 | }; |
2404 | ||
2405 | /* | |
2406 | wxEVT_ICONIZE | |
2407 | */ | |
2408 | ||
bddd7a8d | 2409 | class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent |
c801d85f | 2410 | { |
2b854a32 | 2411 | public: |
a0d9c6cb | 2412 | wxIconizeEvent(int winid = 0, bool iconized = true) |
d9e2e4c2 | 2413 | : wxEvent(winid, wxEVT_ICONIZE) |
497dbbd3 | 2414 | { m_iconized = iconized; } |
f3ff831f | 2415 | wxIconizeEvent(const wxIconizeEvent& event) |
1d2eddff | 2416 | : wxEvent(event) |
b2697d42 | 2417 | { m_iconized = event.m_iconized; } |
c2bbeff0 | 2418 | |
831b64f3 | 2419 | #if WXWIN_COMPATIBILITY_2_8 |
d317fdeb VZ |
2420 | wxDEPRECATED( bool Iconized() const { return IsIconized(); } ) |
2421 | #endif | |
3dd9b88a | 2422 | // return true if the frame was iconized, false if restored |
d317fdeb | 2423 | bool IsIconized() const { return m_iconized; } |
3dd9b88a | 2424 | |
8e72b8b5 | 2425 | virtual wxEvent *Clone() const { return new wxIconizeEvent(*this); } |
f97500b8 | 2426 | |
3dd9b88a VZ |
2427 | protected: |
2428 | bool m_iconized; | |
2429 | ||
8e72b8b5 | 2430 | private: |
fc7a2a60 | 2431 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent) |
c801d85f | 2432 | }; |
c801d85f KB |
2433 | /* |
2434 | wxEVT_MAXIMIZE | |
2435 | */ | |
2436 | ||
bddd7a8d | 2437 | class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent |
c801d85f | 2438 | { |
2b854a32 | 2439 | public: |
d9e2e4c2 DE |
2440 | wxMaximizeEvent(int winid = 0) |
2441 | : wxEvent(winid, wxEVT_MAXIMIZE) | |
e6a6feba | 2442 | { } |
3dd9b88a | 2443 | |
8e72b8b5 | 2444 | virtual wxEvent *Clone() const { return new wxMaximizeEvent(*this); } |
f97500b8 | 2445 | |
8e72b8b5 | 2446 | private: |
fc7a2a60 | 2447 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent) |
c801d85f KB |
2448 | }; |
2449 | ||
2450 | // Joystick event class | |
2451 | /* | |
2452 | wxEVT_JOY_BUTTON_DOWN, | |
2453 | wxEVT_JOY_BUTTON_UP, | |
2454 | wxEVT_JOY_MOVE, | |
2455 | wxEVT_JOY_ZMOVE | |
2456 | */ | |
2457 | ||
2458 | // Which joystick? Same as Windows ids so no conversion necessary. | |
497dbbd3 VZ |
2459 | enum |
2460 | { | |
2461 | wxJOYSTICK1, | |
2462 | wxJOYSTICK2 | |
2463 | }; | |
c801d85f KB |
2464 | |
2465 | // Which button is down? | |
497dbbd3 VZ |
2466 | enum |
2467 | { | |
2468 | wxJOY_BUTTON_ANY = -1, | |
2469 | wxJOY_BUTTON1 = 1, | |
2470 | wxJOY_BUTTON2 = 2, | |
2471 | wxJOY_BUTTON3 = 4, | |
2472 | wxJOY_BUTTON4 = 8 | |
2473 | }; | |
c801d85f | 2474 | |
bddd7a8d | 2475 | class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent |
c801d85f | 2476 | { |
b4b76d61 | 2477 | protected: |
2b854a32 VZ |
2478 | wxPoint m_pos; |
2479 | int m_zPosition; | |
497dbbd3 VZ |
2480 | int m_buttonChange; // Which button changed? |
2481 | int m_buttonState; // Which buttons are down? | |
2482 | int m_joyStick; // Which joystick? | |
2b854a32 | 2483 | |
b4b76d61 | 2484 | public: |
2b854a32 VZ |
2485 | wxJoystickEvent(wxEventType type = wxEVT_NULL, |
2486 | int state = 0, | |
2487 | int joystick = wxJOYSTICK1, | |
2488 | int change = 0) | |
497dbbd3 | 2489 | : wxEvent(0, type), |
8b5d5223 | 2490 | m_pos(), |
497dbbd3 VZ |
2491 | m_zPosition(0), |
2492 | m_buttonChange(change), | |
2493 | m_buttonState(state), | |
2494 | m_joyStick(joystick) | |
2b854a32 | 2495 | { |
2b854a32 | 2496 | } |
f3ff831f | 2497 | wxJoystickEvent(const wxJoystickEvent& event) |
b2697d42 VZ |
2498 | : wxEvent(event), |
2499 | m_pos(event.m_pos), | |
2500 | m_zPosition(event.m_zPosition), | |
2501 | m_buttonChange(event.m_buttonChange), | |
2502 | m_buttonState(event.m_buttonState), | |
2503 | m_joyStick(event.m_joyStick) | |
1d2eddff | 2504 | { } |
c2bbeff0 | 2505 | |
2b854a32 VZ |
2506 | wxPoint GetPosition() const { return m_pos; } |
2507 | int GetZPosition() const { return m_zPosition; } | |
2508 | int GetButtonState() const { return m_buttonState; } | |
2509 | int GetButtonChange() const { return m_buttonChange; } | |
2510 | int GetJoystick() const { return m_joyStick; } | |
2511 | ||
2512 | void SetJoystick(int stick) { m_joyStick = stick; } | |
2513 | void SetButtonState(int state) { m_buttonState = state; } | |
2514 | void SetButtonChange(int change) { m_buttonChange = change; } | |
2515 | void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
2516 | void SetZPosition(int zPos) { m_zPosition = zPos; } | |
2517 | ||
2518 | // Was it a button event? (*doesn't* mean: is any button *down*?) | |
2519 | bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) || | |
b70ababc | 2520 | (GetEventType() == wxEVT_JOY_BUTTON_UP)); } |
2b854a32 VZ |
2521 | |
2522 | // Was it a move event? | |
a7bc03c9 | 2523 | bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE); } |
2b854a32 VZ |
2524 | |
2525 | // Was it a zmove event? | |
a7bc03c9 | 2526 | bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE); } |
2b854a32 VZ |
2527 | |
2528 | // Was it a down event from button 1, 2, 3, 4 or any? | |
2529 | bool ButtonDown(int but = wxJOY_BUTTON_ANY) const | |
c801d85f | 2530 | { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) && |
2b854a32 | 2531 | ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } |
c801d85f | 2532 | |
2b854a32 VZ |
2533 | // Was it a up event from button 1, 2, 3 or any? |
2534 | bool ButtonUp(int but = wxJOY_BUTTON_ANY) const | |
c801d85f | 2535 | { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) && |
2b854a32 | 2536 | ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } |
c801d85f | 2537 | |
2b854a32 VZ |
2538 | // Was the given button 1,2,3,4 or any in Down state? |
2539 | bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const | |
c801d85f | 2540 | { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) || |
2b854a32 | 2541 | ((m_buttonState & but) == but)); } |
f305c661 | 2542 | |
8e72b8b5 | 2543 | virtual wxEvent *Clone() const { return new wxJoystickEvent(*this); } |
f97500b8 | 2544 | |
8e72b8b5 | 2545 | private: |
fc7a2a60 | 2546 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent) |
c801d85f KB |
2547 | }; |
2548 | ||
2549 | // Drop files event class | |
2550 | /* | |
2551 | wxEVT_DROP_FILES | |
2552 | */ | |
2553 | ||
bddd7a8d | 2554 | class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent |
c801d85f | 2555 | { |
2b854a32 VZ |
2556 | public: |
2557 | int m_noFiles; | |
2558 | wxPoint m_pos; | |
c3c39620 | 2559 | wxString* m_files; |
2b854a32 VZ |
2560 | |
2561 | wxDropFilesEvent(wxEventType type = wxEVT_NULL, | |
2562 | int noFiles = 0, | |
03f3617b | 2563 | wxString *files = NULL) |
497dbbd3 VZ |
2564 | : wxEvent(0, type), |
2565 | m_noFiles(noFiles), | |
2566 | m_pos(), | |
2567 | m_files(files) | |
e6a6feba | 2568 | { } |
2b854a32 | 2569 | |
c3c39620 VZ |
2570 | // we need a copy ctor to avoid deleting m_files pointer twice |
2571 | wxDropFilesEvent(const wxDropFilesEvent& other) | |
497dbbd3 VZ |
2572 | : wxEvent(other), |
2573 | m_noFiles(other.m_noFiles), | |
2574 | m_pos(other.m_pos), | |
2575 | m_files(NULL) | |
c3c39620 | 2576 | { |
c3c39620 VZ |
2577 | m_files = new wxString[m_noFiles]; |
2578 | for ( int n = 0; n < m_noFiles; n++ ) | |
2579 | { | |
2580 | m_files[n] = other.m_files[n]; | |
2581 | } | |
2582 | } | |
2583 | ||
2584 | virtual ~wxDropFilesEvent() | |
2585 | { | |
2586 | delete [] m_files; | |
2587 | } | |
2588 | ||
2b854a32 VZ |
2589 | wxPoint GetPosition() const { return m_pos; } |
2590 | int GetNumberOfFiles() const { return m_noFiles; } | |
2591 | wxString *GetFiles() const { return m_files; } | |
f305c661 | 2592 | |
c3c39620 | 2593 | virtual wxEvent *Clone() const { return new wxDropFilesEvent(*this); } |
f97500b8 | 2594 | |
8e72b8b5 | 2595 | private: |
fc7a2a60 | 2596 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent) |
c801d85f KB |
2597 | }; |
2598 | ||
c801d85f KB |
2599 | // Update UI event |
2600 | /* | |
2601 | wxEVT_UPDATE_UI | |
2602 | */ | |
2603 | ||
e39af974 JS |
2604 | // Whether to always send update events to windows, or |
2605 | // to only send update events to those with the | |
2606 | // wxWS_EX_PROCESS_UI_UPDATES style. | |
2607 | ||
2608 | enum wxUpdateUIMode | |
2609 | { | |
2610 | // Send UI update events to all windows | |
2611 | wxUPDATE_UI_PROCESS_ALL, | |
2612 | ||
2613 | // Send UI update events to windows that have | |
2614 | // the wxWS_EX_PROCESS_UI_UPDATES flag specified | |
2615 | wxUPDATE_UI_PROCESS_SPECIFIED | |
2616 | }; | |
2617 | ||
bddd7a8d | 2618 | class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent |
c801d85f | 2619 | { |
2b854a32 VZ |
2620 | public: |
2621 | wxUpdateUIEvent(wxWindowID commandId = 0) | |
e6a6feba | 2622 | : wxCommandEvent(wxEVT_UPDATE_UI, commandId) |
497dbbd3 VZ |
2623 | { |
2624 | m_checked = | |
2625 | m_enabled = | |
a3a4105d | 2626 | m_shown = |
497dbbd3 | 2627 | m_setEnabled = |
a3a4105d | 2628 | m_setShown = |
9b9337da | 2629 | m_setText = |
a0d9c6cb | 2630 | m_setChecked = false; |
497dbbd3 | 2631 | } |
f3ff831f | 2632 | wxUpdateUIEvent(const wxUpdateUIEvent& event) |
1d2eddff | 2633 | : wxCommandEvent(event), |
b2697d42 VZ |
2634 | m_checked(event.m_checked), |
2635 | m_enabled(event.m_enabled), | |
a3a4105d | 2636 | m_shown(event.m_shown), |
b2697d42 | 2637 | m_setEnabled(event.m_setEnabled), |
a3a4105d | 2638 | m_setShown(event.m_setShown), |
b2697d42 VZ |
2639 | m_setText(event.m_setText), |
2640 | m_setChecked(event.m_setChecked), | |
2641 | m_text(event.m_text) | |
2642 | { } | |
c2bbeff0 | 2643 | |
2b854a32 VZ |
2644 | bool GetChecked() const { return m_checked; } |
2645 | bool GetEnabled() const { return m_enabled; } | |
a3a4105d | 2646 | bool GetShown() const { return m_shown; } |
2b854a32 VZ |
2647 | wxString GetText() const { return m_text; } |
2648 | bool GetSetText() const { return m_setText; } | |
2649 | bool GetSetChecked() const { return m_setChecked; } | |
2650 | bool GetSetEnabled() const { return m_setEnabled; } | |
a3a4105d | 2651 | bool GetSetShown() const { return m_setShown; } |
2b854a32 | 2652 | |
a0d9c6cb WS |
2653 | void Check(bool check) { m_checked = check; m_setChecked = true; } |
2654 | void Enable(bool enable) { m_enabled = enable; m_setEnabled = true; } | |
a3a4105d | 2655 | void Show(bool show) { m_shown = show; m_setShown = true; } |
a0d9c6cb | 2656 | void SetText(const wxString& text) { m_text = text; m_setText = true; } |
c801d85f | 2657 | |
0b30bb0b JS |
2658 | // Sets the interval between updates in milliseconds. |
2659 | // Set to -1 to disable updates, or to 0 to update as frequently as possible. | |
e39af974 | 2660 | static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; } |
0b30bb0b JS |
2661 | |
2662 | // Returns the current interval between updates in milliseconds | |
a7bc03c9 | 2663 | static long GetUpdateInterval() { return sm_updateInterval; } |
0b30bb0b | 2664 | |
e39af974 | 2665 | // Can we update this window? |
a7bc03c9 | 2666 | static bool CanUpdate(wxWindowBase *win); |
0b30bb0b JS |
2667 | |
2668 | // Reset the update time to provide a delay until the next | |
2669 | // time we should update | |
a7bc03c9 | 2670 | static void ResetUpdateTime(); |
0b30bb0b | 2671 | |
77ffb593 | 2672 | // Specify how wxWidgets will send update events: to |
e39af974 JS |
2673 | // all windows, or only to those which specify that they |
2674 | // will process the events. | |
2675 | static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; } | |
2676 | ||
2677 | // Returns the UI update mode | |
a7bc03c9 | 2678 | static wxUpdateUIMode GetMode() { return sm_updateMode; } |
e39af974 | 2679 | |
8e72b8b5 | 2680 | virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); } |
f305c661 | 2681 | |
2b854a32 VZ |
2682 | protected: |
2683 | bool m_checked; | |
2684 | bool m_enabled; | |
a3a4105d | 2685 | bool m_shown; |
2b854a32 | 2686 | bool m_setEnabled; |
a3a4105d | 2687 | bool m_setShown; |
2b854a32 VZ |
2688 | bool m_setText; |
2689 | bool m_setChecked; | |
2690 | wxString m_text; | |
0b30bb0b | 2691 | #if wxUSE_LONGLONG |
e39af974 | 2692 | static wxLongLong sm_lastUpdate; |
0b30bb0b | 2693 | #endif |
e39af974 JS |
2694 | static long sm_updateInterval; |
2695 | static wxUpdateUIMode sm_updateMode; | |
f97500b8 | 2696 | |
8e72b8b5 | 2697 | private: |
fc7a2a60 | 2698 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent) |
c801d85f KB |
2699 | }; |
2700 | ||
2701 | /* | |
2702 | wxEVT_SYS_COLOUR_CHANGED | |
2703 | */ | |
2704 | ||
2705 | // TODO: shouldn't all events record the window ID? | |
bddd7a8d | 2706 | class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent |
c801d85f | 2707 | { |
2b854a32 VZ |
2708 | public: |
2709 | wxSysColourChangedEvent() | |
e6a6feba GD |
2710 | : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED) |
2711 | { } | |
f97500b8 | 2712 | |
8e72b8b5 | 2713 | virtual wxEvent *Clone() const { return new wxSysColourChangedEvent(*this); } |
f97500b8 | 2714 | |
8e72b8b5 | 2715 | private: |
fc7a2a60 | 2716 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent) |
c801d85f KB |
2717 | }; |
2718 | ||
a5e84126 JS |
2719 | /* |
2720 | wxEVT_MOUSE_CAPTURE_CHANGED | |
2721 | The window losing the capture receives this message | |
2722 | (even if it released the capture itself). | |
2723 | */ | |
2724 | ||
bddd7a8d | 2725 | class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent |
a5e84126 JS |
2726 | { |
2727 | public: | |
d9e2e4c2 DE |
2728 | wxMouseCaptureChangedEvent(wxWindowID winid = 0, wxWindow* gainedCapture = NULL) |
2729 | : wxEvent(winid, wxEVT_MOUSE_CAPTURE_CHANGED), | |
497dbbd3 | 2730 | m_gainedCapture(gainedCapture) |
e6a6feba GD |
2731 | { } |
2732 | ||
2733 | wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent& event) | |
497dbbd3 VZ |
2734 | : wxEvent(event), |
2735 | m_gainedCapture(event.m_gainedCapture) | |
e6a6feba | 2736 | { } |
a5e84126 JS |
2737 | |
2738 | virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); } | |
2739 | ||
47b378bd | 2740 | wxWindow* GetCapturedWindow() const { return m_gainedCapture; } |
a5e84126 JS |
2741 | |
2742 | private: | |
2743 | wxWindow* m_gainedCapture; | |
fc7a2a60 VZ |
2744 | |
2745 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent) | |
a5e84126 JS |
2746 | }; |
2747 | ||
63e819f2 VS |
2748 | /* |
2749 | wxEVT_MOUSE_CAPTURE_LOST | |
2750 | The window losing the capture receives this message, unless it released it | |
2751 | it itself or unless wxWindow::CaptureMouse was called on another window | |
2752 | (and so capture will be restored when the new capturer releases it). | |
2753 | */ | |
2754 | ||
2755 | class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent : public wxEvent | |
2756 | { | |
2757 | public: | |
2758 | wxMouseCaptureLostEvent(wxWindowID winid = 0) | |
2759 | : wxEvent(winid, wxEVT_MOUSE_CAPTURE_LOST) | |
2760 | {} | |
2761 | ||
2762 | wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent& event) | |
2763 | : wxEvent(event) | |
2764 | {} | |
2765 | ||
2766 | virtual wxEvent *Clone() const { return new wxMouseCaptureLostEvent(*this); } | |
2767 | ||
2768 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent) | |
2769 | }; | |
2770 | ||
574c939e KB |
2771 | /* |
2772 | wxEVT_DISPLAY_CHANGED | |
2773 | */ | |
bddd7a8d | 2774 | class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent |
574c939e KB |
2775 | { |
2776 | private: | |
fc7a2a60 | 2777 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent) |
574c939e KB |
2778 | |
2779 | public: | |
2780 | wxDisplayChangedEvent() | |
e6a6feba GD |
2781 | : wxEvent(0, wxEVT_DISPLAY_CHANGED) |
2782 | { } | |
574c939e KB |
2783 | |
2784 | virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); } | |
2785 | }; | |
2786 | ||
f7bd2698 JS |
2787 | /* |
2788 | wxEVT_PALETTE_CHANGED | |
2789 | */ | |
2790 | ||
bddd7a8d | 2791 | class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent |
f7bd2698 | 2792 | { |
f7bd2698 | 2793 | public: |
d9e2e4c2 DE |
2794 | wxPaletteChangedEvent(wxWindowID winid = 0) |
2795 | : wxEvent(winid, wxEVT_PALETTE_CHANGED), | |
03f3617b | 2796 | m_changedWindow(NULL) |
497dbbd3 | 2797 | { } |
e6a6feba GD |
2798 | |
2799 | wxPaletteChangedEvent(const wxPaletteChangedEvent& event) | |
497dbbd3 VZ |
2800 | : wxEvent(event), |
2801 | m_changedWindow(event.m_changedWindow) | |
e6a6feba | 2802 | { } |
f7bd2698 | 2803 | |
2b854a32 VZ |
2804 | void SetChangedWindow(wxWindow* win) { m_changedWindow = win; } |
2805 | wxWindow* GetChangedWindow() const { return m_changedWindow; } | |
f7bd2698 | 2806 | |
8e72b8b5 | 2807 | virtual wxEvent *Clone() const { return new wxPaletteChangedEvent(*this); } |
f305c661 | 2808 | |
f7bd2698 | 2809 | protected: |
2b854a32 | 2810 | wxWindow* m_changedWindow; |
8e72b8b5 RR |
2811 | |
2812 | private: | |
fc7a2a60 | 2813 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent) |
f7bd2698 JS |
2814 | }; |
2815 | ||
2816 | /* | |
2817 | wxEVT_QUERY_NEW_PALETTE | |
2818 | Indicates the window is getting keyboard focus and should re-do its palette. | |
2819 | */ | |
2820 | ||
bddd7a8d | 2821 | class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent |
f7bd2698 | 2822 | { |
f7bd2698 | 2823 | public: |
d9e2e4c2 DE |
2824 | wxQueryNewPaletteEvent(wxWindowID winid = 0) |
2825 | : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE), | |
a0d9c6cb | 2826 | m_paletteRealized(false) |
e6a6feba | 2827 | { } |
f3ff831f | 2828 | wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent& event) |
1d2eddff | 2829 | : wxEvent(event), |
b2697d42 VZ |
2830 | m_paletteRealized(event.m_paletteRealized) |
2831 | { } | |
c2bbeff0 | 2832 | |
2b854a32 VZ |
2833 | // App sets this if it changes the palette. |
2834 | void SetPaletteRealized(bool realized) { m_paletteRealized = realized; } | |
2835 | bool GetPaletteRealized() const { return m_paletteRealized; } | |
f7bd2698 | 2836 | |
8e72b8b5 | 2837 | virtual wxEvent *Clone() const { return new wxQueryNewPaletteEvent(*this); } |
f305c661 | 2838 | |
f7bd2698 | 2839 | protected: |
2b854a32 | 2840 | bool m_paletteRealized; |
f97500b8 | 2841 | |
8e72b8b5 | 2842 | private: |
fc7a2a60 | 2843 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent) |
f7bd2698 JS |
2844 | }; |
2845 | ||
7fdefd57 VZ |
2846 | /* |
2847 | Event generated by dialog navigation keys | |
2848 | wxEVT_NAVIGATION_KEY | |
2849 | */ | |
d9506e77 | 2850 | // NB: don't derive from command event to avoid being propagated to the parent |
bddd7a8d | 2851 | class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent |
7fdefd57 | 2852 | { |
7fdefd57 | 2853 | public: |
d9506e77 | 2854 | wxNavigationKeyEvent() |
497dbbd3 | 2855 | : wxEvent(0, wxEVT_NAVIGATION_KEY), |
298ca00c | 2856 | m_flags(IsForward | FromTab), // defaults are for TAB |
03f3617b | 2857 | m_focus(NULL) |
aef35d0e VZ |
2858 | { |
2859 | m_propagationLevel = wxEVENT_PROPAGATE_NONE; | |
2860 | } | |
d9506e77 | 2861 | |
e6a6feba | 2862 | wxNavigationKeyEvent(const wxNavigationKeyEvent& event) |
497dbbd3 VZ |
2863 | : wxEvent(event), |
2864 | m_flags(event.m_flags), | |
2865 | m_focus(event.m_focus) | |
e6a6feba | 2866 | { } |
7fdefd57 | 2867 | |
2b854a32 | 2868 | // direction: forward (true) or backward (false) |
d9506e77 VZ |
2869 | bool GetDirection() const |
2870 | { return (m_flags & IsForward) != 0; } | |
2871 | void SetDirection(bool bForward) | |
2872 | { if ( bForward ) m_flags |= IsForward; else m_flags &= ~IsForward; } | |
7fdefd57 | 2873 | |
2b854a32 VZ |
2874 | // it may be a window change event (MDI, notebook pages...) or a control |
2875 | // change event | |
d9506e77 VZ |
2876 | bool IsWindowChange() const |
2877 | { return (m_flags & WinChange) != 0; } | |
2878 | void SetWindowChange(bool bIs) | |
2879 | { if ( bIs ) m_flags |= WinChange; else m_flags &= ~WinChange; } | |
2880 | ||
298ca00c VZ |
2881 | // Set to true under MSW if the event was generated using the tab key. |
2882 | // This is required for proper navogation over radio buttons | |
2883 | bool IsFromTab() const | |
2884 | { return (m_flags & FromTab) != 0; } | |
2885 | void SetFromTab(bool bIs) | |
2886 | { if ( bIs ) m_flags |= FromTab; else m_flags &= ~FromTab; } | |
2887 | ||
2b854a32 VZ |
2888 | // the child which has the focus currently (may be NULL - use |
2889 | // wxWindow::FindFocus then) | |
d9506e77 VZ |
2890 | wxWindow* GetCurrentFocus() const { return m_focus; } |
2891 | void SetCurrentFocus(wxWindow *win) { m_focus = win; } | |
2892 | ||
54a69edf JS |
2893 | // Set flags |
2894 | void SetFlags(long flags) { m_flags = flags; } | |
2895 | ||
8e72b8b5 RR |
2896 | virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); } |
2897 | ||
1e8af825 | 2898 | enum wxNavigationKeyEventFlags |
d9506e77 | 2899 | { |
f2de9fee | 2900 | IsBackward = 0x0000, |
d9506e77 | 2901 | IsForward = 0x0001, |
298ca00c VZ |
2902 | WinChange = 0x0002, |
2903 | FromTab = 0x0004 | |
d9506e77 VZ |
2904 | }; |
2905 | ||
2906 | long m_flags; | |
2907 | wxWindow *m_focus; | |
2908 | ||
8e72b8b5 | 2909 | private: |
fc7a2a60 | 2910 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent) |
7fdefd57 VZ |
2911 | }; |
2912 | ||
42e69d6b VZ |
2913 | // Window creation/destruction events: the first is sent as soon as window is |
2914 | // created (i.e. the underlying GUI object exists), but when the C++ object is | |
2915 | // fully initialized (so virtual functions may be called). The second, | |
2916 | // wxEVT_DESTROY, is sent right before the window is destroyed - again, it's | |
2917 | // still safe to call virtual functions at this moment | |
2918 | /* | |
2919 | wxEVT_CREATE | |
2920 | wxEVT_DESTROY | |
2921 | */ | |
2922 | ||
bddd7a8d | 2923 | class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent |
42e69d6b | 2924 | { |
42e69d6b VZ |
2925 | public: |
2926 | wxWindowCreateEvent(wxWindow *win = NULL); | |
2927 | ||
2928 | wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } | |
f97500b8 | 2929 | |
8e72b8b5 | 2930 | virtual wxEvent *Clone() const { return new wxWindowCreateEvent(*this); } |
f97500b8 | 2931 | |
8e72b8b5 | 2932 | private: |
fc7a2a60 | 2933 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent) |
42e69d6b VZ |
2934 | }; |
2935 | ||
bddd7a8d | 2936 | class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent |
42e69d6b | 2937 | { |
42e69d6b VZ |
2938 | public: |
2939 | wxWindowDestroyEvent(wxWindow *win = NULL); | |
2940 | ||
2941 | wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } | |
f97500b8 | 2942 | |
8e72b8b5 RR |
2943 | virtual wxEvent *Clone() const { return new wxWindowDestroyEvent(*this); } |
2944 | ||
2945 | private: | |
fc7a2a60 | 2946 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent) |
42e69d6b VZ |
2947 | }; |
2948 | ||
bd83cb56 | 2949 | // A help event is sent when the user clicks on a window in context-help mode. |
b96340e6 | 2950 | /* |
bd83cb56 VZ |
2951 | wxEVT_HELP |
2952 | wxEVT_DETAILED_HELP | |
2953 | */ | |
b96340e6 | 2954 | |
bddd7a8d | 2955 | class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent |
b96340e6 | 2956 | { |
b96340e6 | 2957 | public: |
b107e8d5 VZ |
2958 | // how was this help event generated? |
2959 | enum Origin | |
2960 | { | |
2961 | Origin_Unknown, // unrecognized event source | |
2962 | Origin_Keyboard, // event generated from F1 key press | |
2963 | Origin_HelpButton // event from [?] button on the title bar (Windows) | |
2964 | }; | |
2965 | ||
bd83cb56 | 2966 | wxHelpEvent(wxEventType type = wxEVT_NULL, |
d9e2e4c2 | 2967 | wxWindowID winid = 0, |
b107e8d5 VZ |
2968 | const wxPoint& pt = wxDefaultPosition, |
2969 | Origin origin = Origin_Unknown) | |
d9e2e4c2 | 2970 | : wxCommandEvent(type, winid), |
b107e8d5 VZ |
2971 | m_pos(pt), |
2972 | m_origin(GuessOrigin(origin)) | |
e6a6feba | 2973 | { } |
f3ff831f | 2974 | wxHelpEvent(const wxHelpEvent& event) |
1d2eddff | 2975 | : wxCommandEvent(event), |
b2697d42 VZ |
2976 | m_pos(event.m_pos), |
2977 | m_target(event.m_target), | |
b107e8d5 VZ |
2978 | m_link(event.m_link), |
2979 | m_origin(event.m_origin) | |
1d2eddff | 2980 | { } |
c2bbeff0 | 2981 | |
bd83cb56 VZ |
2982 | // Position of event (in screen coordinates) |
2983 | const wxPoint& GetPosition() const { return m_pos; } | |
2984 | void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
b96340e6 | 2985 | |
bd83cb56 VZ |
2986 | // Optional link to further help |
2987 | const wxString& GetLink() const { return m_link; } | |
2988 | void SetLink(const wxString& link) { m_link = link; } | |
fb6261e9 | 2989 | |
bd83cb56 VZ |
2990 | // Optional target to display help in. E.g. a window specification |
2991 | const wxString& GetTarget() const { return m_target; } | |
2992 | void SetTarget(const wxString& target) { m_target = target; } | |
fb6261e9 | 2993 | |
8e72b8b5 | 2994 | virtual wxEvent *Clone() const { return new wxHelpEvent(*this); } |
f97500b8 | 2995 | |
b107e8d5 VZ |
2996 | // optional indication of the event source |
2997 | Origin GetOrigin() const { return m_origin; } | |
2998 | void SetOrigin(Origin origin) { m_origin = origin; } | |
2999 | ||
bd83cb56 VZ |
3000 | protected: |
3001 | wxPoint m_pos; | |
3002 | wxString m_target; | |
3003 | wxString m_link; | |
b107e8d5 VZ |
3004 | Origin m_origin; |
3005 | ||
3006 | // we can try to guess the event origin ourselves, even if none is | |
3007 | // specified in the ctor | |
3008 | static Origin GuessOrigin(Origin origin); | |
bd83cb56 VZ |
3009 | |
3010 | private: | |
fc7a2a60 | 3011 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent) |
b96340e6 JS |
3012 | }; |
3013 | ||
78c91815 VZ |
3014 | // A Clipboard Text event is sent when a window intercepts text copy/cut/paste |
3015 | // message, i.e. the user has cut/copied/pasted data from/into a text control | |
3016 | // via ctrl-C/X/V, ctrl/shift-del/insert, a popup menu command, etc. | |
3017 | // NOTE : under windows these events are *NOT* generated automatically | |
3018 | // for a Rich Edit text control. | |
3019 | /* | |
ce7fe42e VZ |
3020 | wxEVT_TEXT_COPY |
3021 | wxEVT_TEXT_CUT | |
3022 | wxEVT_TEXT_PASTE | |
78c91815 VZ |
3023 | */ |
3024 | ||
3025 | class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent | |
3026 | { | |
3027 | public: | |
3028 | wxClipboardTextEvent(wxEventType type = wxEVT_NULL, | |
3029 | wxWindowID winid = 0) | |
3030 | : wxCommandEvent(type, winid) | |
3031 | { } | |
f3ff831f | 3032 | wxClipboardTextEvent(const wxClipboardTextEvent& event) |
78c91815 VZ |
3033 | : wxCommandEvent(event) |
3034 | { } | |
3035 | ||
3036 | virtual wxEvent *Clone() const { return new wxClipboardTextEvent(*this); } | |
3037 | ||
3038 | private: | |
3039 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent) | |
3040 | }; | |
3041 | ||
69231000 JS |
3042 | // A Context event is sent when the user right clicks on a window or |
3043 | // presses Shift-F10 | |
3044 | // NOTE : Under windows this is a repackaged WM_CONTETXMENU message | |
3045 | // Under other systems it may have to be generated from a right click event | |
3046 | /* | |
3047 | wxEVT_CONTEXT_MENU | |
3048 | */ | |
3049 | ||
bddd7a8d | 3050 | class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent |
69231000 JS |
3051 | { |
3052 | public: | |
3053 | wxContextMenuEvent(wxEventType type = wxEVT_NULL, | |
d9e2e4c2 | 3054 | wxWindowID winid = 0, |
e6a6feba | 3055 | const wxPoint& pt = wxDefaultPosition) |
d9e2e4c2 | 3056 | : wxCommandEvent(type, winid), |
497dbbd3 | 3057 | m_pos(pt) |
e6a6feba | 3058 | { } |
f3ff831f | 3059 | wxContextMenuEvent(const wxContextMenuEvent& event) |
1d2eddff | 3060 | : wxCommandEvent(event), |
b2697d42 | 3061 | m_pos(event.m_pos) |
1d2eddff | 3062 | { } |
c2bbeff0 | 3063 | |
69231000 JS |
3064 | // Position of event (in screen coordinates) |
3065 | const wxPoint& GetPosition() const { return m_pos; } | |
3066 | void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
3067 | ||
8e72b8b5 | 3068 | virtual wxEvent *Clone() const { return new wxContextMenuEvent(*this); } |
f97500b8 | 3069 | |
69231000 JS |
3070 | protected: |
3071 | wxPoint m_pos; | |
3072 | ||
3073 | private: | |
fc7a2a60 | 3074 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent) |
69231000 JS |
3075 | }; |
3076 | ||
e90c1d2a | 3077 | |
e5fb7191 | 3078 | /* TODO |
c801d85f KB |
3079 | wxEVT_MOUSE_CAPTURE_CHANGED, |
3080 | wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95) | |
c801d85f KB |
3081 | // wxEVT_FONT_CHANGED, // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate |
3082 | // wxEVT_FONT_CHANGED to all other windows (maybe). | |
3083 | wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific. | |
3084 | wxEVT_MEASURE_ITEM, | |
3085 | wxEVT_COMPARE_ITEM | |
3086 | */ | |
3087 | ||
c1b293bb | 3088 | #endif // wxUSE_GUI |
88a9f974 | 3089 | |
d48b06bd | 3090 | |
8e193f38 VZ |
3091 | // ============================================================================ |
3092 | // event handler and related classes | |
3093 | // ============================================================================ | |
3094 | ||
c801d85f | 3095 | |
6164f93c VZ |
3096 | // struct containing the members common to static and dynamic event tables |
3097 | // entries | |
bddd7a8d | 3098 | struct WXDLLIMPEXP_BASE wxEventTableEntryBase |
77d4384e | 3099 | { |
d9e2e4c2 | 3100 | wxEventTableEntryBase(int winid, int idLast, |
3c778901 | 3101 | wxEventFunctor* fn, wxObject *data) |
d9e2e4c2 | 3102 | : m_id(winid), |
497dbbd3 VZ |
3103 | m_lastId(idLast), |
3104 | m_fn(fn), | |
3105 | m_callbackUserData(data) | |
58791ef8 VS |
3106 | { |
3107 | wxASSERT_MSG( idLast == wxID_ANY || winid <= idLast, | |
3108 | "invalid IDs range: lower bound > upper bound" ); | |
3109 | } | |
e6a6feba | 3110 | |
3c778901 VZ |
3111 | wxEventTableEntryBase( const wxEventTableEntryBase &entry ) |
3112 | : m_id( entry.m_id ), | |
3113 | m_lastId( entry.m_lastId ), | |
3114 | m_fn( entry.m_fn ), | |
3115 | m_callbackUserData( entry.m_callbackUserData ) | |
3116 | { | |
3117 | // This is a 'hack' to ensure that only one instance tries to delete | |
3118 | // the functor pointer. It is safe as long as the only place where the | |
3119 | // copy constructor is being called is when the static event tables are | |
3120 | // being initialized (a temporary instance is created and then this | |
3121 | // constructor is called). | |
3122 | ||
f3ff831f | 3123 | const_cast<wxEventTableEntryBase&>( entry ).m_fn = NULL; |
3c778901 VZ |
3124 | } |
3125 | ||
3126 | ~wxEventTableEntryBase() | |
3127 | { | |
0b632977 | 3128 | delete m_fn; |
3c778901 | 3129 | } |
6164f93c | 3130 | |
497dbbd3 VZ |
3131 | // the range of ids for this entry: if m_lastId == wxID_ANY, the range |
3132 | // consists only of m_id, otherwise it is m_id..m_lastId inclusive | |
3133 | int m_id, | |
3134 | m_lastId; | |
82a5f02c | 3135 | |
3c778901 VZ |
3136 | // function/method/functor to call |
3137 | wxEventFunctor* m_fn; | |
77d4384e | 3138 | |
3c778901 | 3139 | // arbitrary user data associated with the callback |
77d4384e | 3140 | wxObject* m_callbackUserData; |
3c778901 VZ |
3141 | |
3142 | private: | |
c0c133e1 | 3143 | wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase); |
77d4384e RR |
3144 | }; |
3145 | ||
6164f93c | 3146 | // an entry from a static event table |
bddd7a8d | 3147 | struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase |
c801d85f | 3148 | { |
d9e2e4c2 | 3149 | wxEventTableEntry(const int& evType, int winid, int idLast, |
3c778901 | 3150 | wxEventFunctor* fn, wxObject *data) |
d9e2e4c2 | 3151 | : wxEventTableEntryBase(winid, idLast, fn, data), |
e6a6feba GD |
3152 | m_eventType(evType) |
3153 | { } | |
6164f93c VZ |
3154 | |
3155 | // the reference to event type: this allows us to not care about the | |
3156 | // (undefined) order in which the event table entries and the event types | |
3157 | // are initialized: initially the value of this reference might be | |
3158 | // invalid, but by the time it is used for the first time, all global | |
3159 | // objects will have been initialized (including the event type constants) | |
3160 | // and so it will have the correct value when it is needed | |
3161 | const int& m_eventType; | |
fc7a2a60 VZ |
3162 | |
3163 | private: | |
c0c133e1 | 3164 | wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntry); |
6164f93c VZ |
3165 | }; |
3166 | ||
3167 | // an entry used in dynamic event table managed by wxEvtHandler::Connect() | |
bddd7a8d | 3168 | struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase |
6164f93c | 3169 | { |
d9e2e4c2 | 3170 | wxDynamicEventTableEntry(int evType, int winid, int idLast, |
3c778901 | 3171 | wxEventFunctor* fn, wxObject *data) |
d9e2e4c2 | 3172 | : wxEventTableEntryBase(winid, idLast, fn, data), |
3c778901 | 3173 | m_eventType(evType) |
e6a6feba | 3174 | { } |
6164f93c VZ |
3175 | |
3176 | // not a reference here as we can't keep a reference to a temporary int | |
3177 | // created to wrap the constant value typically passed to Connect() - nor | |
3178 | // do we need it | |
3179 | int m_eventType; | |
65b17727 | 3180 | |
3c778901 | 3181 | private: |
c0c133e1 | 3182 | wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry); |
c801d85f KB |
3183 | }; |
3184 | ||
2e4df4bf VZ |
3185 | // ---------------------------------------------------------------------------- |
3186 | // wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0} | |
3187 | // ---------------------------------------------------------------------------- | |
886dd7d2 | 3188 | |
bddd7a8d | 3189 | struct WXDLLIMPEXP_BASE wxEventTable |
c801d85f | 3190 | { |
0b5eceb6 VZ |
3191 | const wxEventTable *baseTable; // base event table (next in chain) |
3192 | const wxEventTableEntry *entries; // bottom of entry array | |
c801d85f KB |
3193 | }; |
3194 | ||
b5a98acd VZ |
3195 | // ---------------------------------------------------------------------------- |
3196 | // wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups. | |
3197 | // ---------------------------------------------------------------------------- | |
3198 | ||
d5d29b8a | 3199 | WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray); |
b5a98acd VZ |
3200 | |
3201 | class WXDLLIMPEXP_BASE wxEventHashTable | |
3202 | { | |
3203 | private: | |
3204 | // Internal data structs | |
3205 | struct EventTypeTable | |
3206 | { | |
3207 | wxEventType eventType; | |
3208 | wxEventTableEntryPointerArray eventEntryTable; | |
3209 | }; | |
3210 | typedef EventTypeTable* EventTypeTablePointer; | |
3211 | ||
3212 | public: | |
3213 | // Constructor, needs the event table it needs to hash later on. | |
1c624631 VZ |
3214 | // Note: hashing of the event table is not done in the constructor as it |
3215 | // can be that the event table is not yet full initialize, the hash | |
b5a98acd VZ |
3216 | // will gets initialized when handling the first event look-up request. |
3217 | wxEventHashTable(const wxEventTable &table); | |
3218 | // Destructor. | |
3219 | ~wxEventHashTable(); | |
3220 | ||
1c624631 | 3221 | // Handle the given event, in other words search the event table hash |
b5a98acd | 3222 | // and call self->ProcessEvent() if a match was found. |
f3ff831f | 3223 | bool HandleEvent(wxEvent& event, wxEvtHandler *self); |
b5a98acd | 3224 | |
afa039f9 JS |
3225 | // Clear table |
3226 | void Clear(); | |
3227 | ||
657a8a35 VZ |
3228 | #if wxUSE_MEMORY_TRACING |
3229 | // Clear all tables: only used to work around problems in memory tracing | |
3230 | // code | |
afa039f9 | 3231 | static void ClearAll(); |
657a8a35 | 3232 | #endif // wxUSE_MEMORY_TRACING |
afa039f9 | 3233 | |
b5a98acd VZ |
3234 | protected: |
3235 | // Init the hash table with the entries of the static event table. | |
3236 | void InitHashTable(); | |
105b2ca7 | 3237 | // Helper function of InitHashTable() to insert 1 entry into the hash table. |
b5a98acd VZ |
3238 | void AddEntry(const wxEventTableEntry &entry); |
3239 | // Allocate and init with null pointers the base hash table. | |
3240 | void AllocEventTypeTable(size_t size); | |
1c624631 | 3241 | // Grow the hash table in size and transfer all items currently |
b5a98acd VZ |
3242 | // in the table to the correct location in the new table. |
3243 | void GrowEventTypeTable(); | |
3244 | ||
3245 | protected: | |
3246 | const wxEventTable &m_table; | |
3247 | bool m_rebuildHash; | |
3248 | ||
3249 | size_t m_size; | |
3250 | EventTypeTablePointer *m_eventTypeTable; | |
fc7a2a60 | 3251 | |
afa039f9 JS |
3252 | static wxEventHashTable* sm_first; |
3253 | wxEventHashTable* m_previous; | |
3254 | wxEventHashTable* m_next; | |
3255 | ||
c0c133e1 | 3256 | wxDECLARE_NO_COPY_CLASS(wxEventHashTable); |
b5a98acd VZ |
3257 | }; |
3258 | ||
6164f93c | 3259 | // ---------------------------------------------------------------------------- |
77ffb593 | 3260 | // wxEvtHandler: the base class for all objects handling wxWidgets events |
6164f93c VZ |
3261 | // ---------------------------------------------------------------------------- |
3262 | ||
4732e2dc | 3263 | class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject |
4732e2dc | 3264 | , public wxTrackable |
c801d85f | 3265 | { |
2b854a32 VZ |
3266 | public: |
3267 | wxEvtHandler(); | |
6164f93c | 3268 | virtual ~wxEvtHandler(); |
2b854a32 | 3269 | |
7f853dd0 FM |
3270 | |
3271 | // Event handler chain | |
3272 | // ------------------- | |
3273 | ||
2b854a32 VZ |
3274 | wxEvtHandler *GetNextHandler() const { return m_nextHandler; } |
3275 | wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; } | |
7f853dd0 FM |
3276 | virtual void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; } |
3277 | virtual void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; } | |
2b854a32 | 3278 | |
8e193f38 | 3279 | void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; } |
2b854a32 VZ |
3280 | bool GetEvtHandlerEnabled() const { return m_enabled; } |
3281 | ||
7f853dd0 FM |
3282 | void Unlink(); |
3283 | bool IsUnlinked() const; | |
3284 | ||
3285 | ||
58cc1587 VZ |
3286 | // Global event filters |
3287 | // -------------------- | |
3288 | ||
3289 | // Add an event filter whose FilterEvent() method will be called for each | |
3290 | // and every event processed by wxWidgets. The filters are called in LIFO | |
3291 | // order and wxApp is registered as an event filter by default. The pointer | |
3292 | // must remain valid until it's removed with RemoveFilter() and is not | |
3293 | // deleted by wxEvtHandler. | |
3294 | static void AddFilter(wxEventFilter* filter); | |
3295 | ||
3296 | // Remove a filter previously installed with AddFilter(). | |
3297 | static void RemoveFilter(wxEventFilter* filter); | |
3298 | ||
7f853dd0 FM |
3299 | |
3300 | // Event queuing and processing | |
3301 | // ---------------------------- | |
3302 | ||
c3f94162 VZ |
3303 | // Process an event right now: this can only be called from the main |
3304 | // thread, use QueueEvent() for scheduling the events for | |
3305 | // processing from other threads. | |
8e193f38 | 3306 | virtual bool ProcessEvent(wxEvent& event); |
2b854a32 | 3307 | |
937013e0 VS |
3308 | // Process an event by calling ProcessEvent and handling any exceptions |
3309 | // thrown by event handlers. It's mostly useful when processing wx events | |
3310 | // when called from C code (e.g. in GTK+ callback) when the exception | |
3311 | // wouldn't correctly propagate to wxEventLoop. | |
3312 | bool SafelyProcessEvent(wxEvent& event); | |
7f853dd0 | 3313 | // NOTE: uses ProcessEvent() |
937013e0 | 3314 | |
3cbb9df8 VZ |
3315 | // This method tries to process the event in this event handler, including |
3316 | // any preprocessing done by TryBefore() and all the handlers chained to | |
3317 | // it, but excluding the post-processing done in TryAfter(). | |
3318 | // | |
3319 | // It is meant to be called from ProcessEvent() only and is not virtual, | |
3320 | // additional event handlers can be hooked into the normal event processing | |
3321 | // logic using TryBefore() and TryAfter() hooks. | |
3322 | // | |
3323 | // You can also call it yourself to forward an event to another handler but | |
3324 | // without propagating it upwards if it's unhandled (this is usually | |
3325 | // unwanted when forwarding as the original handler would already do it if | |
3326 | // needed normally). | |
3327 | bool ProcessEventLocally(wxEvent& event); | |
3328 | ||
c3f94162 VZ |
3329 | // Schedule the given event to be processed later. It takes ownership of |
3330 | // the event pointer, i.e. it will be deleted later. This is safe to call | |
3331 | // from multiple threads although you still need to ensure that wxString | |
3332 | // fields of the event object are deep copies and not use the same string | |
3333 | // buffer as other wxString objects in this thread. | |
3334 | virtual void QueueEvent(wxEvent *event); | |
3335 | ||
3336 | // Add an event to be processed later: notice that this function is not | |
3337 | // safe to call from threads other than main, use QueueEvent() | |
3338 | virtual void AddPendingEvent(const wxEvent& event) | |
3339 | { | |
3340 | // notice that the thread-safety problem comes from the fact that | |
3341 | // Clone() doesn't make deep copies of wxString fields of wxEvent | |
3342 | // object and so the same wxString could be used from both threads when | |
3343 | // the event object is destroyed in this one -- QueueEvent() avoids | |
3344 | // this problem as the event pointer is not used any more in this | |
3345 | // thread at all after it is called. | |
3346 | QueueEvent(event.Clone()); | |
3347 | } | |
2b854a32 | 3348 | |
8e193f38 | 3349 | void ProcessPendingEvents(); |
7f853dd0 | 3350 | // NOTE: uses ProcessEvent() |
2b854a32 | 3351 | |
cae9e7b1 FM |
3352 | void DeletePendingEvents(); |
3353 | ||
7214297d | 3354 | #if wxUSE_THREADS |
76bfdc9a | 3355 | bool ProcessThreadEvent(const wxEvent& event); |
cae9e7b1 | 3356 | // NOTE: uses AddPendingEvent(); call only from secondary threads |
7214297d | 3357 | #endif |
2b854a32 | 3358 | |
8f6bb260 | 3359 | #ifdef wxHAS_CALL_AFTER |
cf222762 VZ |
3360 | // Asynchronous method calls: these methods schedule the given method |
3361 | // pointer for a later call (during the next idle event loop iteration). | |
3362 | // | |
3363 | // Notice that the method is called on this object itself, so the object | |
3364 | // CallAfter() is called on must have the correct dynamic type. | |
3365 | // | |
3366 | // These method can be used from another thread. | |
3367 | ||
3368 | template <typename T> | |
3369 | void CallAfter(void (T::*method)()) | |
3370 | { | |
3371 | QueueEvent( | |
3372 | new wxAsyncMethodCallEvent0<T>(static_cast<T*>(this), method) | |
3373 | ); | |
3374 | } | |
3375 | ||
3376 | // Notice that we use P1 and not T1 for the parameter to allow passing | |
856cad9a | 3377 | // parameters that are convertible to the type taken by the method |
cf222762 VZ |
3378 | // instead of being exactly the same, to be closer to the usual method call |
3379 | // semantics. | |
3380 | template <typename T, typename T1, typename P1> | |
3381 | void CallAfter(void (T::*method)(T1 x1), P1 x1) | |
3382 | { | |
3383 | QueueEvent( | |
3384 | new wxAsyncMethodCallEvent1<T, T1>( | |
3385 | static_cast<T*>(this), method, x1) | |
3386 | ); | |
3387 | } | |
3388 | ||
3389 | template <typename T, typename T1, typename T2, typename P1, typename P2> | |
3390 | void CallAfter(void (T::*method)(T1 x1, T2 x2), P1 x1, P2 x2) | |
3391 | { | |
3392 | QueueEvent( | |
3393 | new wxAsyncMethodCallEvent2<T, T1, T2>( | |
3394 | static_cast<T*>(this), method, x1, x2) | |
3395 | ); | |
3396 | } | |
8f6bb260 | 3397 | #endif // wxHAS_CALL_AFTER |
cf222762 | 3398 | |
7f853dd0 FM |
3399 | |
3400 | // Connecting and disconnecting | |
3401 | // ---------------------------- | |
3402 | ||
f3ff831f VZ |
3403 | // These functions are used for old, untyped, event handlers and don't |
3404 | // check that the type of the function passed to them actually matches the | |
3405 | // type of the event. They also only allow connecting events to methods of | |
3406 | // wxEvtHandler-derived classes. | |
3407 | // | |
3408 | // The template Connect() methods below are safer and allow connecting | |
3409 | // events to arbitrary functions or functors -- but require compiler | |
3410 | // support for templates. | |
3411 | ||
2b854a32 | 3412 | // Dynamic association of a member function handler with the event handler, |
d9e2e4c2 | 3413 | // winid and event type |
7fa03f04 VZ |
3414 | void Connect(int winid, |
3415 | int lastId, | |
c9c1faa4 | 3416 | wxEventType eventType, |
7fa03f04 | 3417 | wxObjectEventFunction func, |
03f3617b VZ |
3418 | wxObject *userData = NULL, |
3419 | wxEvtHandler *eventSink = NULL) | |
3c778901 | 3420 | { |
890d70eb | 3421 | DoBind(winid, lastId, eventType, |
f3ff831f VZ |
3422 | wxNewEventFunctor(eventType, func, eventSink), |
3423 | userData); | |
3c778901 | 3424 | } |
2b854a32 VZ |
3425 | |
3426 | // Convenience function: take just one id | |
7fa03f04 | 3427 | void Connect(int winid, |
c9c1faa4 | 3428 | wxEventType eventType, |
7fa03f04 | 3429 | wxObjectEventFunction func, |
03f3617b VZ |
3430 | wxObject *userData = NULL, |
3431 | wxEvtHandler *eventSink = NULL) | |
65b17727 | 3432 | { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); } |
2b854a32 | 3433 | |
7fa03f04 | 3434 | // Even more convenient: without id (same as using id of wxID_ANY) |
c9c1faa4 | 3435 | void Connect(wxEventType eventType, |
7fa03f04 | 3436 | wxObjectEventFunction func, |
03f3617b VZ |
3437 | wxObject *userData = NULL, |
3438 | wxEvtHandler *eventSink = NULL) | |
7fa03f04 VZ |
3439 | { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); } |
3440 | ||
3441 | bool Disconnect(int winid, | |
3442 | int lastId, | |
3443 | wxEventType eventType, | |
3444 | wxObjectEventFunction func = NULL, | |
03f3617b VZ |
3445 | wxObject *userData = NULL, |
3446 | wxEvtHandler *eventSink = NULL) | |
3c778901 | 3447 | { |
890d70eb | 3448 | return DoUnbind(winid, lastId, eventType, |
f3ff831f VZ |
3449 | wxMakeEventFunctor(eventType, func, eventSink), |
3450 | userData ); | |
3c778901 | 3451 | } |
7fa03f04 | 3452 | |
e554d626 | 3453 | bool Disconnect(int winid = wxID_ANY, |
7fa03f04 VZ |
3454 | wxEventType eventType = wxEVT_NULL, |
3455 | wxObjectEventFunction func = NULL, | |
03f3617b VZ |
3456 | wxObject *userData = NULL, |
3457 | wxEvtHandler *eventSink = NULL) | |
65b17727 | 3458 | { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); } |
98243fed | 3459 | |
bdbe28fa | 3460 | bool Disconnect(wxEventType eventType, |
e0685bb0 | 3461 | wxObjectEventFunction func, |
03f3617b VZ |
3462 | wxObject *userData = NULL, |
3463 | wxEvtHandler *eventSink = NULL) | |
bdbe28fa | 3464 | { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); } |
f3ff831f | 3465 | |
890d70eb VZ |
3466 | #ifdef wxHAS_EVENT_BIND |
3467 | // Bind functions to an event: | |
3468 | template <typename EventTag, typename EventArg> | |
3469 | void Bind(const EventTag& eventType, | |
3470 | void (*function)(EventArg &), | |
3471 | int winid = wxID_ANY, | |
3472 | int lastId = wxID_ANY, | |
3473 | wxObject *userData = NULL) | |
3474 | { | |
3475 | DoBind(winid, lastId, eventType, | |
3476 | wxNewEventFunctor(eventType, function), | |
3477 | userData); | |
3478 | } | |
3479 | ||
3480 | ||
3481 | template <typename EventTag, typename EventArg> | |
3482 | bool Unbind(const EventTag& eventType, | |
3483 | void (*function)(EventArg &), | |
3484 | int winid = wxID_ANY, | |
3485 | int lastId = wxID_ANY, | |
3486 | wxObject *userData = NULL) | |
3487 | { | |
3488 | return DoUnbind(winid, lastId, eventType, | |
3489 | wxMakeEventFunctor(eventType, function), | |
3490 | userData); | |
3491 | } | |
3492 | ||
3493 | // Bind functors to an event: | |
f3ff831f | 3494 | template <typename EventTag, typename Functor> |
5293e4b7 | 3495 | void Bind(const EventTag& eventType, |
ca6911c3 | 3496 | const Functor &functor, |
5293e4b7 VZ |
3497 | int winid = wxID_ANY, |
3498 | int lastId = wxID_ANY, | |
3499 | wxObject *userData = NULL) | |
f3ff831f | 3500 | { |
890d70eb | 3501 | DoBind(winid, lastId, eventType, |
03ae811e | 3502 | wxNewEventFunctor(eventType, functor), |
f3ff831f | 3503 | userData); |
111d41b2 VZ |
3504 | } |
3505 | ||
111d41b2 | 3506 | |
5293e4b7 VZ |
3507 | template <typename EventTag, typename Functor> |
3508 | bool Unbind(const EventTag& eventType, | |
ca6911c3 | 3509 | const Functor &functor, |
5293e4b7 VZ |
3510 | int winid = wxID_ANY, |
3511 | int lastId = wxID_ANY, | |
3512 | wxObject *userData = NULL) | |
3c778901 | 3513 | { |
890d70eb | 3514 | return DoUnbind(winid, lastId, eventType, |
03ae811e | 3515 | wxMakeEventFunctor(eventType, functor), |
f3ff831f | 3516 | userData); |
3c778901 | 3517 | } |
3c778901 | 3518 | |
f3ff831f | 3519 | |
4c802fdc | 3520 | // Bind a method of a class (called on the specified handler which must |
5293e4b7 | 3521 | // be convertible to this class) object to an event: |
3c778901 | 3522 | |
4c802fdc | 3523 | template <typename EventTag, typename Class, typename EventArg, typename EventHandler> |
5293e4b7 | 3524 | void Bind(const EventTag &eventType, |
03ae811e | 3525 | void (Class::*method)(EventArg &), |
4c802fdc | 3526 | EventHandler *handler, |
5293e4b7 VZ |
3527 | int winid = wxID_ANY, |
3528 | int lastId = wxID_ANY, | |
3529 | wxObject *userData = NULL) | |
f3ff831f | 3530 | { |
890d70eb | 3531 | DoBind(winid, lastId, eventType, |
4c802fdc | 3532 | wxNewEventFunctor(eventType, method, handler), |
f3ff831f | 3533 | userData); |
3c778901 VZ |
3534 | } |
3535 | ||
4c802fdc | 3536 | template <typename EventTag, typename Class, typename EventArg, typename EventHandler> |
5293e4b7 | 3537 | bool Unbind(const EventTag &eventType, |
03ae811e | 3538 | void (Class::*method)(EventArg&), |
4c802fdc | 3539 | EventHandler *handler, |
5293e4b7 VZ |
3540 | int winid = wxID_ANY, |
3541 | int lastId = wxID_ANY, | |
3542 | wxObject *userData = NULL ) | |
f3ff831f | 3543 | { |
890d70eb | 3544 | return DoUnbind(winid, lastId, eventType, |
4c802fdc | 3545 | wxMakeEventFunctor(eventType, method, handler), |
f3ff831f VZ |
3546 | userData); |
3547 | } | |
890d70eb | 3548 | #endif // wxHAS_EVENT_BIND |
3c778901 | 3549 | |
10da6a8f | 3550 | wxList* GetDynamicEventTable() const { return m_dynamicEvents ; } |
b88c44e7 RD |
3551 | |
3552 | // User data can be associated with each wxEvtHandler | |
3553 | void SetClientObject( wxClientData *data ) { DoSetClientObject(data); } | |
3554 | wxClientData *GetClientObject() const { return DoGetClientObject(); } | |
3555 | ||
3556 | void SetClientData( void *data ) { DoSetClientData(data); } | |
3557 | void *GetClientData() const { return DoGetClientData(); } | |
3558 | ||
25250d33 VZ |
3559 | |
3560 | // implementation from now on | |
3561 | // -------------------------- | |
3562 | ||
03f3617b VZ |
3563 | // check if the given event table entry matches this event by id (the check |
3564 | // for the event type should be done by caller) and call the handler if it | |
3565 | // does | |
1c624631 VZ |
3566 | // |
3567 | // return true if the event was processed, false otherwise (no match or the | |
3568 | // handler decided to skip the event) | |
03f3617b VZ |
3569 | static bool ProcessEventIfMatchesId(const wxEventTableEntryBase& tableEntry, |
3570 | wxEvtHandler *handler, | |
3571 | wxEvent& event); | |
b88c44e7 | 3572 | |
8e193f38 | 3573 | virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); |
2b854a32 | 3574 | bool SearchDynamicEventTable( wxEvent& event ); |
c801d85f | 3575 | |
afa039f9 JS |
3576 | // Avoid problems at exit by cleaning up static hash table gracefully |
3577 | void ClearEventHashTable() { GetEventHashTable().Clear(); } | |
2ef989c9 | 3578 | void OnSinkDestroyed( wxEvtHandler *sink ); |
afa039f9 | 3579 | |
25250d33 | 3580 | |
c801d85f | 3581 | private: |
890d70eb | 3582 | void DoBind(int winid, |
3c778901 VZ |
3583 | int lastId, |
3584 | wxEventType eventType, | |
3585 | wxEventFunctor *func, | |
f3ff831f | 3586 | wxObject* userData = NULL); |
3c778901 | 3587 | |
890d70eb | 3588 | bool DoUnbind(int winid, |
f3ff831f VZ |
3589 | int lastId, |
3590 | wxEventType eventType, | |
3591 | const wxEventFunctor& func, | |
3592 | wxObject *userData = NULL); | |
3c778901 | 3593 | |
8e193f38 | 3594 | static const wxEventTableEntry sm_eventTableEntries[]; |
2b854a32 | 3595 | |
c801d85f | 3596 | protected: |
4caf847c VZ |
3597 | // hooks for wxWindow used by ProcessEvent() |
3598 | // ----------------------------------------- | |
3599 | ||
8cc208e3 VZ |
3600 | // this one is called before trying our own event table to allow plugging |
3601 | // in the event handlers overriding the default logic, this is used by e.g. | |
3602 | // validators. | |
2d8c0c2c | 3603 | virtual bool TryBefore(wxEvent& event); |
4caf847c | 3604 | |
4b6d82c7 VZ |
3605 | // This one is not a hook but just a helper which looks up the handler in |
3606 | // this object itself. | |
3607 | // | |
3608 | // It is called from ProcessEventLocally() and normally shouldn't be called | |
3609 | // directly as doing it would ignore any chained event handlers | |
3610 | bool TryHereOnly(wxEvent& event); | |
3611 | ||
3612 | // Another helper which simply calls pre-processing hook and then tries to | |
3613 | // handle the event at this handler level. | |
3614 | bool TryBeforeAndHere(wxEvent& event) | |
3615 | { | |
3616 | return TryBefore(event) || TryHereOnly(event); | |
3617 | } | |
512220b6 | 3618 | |
4caf847c VZ |
3619 | // this one is called after failing to find the event handle in our own |
3620 | // table to give a chance to the other windows to process it | |
3621 | // | |
3622 | // base class implementation passes the event to wxTheApp | |
2d8c0c2c | 3623 | virtual bool TryAfter(wxEvent& event); |
8cc208e3 | 3624 | |
7bc57fd9 | 3625 | #if WXWIN_COMPATIBILITY_2_8 |
8cc208e3 VZ |
3626 | // deprecated method: override TryBefore() instead of this one |
3627 | wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( | |
3628 | virtual bool TryValidator(wxEvent& WXUNUSED(event)), return false; ) | |
3629 | ||
3630 | wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( | |
3631 | virtual bool TryParent(wxEvent& event), return DoTryApp(event); ) | |
3632 | #endif // WXWIN_COMPATIBILITY_2_8 | |
4caf847c VZ |
3633 | |
3634 | ||
1c624631 | 3635 | static const wxEventTable sm_eventTable; |
193bf013 VZ |
3636 | virtual const wxEventTable *GetEventTable() const; |
3637 | ||
b5a98acd VZ |
3638 | static wxEventHashTable sm_eventHashTable; |
3639 | virtual wxEventHashTable& GetEventHashTable() const; | |
3640 | ||
63863e09 JS |
3641 | wxEvtHandler* m_nextHandler; |
3642 | wxEvtHandler* m_previousHandler; | |
63863e09 | 3643 | wxList* m_dynamicEvents; |
42e69d6b | 3644 | wxList* m_pendingEvents; |
6164f93c | 3645 | |
7214297d | 3646 | #if wxUSE_THREADS |
8ebec7dc VZ |
3647 | // critical section protecting m_pendingEvents |
3648 | wxCriticalSection m_pendingEventsLock; | |
3649 | #endif // wxUSE_THREADS | |
193bf013 | 3650 | |
8e193f38 VZ |
3651 | // Is event handler enabled? |
3652 | bool m_enabled; | |
6164f93c | 3653 | |
b88c44e7 RD |
3654 | |
3655 | // The user data: either an object which will be deleted by the container | |
3656 | // when it's deleted or some raw pointer which we do nothing with - only | |
3657 | // one type of data can be used with the given window (i.e. you cannot set | |
3658 | // the void data and then associate the container with wxClientData or vice | |
3659 | // versa) | |
3660 | union | |
3661 | { | |
3662 | wxClientData *m_clientObject; | |
3663 | void *m_clientData; | |
3664 | }; | |
3665 | ||
3666 | // what kind of data do we have? | |
3667 | wxClientDataType m_clientDataType; | |
3668 | ||
3669 | // client data accessors | |
3670 | virtual void DoSetClientObject( wxClientData *data ); | |
3671 | virtual wxClientData *DoGetClientObject() const; | |
3672 | ||
3673 | virtual void DoSetClientData( void *data ); | |
3674 | virtual void *DoGetClientData() const; | |
3675 | ||
2ef989c9 | 3676 | // Search tracker objects for event connection with this sink |
4c802fdc | 3677 | wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *handler); |
2ef989c9 | 3678 | |
6164f93c | 3679 | private: |
8cc208e3 VZ |
3680 | // pass the event to wxTheApp instance, called from TryAfter() |
3681 | bool DoTryApp(wxEvent& event); | |
3682 | ||
3cbb9df8 VZ |
3683 | // try to process events in all handlers chained to this one |
3684 | bool DoTryChain(wxEvent& event); | |
3685 | ||
58cc1587 VZ |
3686 | // Head of the event filter linked list. |
3687 | static wxEventFilter* ms_filterList; | |
3688 | ||
fc7a2a60 | 3689 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler) |
c801d85f KB |
3690 | }; |
3691 | ||
a405cd89 | 3692 | WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler *, wxEvtHandlerArray, class WXDLLIMPEXP_BASE); |
d48b06bd | 3693 | |
8cb2c49f VZ |
3694 | |
3695 | // Define an inline method of wxObjectEventFunctor which couldn't be defined | |
3696 | // before wxEvtHandler declaration: at least Sun CC refuses to compile function | |
3697 | // calls through pointer to member for forward-declared classes (see #12452). | |
3698 | inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& event) | |
3699 | { | |
3700 | wxEvtHandler * const realHandler = m_handler ? m_handler : handler; | |
3701 | ||
3702 | (realHandler->*m_method)(event); | |
3703 | } | |
3704 | ||
cc6ceca7 VZ |
3705 | // ---------------------------------------------------------------------------- |
3706 | // wxEventConnectionRef represents all connections between two event handlers | |
3707 | // and enables automatic disconnect when an event handler sink goes out of | |
3708 | // scope. Each connection/disconnect increases/decreases ref count, and | |
3709 | // when it reaches zero the node goes out of scope. | |
3710 | // ---------------------------------------------------------------------------- | |
3711 | ||
3712 | class wxEventConnectionRef : public wxTrackerNode | |
3713 | { | |
3714 | public: | |
3715 | wxEventConnectionRef() : m_src(NULL), m_sink(NULL), m_refCount(0) { } | |
3716 | wxEventConnectionRef(wxEvtHandler *src, wxEvtHandler *sink) | |
3717 | : m_src(src), m_sink(sink), m_refCount(1) | |
3718 | { | |
3719 | m_sink->AddNode(this); | |
3720 | } | |
3721 | ||
3722 | // The sink is being destroyed | |
3723 | virtual void OnObjectDestroy( ) | |
3724 | { | |
3725 | if ( m_src ) | |
3726 | m_src->OnSinkDestroyed( m_sink ); | |
3727 | delete this; | |
3728 | } | |
3729 | ||
3730 | virtual wxEventConnectionRef *ToEventConnection() { return this; } | |
3731 | ||
3732 | void IncRef() { m_refCount++; } | |
3733 | void DecRef() | |
3734 | { | |
3735 | if ( !--m_refCount ) | |
3736 | { | |
3737 | // The sink holds the only external pointer to this object | |
3738 | if ( m_sink ) | |
3739 | m_sink->RemoveNode(this); | |
3740 | delete this; | |
3741 | } | |
3742 | } | |
3743 | ||
3744 | private: | |
3745 | wxEvtHandler *m_src, | |
3746 | *m_sink; | |
3747 | int m_refCount; | |
3748 | ||
3749 | friend class wxEvtHandler; | |
3750 | ||
c0c133e1 | 3751 | wxDECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef); |
cc6ceca7 VZ |
3752 | }; |
3753 | ||
c3f94162 VZ |
3754 | // Post a message to the given event handler which will be processed during the |
3755 | // next event loop iteration. | |
3756 | // | |
3757 | // Notice that this one is not thread-safe, use wxQueueEvent() | |
76bfdc9a | 3758 | inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event) |
e2478fde | 3759 | { |
c3f94162 | 3760 | wxCHECK_RET( dest, "need an object to post event to" ); |
e2478fde VZ |
3761 | |
3762 | dest->AddPendingEvent(event); | |
3763 | } | |
3764 | ||
c3f94162 VZ |
3765 | // Wrapper around wxEvtHandler::QueueEvent(): adds an event for later |
3766 | // processing, unlike wxPostEvent it is safe to use from different thread even | |
3767 | // for events with wxString members | |
3768 | inline void wxQueueEvent(wxEvtHandler *dest, wxEvent *event) | |
3769 | { | |
3770 | wxCHECK_RET( dest, "need an object to queue event for" ); | |
3771 | ||
3772 | dest->QueueEvent(event); | |
3773 | } | |
3774 | ||
96d38c7e | 3775 | typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); |
85ee6241 | 3776 | typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); |
c1b293bb | 3777 | typedef void (wxEvtHandler::*wxThreadEventFunction)(wxThreadEvent&); |
96d38c7e | 3778 | |
7fa03f04 | 3779 | #define wxEventHandler(func) \ |
3c778901 | 3780 | wxEVENT_HANDLER_CAST(wxEventFunction, func) |
85ee6241 | 3781 | #define wxIdleEventHandler(func) \ |
3c778901 | 3782 | wxEVENT_HANDLER_CAST(wxIdleEventFunction, func) |
c1b293bb VS |
3783 | #define wxThreadEventHandler(func) \ |
3784 | wxEVENT_HANDLER_CAST(wxThreadEventFunction, func) | |
7fa03f04 | 3785 | |
e90c1d2a | 3786 | #if wxUSE_GUI |
7fa03f04 | 3787 | |
c4fa5aa7 VZ |
3788 | // ---------------------------------------------------------------------------- |
3789 | // wxEventBlocker: helper class to temporarily disable event handling for a window | |
3790 | // ---------------------------------------------------------------------------- | |
3791 | ||
b483f5fe | 3792 | class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler |
c4fa5aa7 VZ |
3793 | { |
3794 | public: | |
3795 | wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY); | |
3796 | virtual ~wxEventBlocker(); | |
3797 | ||
3798 | void Block(wxEventType type) | |
3799 | { | |
3800 | m_eventsToBlock.push_back(type); | |
3801 | } | |
3802 | ||
3803 | virtual bool ProcessEvent(wxEvent& event); | |
3804 | ||
3805 | protected: | |
3806 | wxArrayInt m_eventsToBlock; | |
3807 | wxWindow *m_window; | |
3808 | ||
c0c133e1 | 3809 | wxDECLARE_NO_COPY_CLASS(wxEventBlocker); |
c4fa5aa7 VZ |
3810 | }; |
3811 | ||
c801d85f KB |
3812 | typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); |
3813 | typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&); | |
c5b42c87 | 3814 | typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&); |
c801d85f KB |
3815 | typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&); |
3816 | typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&); | |
3817 | typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&); | |
7309deea | 3818 | typedef void (wxEvtHandler::*wxNcPaintEventFunction)(wxNcPaintEvent&); |
c801d85f KB |
3819 | typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&); |
3820 | typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&); | |
3821 | typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&); | |
3822 | typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&); | |
456bc6d9 | 3823 | typedef void (wxEvtHandler::*wxChildFocusEventFunction)(wxChildFocusEvent&); |
c801d85f KB |
3824 | typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&); |
3825 | typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&); | |
3826 | typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&); | |
3827 | typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&); | |
3828 | typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&); | |
7fa03f04 VZ |
3829 | typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&); |
3830 | typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&); | |
c801d85f | 3831 | typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&); |
c801d85f KB |
3832 | typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&); |
3833 | typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&); | |
9bc13858 | 3834 | typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&); |
98e78a5e | 3835 | typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxMaximizeEvent&); |
81d66cf3 | 3836 | typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&); |
f7bd2698 JS |
3837 | typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&); |
3838 | typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&); | |
43b5058d VZ |
3839 | typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&); |
3840 | typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&); | |
3841 | typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&); | |
669f7a11 | 3842 | typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&); |
b96340e6 | 3843 | typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&); |
69231000 | 3844 | typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); |
a5e84126 | 3845 | typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&); |
63e819f2 | 3846 | typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&); |
78c91815 | 3847 | typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&); |
7fa03f04 | 3848 | |
7fa03f04 VZ |
3849 | |
3850 | #define wxCommandEventHandler(func) \ | |
3c778901 | 3851 | wxEVENT_HANDLER_CAST(wxCommandEventFunction, func) |
7fa03f04 | 3852 | #define wxScrollEventHandler(func) \ |
3c778901 | 3853 | wxEVENT_HANDLER_CAST(wxScrollEventFunction, func) |
7fa03f04 | 3854 | #define wxScrollWinEventHandler(func) \ |
3c778901 | 3855 | wxEVENT_HANDLER_CAST(wxScrollWinEventFunction, func) |
7fa03f04 | 3856 | #define wxSizeEventHandler(func) \ |
3c778901 | 3857 | wxEVENT_HANDLER_CAST(wxSizeEventFunction, func) |
7fa03f04 | 3858 | #define wxMoveEventHandler(func) \ |
3c778901 | 3859 | wxEVENT_HANDLER_CAST(wxMoveEventFunction, func) |
7fa03f04 | 3860 | #define wxPaintEventHandler(func) \ |
3c778901 | 3861 | wxEVENT_HANDLER_CAST(wxPaintEventFunction, func) |
7fa03f04 | 3862 | #define wxNcPaintEventHandler(func) \ |
3c778901 | 3863 | wxEVENT_HANDLER_CAST(wxNcPaintEventFunction, func) |
7fa03f04 | 3864 | #define wxEraseEventHandler(func) \ |
3c778901 | 3865 | wxEVENT_HANDLER_CAST(wxEraseEventFunction, func) |
7fa03f04 | 3866 | #define wxMouseEventHandler(func) \ |
3c778901 | 3867 | wxEVENT_HANDLER_CAST(wxMouseEventFunction, func) |
7fa03f04 | 3868 | #define wxCharEventHandler(func) \ |
3c778901 | 3869 | wxEVENT_HANDLER_CAST(wxCharEventFunction, func) |
7fa03f04 VZ |
3870 | #define wxKeyEventHandler(func) wxCharEventHandler(func) |
3871 | #define wxFocusEventHandler(func) \ | |
3c778901 | 3872 | wxEVENT_HANDLER_CAST(wxFocusEventFunction, func) |
7fa03f04 | 3873 | #define wxChildFocusEventHandler(func) \ |
3c778901 | 3874 | wxEVENT_HANDLER_CAST(wxChildFocusEventFunction, func) |
7fa03f04 | 3875 | #define wxActivateEventHandler(func) \ |
3c778901 | 3876 | wxEVENT_HANDLER_CAST(wxActivateEventFunction, func) |
7fa03f04 | 3877 | #define wxMenuEventHandler(func) \ |
3c778901 | 3878 | wxEVENT_HANDLER_CAST(wxMenuEventFunction, func) |
7fa03f04 | 3879 | #define wxJoystickEventHandler(func) \ |
3c778901 | 3880 | wxEVENT_HANDLER_CAST(wxJoystickEventFunction, func) |
7fa03f04 | 3881 | #define wxDropFilesEventHandler(func) \ |
3c778901 | 3882 | wxEVENT_HANDLER_CAST(wxDropFilesEventFunction, func) |
7fa03f04 | 3883 | #define wxInitDialogEventHandler(func) \ |
3c778901 | 3884 | wxEVENT_HANDLER_CAST(wxInitDialogEventFunction, func) |
7fa03f04 | 3885 | #define wxSysColourChangedEventHandler(func) \ |
3c778901 | 3886 | wxEVENT_HANDLER_CAST(wxSysColourChangedEventFunction, func) |
7fa03f04 | 3887 | #define wxDisplayChangedEventHandler(func) \ |
3c778901 | 3888 | wxEVENT_HANDLER_CAST(wxDisplayChangedEventFunction, func) |
7fa03f04 | 3889 | #define wxUpdateUIEventHandler(func) \ |
3c778901 | 3890 | wxEVENT_HANDLER_CAST(wxUpdateUIEventFunction, func) |
7fa03f04 | 3891 | #define wxCloseEventHandler(func) \ |
3c778901 | 3892 | wxEVENT_HANDLER_CAST(wxCloseEventFunction, func) |
7fa03f04 | 3893 | #define wxShowEventHandler(func) \ |
3c778901 | 3894 | wxEVENT_HANDLER_CAST(wxShowEventFunction, func) |
7fa03f04 | 3895 | #define wxIconizeEventHandler(func) \ |
3c778901 | 3896 | wxEVENT_HANDLER_CAST(wxIconizeEventFunction, func) |
7fa03f04 | 3897 | #define wxMaximizeEventHandler(func) \ |
3c778901 | 3898 | wxEVENT_HANDLER_CAST(wxMaximizeEventFunction, func) |
7fa03f04 | 3899 | #define wxNavigationKeyEventHandler(func) \ |
3c778901 | 3900 | wxEVENT_HANDLER_CAST(wxNavigationKeyEventFunction, func) |
7fa03f04 | 3901 | #define wxPaletteChangedEventHandler(func) \ |
3c778901 | 3902 | wxEVENT_HANDLER_CAST(wxPaletteChangedEventFunction, func) |
7fa03f04 | 3903 | #define wxQueryNewPaletteEventHandler(func) \ |
3c778901 | 3904 | wxEVENT_HANDLER_CAST(wxQueryNewPaletteEventFunction, func) |
7fa03f04 | 3905 | #define wxWindowCreateEventHandler(func) \ |
3c778901 | 3906 | wxEVENT_HANDLER_CAST(wxWindowCreateEventFunction, func) |
7fa03f04 | 3907 | #define wxWindowDestroyEventHandler(func) \ |
3c778901 | 3908 | wxEVENT_HANDLER_CAST(wxWindowDestroyEventFunction, func) |
7fa03f04 | 3909 | #define wxSetCursorEventHandler(func) \ |
3c778901 | 3910 | wxEVENT_HANDLER_CAST(wxSetCursorEventFunction, func) |
7fa03f04 | 3911 | #define wxNotifyEventHandler(func) \ |
3c778901 | 3912 | wxEVENT_HANDLER_CAST(wxNotifyEventFunction, func) |
7fa03f04 | 3913 | #define wxHelpEventHandler(func) \ |
3c778901 | 3914 | wxEVENT_HANDLER_CAST(wxHelpEventFunction, func) |
7fa03f04 | 3915 | #define wxContextMenuEventHandler(func) \ |
3c778901 | 3916 | wxEVENT_HANDLER_CAST(wxContextMenuEventFunction, func) |
7fa03f04 | 3917 | #define wxMouseCaptureChangedEventHandler(func) \ |
3c778901 | 3918 | wxEVENT_HANDLER_CAST(wxMouseCaptureChangedEventFunction, func) |
63e819f2 | 3919 | #define wxMouseCaptureLostEventHandler(func) \ |
3c778901 | 3920 | wxEVENT_HANDLER_CAST(wxMouseCaptureLostEventFunction, func) |
78c91815 | 3921 | #define wxClipboardTextEventHandler(func) \ |
3c778901 | 3922 | wxEVENT_HANDLER_CAST(wxClipboardTextEventFunction, func) |
7fa03f04 | 3923 | |
e90c1d2a | 3924 | #endif // wxUSE_GUI |
c801d85f KB |
3925 | |
3926 | // N.B. In GNU-WIN32, you *have* to take the address of a member function | |
3927 | // (use &) or the compiler crashes... | |
3928 | ||
a0e9a5df FM |
3929 | #define wxDECLARE_EVENT_TABLE() \ |
3930 | private: \ | |
3931 | static const wxEventTableEntry sm_eventTableEntries[]; \ | |
3932 | protected: \ | |
3933 | static const wxEventTable sm_eventTable; \ | |
3934 | virtual const wxEventTable* GetEventTable() const; \ | |
3935 | static wxEventHashTable sm_eventHashTable; \ | |
3936 | virtual wxEventHashTable& GetEventHashTable() const | |
c801d85f | 3937 | |
48276300 VZ |
3938 | // N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize |
3939 | // sm_eventTable before using it in GetEventTable() or the compiler gives | |
3940 | // E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews) | |
b5a98acd | 3941 | |
a0e9a5df | 3942 | #define wxBEGIN_EVENT_TABLE(theClass, baseClass) \ |
2e4df4bf VZ |
3943 | const wxEventTable theClass::sm_eventTable = \ |
3944 | { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ | |
48276300 VZ |
3945 | const wxEventTable *theClass::GetEventTable() const \ |
3946 | { return &theClass::sm_eventTable; } \ | |
b5a98acd VZ |
3947 | wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ |
3948 | wxEventHashTable &theClass::GetEventHashTable() const \ | |
3949 | { return theClass::sm_eventHashTable; } \ | |
2e4df4bf | 3950 | const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ |
c801d85f | 3951 | |
a0e9a5df | 3952 | #define wxBEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \ |
f96a9d34 JS |
3953 | template<typename T1> \ |
3954 | const wxEventTable theClass<T1>::sm_eventTable = \ | |
3955 | { &baseClass::sm_eventTable, &theClass<T1>::sm_eventTableEntries[0] }; \ | |
3956 | template<typename T1> \ | |
3957 | const wxEventTable *theClass<T1>::GetEventTable() const \ | |
3958 | { return &theClass<T1>::sm_eventTable; } \ | |
3959 | template<typename T1> \ | |
3960 | wxEventHashTable theClass<T1>::sm_eventHashTable(theClass<T1>::sm_eventTable); \ | |
3961 | template<typename T1> \ | |
3962 | wxEventHashTable &theClass<T1>::GetEventHashTable() const \ | |
3963 | { return theClass<T1>::sm_eventHashTable; } \ | |
3964 | template<typename T1> \ | |
3965 | const wxEventTableEntry theClass<T1>::sm_eventTableEntries[] = { \ | |
3966 | ||
a0e9a5df | 3967 | #define wxBEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \ |
f96a9d34 JS |
3968 | template<typename T1, typename T2> \ |
3969 | const wxEventTable theClass<T1, T2>::sm_eventTable = \ | |
3970 | { &baseClass::sm_eventTable, &theClass<T1, T2>::sm_eventTableEntries[0] }; \ | |
3971 | template<typename T1, typename T2> \ | |
3972 | const wxEventTable *theClass<T1, T2>::GetEventTable() const \ | |
3973 | { return &theClass<T1, T2>::sm_eventTable; } \ | |
3974 | template<typename T1, typename T2> \ | |
3975 | wxEventHashTable theClass<T1, T2>::sm_eventHashTable(theClass<T1, T2>::sm_eventTable); \ | |
3976 | template<typename T1, typename T2> \ | |
3977 | wxEventHashTable &theClass<T1, T2>::GetEventHashTable() const \ | |
3978 | { return theClass<T1, T2>::sm_eventHashTable; } \ | |
3979 | template<typename T1, typename T2> \ | |
3980 | const wxEventTableEntry theClass<T1, T2>::sm_eventTableEntries[] = { \ | |
3981 | ||
a0e9a5df | 3982 | #define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \ |
f96a9d34 JS |
3983 | template<typename T1, typename T2, typename T3> \ |
3984 | const wxEventTable theClass<T1, T2, T3>::sm_eventTable = \ | |
3985 | { &baseClass::sm_eventTable, &theClass<T1, T2, T3>::sm_eventTableEntries[0] }; \ | |
3986 | template<typename T1, typename T2, typename T3> \ | |
3987 | const wxEventTable *theClass<T1, T2, T3>::GetEventTable() const \ | |
3988 | { return &theClass<T1, T2, T3>::sm_eventTable; } \ | |
3989 | template<typename T1, typename T2, typename T3> \ | |
3990 | wxEventHashTable theClass<T1, T2, T3>::sm_eventHashTable(theClass<T1, T2, T3>::sm_eventTable); \ | |
3991 | template<typename T1, typename T2, typename T3> \ | |
3992 | wxEventHashTable &theClass<T1, T2, T3>::GetEventHashTable() const \ | |
3993 | { return theClass<T1, T2, T3>::sm_eventHashTable; } \ | |
3994 | template<typename T1, typename T2, typename T3> \ | |
3995 | const wxEventTableEntry theClass<T1, T2, T3>::sm_eventTableEntries[] = { \ | |
3996 | ||
a0e9a5df | 3997 | #define wxBEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \ |
f96a9d34 JS |
3998 | template<typename T1, typename T2, typename T3, typename T4> \ |
3999 | const wxEventTable theClass<T1, T2, T3, T4>::sm_eventTable = \ | |
4000 | { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4>::sm_eventTableEntries[0] }; \ | |
4001 | template<typename T1, typename T2, typename T3, typename T4> \ | |
4002 | const wxEventTable *theClass<T1, T2, T3, T4>::GetEventTable() const \ | |
4003 | { return &theClass<T1, T2, T3, T4>::sm_eventTable; } \ | |
4004 | template<typename T1, typename T2, typename T3, typename T4> \ | |
4005 | wxEventHashTable theClass<T1, T2, T3, T4>::sm_eventHashTable(theClass<T1, T2, T3, T4>::sm_eventTable); \ | |
4006 | template<typename T1, typename T2, typename T3, typename T4> \ | |
4007 | wxEventHashTable &theClass<T1, T2, T3, T4>::GetEventHashTable() const \ | |
4008 | { return theClass<T1, T2, T3, T4>::sm_eventHashTable; } \ | |
4009 | template<typename T1, typename T2, typename T3, typename T4> \ | |
4010 | const wxEventTableEntry theClass<T1, T2, T3, T4>::sm_eventTableEntries[] = { \ | |
4011 | ||
a0e9a5df | 4012 | #define wxBEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \ |
f96a9d34 JS |
4013 | template<typename T1, typename T2, typename T3, typename T4, typename T5> \ |
4014 | const wxEventTable theClass<T1, T2, T3, T4, T5>::sm_eventTable = \ | |
4015 | { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[0] }; \ | |
4016 | template<typename T1, typename T2, typename T3, typename T4, typename T5> \ | |
4017 | const wxEventTable *theClass<T1, T2, T3, T4, T5>::GetEventTable() const \ | |
4018 | { return &theClass<T1, T2, T3, T4, T5>::sm_eventTable; } \ | |
4019 | template<typename T1, typename T2, typename T3, typename T4, typename T5> \ | |
4020 | wxEventHashTable theClass<T1, T2, T3, T4, T5>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5>::sm_eventTable); \ | |
4021 | template<typename T1, typename T2, typename T3, typename T4, typename T5> \ | |
4022 | wxEventHashTable &theClass<T1, T2, T3, T4, T5>::GetEventHashTable() const \ | |
4023 | { return theClass<T1, T2, T3, T4, T5>::sm_eventHashTable; } \ | |
4024 | template<typename T1, typename T2, typename T3, typename T4, typename T5> \ | |
4025 | const wxEventTableEntry theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[] = { \ | |
4026 | ||
a0e9a5df | 4027 | #define wxBEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \ |
f96a9d34 JS |
4028 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \ |
4029 | const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable = \ | |
4030 | { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[0] }; \ | |
4031 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \ | |
4032 | const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventTable() const \ | |
4033 | { return &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable; } \ | |
4034 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \ | |
4035 | wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable); \ | |
4036 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \ | |
4037 | wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventHashTable() const \ | |
4038 | { return theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable; } \ | |
4039 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \ | |
4040 | const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[] = { \ | |
4041 | ||
a0e9a5df | 4042 | #define wxBEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \ |
f96a9d34 JS |
4043 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \ |
4044 | const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable = \ | |
4045 | { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[0] }; \ | |
4046 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \ | |
4047 | const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventTable() const \ | |
4048 | { return &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable; } \ | |
4049 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \ | |
4050 | wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable); \ | |
4051 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \ | |
4052 | wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventHashTable() const \ | |
4053 | { return theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable; } \ | |
4054 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \ | |
4055 | const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[] = { \ | |
4056 | ||
a0e9a5df FM |
4057 | #define wxEND_EVENT_TABLE() \ |
4058 | wxDECLARE_EVENT_TABLE_TERMINATOR() }; | |
2b854a32 | 4059 | |
c801d85f KB |
4060 | /* |
4061 | * Event table macros | |
4062 | */ | |
4063 | ||
7fa03f04 VZ |
4064 | // helpers for writing shorter code below: declare an event macro taking 2, 1 |
4065 | // or none ids (the missing ids default to wxID_ANY) | |
4066 | // | |
4067 | // macro arguments: | |
4068 | // - evt one of wxEVT_XXX constants | |
4069 | // - id1, id2 ids of the first/last id | |
4070 | // - fn the function (should be cast to the right type) | |
4071 | #define wx__DECLARE_EVT2(evt, id1, id2, fn) \ | |
a0e9a5df | 4072 | wxDECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL), |
7fa03f04 VZ |
4073 | #define wx__DECLARE_EVT1(evt, id, fn) \ |
4074 | wx__DECLARE_EVT2(evt, id, wxID_ANY, fn) | |
4075 | #define wx__DECLARE_EVT0(evt, fn) \ | |
4076 | wx__DECLARE_EVT1(evt, wxID_ANY, fn) | |
4077 | ||
4078 | ||
c801d85f | 4079 | // Generic events |
7fa03f04 VZ |
4080 | #define EVT_CUSTOM(event, winid, func) \ |
4081 | wx__DECLARE_EVT1(event, winid, wxEventHandler(func)) | |
4082 | #define EVT_CUSTOM_RANGE(event, id1, id2, func) \ | |
4083 | wx__DECLARE_EVT2(event, id1, id2, wxEventHandler(func)) | |
c801d85f | 4084 | |
265accbe | 4085 | // EVT_COMMAND |
96eb51bb | 4086 | #define EVT_COMMAND(winid, event, func) \ |
7fa03f04 | 4087 | wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func)) |
3c778901 | 4088 | |
96eb51bb | 4089 | #define EVT_COMMAND_RANGE(id1, id2, event, func) \ |
7fa03f04 | 4090 | wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func)) |
265accbe | 4091 | |
7fa03f04 VZ |
4092 | #define EVT_NOTIFY(event, winid, func) \ |
4093 | wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func)) | |
3c778901 | 4094 | |
7fa03f04 VZ |
4095 | #define EVT_NOTIFY_RANGE(event, id1, id2, func) \ |
4096 | wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func)) | |
265accbe | 4097 | |
c801d85f | 4098 | // Miscellaneous |
7fa03f04 VZ |
4099 | #define EVT_SIZE(func) wx__DECLARE_EVT0(wxEVT_SIZE, wxSizeEventHandler(func)) |
4100 | #define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func)) | |
4101 | #define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func)) | |
4102 | #define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func)) | |
aa767a45 JS |
4103 | #define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func)) |
4104 | #define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func)) | |
7fa03f04 VZ |
4105 | #define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func)) |
4106 | #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func)) | |
4107 | #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func)) | |
4108 | #define EVT_PAINT(func) wx__DECLARE_EVT0(wxEVT_PAINT, wxPaintEventHandler(func)) | |
4109 | #define EVT_NC_PAINT(func) wx__DECLARE_EVT0(wxEVT_NC_PAINT, wxNcPaintEventHandler(func)) | |
4110 | #define EVT_ERASE_BACKGROUND(func) wx__DECLARE_EVT0(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(func)) | |
4111 | #define EVT_CHAR(func) wx__DECLARE_EVT0(wxEVT_CHAR, wxCharEventHandler(func)) | |
4112 | #define EVT_KEY_DOWN(func) wx__DECLARE_EVT0(wxEVT_KEY_DOWN, wxKeyEventHandler(func)) | |
4113 | #define EVT_KEY_UP(func) wx__DECLARE_EVT0(wxEVT_KEY_UP, wxKeyEventHandler(func)) | |
5048c832 | 4114 | #if wxUSE_HOTKEY |
7fa03f04 | 4115 | #define EVT_HOTKEY(winid, func) wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func)) |
5048c832 | 4116 | #endif |
7fa03f04 VZ |
4117 | #define EVT_CHAR_HOOK(func) wx__DECLARE_EVT0(wxEVT_CHAR_HOOK, wxCharEventHandler(func)) |
4118 | #define EVT_MENU_OPEN(func) wx__DECLARE_EVT0(wxEVT_MENU_OPEN, wxMenuEventHandler(func)) | |
4119 | #define EVT_MENU_CLOSE(func) wx__DECLARE_EVT0(wxEVT_MENU_CLOSE, wxMenuEventHandler(func)) | |
4120 | #define EVT_MENU_HIGHLIGHT(winid, func) wx__DECLARE_EVT1(wxEVT_MENU_HIGHLIGHT, winid, wxMenuEventHandler(func)) | |
4121 | #define EVT_MENU_HIGHLIGHT_ALL(func) wx__DECLARE_EVT0(wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler(func)) | |
4122 | #define EVT_SET_FOCUS(func) wx__DECLARE_EVT0(wxEVT_SET_FOCUS, wxFocusEventHandler(func)) | |
4123 | #define EVT_KILL_FOCUS(func) wx__DECLARE_EVT0(wxEVT_KILL_FOCUS, wxFocusEventHandler(func)) | |
4124 | #define EVT_CHILD_FOCUS(func) wx__DECLARE_EVT0(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(func)) | |
4125 | #define EVT_ACTIVATE(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE, wxActivateEventHandler(func)) | |
4126 | #define EVT_ACTIVATE_APP(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE_APP, wxActivateEventHandler(func)) | |
afafd942 | 4127 | #define EVT_HIBERNATE(func) wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func)) |
7fa03f04 VZ |
4128 | #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func)) |
4129 | #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func)) | |
4130 | #define EVT_DROP_FILES(func) wx__DECLARE_EVT0(wxEVT_DROP_FILES, wxDropFilesEventHandler(func)) | |
4131 | #define EVT_INIT_DIALOG(func) wx__DECLARE_EVT0(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(func)) | |
4132 | #define EVT_SYS_COLOUR_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler(func)) | |
4133 | #define EVT_DISPLAY_CHANGED(func) wx__DECLARE_EVT0(wxEVT_DISPLAY_CHANGED, wxDisplayChangedEventHandler(func)) | |
4134 | #define EVT_SHOW(func) wx__DECLARE_EVT0(wxEVT_SHOW, wxShowEventHandler(func)) | |
4135 | #define EVT_MAXIMIZE(func) wx__DECLARE_EVT0(wxEVT_MAXIMIZE, wxMaximizeEventHandler(func)) | |
4136 | #define EVT_ICONIZE(func) wx__DECLARE_EVT0(wxEVT_ICONIZE, wxIconizeEventHandler(func)) | |
4137 | #define EVT_NAVIGATION_KEY(func) wx__DECLARE_EVT0(wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(func)) | |
4138 | #define EVT_PALETTE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_PALETTE_CHANGED, wxPaletteChangedEventHandler(func)) | |
4139 | #define EVT_QUERY_NEW_PALETTE(func) wx__DECLARE_EVT0(wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEventHandler(func)) | |
4140 | #define EVT_WINDOW_CREATE(func) wx__DECLARE_EVT0(wxEVT_CREATE, wxWindowCreateEventHandler(func)) | |
4141 | #define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func)) | |
4142 | #define EVT_SET_CURSOR(func) wx__DECLARE_EVT0(wxEVT_SET_CURSOR, wxSetCursorEventHandler(func)) | |
4143 | #define EVT_MOUSE_CAPTURE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEventHandler(func)) | |
63e819f2 | 4144 | #define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func)) |
c801d85f KB |
4145 | |
4146 | // Mouse events | |
7fa03f04 VZ |
4147 | #define EVT_LEFT_DOWN(func) wx__DECLARE_EVT0(wxEVT_LEFT_DOWN, wxMouseEventHandler(func)) |
4148 | #define EVT_LEFT_UP(func) wx__DECLARE_EVT0(wxEVT_LEFT_UP, wxMouseEventHandler(func)) | |
4149 | #define EVT_MIDDLE_DOWN(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(func)) | |
4150 | #define EVT_MIDDLE_UP(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_UP, wxMouseEventHandler(func)) | |
4151 | #define EVT_RIGHT_DOWN(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DOWN, wxMouseEventHandler(func)) | |
4152 | #define EVT_RIGHT_UP(func) wx__DECLARE_EVT0(wxEVT_RIGHT_UP, wxMouseEventHandler(func)) | |
4153 | #define EVT_MOTION(func) wx__DECLARE_EVT0(wxEVT_MOTION, wxMouseEventHandler(func)) | |
4154 | #define EVT_LEFT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_LEFT_DCLICK, wxMouseEventHandler(func)) | |
4155 | #define EVT_MIDDLE_DCLICK(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(func)) | |
4156 | #define EVT_RIGHT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(func)) | |
4157 | #define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func)) | |
4158 | #define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func)) | |
4159 | #define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func)) | |
01101e2d VZ |
4160 | #define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func)) |
4161 | #define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func)) | |
4162 | #define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func)) | |
4163 | #define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func)) | |
4164 | #define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func)) | |
4165 | #define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func)) | |
c801d85f KB |
4166 | |
4167 | // All mouse events | |
4168 | #define EVT_MOUSE_EVENTS(func) \ | |
7fa03f04 VZ |
4169 | EVT_LEFT_DOWN(func) \ |
4170 | EVT_LEFT_UP(func) \ | |
01101e2d | 4171 | EVT_LEFT_DCLICK(func) \ |
7fa03f04 VZ |
4172 | EVT_MIDDLE_DOWN(func) \ |
4173 | EVT_MIDDLE_UP(func) \ | |
01101e2d | 4174 | EVT_MIDDLE_DCLICK(func) \ |
7fa03f04 VZ |
4175 | EVT_RIGHT_DOWN(func) \ |
4176 | EVT_RIGHT_UP(func) \ | |
7fa03f04 | 4177 | EVT_RIGHT_DCLICK(func) \ |
01101e2d VZ |
4178 | EVT_MOUSE_AUX1_DOWN(func) \ |
4179 | EVT_MOUSE_AUX1_UP(func) \ | |
4180 | EVT_MOUSE_AUX1_DCLICK(func) \ | |
4181 | EVT_MOUSE_AUX2_DOWN(func) \ | |
4182 | EVT_MOUSE_AUX2_UP(func) \ | |
4183 | EVT_MOUSE_AUX2_DCLICK(func) \ | |
4184 | EVT_MOTION(func) \ | |
7fa03f04 VZ |
4185 | EVT_LEAVE_WINDOW(func) \ |
4186 | EVT_ENTER_WINDOW(func) \ | |
4187 | EVT_MOUSEWHEEL(func) | |
c801d85f | 4188 | |
c5b42c87 | 4189 | // Scrolling from wxWindow (sent to wxScrolledWindow) |
7fa03f04 VZ |
4190 | #define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func)) |
4191 | #define EVT_SCROLLWIN_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(func)) | |
4192 | #define EVT_SCROLLWIN_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(func)) | |
4193 | #define EVT_SCROLLWIN_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(func)) | |
4194 | #define EVT_SCROLLWIN_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(func)) | |
4195 | #define EVT_SCROLLWIN_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(func)) | |
4196 | #define EVT_SCROLLWIN_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(func)) | |
4197 | #define EVT_SCROLLWIN_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(func)) | |
4198 | ||
c5b42c87 | 4199 | #define EVT_SCROLLWIN(func) \ |
7fa03f04 VZ |
4200 | EVT_SCROLLWIN_TOP(func) \ |
4201 | EVT_SCROLLWIN_BOTTOM(func) \ | |
4202 | EVT_SCROLLWIN_LINEUP(func) \ | |
4203 | EVT_SCROLLWIN_LINEDOWN(func) \ | |
4204 | EVT_SCROLLWIN_PAGEUP(func) \ | |
4205 | EVT_SCROLLWIN_PAGEDOWN(func) \ | |
4206 | EVT_SCROLLWIN_THUMBTRACK(func) \ | |
4207 | EVT_SCROLLWIN_THUMBRELEASE(func) | |
c5b42c87 RR |
4208 | |
4209 | // Scrolling from wxSlider and wxScrollBar | |
7fa03f04 VZ |
4210 | #define EVT_SCROLL_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_TOP, wxScrollEventHandler(func)) |
4211 | #define EVT_SCROLL_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(func)) | |
4212 | #define EVT_SCROLL_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(func)) | |
4213 | #define EVT_SCROLL_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(func)) | |
4214 | #define EVT_SCROLL_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(func)) | |
4215 | #define EVT_SCROLL_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(func)) | |
4216 | #define EVT_SCROLL_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(func)) | |
4217 | #define EVT_SCROLL_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(func)) | |
cbc85508 | 4218 | #define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func)) |
7fa03f04 | 4219 | |
c801d85f | 4220 | #define EVT_SCROLL(func) \ |
7fa03f04 VZ |
4221 | EVT_SCROLL_TOP(func) \ |
4222 | EVT_SCROLL_BOTTOM(func) \ | |
4223 | EVT_SCROLL_LINEUP(func) \ | |
4224 | EVT_SCROLL_LINEDOWN(func) \ | |
4225 | EVT_SCROLL_PAGEUP(func) \ | |
4226 | EVT_SCROLL_PAGEDOWN(func) \ | |
4227 | EVT_SCROLL_THUMBTRACK(func) \ | |
e8739575 | 4228 | EVT_SCROLL_THUMBRELEASE(func) \ |
84006e65 | 4229 | EVT_SCROLL_CHANGED(func) |
c801d85f | 4230 | |
c5b42c87 | 4231 | // Scrolling from wxSlider and wxScrollBar, with an id |
7fa03f04 VZ |
4232 | #define EVT_COMMAND_SCROLL_TOP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_TOP, winid, wxScrollEventHandler(func)) |
4233 | #define EVT_COMMAND_SCROLL_BOTTOM(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_BOTTOM, winid, wxScrollEventHandler(func)) | |
4234 | #define EVT_COMMAND_SCROLL_LINEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEUP, winid, wxScrollEventHandler(func)) | |
4235 | #define EVT_COMMAND_SCROLL_LINEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEDOWN, winid, wxScrollEventHandler(func)) | |
4236 | #define EVT_COMMAND_SCROLL_PAGEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEUP, winid, wxScrollEventHandler(func)) | |
4237 | #define EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEDOWN, winid, wxScrollEventHandler(func)) | |
4238 | #define EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxScrollEventHandler(func)) | |
4239 | #define EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBRELEASE, winid, wxScrollEventHandler(func)) | |
cbc85508 | 4240 | #define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func)) |
7fa03f04 | 4241 | |
d9e2e4c2 | 4242 | #define EVT_COMMAND_SCROLL(winid, func) \ |
7fa03f04 VZ |
4243 | EVT_COMMAND_SCROLL_TOP(winid, func) \ |
4244 | EVT_COMMAND_SCROLL_BOTTOM(winid, func) \ | |
4245 | EVT_COMMAND_SCROLL_LINEUP(winid, func) \ | |
4246 | EVT_COMMAND_SCROLL_LINEDOWN(winid, func) \ | |
4247 | EVT_COMMAND_SCROLL_PAGEUP(winid, func) \ | |
4248 | EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \ | |
4249 | EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \ | |
e8739575 | 4250 | EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \ |
84006e65 | 4251 | EVT_COMMAND_SCROLL_CHANGED(winid, func) |
cbc85508 | 4252 | |
ca3e85cf WS |
4253 | #if WXWIN_COMPATIBILITY_2_6 |
4254 | // compatibility macros for the old name, deprecated in 2.8 | |
4255 | #define wxEVT_SCROLL_ENDSCROLL wxEVT_SCROLL_CHANGED | |
4256 | #define EVT_COMMAND_SCROLL_ENDSCROLL EVT_COMMAND_SCROLL_CHANGED | |
4257 | #define EVT_SCROLL_ENDSCROLL EVT_SCROLL_CHANGED | |
4258 | #endif // WXWIN_COMPATIBILITY_2_6 | |
c801d85f KB |
4259 | |
4260 | // Convenience macros for commonly-used commands | |
ce7fe42e VZ |
4261 | #define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKBOX, winid, wxCommandEventHandler(func)) |
4262 | #define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_CHOICE, winid, wxCommandEventHandler(func)) | |
4263 | #define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX, winid, wxCommandEventHandler(func)) | |
4264 | #define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX_DCLICK, winid, wxCommandEventHandler(func)) | |
4265 | #define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_MENU, winid, wxCommandEventHandler(func)) | |
4266 | #define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_MENU, id1, id2, wxCommandEventHandler(func)) | |
119727ad | 4267 | #if defined(__SMARTPHONE__) |
7fa03f04 | 4268 | # define EVT_BUTTON(winid, func) EVT_MENU(winid, func) |
119727ad | 4269 | #else |
ce7fe42e | 4270 | # define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_BUTTON, winid, wxCommandEventHandler(func)) |
119727ad | 4271 | #endif |
ce7fe42e VZ |
4272 | #define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_SLIDER, winid, wxCommandEventHandler(func)) |
4273 | #define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBOX, winid, wxCommandEventHandler(func)) | |
4274 | #define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBUTTON, winid, wxCommandEventHandler(func)) | |
c801d85f | 4275 | // EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events |
ce7fe42e VZ |
4276 | #define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLLBAR, winid, wxCommandEventHandler(func)) |
4277 | #define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_VLBOX, winid, wxCommandEventHandler(func)) | |
4278 | #define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX, winid, wxCommandEventHandler(func)) | |
4279 | #define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL, winid, wxCommandEventHandler(func)) | |
4280 | #define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_DROPDOWN, winid, wxCommandEventHandler(func)) | |
4281 | #define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL, id1, id2, wxCommandEventHandler(func)) | |
4282 | #define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_RCLICKED, winid, wxCommandEventHandler(func)) | |
4283 | #define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func)) | |
4284 | #define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_ENTER, winid, wxCommandEventHandler(func)) | |
4285 | #define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKLISTBOX, winid, wxCommandEventHandler(func)) | |
4286 | #define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func)) | |
4287 | #define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func)) | |
c801d85f KB |
4288 | |
4289 | // Generic command events | |
7fa03f04 VZ |
4290 | #define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func)) |
4291 | #define EVT_COMMAND_LEFT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_DCLICK, winid, wxCommandEventHandler(func)) | |
4292 | #define EVT_COMMAND_RIGHT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_CLICK, winid, wxCommandEventHandler(func)) | |
4293 | #define EVT_COMMAND_RIGHT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_DCLICK, winid, wxCommandEventHandler(func)) | |
4294 | #define EVT_COMMAND_SET_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SET_FOCUS, winid, wxCommandEventHandler(func)) | |
4295 | #define EVT_COMMAND_KILL_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_KILL_FOCUS, winid, wxCommandEventHandler(func)) | |
4296 | #define EVT_COMMAND_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_ENTER, winid, wxCommandEventHandler(func)) | |
c801d85f KB |
4297 | |
4298 | // Joystick events | |
1241ab8b | 4299 | |
7fa03f04 VZ |
4300 | #define EVT_JOY_BUTTON_DOWN(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_DOWN, wxJoystickEventHandler(func)) |
4301 | #define EVT_JOY_BUTTON_UP(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_UP, wxJoystickEventHandler(func)) | |
4302 | #define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func)) | |
4303 | #define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func)) | |
c801d85f KB |
4304 | |
4305 | // All joystick events | |
4306 | #define EVT_JOYSTICK_EVENTS(func) \ | |
7fa03f04 VZ |
4307 | EVT_JOY_BUTTON_DOWN(func) \ |
4308 | EVT_JOY_BUTTON_UP(func) \ | |
4309 | EVT_JOY_MOVE(func) \ | |
4310 | EVT_JOY_ZMOVE(func) | |
c801d85f KB |
4311 | |
4312 | // Idle event | |
7fa03f04 | 4313 | #define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func)) |
c801d85f KB |
4314 | |
4315 | // Update UI event | |
7fa03f04 VZ |
4316 | #define EVT_UPDATE_UI(winid, func) wx__DECLARE_EVT1(wxEVT_UPDATE_UI, winid, wxUpdateUIEventHandler(func)) |
4317 | #define EVT_UPDATE_UI_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_UPDATE_UI, id1, id2, wxUpdateUIEventHandler(func)) | |
c801d85f | 4318 | |
b96340e6 | 4319 | // Help events |
7fa03f04 VZ |
4320 | #define EVT_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_HELP, winid, wxHelpEventHandler(func)) |
4321 | #define EVT_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_HELP, id1, id2, wxHelpEventHandler(func)) | |
4322 | #define EVT_DETAILED_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_DETAILED_HELP, winid, wxHelpEventHandler(func)) | |
4323 | #define EVT_DETAILED_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_DETAILED_HELP, id1, id2, wxHelpEventHandler(func)) | |
fb6261e9 | 4324 | |
69231000 | 4325 | // Context Menu Events |
7fa03f04 | 4326 | #define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func)) |
5cd2a6ae | 4327 | #define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func)) |
69231000 | 4328 | |
78c91815 | 4329 | // Clipboard text Events |
ce7fe42e VZ |
4330 | #define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_CUT, winid, wxClipboardTextEventHandler(func)) |
4331 | #define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_COPY, winid, wxClipboardTextEventHandler(func)) | |
4332 | #define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_PASTE, winid, wxClipboardTextEventHandler(func)) | |
78c91815 | 4333 | |
d48b06bd | 4334 | // Thread events |
c1b293bb | 4335 | #define EVT_THREAD(id, func) wx__DECLARE_EVT1(wxEVT_THREAD, id, wxThreadEventHandler(func)) |
d48b06bd | 4336 | |
e90c1d2a VZ |
4337 | // ---------------------------------------------------------------------------- |
4338 | // Helper functions | |
4339 | // ---------------------------------------------------------------------------- | |
4340 | ||
23172836 VZ |
4341 | // This is an ugly hack to allow the use of Bind() instead of Connect() inside |
4342 | // the library code if the library was built with support for it, here is how | |
4343 | // it is used: | |
4344 | // | |
4345 | // class SomeEventHandlingClass : wxBIND_OR_CONNECT_HACK_BASE_CLASS | |
4346 | // public SomeBaseClass | |
4347 | // { | |
4348 | // public: | |
4349 | // SomeEventHandlingClass(wxWindow *win) | |
4350 | // { | |
4351 | // // connect to the event for the given window | |
4352 | // wxBIND_OR_CONNECT_HACK(win, wxEVT_SOMETHING, wxSomeEventHandler, | |
4353 | // SomeEventHandlingClass::OnSomeEvent, this); | |
4354 | // } | |
4355 | // | |
4356 | // private: | |
4357 | // void OnSomeEvent(wxSomeEvent&) { ... } | |
4358 | // }; | |
4359 | // | |
4360 | // This is *not* meant to be used by library users, it is only defined here | |
4361 | // (and not in a private header) because the base class must be visible from | |
4362 | // other public headers, please do NOT use this in your code, it will be | |
4363 | // removed from future wx versions without warning. | |
54a9471a | 4364 | #ifdef wxHAS_EVENT_BIND |
23172836 VZ |
4365 | #define wxBIND_OR_CONNECT_HACK_BASE_CLASS |
4366 | #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS | |
03ef5fef | 4367 | #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \ |
23172836 | 4368 | win->Bind(evt, &func, obj) |
54a9471a VZ |
4369 | #else // wxHAS_EVENT_BIND |
4370 | #define wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxEvtHandler, | |
4371 | #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS : public wxEvtHandler | |
03ef5fef | 4372 | #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \ |
54a9471a | 4373 | win->Connect(evt, handler(func), NULL, obj) |
890d70eb | 4374 | #endif // wxHAS_EVENT_BIND |
23172836 | 4375 | |
e90c1d2a | 4376 | #if wxUSE_GUI |
e702ff0f JS |
4377 | |
4378 | // Find a window with the focus, that is also a descendant of the given window. | |
4379 | // This is used to determine the window to initially send commands to. | |
9f8b9d9c | 4380 | WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor); |
e702ff0f | 4381 | |
e90c1d2a VZ |
4382 | #endif // wxUSE_GUI |
4383 | ||
a0e9a5df FM |
4384 | |
4385 | // ---------------------------------------------------------------------------- | |
4386 | // Compatibility macro aliases | |
4387 | // ---------------------------------------------------------------------------- | |
4388 | ||
4389 | // deprecated variants _not_ requiring a semicolon after them and without wx prefix | |
4390 | // (note that also some wx-prefixed macro do _not_ require a semicolon because | |
4391 | // it's not always possible to force the compire to require it) | |
4392 | ||
4393 | #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ | |
4394 | wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) | |
4395 | #define DECLARE_EVENT_TABLE_TERMINATOR() wxDECLARE_EVENT_TABLE_TERMINATOR() | |
4396 | #define DECLARE_EVENT_TABLE() wxDECLARE_EVENT_TABLE(); | |
4397 | #define BEGIN_EVENT_TABLE(a,b) wxBEGIN_EVENT_TABLE(a,b) | |
4398 | #define BEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) | |
4cf8e24b VZ |
4399 | #define BEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) wxBEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) |
4400 | #define BEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) wxBEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) | |
4401 | #define BEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) wxBEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) | |
4402 | #define BEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) wxBEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) | |
4403 | #define BEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h) wxBEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h) | |
a0e9a5df FM |
4404 | #define END_EVENT_TABLE() wxEND_EVENT_TABLE() |
4405 | ||
4406 | // other obsolete event declaration/definition macros; we don't need them any longer | |
4407 | // but we keep them for compatibility as it doesn't cost us anything anyhow | |
4408 | #define BEGIN_DECLARE_EVENT_TYPES() | |
4409 | #define END_DECLARE_EVENT_TYPES() | |
4410 | #define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ | |
4411 | extern expdecl const wxEventType name; | |
4412 | #define DECLARE_EVENT_TYPE(name, value) \ | |
4413 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) | |
4414 | #define DECLARE_LOCAL_EVENT_TYPE(name, value) \ | |
4415 | DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) | |
4416 | #define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); | |
4417 | #define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) | |
4418 | ||
ce7fe42e VZ |
4419 | // alias for backward compatibility with 2.9.0: |
4420 | #define wxEVT_COMMAND_THREAD wxEVT_THREAD | |
4421 | // other old wxEVT_COMMAND_* constants | |
4422 | #define wxEVT_COMMAND_BUTTON_CLICKED wxEVT_BUTTON | |
4423 | #define wxEVT_COMMAND_CHECKBOX_CLICKED wxEVT_CHECKBOX | |
4424 | #define wxEVT_COMMAND_CHOICE_SELECTED wxEVT_CHOICE | |
4425 | #define wxEVT_COMMAND_LISTBOX_SELECTED wxEVT_LISTBOX | |
4426 | #define wxEVT_COMMAND_LISTBOX_DOUBLECLICKED wxEVT_LISTBOX_DCLICK | |
4427 | #define wxEVT_COMMAND_CHECKLISTBOX_TOGGLED wxEVT_CHECKLISTBOX | |
4428 | #define wxEVT_COMMAND_MENU_SELECTED wxEVT_MENU | |
4429 | #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_TOOL | |
4430 | #define wxEVT_COMMAND_SLIDER_UPDATED wxEVT_SLIDER | |
4431 | #define wxEVT_COMMAND_RADIOBOX_SELECTED wxEVT_RADIOBOX | |
4432 | #define wxEVT_COMMAND_RADIOBUTTON_SELECTED wxEVT_RADIOBUTTON | |
4433 | #define wxEVT_COMMAND_SCROLLBAR_UPDATED wxEVT_SCROLLBAR | |
4434 | #define wxEVT_COMMAND_VLBOX_SELECTED wxEVT_VLBOX | |
4435 | #define wxEVT_COMMAND_COMBOBOX_SELECTED wxEVT_COMBOBOX | |
4436 | #define wxEVT_COMMAND_TOOL_RCLICKED wxEVT_TOOL_RCLICKED | |
4437 | #define wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED wxEVT_TOOL_DROPDOWN | |
4438 | #define wxEVT_COMMAND_TOOL_ENTER wxEVT_TOOL_ENTER | |
4439 | #define wxEVT_COMMAND_COMBOBOX_DROPDOWN wxEVT_COMBOBOX_DROPDOWN | |
4440 | #define wxEVT_COMMAND_COMBOBOX_CLOSEUP wxEVT_COMBOBOX_CLOSEUP | |
4441 | #define wxEVT_COMMAND_TEXT_COPY wxEVT_TEXT_COPY | |
4442 | #define wxEVT_COMMAND_TEXT_CUT wxEVT_TEXT_CUT | |
4443 | #define wxEVT_COMMAND_TEXT_PASTE wxEVT_TEXT_PASTE | |
4444 | #define wxEVT_COMMAND_TEXT_UPDATED wxEVT_TEXT | |
4445 | ||
204abcd4 | 4446 | #endif // _WX_EVENT_H_ |