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