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