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