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