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