]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
bd83cb56 | 2 | // Name: wx/event.h |
c801d85f KB |
3 | // Purpose: Event classes |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
204abcd4 PC |
12 | #ifndef _WX_EVENT_H_ |
13 | #define _WX_EVENT_H_ | |
c801d85f | 14 | |
c801d85f | 15 | #include "wx/defs.h" |
bde626ce | 16 | #include "wx/cpp.h" |
c801d85f | 17 | #include "wx/object.h" |
341050e2 | 18 | #include "wx/clntdata.h" |
e90c1d2a VZ |
19 | |
20 | #if wxUSE_GUI | |
21 | #include "wx/gdicmn.h" | |
43b5058d | 22 | #include "wx/cursor.h" |
0e097789 | 23 | #include "wx/mousestate.h" |
e90c1d2a | 24 | #endif |
42e69d6b | 25 | |
b5a98acd | 26 | #include "wx/dynarray.h" |
8ebec7dc | 27 | #include "wx/thread.h" |
2ef989c9 | 28 | #include "wx/tracker.h" |
b5a98acd | 29 | |
e90c1d2a VZ |
30 | // ---------------------------------------------------------------------------- |
31 | // forward declarations | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
b5dbe15d | 34 | class WXDLLIMPEXP_FWD_BASE wxList; |
3c778901 | 35 | class WXDLLIMPEXP_FWD_BASE wxEvent; |
e90c1d2a | 36 | #if wxUSE_GUI |
b5dbe15d VS |
37 | class WXDLLIMPEXP_FWD_CORE wxDC; |
38 | class WXDLLIMPEXP_FWD_CORE wxMenu; | |
39 | class WXDLLIMPEXP_FWD_CORE wxWindow; | |
40 | class WXDLLIMPEXP_FWD_CORE wxWindowBase; | |
e90c1d2a VZ |
41 | #endif // wxUSE_GUI |
42 | ||
d1a64f69 VZ |
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 | ||
60 | class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler; | |
cc6ceca7 | 61 | class wxEventConnectionRef; |
432968bf | 62 | |
e90c1d2a VZ |
63 | // ---------------------------------------------------------------------------- |
64 | // Event types | |
65 | // ---------------------------------------------------------------------------- | |
64693098 | 66 | |
cbee8f8d VZ |
67 | typedef int wxEventType; |
68 | ||
c4fa5aa7 VZ |
69 | #define wxEVT_ANY ((wxEventType)-1) |
70 | ||
3a818b15 | 71 | // this is used to make the event table entry type safe, so that for an event |
111d41b2 VZ |
72 | // handler only a function with proper parameter list can be given. See also |
73 | // the wxEVENT_HANDLER_CAST-macro. | |
5c33522f | 74 | #define wxStaticCastEvent(type, val) static_cast<type>(val) |
3a818b15 | 75 | |
d9e2e4c2 | 76 | #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ |
3c778901 VZ |
77 | wxEventTableEntry(type, winid, idLast, wxNewEventFunctor(type, fn), obj) |
78 | ||
79 | #define DECLARE_EVENT_TABLE_TERMINATOR() \ | |
80 | wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0) | |
cbee8f8d | 81 | |
c058cafa VZ |
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 | |
2e4df4bf VZ |
84 | #define BEGIN_DECLARE_EVENT_TYPES() |
85 | #define END_DECLARE_EVENT_TYPES() | |
886dd7d2 VZ |
86 | #define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ |
87 | extern expdecl const wxEventType name; | |
85664da6 | 88 | #define DECLARE_EVENT_TYPE(name, value) \ |
bddd7a8d | 89 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) |
886dd7d2 | 90 | #define DECLARE_LOCAL_EVENT_TYPE(name, value) \ |
bde626ce | 91 | DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) |
71499aaf | 92 | #define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); |
886dd7d2 | 93 | #define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) |
cbee8f8d VZ |
94 | |
95 | // generate a new unique event type | |
bddd7a8d | 96 | extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); |
cbee8f8d | 97 | |
cf516c2b VZ |
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 | ||
111d41b2 | 103 | // New macros to create templatized event types: |
3c778901 VZ |
104 | |
105 | #if wxEVENTS_COMPATIBILITY_2_8 | |
111d41b2 VZ |
106 | |
107 | // Define/Declare a wxEventType-based event type: | |
108 | ||
3c778901 VZ |
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 | ||
111d41b2 VZ |
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 | ||
dca94103 VZ |
119 | #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ |
120 | const wxEventType name = value; | |
3c778901 | 121 | |
dca94103 VZ |
122 | #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ |
123 | extern const expdecl wxEventType name; | |
3c778901 | 124 | |
111d41b2 VZ |
125 | // Declare a local (not exported) wxEventType-based event type: |
126 | ||
3c778901 VZ |
127 | #define wxDECLARE_LOCAL_EVENT( name, type ) \ |
128 | wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) | |
129 | ||
111d41b2 VZ |
130 | // Try to cast the given event handler to the correct handler type: |
131 | ||
3c778901 VZ |
132 | #define wxEVENT_HANDLER_CAST( functype, func ) \ |
133 | ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func ) | |
134 | #else | |
111d41b2 VZ |
135 | // Define/Declare a templatized event type with the corresponding event as |
136 | // a nested typedef: | |
137 | ||
3c778901 VZ |
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 | ||
111d41b2 VZ |
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 | ||
dca94103 VZ |
148 | #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ |
149 | const wxTypedEventType< type > name( value ); | |
3c778901 | 150 | |
dca94103 VZ |
151 | #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ |
152 | extern const expdecl wxTypedEventType< type > name; | |
3c778901 | 153 | |
111d41b2 VZ |
154 | // Declare a local (not exported) templatized event type: |
155 | ||
3c778901 VZ |
156 | #define wxDECLARE_LOCAL_EVENT( name, type ) \ |
157 | wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) | |
158 | ||
111d41b2 VZ |
159 | // Don't cast the given event handler so that wxEvtHandler::Connect() sees |
160 | // the actual type: | |
161 | ||
3c778901 VZ |
162 | #define wxEVENT_HANDLER_CAST( functype, func ) \ |
163 | ( &func ) | |
164 | #endif | |
165 | ||
111d41b2 | 166 | // Template which associates the correct event object with the event type |
3c778901 VZ |
167 | |
168 | #if !wxEVENTS_COMPATIBILITY_2_8 | |
169 | ||
170 | template <typename Event> | |
171 | class WXDLLIMPEXP_BASE wxTypedEventType | |
172 | { | |
173 | public: | |
174 | typedef Event CorrespondingEvent; | |
175 | ||
176 | wxTypedEventType(wxEventType type) { m_type = type; } | |
177 | ||
111d41b2 VZ |
178 | // Return a wxEventType reference for the initialization of the static |
179 | // event tables. See wxEventTableEntry::m_eventType for a more thorough | |
180 | // explanation. | |
3c778901 VZ |
181 | operator const wxEventType&() const { return m_type; } |
182 | ||
183 | private: | |
184 | wxEventType m_type; | |
185 | }; | |
186 | ||
3c778901 VZ |
187 | #endif // !wxEVENTS_COMPATIBILITY_2_8 |
188 | ||
189 | // These are needed for the functor definitions | |
190 | typedef 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. | |
199 | typedef wxEventFunction wxObjectEventFunction; | |
200 | ||
201 | ||
111d41b2 | 202 | // The event functor which is stored in the static and dynamic event tables: |
3c778901 VZ |
203 | class WXDLLIMPEXP_BASE wxEventFunctor |
204 | { | |
205 | public: | |
206 | virtual ~wxEventFunctor(); | |
207 | ||
111d41b2 | 208 | // Invoke the actual event handler: |
3c778901 VZ |
209 | virtual void operator()(wxEvtHandler *, wxEvent &) = 0; |
210 | ||
03f3617b VZ |
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; | |
3c778901 VZ |
214 | |
215 | virtual wxEvtHandler *GetHandler() const { return NULL; } | |
216 | ||
217 | virtual wxObjectEventFunction GetMethod() const { return NULL; } | |
218 | }; | |
219 | ||
220 | // A plain method functor | |
221 | class WXDLLIMPEXP_BASE wxObjectEventFunctor : public wxEventFunctor | |
222 | { | |
223 | public: | |
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 | ||
03f3617b | 237 | virtual bool Matches(const wxEventFunctor& other) const |
3c778901 VZ |
238 | { |
239 | wxEvtHandler * const handler = other.GetHandler(); | |
3c778901 VZ |
240 | |
241 | return (m_handler == handler || !handler) && | |
03f3617b | 242 | (m_method == other.GetMethod()); |
3c778901 VZ |
243 | } |
244 | ||
245 | virtual wxEvtHandler *GetHandler() const { return m_handler; } | |
246 | virtual wxObjectEventFunction GetMethod() const { return m_method; } | |
247 | ||
248 | private: | |
249 | wxEvtHandler *m_handler; | |
250 | wxObjectEventFunction m_method; | |
251 | }; | |
252 | ||
898a466a VZ |
253 | // Create a functor for the legacy events: handler can be NULL and its default |
254 | // value is used by the event table macros | |
03f3617b VZ |
255 | |
256 | inline wxObjectEventFunctor * | |
48def411 | 257 | wxNewEventFunctor(const wxEventType& WXUNUSED(evtType), |
03f3617b | 258 | wxObjectEventFunction method, |
898a466a | 259 | wxEvtHandler *handler = NULL) |
03f3617b VZ |
260 | { |
261 | return new wxObjectEventFunctor(method, handler); | |
262 | } | |
263 | ||
264 | inline wxObjectEventFunctor | |
48def411 | 265 | wxConstructEventFunctor(const wxEventType& WXUNUSED(evtType), |
03f3617b VZ |
266 | wxObjectEventFunction method, |
267 | wxEvtHandler *handler) | |
268 | { | |
269 | return wxObjectEventFunctor(method, handler); | |
270 | } | |
271 | ||
3c778901 VZ |
272 | #if !wxEVENTS_COMPATIBILITY_2_8 |
273 | ||
274 | template <typename EventType> | |
275 | class WXDLLIMPEXP_BASE wxEventFunctorFunction : public wxEventFunctor | |
276 | { | |
277 | public: | |
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 | ||
03f3617b | 292 | virtual bool Matches( const wxEventFunctor &right ) const |
3c778901 VZ |
293 | { |
294 | wxEventFunctorFunction const &other = dynamic_cast< wxEventFunctorFunction const & >( right ); | |
295 | ||
296 | return m_handler == other.m_handler || other.m_handler == NULL; | |
297 | } | |
298 | ||
299 | private: | |
300 | void ( *m_handler )( typename EventType::CorrespondingEvent & ); | |
301 | }; | |
302 | ||
303 | ||
304 | template <typename EventType, typename Class, typename Derived> | |
305 | class WXDLLIMPEXP_BASE wxEventFunctorMethod : public wxEventFunctor | |
306 | { | |
307 | public: | |
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 | ||
03f3617b | 337 | virtual bool Matches( const wxEventFunctor &right ) const |
3c778901 VZ |
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 | ||
361 | private: | |
362 | Derived *m_handler; | |
363 | void (Class::*m_method)(typename EventType::CorrespondingEvent&); | |
364 | }; | |
365 | ||
366 | ||
367 | template <typename EventType, typename Functor> | |
368 | class WXDLLIMPEXP_BASE wxEventFunctorAdapter : public wxEventFunctor | |
369 | { | |
370 | public: | |
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 | ||
03f3617b | 385 | virtual bool Matches( const wxEventFunctor &right ) const |
3c778901 VZ |
386 | { |
387 | wxEventFunctorAdapter const &other = dynamic_cast< wxEventFunctorAdapter const & >( right ); | |
388 | ||
389 | return m_functor == other.m_functor; | |
390 | } | |
391 | ||
392 | private: | |
393 | Functor m_functor; | |
394 | }; | |
395 | ||
3c778901 VZ |
396 | // |
397 | // Create functors for the templatized events (needed in wxEvtHandler::Connect): | |
398 | // | |
399 | ||
400 | // Create a functor for functions: | |
401 | ||
402 | template <typename EventType> | |
403 | inline wxEventFunctorFunction<EventType> * | |
404 | wxNewEventFunctor(const EventType &, | |
405 | void (*function)(typename EventType::CorrespondingEvent&)) | |
406 | { | |
407 | return new wxEventFunctorFunction<EventType>(function); | |
408 | } | |
409 | ||
410 | // Create a functor for methods: | |
411 | ||
412 | template <typename EventType, typename Class> | |
413 | inline wxEventFunctorMethod<EventType, Class, Class> * | |
414 | wxNewEventFunctor(const EventType &, | |
415 | void (Class::*method)(typename EventType::CorrespondingEvent&)) | |
416 | { | |
417 | return new wxEventFunctorMethod<EventType, Class, Class>(method, NULL); | |
418 | } | |
419 | ||
420 | template <typename EventType, typename Class, typename Derived> | |
421 | inline wxEventFunctorMethod<EventType, Class, Derived> * | |
422 | wxNewEventFunctor(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): | |
430 | template <typename EventType, typename Functor> | |
431 | inline wxEventFunctorAdapter<EventType, Functor> * | |
432 | wxNewEventFunctor(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 | ||
444 | template <typename EventType> | |
445 | inline wxEventFunctorFunction<EventType> | |
446 | wxConstructEventFunctor(const EventType &, | |
447 | void (*function)(typename EventType::CorrespondingEvent&)) | |
448 | { | |
449 | return wxEventFunctorFunction<EventType>(function); | |
450 | } | |
451 | ||
452 | // Construct a functor for methods: | |
453 | ||
454 | template <typename EventType, typename Class> | |
455 | inline wxEventFunctorMethod<EventType, Class, Class> | |
456 | wxConstructEventFunctor(const EventType &, | |
457 | void (Class::*method)(typename EventType::CorrespondingEvent&)) | |
458 | { | |
459 | return wxEventFunctorMethod<EventType, Class, Class>(method, NULL); | |
460 | } | |
461 | ||
462 | template <typename EventType, typename Class, typename Derived> | |
463 | inline wxEventFunctorMethod<EventType, Class, Derived> | |
464 | wxConstructEventFunctor(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 | ||
473 | template <typename EventType, typename Functor> | |
474 | inline wxEventFunctorAdapter<EventType, Functor> | |
475 | wxConstructEventFunctor(const EventType &, | |
476 | Functor& functor) | |
477 | { | |
478 | return wxEventFunctorAdapter<EventType, Functor>(functor); | |
479 | } | |
480 | ||
481 | #endif // !wxEVENTS_COMPATIBILITY_2_8 | |
482 | ||
c058cafa VZ |
483 | // many, but not all, standard event types |
484 | ||
485 | // some generic events | |
486 | extern WXDLLIMPEXP_BASE const wxEventType wxEVT_NULL; | |
487 | extern WXDLLIMPEXP_BASE const wxEventType wxEVT_FIRST; | |
488 | extern WXDLLIMPEXP_BASE const wxEventType wxEVT_USER_FIRST; | |
489 | ||
3c778901 VZ |
490 | // Need events declared to do this |
491 | class WXDLLIMPEXP_FWD_CORE wxCommandEvent; | |
492 | class WXDLLIMPEXP_FWD_CORE wxMouseEvent; | |
493 | class WXDLLIMPEXP_FWD_CORE wxFocusEvent; | |
494 | class WXDLLIMPEXP_FWD_CORE wxChildFocusEvent; | |
495 | class WXDLLIMPEXP_FWD_CORE wxKeyEvent; | |
496 | class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent; | |
497 | class WXDLLIMPEXP_FWD_CORE wxSetCursorEvent; | |
498 | class WXDLLIMPEXP_FWD_CORE wxScrollEvent; | |
dca94103 | 499 | class WXDLLIMPEXP_FWD_CORE wxSpinEvent; |
3c778901 VZ |
500 | class WXDLLIMPEXP_FWD_CORE wxScrollWinEvent; |
501 | class WXDLLIMPEXP_FWD_CORE wxSizeEvent; | |
502 | class WXDLLIMPEXP_FWD_CORE wxMoveEvent; | |
503 | class WXDLLIMPEXP_FWD_CORE wxCloseEvent; | |
504 | class WXDLLIMPEXP_FWD_CORE wxActivateEvent; | |
505 | class WXDLLIMPEXP_FWD_CORE wxWindowCreateEvent; | |
506 | class WXDLLIMPEXP_FWD_CORE wxWindowDestroyEvent; | |
507 | class WXDLLIMPEXP_FWD_CORE wxShowEvent; | |
508 | class WXDLLIMPEXP_FWD_CORE wxIconizeEvent; | |
509 | class WXDLLIMPEXP_FWD_CORE wxMaximizeEvent; | |
510 | class WXDLLIMPEXP_FWD_CORE wxMouseCaptureChangedEvent; | |
511 | class WXDLLIMPEXP_FWD_CORE wxMouseCaptureLostEvent; | |
512 | class WXDLLIMPEXP_FWD_CORE wxPaintEvent; | |
513 | class WXDLLIMPEXP_FWD_CORE wxEraseEvent; | |
514 | class WXDLLIMPEXP_FWD_CORE wxNcPaintEvent; | |
515 | class WXDLLIMPEXP_FWD_CORE wxMenuEvent; | |
516 | class WXDLLIMPEXP_FWD_CORE wxContextMenuEvent; | |
517 | class WXDLLIMPEXP_FWD_CORE wxSysColourChangedEvent; | |
518 | class WXDLLIMPEXP_FWD_CORE wxDisplayChangedEvent; | |
519 | class WXDLLIMPEXP_FWD_CORE wxQueryNewPaletteEvent; | |
520 | class WXDLLIMPEXP_FWD_CORE wxPaletteChangedEvent; | |
521 | class WXDLLIMPEXP_FWD_CORE wxJoystickEvent; | |
522 | class WXDLLIMPEXP_FWD_CORE wxDropFilesEvent; | |
523 | class WXDLLIMPEXP_FWD_CORE wxInitDialogEvent; | |
524 | class WXDLLIMPEXP_FWD_CORE wxIdleEvent; | |
525 | class WXDLLIMPEXP_FWD_CORE wxUpdateUIEvent; | |
526 | class WXDLLIMPEXP_FWD_CORE wxClipboardTextEvent; | |
527 | class WXDLLIMPEXP_FWD_CORE wxHelpEvent; | |
528 | ||
529 | ||
c058cafa | 530 | // Command events |
3c778901 VZ |
531 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent) |
532 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEvent) | |
533 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEvent) | |
534 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEvent) | |
535 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEvent) | |
536 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEvent) | |
537 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEvent) | |
538 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SLIDER_UPDATED, wxCommandEvent) | |
539 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEvent) | |
540 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEvent) | |
c058cafa VZ |
541 | |
542 | // wxEVT_COMMAND_SCROLLBAR_UPDATED is deprecated, use wxEVT_SCROLL... events | |
3c778901 VZ |
543 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SCROLLBAR_UPDATED, wxCommandEvent) |
544 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_VLBOX_SELECTED, wxCommandEvent) | |
545 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEvent) | |
546 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_RCLICKED, wxCommandEvent) | |
547 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent) | |
548 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent) | |
c058cafa VZ |
549 | |
550 | // Mouse event types | |
3c778901 VZ |
551 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DOWN, wxMouseEvent) |
552 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_UP, wxMouseEvent) | |
553 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DOWN, wxMouseEvent) | |
554 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_UP, wxMouseEvent) | |
555 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DOWN, wxMouseEvent) | |
556 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_UP, wxMouseEvent) | |
557 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOTION, wxMouseEvent) | |
558 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ENTER_WINDOW, wxMouseEvent) | |
559 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEAVE_WINDOW, wxMouseEvent) | |
560 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DCLICK, wxMouseEvent) | |
561 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DCLICK, wxMouseEvent) | |
562 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DCLICK, wxMouseEvent) | |
563 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_FOCUS, wxFocusEvent) | |
564 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KILL_FOCUS, wxFocusEvent) | |
565 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHILD_FOCUS, wxChildFocusEvent) | |
566 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSEWHEEL, wxMouseEvent) | |
567 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DOWN, wxMouseEvent) | |
568 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_UP, wxMouseEvent) | |
569 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent) | |
570 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent) | |
571 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent) | |
572 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent) | |
c058cafa VZ |
573 | |
574 | // Character input event type | |
3c778901 VZ |
575 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent) |
576 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR_HOOK, wxKeyEvent) | |
577 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent) | |
578 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_DOWN, wxKeyEvent) | |
579 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent) | |
5048c832 | 580 | #if wxUSE_HOTKEY |
3c778901 | 581 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent) |
5048c832 | 582 | #endif |
c058cafa | 583 | // Set cursor event |
3c778901 | 584 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent) |
c058cafa VZ |
585 | |
586 | // wxScrollBar and wxSlider event identifiers | |
3c778901 VZ |
587 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_TOP, wxScrollEvent) |
588 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_BOTTOM, wxScrollEvent) | |
589 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEUP, wxScrollEvent) | |
590 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEDOWN, wxScrollEvent) | |
591 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEUP, wxScrollEvent) | |
592 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEDOWN, wxScrollEvent) | |
593 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBTRACK, wxScrollEvent) | |
594 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBRELEASE, wxScrollEvent) | |
595 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent) | |
c058cafa | 596 | |
dca94103 VZ |
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 | ||
606 | wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent ) | |
607 | wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent ) | |
608 | wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent ) | |
609 | ||
610 | #endif | |
611 | ||
c058cafa | 612 | // Scroll events from wxWindow |
3c778901 VZ |
613 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_TOP, wxScrollWinEvent) |
614 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEvent) | |
615 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEUP, wxScrollWinEvent) | |
616 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEvent) | |
617 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEvent) | |
618 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEvent) | |
619 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEvent) | |
620 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEvent) | |
c058cafa VZ |
621 | |
622 | // System events | |
3c778901 VZ |
623 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZE, wxSizeEvent) |
624 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE, wxMoveEvent) | |
625 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CLOSE_WINDOW, wxCloseEvent) | |
626 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_END_SESSION, wxCloseEvent) | |
627 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_END_SESSION, wxCloseEvent) | |
628 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE_APP, wxActivateEvent) | |
629 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE, wxActivateEvent) | |
630 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CREATE, wxWindowCreateEvent) | |
631 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DESTROY, wxWindowDestroyEvent) | |
632 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SHOW, wxShowEvent) | |
633 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ICONIZE, wxIconizeEvent) | |
634 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAXIMIZE, wxMaximizeEvent) | |
635 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEvent) | |
636 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEvent) | |
637 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PAINT, wxPaintEvent) | |
638 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ERASE_BACKGROUND, wxEraseEvent) | |
639 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NC_PAINT, wxNcPaintEvent) | |
640 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_OPEN, wxMenuEvent) | |
641 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_CLOSE, wxMenuEvent) | |
642 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_HIGHLIGHT, wxMenuEvent) | |
643 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CONTEXT_MENU, wxContextMenuEvent) | |
644 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEvent) | |
645 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DISPLAY_CHANGED, wxDisplayChangedEvent) | |
646 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEvent) | |
647 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PALETTE_CHANGED, wxPaletteChangedEvent) | |
648 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_DOWN, wxJoystickEvent) | |
649 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_UP, wxJoystickEvent) | |
650 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_MOVE, wxJoystickEvent) | |
651 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_ZMOVE, wxJoystickEvent) | |
652 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DROP_FILES, wxDropFilesEvent) | |
653 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_INIT_DIALOG, wxInitDialogEvent) | |
654 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_IDLE, wxIdleEvent) | |
655 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_UPDATE_UI, wxUpdateUIEvent) | |
656 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZING, wxSizeEvent) | |
657 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVING, wxMoveEvent) | |
658 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_START, wxMoveEvent) | |
659 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_END, wxMoveEvent) | |
660 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HIBERNATE, wxActivateEvent) | |
c058cafa VZ |
661 | |
662 | // Clipboard events | |
3c778901 VZ |
663 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_COPY, wxClipboardTextEvent) |
664 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_CUT, wxClipboardTextEvent) | |
665 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_PASTE, wxClipboardTextEvent) | |
c058cafa VZ |
666 | |
667 | // Generic command events | |
668 | // Note: a click is a higher-level event than button down/up | |
3c778901 VZ |
669 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_CLICK, wxCommandEvent) |
670 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_DCLICK, wxCommandEvent) | |
671 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEvent) | |
672 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_DCLICK, wxCommandEvent) | |
673 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SET_FOCUS, wxCommandEvent) | |
674 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_KILL_FOCUS, wxCommandEvent) | |
675 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_ENTER, wxCommandEvent) | |
c058cafa VZ |
676 | |
677 | // Help events | |
3c778901 VZ |
678 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HELP, wxHelpEvent) |
679 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent) | |
96f6c703 | 680 | |
cbee8f8d VZ |
681 | // these 2 events are the same |
682 | #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED | |
96f6c703 | 683 | |
ad0bae85 | 684 | // ---------------------------------------------------------------------------- |
77d4384e | 685 | // Compatibility |
ad0bae85 VZ |
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 | |
3c778901 | 692 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent) |
c801d85f | 693 | |
1648d51b VZ |
694 | // the predefined constants for the number of times we propagate event |
695 | // upwards window child-parent chain | |
696 | enum 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 | ||
c801d85f | 705 | /* |
77ffb593 | 706 | * wxWidgets events, covering all interesting things that might happen |
c801d85f KB |
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 | ||
bddd7a8d | 717 | class WXDLLIMPEXP_BASE wxEvent : public wxObject |
c801d85f | 718 | { |
c801d85f | 719 | public: |
d9e2e4c2 | 720 | wxEvent(int winid = 0, wxEventType commandType = wxEVT_NULL ); |
2b854a32 VZ |
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() | |
a0d9c6cb WS |
734 | // is the analog of calling the base class version of a virtual function) |
735 | void Skip(bool skip = true) { m_skipped = skip; } | |
47b378bd | 736 | bool GetSkipped() const { return m_skipped; } |
c801d85f | 737 | |
29de6f40 | 738 | // This function is used to create a copy of the event polymorphically and |
acd15a3f VZ |
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; | |
a737331d | 742 | |
87b6002d | 743 | // Implementation only: this test is explicitly anti OO and this function |
1648d51b VZ |
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 | ||
29de6f40 VZ |
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 | ||
b4b76d61 | 781 | protected: |
2b854a32 | 782 | wxObject* m_eventObject; |
2b854a32 VZ |
783 | wxEventType m_eventType; |
784 | long m_timeStamp; | |
785 | int m_id; | |
b4b76d61 KH |
786 | |
787 | public: | |
788 | // m_callbackUserData is for internal usage only | |
2b854a32 | 789 | wxObject* m_callbackUserData; |
1648d51b VZ |
790 | |
791 | protected: | |
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 | ||
42e69d6b | 799 | bool m_skipped; |
193bf013 | 800 | bool m_isCommandEvent; |
1c624631 | 801 | |
29de6f40 VZ |
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 | ||
0e097789 VZ |
808 | protected: |
809 | wxEvent(const wxEvent&); // for implementing Clone() | |
810 | wxEvent& operator=(const wxEvent&); // for derived classes operator=() | |
811 | ||
8e72b8b5 | 812 | private: |
1648d51b | 813 | // it needs to access our m_propagationLevel |
b5dbe15d | 814 | friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce; |
1648d51b | 815 | |
8e72b8b5 | 816 | DECLARE_ABSTRACT_CLASS(wxEvent) |
c801d85f KB |
817 | }; |
818 | ||
1648d51b VZ |
819 | /* |
820 | * Helper class to temporarily change an event not to propagate. | |
821 | */ | |
822 | class WXDLLIMPEXP_BASE wxPropagationDisabler | |
823 | { | |
824 | public: | |
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 | ||
835 | private: | |
836 | wxEvent& m_event; | |
837 | int m_propagationLevelOld; | |
fc7a2a60 VZ |
838 | |
839 | DECLARE_NO_COPY_CLASS(wxPropagationDisabler) | |
1648d51b VZ |
840 | }; |
841 | ||
842 | /* | |
843 | * Another one to temporarily lower propagation level. | |
844 | */ | |
845 | class WXDLLIMPEXP_BASE wxPropagateOnce | |
846 | { | |
847 | public: | |
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 | ||
861 | private: | |
862 | wxEvent& m_event; | |
fc7a2a60 VZ |
863 | |
864 | DECLARE_NO_COPY_CLASS(wxPropagateOnce) | |
1648d51b VZ |
865 | }; |
866 | ||
c4fa5aa7 | 867 | |
e90c1d2a VZ |
868 | #if wxUSE_GUI |
869 | ||
1648d51b | 870 | |
c801d85f KB |
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 | |
1db8dc4a | 887 | wxEVT_COMMAND_TOGGLEBUTTON_CLICKED |
c801d85f KB |
888 | */ |
889 | ||
bddd7a8d | 890 | class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent |
c801d85f | 891 | { |
2b854a32 | 892 | public: |
d9e2e4c2 | 893 | wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); |
c801d85f | 894 | |
e6a6feba | 895 | wxCommandEvent(const wxCommandEvent& event) |
497dbbd3 | 896 | : wxEvent(event), |
c3f94162 | 897 | m_cmdString(event.m_cmdString), |
497dbbd3 VZ |
898 | m_commandInt(event.m_commandInt), |
899 | m_extraLong(event.m_extraLong), | |
900 | m_clientData(event.m_clientData), | |
901 | m_clientObject(event.m_clientObject) | |
e6a6feba GD |
902 | { } |
903 | ||
2b854a32 VZ |
904 | // Set/Get client data from controls |
905 | void SetClientData(void* clientData) { m_clientData = clientData; } | |
906 | void *GetClientData() const { return m_clientData; } | |
c801d85f | 907 | |
2b854a32 VZ |
908 | // Set/Get client object from controls |
909 | void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; } | |
88eadcf2 | 910 | wxClientData *GetClientObject() const { return m_clientObject; } |
f5e27805 | 911 | |
2b854a32 VZ |
912 | // Get listbox selection if single-choice |
913 | int GetSelection() const { return m_commandInt; } | |
c801d85f | 914 | |
2b854a32 | 915 | // Set/Get listbox/choice selection string |
b4b76d61 KH |
916 | void SetString(const wxString& s) { m_cmdString = s; } |
917 | wxString GetString() const; | |
c801d85f | 918 | |
2b854a32 | 919 | // Get checkbox value |
3ca6a5f0 | 920 | bool IsChecked() const { return m_commandInt != 0; } |
c801d85f | 921 | |
a0d9c6cb | 922 | // true if the listbox event was a selection. |
2b854a32 | 923 | bool IsSelection() const { return (m_extraLong != 0); } |
c801d85f | 924 | |
2b854a32 | 925 | void SetExtraLong(long extraLong) { m_extraLong = extraLong; } |
a7bc03c9 | 926 | long GetExtraLong() const { return m_extraLong; } |
c801d85f | 927 | |
2b854a32 | 928 | void SetInt(int i) { m_commandInt = i; } |
fd587c7a | 929 | int GetInt() const { return m_commandInt; } |
c801d85f | 930 | |
8e72b8b5 | 931 | virtual wxEvent *Clone() const { return new wxCommandEvent(*this); } |
aadbdf11 | 932 | |
b4b76d61 | 933 | protected: |
b4b76d61 | 934 | wxString m_cmdString; // String event argument |
2b854a32 VZ |
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 | |
f97500b8 | 939 | |
8e72b8b5 | 940 | private: |
fc7a2a60 | 941 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent) |
c801d85f KB |
942 | }; |
943 | ||
fd3f686c VZ |
944 | // this class adds a possibility to react (from the user) code to a control |
945 | // notification: allow or veto the operation being reported. | |
bddd7a8d | 946 | class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent |
fd3f686c VZ |
947 | { |
948 | public: | |
d9e2e4c2 DE |
949 | wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) |
950 | : wxCommandEvent(commandType, winid) | |
a0d9c6cb | 951 | { m_bAllow = true; } |
e6a6feba GD |
952 | |
953 | wxNotifyEvent(const wxNotifyEvent& event) | |
954 | : wxCommandEvent(event) | |
497dbbd3 | 955 | { m_bAllow = event.m_bAllow; } |
fd3f686c | 956 | |
23f681ec | 957 | // veto the operation (usually it's allowed by default) |
a0d9c6cb | 958 | void Veto() { m_bAllow = false; } |
fd3f686c | 959 | |
23f681ec | 960 | // allow the operation if it was disabled by default |
a0d9c6cb | 961 | void Allow() { m_bAllow = true; } |
23f681ec | 962 | |
fd3f686c VZ |
963 | // for implementation code only: is the operation allowed? |
964 | bool IsAllowed() const { return m_bAllow; } | |
965 | ||
8e72b8b5 | 966 | virtual wxEvent *Clone() const { return new wxNotifyEvent(*this); } |
924ef850 | 967 | |
fd3f686c VZ |
968 | private: |
969 | bool m_bAllow; | |
970 | ||
8e72b8b5 | 971 | private: |
fc7a2a60 | 972 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent) |
fd3f686c VZ |
973 | }; |
974 | ||
d1367c3d | 975 | // Scroll event class, derived form wxCommandEvent. wxScrollEvents are |
e8b669d3 | 976 | // sent by wxSlider and wxScrollBar. |
c801d85f KB |
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 | |
7d56fb8f | 985 | wxEVT_SCROLL_THUMBRELEASE |
cbc85508 | 986 | wxEVT_SCROLL_CHANGED |
c801d85f KB |
987 | */ |
988 | ||
bddd7a8d | 989 | class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent |
c801d85f | 990 | { |
2b854a32 VZ |
991 | public: |
992 | wxScrollEvent(wxEventType commandType = wxEVT_NULL, | |
d9e2e4c2 | 993 | int winid = 0, int pos = 0, int orient = 0); |
2b854a32 | 994 | |
a7bc03c9 VZ |
995 | int GetOrientation() const { return (int) m_extraLong; } |
996 | int GetPosition() const { return m_commandInt; } | |
2b854a32 VZ |
997 | void SetOrientation(int orient) { m_extraLong = (long) orient; } |
998 | void SetPosition(int pos) { m_commandInt = pos; } | |
f97500b8 | 999 | |
8e72b8b5 | 1000 | virtual wxEvent *Clone() const { return new wxScrollEvent(*this); } |
f97500b8 | 1001 | |
8e72b8b5 | 1002 | private: |
fc7a2a60 | 1003 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent) |
c801d85f KB |
1004 | }; |
1005 | ||
d1367c3d RR |
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 | |
7d56fb8f | 1016 | wxEVT_SCROLLWIN_THUMBRELEASE |
d1367c3d RR |
1017 | */ |
1018 | ||
bddd7a8d | 1019 | class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent |
d1367c3d | 1020 | { |
d1367c3d RR |
1021 | public: |
1022 | wxScrollWinEvent(wxEventType commandType = wxEVT_NULL, | |
1023 | int pos = 0, int orient = 0); | |
b2697d42 VZ |
1024 | wxScrollWinEvent(const wxScrollWinEvent & event) : wxEvent(event) |
1025 | { m_commandInt = event.m_commandInt; | |
1026 | m_extraLong = event.m_extraLong; } | |
d1367c3d | 1027 | |
a7bc03c9 VZ |
1028 | int GetOrientation() const { return (int) m_extraLong; } |
1029 | int GetPosition() const { return m_commandInt; } | |
d1367c3d RR |
1030 | void SetOrientation(int orient) { m_extraLong = (long) orient; } |
1031 | void SetPosition(int pos) { m_commandInt = pos; } | |
1032 | ||
8e72b8b5 | 1033 | virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); } |
1e6feb95 | 1034 | |
b4b76d61 | 1035 | protected: |
8e72b8b5 | 1036 | int m_commandInt; |
20947e08 | 1037 | long m_extraLong; |
1e6feb95 | 1038 | |
8e72b8b5 | 1039 | private: |
fc7a2a60 | 1040 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent) |
d1367c3d RR |
1041 | }; |
1042 | ||
c801d85f KB |
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 | ||
497dbbd3 VZ |
1072 | // the symbolic names for the mouse buttons |
1073 | enum | |
1074 | { | |
1075 | wxMOUSE_BTN_ANY = -1, | |
3e89999c VZ |
1076 | wxMOUSE_BTN_NONE = 0, |
1077 | wxMOUSE_BTN_LEFT = 1, | |
1078 | wxMOUSE_BTN_MIDDLE = 2, | |
01101e2d VZ |
1079 | wxMOUSE_BTN_RIGHT = 3, |
1080 | wxMOUSE_BTN_AUX1 = 4, | |
1081 | wxMOUSE_BTN_AUX2 = 5, | |
1082 | wxMOUSE_BTN_MAX | |
497dbbd3 VZ |
1083 | }; |
1084 | ||
0e097789 VZ |
1085 | class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent, |
1086 | public wxMouseState | |
c801d85f | 1087 | { |
2b854a32 VZ |
1088 | public: |
1089 | wxMouseEvent(wxEventType mouseType = wxEVT_NULL); | |
0e097789 VZ |
1090 | wxMouseEvent(const wxMouseEvent& event) |
1091 | : wxEvent(event), | |
1092 | wxMouseState(event) | |
1093 | { | |
1094 | Assign(event); | |
1095 | } | |
c801d85f | 1096 | |
2b854a32 | 1097 | // Was it a button event? (*doesn't* mean: is any button *down*?) |
497dbbd3 | 1098 | bool IsButton() const { return Button(wxMOUSE_BTN_ANY); } |
c801d85f | 1099 | |
3e89999c | 1100 | // Was it a down event from this (or any) button? |
497dbbd3 | 1101 | bool ButtonDown(int but = wxMOUSE_BTN_ANY) const; |
c801d85f | 1102 | |
3e89999c | 1103 | // Was it a dclick event from this (or any) button? |
497dbbd3 | 1104 | bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const; |
c801d85f | 1105 | |
3e89999c | 1106 | // Was it a up event from this (or any) button? |
497dbbd3 | 1107 | bool ButtonUp(int but = wxMOUSE_BTN_ANY) const; |
c801d85f | 1108 | |
3e89999c | 1109 | // Was the given button? |
2b854a32 | 1110 | bool Button(int but) const; |
c801d85f | 1111 | |
3e89999c | 1112 | // Was the given button in Down state? |
2b854a32 | 1113 | bool ButtonIsDown(int but) const; |
c801d85f | 1114 | |
497dbbd3 | 1115 | // Get the button which is changing state (wxMOUSE_BTN_NONE if none) |
1e6feb95 VZ |
1116 | int GetButton() const; |
1117 | ||
2b854a32 VZ |
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); } | |
01101e2d VZ |
1122 | bool Aux1Down() const { return (m_eventType == wxEVT_AUX1_DOWN); } |
1123 | bool Aux2Down() const { return (m_eventType == wxEVT_AUX2_DOWN); } | |
c801d85f | 1124 | |
2b854a32 VZ |
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); } | |
01101e2d VZ |
1128 | bool Aux1Up() const { return (m_eventType == wxEVT_AUX1_UP); } |
1129 | bool Aux2Up() const { return (m_eventType == wxEVT_AUX2_UP); } | |
c801d85f | 1130 | |
2b854a32 VZ |
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); } | |
01101e2d VZ |
1134 | bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_UP); } |
1135 | bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_UP); } | |
c801d85f | 1136 | |
2b854a32 VZ |
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; } | |
01101e2d VZ |
1142 | bool Aux1IsDown() const { return m_aux1Down; } |
1143 | bool Aux2IsDown() const { return m_aux2Down; } | |
c801d85f | 1144 | |
2b854a32 VZ |
1145 | // True if a button is down and the mouse is moving |
1146 | bool Dragging() const | |
1147 | { | |
5b66d31a | 1148 | return (m_eventType == wxEVT_MOTION) && ButtonIsDown(wxMOUSE_BTN_ANY); |
2b854a32 | 1149 | } |
c801d85f | 1150 | |
2b854a32 | 1151 | // True if the mouse is moving, and no button is down |
6f63704f VZ |
1152 | bool Moving() const |
1153 | { | |
5b66d31a | 1154 | return (m_eventType == wxEVT_MOTION) && !ButtonIsDown(wxMOUSE_BTN_ANY); |
6f63704f | 1155 | } |
c801d85f | 1156 | |
2b854a32 VZ |
1157 | // True if the mouse is just entering the window |
1158 | bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); } | |
c801d85f | 1159 | |
2b854a32 VZ |
1160 | // True if the mouse is just leaving the window |
1161 | bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); } | |
c801d85f | 1162 | |
8866abbb VZ |
1163 | // Returns the number of mouse clicks associated with this event. |
1164 | int GetClickCount() const { return m_clickCount; } | |
1165 | ||
1166 | ||
2b854a32 | 1167 | // Find the position of the event |
20947e08 | 1168 | void GetPosition(wxCoord *xpos, wxCoord *ypos) const |
b02da6b1 VZ |
1169 | { |
1170 | if (xpos) | |
20947e08 | 1171 | *xpos = m_x; |
b02da6b1 VZ |
1172 | if (ypos) |
1173 | *ypos = m_y; | |
1174 | } | |
1175 | ||
bf57d1ad | 1176 | void GetPosition(long *xpos, long *ypos) const |
b02da6b1 VZ |
1177 | { |
1178 | if (xpos) | |
20947e08 | 1179 | *xpos = (long)m_x; |
b02da6b1 | 1180 | if (ypos) |
bf57d1ad | 1181 | *ypos = (long)m_y; |
b02da6b1 | 1182 | } |
c801d85f | 1183 | |
2b854a32 VZ |
1184 | // Find the position of the event |
1185 | wxPoint GetPosition() const { return wxPoint(m_x, m_y); } | |
c801d85f | 1186 | |
2b854a32 | 1187 | // Find the logical position of the event given the DC |
a7bc03c9 | 1188 | wxPoint GetLogicalPosition(const wxDC& dc) const; |
c801d85f | 1189 | |
2b854a32 | 1190 | // Get X position |
6cedba09 | 1191 | wxCoord GetX() const { return m_x; } |
c801d85f | 1192 | |
2b854a32 | 1193 | // Get Y position |
6cedba09 | 1194 | wxCoord GetY() const { return m_y; } |
c801d85f | 1195 | |
d2c52078 RD |
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 | ||
aea37008 SC |
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 | ||
d2c52078 RD |
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; } | |
aa767a45 | 1218 | |
9b9337da | 1219 | // Is the system set to do page scrolling? |
c2bbeff0 | 1220 | bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); } |
9b9337da | 1221 | |
8e72b8b5 | 1222 | virtual wxEvent *Clone() const { return new wxMouseEvent(*this); } |
aadbdf11 | 1223 | |
0e097789 VZ |
1224 | wxMouseEvent& operator=(const wxMouseEvent& event) |
1225 | { | |
1226 | if (&event != this) | |
1227 | Assign(event); | |
1228 | return *this; | |
1229 | } | |
c7d176e2 | 1230 | |
c801d85f | 1231 | public: |
b02da6b1 VZ |
1232 | wxCoord m_x, m_y; |
1233 | ||
2b854a32 VZ |
1234 | bool m_leftDown; |
1235 | bool m_middleDown; | |
1236 | bool m_rightDown; | |
01101e2d VZ |
1237 | bool m_aux1Down; |
1238 | bool m_aux2Down; | |
2b854a32 | 1239 | |
8866abbb VZ |
1240 | int m_clickCount; |
1241 | ||
aea37008 | 1242 | int m_wheelAxis; |
d2c52078 RD |
1243 | int m_wheelRotation; |
1244 | int m_wheelDelta; | |
1245 | int m_linesPerAction; | |
1e6feb95 | 1246 | |
abcbaea7 VZ |
1247 | protected: |
1248 | void Assign(const wxMouseEvent& evt); | |
1249 | ||
1e6feb95 VZ |
1250 | private: |
1251 | DECLARE_DYNAMIC_CLASS(wxMouseEvent) | |
c801d85f KB |
1252 | }; |
1253 | ||
43b5058d VZ |
1254 | // Cursor set event |
1255 | ||
1256 | /* | |
1257 | wxEVT_SET_CURSOR | |
1258 | */ | |
1259 | ||
bddd7a8d | 1260 | class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent |
43b5058d VZ |
1261 | { |
1262 | public: | |
8e72b8b5 | 1263 | wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0) |
497dbbd3 VZ |
1264 | : wxEvent(0, wxEVT_SET_CURSOR), |
1265 | m_x(x), m_y(y), m_cursor() | |
e6a6feba | 1266 | { } |
43b5058d | 1267 | |
b2697d42 VZ |
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 | { } | |
1d2eddff | 1274 | |
43b5058d VZ |
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 | ||
8e72b8b5 | 1282 | virtual wxEvent *Clone() const { return new wxSetCursorEvent(*this); } |
f97500b8 | 1283 | |
43b5058d VZ |
1284 | private: |
1285 | wxCoord m_x, m_y; | |
1286 | wxCursor m_cursor; | |
f97500b8 | 1287 | |
8e72b8b5 | 1288 | private: |
fc7a2a60 | 1289 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent) |
43b5058d VZ |
1290 | }; |
1291 | ||
c801d85f KB |
1292 | // Keyboard input event class |
1293 | ||
1294 | /* | |
1295 | wxEVT_CHAR | |
1296 | wxEVT_CHAR_HOOK | |
4ce81a75 | 1297 | wxEVT_KEY_DOWN |
c801d85f | 1298 | wxEVT_KEY_UP |
5048c832 | 1299 | wxEVT_HOTKEY |
c801d85f KB |
1300 | */ |
1301 | ||
0e097789 VZ |
1302 | class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent, |
1303 | public wxKeyboardState | |
c801d85f | 1304 | { |
c801d85f | 1305 | public: |
2b854a32 | 1306 | wxKeyEvent(wxEventType keyType = wxEVT_NULL); |
b2697d42 | 1307 | wxKeyEvent(const wxKeyEvent& evt); |
c801d85f | 1308 | |
f6bcfd97 BP |
1309 | // get the key code: an ASCII7 char or an element of wxKeyCode enum |
1310 | int GetKeyCode() const { return (int)m_keyCode; } | |
c801d85f | 1311 | |
a3db5254 VZ |
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 | ||
9c7df356 VZ |
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 | ||
2b854a32 | 1323 | // Find the position of the event |
b02da6b1 VZ |
1324 | void GetPosition(wxCoord *xpos, wxCoord *ypos) const |
1325 | { | |
20947e08 | 1326 | if (xpos) *xpos = m_x; |
b02da6b1 VZ |
1327 | if (ypos) *ypos = m_y; |
1328 | } | |
1329 | ||
bf57d1ad | 1330 | void GetPosition(long *xpos, long *ypos) const |
b02da6b1 | 1331 | { |
20947e08 | 1332 | if (xpos) *xpos = (long)m_x; |
bf57d1ad | 1333 | if (ypos) *ypos = (long)m_y; |
b02da6b1 | 1334 | } |
803ef874 JS |
1335 | |
1336 | wxPoint GetPosition() const | |
1337 | { return wxPoint(m_x, m_y); } | |
c801d85f | 1338 | |
2b854a32 | 1339 | // Get X position |
b02da6b1 | 1340 | wxCoord GetX() const { return m_x; } |
c801d85f | 1341 | |
2b854a32 | 1342 | // Get Y position |
b02da6b1 | 1343 | wxCoord GetY() const { return m_y; } |
c801d85f | 1344 | |
8e72b8b5 | 1345 | virtual wxEvent *Clone() const { return new wxKeyEvent(*this); } |
f97500b8 VZ |
1346 | |
1347 | // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for | |
1348 | // example) | |
1349 | wxKeyEvent& operator=(const wxKeyEvent& evt) | |
1350 | { | |
3232da9d | 1351 | if ( &evt != this ) |
162e998c | 1352 | { |
0e097789 | 1353 | wxEvent::operator=(evt); |
3232da9d VZ |
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; | |
0e097789 | 1358 | |
162e998c PC |
1359 | m_x = evt.m_x; |
1360 | m_y = evt.m_y; | |
1361 | ||
1362 | m_keyCode = evt.m_keyCode; | |
1363 | ||
162e998c PC |
1364 | m_scanCode = evt.m_scanCode; |
1365 | m_rawCode = evt.m_rawCode; | |
1366 | m_rawFlags = evt.m_rawFlags; | |
cedea72f | 1367 | #if wxUSE_UNICODE |
162e998c | 1368 | m_uniChar = evt.m_uniChar; |
cedea72f | 1369 | #endif |
162e998c | 1370 | } |
f97500b8 VZ |
1371 | return *this; |
1372 | } | |
1373 | ||
2b854a32 | 1374 | public: |
b02da6b1 VZ |
1375 | wxCoord m_x, m_y; |
1376 | ||
2b854a32 | 1377 | long m_keyCode; |
b02da6b1 | 1378 | |
e7102772 | 1379 | // FIXME: what is this for? relation to m_rawXXX? |
b0e813a0 | 1380 | bool m_scanCode; |
f97500b8 | 1381 | |
2b5f62a0 VZ |
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 | |
9c7df356 VZ |
1390 | wxUint32 m_rawCode; |
1391 | wxUint32 m_rawFlags; | |
1392 | ||
8e72b8b5 RR |
1393 | private: |
1394 | DECLARE_DYNAMIC_CLASS(wxKeyEvent) | |
c801d85f KB |
1395 | }; |
1396 | ||
1397 | // Size event class | |
1398 | /* | |
1399 | wxEVT_SIZE | |
1400 | */ | |
1401 | ||
bddd7a8d | 1402 | class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent |
c801d85f | 1403 | { |
2b854a32 | 1404 | public: |
497dbbd3 | 1405 | wxSizeEvent() : wxEvent(0, wxEVT_SIZE) |
e6a6feba | 1406 | { } |
d9e2e4c2 DE |
1407 | wxSizeEvent(const wxSize& sz, int winid = 0) |
1408 | : wxEvent(winid, wxEVT_SIZE), | |
497dbbd3 | 1409 | m_size(sz) |
e6a6feba | 1410 | { } |
1d2eddff | 1411 | wxSizeEvent(const wxSizeEvent & event) |
b2697d42 | 1412 | : wxEvent(event), |
5706de1c | 1413 | m_size(event.m_size), m_rect(event.m_rect) |
b2697d42 | 1414 | { } |
5706de1c | 1415 | wxSizeEvent(const wxRect& rect, int id = 0) |
e00865fa | 1416 | : m_size(rect.GetSize()), m_rect(rect) |
5706de1c | 1417 | { m_eventType = wxEVT_SIZING; m_id = id; } |
c2bbeff0 | 1418 | |
2b854a32 | 1419 | wxSize GetSize() const { return m_size; } |
5706de1c | 1420 | wxRect GetRect() const { return m_rect; } |
fbfb8bcc | 1421 | void SetRect(const wxRect& rect) { m_rect = rect; } |
aadbdf11 | 1422 | |
8e72b8b5 RR |
1423 | virtual wxEvent *Clone() const { return new wxSizeEvent(*this); } |
1424 | ||
1425 | public: | |
b4b76d61 | 1426 | // For internal usage only. Will be converted to protected members. |
8e72b8b5 | 1427 | wxSize m_size; |
5706de1c | 1428 | wxRect m_rect; // Used for wxEVT_SIZING |
8e72b8b5 | 1429 | |
f97500b8 | 1430 | private: |
fc7a2a60 | 1431 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent) |
c801d85f KB |
1432 | }; |
1433 | ||
1434 | // Move event class | |
1435 | ||
1436 | /* | |
1437 | wxEVT_MOVE | |
1438 | */ | |
1439 | ||
bddd7a8d | 1440 | class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent |
c801d85f | 1441 | { |
2b854a32 | 1442 | public: |
e6a6feba GD |
1443 | wxMoveEvent() |
1444 | : wxEvent(0, wxEVT_MOVE) | |
e6a6feba | 1445 | { } |
d9e2e4c2 DE |
1446 | wxMoveEvent(const wxPoint& pos, int winid = 0) |
1447 | : wxEvent(winid, wxEVT_MOVE), | |
497dbbd3 | 1448 | m_pos(pos) |
e6a6feba | 1449 | { } |
1d2eddff JS |
1450 | wxMoveEvent(const wxMoveEvent& event) |
1451 | : wxEvent(event), | |
b2697d42 VZ |
1452 | m_pos(event.m_pos) |
1453 | { } | |
5706de1c JS |
1454 | wxMoveEvent(const wxRect& rect, int id = 0) |
1455 | : m_pos(rect.GetPosition()), m_rect(rect) | |
1456 | { m_eventType = wxEVT_MOVING; m_id = id; } | |
c2bbeff0 | 1457 | |
2b854a32 | 1458 | wxPoint GetPosition() const { return m_pos; } |
d7f03cae | 1459 | void SetPosition(const wxPoint& pos) { m_pos = pos; } |
5706de1c | 1460 | wxRect GetRect() const { return m_rect; } |
fbfb8bcc | 1461 | void SetRect(const wxRect& rect) { m_rect = rect; } |
aadbdf11 | 1462 | |
8e72b8b5 | 1463 | virtual wxEvent *Clone() const { return new wxMoveEvent(*this); } |
f97500b8 | 1464 | |
b4b76d61 | 1465 | protected: |
8e72b8b5 | 1466 | wxPoint m_pos; |
5706de1c | 1467 | wxRect m_rect; |
f97500b8 | 1468 | |
8e72b8b5 | 1469 | private: |
fc7a2a60 | 1470 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent) |
c801d85f KB |
1471 | }; |
1472 | ||
1473 | // Paint event class | |
1474 | /* | |
1475 | wxEVT_PAINT | |
1476 | wxEVT_NC_PAINT | |
1477 | wxEVT_PAINT_ICON | |
1478 | */ | |
1479 | ||
b078fa02 JS |
1480 | #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) |
1481 | // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined | |
bddd7a8d | 1482 | extern WXDLLIMPEXP_CORE int g_isPainting; |
edccf428 VZ |
1483 | #endif // debug |
1484 | ||
bddd7a8d | 1485 | class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent |
c801d85f | 1486 | { |
2b854a32 | 1487 | public: |
edccf428 | 1488 | wxPaintEvent(int Id = 0) |
e6a6feba | 1489 | : wxEvent(Id, wxEVT_PAINT) |
edccf428 | 1490 | { |
b078fa02 | 1491 | #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) |
edccf428 VZ |
1492 | // set the internal flag for the duration of processing of WM_PAINT |
1493 | g_isPainting++; | |
1494 | #endif // debug | |
1495 | } | |
1496 | ||
4e689ecd VZ |
1497 | // default copy ctor and dtor are normally fine, we only need them to keep |
1498 | // g_isPainting updated in debug build | |
b078fa02 | 1499 | #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) |
4e689ecd VZ |
1500 | wxPaintEvent(const wxPaintEvent& event) |
1501 | : wxEvent(event) | |
1502 | { | |
1503 | g_isPainting++; | |
1504 | } | |
1505 | ||
d3c7fc99 | 1506 | virtual ~wxPaintEvent() |
edccf428 VZ |
1507 | { |
1508 | g_isPainting--; | |
1509 | } | |
1510 | #endif // debug | |
8e72b8b5 RR |
1511 | |
1512 | virtual wxEvent *Clone() const { return new wxPaintEvent(*this); } | |
f97500b8 | 1513 | |
8e72b8b5 | 1514 | private: |
fc7a2a60 | 1515 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent) |
c801d85f KB |
1516 | }; |
1517 | ||
bddd7a8d | 1518 | class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent |
1e6feb95 VZ |
1519 | { |
1520 | public: | |
d9e2e4c2 DE |
1521 | wxNcPaintEvent(int winid = 0) |
1522 | : wxEvent(winid, wxEVT_NC_PAINT) | |
e6a6feba | 1523 | { } |
f97500b8 | 1524 | |
8e72b8b5 | 1525 | virtual wxEvent *Clone() const { return new wxNcPaintEvent(*this); } |
1e6feb95 VZ |
1526 | |
1527 | private: | |
fc7a2a60 | 1528 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent) |
1e6feb95 VZ |
1529 | }; |
1530 | ||
c801d85f KB |
1531 | // Erase background event class |
1532 | /* | |
1533 | wxEVT_ERASE_BACKGROUND | |
1534 | */ | |
1535 | ||
bddd7a8d | 1536 | class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent |
c801d85f | 1537 | { |
2b854a32 | 1538 | public: |
03f3617b | 1539 | wxEraseEvent(int Id = 0, wxDC *dc = NULL) |
497dbbd3 VZ |
1540 | : wxEvent(Id, wxEVT_ERASE_BACKGROUND), |
1541 | m_dc(dc) | |
e6a6feba GD |
1542 | { } |
1543 | ||
1544 | wxEraseEvent(const wxEraseEvent& event) | |
497dbbd3 VZ |
1545 | : wxEvent(event), |
1546 | m_dc(event.m_dc) | |
e6a6feba | 1547 | { } |
f97500b8 | 1548 | |
2b854a32 | 1549 | wxDC *GetDC() const { return m_dc; } |
aadbdf11 | 1550 | |
8e72b8b5 | 1551 | virtual wxEvent *Clone() const { return new wxEraseEvent(*this); } |
f97500b8 | 1552 | |
b4b76d61 | 1553 | protected: |
8e72b8b5 RR |
1554 | wxDC *m_dc; |
1555 | ||
1556 | private: | |
fc7a2a60 | 1557 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent) |
c801d85f KB |
1558 | }; |
1559 | ||
1560 | // Focus event class | |
1561 | /* | |
1562 | wxEVT_SET_FOCUS | |
1563 | wxEVT_KILL_FOCUS | |
1564 | */ | |
1565 | ||
bddd7a8d | 1566 | class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent |
c801d85f | 1567 | { |
2b854a32 | 1568 | public: |
d9e2e4c2 DE |
1569 | wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0) |
1570 | : wxEvent(winid, type) | |
497dbbd3 | 1571 | { m_win = NULL; } |
e6a6feba GD |
1572 | |
1573 | wxFocusEvent(const wxFocusEvent& event) | |
1574 | : wxEvent(event) | |
497dbbd3 | 1575 | { m_win = event.m_win; } |
1e6feb95 | 1576 | |
8e72b8b5 | 1577 | // The window associated with this event is the window which had focus |
1e6feb95 | 1578 | // before for SET event and the window which will have focus for the KILL |
8e72b8b5 | 1579 | // one. NB: it may be NULL in both cases! |
1e6feb95 VZ |
1580 | wxWindow *GetWindow() const { return m_win; } |
1581 | void SetWindow(wxWindow *win) { m_win = win; } | |
1582 | ||
8e72b8b5 | 1583 | virtual wxEvent *Clone() const { return new wxFocusEvent(*this); } |
f97500b8 | 1584 | |
1e6feb95 VZ |
1585 | private: |
1586 | wxWindow *m_win; | |
1587 | ||
8e72b8b5 | 1588 | private: |
fc7a2a60 | 1589 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent) |
c801d85f KB |
1590 | }; |
1591 | ||
456bc6d9 | 1592 | // wxChildFocusEvent notifies the parent that a child has got the focus: unlike |
1648d51b | 1593 | // wxFocusEvent it is propagated upwards the window chain |
bddd7a8d | 1594 | class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent |
456bc6d9 VZ |
1595 | { |
1596 | public: | |
1597 | wxChildFocusEvent(wxWindow *win = NULL); | |
1598 | ||
1599 | wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } | |
1600 | ||
8e72b8b5 | 1601 | virtual wxEvent *Clone() const { return new wxChildFocusEvent(*this); } |
f97500b8 | 1602 | |
8e72b8b5 | 1603 | private: |
fc7a2a60 | 1604 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent) |
456bc6d9 VZ |
1605 | }; |
1606 | ||
c801d85f KB |
1607 | // Activate event class |
1608 | /* | |
1609 | wxEVT_ACTIVATE | |
1610 | wxEVT_ACTIVATE_APP | |
afafd942 | 1611 | wxEVT_HIBERNATE |
c801d85f KB |
1612 | */ |
1613 | ||
bddd7a8d | 1614 | class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent |
c801d85f | 1615 | { |
2b854a32 | 1616 | public: |
a0d9c6cb | 1617 | wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, int Id = 0) |
e6a6feba | 1618 | : wxEvent(Id, type) |
497dbbd3 | 1619 | { m_active = active; } |
1d2eddff JS |
1620 | wxActivateEvent(const wxActivateEvent& event) |
1621 | : wxEvent(event) | |
b2697d42 | 1622 | { m_active = event.m_active; } |
c2bbeff0 | 1623 | |
2b854a32 | 1624 | bool GetActive() const { return m_active; } |
c801d85f | 1625 | |
8e72b8b5 | 1626 | virtual wxEvent *Clone() const { return new wxActivateEvent(*this); } |
aadbdf11 | 1627 | |
2b854a32 VZ |
1628 | private: |
1629 | bool m_active; | |
8e72b8b5 RR |
1630 | |
1631 | private: | |
fc7a2a60 | 1632 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent) |
c801d85f KB |
1633 | }; |
1634 | ||
1635 | // InitDialog event class | |
1636 | /* | |
1637 | wxEVT_INIT_DIALOG | |
1638 | */ | |
1639 | ||
bddd7a8d | 1640 | class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent |
c801d85f | 1641 | { |
2b854a32 VZ |
1642 | public: |
1643 | wxInitDialogEvent(int Id = 0) | |
e6a6feba GD |
1644 | : wxEvent(Id, wxEVT_INIT_DIALOG) |
1645 | { } | |
8e72b8b5 RR |
1646 | |
1647 | virtual wxEvent *Clone() const { return new wxInitDialogEvent(*this); } | |
f97500b8 VZ |
1648 | |
1649 | private: | |
fc7a2a60 | 1650 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent) |
c801d85f KB |
1651 | }; |
1652 | ||
1653 | // Miscellaneous menu event class | |
1654 | /* | |
ccef86c7 VZ |
1655 | wxEVT_MENU_OPEN, |
1656 | wxEVT_MENU_CLOSE, | |
c801d85f | 1657 | wxEVT_MENU_HIGHLIGHT, |
c801d85f KB |
1658 | */ |
1659 | ||
bddd7a8d | 1660 | class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent |
c801d85f | 1661 | { |
c801d85f | 1662 | public: |
92f1a59c | 1663 | wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL) |
d9e2e4c2 | 1664 | : wxEvent(winid, type) |
fc7a2a60 | 1665 | { m_menuId = winid; m_menu = menu; } |
1d2eddff JS |
1666 | wxMenuEvent(const wxMenuEvent & event) |
1667 | : wxEvent(event) | |
92f1a59c | 1668 | { m_menuId = event.m_menuId; m_menu = event.m_menu; } |
c2bbeff0 | 1669 | |
ccef86c7 | 1670 | // only for wxEVT_MENU_HIGHLIGHT |
aadbdf11 | 1671 | int GetMenuId() const { return m_menuId; } |
c801d85f | 1672 | |
ccef86c7 | 1673 | // only for wxEVT_MENU_OPEN/CLOSE |
1a18887b | 1674 | bool IsPopup() const { return m_menuId == wxID_ANY; } |
ccef86c7 | 1675 | |
92f1a59c JS |
1676 | // only for wxEVT_MENU_OPEN/CLOSE |
1677 | wxMenu* GetMenu() const { return m_menu; } | |
1678 | ||
8e72b8b5 | 1679 | virtual wxEvent *Clone() const { return new wxMenuEvent(*this); } |
f97500b8 | 1680 | |
2b854a32 | 1681 | private: |
92f1a59c JS |
1682 | int m_menuId; |
1683 | wxMenu* m_menu; | |
f97500b8 | 1684 | |
fc7a2a60 | 1685 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent) |
c801d85f KB |
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 | ||
bddd7a8d | 1695 | class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent |
c801d85f | 1696 | { |
c801d85f | 1697 | public: |
d9e2e4c2 DE |
1698 | wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0) |
1699 | : wxEvent(winid, type), | |
a0d9c6cb WS |
1700 | m_loggingOff(true), |
1701 | m_veto(false), // should be false by default | |
1702 | m_canVeto(true) {} | |
a3bf7524 | 1703 | |
1d2eddff JS |
1704 | wxCloseEvent(const wxCloseEvent & event) |
1705 | : wxEvent(event), | |
b2697d42 VZ |
1706 | m_loggingOff(event.m_loggingOff), |
1707 | m_veto(event.m_veto), | |
a3bf7524 | 1708 | m_canVeto(event.m_canVeto) {} |
c2bbeff0 | 1709 | |
2b854a32 | 1710 | void SetLoggingOff(bool logOff) { m_loggingOff = logOff; } |
4bcfcdef VZ |
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 | } | |
2b854a32 | 1720 | |
a0d9c6cb | 1721 | void Veto(bool veto = true) |
fe4e9e6c | 1722 | { |
a0d9c6cb | 1723 | // GetVeto() will return false anyhow... |
fe4e9e6c | 1724 | wxCHECK_RET( m_canVeto, |
223d09f6 | 1725 | wxT("call to Veto() ignored (can't veto this event)") ); |
fe4e9e6c VZ |
1726 | |
1727 | m_veto = veto; | |
1728 | } | |
2b854a32 VZ |
1729 | void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } |
1730 | bool CanVeto() const { return m_canVeto; } | |
fe4e9e6c | 1731 | bool GetVeto() const { return m_canVeto && m_veto; } |
c801d85f | 1732 | |
8e72b8b5 | 1733 | virtual wxEvent *Clone() const { return new wxCloseEvent(*this); } |
aadbdf11 | 1734 | |
2b854a32 | 1735 | protected: |
4bcfcdef VZ |
1736 | bool m_loggingOff, |
1737 | m_veto, | |
1738 | m_canVeto; | |
2b854a32 | 1739 | |
8e72b8b5 | 1740 | private: |
fc7a2a60 | 1741 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent) |
c801d85f KB |
1742 | }; |
1743 | ||
1744 | /* | |
1745 | wxEVT_SHOW | |
1746 | */ | |
1747 | ||
bddd7a8d | 1748 | class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent |
c801d85f | 1749 | { |
c801d85f | 1750 | public: |
a0d9c6cb | 1751 | wxShowEvent(int winid = 0, bool show = false) |
d9e2e4c2 | 1752 | : wxEvent(winid, wxEVT_SHOW) |
497dbbd3 | 1753 | { m_show = show; } |
1d2eddff JS |
1754 | wxShowEvent(const wxShowEvent & event) |
1755 | : wxEvent(event) | |
b2697d42 | 1756 | { m_show = event.m_show; } |
c2bbeff0 | 1757 | |
2b854a32 | 1758 | void SetShow(bool show) { m_show = show; } |
d317fdeb VZ |
1759 | |
1760 | // return true if the window was shown, false if hidden | |
1761 | bool IsShown() const { return m_show; } | |
1762 | ||
831b64f3 | 1763 | #if WXWIN_COMPATIBILITY_2_8 |
d317fdeb VZ |
1764 | wxDEPRECATED( bool GetShow() const { return IsShown(); } ) |
1765 | #endif | |
c801d85f | 1766 | |
8e72b8b5 | 1767 | virtual wxEvent *Clone() const { return new wxShowEvent(*this); } |
aadbdf11 | 1768 | |
c801d85f | 1769 | protected: |
2b854a32 | 1770 | bool m_show; |
3dd9b88a | 1771 | |
8e72b8b5 | 1772 | private: |
fc7a2a60 | 1773 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent) |
c801d85f KB |
1774 | }; |
1775 | ||
1776 | /* | |
1777 | wxEVT_ICONIZE | |
1778 | */ | |
1779 | ||
bddd7a8d | 1780 | class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent |
c801d85f | 1781 | { |
2b854a32 | 1782 | public: |
a0d9c6cb | 1783 | wxIconizeEvent(int winid = 0, bool iconized = true) |
d9e2e4c2 | 1784 | : wxEvent(winid, wxEVT_ICONIZE) |
497dbbd3 | 1785 | { m_iconized = iconized; } |
1d2eddff JS |
1786 | wxIconizeEvent(const wxIconizeEvent & event) |
1787 | : wxEvent(event) | |
b2697d42 | 1788 | { m_iconized = event.m_iconized; } |
c2bbeff0 | 1789 | |
831b64f3 | 1790 | #if WXWIN_COMPATIBILITY_2_8 |
d317fdeb VZ |
1791 | wxDEPRECATED( bool Iconized() const { return IsIconized(); } ) |
1792 | #endif | |
3dd9b88a | 1793 | // return true if the frame was iconized, false if restored |
d317fdeb | 1794 | bool IsIconized() const { return m_iconized; } |
3dd9b88a | 1795 | |
8e72b8b5 | 1796 | virtual wxEvent *Clone() const { return new wxIconizeEvent(*this); } |
f97500b8 | 1797 | |
3dd9b88a VZ |
1798 | protected: |
1799 | bool m_iconized; | |
1800 | ||
8e72b8b5 | 1801 | private: |
fc7a2a60 | 1802 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent) |
c801d85f | 1803 | }; |
c801d85f KB |
1804 | /* |
1805 | wxEVT_MAXIMIZE | |
1806 | */ | |
1807 | ||
bddd7a8d | 1808 | class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent |
c801d85f | 1809 | { |
2b854a32 | 1810 | public: |
d9e2e4c2 DE |
1811 | wxMaximizeEvent(int winid = 0) |
1812 | : wxEvent(winid, wxEVT_MAXIMIZE) | |
e6a6feba | 1813 | { } |
3dd9b88a | 1814 | |
8e72b8b5 | 1815 | virtual wxEvent *Clone() const { return new wxMaximizeEvent(*this); } |
f97500b8 | 1816 | |
8e72b8b5 | 1817 | private: |
fc7a2a60 | 1818 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent) |
c801d85f KB |
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. | |
497dbbd3 VZ |
1830 | enum |
1831 | { | |
1832 | wxJOYSTICK1, | |
1833 | wxJOYSTICK2 | |
1834 | }; | |
c801d85f KB |
1835 | |
1836 | // Which button is down? | |
497dbbd3 VZ |
1837 | enum |
1838 | { | |
1839 | wxJOY_BUTTON_ANY = -1, | |
1840 | wxJOY_BUTTON1 = 1, | |
1841 | wxJOY_BUTTON2 = 2, | |
1842 | wxJOY_BUTTON3 = 4, | |
1843 | wxJOY_BUTTON4 = 8 | |
1844 | }; | |
c801d85f | 1845 | |
bddd7a8d | 1846 | class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent |
c801d85f | 1847 | { |
b4b76d61 | 1848 | protected: |
2b854a32 VZ |
1849 | wxPoint m_pos; |
1850 | int m_zPosition; | |
497dbbd3 VZ |
1851 | int m_buttonChange; // Which button changed? |
1852 | int m_buttonState; // Which buttons are down? | |
1853 | int m_joyStick; // Which joystick? | |
2b854a32 | 1854 | |
b4b76d61 | 1855 | public: |
2b854a32 VZ |
1856 | wxJoystickEvent(wxEventType type = wxEVT_NULL, |
1857 | int state = 0, | |
1858 | int joystick = wxJOYSTICK1, | |
1859 | int change = 0) | |
497dbbd3 | 1860 | : wxEvent(0, type), |
8b5d5223 | 1861 | m_pos(), |
497dbbd3 VZ |
1862 | m_zPosition(0), |
1863 | m_buttonChange(change), | |
1864 | m_buttonState(state), | |
1865 | m_joyStick(joystick) | |
2b854a32 | 1866 | { |
2b854a32 | 1867 | } |
1d2eddff | 1868 | wxJoystickEvent(const wxJoystickEvent & event) |
b2697d42 VZ |
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) | |
1d2eddff | 1875 | { } |
c2bbeff0 | 1876 | |
2b854a32 VZ |
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) || | |
b70ababc | 1891 | (GetEventType() == wxEVT_JOY_BUTTON_UP)); } |
2b854a32 VZ |
1892 | |
1893 | // Was it a move event? | |
a7bc03c9 | 1894 | bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE); } |
2b854a32 VZ |
1895 | |
1896 | // Was it a zmove event? | |
a7bc03c9 | 1897 | bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE); } |
2b854a32 VZ |
1898 | |
1899 | // Was it a down event from button 1, 2, 3, 4 or any? | |
1900 | bool ButtonDown(int but = wxJOY_BUTTON_ANY) const | |
c801d85f | 1901 | { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) && |
2b854a32 | 1902 | ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } |
c801d85f | 1903 | |
2b854a32 VZ |
1904 | // Was it a up event from button 1, 2, 3 or any? |
1905 | bool ButtonUp(int but = wxJOY_BUTTON_ANY) const | |
c801d85f | 1906 | { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) && |
2b854a32 | 1907 | ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } |
c801d85f | 1908 | |
2b854a32 VZ |
1909 | // Was the given button 1,2,3,4 or any in Down state? |
1910 | bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const | |
c801d85f | 1911 | { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) || |
2b854a32 | 1912 | ((m_buttonState & but) == but)); } |
f305c661 | 1913 | |
8e72b8b5 | 1914 | virtual wxEvent *Clone() const { return new wxJoystickEvent(*this); } |
f97500b8 | 1915 | |
8e72b8b5 | 1916 | private: |
fc7a2a60 | 1917 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent) |
c801d85f KB |
1918 | }; |
1919 | ||
1920 | // Drop files event class | |
1921 | /* | |
1922 | wxEVT_DROP_FILES | |
1923 | */ | |
1924 | ||
bddd7a8d | 1925 | class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent |
c801d85f | 1926 | { |
2b854a32 VZ |
1927 | public: |
1928 | int m_noFiles; | |
1929 | wxPoint m_pos; | |
c3c39620 | 1930 | wxString* m_files; |
2b854a32 VZ |
1931 | |
1932 | wxDropFilesEvent(wxEventType type = wxEVT_NULL, | |
1933 | int noFiles = 0, | |
03f3617b | 1934 | wxString *files = NULL) |
497dbbd3 VZ |
1935 | : wxEvent(0, type), |
1936 | m_noFiles(noFiles), | |
1937 | m_pos(), | |
1938 | m_files(files) | |
e6a6feba | 1939 | { } |
2b854a32 | 1940 | |
c3c39620 VZ |
1941 | // we need a copy ctor to avoid deleting m_files pointer twice |
1942 | wxDropFilesEvent(const wxDropFilesEvent& other) | |
497dbbd3 VZ |
1943 | : wxEvent(other), |
1944 | m_noFiles(other.m_noFiles), | |
1945 | m_pos(other.m_pos), | |
1946 | m_files(NULL) | |
c3c39620 | 1947 | { |
c3c39620 VZ |
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 | ||
2b854a32 VZ |
1960 | wxPoint GetPosition() const { return m_pos; } |
1961 | int GetNumberOfFiles() const { return m_noFiles; } | |
1962 | wxString *GetFiles() const { return m_files; } | |
f305c661 | 1963 | |
c3c39620 | 1964 | virtual wxEvent *Clone() const { return new wxDropFilesEvent(*this); } |
f97500b8 | 1965 | |
8e72b8b5 | 1966 | private: |
fc7a2a60 | 1967 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent) |
c801d85f KB |
1968 | }; |
1969 | ||
c801d85f KB |
1970 | // Update UI event |
1971 | /* | |
1972 | wxEVT_UPDATE_UI | |
1973 | */ | |
1974 | ||
e39af974 JS |
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 | ||
1979 | enum 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 | ||
bddd7a8d | 1989 | class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent |
c801d85f | 1990 | { |
2b854a32 VZ |
1991 | public: |
1992 | wxUpdateUIEvent(wxWindowID commandId = 0) | |
e6a6feba | 1993 | : wxCommandEvent(wxEVT_UPDATE_UI, commandId) |
497dbbd3 VZ |
1994 | { |
1995 | m_checked = | |
1996 | m_enabled = | |
a3a4105d | 1997 | m_shown = |
497dbbd3 | 1998 | m_setEnabled = |
a3a4105d | 1999 | m_setShown = |
9b9337da | 2000 | m_setText = |
a0d9c6cb | 2001 | m_setChecked = false; |
497dbbd3 | 2002 | } |
1d2eddff JS |
2003 | wxUpdateUIEvent(const wxUpdateUIEvent & event) |
2004 | : wxCommandEvent(event), | |
b2697d42 VZ |
2005 | m_checked(event.m_checked), |
2006 | m_enabled(event.m_enabled), | |
a3a4105d | 2007 | m_shown(event.m_shown), |
b2697d42 | 2008 | m_setEnabled(event.m_setEnabled), |
a3a4105d | 2009 | m_setShown(event.m_setShown), |
b2697d42 VZ |
2010 | m_setText(event.m_setText), |
2011 | m_setChecked(event.m_setChecked), | |
2012 | m_text(event.m_text) | |
2013 | { } | |
c2bbeff0 | 2014 | |
2b854a32 VZ |
2015 | bool GetChecked() const { return m_checked; } |
2016 | bool GetEnabled() const { return m_enabled; } | |
a3a4105d | 2017 | bool GetShown() const { return m_shown; } |
2b854a32 VZ |
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; } | |
a3a4105d | 2022 | bool GetSetShown() const { return m_setShown; } |
2b854a32 | 2023 | |
a0d9c6cb WS |
2024 | void Check(bool check) { m_checked = check; m_setChecked = true; } |
2025 | void Enable(bool enable) { m_enabled = enable; m_setEnabled = true; } | |
a3a4105d | 2026 | void Show(bool show) { m_shown = show; m_setShown = true; } |
a0d9c6cb | 2027 | void SetText(const wxString& text) { m_text = text; m_setText = true; } |
c801d85f | 2028 | |
0b30bb0b JS |
2029 | // Sets the interval between updates in milliseconds. |
2030 | // Set to -1 to disable updates, or to 0 to update as frequently as possible. | |
e39af974 | 2031 | static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; } |
0b30bb0b JS |
2032 | |
2033 | // Returns the current interval between updates in milliseconds | |
a7bc03c9 | 2034 | static long GetUpdateInterval() { return sm_updateInterval; } |
0b30bb0b | 2035 | |
e39af974 | 2036 | // Can we update this window? |
a7bc03c9 | 2037 | static bool CanUpdate(wxWindowBase *win); |
0b30bb0b JS |
2038 | |
2039 | // Reset the update time to provide a delay until the next | |
2040 | // time we should update | |
a7bc03c9 | 2041 | static void ResetUpdateTime(); |
0b30bb0b | 2042 | |
77ffb593 | 2043 | // Specify how wxWidgets will send update events: to |
e39af974 JS |
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 | |
a7bc03c9 | 2049 | static wxUpdateUIMode GetMode() { return sm_updateMode; } |
e39af974 | 2050 | |
8e72b8b5 | 2051 | virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); } |
f305c661 | 2052 | |
2b854a32 VZ |
2053 | protected: |
2054 | bool m_checked; | |
2055 | bool m_enabled; | |
a3a4105d | 2056 | bool m_shown; |
2b854a32 | 2057 | bool m_setEnabled; |
a3a4105d | 2058 | bool m_setShown; |
2b854a32 VZ |
2059 | bool m_setText; |
2060 | bool m_setChecked; | |
2061 | wxString m_text; | |
0b30bb0b | 2062 | #if wxUSE_LONGLONG |
e39af974 | 2063 | static wxLongLong sm_lastUpdate; |
0b30bb0b | 2064 | #endif |
e39af974 JS |
2065 | static long sm_updateInterval; |
2066 | static wxUpdateUIMode sm_updateMode; | |
f97500b8 | 2067 | |
8e72b8b5 | 2068 | private: |
fc7a2a60 | 2069 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent) |
c801d85f KB |
2070 | }; |
2071 | ||
2072 | /* | |
2073 | wxEVT_SYS_COLOUR_CHANGED | |
2074 | */ | |
2075 | ||
2076 | // TODO: shouldn't all events record the window ID? | |
bddd7a8d | 2077 | class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent |
c801d85f | 2078 | { |
2b854a32 VZ |
2079 | public: |
2080 | wxSysColourChangedEvent() | |
e6a6feba GD |
2081 | : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED) |
2082 | { } | |
f97500b8 | 2083 | |
8e72b8b5 | 2084 | virtual wxEvent *Clone() const { return new wxSysColourChangedEvent(*this); } |
f97500b8 | 2085 | |
8e72b8b5 | 2086 | private: |
fc7a2a60 | 2087 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent) |
c801d85f KB |
2088 | }; |
2089 | ||
a5e84126 JS |
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 | ||
bddd7a8d | 2096 | class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent |
a5e84126 JS |
2097 | { |
2098 | public: | |
d9e2e4c2 DE |
2099 | wxMouseCaptureChangedEvent(wxWindowID winid = 0, wxWindow* gainedCapture = NULL) |
2100 | : wxEvent(winid, wxEVT_MOUSE_CAPTURE_CHANGED), | |
497dbbd3 | 2101 | m_gainedCapture(gainedCapture) |
e6a6feba GD |
2102 | { } |
2103 | ||
2104 | wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent& event) | |
497dbbd3 VZ |
2105 | : wxEvent(event), |
2106 | m_gainedCapture(event.m_gainedCapture) | |
e6a6feba | 2107 | { } |
a5e84126 JS |
2108 | |
2109 | virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); } | |
2110 | ||
47b378bd | 2111 | wxWindow* GetCapturedWindow() const { return m_gainedCapture; } |
a5e84126 JS |
2112 | |
2113 | private: | |
2114 | wxWindow* m_gainedCapture; | |
fc7a2a60 VZ |
2115 | |
2116 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent) | |
a5e84126 JS |
2117 | }; |
2118 | ||
63e819f2 VS |
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 | ||
2126 | class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent : public wxEvent | |
2127 | { | |
2128 | public: | |
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 | ||
574c939e KB |
2142 | /* |
2143 | wxEVT_DISPLAY_CHANGED | |
2144 | */ | |
bddd7a8d | 2145 | class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent |
574c939e KB |
2146 | { |
2147 | private: | |
fc7a2a60 | 2148 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent) |
574c939e KB |
2149 | |
2150 | public: | |
2151 | wxDisplayChangedEvent() | |
e6a6feba GD |
2152 | : wxEvent(0, wxEVT_DISPLAY_CHANGED) |
2153 | { } | |
574c939e KB |
2154 | |
2155 | virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); } | |
2156 | }; | |
2157 | ||
f7bd2698 JS |
2158 | /* |
2159 | wxEVT_PALETTE_CHANGED | |
2160 | */ | |
2161 | ||
bddd7a8d | 2162 | class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent |
f7bd2698 | 2163 | { |
f7bd2698 | 2164 | public: |
d9e2e4c2 DE |
2165 | wxPaletteChangedEvent(wxWindowID winid = 0) |
2166 | : wxEvent(winid, wxEVT_PALETTE_CHANGED), | |
03f3617b | 2167 | m_changedWindow(NULL) |
497dbbd3 | 2168 | { } |
e6a6feba GD |
2169 | |
2170 | wxPaletteChangedEvent(const wxPaletteChangedEvent& event) | |
497dbbd3 VZ |
2171 | : wxEvent(event), |
2172 | m_changedWindow(event.m_changedWindow) | |
e6a6feba | 2173 | { } |
f7bd2698 | 2174 | |
2b854a32 VZ |
2175 | void SetChangedWindow(wxWindow* win) { m_changedWindow = win; } |
2176 | wxWindow* GetChangedWindow() const { return m_changedWindow; } | |
f7bd2698 | 2177 | |
8e72b8b5 | 2178 | virtual wxEvent *Clone() const { return new wxPaletteChangedEvent(*this); } |
f305c661 | 2179 | |
f7bd2698 | 2180 | protected: |
2b854a32 | 2181 | wxWindow* m_changedWindow; |
8e72b8b5 RR |
2182 | |
2183 | private: | |
fc7a2a60 | 2184 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent) |
f7bd2698 JS |
2185 | }; |
2186 | ||
2187 | /* | |
2188 | wxEVT_QUERY_NEW_PALETTE | |
2189 | Indicates the window is getting keyboard focus and should re-do its palette. | |
2190 | */ | |
2191 | ||
bddd7a8d | 2192 | class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent |
f7bd2698 | 2193 | { |
f7bd2698 | 2194 | public: |
d9e2e4c2 DE |
2195 | wxQueryNewPaletteEvent(wxWindowID winid = 0) |
2196 | : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE), | |
a0d9c6cb | 2197 | m_paletteRealized(false) |
e6a6feba | 2198 | { } |
1d2eddff JS |
2199 | wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent & event) |
2200 | : wxEvent(event), | |
b2697d42 VZ |
2201 | m_paletteRealized(event.m_paletteRealized) |
2202 | { } | |
c2bbeff0 | 2203 | |
2b854a32 VZ |
2204 | // App sets this if it changes the palette. |
2205 | void SetPaletteRealized(bool realized) { m_paletteRealized = realized; } | |
2206 | bool GetPaletteRealized() const { return m_paletteRealized; } | |
f7bd2698 | 2207 | |
8e72b8b5 | 2208 | virtual wxEvent *Clone() const { return new wxQueryNewPaletteEvent(*this); } |
f305c661 | 2209 | |
f7bd2698 | 2210 | protected: |
2b854a32 | 2211 | bool m_paletteRealized; |
f97500b8 | 2212 | |
8e72b8b5 | 2213 | private: |
fc7a2a60 | 2214 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent) |
f7bd2698 JS |
2215 | }; |
2216 | ||
7fdefd57 VZ |
2217 | /* |
2218 | Event generated by dialog navigation keys | |
2219 | wxEVT_NAVIGATION_KEY | |
2220 | */ | |
d9506e77 | 2221 | // NB: don't derive from command event to avoid being propagated to the parent |
bddd7a8d | 2222 | class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent |
7fdefd57 | 2223 | { |
7fdefd57 | 2224 | public: |
d9506e77 | 2225 | wxNavigationKeyEvent() |
497dbbd3 | 2226 | : wxEvent(0, wxEVT_NAVIGATION_KEY), |
298ca00c | 2227 | m_flags(IsForward | FromTab), // defaults are for TAB |
03f3617b | 2228 | m_focus(NULL) |
aef35d0e VZ |
2229 | { |
2230 | m_propagationLevel = wxEVENT_PROPAGATE_NONE; | |
2231 | } | |
d9506e77 | 2232 | |
e6a6feba | 2233 | wxNavigationKeyEvent(const wxNavigationKeyEvent& event) |
497dbbd3 VZ |
2234 | : wxEvent(event), |
2235 | m_flags(event.m_flags), | |
2236 | m_focus(event.m_focus) | |
e6a6feba | 2237 | { } |
7fdefd57 | 2238 | |
2b854a32 | 2239 | // direction: forward (true) or backward (false) |
d9506e77 VZ |
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; } | |
7fdefd57 | 2244 | |
2b854a32 VZ |
2245 | // it may be a window change event (MDI, notebook pages...) or a control |
2246 | // change event | |
d9506e77 VZ |
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 | ||
298ca00c VZ |
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 | ||
2b854a32 VZ |
2259 | // the child which has the focus currently (may be NULL - use |
2260 | // wxWindow::FindFocus then) | |
d9506e77 VZ |
2261 | wxWindow* GetCurrentFocus() const { return m_focus; } |
2262 | void SetCurrentFocus(wxWindow *win) { m_focus = win; } | |
2263 | ||
54a69edf JS |
2264 | // Set flags |
2265 | void SetFlags(long flags) { m_flags = flags; } | |
2266 | ||
8e72b8b5 RR |
2267 | virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); } |
2268 | ||
d9506e77 VZ |
2269 | enum |
2270 | { | |
f2de9fee | 2271 | IsBackward = 0x0000, |
d9506e77 | 2272 | IsForward = 0x0001, |
298ca00c VZ |
2273 | WinChange = 0x0002, |
2274 | FromTab = 0x0004 | |
d9506e77 VZ |
2275 | }; |
2276 | ||
2277 | long m_flags; | |
2278 | wxWindow *m_focus; | |
2279 | ||
8e72b8b5 | 2280 | private: |
fc7a2a60 | 2281 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent) |
7fdefd57 VZ |
2282 | }; |
2283 | ||
42e69d6b VZ |
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 | ||
bddd7a8d | 2294 | class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent |
42e69d6b | 2295 | { |
42e69d6b VZ |
2296 | public: |
2297 | wxWindowCreateEvent(wxWindow *win = NULL); | |
2298 | ||
2299 | wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } | |
f97500b8 | 2300 | |
8e72b8b5 | 2301 | virtual wxEvent *Clone() const { return new wxWindowCreateEvent(*this); } |
f97500b8 | 2302 | |
8e72b8b5 | 2303 | private: |
fc7a2a60 | 2304 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent) |
42e69d6b VZ |
2305 | }; |
2306 | ||
bddd7a8d | 2307 | class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent |
42e69d6b | 2308 | { |
42e69d6b VZ |
2309 | public: |
2310 | wxWindowDestroyEvent(wxWindow *win = NULL); | |
2311 | ||
2312 | wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } | |
f97500b8 | 2313 | |
8e72b8b5 RR |
2314 | virtual wxEvent *Clone() const { return new wxWindowDestroyEvent(*this); } |
2315 | ||
2316 | private: | |
fc7a2a60 | 2317 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent) |
42e69d6b VZ |
2318 | }; |
2319 | ||
bd83cb56 | 2320 | // A help event is sent when the user clicks on a window in context-help mode. |
b96340e6 | 2321 | /* |
bd83cb56 VZ |
2322 | wxEVT_HELP |
2323 | wxEVT_DETAILED_HELP | |
2324 | */ | |
b96340e6 | 2325 | |
bddd7a8d | 2326 | class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent |
b96340e6 | 2327 | { |
b96340e6 | 2328 | public: |
b107e8d5 VZ |
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 | ||
bd83cb56 | 2337 | wxHelpEvent(wxEventType type = wxEVT_NULL, |
d9e2e4c2 | 2338 | wxWindowID winid = 0, |
b107e8d5 VZ |
2339 | const wxPoint& pt = wxDefaultPosition, |
2340 | Origin origin = Origin_Unknown) | |
d9e2e4c2 | 2341 | : wxCommandEvent(type, winid), |
b107e8d5 VZ |
2342 | m_pos(pt), |
2343 | m_origin(GuessOrigin(origin)) | |
e6a6feba | 2344 | { } |
1d2eddff JS |
2345 | wxHelpEvent(const wxHelpEvent & event) |
2346 | : wxCommandEvent(event), | |
b2697d42 VZ |
2347 | m_pos(event.m_pos), |
2348 | m_target(event.m_target), | |
b107e8d5 VZ |
2349 | m_link(event.m_link), |
2350 | m_origin(event.m_origin) | |
1d2eddff | 2351 | { } |
c2bbeff0 | 2352 | |
bd83cb56 VZ |
2353 | // Position of event (in screen coordinates) |
2354 | const wxPoint& GetPosition() const { return m_pos; } | |
2355 | void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
b96340e6 | 2356 | |
bd83cb56 VZ |
2357 | // Optional link to further help |
2358 | const wxString& GetLink() const { return m_link; } | |
2359 | void SetLink(const wxString& link) { m_link = link; } | |
fb6261e9 | 2360 | |
bd83cb56 VZ |
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; } | |
fb6261e9 | 2364 | |
8e72b8b5 | 2365 | virtual wxEvent *Clone() const { return new wxHelpEvent(*this); } |
f97500b8 | 2366 | |
b107e8d5 VZ |
2367 | // optional indication of the event source |
2368 | Origin GetOrigin() const { return m_origin; } | |
2369 | void SetOrigin(Origin origin) { m_origin = origin; } | |
2370 | ||
bd83cb56 VZ |
2371 | protected: |
2372 | wxPoint m_pos; | |
2373 | wxString m_target; | |
2374 | wxString m_link; | |
b107e8d5 VZ |
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); | |
bd83cb56 VZ |
2380 | |
2381 | private: | |
fc7a2a60 | 2382 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent) |
b96340e6 JS |
2383 | }; |
2384 | ||
78c91815 VZ |
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 | /* | |
2391 | wxEVT_COMMAND_TEXT_COPY | |
2392 | wxEVT_COMMAND_TEXT_CUT | |
2393 | wxEVT_COMMAND_TEXT_PASTE | |
2394 | */ | |
2395 | ||
2396 | class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent | |
2397 | { | |
2398 | public: | |
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 | ||
2409 | private: | |
2410 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent) | |
2411 | }; | |
2412 | ||
69231000 JS |
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 | ||
bddd7a8d | 2421 | class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent |
69231000 JS |
2422 | { |
2423 | public: | |
2424 | wxContextMenuEvent(wxEventType type = wxEVT_NULL, | |
d9e2e4c2 | 2425 | wxWindowID winid = 0, |
e6a6feba | 2426 | const wxPoint& pt = wxDefaultPosition) |
d9e2e4c2 | 2427 | : wxCommandEvent(type, winid), |
497dbbd3 | 2428 | m_pos(pt) |
e6a6feba | 2429 | { } |
1d2eddff JS |
2430 | wxContextMenuEvent(const wxContextMenuEvent & event) |
2431 | : wxCommandEvent(event), | |
b2697d42 | 2432 | m_pos(event.m_pos) |
1d2eddff | 2433 | { } |
c2bbeff0 | 2434 | |
69231000 JS |
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 | ||
8e72b8b5 | 2439 | virtual wxEvent *Clone() const { return new wxContextMenuEvent(*this); } |
f97500b8 | 2440 | |
69231000 JS |
2441 | protected: |
2442 | wxPoint m_pos; | |
2443 | ||
2444 | private: | |
fc7a2a60 | 2445 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent) |
69231000 JS |
2446 | }; |
2447 | ||
b46b1d59 VZ |
2448 | #endif // wxUSE_GUI |
2449 | ||
e90c1d2a VZ |
2450 | // Idle event |
2451 | /* | |
2452 | wxEVT_IDLE | |
2453 | */ | |
2454 | ||
e39af974 JS |
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 | ||
2459 | enum 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 | ||
b46b1d59 | 2469 | class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent |
e90c1d2a | 2470 | { |
e90c1d2a VZ |
2471 | public: |
2472 | wxIdleEvent() | |
497dbbd3 | 2473 | : wxEvent(0, wxEVT_IDLE), |
a0d9c6cb | 2474 | m_requestMore(false) |
e6a6feba | 2475 | { } |
1d2eddff JS |
2476 | wxIdleEvent(const wxIdleEvent & event) |
2477 | : wxEvent(event), | |
b2697d42 VZ |
2478 | m_requestMore(event.m_requestMore) |
2479 | { } | |
c2bbeff0 | 2480 | |
a0d9c6cb | 2481 | void RequestMore(bool needMore = true) { m_requestMore = needMore; } |
e90c1d2a VZ |
2482 | bool MoreRequested() const { return m_requestMore; } |
2483 | ||
8e72b8b5 | 2484 | virtual wxEvent *Clone() const { return new wxIdleEvent(*this); } |
e90c1d2a | 2485 | |
77ffb593 | 2486 | // Specify how wxWidgets will send idle events: to |
e39af974 JS |
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 | |
a7bc03c9 | 2492 | static wxIdleMode GetMode() { return sm_idleMode; } |
e39af974 | 2493 | |
e90c1d2a VZ |
2494 | protected: |
2495 | bool m_requestMore; | |
e39af974 | 2496 | static wxIdleMode sm_idleMode; |
f97500b8 | 2497 | |
8e72b8b5 | 2498 | private: |
fc7a2a60 | 2499 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent) |
e90c1d2a VZ |
2500 | }; |
2501 | ||
e5fb7191 | 2502 | /* TODO |
c801d85f KB |
2503 | wxEVT_MOUSE_CAPTURE_CHANGED, |
2504 | wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95) | |
c801d85f KB |
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 | ||
88a9f974 | 2512 | |
8e193f38 VZ |
2513 | // ============================================================================ |
2514 | // event handler and related classes | |
2515 | // ============================================================================ | |
2516 | ||
c801d85f | 2517 | |
6164f93c VZ |
2518 | // struct containing the members common to static and dynamic event tables |
2519 | // entries | |
bddd7a8d | 2520 | struct WXDLLIMPEXP_BASE wxEventTableEntryBase |
77d4384e | 2521 | { |
d9e2e4c2 | 2522 | wxEventTableEntryBase(int winid, int idLast, |
3c778901 | 2523 | wxEventFunctor* fn, wxObject *data) |
d9e2e4c2 | 2524 | : m_id(winid), |
497dbbd3 VZ |
2525 | m_lastId(idLast), |
2526 | m_fn(fn), | |
2527 | m_callbackUserData(data) | |
e6a6feba GD |
2528 | { } |
2529 | ||
3c778901 VZ |
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 | { | |
0b632977 | 2547 | delete m_fn; |
3c778901 | 2548 | } |
6164f93c | 2549 | |
497dbbd3 VZ |
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; | |
82a5f02c | 2554 | |
3c778901 VZ |
2555 | // function/method/functor to call |
2556 | wxEventFunctor* m_fn; | |
77d4384e | 2557 | |
3c778901 | 2558 | // arbitrary user data associated with the callback |
77d4384e | 2559 | wxObject* m_callbackUserData; |
3c778901 VZ |
2560 | |
2561 | private: | |
2562 | wxEventTableEntryBase &operator = ( const wxEventTableEntryBase & ); | |
77d4384e RR |
2563 | }; |
2564 | ||
6164f93c | 2565 | // an entry from a static event table |
bddd7a8d | 2566 | struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase |
c801d85f | 2567 | { |
d9e2e4c2 | 2568 | wxEventTableEntry(const int& evType, int winid, int idLast, |
3c778901 | 2569 | wxEventFunctor* fn, wxObject *data) |
d9e2e4c2 | 2570 | : wxEventTableEntryBase(winid, idLast, fn, data), |
e6a6feba GD |
2571 | m_eventType(evType) |
2572 | { } | |
6164f93c VZ |
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; | |
fc7a2a60 VZ |
2581 | |
2582 | private: | |
3c778901 | 2583 | wxEventTableEntry &operator = ( const wxEventTableEntry & ); |
6164f93c VZ |
2584 | }; |
2585 | ||
2586 | // an entry used in dynamic event table managed by wxEvtHandler::Connect() | |
bddd7a8d | 2587 | struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase |
6164f93c | 2588 | { |
d9e2e4c2 | 2589 | wxDynamicEventTableEntry(int evType, int winid, int idLast, |
3c778901 | 2590 | wxEventFunctor* fn, wxObject *data) |
d9e2e4c2 | 2591 | : wxEventTableEntryBase(winid, idLast, fn, data), |
3c778901 | 2592 | m_eventType(evType) |
e6a6feba | 2593 | { } |
6164f93c VZ |
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; | |
65b17727 | 2599 | |
3c778901 VZ |
2600 | private: |
2601 | wxDynamicEventTableEntry &operator = ( const wxDynamicEventTableEntry & ); | |
c801d85f KB |
2602 | }; |
2603 | ||
2e4df4bf VZ |
2604 | // ---------------------------------------------------------------------------- |
2605 | // wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0} | |
2606 | // ---------------------------------------------------------------------------- | |
886dd7d2 | 2607 | |
bddd7a8d | 2608 | struct WXDLLIMPEXP_BASE wxEventTable |
c801d85f | 2609 | { |
0b5eceb6 VZ |
2610 | const wxEventTable *baseTable; // base event table (next in chain) |
2611 | const wxEventTableEntry *entries; // bottom of entry array | |
c801d85f KB |
2612 | }; |
2613 | ||
b5a98acd VZ |
2614 | // ---------------------------------------------------------------------------- |
2615 | // wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups. | |
2616 | // ---------------------------------------------------------------------------- | |
2617 | ||
d5d29b8a | 2618 | WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray); |
b5a98acd VZ |
2619 | |
2620 | class WXDLLIMPEXP_BASE wxEventHashTable | |
2621 | { | |
2622 | private: | |
2623 | // Internal data structs | |
2624 | struct EventTypeTable | |
2625 | { | |
2626 | wxEventType eventType; | |
2627 | wxEventTableEntryPointerArray eventEntryTable; | |
2628 | }; | |
2629 | typedef EventTypeTable* EventTypeTablePointer; | |
2630 | ||
2631 | public: | |
2632 | // Constructor, needs the event table it needs to hash later on. | |
1c624631 VZ |
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 | |
b5a98acd VZ |
2635 | // will gets initialized when handling the first event look-up request. |
2636 | wxEventHashTable(const wxEventTable &table); | |
2637 | // Destructor. | |
2638 | ~wxEventHashTable(); | |
2639 | ||
1c624631 | 2640 | // Handle the given event, in other words search the event table hash |
b5a98acd VZ |
2641 | // and call self->ProcessEvent() if a match was found. |
2642 | bool HandleEvent(wxEvent &event, wxEvtHandler *self); | |
2643 | ||
afa039f9 JS |
2644 | // Clear table |
2645 | void Clear(); | |
2646 | ||
aa767a45 | 2647 | #if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING |
afa039f9 JS |
2648 | // Clear all tables |
2649 | static void ClearAll(); | |
a0826b11 | 2650 | #endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING |
afa039f9 | 2651 | |
b5a98acd VZ |
2652 | protected: |
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); | |
1c624631 | 2659 | // Grow the hash table in size and transfer all items currently |
b5a98acd VZ |
2660 | // in the table to the correct location in the new table. |
2661 | void GrowEventTypeTable(); | |
2662 | ||
2663 | protected: | |
2664 | const wxEventTable &m_table; | |
2665 | bool m_rebuildHash; | |
2666 | ||
2667 | size_t m_size; | |
2668 | EventTypeTablePointer *m_eventTypeTable; | |
fc7a2a60 | 2669 | |
afa039f9 JS |
2670 | static wxEventHashTable* sm_first; |
2671 | wxEventHashTable* m_previous; | |
2672 | wxEventHashTable* m_next; | |
2673 | ||
fc7a2a60 | 2674 | DECLARE_NO_COPY_CLASS(wxEventHashTable) |
b5a98acd VZ |
2675 | }; |
2676 | ||
6164f93c | 2677 | // ---------------------------------------------------------------------------- |
77ffb593 | 2678 | // wxEvtHandler: the base class for all objects handling wxWidgets events |
6164f93c VZ |
2679 | // ---------------------------------------------------------------------------- |
2680 | ||
4732e2dc | 2681 | class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject |
4732e2dc | 2682 | , public wxTrackable |
c801d85f | 2683 | { |
2b854a32 VZ |
2684 | public: |
2685 | wxEvtHandler(); | |
6164f93c | 2686 | virtual ~wxEvtHandler(); |
2b854a32 | 2687 | |
7f853dd0 FM |
2688 | |
2689 | // Event handler chain | |
2690 | // ------------------- | |
2691 | ||
2b854a32 VZ |
2692 | wxEvtHandler *GetNextHandler() const { return m_nextHandler; } |
2693 | wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; } | |
7f853dd0 FM |
2694 | virtual void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; } |
2695 | virtual void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; } | |
2b854a32 | 2696 | |
8e193f38 | 2697 | void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; } |
2b854a32 VZ |
2698 | bool GetEvtHandlerEnabled() const { return m_enabled; } |
2699 | ||
7f853dd0 FM |
2700 | void Unlink(); |
2701 | bool IsUnlinked() const; | |
2702 | ||
2703 | ||
2704 | ||
2705 | // Event queuing and processing | |
2706 | // ---------------------------- | |
2707 | ||
2708 | ||
c3f94162 VZ |
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. | |
8e193f38 | 2712 | virtual bool ProcessEvent(wxEvent& event); |
2b854a32 | 2713 | |
937013e0 VS |
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); | |
7f853dd0 | 2719 | // NOTE: uses ProcessEvent() |
937013e0 | 2720 | |
c3f94162 VZ |
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 | } | |
2b854a32 | 2740 | |
8e193f38 | 2741 | void ProcessPendingEvents(); |
7f853dd0 | 2742 | // NOTE: uses ProcessEvent() |
2b854a32 | 2743 | |
7214297d | 2744 | #if wxUSE_THREADS |
76bfdc9a | 2745 | bool ProcessThreadEvent(const wxEvent& event); |
7f853dd0 | 2746 | // NOTE: uses AddPendingEvent() |
7214297d | 2747 | #endif |
2b854a32 | 2748 | |
7f853dd0 FM |
2749 | |
2750 | // Connecting and disconnecting | |
2751 | // ---------------------------- | |
2752 | ||
2b854a32 | 2753 | // Dynamic association of a member function handler with the event handler, |
d9e2e4c2 | 2754 | // winid and event type |
7fa03f04 VZ |
2755 | void Connect(int winid, |
2756 | int lastId, | |
c9c1faa4 | 2757 | wxEventType eventType, |
7fa03f04 | 2758 | wxObjectEventFunction func, |
03f3617b VZ |
2759 | wxObject *userData = NULL, |
2760 | wxEvtHandler *eventSink = NULL) | |
3c778901 VZ |
2761 | { |
2762 | wxObjectEventFunctor *functor = wxNewEventFunctor( eventType, func, eventSink ); | |
2763 | ||
2764 | Subscribe( winid, lastId, eventType, functor, userData ); | |
2765 | } | |
2b854a32 VZ |
2766 | |
2767 | // Convenience function: take just one id | |
7fa03f04 | 2768 | void Connect(int winid, |
c9c1faa4 | 2769 | wxEventType eventType, |
7fa03f04 | 2770 | wxObjectEventFunction func, |
03f3617b VZ |
2771 | wxObject *userData = NULL, |
2772 | wxEvtHandler *eventSink = NULL) | |
65b17727 | 2773 | { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); } |
2b854a32 | 2774 | |
7fa03f04 | 2775 | // Even more convenient: without id (same as using id of wxID_ANY) |
c9c1faa4 | 2776 | void Connect(wxEventType eventType, |
7fa03f04 | 2777 | wxObjectEventFunction func, |
03f3617b VZ |
2778 | wxObject *userData = NULL, |
2779 | wxEvtHandler *eventSink = NULL) | |
7fa03f04 VZ |
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, | |
03f3617b VZ |
2786 | wxObject *userData = NULL, |
2787 | wxEvtHandler *eventSink = NULL) | |
3c778901 VZ |
2788 | { |
2789 | wxObjectEventFunctor functor = wxConstructEventFunctor( eventType, func, eventSink ); | |
2790 | ||
2791 | return Unsubscribe( winid, lastId, eventType, functor, userData ); | |
2792 | } | |
7fa03f04 | 2793 | |
e554d626 | 2794 | bool Disconnect(int winid = wxID_ANY, |
7fa03f04 VZ |
2795 | wxEventType eventType = wxEVT_NULL, |
2796 | wxObjectEventFunction func = NULL, | |
03f3617b VZ |
2797 | wxObject *userData = NULL, |
2798 | wxEvtHandler *eventSink = NULL) | |
65b17727 | 2799 | { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); } |
98243fed | 2800 | |
bdbe28fa | 2801 | bool Disconnect(wxEventType eventType, |
e0685bb0 | 2802 | wxObjectEventFunction func, |
03f3617b VZ |
2803 | wxObject *userData = NULL, |
2804 | wxEvtHandler *eventSink = NULL) | |
bdbe28fa | 2805 | { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); } |
3c778901 | 2806 | #if !wxEVENTS_COMPATIBILITY_2_8 |
3c778901 VZ |
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 | ||
111d41b2 VZ |
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 | ||
3c778901 VZ |
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 | ||
10da6a8f | 3108 | wxList* GetDynamicEventTable() const { return m_dynamicEvents ; } |
b88c44e7 RD |
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 | ||
25250d33 VZ |
3117 | |
3118 | // implementation from now on | |
3119 | // -------------------------- | |
3120 | ||
03f3617b VZ |
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 | |
1c624631 VZ |
3124 | // |
3125 | // return true if the event was processed, false otherwise (no match or the | |
3126 | // handler decided to skip the event) | |
03f3617b VZ |
3127 | static bool ProcessEventIfMatchesId(const wxEventTableEntryBase& tableEntry, |
3128 | wxEvtHandler *handler, | |
3129 | wxEvent& event); | |
b88c44e7 | 3130 | |
8e193f38 | 3131 | virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); |
2b854a32 | 3132 | bool SearchDynamicEventTable( wxEvent& event ); |
c801d85f | 3133 | |
afa039f9 JS |
3134 | // Avoid problems at exit by cleaning up static hash table gracefully |
3135 | void ClearEventHashTable() { GetEventHashTable().Clear(); } | |
2ef989c9 | 3136 | void OnSinkDestroyed( wxEvtHandler *sink ); |
afa039f9 | 3137 | |
25250d33 | 3138 | |
29de6f40 | 3139 | // The method tries to process the event in this event handler. |
25250d33 VZ |
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 | ||
c801d85f | 3147 | private: |
3c778901 VZ |
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 | ||
8e193f38 | 3160 | static const wxEventTableEntry sm_eventTableEntries[]; |
2b854a32 | 3161 | |
c801d85f | 3162 | protected: |
4caf847c VZ |
3163 | // hooks for wxWindow used by ProcessEvent() |
3164 | // ----------------------------------------- | |
3165 | ||
6eabf58c VS |
3166 | // This one is called before trying our own event table to allow plugging |
3167 | // in the validators. | |
1c624631 | 3168 | // |
6eabf58c VS |
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 | |
3103e8a9 | 3172 | // binary compatibility and wxBase library can't be used by GUI |
6eabf58c | 3173 | // ports. |
4caf847c | 3174 | virtual bool TryValidator(wxEvent& WXUNUSED(event)) { return false; } |
4caf847c VZ |
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 | ||
1c624631 | 3183 | static const wxEventTable sm_eventTable; |
193bf013 VZ |
3184 | virtual const wxEventTable *GetEventTable() const; |
3185 | ||
b5a98acd VZ |
3186 | static wxEventHashTable sm_eventHashTable; |
3187 | virtual wxEventHashTable& GetEventHashTable() const; | |
3188 | ||
63863e09 JS |
3189 | wxEvtHandler* m_nextHandler; |
3190 | wxEvtHandler* m_previousHandler; | |
63863e09 | 3191 | wxList* m_dynamicEvents; |
42e69d6b | 3192 | wxList* m_pendingEvents; |
6164f93c | 3193 | |
7214297d | 3194 | #if wxUSE_THREADS |
8ebec7dc VZ |
3195 | // critical section protecting m_pendingEvents |
3196 | wxCriticalSection m_pendingEventsLock; | |
3197 | #endif // wxUSE_THREADS | |
193bf013 | 3198 | |
8e193f38 VZ |
3199 | // Is event handler enabled? |
3200 | bool m_enabled; | |
6164f93c | 3201 | |
b88c44e7 RD |
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 | ||
2ef989c9 | 3224 | // Search tracker objects for event connection with this sink |
cc6ceca7 | 3225 | wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *eventSink); |
2ef989c9 | 3226 | |
6164f93c | 3227 | private: |
fc7a2a60 | 3228 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler) |
c801d85f KB |
3229 | }; |
3230 | ||
cc6ceca7 VZ |
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 | ||
3238 | class wxEventConnectionRef : public wxTrackerNode | |
3239 | { | |
3240 | public: | |
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 | ||
3270 | private: | |
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 | ||
c3f94162 VZ |
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() | |
76bfdc9a | 3284 | inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event) |
e2478fde | 3285 | { |
c3f94162 | 3286 | wxCHECK_RET( dest, "need an object to post event to" ); |
e2478fde VZ |
3287 | |
3288 | dest->AddPendingEvent(event); | |
3289 | } | |
3290 | ||
c3f94162 VZ |
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 | |
3294 | inline 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 | ||
96d38c7e | 3301 | typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); |
85ee6241 | 3302 | typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); |
96d38c7e | 3303 | |
7fa03f04 | 3304 | #define wxEventHandler(func) \ |
3c778901 | 3305 | wxEVENT_HANDLER_CAST(wxEventFunction, func) |
85ee6241 | 3306 | #define wxIdleEventHandler(func) \ |
3c778901 | 3307 | wxEVENT_HANDLER_CAST(wxIdleEventFunction, func) |
7fa03f04 | 3308 | |
e90c1d2a | 3309 | #if wxUSE_GUI |
7fa03f04 | 3310 | |
c4fa5aa7 VZ |
3311 | // ---------------------------------------------------------------------------- |
3312 | // wxEventBlocker: helper class to temporarily disable event handling for a window | |
3313 | // ---------------------------------------------------------------------------- | |
3314 | ||
b483f5fe | 3315 | class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler |
c4fa5aa7 VZ |
3316 | { |
3317 | public: | |
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 | ||
3328 | protected: | |
3329 | wxArrayInt m_eventsToBlock; | |
3330 | wxWindow *m_window; | |
3331 | ||
3332 | DECLARE_NO_COPY_CLASS(wxEventBlocker) | |
3333 | }; | |
3334 | ||
c801d85f KB |
3335 | typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); |
3336 | typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&); | |
c5b42c87 | 3337 | typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&); |
c801d85f KB |
3338 | typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&); |
3339 | typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&); | |
3340 | typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&); | |
7309deea | 3341 | typedef void (wxEvtHandler::*wxNcPaintEventFunction)(wxNcPaintEvent&); |
c801d85f KB |
3342 | typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&); |
3343 | typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&); | |
3344 | typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&); | |
3345 | typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&); | |
456bc6d9 | 3346 | typedef void (wxEvtHandler::*wxChildFocusEventFunction)(wxChildFocusEvent&); |
c801d85f KB |
3347 | typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&); |
3348 | typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&); | |
3349 | typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&); | |
3350 | typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&); | |
3351 | typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&); | |
7fa03f04 VZ |
3352 | typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&); |
3353 | typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&); | |
c801d85f | 3354 | typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&); |
c801d85f KB |
3355 | typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&); |
3356 | typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&); | |
9bc13858 | 3357 | typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&); |
98e78a5e | 3358 | typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxMaximizeEvent&); |
81d66cf3 | 3359 | typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&); |
f7bd2698 JS |
3360 | typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&); |
3361 | typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&); | |
43b5058d VZ |
3362 | typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&); |
3363 | typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&); | |
3364 | typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&); | |
669f7a11 | 3365 | typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&); |
b96340e6 | 3366 | typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&); |
69231000 | 3367 | typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); |
a5e84126 | 3368 | typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&); |
63e819f2 | 3369 | typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&); |
78c91815 | 3370 | typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&); |
7fa03f04 | 3371 | |
7fa03f04 VZ |
3372 | |
3373 | #define wxCommandEventHandler(func) \ | |
3c778901 | 3374 | wxEVENT_HANDLER_CAST(wxCommandEventFunction, func) |
7fa03f04 | 3375 | #define wxScrollEventHandler(func) \ |
3c778901 | 3376 | wxEVENT_HANDLER_CAST(wxScrollEventFunction, func) |
7fa03f04 | 3377 | #define wxScrollWinEventHandler(func) \ |
3c778901 | 3378 | wxEVENT_HANDLER_CAST(wxScrollWinEventFunction, func) |
7fa03f04 | 3379 | #define wxSizeEventHandler(func) \ |
3c778901 | 3380 | wxEVENT_HANDLER_CAST(wxSizeEventFunction, func) |
7fa03f04 | 3381 | #define wxMoveEventHandler(func) \ |
3c778901 | 3382 | wxEVENT_HANDLER_CAST(wxMoveEventFunction, func) |
7fa03f04 | 3383 | #define wxPaintEventHandler(func) \ |
3c778901 | 3384 | wxEVENT_HANDLER_CAST(wxPaintEventFunction, func) |
7fa03f04 | 3385 | #define wxNcPaintEventHandler(func) \ |
3c778901 | 3386 | wxEVENT_HANDLER_CAST(wxNcPaintEventFunction, func) |
7fa03f04 | 3387 | #define wxEraseEventHandler(func) \ |
3c778901 | 3388 | wxEVENT_HANDLER_CAST(wxEraseEventFunction, func) |
7fa03f04 | 3389 | #define wxMouseEventHandler(func) \ |
3c778901 | 3390 | wxEVENT_HANDLER_CAST(wxMouseEventFunction, func) |
7fa03f04 | 3391 | #define wxCharEventHandler(func) \ |
3c778901 | 3392 | wxEVENT_HANDLER_CAST(wxCharEventFunction, func) |
7fa03f04 VZ |
3393 | #define wxKeyEventHandler(func) wxCharEventHandler(func) |
3394 | #define wxFocusEventHandler(func) \ | |
3c778901 | 3395 | wxEVENT_HANDLER_CAST(wxFocusEventFunction, func) |
7fa03f04 | 3396 | #define wxChildFocusEventHandler(func) \ |
3c778901 | 3397 | wxEVENT_HANDLER_CAST(wxChildFocusEventFunction, func) |
7fa03f04 | 3398 | #define wxActivateEventHandler(func) \ |
3c778901 | 3399 | wxEVENT_HANDLER_CAST(wxActivateEventFunction, func) |
7fa03f04 | 3400 | #define wxMenuEventHandler(func) \ |
3c778901 | 3401 | wxEVENT_HANDLER_CAST(wxMenuEventFunction, func) |
7fa03f04 | 3402 | #define wxJoystickEventHandler(func) \ |
3c778901 | 3403 | wxEVENT_HANDLER_CAST(wxJoystickEventFunction, func) |
7fa03f04 | 3404 | #define wxDropFilesEventHandler(func) \ |
3c778901 | 3405 | wxEVENT_HANDLER_CAST(wxDropFilesEventFunction, func) |
7fa03f04 | 3406 | #define wxInitDialogEventHandler(func) \ |
3c778901 | 3407 | wxEVENT_HANDLER_CAST(wxInitDialogEventFunction, func) |
7fa03f04 | 3408 | #define wxSysColourChangedEventHandler(func) \ |
3c778901 | 3409 | wxEVENT_HANDLER_CAST(wxSysColourChangedEventFunction, func) |
7fa03f04 | 3410 | #define wxDisplayChangedEventHandler(func) \ |
3c778901 | 3411 | wxEVENT_HANDLER_CAST(wxDisplayChangedEventFunction, func) |
7fa03f04 | 3412 | #define wxUpdateUIEventHandler(func) \ |
3c778901 | 3413 | wxEVENT_HANDLER_CAST(wxUpdateUIEventFunction, func) |
7fa03f04 | 3414 | #define wxCloseEventHandler(func) \ |
3c778901 | 3415 | wxEVENT_HANDLER_CAST(wxCloseEventFunction, func) |
7fa03f04 | 3416 | #define wxShowEventHandler(func) \ |
3c778901 | 3417 | wxEVENT_HANDLER_CAST(wxShowEventFunction, func) |
7fa03f04 | 3418 | #define wxIconizeEventHandler(func) \ |
3c778901 | 3419 | wxEVENT_HANDLER_CAST(wxIconizeEventFunction, func) |
7fa03f04 | 3420 | #define wxMaximizeEventHandler(func) \ |
3c778901 | 3421 | wxEVENT_HANDLER_CAST(wxMaximizeEventFunction, func) |
7fa03f04 | 3422 | #define wxNavigationKeyEventHandler(func) \ |
3c778901 | 3423 | wxEVENT_HANDLER_CAST(wxNavigationKeyEventFunction, func) |
7fa03f04 | 3424 | #define wxPaletteChangedEventHandler(func) \ |
3c778901 | 3425 | wxEVENT_HANDLER_CAST(wxPaletteChangedEventFunction, func) |
7fa03f04 | 3426 | #define wxQueryNewPaletteEventHandler(func) \ |
3c778901 | 3427 | wxEVENT_HANDLER_CAST(wxQueryNewPaletteEventFunction, func) |
7fa03f04 | 3428 | #define wxWindowCreateEventHandler(func) \ |
3c778901 | 3429 | wxEVENT_HANDLER_CAST(wxWindowCreateEventFunction, func) |
7fa03f04 | 3430 | #define wxWindowDestroyEventHandler(func) \ |
3c778901 | 3431 | wxEVENT_HANDLER_CAST(wxWindowDestroyEventFunction, func) |
7fa03f04 | 3432 | #define wxSetCursorEventHandler(func) \ |
3c778901 | 3433 | wxEVENT_HANDLER_CAST(wxSetCursorEventFunction, func) |
7fa03f04 | 3434 | #define wxNotifyEventHandler(func) \ |
3c778901 | 3435 | wxEVENT_HANDLER_CAST(wxNotifyEventFunction, func) |
7fa03f04 | 3436 | #define wxHelpEventHandler(func) \ |
3c778901 | 3437 | wxEVENT_HANDLER_CAST(wxHelpEventFunction, func) |
7fa03f04 | 3438 | #define wxContextMenuEventHandler(func) \ |
3c778901 | 3439 | wxEVENT_HANDLER_CAST(wxContextMenuEventFunction, func) |
7fa03f04 | 3440 | #define wxMouseCaptureChangedEventHandler(func) \ |
3c778901 | 3441 | wxEVENT_HANDLER_CAST(wxMouseCaptureChangedEventFunction, func) |
63e819f2 | 3442 | #define wxMouseCaptureLostEventHandler(func) \ |
3c778901 | 3443 | wxEVENT_HANDLER_CAST(wxMouseCaptureLostEventFunction, func) |
78c91815 | 3444 | #define wxClipboardTextEventHandler(func) \ |
3c778901 | 3445 | wxEVENT_HANDLER_CAST(wxClipboardTextEventFunction, func) |
7fa03f04 | 3446 | |
e90c1d2a | 3447 | #endif // wxUSE_GUI |
c801d85f KB |
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() \ | |
2e4df4bf VZ |
3453 | private: \ |
3454 | static const wxEventTableEntry sm_eventTableEntries[]; \ | |
3455 | protected: \ | |
3456 | static const wxEventTable sm_eventTable; \ | |
b5a98acd VZ |
3457 | virtual const wxEventTable* GetEventTable() const; \ |
3458 | static wxEventHashTable sm_eventHashTable; \ | |
3459 | virtual wxEventHashTable& GetEventHashTable() const; | |
c801d85f | 3460 | |
48276300 VZ |
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) | |
b5a98acd | 3464 | |
c801d85f | 3465 | #define BEGIN_EVENT_TABLE(theClass, baseClass) \ |
2e4df4bf VZ |
3466 | const wxEventTable theClass::sm_eventTable = \ |
3467 | { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ | |
48276300 VZ |
3468 | const wxEventTable *theClass::GetEventTable() const \ |
3469 | { return &theClass::sm_eventTable; } \ | |
b5a98acd VZ |
3470 | wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ |
3471 | wxEventHashTable &theClass::GetEventHashTable() const \ | |
3472 | { return theClass::sm_eventHashTable; } \ | |
2e4df4bf | 3473 | const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ |
c801d85f | 3474 | |
f96a9d34 JS |
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 | ||
3c778901 | 3580 | #define END_EVENT_TABLE() DECLARE_EVENT_TABLE_TERMINATOR() }; |
2b854a32 | 3581 | |
c801d85f KB |
3582 | /* |
3583 | * Event table macros | |
3584 | */ | |
3585 | ||
7fa03f04 VZ |
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 | ||
c801d85f | 3601 | // Generic events |
7fa03f04 VZ |
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)) | |
c801d85f | 3606 | |
265accbe | 3607 | // EVT_COMMAND |
96eb51bb | 3608 | #define EVT_COMMAND(winid, event, func) \ |
7fa03f04 | 3609 | wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func)) |
3c778901 | 3610 | |
96eb51bb | 3611 | #define EVT_COMMAND_RANGE(id1, id2, event, func) \ |
7fa03f04 | 3612 | wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func)) |
265accbe | 3613 | |
7fa03f04 VZ |
3614 | #define EVT_NOTIFY(event, winid, func) \ |
3615 | wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func)) | |
3c778901 | 3616 | |
7fa03f04 VZ |
3617 | #define EVT_NOTIFY_RANGE(event, id1, id2, func) \ |
3618 | wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func)) | |
265accbe | 3619 | |
c801d85f | 3620 | // Miscellaneous |
7fa03f04 VZ |
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)) | |
aa767a45 JS |
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)) | |
7fa03f04 VZ |
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)) | |
5048c832 | 3636 | #if wxUSE_HOTKEY |
7fa03f04 | 3637 | #define EVT_HOTKEY(winid, func) wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func)) |
5048c832 | 3638 | #endif |
7fa03f04 VZ |
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)) | |
afafd942 | 3649 | #define EVT_HIBERNATE(func) wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func)) |
7fa03f04 VZ |
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)) | |
63e819f2 | 3666 | #define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func)) |
c801d85f KB |
3667 | |
3668 | // Mouse events | |
7fa03f04 VZ |
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)) | |
01101e2d VZ |
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)) | |
c801d85f KB |
3688 | |
3689 | // All mouse events | |
3690 | #define EVT_MOUSE_EVENTS(func) \ | |
7fa03f04 VZ |
3691 | EVT_LEFT_DOWN(func) \ |
3692 | EVT_LEFT_UP(func) \ | |
01101e2d | 3693 | EVT_LEFT_DCLICK(func) \ |
7fa03f04 VZ |
3694 | EVT_MIDDLE_DOWN(func) \ |
3695 | EVT_MIDDLE_UP(func) \ | |
01101e2d | 3696 | EVT_MIDDLE_DCLICK(func) \ |
7fa03f04 VZ |
3697 | EVT_RIGHT_DOWN(func) \ |
3698 | EVT_RIGHT_UP(func) \ | |
7fa03f04 | 3699 | EVT_RIGHT_DCLICK(func) \ |
01101e2d VZ |
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) \ | |
7fa03f04 VZ |
3707 | EVT_LEAVE_WINDOW(func) \ |
3708 | EVT_ENTER_WINDOW(func) \ | |
3709 | EVT_MOUSEWHEEL(func) | |
c801d85f | 3710 | |
c5b42c87 | 3711 | // Scrolling from wxWindow (sent to wxScrolledWindow) |
7fa03f04 VZ |
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 | ||
c5b42c87 | 3721 | #define EVT_SCROLLWIN(func) \ |
7fa03f04 VZ |
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) | |
c5b42c87 RR |
3730 | |
3731 | // Scrolling from wxSlider and wxScrollBar | |
7fa03f04 VZ |
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)) | |
cbc85508 | 3740 | #define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func)) |
7fa03f04 | 3741 | |
c801d85f | 3742 | #define EVT_SCROLL(func) \ |
7fa03f04 VZ |
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) \ | |
e8739575 | 3750 | EVT_SCROLL_THUMBRELEASE(func) \ |
84006e65 | 3751 | EVT_SCROLL_CHANGED(func) |
c801d85f | 3752 | |
c5b42c87 | 3753 | // Scrolling from wxSlider and wxScrollBar, with an id |
7fa03f04 VZ |
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)) | |
cbc85508 | 3762 | #define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func)) |
7fa03f04 | 3763 | |
d9e2e4c2 | 3764 | #define EVT_COMMAND_SCROLL(winid, func) \ |
7fa03f04 VZ |
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) \ | |
e8739575 | 3772 | EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \ |
84006e65 | 3773 | EVT_COMMAND_SCROLL_CHANGED(winid, func) |
cbc85508 | 3774 | |
ca3e85cf WS |
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 | |
c801d85f KB |
3781 | |
3782 | // Convenience macros for commonly-used commands | |
7fa03f04 VZ |
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)) | |
119727ad | 3789 | #if defined(__SMARTPHONE__) |
7fa03f04 | 3790 | # define EVT_BUTTON(winid, func) EVT_MENU(winid, func) |
119727ad | 3791 | #else |
7fa03f04 | 3792 | # define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_BUTTON_CLICKED, winid, wxCommandEventHandler(func)) |
119727ad | 3793 | #endif |
7fa03f04 VZ |
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)) | |
c801d85f | 3797 | // EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events |
7fa03f04 VZ |
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)) | |
a9a0ceca | 3802 | #define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, winid, wxCommandEventHandler(func)) |
7fa03f04 VZ |
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)) | |
c801d85f KB |
3808 | |
3809 | // Generic command events | |
7fa03f04 VZ |
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)) | |
c801d85f KB |
3817 | |
3818 | // Joystick events | |
1241ab8b | 3819 | |
7fa03f04 VZ |
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)) | |
c801d85f KB |
3824 | |
3825 | // All joystick events | |
3826 | #define EVT_JOYSTICK_EVENTS(func) \ | |
7fa03f04 VZ |
3827 | EVT_JOY_BUTTON_DOWN(func) \ |
3828 | EVT_JOY_BUTTON_UP(func) \ | |
3829 | EVT_JOY_MOVE(func) \ | |
3830 | EVT_JOY_ZMOVE(func) | |
c801d85f KB |
3831 | |
3832 | // Idle event | |
7fa03f04 | 3833 | #define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func)) |
c801d85f KB |
3834 | |
3835 | // Update UI event | |
7fa03f04 VZ |
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)) | |
c801d85f | 3838 | |
b96340e6 | 3839 | // Help events |
7fa03f04 VZ |
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)) | |
fb6261e9 | 3844 | |
69231000 | 3845 | // Context Menu Events |
7fa03f04 | 3846 | #define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func)) |
5cd2a6ae | 3847 | #define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func)) |
69231000 | 3848 | |
78c91815 VZ |
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 | ||
8e193f38 VZ |
3854 | // ---------------------------------------------------------------------------- |
3855 | // Global data | |
3856 | // ---------------------------------------------------------------------------- | |
3857 | ||
19c4d916 VZ |
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 | |
079f4130 | 3861 | extern WXDLLIMPEXP_BASE wxList *wxHandlersWithPendingEvents; |
8e193f38 | 3862 | #if wxUSE_THREADS |
079f4130 | 3863 | extern WXDLLIMPEXP_BASE wxCriticalSection *wxHandlersWithPendingEventsLocker; |
8e193f38 VZ |
3864 | #endif |
3865 | ||
e90c1d2a VZ |
3866 | // ---------------------------------------------------------------------------- |
3867 | // Helper functions | |
3868 | // ---------------------------------------------------------------------------- | |
3869 | ||
3870 | #if wxUSE_GUI | |
e702ff0f JS |
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. | |
9f8b9d9c | 3874 | WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor); |
e702ff0f | 3875 | |
e90c1d2a VZ |
3876 | #endif // wxUSE_GUI |
3877 | ||
204abcd4 | 3878 | #endif // _WX_EVENT_H_ |