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