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