check for self-assignment in operator=
[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) { if (&event != this) 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 if (&evt != this)
944 {
945 m_x = evt.m_x;
946 m_y = evt.m_y;
947
948 m_keyCode = evt.m_keyCode;
949
950 m_controlDown = evt.m_controlDown;
951 m_shiftDown = evt.m_shiftDown;
952 m_altDown = evt.m_altDown;
953 m_metaDown = evt.m_metaDown;
954 m_scanCode = evt.m_scanCode;
955 m_rawCode = evt.m_rawCode;
956 m_rawFlags = evt.m_rawFlags;
957 #if wxUSE_UNICODE
958 m_uniChar = evt.m_uniChar;
959 #endif
960 }
961 return *this;
962 }
963
964 public:
965 wxCoord m_x, m_y;
966
967 long m_keyCode;
968
969 // TODO: replace those with a single m_modifiers bitmask of wxMOD_XXX?
970 bool m_controlDown;
971 bool m_shiftDown;
972 bool m_altDown;
973 bool m_metaDown;
974
975 // FIXME: what is this for? relation to m_rawXXX?
976 bool m_scanCode;
977
978 #if wxUSE_UNICODE
979 // This contains the full Unicode character
980 // in a character events in Unicode mode
981 wxChar m_uniChar;
982 #endif
983
984 // these fields contain the platform-specific information about
985 // key that was pressed
986 wxUint32 m_rawCode;
987 wxUint32 m_rawFlags;
988
989 private:
990 DECLARE_DYNAMIC_CLASS(wxKeyEvent)
991 };
992
993 // Size event class
994 /*
995 wxEVT_SIZE
996 */
997
998 class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent
999 {
1000 public:
1001 wxSizeEvent() : wxEvent(0, wxEVT_SIZE)
1002 { }
1003 wxSizeEvent(const wxSize& sz, int winid = 0)
1004 : wxEvent(winid, wxEVT_SIZE),
1005 m_size(sz)
1006 { }
1007 wxSizeEvent(const wxSizeEvent & event)
1008 : wxEvent(event),
1009 m_size(event.m_size), m_rect(event.m_rect)
1010 { }
1011 wxSizeEvent(const wxRect& rect, int id = 0)
1012 : m_size(rect.GetSize()), m_rect(rect)
1013 { m_eventType = wxEVT_SIZING; m_id = id; }
1014
1015 wxSize GetSize() const { return m_size; }
1016 wxRect GetRect() const { return m_rect; }
1017 void SetRect(const wxRect& rect) { m_rect = rect; }
1018
1019 virtual wxEvent *Clone() const { return new wxSizeEvent(*this); }
1020
1021 public:
1022 // For internal usage only. Will be converted to protected members.
1023 wxSize m_size;
1024 wxRect m_rect; // Used for wxEVT_SIZING
1025
1026 private:
1027 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent)
1028 };
1029
1030 // Move event class
1031
1032 /*
1033 wxEVT_MOVE
1034 */
1035
1036 class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent
1037 {
1038 public:
1039 wxMoveEvent()
1040 : wxEvent(0, wxEVT_MOVE)
1041 { }
1042 wxMoveEvent(const wxPoint& pos, int winid = 0)
1043 : wxEvent(winid, wxEVT_MOVE),
1044 m_pos(pos)
1045 { }
1046 wxMoveEvent(const wxMoveEvent& event)
1047 : wxEvent(event),
1048 m_pos(event.m_pos)
1049 { }
1050 wxMoveEvent(const wxRect& rect, int id = 0)
1051 : m_pos(rect.GetPosition()), m_rect(rect)
1052 { m_eventType = wxEVT_MOVING; m_id = id; }
1053
1054 wxPoint GetPosition() const { return m_pos; }
1055 void SetPosition(const wxPoint& pos) { m_pos = pos; }
1056 wxRect GetRect() const { return m_rect; }
1057 void SetRect(const wxRect& rect) { m_rect = rect; }
1058
1059 virtual wxEvent *Clone() const { return new wxMoveEvent(*this); }
1060
1061 protected:
1062 wxPoint m_pos;
1063 wxRect m_rect;
1064
1065 private:
1066 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent)
1067 };
1068
1069 // Paint event class
1070 /*
1071 wxEVT_PAINT
1072 wxEVT_NC_PAINT
1073 wxEVT_PAINT_ICON
1074 */
1075
1076 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
1077 // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
1078 extern WXDLLIMPEXP_CORE int g_isPainting;
1079 #endif // debug
1080
1081 class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
1082 {
1083 public:
1084 wxPaintEvent(int Id = 0)
1085 : wxEvent(Id, wxEVT_PAINT)
1086 {
1087 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
1088 // set the internal flag for the duration of processing of WM_PAINT
1089 g_isPainting++;
1090 #endif // debug
1091 }
1092
1093 // default copy ctor and dtor are normally fine, we only need them to keep
1094 // g_isPainting updated in debug build
1095 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
1096 wxPaintEvent(const wxPaintEvent& event)
1097 : wxEvent(event)
1098 {
1099 g_isPainting++;
1100 }
1101
1102 virtual ~wxPaintEvent()
1103 {
1104 g_isPainting--;
1105 }
1106 #endif // debug
1107
1108 virtual wxEvent *Clone() const { return new wxPaintEvent(*this); }
1109
1110 private:
1111 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent)
1112 };
1113
1114 class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
1115 {
1116 public:
1117 wxNcPaintEvent(int winid = 0)
1118 : wxEvent(winid, wxEVT_NC_PAINT)
1119 { }
1120
1121 virtual wxEvent *Clone() const { return new wxNcPaintEvent(*this); }
1122
1123 private:
1124 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent)
1125 };
1126
1127 // Erase background event class
1128 /*
1129 wxEVT_ERASE_BACKGROUND
1130 */
1131
1132 class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent
1133 {
1134 public:
1135 wxEraseEvent(int Id = 0, wxDC *dc = (wxDC *) NULL)
1136 : wxEvent(Id, wxEVT_ERASE_BACKGROUND),
1137 m_dc(dc)
1138 { }
1139
1140 wxEraseEvent(const wxEraseEvent& event)
1141 : wxEvent(event),
1142 m_dc(event.m_dc)
1143 { }
1144
1145 wxDC *GetDC() const { return m_dc; }
1146
1147 virtual wxEvent *Clone() const { return new wxEraseEvent(*this); }
1148
1149 protected:
1150 wxDC *m_dc;
1151
1152 private:
1153 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent)
1154 };
1155
1156 // Focus event class
1157 /*
1158 wxEVT_SET_FOCUS
1159 wxEVT_KILL_FOCUS
1160 */
1161
1162 class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent
1163 {
1164 public:
1165 wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0)
1166 : wxEvent(winid, type)
1167 { m_win = NULL; }
1168
1169 wxFocusEvent(const wxFocusEvent& event)
1170 : wxEvent(event)
1171 { m_win = event.m_win; }
1172
1173 // The window associated with this event is the window which had focus
1174 // before for SET event and the window which will have focus for the KILL
1175 // one. NB: it may be NULL in both cases!
1176 wxWindow *GetWindow() const { return m_win; }
1177 void SetWindow(wxWindow *win) { m_win = win; }
1178
1179 virtual wxEvent *Clone() const { return new wxFocusEvent(*this); }
1180
1181 private:
1182 wxWindow *m_win;
1183
1184 private:
1185 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent)
1186 };
1187
1188 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
1189 // wxFocusEvent it is propagated upwards the window chain
1190 class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent
1191 {
1192 public:
1193 wxChildFocusEvent(wxWindow *win = NULL);
1194
1195 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
1196
1197 virtual wxEvent *Clone() const { return new wxChildFocusEvent(*this); }
1198
1199 private:
1200 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent)
1201 };
1202
1203 // Activate event class
1204 /*
1205 wxEVT_ACTIVATE
1206 wxEVT_ACTIVATE_APP
1207 wxEVT_HIBERNATE
1208 */
1209
1210 class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent
1211 {
1212 public:
1213 wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, int Id = 0)
1214 : wxEvent(Id, type)
1215 { m_active = active; }
1216 wxActivateEvent(const wxActivateEvent& event)
1217 : wxEvent(event)
1218 { m_active = event.m_active; }
1219
1220 bool GetActive() const { return m_active; }
1221
1222 virtual wxEvent *Clone() const { return new wxActivateEvent(*this); }
1223
1224 private:
1225 bool m_active;
1226
1227 private:
1228 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent)
1229 };
1230
1231 // InitDialog event class
1232 /*
1233 wxEVT_INIT_DIALOG
1234 */
1235
1236 class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent
1237 {
1238 public:
1239 wxInitDialogEvent(int Id = 0)
1240 : wxEvent(Id, wxEVT_INIT_DIALOG)
1241 { }
1242
1243 virtual wxEvent *Clone() const { return new wxInitDialogEvent(*this); }
1244
1245 private:
1246 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent)
1247 };
1248
1249 // Miscellaneous menu event class
1250 /*
1251 wxEVT_MENU_OPEN,
1252 wxEVT_MENU_CLOSE,
1253 wxEVT_MENU_HIGHLIGHT,
1254 */
1255
1256 class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent
1257 {
1258 public:
1259 wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL)
1260 : wxEvent(winid, type)
1261 { m_menuId = winid; m_menu = menu; }
1262 wxMenuEvent(const wxMenuEvent & event)
1263 : wxEvent(event)
1264 { m_menuId = event.m_menuId; m_menu = event.m_menu; }
1265
1266 // only for wxEVT_MENU_HIGHLIGHT
1267 int GetMenuId() const { return m_menuId; }
1268
1269 // only for wxEVT_MENU_OPEN/CLOSE
1270 bool IsPopup() const { return m_menuId == wxID_ANY; }
1271
1272 // only for wxEVT_MENU_OPEN/CLOSE
1273 wxMenu* GetMenu() const { return m_menu; }
1274
1275 virtual wxEvent *Clone() const { return new wxMenuEvent(*this); }
1276
1277 private:
1278 int m_menuId;
1279 wxMenu* m_menu;
1280
1281 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent)
1282 };
1283
1284 // Window close or session close event class
1285 /*
1286 wxEVT_CLOSE_WINDOW,
1287 wxEVT_END_SESSION,
1288 wxEVT_QUERY_END_SESSION
1289 */
1290
1291 class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent
1292 {
1293 public:
1294 wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0)
1295 : wxEvent(winid, type),
1296 m_loggingOff(true),
1297 m_veto(false), // should be false by default
1298 m_canVeto(true) {}
1299
1300 wxCloseEvent(const wxCloseEvent & event)
1301 : wxEvent(event),
1302 m_loggingOff(event.m_loggingOff),
1303 m_veto(event.m_veto),
1304 m_canVeto(event.m_canVeto) {}
1305
1306 void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
1307 bool GetLoggingOff() const
1308 {
1309 // m_loggingOff flag is only used by wxEVT_[QUERY_]END_SESSION, it
1310 // doesn't make sense for wxEVT_CLOSE_WINDOW
1311 wxASSERT_MSG( m_eventType != wxEVT_CLOSE_WINDOW,
1312 _T("this flag is for end session events only") );
1313
1314 return m_loggingOff;
1315 }
1316
1317 void Veto(bool veto = true)
1318 {
1319 // GetVeto() will return false anyhow...
1320 wxCHECK_RET( m_canVeto,
1321 wxT("call to Veto() ignored (can't veto this event)") );
1322
1323 m_veto = veto;
1324 }
1325 void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
1326 bool CanVeto() const { return m_canVeto; }
1327 bool GetVeto() const { return m_canVeto && m_veto; }
1328
1329 virtual wxEvent *Clone() const { return new wxCloseEvent(*this); }
1330
1331 protected:
1332 bool m_loggingOff,
1333 m_veto,
1334 m_canVeto;
1335
1336 private:
1337 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent)
1338 };
1339
1340 /*
1341 wxEVT_SHOW
1342 */
1343
1344 class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent
1345 {
1346 public:
1347 wxShowEvent(int winid = 0, bool show = false)
1348 : wxEvent(winid, wxEVT_SHOW)
1349 { m_show = show; }
1350 wxShowEvent(const wxShowEvent & event)
1351 : wxEvent(event)
1352 { m_show = event.m_show; }
1353
1354 void SetShow(bool show) { m_show = show; }
1355 bool GetShow() const { return m_show; }
1356
1357 virtual wxEvent *Clone() const { return new wxShowEvent(*this); }
1358
1359 protected:
1360 bool m_show;
1361
1362 private:
1363 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent)
1364 };
1365
1366 /*
1367 wxEVT_ICONIZE
1368 */
1369
1370 class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent
1371 {
1372 public:
1373 wxIconizeEvent(int winid = 0, bool iconized = true)
1374 : wxEvent(winid, wxEVT_ICONIZE)
1375 { m_iconized = iconized; }
1376 wxIconizeEvent(const wxIconizeEvent & event)
1377 : wxEvent(event)
1378 { m_iconized = event.m_iconized; }
1379
1380 // return true if the frame was iconized, false if restored
1381 bool Iconized() const { return m_iconized; }
1382
1383 virtual wxEvent *Clone() const { return new wxIconizeEvent(*this); }
1384
1385 protected:
1386 bool m_iconized;
1387
1388 private:
1389 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent)
1390 };
1391 /*
1392 wxEVT_MAXIMIZE
1393 */
1394
1395 class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent
1396 {
1397 public:
1398 wxMaximizeEvent(int winid = 0)
1399 : wxEvent(winid, wxEVT_MAXIMIZE)
1400 { }
1401
1402 virtual wxEvent *Clone() const { return new wxMaximizeEvent(*this); }
1403
1404 private:
1405 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent)
1406 };
1407
1408 // Joystick event class
1409 /*
1410 wxEVT_JOY_BUTTON_DOWN,
1411 wxEVT_JOY_BUTTON_UP,
1412 wxEVT_JOY_MOVE,
1413 wxEVT_JOY_ZMOVE
1414 */
1415
1416 // Which joystick? Same as Windows ids so no conversion necessary.
1417 enum
1418 {
1419 wxJOYSTICK1,
1420 wxJOYSTICK2
1421 };
1422
1423 // Which button is down?
1424 enum
1425 {
1426 wxJOY_BUTTON_ANY = -1,
1427 wxJOY_BUTTON1 = 1,
1428 wxJOY_BUTTON2 = 2,
1429 wxJOY_BUTTON3 = 4,
1430 wxJOY_BUTTON4 = 8
1431 };
1432
1433 class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent
1434 {
1435 protected:
1436 wxPoint m_pos;
1437 int m_zPosition;
1438 int m_buttonChange; // Which button changed?
1439 int m_buttonState; // Which buttons are down?
1440 int m_joyStick; // Which joystick?
1441
1442 public:
1443 wxJoystickEvent(wxEventType type = wxEVT_NULL,
1444 int state = 0,
1445 int joystick = wxJOYSTICK1,
1446 int change = 0)
1447 : wxEvent(0, type),
1448 m_pos(),
1449 m_zPosition(0),
1450 m_buttonChange(change),
1451 m_buttonState(state),
1452 m_joyStick(joystick)
1453 {
1454 }
1455 wxJoystickEvent(const wxJoystickEvent & event)
1456 : wxEvent(event),
1457 m_pos(event.m_pos),
1458 m_zPosition(event.m_zPosition),
1459 m_buttonChange(event.m_buttonChange),
1460 m_buttonState(event.m_buttonState),
1461 m_joyStick(event.m_joyStick)
1462 { }
1463
1464 wxPoint GetPosition() const { return m_pos; }
1465 int GetZPosition() const { return m_zPosition; }
1466 int GetButtonState() const { return m_buttonState; }
1467 int GetButtonChange() const { return m_buttonChange; }
1468 int GetJoystick() const { return m_joyStick; }
1469
1470 void SetJoystick(int stick) { m_joyStick = stick; }
1471 void SetButtonState(int state) { m_buttonState = state; }
1472 void SetButtonChange(int change) { m_buttonChange = change; }
1473 void SetPosition(const wxPoint& pos) { m_pos = pos; }
1474 void SetZPosition(int zPos) { m_zPosition = zPos; }
1475
1476 // Was it a button event? (*doesn't* mean: is any button *down*?)
1477 bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) ||
1478 (GetEventType() == wxEVT_JOY_BUTTON_UP)); }
1479
1480 // Was it a move event?
1481 bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE); }
1482
1483 // Was it a zmove event?
1484 bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE); }
1485
1486 // Was it a down event from button 1, 2, 3, 4 or any?
1487 bool ButtonDown(int but = wxJOY_BUTTON_ANY) const
1488 { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) &&
1489 ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
1490
1491 // Was it a up event from button 1, 2, 3 or any?
1492 bool ButtonUp(int but = wxJOY_BUTTON_ANY) const
1493 { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) &&
1494 ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
1495
1496 // Was the given button 1,2,3,4 or any in Down state?
1497 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const
1498 { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) ||
1499 ((m_buttonState & but) == but)); }
1500
1501 virtual wxEvent *Clone() const { return new wxJoystickEvent(*this); }
1502
1503 private:
1504 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent)
1505 };
1506
1507 // Drop files event class
1508 /*
1509 wxEVT_DROP_FILES
1510 */
1511
1512 class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent
1513 {
1514 public:
1515 int m_noFiles;
1516 wxPoint m_pos;
1517 wxString* m_files;
1518
1519 wxDropFilesEvent(wxEventType type = wxEVT_NULL,
1520 int noFiles = 0,
1521 wxString *files = (wxString *) NULL)
1522 : wxEvent(0, type),
1523 m_noFiles(noFiles),
1524 m_pos(),
1525 m_files(files)
1526 { }
1527
1528 // we need a copy ctor to avoid deleting m_files pointer twice
1529 wxDropFilesEvent(const wxDropFilesEvent& other)
1530 : wxEvent(other),
1531 m_noFiles(other.m_noFiles),
1532 m_pos(other.m_pos),
1533 m_files(NULL)
1534 {
1535 m_files = new wxString[m_noFiles];
1536 for ( int n = 0; n < m_noFiles; n++ )
1537 {
1538 m_files[n] = other.m_files[n];
1539 }
1540 }
1541
1542 virtual ~wxDropFilesEvent()
1543 {
1544 delete [] m_files;
1545 }
1546
1547 wxPoint GetPosition() const { return m_pos; }
1548 int GetNumberOfFiles() const { return m_noFiles; }
1549 wxString *GetFiles() const { return m_files; }
1550
1551 virtual wxEvent *Clone() const { return new wxDropFilesEvent(*this); }
1552
1553 private:
1554 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent)
1555 };
1556
1557 // Update UI event
1558 /*
1559 wxEVT_UPDATE_UI
1560 */
1561
1562 // Whether to always send update events to windows, or
1563 // to only send update events to those with the
1564 // wxWS_EX_PROCESS_UI_UPDATES style.
1565
1566 enum wxUpdateUIMode
1567 {
1568 // Send UI update events to all windows
1569 wxUPDATE_UI_PROCESS_ALL,
1570
1571 // Send UI update events to windows that have
1572 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
1573 wxUPDATE_UI_PROCESS_SPECIFIED
1574 };
1575
1576 class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent
1577 {
1578 public:
1579 wxUpdateUIEvent(wxWindowID commandId = 0)
1580 : wxCommandEvent(wxEVT_UPDATE_UI, commandId)
1581 {
1582 m_checked =
1583 m_enabled =
1584 m_shown =
1585 m_setEnabled =
1586 m_setShown =
1587 m_setText =
1588 m_setChecked = false;
1589 }
1590 wxUpdateUIEvent(const wxUpdateUIEvent & event)
1591 : wxCommandEvent(event),
1592 m_checked(event.m_checked),
1593 m_enabled(event.m_enabled),
1594 m_shown(event.m_shown),
1595 m_setEnabled(event.m_setEnabled),
1596 m_setShown(event.m_setShown),
1597 m_setText(event.m_setText),
1598 m_setChecked(event.m_setChecked),
1599 m_text(event.m_text)
1600 { }
1601
1602 bool GetChecked() const { return m_checked; }
1603 bool GetEnabled() const { return m_enabled; }
1604 bool GetShown() const { return m_shown; }
1605 wxString GetText() const { return m_text; }
1606 bool GetSetText() const { return m_setText; }
1607 bool GetSetChecked() const { return m_setChecked; }
1608 bool GetSetEnabled() const { return m_setEnabled; }
1609 bool GetSetShown() const { return m_setShown; }
1610
1611 void Check(bool check) { m_checked = check; m_setChecked = true; }
1612 void Enable(bool enable) { m_enabled = enable; m_setEnabled = true; }
1613 void Show(bool show) { m_shown = show; m_setShown = true; }
1614 void SetText(const wxString& text) { m_text = text; m_setText = true; }
1615
1616 // Sets the interval between updates in milliseconds.
1617 // Set to -1 to disable updates, or to 0 to update as frequently as possible.
1618 static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
1619
1620 // Returns the current interval between updates in milliseconds
1621 static long GetUpdateInterval() { return sm_updateInterval; }
1622
1623 // Can we update this window?
1624 static bool CanUpdate(wxWindowBase *win);
1625
1626 // Reset the update time to provide a delay until the next
1627 // time we should update
1628 static void ResetUpdateTime();
1629
1630 // Specify how wxWidgets will send update events: to
1631 // all windows, or only to those which specify that they
1632 // will process the events.
1633 static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; }
1634
1635 // Returns the UI update mode
1636 static wxUpdateUIMode GetMode() { return sm_updateMode; }
1637
1638 virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); }
1639
1640 protected:
1641 bool m_checked;
1642 bool m_enabled;
1643 bool m_shown;
1644 bool m_setEnabled;
1645 bool m_setShown;
1646 bool m_setText;
1647 bool m_setChecked;
1648 wxString m_text;
1649 #if wxUSE_LONGLONG
1650 static wxLongLong sm_lastUpdate;
1651 #endif
1652 static long sm_updateInterval;
1653 static wxUpdateUIMode sm_updateMode;
1654
1655 private:
1656 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent)
1657 };
1658
1659 /*
1660 wxEVT_SYS_COLOUR_CHANGED
1661 */
1662
1663 // TODO: shouldn't all events record the window ID?
1664 class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent
1665 {
1666 public:
1667 wxSysColourChangedEvent()
1668 : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED)
1669 { }
1670
1671 virtual wxEvent *Clone() const { return new wxSysColourChangedEvent(*this); }
1672
1673 private:
1674 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent)
1675 };
1676
1677 /*
1678 wxEVT_MOUSE_CAPTURE_CHANGED
1679 The window losing the capture receives this message
1680 (even if it released the capture itself).
1681 */
1682
1683 class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent
1684 {
1685 public:
1686 wxMouseCaptureChangedEvent(wxWindowID winid = 0, wxWindow* gainedCapture = NULL)
1687 : wxEvent(winid, wxEVT_MOUSE_CAPTURE_CHANGED),
1688 m_gainedCapture(gainedCapture)
1689 { }
1690
1691 wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent& event)
1692 : wxEvent(event),
1693 m_gainedCapture(event.m_gainedCapture)
1694 { }
1695
1696 virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); }
1697
1698 wxWindow* GetCapturedWindow() const { return m_gainedCapture; }
1699
1700 private:
1701 wxWindow* m_gainedCapture;
1702
1703 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent)
1704 };
1705
1706 /*
1707 wxEVT_MOUSE_CAPTURE_LOST
1708 The window losing the capture receives this message, unless it released it
1709 it itself or unless wxWindow::CaptureMouse was called on another window
1710 (and so capture will be restored when the new capturer releases it).
1711 */
1712
1713 class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent : public wxEvent
1714 {
1715 public:
1716 wxMouseCaptureLostEvent(wxWindowID winid = 0)
1717 : wxEvent(winid, wxEVT_MOUSE_CAPTURE_LOST)
1718 {}
1719
1720 wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent& event)
1721 : wxEvent(event)
1722 {}
1723
1724 virtual wxEvent *Clone() const { return new wxMouseCaptureLostEvent(*this); }
1725
1726 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent)
1727 };
1728
1729 /*
1730 wxEVT_DISPLAY_CHANGED
1731 */
1732 class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent
1733 {
1734 private:
1735 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent)
1736
1737 public:
1738 wxDisplayChangedEvent()
1739 : wxEvent(0, wxEVT_DISPLAY_CHANGED)
1740 { }
1741
1742 virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); }
1743 };
1744
1745 /*
1746 wxEVT_PALETTE_CHANGED
1747 */
1748
1749 class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent
1750 {
1751 public:
1752 wxPaletteChangedEvent(wxWindowID winid = 0)
1753 : wxEvent(winid, wxEVT_PALETTE_CHANGED),
1754 m_changedWindow((wxWindow *) NULL)
1755 { }
1756
1757 wxPaletteChangedEvent(const wxPaletteChangedEvent& event)
1758 : wxEvent(event),
1759 m_changedWindow(event.m_changedWindow)
1760 { }
1761
1762 void SetChangedWindow(wxWindow* win) { m_changedWindow = win; }
1763 wxWindow* GetChangedWindow() const { return m_changedWindow; }
1764
1765 virtual wxEvent *Clone() const { return new wxPaletteChangedEvent(*this); }
1766
1767 protected:
1768 wxWindow* m_changedWindow;
1769
1770 private:
1771 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent)
1772 };
1773
1774 /*
1775 wxEVT_QUERY_NEW_PALETTE
1776 Indicates the window is getting keyboard focus and should re-do its palette.
1777 */
1778
1779 class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent
1780 {
1781 public:
1782 wxQueryNewPaletteEvent(wxWindowID winid = 0)
1783 : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE),
1784 m_paletteRealized(false)
1785 { }
1786 wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent & event)
1787 : wxEvent(event),
1788 m_paletteRealized(event.m_paletteRealized)
1789 { }
1790
1791 // App sets this if it changes the palette.
1792 void SetPaletteRealized(bool realized) { m_paletteRealized = realized; }
1793 bool GetPaletteRealized() const { return m_paletteRealized; }
1794
1795 virtual wxEvent *Clone() const { return new wxQueryNewPaletteEvent(*this); }
1796
1797 protected:
1798 bool m_paletteRealized;
1799
1800 private:
1801 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent)
1802 };
1803
1804 /*
1805 Event generated by dialog navigation keys
1806 wxEVT_NAVIGATION_KEY
1807 */
1808 // NB: don't derive from command event to avoid being propagated to the parent
1809 class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent
1810 {
1811 public:
1812 wxNavigationKeyEvent()
1813 : wxEvent(0, wxEVT_NAVIGATION_KEY),
1814 m_flags(IsForward | FromTab), // defaults are for TAB
1815 m_focus((wxWindow *)NULL)
1816 {
1817 m_propagationLevel = wxEVENT_PROPAGATE_NONE;
1818 }
1819
1820 wxNavigationKeyEvent(const wxNavigationKeyEvent& event)
1821 : wxEvent(event),
1822 m_flags(event.m_flags),
1823 m_focus(event.m_focus)
1824 { }
1825
1826 // direction: forward (true) or backward (false)
1827 bool GetDirection() const
1828 { return (m_flags & IsForward) != 0; }
1829 void SetDirection(bool bForward)
1830 { if ( bForward ) m_flags |= IsForward; else m_flags &= ~IsForward; }
1831
1832 // it may be a window change event (MDI, notebook pages...) or a control
1833 // change event
1834 bool IsWindowChange() const
1835 { return (m_flags & WinChange) != 0; }
1836 void SetWindowChange(bool bIs)
1837 { if ( bIs ) m_flags |= WinChange; else m_flags &= ~WinChange; }
1838
1839 // Set to true under MSW if the event was generated using the tab key.
1840 // This is required for proper navogation over radio buttons
1841 bool IsFromTab() const
1842 { return (m_flags & FromTab) != 0; }
1843 void SetFromTab(bool bIs)
1844 { if ( bIs ) m_flags |= FromTab; else m_flags &= ~FromTab; }
1845
1846 // the child which has the focus currently (may be NULL - use
1847 // wxWindow::FindFocus then)
1848 wxWindow* GetCurrentFocus() const { return m_focus; }
1849 void SetCurrentFocus(wxWindow *win) { m_focus = win; }
1850
1851 // Set flags
1852 void SetFlags(long flags) { m_flags = flags; }
1853
1854 virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); }
1855
1856 enum
1857 {
1858 IsBackward = 0x0000,
1859 IsForward = 0x0001,
1860 WinChange = 0x0002,
1861 FromTab = 0x0004
1862 };
1863
1864 long m_flags;
1865 wxWindow *m_focus;
1866
1867 private:
1868 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent)
1869 };
1870
1871 // Window creation/destruction events: the first is sent as soon as window is
1872 // created (i.e. the underlying GUI object exists), but when the C++ object is
1873 // fully initialized (so virtual functions may be called). The second,
1874 // wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
1875 // still safe to call virtual functions at this moment
1876 /*
1877 wxEVT_CREATE
1878 wxEVT_DESTROY
1879 */
1880
1881 class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent
1882 {
1883 public:
1884 wxWindowCreateEvent(wxWindow *win = NULL);
1885
1886 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
1887
1888 virtual wxEvent *Clone() const { return new wxWindowCreateEvent(*this); }
1889
1890 private:
1891 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent)
1892 };
1893
1894 class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent
1895 {
1896 public:
1897 wxWindowDestroyEvent(wxWindow *win = NULL);
1898
1899 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
1900
1901 virtual wxEvent *Clone() const { return new wxWindowDestroyEvent(*this); }
1902
1903 private:
1904 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent)
1905 };
1906
1907 // A help event is sent when the user clicks on a window in context-help mode.
1908 /*
1909 wxEVT_HELP
1910 wxEVT_DETAILED_HELP
1911 */
1912
1913 class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent
1914 {
1915 public:
1916 // how was this help event generated?
1917 enum Origin
1918 {
1919 Origin_Unknown, // unrecognized event source
1920 Origin_Keyboard, // event generated from F1 key press
1921 Origin_HelpButton // event from [?] button on the title bar (Windows)
1922 };
1923
1924 wxHelpEvent(wxEventType type = wxEVT_NULL,
1925 wxWindowID winid = 0,
1926 const wxPoint& pt = wxDefaultPosition,
1927 Origin origin = Origin_Unknown)
1928 : wxCommandEvent(type, winid),
1929 m_pos(pt),
1930 m_origin(GuessOrigin(origin))
1931 { }
1932 wxHelpEvent(const wxHelpEvent & event)
1933 : wxCommandEvent(event),
1934 m_pos(event.m_pos),
1935 m_target(event.m_target),
1936 m_link(event.m_link),
1937 m_origin(event.m_origin)
1938 { }
1939
1940 // Position of event (in screen coordinates)
1941 const wxPoint& GetPosition() const { return m_pos; }
1942 void SetPosition(const wxPoint& pos) { m_pos = pos; }
1943
1944 // Optional link to further help
1945 const wxString& GetLink() const { return m_link; }
1946 void SetLink(const wxString& link) { m_link = link; }
1947
1948 // Optional target to display help in. E.g. a window specification
1949 const wxString& GetTarget() const { return m_target; }
1950 void SetTarget(const wxString& target) { m_target = target; }
1951
1952 virtual wxEvent *Clone() const { return new wxHelpEvent(*this); }
1953
1954 // optional indication of the event source
1955 Origin GetOrigin() const { return m_origin; }
1956 void SetOrigin(Origin origin) { m_origin = origin; }
1957
1958 protected:
1959 wxPoint m_pos;
1960 wxString m_target;
1961 wxString m_link;
1962 Origin m_origin;
1963
1964 // we can try to guess the event origin ourselves, even if none is
1965 // specified in the ctor
1966 static Origin GuessOrigin(Origin origin);
1967
1968 private:
1969 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent)
1970 };
1971
1972 // A Clipboard Text event is sent when a window intercepts text copy/cut/paste
1973 // message, i.e. the user has cut/copied/pasted data from/into a text control
1974 // via ctrl-C/X/V, ctrl/shift-del/insert, a popup menu command, etc.
1975 // NOTE : under windows these events are *NOT* generated automatically
1976 // for a Rich Edit text control.
1977 /*
1978 wxEVT_COMMAND_TEXT_COPY
1979 wxEVT_COMMAND_TEXT_CUT
1980 wxEVT_COMMAND_TEXT_PASTE
1981 */
1982
1983 class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent
1984 {
1985 public:
1986 wxClipboardTextEvent(wxEventType type = wxEVT_NULL,
1987 wxWindowID winid = 0)
1988 : wxCommandEvent(type, winid)
1989 { }
1990 wxClipboardTextEvent(const wxClipboardTextEvent & event)
1991 : wxCommandEvent(event)
1992 { }
1993
1994 virtual wxEvent *Clone() const { return new wxClipboardTextEvent(*this); }
1995
1996 private:
1997 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent)
1998 };
1999
2000 // A Context event is sent when the user right clicks on a window or
2001 // presses Shift-F10
2002 // NOTE : Under windows this is a repackaged WM_CONTETXMENU message
2003 // Under other systems it may have to be generated from a right click event
2004 /*
2005 wxEVT_CONTEXT_MENU
2006 */
2007
2008 class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent
2009 {
2010 public:
2011 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
2012 wxWindowID winid = 0,
2013 const wxPoint& pt = wxDefaultPosition)
2014 : wxCommandEvent(type, winid),
2015 m_pos(pt)
2016 { }
2017 wxContextMenuEvent(const wxContextMenuEvent & event)
2018 : wxCommandEvent(event),
2019 m_pos(event.m_pos)
2020 { }
2021
2022 // Position of event (in screen coordinates)
2023 const wxPoint& GetPosition() const { return m_pos; }
2024 void SetPosition(const wxPoint& pos) { m_pos = pos; }
2025
2026 virtual wxEvent *Clone() const { return new wxContextMenuEvent(*this); }
2027
2028 protected:
2029 wxPoint m_pos;
2030
2031 private:
2032 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent)
2033 };
2034
2035 #endif // wxUSE_GUI
2036
2037 // Idle event
2038 /*
2039 wxEVT_IDLE
2040 */
2041
2042 // Whether to always send idle events to windows, or
2043 // to only send update events to those with the
2044 // wxWS_EX_PROCESS_IDLE style.
2045
2046 enum wxIdleMode
2047 {
2048 // Send idle events to all windows
2049 wxIDLE_PROCESS_ALL,
2050
2051 // Send idle events to windows that have
2052 // the wxWS_EX_PROCESS_IDLE flag specified
2053 wxIDLE_PROCESS_SPECIFIED
2054 };
2055
2056 class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent
2057 {
2058 public:
2059 wxIdleEvent()
2060 : wxEvent(0, wxEVT_IDLE),
2061 m_requestMore(false)
2062 { }
2063 wxIdleEvent(const wxIdleEvent & event)
2064 : wxEvent(event),
2065 m_requestMore(event.m_requestMore)
2066 { }
2067
2068 void RequestMore(bool needMore = true) { m_requestMore = needMore; }
2069 bool MoreRequested() const { return m_requestMore; }
2070
2071 virtual wxEvent *Clone() const { return new wxIdleEvent(*this); }
2072
2073 // Specify how wxWidgets will send idle events: to
2074 // all windows, or only to those which specify that they
2075 // will process the events.
2076 static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
2077
2078 // Returns the idle event mode
2079 static wxIdleMode GetMode() { return sm_idleMode; }
2080
2081 protected:
2082 bool m_requestMore;
2083 static wxIdleMode sm_idleMode;
2084
2085 private:
2086 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent)
2087 };
2088
2089 /* TODO
2090 wxEVT_MOUSE_CAPTURE_CHANGED,
2091 wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
2092 // wxEVT_FONT_CHANGED, // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate
2093 // wxEVT_FONT_CHANGED to all other windows (maybe).
2094 wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific.
2095 wxEVT_MEASURE_ITEM,
2096 wxEVT_COMPARE_ITEM
2097 */
2098
2099
2100 // ============================================================================
2101 // event handler and related classes
2102 // ============================================================================
2103
2104 // for backwards compatibility and to prevent eVC 4 for ARM from crashing with
2105 // internal compiler error when compiling wx, we define wxObjectEventFunction
2106 // as a wxObject method even though it can only be a wxEvtHandler one
2107 typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
2108
2109 // struct containing the members common to static and dynamic event tables
2110 // entries
2111 struct WXDLLIMPEXP_BASE wxEventTableEntryBase
2112 {
2113 private:
2114 wxEventTableEntryBase& operator=(const wxEventTableEntryBase& event);
2115
2116 public:
2117 wxEventTableEntryBase(int winid, int idLast,
2118 wxObjectEventFunction fn, wxObject *data)
2119 : m_id(winid),
2120 m_lastId(idLast),
2121 m_fn(fn),
2122 m_callbackUserData(data)
2123 { }
2124
2125 wxEventTableEntryBase(const wxEventTableEntryBase& event)
2126 : m_id(event.m_id),
2127 m_lastId(event.m_lastId),
2128 m_fn(event.m_fn),
2129 m_callbackUserData(event.m_callbackUserData)
2130 { }
2131
2132 // the range of ids for this entry: if m_lastId == wxID_ANY, the range
2133 // consists only of m_id, otherwise it is m_id..m_lastId inclusive
2134 int m_id,
2135 m_lastId;
2136
2137 // function to call: not wxEventFunction, because of dependency problems
2138 wxObjectEventFunction m_fn;
2139
2140 // arbitrary user data asosciated with the callback
2141 wxObject* m_callbackUserData;
2142 };
2143
2144 // an entry from a static event table
2145 struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase
2146 {
2147 wxEventTableEntry(const int& evType, int winid, int idLast,
2148 wxObjectEventFunction fn, wxObject *data)
2149 : wxEventTableEntryBase(winid, idLast, fn, data),
2150 m_eventType(evType)
2151 { }
2152
2153 // the reference to event type: this allows us to not care about the
2154 // (undefined) order in which the event table entries and the event types
2155 // are initialized: initially the value of this reference might be
2156 // invalid, but by the time it is used for the first time, all global
2157 // objects will have been initialized (including the event type constants)
2158 // and so it will have the correct value when it is needed
2159 const int& m_eventType;
2160
2161 private:
2162 wxEventTableEntry& operator=(const wxEventTableEntry&);
2163 };
2164
2165 // an entry used in dynamic event table managed by wxEvtHandler::Connect()
2166 struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase
2167 {
2168 wxDynamicEventTableEntry(int evType, int winid, int idLast,
2169 wxObjectEventFunction fn, wxObject *data, wxEvtHandler* eventSink)
2170 : wxEventTableEntryBase(winid, idLast, fn, data),
2171 m_eventType(evType),
2172 m_eventSink(eventSink)
2173 { }
2174
2175 // not a reference here as we can't keep a reference to a temporary int
2176 // created to wrap the constant value typically passed to Connect() - nor
2177 // do we need it
2178 int m_eventType;
2179
2180 // Pointer to object whose function is fn - so we don't assume the
2181 // EventFunction is always a member of the EventHandler receiving the
2182 // message
2183 wxEvtHandler* m_eventSink;
2184
2185 DECLARE_NO_COPY_CLASS(wxDynamicEventTableEntry)
2186 };
2187
2188 // ----------------------------------------------------------------------------
2189 // wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
2190 // ----------------------------------------------------------------------------
2191
2192 struct WXDLLIMPEXP_BASE wxEventTable
2193 {
2194 const wxEventTable *baseTable; // base event table (next in chain)
2195 const wxEventTableEntry *entries; // bottom of entry array
2196 };
2197
2198 // ----------------------------------------------------------------------------
2199 // wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
2200 // ----------------------------------------------------------------------------
2201
2202 WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray);
2203
2204 class WXDLLIMPEXP_BASE wxEventHashTable
2205 {
2206 private:
2207 // Internal data structs
2208 struct EventTypeTable
2209 {
2210 wxEventType eventType;
2211 wxEventTableEntryPointerArray eventEntryTable;
2212 };
2213 typedef EventTypeTable* EventTypeTablePointer;
2214
2215 public:
2216 // Constructor, needs the event table it needs to hash later on.
2217 // Note: hashing of the event table is not done in the constructor as it
2218 // can be that the event table is not yet full initialize, the hash
2219 // will gets initialized when handling the first event look-up request.
2220 wxEventHashTable(const wxEventTable &table);
2221 // Destructor.
2222 ~wxEventHashTable();
2223
2224 // Handle the given event, in other words search the event table hash
2225 // and call self->ProcessEvent() if a match was found.
2226 bool HandleEvent(wxEvent &event, wxEvtHandler *self);
2227
2228 // Clear table
2229 void Clear();
2230
2231 #if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
2232 // Clear all tables
2233 static void ClearAll();
2234 #endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
2235
2236 protected:
2237 // Init the hash table with the entries of the static event table.
2238 void InitHashTable();
2239 // Helper funtion of InitHashTable() to insert 1 entry into the hash table.
2240 void AddEntry(const wxEventTableEntry &entry);
2241 // Allocate and init with null pointers the base hash table.
2242 void AllocEventTypeTable(size_t size);
2243 // Grow the hash table in size and transfer all items currently
2244 // in the table to the correct location in the new table.
2245 void GrowEventTypeTable();
2246
2247 protected:
2248 const wxEventTable &m_table;
2249 bool m_rebuildHash;
2250
2251 size_t m_size;
2252 EventTypeTablePointer *m_eventTypeTable;
2253
2254 static wxEventHashTable* sm_first;
2255 wxEventHashTable* m_previous;
2256 wxEventHashTable* m_next;
2257
2258 DECLARE_NO_COPY_CLASS(wxEventHashTable)
2259 };
2260
2261 // ----------------------------------------------------------------------------
2262 // wxEventConnectionRef: A class that represents all connections between two event
2263 // handlers and enables automatic disconnect when an event handler sink goes
2264 // out of scope. Each connection/disconnect increases/decreases ref count, and
2265 // when zero the node goes out of scope.
2266 // ----------------------------------------------------------------------------
2267
2268 struct wxEventConnectionRef : public wxTrackerNode {
2269
2270 wxEventConnectionRef() : m_src(0), m_sink(0), m_refCount(0) { }
2271 wxEventConnectionRef( wxEvtHandler *src, wxEvtHandler *sink );
2272 virtual ~wxEventConnectionRef();
2273
2274 // The sink is being destroyed
2275 virtual void OnObjectDestroy( );
2276 virtual wxTrackerNodeType GetType( ){ return EventConnectionRef; }
2277
2278 void IncRef( ) { m_refCount++; }
2279 void DecRef( );
2280
2281 protected:
2282 wxEvtHandler *m_src, *m_sink;
2283 int m_refCount;
2284
2285 friend class wxEvtHandler;
2286
2287 private:
2288 // It makes no sense to copy objects of this class
2289 wxEventConnectionRef& operator = (const wxEventConnectionRef& WXUNUSED(other)) { wxFAIL; return *this; }
2290 };
2291
2292
2293
2294 // ----------------------------------------------------------------------------
2295 // wxEvtHandler: the base class for all objects handling wxWidgets events
2296 // ----------------------------------------------------------------------------
2297
2298 class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject, public wxTrackableBase
2299 {
2300 public:
2301 wxEvtHandler();
2302 virtual ~wxEvtHandler();
2303
2304 wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
2305 wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
2306 void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
2307 void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }
2308
2309 void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
2310 bool GetEvtHandlerEnabled() const { return m_enabled; }
2311
2312 // process an event right now
2313 virtual bool ProcessEvent(wxEvent& event);
2314
2315 // Process an event by calling ProcessEvent and handling any exceptions
2316 // thrown by event handlers. It's mostly useful when processing wx events
2317 // when called from C code (e.g. in GTK+ callback) when the exception
2318 // wouldn't correctly propagate to wxEventLoop.
2319 bool SafelyProcessEvent(wxEvent& event);
2320
2321 // add an event to be processed later
2322 virtual void AddPendingEvent(const wxEvent& event);
2323
2324 void ProcessPendingEvents();
2325
2326 #if wxUSE_THREADS
2327 bool ProcessThreadEvent(const wxEvent& event);
2328 #endif
2329
2330 // Dynamic association of a member function handler with the event handler,
2331 // winid and event type
2332 void Connect(int winid,
2333 int lastId,
2334 int eventType,
2335 wxObjectEventFunction func,
2336 wxObject *userData = (wxObject *) NULL,
2337 wxEvtHandler *eventSink = (wxEvtHandler *) NULL);
2338
2339 // Convenience function: take just one id
2340 void Connect(int winid,
2341 int eventType,
2342 wxObjectEventFunction func,
2343 wxObject *userData = (wxObject *) NULL,
2344 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
2345 { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }
2346
2347 // Even more convenient: without id (same as using id of wxID_ANY)
2348 void Connect(int eventType,
2349 wxObjectEventFunction func,
2350 wxObject *userData = (wxObject *) NULL,
2351 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
2352 { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); }
2353
2354 bool Disconnect(int winid,
2355 int lastId,
2356 wxEventType eventType,
2357 wxObjectEventFunction func = NULL,
2358 wxObject *userData = (wxObject *) NULL,
2359 wxEvtHandler *eventSink = (wxEvtHandler *) NULL);
2360
2361 bool Disconnect(int winid = wxID_ANY,
2362 wxEventType eventType = wxEVT_NULL,
2363 wxObjectEventFunction func = NULL,
2364 wxObject *userData = (wxObject *) NULL,
2365 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
2366 { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }
2367
2368 bool Disconnect(wxEventType eventType,
2369 wxObjectEventFunction func,
2370 wxObject *userData = (wxObject *) NULL,
2371 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
2372 { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); }
2373
2374 wxList* GetDynamicEventTable() const { return m_dynamicEvents ; }
2375
2376 // User data can be associated with each wxEvtHandler
2377 void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
2378 wxClientData *GetClientObject() const { return DoGetClientObject(); }
2379
2380 void SetClientData( void *data ) { DoSetClientData(data); }
2381 void *GetClientData() const { return DoGetClientData(); }
2382
2383 // check if the given event table entry matches this event and call the
2384 // handler if it does
2385 //
2386 // return true if the event was processed, false otherwise (no match or the
2387 // handler decided to skip the event)
2388 static bool ProcessEventIfMatches(const wxEventTableEntryBase& tableEntry,
2389 wxEvtHandler *handler,
2390 wxEvent& event);
2391
2392 // implementation from now on
2393 virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
2394 bool SearchDynamicEventTable( wxEvent& event );
2395
2396 // Avoid problems at exit by cleaning up static hash table gracefully
2397 void ClearEventHashTable() { GetEventHashTable().Clear(); }
2398 void OnSinkDestroyed( wxEvtHandler *sink );
2399
2400 private:
2401 static const wxEventTableEntry sm_eventTableEntries[];
2402
2403 protected:
2404 // hooks for wxWindow used by ProcessEvent()
2405 // -----------------------------------------
2406
2407 // This one is called before trying our own event table to allow plugging
2408 // in the validators.
2409 //
2410 // NB: This method is intentionally *not* inside wxUSE_VALIDATORS!
2411 // It is part of wxBase which doesn't use validators and the code
2412 // is compiled out when building wxBase w/o GUI classes, which affects
2413 // binary compatibility and wxBase library can't be used by GUI
2414 // ports.
2415 virtual bool TryValidator(wxEvent& WXUNUSED(event)) { return false; }
2416
2417 // this one is called after failing to find the event handle in our own
2418 // table to give a chance to the other windows to process it
2419 //
2420 // base class implementation passes the event to wxTheApp
2421 virtual bool TryParent(wxEvent& event);
2422
2423
2424 static const wxEventTable sm_eventTable;
2425 virtual const wxEventTable *GetEventTable() const;
2426
2427 static wxEventHashTable sm_eventHashTable;
2428 virtual wxEventHashTable& GetEventHashTable() const;
2429
2430 wxEvtHandler* m_nextHandler;
2431 wxEvtHandler* m_previousHandler;
2432 wxList* m_dynamicEvents;
2433 wxList* m_pendingEvents;
2434
2435 #if wxUSE_THREADS
2436 // critical section protecting m_pendingEvents
2437 wxCriticalSection m_pendingEventsLock;
2438 #endif // wxUSE_THREADS
2439
2440 // Is event handler enabled?
2441 bool m_enabled;
2442
2443
2444 // The user data: either an object which will be deleted by the container
2445 // when it's deleted or some raw pointer which we do nothing with - only
2446 // one type of data can be used with the given window (i.e. you cannot set
2447 // the void data and then associate the container with wxClientData or vice
2448 // versa)
2449 union
2450 {
2451 wxClientData *m_clientObject;
2452 void *m_clientData;
2453 };
2454
2455 // what kind of data do we have?
2456 wxClientDataType m_clientDataType;
2457
2458 // client data accessors
2459 virtual void DoSetClientObject( wxClientData *data );
2460 virtual wxClientData *DoGetClientObject() const;
2461
2462 virtual void DoSetClientData( void *data );
2463 virtual void *DoGetClientData() const;
2464
2465 // Search tracker objects for event connection with this sink
2466 wxEventConnectionRef *FindRefInTrackerList( wxEvtHandler *eventSink );
2467
2468 private:
2469 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler)
2470 };
2471
2472 // Post a message to the given eventhandler which will be processed during the
2473 // next event loop iteration
2474 inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event)
2475 {
2476 wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
2477
2478 dest->AddPendingEvent(event);
2479 }
2480
2481 typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
2482
2483 #define wxEventHandler(func) \
2484 (wxObjectEventFunction)wxStaticCastEvent(wxEventFunction, &func)
2485
2486 #if wxUSE_GUI
2487
2488 // ----------------------------------------------------------------------------
2489 // wxEventBlocker: helper class to temporarily disable event handling for a window
2490 // ----------------------------------------------------------------------------
2491
2492 class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler
2493 {
2494 public:
2495 wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY);
2496 virtual ~wxEventBlocker();
2497
2498 void Block(wxEventType type)
2499 {
2500 m_eventsToBlock.push_back(type);
2501 }
2502
2503 virtual bool ProcessEvent(wxEvent& event);
2504
2505 protected:
2506 wxArrayInt m_eventsToBlock;
2507 wxWindow *m_window;
2508
2509 DECLARE_NO_COPY_CLASS(wxEventBlocker)
2510 };
2511
2512 typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);
2513 typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&);
2514 typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&);
2515 typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&);
2516 typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&);
2517 typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&);
2518 typedef void (wxEvtHandler::*wxNcPaintEventFunction)(wxNcPaintEvent&);
2519 typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&);
2520 typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&);
2521 typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&);
2522 typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&);
2523 typedef void (wxEvtHandler::*wxChildFocusEventFunction)(wxChildFocusEvent&);
2524 typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&);
2525 typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&);
2526 typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&);
2527 typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&);
2528 typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&);
2529 typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&);
2530 typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&);
2531 typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&);
2532 typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
2533 typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&);
2534 typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&);
2535 typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&);
2536 typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxMaximizeEvent&);
2537 typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&);
2538 typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&);
2539 typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&);
2540 typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&);
2541 typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&);
2542 typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&);
2543 typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&);
2544 typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&);
2545 typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&);
2546 typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&);
2547 typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&);
2548 typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&);
2549
2550
2551 #define wxCommandEventHandler(func) \
2552 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCommandEventFunction, &func)
2553 #define wxScrollEventHandler(func) \
2554 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScrollEventFunction, &func)
2555 #define wxScrollWinEventHandler(func) \
2556 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScrollWinEventFunction, &func)
2557 #define wxSizeEventHandler(func) \
2558 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSizeEventFunction, &func)
2559 #define wxMoveEventHandler(func) \
2560 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMoveEventFunction, &func)
2561 #define wxPaintEventHandler(func) \
2562 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxPaintEventFunction, &func)
2563 #define wxNcPaintEventHandler(func) \
2564 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNcPaintEventFunction, &func)
2565 #define wxEraseEventHandler(func) \
2566 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxEraseEventFunction, &func)
2567 #define wxMouseEventHandler(func) \
2568 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseEventFunction, &func)
2569 #define wxCharEventHandler(func) \
2570 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCharEventFunction, &func)
2571 #define wxKeyEventHandler(func) wxCharEventHandler(func)
2572 #define wxFocusEventHandler(func) \
2573 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFocusEventFunction, &func)
2574 #define wxChildFocusEventHandler(func) \
2575 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChildFocusEventFunction, &func)
2576 #define wxActivateEventHandler(func) \
2577 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxActivateEventFunction, &func)
2578 #define wxMenuEventHandler(func) \
2579 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMenuEventFunction, &func)
2580 #define wxJoystickEventHandler(func) \
2581 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxJoystickEventFunction, &func)
2582 #define wxDropFilesEventHandler(func) \
2583 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDropFilesEventFunction, &func)
2584 #define wxInitDialogEventHandler(func) \
2585 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxInitDialogEventFunction, &func)
2586 #define wxSysColourChangedEventHandler(func) \
2587 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSysColourChangedEventFunction, &func)
2588 #define wxDisplayChangedEventHandler(func) \
2589 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDisplayChangedEventFunction, &func)
2590 #define wxUpdateUIEventHandler(func) \
2591 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxUpdateUIEventFunction, &func)
2592 #define wxIdleEventHandler(func) \
2593 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIdleEventFunction, &func)
2594 #define wxCloseEventHandler(func) \
2595 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCloseEventFunction, &func)
2596 #define wxShowEventHandler(func) \
2597 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxShowEventFunction, &func)
2598 #define wxIconizeEventHandler(func) \
2599 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIconizeEventFunction, &func)
2600 #define wxMaximizeEventHandler(func) \
2601 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMaximizeEventFunction, &func)
2602 #define wxNavigationKeyEventHandler(func) \
2603 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNavigationKeyEventFunction, &func)
2604 #define wxPaletteChangedEventHandler(func) \
2605 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxPaletteChangedEventFunction, &func)
2606 #define wxQueryNewPaletteEventHandler(func) \
2607 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxQueryNewPaletteEventFunction, &func)
2608 #define wxWindowCreateEventHandler(func) \
2609 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWindowCreateEventFunction, &func)
2610 #define wxWindowDestroyEventHandler(func) \
2611 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWindowDestroyEventFunction, &func)
2612 #define wxSetCursorEventHandler(func) \
2613 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSetCursorEventFunction, &func)
2614 #define wxNotifyEventHandler(func) \
2615 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNotifyEventFunction, &func)
2616 #define wxHelpEventHandler(func) \
2617 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHelpEventFunction, &func)
2618 #define wxContextMenuEventHandler(func) \
2619 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxContextMenuEventFunction, &func)
2620 #define wxMouseCaptureChangedEventHandler(func) \
2621 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseCaptureChangedEventFunction, &func)
2622 #define wxMouseCaptureLostEventHandler(func) \
2623 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseCaptureLostEventFunction, &func)
2624 #define wxClipboardTextEventHandler(func) \
2625 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxClipboardTextEventFunction, &func)
2626
2627 #endif // wxUSE_GUI
2628
2629 // N.B. In GNU-WIN32, you *have* to take the address of a member function
2630 // (use &) or the compiler crashes...
2631
2632 #define DECLARE_EVENT_TABLE() \
2633 private: \
2634 static const wxEventTableEntry sm_eventTableEntries[]; \
2635 protected: \
2636 static const wxEventTable sm_eventTable; \
2637 virtual const wxEventTable* GetEventTable() const; \
2638 static wxEventHashTable sm_eventHashTable; \
2639 virtual wxEventHashTable& GetEventHashTable() const;
2640
2641 // N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize
2642 // sm_eventTable before using it in GetEventTable() or the compiler gives
2643 // E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews)
2644
2645 #define BEGIN_EVENT_TABLE(theClass, baseClass) \
2646 const wxEventTable theClass::sm_eventTable = \
2647 { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \
2648 const wxEventTable *theClass::GetEventTable() const \
2649 { return &theClass::sm_eventTable; } \
2650 wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \
2651 wxEventHashTable &theClass::GetEventHashTable() const \
2652 { return theClass::sm_eventHashTable; } \
2653 const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
2654
2655 #define BEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \
2656 template<typename T1> \
2657 const wxEventTable theClass<T1>::sm_eventTable = \
2658 { &baseClass::sm_eventTable, &theClass<T1>::sm_eventTableEntries[0] }; \
2659 template<typename T1> \
2660 const wxEventTable *theClass<T1>::GetEventTable() const \
2661 { return &theClass<T1>::sm_eventTable; } \
2662 template<typename T1> \
2663 wxEventHashTable theClass<T1>::sm_eventHashTable(theClass<T1>::sm_eventTable); \
2664 template<typename T1> \
2665 wxEventHashTable &theClass<T1>::GetEventHashTable() const \
2666 { return theClass<T1>::sm_eventHashTable; } \
2667 template<typename T1> \
2668 const wxEventTableEntry theClass<T1>::sm_eventTableEntries[] = { \
2669
2670 #define BEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \
2671 template<typename T1, typename T2> \
2672 const wxEventTable theClass<T1, T2>::sm_eventTable = \
2673 { &baseClass::sm_eventTable, &theClass<T1, T2>::sm_eventTableEntries[0] }; \
2674 template<typename T1, typename T2> \
2675 const wxEventTable *theClass<T1, T2>::GetEventTable() const \
2676 { return &theClass<T1, T2>::sm_eventTable; } \
2677 template<typename T1, typename T2> \
2678 wxEventHashTable theClass<T1, T2>::sm_eventHashTable(theClass<T1, T2>::sm_eventTable); \
2679 template<typename T1, typename T2> \
2680 wxEventHashTable &theClass<T1, T2>::GetEventHashTable() const \
2681 { return theClass<T1, T2>::sm_eventHashTable; } \
2682 template<typename T1, typename T2> \
2683 const wxEventTableEntry theClass<T1, T2>::sm_eventTableEntries[] = { \
2684
2685 #define BEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \
2686 template<typename T1, typename T2, typename T3> \
2687 const wxEventTable theClass<T1, T2, T3>::sm_eventTable = \
2688 { &baseClass::sm_eventTable, &theClass<T1, T2, T3>::sm_eventTableEntries[0] }; \
2689 template<typename T1, typename T2, typename T3> \
2690 const wxEventTable *theClass<T1, T2, T3>::GetEventTable() const \
2691 { return &theClass<T1, T2, T3>::sm_eventTable; } \
2692 template<typename T1, typename T2, typename T3> \
2693 wxEventHashTable theClass<T1, T2, T3>::sm_eventHashTable(theClass<T1, T2, T3>::sm_eventTable); \
2694 template<typename T1, typename T2, typename T3> \
2695 wxEventHashTable &theClass<T1, T2, T3>::GetEventHashTable() const \
2696 { return theClass<T1, T2, T3>::sm_eventHashTable; } \
2697 template<typename T1, typename T2, typename T3> \
2698 const wxEventTableEntry theClass<T1, T2, T3>::sm_eventTableEntries[] = { \
2699
2700 #define BEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \
2701 template<typename T1, typename T2, typename T3, typename T4> \
2702 const wxEventTable theClass<T1, T2, T3, T4>::sm_eventTable = \
2703 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4>::sm_eventTableEntries[0] }; \
2704 template<typename T1, typename T2, typename T3, typename T4> \
2705 const wxEventTable *theClass<T1, T2, T3, T4>::GetEventTable() const \
2706 { return &theClass<T1, T2, T3, T4>::sm_eventTable; } \
2707 template<typename T1, typename T2, typename T3, typename T4> \
2708 wxEventHashTable theClass<T1, T2, T3, T4>::sm_eventHashTable(theClass<T1, T2, T3, T4>::sm_eventTable); \
2709 template<typename T1, typename T2, typename T3, typename T4> \
2710 wxEventHashTable &theClass<T1, T2, T3, T4>::GetEventHashTable() const \
2711 { return theClass<T1, T2, T3, T4>::sm_eventHashTable; } \
2712 template<typename T1, typename T2, typename T3, typename T4> \
2713 const wxEventTableEntry theClass<T1, T2, T3, T4>::sm_eventTableEntries[] = { \
2714
2715 #define BEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \
2716 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
2717 const wxEventTable theClass<T1, T2, T3, T4, T5>::sm_eventTable = \
2718 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[0] }; \
2719 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
2720 const wxEventTable *theClass<T1, T2, T3, T4, T5>::GetEventTable() const \
2721 { return &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>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5>::sm_eventTable); \
2724 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
2725 wxEventHashTable &theClass<T1, T2, T3, T4, T5>::GetEventHashTable() const \
2726 { return theClass<T1, T2, T3, T4, T5>::sm_eventHashTable; } \
2727 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
2728 const wxEventTableEntry theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[] = { \
2729
2730 #define BEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \
2731 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
2732 const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable = \
2733 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[0] }; \
2734 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
2735 const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventTable() const \
2736 { return &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>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable); \
2739 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
2740 wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventHashTable() const \
2741 { return theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable; } \
2742 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
2743 const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[] = { \
2744
2745 #define BEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \
2746 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
2747 const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable = \
2748 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[0] }; \
2749 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
2750 const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventTable() const \
2751 { return &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>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable); \
2754 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
2755 wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventHashTable() const \
2756 { return theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable; } \
2757 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
2758 const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[] = { \
2759
2760 #define END_EVENT_TABLE() DECLARE_EVENT_TABLE_ENTRY( wxEVT_NULL, 0, 0, 0, 0 ) };
2761
2762 /*
2763 * Event table macros
2764 */
2765
2766 // helpers for writing shorter code below: declare an event macro taking 2, 1
2767 // or none ids (the missing ids default to wxID_ANY)
2768 //
2769 // macro arguments:
2770 // - evt one of wxEVT_XXX constants
2771 // - id1, id2 ids of the first/last id
2772 // - fn the function (should be cast to the right type)
2773 #define wx__DECLARE_EVT2(evt, id1, id2, fn) \
2774 DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),
2775 #define wx__DECLARE_EVT1(evt, id, fn) \
2776 wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
2777 #define wx__DECLARE_EVT0(evt, fn) \
2778 wx__DECLARE_EVT1(evt, wxID_ANY, fn)
2779
2780
2781 // Generic events
2782 #define EVT_CUSTOM(event, winid, func) \
2783 wx__DECLARE_EVT1(event, winid, wxEventHandler(func))
2784 #define EVT_CUSTOM_RANGE(event, id1, id2, func) \
2785 wx__DECLARE_EVT2(event, id1, id2, wxEventHandler(func))
2786
2787 // EVT_COMMAND
2788 #define EVT_COMMAND(winid, event, func) \
2789 wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func))
2790 #define EVT_COMMAND_RANGE(id1, id2, event, func) \
2791 wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func))
2792
2793 #define EVT_NOTIFY(event, winid, func) \
2794 wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func))
2795 #define EVT_NOTIFY_RANGE(event, id1, id2, func) \
2796 wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func))
2797
2798 // Miscellaneous
2799 #define EVT_SIZE(func) wx__DECLARE_EVT0(wxEVT_SIZE, wxSizeEventHandler(func))
2800 #define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func))
2801 #define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func))
2802 #define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func))
2803 #define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func))
2804 #define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func))
2805 #define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func))
2806 #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
2807 #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
2808 #define EVT_PAINT(func) wx__DECLARE_EVT0(wxEVT_PAINT, wxPaintEventHandler(func))
2809 #define EVT_NC_PAINT(func) wx__DECLARE_EVT0(wxEVT_NC_PAINT, wxNcPaintEventHandler(func))
2810 #define EVT_ERASE_BACKGROUND(func) wx__DECLARE_EVT0(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(func))
2811 #define EVT_CHAR(func) wx__DECLARE_EVT0(wxEVT_CHAR, wxCharEventHandler(func))
2812 #define EVT_KEY_DOWN(func) wx__DECLARE_EVT0(wxEVT_KEY_DOWN, wxKeyEventHandler(func))
2813 #define EVT_KEY_UP(func) wx__DECLARE_EVT0(wxEVT_KEY_UP, wxKeyEventHandler(func))
2814 #if wxUSE_HOTKEY
2815 #define EVT_HOTKEY(winid, func) wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func))
2816 #endif
2817 #define EVT_CHAR_HOOK(func) wx__DECLARE_EVT0(wxEVT_CHAR_HOOK, wxCharEventHandler(func))
2818 #define EVT_MENU_OPEN(func) wx__DECLARE_EVT0(wxEVT_MENU_OPEN, wxMenuEventHandler(func))
2819 #define EVT_MENU_CLOSE(func) wx__DECLARE_EVT0(wxEVT_MENU_CLOSE, wxMenuEventHandler(func))
2820 #define EVT_MENU_HIGHLIGHT(winid, func) wx__DECLARE_EVT1(wxEVT_MENU_HIGHLIGHT, winid, wxMenuEventHandler(func))
2821 #define EVT_MENU_HIGHLIGHT_ALL(func) wx__DECLARE_EVT0(wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler(func))
2822 #define EVT_SET_FOCUS(func) wx__DECLARE_EVT0(wxEVT_SET_FOCUS, wxFocusEventHandler(func))
2823 #define EVT_KILL_FOCUS(func) wx__DECLARE_EVT0(wxEVT_KILL_FOCUS, wxFocusEventHandler(func))
2824 #define EVT_CHILD_FOCUS(func) wx__DECLARE_EVT0(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(func))
2825 #define EVT_ACTIVATE(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE, wxActivateEventHandler(func))
2826 #define EVT_ACTIVATE_APP(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE_APP, wxActivateEventHandler(func))
2827 #define EVT_HIBERNATE(func) wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func))
2828 #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
2829 #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
2830 #define EVT_DROP_FILES(func) wx__DECLARE_EVT0(wxEVT_DROP_FILES, wxDropFilesEventHandler(func))
2831 #define EVT_INIT_DIALOG(func) wx__DECLARE_EVT0(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(func))
2832 #define EVT_SYS_COLOUR_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler(func))
2833 #define EVT_DISPLAY_CHANGED(func) wx__DECLARE_EVT0(wxEVT_DISPLAY_CHANGED, wxDisplayChangedEventHandler(func))
2834 #define EVT_SHOW(func) wx__DECLARE_EVT0(wxEVT_SHOW, wxShowEventHandler(func))
2835 #define EVT_MAXIMIZE(func) wx__DECLARE_EVT0(wxEVT_MAXIMIZE, wxMaximizeEventHandler(func))
2836 #define EVT_ICONIZE(func) wx__DECLARE_EVT0(wxEVT_ICONIZE, wxIconizeEventHandler(func))
2837 #define EVT_NAVIGATION_KEY(func) wx__DECLARE_EVT0(wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(func))
2838 #define EVT_PALETTE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_PALETTE_CHANGED, wxPaletteChangedEventHandler(func))
2839 #define EVT_QUERY_NEW_PALETTE(func) wx__DECLARE_EVT0(wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEventHandler(func))
2840 #define EVT_WINDOW_CREATE(func) wx__DECLARE_EVT0(wxEVT_CREATE, wxWindowCreateEventHandler(func))
2841 #define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func))
2842 #define EVT_SET_CURSOR(func) wx__DECLARE_EVT0(wxEVT_SET_CURSOR, wxSetCursorEventHandler(func))
2843 #define EVT_MOUSE_CAPTURE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEventHandler(func))
2844 #define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func))
2845
2846 // Mouse events
2847 #define EVT_LEFT_DOWN(func) wx__DECLARE_EVT0(wxEVT_LEFT_DOWN, wxMouseEventHandler(func))
2848 #define EVT_LEFT_UP(func) wx__DECLARE_EVT0(wxEVT_LEFT_UP, wxMouseEventHandler(func))
2849 #define EVT_MIDDLE_DOWN(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(func))
2850 #define EVT_MIDDLE_UP(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_UP, wxMouseEventHandler(func))
2851 #define EVT_RIGHT_DOWN(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DOWN, wxMouseEventHandler(func))
2852 #define EVT_RIGHT_UP(func) wx__DECLARE_EVT0(wxEVT_RIGHT_UP, wxMouseEventHandler(func))
2853 #define EVT_MOTION(func) wx__DECLARE_EVT0(wxEVT_MOTION, wxMouseEventHandler(func))
2854 #define EVT_LEFT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_LEFT_DCLICK, wxMouseEventHandler(func))
2855 #define EVT_MIDDLE_DCLICK(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(func))
2856 #define EVT_RIGHT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(func))
2857 #define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func))
2858 #define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func))
2859 #define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func))
2860 #define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func))
2861 #define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func))
2862 #define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func))
2863 #define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
2864 #define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
2865 #define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
2866
2867 // All mouse events
2868 #define EVT_MOUSE_EVENTS(func) \
2869 EVT_LEFT_DOWN(func) \
2870 EVT_LEFT_UP(func) \
2871 EVT_LEFT_DCLICK(func) \
2872 EVT_MIDDLE_DOWN(func) \
2873 EVT_MIDDLE_UP(func) \
2874 EVT_MIDDLE_DCLICK(func) \
2875 EVT_RIGHT_DOWN(func) \
2876 EVT_RIGHT_UP(func) \
2877 EVT_RIGHT_DCLICK(func) \
2878 EVT_MOUSE_AUX1_DOWN(func) \
2879 EVT_MOUSE_AUX1_UP(func) \
2880 EVT_MOUSE_AUX1_DCLICK(func) \
2881 EVT_MOUSE_AUX2_DOWN(func) \
2882 EVT_MOUSE_AUX2_UP(func) \
2883 EVT_MOUSE_AUX2_DCLICK(func) \
2884 EVT_MOTION(func) \
2885 EVT_LEAVE_WINDOW(func) \
2886 EVT_ENTER_WINDOW(func) \
2887 EVT_MOUSEWHEEL(func)
2888
2889 // Scrolling from wxWindow (sent to wxScrolledWindow)
2890 #define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))
2891 #define EVT_SCROLLWIN_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(func))
2892 #define EVT_SCROLLWIN_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(func))
2893 #define EVT_SCROLLWIN_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(func))
2894 #define EVT_SCROLLWIN_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(func))
2895 #define EVT_SCROLLWIN_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(func))
2896 #define EVT_SCROLLWIN_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(func))
2897 #define EVT_SCROLLWIN_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(func))
2898
2899 #define EVT_SCROLLWIN(func) \
2900 EVT_SCROLLWIN_TOP(func) \
2901 EVT_SCROLLWIN_BOTTOM(func) \
2902 EVT_SCROLLWIN_LINEUP(func) \
2903 EVT_SCROLLWIN_LINEDOWN(func) \
2904 EVT_SCROLLWIN_PAGEUP(func) \
2905 EVT_SCROLLWIN_PAGEDOWN(func) \
2906 EVT_SCROLLWIN_THUMBTRACK(func) \
2907 EVT_SCROLLWIN_THUMBRELEASE(func)
2908
2909 // Scrolling from wxSlider and wxScrollBar
2910 #define EVT_SCROLL_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_TOP, wxScrollEventHandler(func))
2911 #define EVT_SCROLL_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(func))
2912 #define EVT_SCROLL_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(func))
2913 #define EVT_SCROLL_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(func))
2914 #define EVT_SCROLL_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(func))
2915 #define EVT_SCROLL_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(func))
2916 #define EVT_SCROLL_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(func))
2917 #define EVT_SCROLL_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(func))
2918 #define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func))
2919
2920 #define EVT_SCROLL(func) \
2921 EVT_SCROLL_TOP(func) \
2922 EVT_SCROLL_BOTTOM(func) \
2923 EVT_SCROLL_LINEUP(func) \
2924 EVT_SCROLL_LINEDOWN(func) \
2925 EVT_SCROLL_PAGEUP(func) \
2926 EVT_SCROLL_PAGEDOWN(func) \
2927 EVT_SCROLL_THUMBTRACK(func) \
2928 EVT_SCROLL_THUMBRELEASE(func) \
2929 EVT_SCROLL_CHANGED(func)
2930
2931 // Scrolling from wxSlider and wxScrollBar, with an id
2932 #define EVT_COMMAND_SCROLL_TOP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_TOP, winid, wxScrollEventHandler(func))
2933 #define EVT_COMMAND_SCROLL_BOTTOM(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_BOTTOM, winid, wxScrollEventHandler(func))
2934 #define EVT_COMMAND_SCROLL_LINEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEUP, winid, wxScrollEventHandler(func))
2935 #define EVT_COMMAND_SCROLL_LINEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEDOWN, winid, wxScrollEventHandler(func))
2936 #define EVT_COMMAND_SCROLL_PAGEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEUP, winid, wxScrollEventHandler(func))
2937 #define EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEDOWN, winid, wxScrollEventHandler(func))
2938 #define EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxScrollEventHandler(func))
2939 #define EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBRELEASE, winid, wxScrollEventHandler(func))
2940 #define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func))
2941
2942 #define EVT_COMMAND_SCROLL(winid, func) \
2943 EVT_COMMAND_SCROLL_TOP(winid, func) \
2944 EVT_COMMAND_SCROLL_BOTTOM(winid, func) \
2945 EVT_COMMAND_SCROLL_LINEUP(winid, func) \
2946 EVT_COMMAND_SCROLL_LINEDOWN(winid, func) \
2947 EVT_COMMAND_SCROLL_PAGEUP(winid, func) \
2948 EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \
2949 EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \
2950 EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \
2951 EVT_COMMAND_SCROLL_CHANGED(winid, func)
2952
2953 #if WXWIN_COMPATIBILITY_2_6
2954 // compatibility macros for the old name, deprecated in 2.8
2955 #define wxEVT_SCROLL_ENDSCROLL wxEVT_SCROLL_CHANGED
2956 #define EVT_COMMAND_SCROLL_ENDSCROLL EVT_COMMAND_SCROLL_CHANGED
2957 #define EVT_SCROLL_ENDSCROLL EVT_SCROLL_CHANGED
2958 #endif // WXWIN_COMPATIBILITY_2_6
2959
2960 // Convenience macros for commonly-used commands
2961 #define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKBOX_CLICKED, winid, wxCommandEventHandler(func))
2962 #define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICE_SELECTED, winid, wxCommandEventHandler(func))
2963 #define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOX_SELECTED, winid, wxCommandEventHandler(func))
2964 #define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, winid, wxCommandEventHandler(func))
2965 #define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_MENU_SELECTED, winid, wxCommandEventHandler(func))
2966 #define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_MENU_SELECTED, id1, id2, wxCommandEventHandler(func))
2967 #if defined(__SMARTPHONE__)
2968 # define EVT_BUTTON(winid, func) EVT_MENU(winid, func)
2969 #else
2970 # define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_BUTTON_CLICKED, winid, wxCommandEventHandler(func))
2971 #endif
2972 #define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SLIDER_UPDATED, winid, wxCommandEventHandler(func))
2973 #define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RADIOBOX_SELECTED, winid, wxCommandEventHandler(func))
2974 #define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RADIOBUTTON_SELECTED, winid, wxCommandEventHandler(func))
2975 // EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events
2976 #define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SCROLLBAR_UPDATED, winid, wxCommandEventHandler(func))
2977 #define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_VLBOX_SELECTED, winid, wxCommandEventHandler(func))
2978 #define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_SELECTED, winid, wxCommandEventHandler(func))
2979 #define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_CLICKED, winid, wxCommandEventHandler(func))
2980 #define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, winid, wxCommandEventHandler(func))
2981 #define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_CLICKED, id1, id2, wxCommandEventHandler(func))
2982 #define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_RCLICKED, winid, wxCommandEventHandler(func))
2983 #define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func))
2984 #define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_ENTER, winid, wxCommandEventHandler(func))
2985 #define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, winid, wxCommandEventHandler(func))
2986
2987 // Generic command events
2988 #define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func))
2989 #define EVT_COMMAND_LEFT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_DCLICK, winid, wxCommandEventHandler(func))
2990 #define EVT_COMMAND_RIGHT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_CLICK, winid, wxCommandEventHandler(func))
2991 #define EVT_COMMAND_RIGHT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_DCLICK, winid, wxCommandEventHandler(func))
2992 #define EVT_COMMAND_SET_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SET_FOCUS, winid, wxCommandEventHandler(func))
2993 #define EVT_COMMAND_KILL_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_KILL_FOCUS, winid, wxCommandEventHandler(func))
2994 #define EVT_COMMAND_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_ENTER, winid, wxCommandEventHandler(func))
2995
2996 // Joystick events
2997
2998 #define EVT_JOY_BUTTON_DOWN(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_DOWN, wxJoystickEventHandler(func))
2999 #define EVT_JOY_BUTTON_UP(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_UP, wxJoystickEventHandler(func))
3000 #define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func))
3001 #define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func))
3002
3003 // All joystick events
3004 #define EVT_JOYSTICK_EVENTS(func) \
3005 EVT_JOY_BUTTON_DOWN(func) \
3006 EVT_JOY_BUTTON_UP(func) \
3007 EVT_JOY_MOVE(func) \
3008 EVT_JOY_ZMOVE(func)
3009
3010 // Idle event
3011 #define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func))
3012
3013 // Update UI event
3014 #define EVT_UPDATE_UI(winid, func) wx__DECLARE_EVT1(wxEVT_UPDATE_UI, winid, wxUpdateUIEventHandler(func))
3015 #define EVT_UPDATE_UI_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_UPDATE_UI, id1, id2, wxUpdateUIEventHandler(func))
3016
3017 // Help events
3018 #define EVT_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_HELP, winid, wxHelpEventHandler(func))
3019 #define EVT_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_HELP, id1, id2, wxHelpEventHandler(func))
3020 #define EVT_DETAILED_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_DETAILED_HELP, winid, wxHelpEventHandler(func))
3021 #define EVT_DETAILED_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_DETAILED_HELP, id1, id2, wxHelpEventHandler(func))
3022
3023 // Context Menu Events
3024 #define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func))
3025 #define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func))
3026
3027 // Clipboard text Events
3028 #define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_CUT, winid, wxClipboardTextEventHandler(func))
3029 #define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_COPY, winid, wxClipboardTextEventHandler(func))
3030 #define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_PASTE, winid, wxClipboardTextEventHandler(func))
3031
3032 // ----------------------------------------------------------------------------
3033 // Global data
3034 // ----------------------------------------------------------------------------
3035
3036 // list containing event handlers with pending events for them
3037 //
3038 // notice that each event handler should occur at most once in this list
3039 extern WXDLLIMPEXP_BASE wxList *wxPendingEvents;
3040 #if wxUSE_THREADS
3041 extern WXDLLIMPEXP_BASE wxCriticalSection *wxPendingEventsLocker;
3042 #endif
3043
3044 // ----------------------------------------------------------------------------
3045 // Helper functions
3046 // ----------------------------------------------------------------------------
3047
3048 #if wxUSE_GUI
3049
3050 // Find a window with the focus, that is also a descendant of the given window.
3051 // This is used to determine the window to initially send commands to.
3052 WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor);
3053
3054 #endif // wxUSE_GUI
3055
3056 #endif // _WX_EVENT_H_