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