1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Event classes
4 // Author: Julian Smart
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/object.h"
18 #include "wx/clntdata.h"
21 #include "wx/gdicmn.h"
22 #include "wx/cursor.h"
25 #include "wx/dynarray.h"
26 #include "wx/thread.h"
27 #include "wx/tracker.h"
29 // ----------------------------------------------------------------------------
30 // forward declarations
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_FWD_BASE wxList
;
35 class WXDLLIMPEXP_FWD_CORE wxDC
;
36 class WXDLLIMPEXP_FWD_CORE wxMenu
;
37 class WXDLLIMPEXP_FWD_CORE wxWindow
;
38 class WXDLLIMPEXP_FWD_CORE wxWindowBase
;
41 class WXDLLIMPEXP_FWD_BASE wxEvtHandler
;
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 typedef int wxEventType
;
49 #define wxEVT_ANY ((wxEventType)-1)
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)
55 #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
56 wxEventTableEntry(type, winid, idLast, fn, obj)
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)
69 // generate a new unique event type
70 extern WXDLLIMPEXP_BASE wxEventType
wxNewEventType();
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)
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)
90 // wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use
91 // wxEVT_SCROLL... events
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)
100 // Toolbar dropdown arrows
101 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED
, 19)
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)
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)
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)
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)
152 DECLARE_EVENT_TYPE(wxEVT_HOTKEY
, 217)
155 DECLARE_EVENT_TYPE(wxEVT_SET_CURSOR
, 230)
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)
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)
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
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)
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)
241 DECLARE_EVENT_TYPE(wxEVT_HELP
, 1050)
242 DECLARE_EVENT_TYPE(wxEVT_DETAILED_HELP
, 1051)
244 END_DECLARE_EVENT_TYPES()
246 // these 2 events are the same
247 #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED
249 // ----------------------------------------------------------------------------
251 // ----------------------------------------------------------------------------
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
256 // still, any new code using it should include wx/textctrl.h explicitly
257 extern const wxEventType WXDLLIMPEXP_CORE wxEVT_COMMAND_TEXT_UPDATED
;
259 // the predefined constants for the number of times we propagate event
260 // upwards window child-parent chain
261 enum Propagation_state
263 // don't propagate it at all
264 wxEVENT_PROPAGATE_NONE
= 0,
266 // propagate it until it is processed
267 wxEVENT_PROPAGATE_MAX
= INT_MAX
271 * wxWidgets events, covering all interesting things that might happen
272 * (button clicking, resizing, setting text in widgets, etc.).
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.
282 class WXDLLIMPEXP_BASE wxEvent
: public wxObject
285 wxEvent
& operator=(const wxEvent
&);
288 wxEvent(const wxEvent
&); // for implementing Clone()
291 wxEvent(int winid
= 0, wxEventType commandType
= wxEVT_NULL
);
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
; }
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
; }
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;
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
; }
318 // Determine if this event should be propagating to the parent window.
319 bool ShouldPropagate() const
320 { return m_propagationLevel
!= wxEVENT_PROPAGATE_NONE
; }
322 // Stop an event from propagating to its parent window, returns the old
323 // propagation level value
324 int StopPropagation()
326 int propagationLevel
= m_propagationLevel
;
327 m_propagationLevel
= wxEVENT_PROPAGATE_NONE
;
328 return propagationLevel
;
331 // Resume the event propagation by restoring the propagation level
332 // (returned by StopPropagation())
333 void ResumePropagation(int propagationLevel
)
335 m_propagationLevel
= propagationLevel
;
339 wxObject
* m_eventObject
;
340 wxEventType m_eventType
;
345 // m_callbackUserData is for internal usage only
346 wxObject
* m_callbackUserData
;
349 // the propagation level: while it is positive, we propagate the event to
350 // the parent window (if any)
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
;
358 bool m_isCommandEvent
;
361 // it needs to access our m_propagationLevel
362 friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce
;
364 DECLARE_ABSTRACT_CLASS(wxEvent
)
368 * Helper class to temporarily change an event not to propagate.
370 class WXDLLIMPEXP_BASE wxPropagationDisabler
373 wxPropagationDisabler(wxEvent
& event
) : m_event(event
)
375 m_propagationLevelOld
= m_event
.StopPropagation();
378 ~wxPropagationDisabler()
380 m_event
.ResumePropagation(m_propagationLevelOld
);
385 int m_propagationLevelOld
;
387 DECLARE_NO_COPY_CLASS(wxPropagationDisabler
)
391 * Another one to temporarily lower propagation level.
393 class WXDLLIMPEXP_BASE wxPropagateOnce
396 wxPropagateOnce(wxEvent
& event
) : m_event(event
)
398 wxASSERT_MSG( m_event
.m_propagationLevel
> 0,
399 _T("shouldn't be used unless ShouldPropagate()!") );
401 m_event
.m_propagationLevel
--;
406 m_event
.m_propagationLevel
++;
412 DECLARE_NO_COPY_CLASS(wxPropagateOnce
)
419 // Item or menu event class
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
438 class WXDLLIMPEXP_CORE wxCommandEvent
: public wxEvent
441 wxCommandEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0);
443 wxCommandEvent(const wxCommandEvent
& 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
)
452 // Set/Get client data from controls
453 void SetClientData(void* clientData
) { m_clientData
= clientData
; }
454 void *GetClientData() const { return m_clientData
; }
456 // Set/Get client object from controls
457 void SetClientObject(wxClientData
* clientObject
) { m_clientObject
= clientObject
; }
458 wxClientData
*GetClientObject() const { return m_clientObject
; }
460 // Get listbox selection if single-choice
461 int GetSelection() const { return m_commandInt
; }
463 // Set/Get listbox/choice selection string
464 void SetString(const wxString
& s
) { m_cmdString
= s
; }
465 wxString
GetString() const;
467 // Get checkbox value
468 bool IsChecked() const { return m_commandInt
!= 0; }
470 // true if the listbox event was a selection.
471 bool IsSelection() const { return (m_extraLong
!= 0); }
473 void SetExtraLong(long extraLong
) { m_extraLong
= extraLong
; }
474 long GetExtraLong() const { return m_extraLong
; }
476 void SetInt(int i
) { m_commandInt
= i
; }
477 int GetInt() const { return m_commandInt
; }
479 virtual wxEvent
*Clone() const { return new wxCommandEvent(*this); }
482 wxString m_cmdString
; // String event argument
484 long m_extraLong
; // Additional information (e.g. select/deselect)
485 void* m_clientData
; // Arbitrary client data
486 wxClientData
* m_clientObject
; // Arbitrary client object
489 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent
)
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
497 wxNotifyEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
498 : wxCommandEvent(commandType
, winid
)
501 wxNotifyEvent(const wxNotifyEvent
& event
)
502 : wxCommandEvent(event
)
503 { m_bAllow
= event
.m_bAllow
; }
505 // veto the operation (usually it's allowed by default)
506 void Veto() { m_bAllow
= false; }
508 // allow the operation if it was disabled by default
509 void Allow() { m_bAllow
= true; }
511 // for implementation code only: is the operation allowed?
512 bool IsAllowed() const { return m_bAllow
; }
514 virtual wxEvent
*Clone() const { return new wxNotifyEvent(*this); }
520 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent
)
523 // Scroll event class, derived form wxCommandEvent. wxScrollEvents are
524 // sent by wxSlider and wxScrollBar.
529 wxEVT_SCROLL_LINEDOWN
531 wxEVT_SCROLL_PAGEDOWN
532 wxEVT_SCROLL_THUMBTRACK
533 wxEVT_SCROLL_THUMBRELEASE
537 class WXDLLIMPEXP_CORE wxScrollEvent
: public wxCommandEvent
540 wxScrollEvent(wxEventType commandType
= wxEVT_NULL
,
541 int winid
= 0, int pos
= 0, int orient
= 0);
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
; }
548 virtual wxEvent
*Clone() const { return new wxScrollEvent(*this); }
551 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent
)
554 // ScrollWin event class, derived fom wxEvent. wxScrollWinEvents
555 // are sent by wxWindow.
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
567 class WXDLLIMPEXP_CORE wxScrollWinEvent
: public wxEvent
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
; }
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
; }
581 virtual wxEvent
*Clone() const { return new wxScrollWinEvent(*this); }
588 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent
)
608 wxEVT_NC_MIDDLE_DOWN,
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,
620 // the symbolic names for the mouse buttons
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,
633 class WXDLLIMPEXP_CORE wxMouseEvent
: public wxEvent
636 wxMouseEvent(wxEventType mouseType
= wxEVT_NULL
);
637 wxMouseEvent(const wxMouseEvent
& event
) : wxEvent(event
)
640 // Was it a button event? (*doesn't* mean: is any button *down*?)
641 bool IsButton() const { return Button(wxMOUSE_BTN_ANY
); }
643 // Was it a down event from this (or any) button?
644 bool ButtonDown(int but
= wxMOUSE_BTN_ANY
) const;
646 // Was it a dclick event from this (or any) button?
647 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
) const;
649 // Was it a up event from this (or any) button?
650 bool ButtonUp(int but
= wxMOUSE_BTN_ANY
) const;
652 // Was the given button?
653 bool Button(int but
) const;
655 // Was the given button in Down state?
656 bool ButtonIsDown(int but
) const;
658 // Get the button which is changing state (wxMOUSE_BTN_NONE if none)
659 int GetButton() const;
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
; }
668 #if defined(__WXMAC__) || defined(__WXCOCOA__)
671 return ControlDown();
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
); }
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
); }
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
); }
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
; }
702 // True if a button is down and the mouse is moving
703 bool Dragging() const
705 return (m_eventType
== wxEVT_MOTION
) && ButtonIsDown(wxMOUSE_BTN_ANY
);
708 // True if the mouse is moving, and no button is down
711 return (m_eventType
== wxEVT_MOTION
) && !ButtonIsDown(wxMOUSE_BTN_ANY
);
714 // True if the mouse is just entering the window
715 bool Entering() const { return (m_eventType
== wxEVT_ENTER_WINDOW
); }
717 // True if the mouse is just leaving the window
718 bool Leaving() const { return (m_eventType
== wxEVT_LEAVE_WINDOW
); }
720 // Returns the number of mouse clicks associated with this event.
721 int GetClickCount() const { return m_clickCount
; }
724 // Find the position of the event
725 void GetPosition(wxCoord
*xpos
, wxCoord
*ypos
) const
733 void GetPosition(long *xpos
, long *ypos
) const
741 // Find the position of the event
742 wxPoint
GetPosition() const { return wxPoint(m_x
, m_y
); }
744 // Find the logical position of the event given the DC
745 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
748 wxCoord
GetX() const { return m_x
; }
751 wxCoord
GetY() const { return m_y
; }
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
; }
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
; }
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
; }
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
; }
776 // Is the system set to do page scrolling?
777 bool IsPageScroll() const { return ((unsigned int)m_linesPerAction
== UINT_MAX
); }
779 virtual wxEvent
*Clone() const { return new wxMouseEvent(*this); }
781 wxMouseEvent
& operator=(const wxMouseEvent
& event
) { if (&event
!= this) Assign(event
); return *this; }
802 int m_linesPerAction
;
805 void Assign(const wxMouseEvent
& evt
);
808 DECLARE_DYNAMIC_CLASS(wxMouseEvent
)
817 class WXDLLIMPEXP_CORE wxSetCursorEvent
: public wxEvent
820 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0)
821 : wxEvent(0, wxEVT_SET_CURSOR
),
822 m_x(x
), m_y(y
), m_cursor()
825 wxSetCursorEvent(const wxSetCursorEvent
& event
)
829 m_cursor(event
.m_cursor
)
832 wxCoord
GetX() const { return m_x
; }
833 wxCoord
GetY() const { return m_y
; }
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(); }
839 virtual wxEvent
*Clone() const { return new wxSetCursorEvent(*this); }
846 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent
)
849 // Keyboard input event class
859 class WXDLLIMPEXP_CORE wxKeyEvent
: public wxEvent
862 wxKeyEvent(wxEventType keyType
= wxEVT_NULL
);
863 wxKeyEvent(const wxKeyEvent
& evt
);
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
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);
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
; }
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)
889 #if defined(__WXMAC__) || defined(__WXCOCOA__)
892 return ControlDown();
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(); }
901 // get the key code: an ASCII7 char or an element of wxKeyCode enum
902 int GetKeyCode() const { return (int)m_keyCode
; }
905 // get the Unicode character corresponding to this key
906 wxChar
GetUnicodeKey() const { return m_uniChar
; }
907 #endif // wxUSE_UNICODE
909 // get the raw key code (platform-dependent)
910 wxUint32
GetRawKeyCode() const { return m_rawCode
; }
912 // get the raw key flags (platform-dependent)
913 wxUint32
GetRawKeyFlags() const { return m_rawFlags
; }
915 // Find the position of the event
916 void GetPosition(wxCoord
*xpos
, wxCoord
*ypos
) const
918 if (xpos
) *xpos
= m_x
;
919 if (ypos
) *ypos
= m_y
;
922 void GetPosition(long *xpos
, long *ypos
) const
924 if (xpos
) *xpos
= (long)m_x
;
925 if (ypos
) *ypos
= (long)m_y
;
928 wxPoint
GetPosition() const
929 { return wxPoint(m_x
, m_y
); }
932 wxCoord
GetX() const { return m_x
; }
935 wxCoord
GetY() const { return m_y
; }
937 virtual wxEvent
*Clone() const { return new wxKeyEvent(*this); }
939 // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
941 wxKeyEvent
& operator=(const wxKeyEvent
& evt
)
948 m_keyCode
= evt
.m_keyCode
;
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
;
958 m_uniChar
= evt
.m_uniChar
;
969 // TODO: replace those with a single m_modifiers bitmask of wxMOD_XXX?
975 // FIXME: what is this for? relation to m_rawXXX?
979 // This contains the full Unicode character
980 // in a character events in Unicode mode
984 // these fields contain the platform-specific information about
985 // key that was pressed
990 DECLARE_DYNAMIC_CLASS(wxKeyEvent
)
998 class WXDLLIMPEXP_CORE wxSizeEvent
: public wxEvent
1001 wxSizeEvent() : wxEvent(0, wxEVT_SIZE
)
1003 wxSizeEvent(const wxSize
& sz
, int winid
= 0)
1004 : wxEvent(winid
, wxEVT_SIZE
),
1007 wxSizeEvent(const wxSizeEvent
& event
)
1009 m_size(event
.m_size
), m_rect(event
.m_rect
)
1011 wxSizeEvent(const wxRect
& rect
, int id
= 0)
1012 : m_size(rect
.GetSize()), m_rect(rect
)
1013 { m_eventType
= wxEVT_SIZING
; m_id
= id
; }
1015 wxSize
GetSize() const { return m_size
; }
1016 wxRect
GetRect() const { return m_rect
; }
1017 void SetRect(const wxRect
& rect
) { m_rect
= rect
; }
1019 virtual wxEvent
*Clone() const { return new wxSizeEvent(*this); }
1022 // For internal usage only. Will be converted to protected members.
1024 wxRect m_rect
; // Used for wxEVT_SIZING
1027 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent
)
1036 class WXDLLIMPEXP_CORE wxMoveEvent
: public wxEvent
1040 : wxEvent(0, wxEVT_MOVE
)
1042 wxMoveEvent(const wxPoint
& pos
, int winid
= 0)
1043 : wxEvent(winid
, wxEVT_MOVE
),
1046 wxMoveEvent(const wxMoveEvent
& event
)
1050 wxMoveEvent(const wxRect
& rect
, int id
= 0)
1051 : m_pos(rect
.GetPosition()), m_rect(rect
)
1052 { m_eventType
= wxEVT_MOVING
; m_id
= id
; }
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
; }
1059 virtual wxEvent
*Clone() const { return new wxMoveEvent(*this); }
1066 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent
)
1069 // Paint event class
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
;
1081 class WXDLLIMPEXP_CORE wxPaintEvent
: public wxEvent
1084 wxPaintEvent(int Id
= 0)
1085 : wxEvent(Id
, wxEVT_PAINT
)
1087 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
1088 // set the internal flag for the duration of processing of WM_PAINT
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
)
1102 virtual ~wxPaintEvent()
1108 virtual wxEvent
*Clone() const { return new wxPaintEvent(*this); }
1111 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent
)
1114 class WXDLLIMPEXP_CORE wxNcPaintEvent
: public wxEvent
1117 wxNcPaintEvent(int winid
= 0)
1118 : wxEvent(winid
, wxEVT_NC_PAINT
)
1121 virtual wxEvent
*Clone() const { return new wxNcPaintEvent(*this); }
1124 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent
)
1127 // Erase background event class
1129 wxEVT_ERASE_BACKGROUND
1132 class WXDLLIMPEXP_CORE wxEraseEvent
: public wxEvent
1135 wxEraseEvent(int Id
= 0, wxDC
*dc
= (wxDC
*) NULL
)
1136 : wxEvent(Id
, wxEVT_ERASE_BACKGROUND
),
1140 wxEraseEvent(const wxEraseEvent
& event
)
1145 wxDC
*GetDC() const { return m_dc
; }
1147 virtual wxEvent
*Clone() const { return new wxEraseEvent(*this); }
1153 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent
)
1156 // Focus event class
1162 class WXDLLIMPEXP_CORE wxFocusEvent
: public wxEvent
1165 wxFocusEvent(wxEventType type
= wxEVT_NULL
, int winid
= 0)
1166 : wxEvent(winid
, type
)
1169 wxFocusEvent(const wxFocusEvent
& event
)
1171 { m_win
= event
.m_win
; }
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
; }
1179 virtual wxEvent
*Clone() const { return new wxFocusEvent(*this); }
1185 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent
)
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
1193 wxChildFocusEvent(wxWindow
*win
= NULL
);
1195 wxWindow
*GetWindow() const { return (wxWindow
*)GetEventObject(); }
1197 virtual wxEvent
*Clone() const { return new wxChildFocusEvent(*this); }
1200 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent
)
1203 // Activate event class
1210 class WXDLLIMPEXP_CORE wxActivateEvent
: public wxEvent
1213 wxActivateEvent(wxEventType type
= wxEVT_NULL
, bool active
= true, int Id
= 0)
1215 { m_active
= active
; }
1216 wxActivateEvent(const wxActivateEvent
& event
)
1218 { m_active
= event
.m_active
; }
1220 bool GetActive() const { return m_active
; }
1222 virtual wxEvent
*Clone() const { return new wxActivateEvent(*this); }
1228 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent
)
1231 // InitDialog event class
1236 class WXDLLIMPEXP_CORE wxInitDialogEvent
: public wxEvent
1239 wxInitDialogEvent(int Id
= 0)
1240 : wxEvent(Id
, wxEVT_INIT_DIALOG
)
1243 virtual wxEvent
*Clone() const { return new wxInitDialogEvent(*this); }
1246 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent
)
1249 // Miscellaneous menu event class
1253 wxEVT_MENU_HIGHLIGHT,
1256 class WXDLLIMPEXP_CORE wxMenuEvent
: public wxEvent
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
)
1264 { m_menuId
= event
.m_menuId
; m_menu
= event
.m_menu
; }
1266 // only for wxEVT_MENU_HIGHLIGHT
1267 int GetMenuId() const { return m_menuId
; }
1269 // only for wxEVT_MENU_OPEN/CLOSE
1270 bool IsPopup() const { return m_menuId
== wxID_ANY
; }
1272 // only for wxEVT_MENU_OPEN/CLOSE
1273 wxMenu
* GetMenu() const { return m_menu
; }
1275 virtual wxEvent
*Clone() const { return new wxMenuEvent(*this); }
1281 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent
)
1284 // Window close or session close event class
1288 wxEVT_QUERY_END_SESSION
1291 class WXDLLIMPEXP_CORE wxCloseEvent
: public wxEvent
1294 wxCloseEvent(wxEventType type
= wxEVT_NULL
, int winid
= 0)
1295 : wxEvent(winid
, type
),
1297 m_veto(false), // should be false by default
1300 wxCloseEvent(const wxCloseEvent
& event
)
1302 m_loggingOff(event
.m_loggingOff
),
1303 m_veto(event
.m_veto
),
1304 m_canVeto(event
.m_canVeto
) {}
1306 void SetLoggingOff(bool logOff
) { m_loggingOff
= logOff
; }
1307 bool GetLoggingOff() const
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") );
1314 return m_loggingOff
;
1317 void Veto(bool veto
= true)
1319 // GetVeto() will return false anyhow...
1320 wxCHECK_RET( m_canVeto
,
1321 wxT("call to Veto() ignored (can't veto this event)") );
1325 void SetCanVeto(bool canVeto
) { m_canVeto
= canVeto
; }
1326 bool CanVeto() const { return m_canVeto
; }
1327 bool GetVeto() const { return m_canVeto
&& m_veto
; }
1329 virtual wxEvent
*Clone() const { return new wxCloseEvent(*this); }
1337 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent
)
1344 class WXDLLIMPEXP_CORE wxShowEvent
: public wxEvent
1347 wxShowEvent(int winid
= 0, bool show
= false)
1348 : wxEvent(winid
, wxEVT_SHOW
)
1350 wxShowEvent(const wxShowEvent
& event
)
1352 { m_show
= event
.m_show
; }
1354 void SetShow(bool show
) { m_show
= show
; }
1355 bool GetShow() const { return m_show
; }
1357 virtual wxEvent
*Clone() const { return new wxShowEvent(*this); }
1363 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent
)
1370 class WXDLLIMPEXP_CORE wxIconizeEvent
: public wxEvent
1373 wxIconizeEvent(int winid
= 0, bool iconized
= true)
1374 : wxEvent(winid
, wxEVT_ICONIZE
)
1375 { m_iconized
= iconized
; }
1376 wxIconizeEvent(const wxIconizeEvent
& event
)
1378 { m_iconized
= event
.m_iconized
; }
1380 // return true if the frame was iconized, false if restored
1381 bool Iconized() const { return m_iconized
; }
1383 virtual wxEvent
*Clone() const { return new wxIconizeEvent(*this); }
1389 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent
)
1395 class WXDLLIMPEXP_CORE wxMaximizeEvent
: public wxEvent
1398 wxMaximizeEvent(int winid
= 0)
1399 : wxEvent(winid
, wxEVT_MAXIMIZE
)
1402 virtual wxEvent
*Clone() const { return new wxMaximizeEvent(*this); }
1405 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent
)
1408 // Joystick event class
1410 wxEVT_JOY_BUTTON_DOWN,
1411 wxEVT_JOY_BUTTON_UP,
1416 // Which joystick? Same as Windows ids so no conversion necessary.
1423 // Which button is down?
1426 wxJOY_BUTTON_ANY
= -1,
1433 class WXDLLIMPEXP_CORE wxJoystickEvent
: public wxEvent
1438 int m_buttonChange
; // Which button changed?
1439 int m_buttonState
; // Which buttons are down?
1440 int m_joyStick
; // Which joystick?
1443 wxJoystickEvent(wxEventType type
= wxEVT_NULL
,
1445 int joystick
= wxJOYSTICK1
,
1450 m_buttonChange(change
),
1451 m_buttonState(state
),
1452 m_joyStick(joystick
)
1455 wxJoystickEvent(const wxJoystickEvent
& event
)
1458 m_zPosition(event
.m_zPosition
),
1459 m_buttonChange(event
.m_buttonChange
),
1460 m_buttonState(event
.m_buttonState
),
1461 m_joyStick(event
.m_joyStick
)
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
; }
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
; }
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
)); }
1480 // Was it a move event?
1481 bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE
); }
1483 // Was it a zmove event?
1484 bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE
); }
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
))); }
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
))); }
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
)); }
1501 virtual wxEvent
*Clone() const { return new wxJoystickEvent(*this); }
1504 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent
)
1507 // Drop files event class
1512 class WXDLLIMPEXP_CORE wxDropFilesEvent
: public wxEvent
1519 wxDropFilesEvent(wxEventType type
= wxEVT_NULL
,
1521 wxString
*files
= (wxString
*) NULL
)
1528 // we need a copy ctor to avoid deleting m_files pointer twice
1529 wxDropFilesEvent(const wxDropFilesEvent
& other
)
1531 m_noFiles(other
.m_noFiles
),
1535 m_files
= new wxString
[m_noFiles
];
1536 for ( int n
= 0; n
< m_noFiles
; n
++ )
1538 m_files
[n
] = other
.m_files
[n
];
1542 virtual ~wxDropFilesEvent()
1547 wxPoint
GetPosition() const { return m_pos
; }
1548 int GetNumberOfFiles() const { return m_noFiles
; }
1549 wxString
*GetFiles() const { return m_files
; }
1551 virtual wxEvent
*Clone() const { return new wxDropFilesEvent(*this); }
1554 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent
)
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.
1568 // Send UI update events to all windows
1569 wxUPDATE_UI_PROCESS_ALL
,
1571 // Send UI update events to windows that have
1572 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
1573 wxUPDATE_UI_PROCESS_SPECIFIED
1576 class WXDLLIMPEXP_CORE wxUpdateUIEvent
: public wxCommandEvent
1579 wxUpdateUIEvent(wxWindowID commandId
= 0)
1580 : wxCommandEvent(wxEVT_UPDATE_UI
, commandId
)
1588 m_setChecked
= false;
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
)
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
; }
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; }
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
; }
1620 // Returns the current interval between updates in milliseconds
1621 static long GetUpdateInterval() { return sm_updateInterval
; }
1623 // Can we update this window?
1624 static bool CanUpdate(wxWindowBase
*win
);
1626 // Reset the update time to provide a delay until the next
1627 // time we should update
1628 static void ResetUpdateTime();
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
; }
1635 // Returns the UI update mode
1636 static wxUpdateUIMode
GetMode() { return sm_updateMode
; }
1638 virtual wxEvent
*Clone() const { return new wxUpdateUIEvent(*this); }
1650 static wxLongLong sm_lastUpdate
;
1652 static long sm_updateInterval
;
1653 static wxUpdateUIMode sm_updateMode
;
1656 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent
)
1660 wxEVT_SYS_COLOUR_CHANGED
1663 // TODO: shouldn't all events record the window ID?
1664 class WXDLLIMPEXP_CORE wxSysColourChangedEvent
: public wxEvent
1667 wxSysColourChangedEvent()
1668 : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED
)
1671 virtual wxEvent
*Clone() const { return new wxSysColourChangedEvent(*this); }
1674 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent
)
1678 wxEVT_MOUSE_CAPTURE_CHANGED
1679 The window losing the capture receives this message
1680 (even if it released the capture itself).
1683 class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent
: public wxEvent
1686 wxMouseCaptureChangedEvent(wxWindowID winid
= 0, wxWindow
* gainedCapture
= NULL
)
1687 : wxEvent(winid
, wxEVT_MOUSE_CAPTURE_CHANGED
),
1688 m_gainedCapture(gainedCapture
)
1691 wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent
& event
)
1693 m_gainedCapture(event
.m_gainedCapture
)
1696 virtual wxEvent
*Clone() const { return new wxMouseCaptureChangedEvent(*this); }
1698 wxWindow
* GetCapturedWindow() const { return m_gainedCapture
; }
1701 wxWindow
* m_gainedCapture
;
1703 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent
)
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).
1713 class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent
: public wxEvent
1716 wxMouseCaptureLostEvent(wxWindowID winid
= 0)
1717 : wxEvent(winid
, wxEVT_MOUSE_CAPTURE_LOST
)
1720 wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent
& event
)
1724 virtual wxEvent
*Clone() const { return new wxMouseCaptureLostEvent(*this); }
1726 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent
)
1730 wxEVT_DISPLAY_CHANGED
1732 class WXDLLIMPEXP_CORE wxDisplayChangedEvent
: public wxEvent
1735 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent
)
1738 wxDisplayChangedEvent()
1739 : wxEvent(0, wxEVT_DISPLAY_CHANGED
)
1742 virtual wxEvent
*Clone() const { return new wxDisplayChangedEvent(*this); }
1746 wxEVT_PALETTE_CHANGED
1749 class WXDLLIMPEXP_CORE wxPaletteChangedEvent
: public wxEvent
1752 wxPaletteChangedEvent(wxWindowID winid
= 0)
1753 : wxEvent(winid
, wxEVT_PALETTE_CHANGED
),
1754 m_changedWindow((wxWindow
*) NULL
)
1757 wxPaletteChangedEvent(const wxPaletteChangedEvent
& event
)
1759 m_changedWindow(event
.m_changedWindow
)
1762 void SetChangedWindow(wxWindow
* win
) { m_changedWindow
= win
; }
1763 wxWindow
* GetChangedWindow() const { return m_changedWindow
; }
1765 virtual wxEvent
*Clone() const { return new wxPaletteChangedEvent(*this); }
1768 wxWindow
* m_changedWindow
;
1771 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent
)
1775 wxEVT_QUERY_NEW_PALETTE
1776 Indicates the window is getting keyboard focus and should re-do its palette.
1779 class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent
: public wxEvent
1782 wxQueryNewPaletteEvent(wxWindowID winid
= 0)
1783 : wxEvent(winid
, wxEVT_QUERY_NEW_PALETTE
),
1784 m_paletteRealized(false)
1786 wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent
& event
)
1788 m_paletteRealized(event
.m_paletteRealized
)
1791 // App sets this if it changes the palette.
1792 void SetPaletteRealized(bool realized
) { m_paletteRealized
= realized
; }
1793 bool GetPaletteRealized() const { return m_paletteRealized
; }
1795 virtual wxEvent
*Clone() const { return new wxQueryNewPaletteEvent(*this); }
1798 bool m_paletteRealized
;
1801 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent
)
1805 Event generated by dialog navigation keys
1806 wxEVT_NAVIGATION_KEY
1808 // NB: don't derive from command event to avoid being propagated to the parent
1809 class WXDLLIMPEXP_CORE wxNavigationKeyEvent
: public wxEvent
1812 wxNavigationKeyEvent()
1813 : wxEvent(0, wxEVT_NAVIGATION_KEY
),
1814 m_flags(IsForward
| FromTab
), // defaults are for TAB
1815 m_focus((wxWindow
*)NULL
)
1817 m_propagationLevel
= wxEVENT_PROPAGATE_NONE
;
1820 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
)
1822 m_flags(event
.m_flags
),
1823 m_focus(event
.m_focus
)
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
; }
1832 // it may be a window change event (MDI, notebook pages...) or a control
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
; }
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
; }
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
; }
1852 void SetFlags(long flags
) { m_flags
= flags
; }
1854 virtual wxEvent
*Clone() const { return new wxNavigationKeyEvent(*this); }
1858 IsBackward
= 0x0000,
1868 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent
)
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
1881 class WXDLLIMPEXP_CORE wxWindowCreateEvent
: public wxCommandEvent
1884 wxWindowCreateEvent(wxWindow
*win
= NULL
);
1886 wxWindow
*GetWindow() const { return (wxWindow
*)GetEventObject(); }
1888 virtual wxEvent
*Clone() const { return new wxWindowCreateEvent(*this); }
1891 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent
)
1894 class WXDLLIMPEXP_CORE wxWindowDestroyEvent
: public wxCommandEvent
1897 wxWindowDestroyEvent(wxWindow
*win
= NULL
);
1899 wxWindow
*GetWindow() const { return (wxWindow
*)GetEventObject(); }
1901 virtual wxEvent
*Clone() const { return new wxWindowDestroyEvent(*this); }
1904 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent
)
1907 // A help event is sent when the user clicks on a window in context-help mode.
1913 class WXDLLIMPEXP_CORE wxHelpEvent
: public wxCommandEvent
1916 // how was this help event generated?
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)
1924 wxHelpEvent(wxEventType type
= wxEVT_NULL
,
1925 wxWindowID winid
= 0,
1926 const wxPoint
& pt
= wxDefaultPosition
,
1927 Origin origin
= Origin_Unknown
)
1928 : wxCommandEvent(type
, winid
),
1930 m_origin(GuessOrigin(origin
))
1932 wxHelpEvent(const wxHelpEvent
& event
)
1933 : wxCommandEvent(event
),
1935 m_target(event
.m_target
),
1936 m_link(event
.m_link
),
1937 m_origin(event
.m_origin
)
1940 // Position of event (in screen coordinates)
1941 const wxPoint
& GetPosition() const { return m_pos
; }
1942 void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
1944 // Optional link to further help
1945 const wxString
& GetLink() const { return m_link
; }
1946 void SetLink(const wxString
& link
) { m_link
= link
; }
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
; }
1952 virtual wxEvent
*Clone() const { return new wxHelpEvent(*this); }
1954 // optional indication of the event source
1955 Origin
GetOrigin() const { return m_origin
; }
1956 void SetOrigin(Origin origin
) { m_origin
= origin
; }
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
);
1969 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent
)
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.
1978 wxEVT_COMMAND_TEXT_COPY
1979 wxEVT_COMMAND_TEXT_CUT
1980 wxEVT_COMMAND_TEXT_PASTE
1983 class WXDLLIMPEXP_CORE wxClipboardTextEvent
: public wxCommandEvent
1986 wxClipboardTextEvent(wxEventType type
= wxEVT_NULL
,
1987 wxWindowID winid
= 0)
1988 : wxCommandEvent(type
, winid
)
1990 wxClipboardTextEvent(const wxClipboardTextEvent
& event
)
1991 : wxCommandEvent(event
)
1994 virtual wxEvent
*Clone() const { return new wxClipboardTextEvent(*this); }
1997 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent
)
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
2008 class WXDLLIMPEXP_CORE wxContextMenuEvent
: public wxCommandEvent
2011 wxContextMenuEvent(wxEventType type
= wxEVT_NULL
,
2012 wxWindowID winid
= 0,
2013 const wxPoint
& pt
= wxDefaultPosition
)
2014 : wxCommandEvent(type
, winid
),
2017 wxContextMenuEvent(const wxContextMenuEvent
& event
)
2018 : wxCommandEvent(event
),
2022 // Position of event (in screen coordinates)
2023 const wxPoint
& GetPosition() const { return m_pos
; }
2024 void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2026 virtual wxEvent
*Clone() const { return new wxContextMenuEvent(*this); }
2032 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent
)
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.
2048 // Send idle events to all windows
2051 // Send idle events to windows that have
2052 // the wxWS_EX_PROCESS_IDLE flag specified
2053 wxIDLE_PROCESS_SPECIFIED
2056 class WXDLLIMPEXP_BASE wxIdleEvent
: public wxEvent
2060 : wxEvent(0, wxEVT_IDLE
),
2061 m_requestMore(false)
2063 wxIdleEvent(const wxIdleEvent
& event
)
2065 m_requestMore(event
.m_requestMore
)
2068 void RequestMore(bool needMore
= true) { m_requestMore
= needMore
; }
2069 bool MoreRequested() const { return m_requestMore
; }
2071 virtual wxEvent
*Clone() const { return new wxIdleEvent(*this); }
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
; }
2078 // Returns the idle event mode
2079 static wxIdleMode
GetMode() { return sm_idleMode
; }
2083 static wxIdleMode sm_idleMode
;
2086 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent
)
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.
2100 // ============================================================================
2101 // event handler and related classes
2102 // ============================================================================
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
&);
2109 // struct containing the members common to static and dynamic event tables
2111 struct WXDLLIMPEXP_BASE wxEventTableEntryBase
2114 wxEventTableEntryBase
& operator=(const wxEventTableEntryBase
& event
);
2117 wxEventTableEntryBase(int winid
, int idLast
,
2118 wxObjectEventFunction fn
, wxObject
*data
)
2122 m_callbackUserData(data
)
2125 wxEventTableEntryBase(const wxEventTableEntryBase
& event
)
2127 m_lastId(event
.m_lastId
),
2129 m_callbackUserData(event
.m_callbackUserData
)
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
2137 // function to call: not wxEventFunction, because of dependency problems
2138 wxObjectEventFunction m_fn
;
2140 // arbitrary user data asosciated with the callback
2141 wxObject
* m_callbackUserData
;
2144 // an entry from a static event table
2145 struct WXDLLIMPEXP_BASE wxEventTableEntry
: public wxEventTableEntryBase
2147 wxEventTableEntry(const int& evType
, int winid
, int idLast
,
2148 wxObjectEventFunction fn
, wxObject
*data
)
2149 : wxEventTableEntryBase(winid
, idLast
, fn
, data
),
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
;
2162 wxEventTableEntry
& operator=(const wxEventTableEntry
&);
2165 // an entry used in dynamic event table managed by wxEvtHandler::Connect()
2166 struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry
: public wxEventTableEntryBase
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
)
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
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
2183 wxEvtHandler
* m_eventSink
;
2185 DECLARE_NO_COPY_CLASS(wxDynamicEventTableEntry
)
2188 // ----------------------------------------------------------------------------
2189 // wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
2190 // ----------------------------------------------------------------------------
2192 struct WXDLLIMPEXP_BASE wxEventTable
2194 const wxEventTable
*baseTable
; // base event table (next in chain)
2195 const wxEventTableEntry
*entries
; // bottom of entry array
2198 // ----------------------------------------------------------------------------
2199 // wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
2200 // ----------------------------------------------------------------------------
2202 WX_DEFINE_ARRAY_PTR(const wxEventTableEntry
*, wxEventTableEntryPointerArray
);
2204 class WXDLLIMPEXP_BASE wxEventHashTable
2207 // Internal data structs
2208 struct EventTypeTable
2210 wxEventType eventType
;
2211 wxEventTableEntryPointerArray eventEntryTable
;
2213 typedef EventTypeTable
* EventTypeTablePointer
;
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
);
2222 ~wxEventHashTable();
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
);
2231 #if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
2233 static void ClearAll();
2234 #endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
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();
2248 const wxEventTable
&m_table
;
2252 EventTypeTablePointer
*m_eventTypeTable
;
2254 static wxEventHashTable
* sm_first
;
2255 wxEventHashTable
* m_previous
;
2256 wxEventHashTable
* m_next
;
2258 DECLARE_NO_COPY_CLASS(wxEventHashTable
)
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 // ----------------------------------------------------------------------------
2268 struct wxEventConnectionRef
: public wxTrackerNode
{
2270 wxEventConnectionRef() : m_src(0), m_sink(0), m_refCount(0) { }
2271 wxEventConnectionRef( wxEvtHandler
*src
, wxEvtHandler
*sink
);
2272 virtual ~wxEventConnectionRef();
2274 // The sink is being destroyed
2275 virtual void OnObjectDestroy( );
2276 virtual wxTrackerNodeType
GetType( ){ return EventConnectionRef
; }
2278 void IncRef( ) { m_refCount
++; }
2282 wxEvtHandler
*m_src
, *m_sink
;
2285 friend class wxEvtHandler
;
2288 // It makes no sense to copy objects of this class
2289 wxEventConnectionRef
& operator = (const wxEventConnectionRef
& WXUNUSED(other
)) { wxFAIL
; return *this; }
2294 // ----------------------------------------------------------------------------
2295 // wxEvtHandler: the base class for all objects handling wxWidgets events
2296 // ----------------------------------------------------------------------------
2298 class WXDLLIMPEXP_BASE wxEvtHandler
: public wxObject
, public wxTrackableBase
2302 virtual ~wxEvtHandler();
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
; }
2309 void SetEvtHandlerEnabled(bool enabled
) { m_enabled
= enabled
; }
2310 bool GetEvtHandlerEnabled() const { return m_enabled
; }
2312 // process an event right now
2313 virtual bool ProcessEvent(wxEvent
& event
);
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
);
2321 // add an event to be processed later
2322 virtual void AddPendingEvent(const wxEvent
& event
);
2324 void ProcessPendingEvents();
2327 bool ProcessThreadEvent(const wxEvent
& event
);
2330 // Dynamic association of a member function handler with the event handler,
2331 // winid and event type
2332 void Connect(int winid
,
2335 wxObjectEventFunction func
,
2336 wxObject
*userData
= (wxObject
*) NULL
,
2337 wxEvtHandler
*eventSink
= (wxEvtHandler
*) NULL
);
2339 // Convenience function: take just one id
2340 void Connect(int winid
,
2342 wxObjectEventFunction func
,
2343 wxObject
*userData
= (wxObject
*) NULL
,
2344 wxEvtHandler
*eventSink
= (wxEvtHandler
*) NULL
)
2345 { Connect(winid
, wxID_ANY
, eventType
, func
, userData
, eventSink
); }
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
); }
2354 bool Disconnect(int winid
,
2356 wxEventType eventType
,
2357 wxObjectEventFunction func
= NULL
,
2358 wxObject
*userData
= (wxObject
*) NULL
,
2359 wxEvtHandler
*eventSink
= (wxEvtHandler
*) NULL
);
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
); }
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
); }
2374 wxList
* GetDynamicEventTable() const { return m_dynamicEvents
; }
2376 // User data can be associated with each wxEvtHandler
2377 void SetClientObject( wxClientData
*data
) { DoSetClientObject(data
); }
2378 wxClientData
*GetClientObject() const { return DoGetClientObject(); }
2380 void SetClientData( void *data
) { DoSetClientData(data
); }
2381 void *GetClientData() const { return DoGetClientData(); }
2383 // check if the given event table entry matches this event and call the
2384 // handler if it does
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
,
2392 // implementation from now on
2393 virtual bool SearchEventTable(wxEventTable
& table
, wxEvent
& event
);
2394 bool SearchDynamicEventTable( wxEvent
& event
);
2396 // Avoid problems at exit by cleaning up static hash table gracefully
2397 void ClearEventHashTable() { GetEventHashTable().Clear(); }
2398 void OnSinkDestroyed( wxEvtHandler
*sink
);
2401 static const wxEventTableEntry sm_eventTableEntries
[];
2404 // hooks for wxWindow used by ProcessEvent()
2405 // -----------------------------------------
2407 // This one is called before trying our own event table to allow plugging
2408 // in the validators.
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
2415 virtual bool TryValidator(wxEvent
& WXUNUSED(event
)) { return false; }
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
2420 // base class implementation passes the event to wxTheApp
2421 virtual bool TryParent(wxEvent
& event
);
2424 static const wxEventTable sm_eventTable
;
2425 virtual const wxEventTable
*GetEventTable() const;
2427 static wxEventHashTable sm_eventHashTable
;
2428 virtual wxEventHashTable
& GetEventHashTable() const;
2430 wxEvtHandler
* m_nextHandler
;
2431 wxEvtHandler
* m_previousHandler
;
2432 wxList
* m_dynamicEvents
;
2433 wxList
* m_pendingEvents
;
2436 // critical section protecting m_pendingEvents
2437 wxCriticalSection m_pendingEventsLock
;
2438 #endif // wxUSE_THREADS
2440 // Is event handler enabled?
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
2451 wxClientData
*m_clientObject
;
2455 // what kind of data do we have?
2456 wxClientDataType m_clientDataType
;
2458 // client data accessors
2459 virtual void DoSetClientObject( wxClientData
*data
);
2460 virtual wxClientData
*DoGetClientObject() const;
2462 virtual void DoSetClientData( void *data
);
2463 virtual void *DoGetClientData() const;
2465 // Search tracker objects for event connection with this sink
2466 wxEventConnectionRef
*FindRefInTrackerList( wxEvtHandler
*eventSink
);
2469 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler
)
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
)
2476 wxCHECK_RET( dest
, wxT("need an object to post event to in wxPostEvent") );
2478 dest
->AddPendingEvent(event
);
2481 typedef void (wxEvtHandler::*wxEventFunction
)(wxEvent
&);
2483 #define wxEventHandler(func) \
2484 (wxObjectEventFunction)wxStaticCastEvent(wxEventFunction, &func)
2488 // ----------------------------------------------------------------------------
2489 // wxEventBlocker: helper class to temporarily disable event handling for a window
2490 // ----------------------------------------------------------------------------
2492 class WXDLLIMPEXP_CORE wxEventBlocker
: public wxEvtHandler
2495 wxEventBlocker(wxWindow
*win
, wxEventType type
= wxEVT_ANY
);
2496 virtual ~wxEventBlocker();
2498 void Block(wxEventType type
)
2500 m_eventsToBlock
.push_back(type
);
2503 virtual bool ProcessEvent(wxEvent
& event
);
2506 wxArrayInt m_eventsToBlock
;
2509 DECLARE_NO_COPY_CLASS(wxEventBlocker
)
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
&);
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)
2629 // N.B. In GNU-WIN32, you *have* to take the address of a member function
2630 // (use &) or the compiler crashes...
2632 #define DECLARE_EVENT_TABLE() \
2634 static const wxEventTableEntry sm_eventTableEntries[]; \
2636 static const wxEventTable sm_eventTable; \
2637 virtual const wxEventTable* GetEventTable() const; \
2638 static wxEventHashTable sm_eventHashTable; \
2639 virtual wxEventHashTable& GetEventHashTable() const;
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)
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[] = { \
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[] = { \
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[] = { \
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[] = { \
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[] = { \
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[] = { \
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[] = { \
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[] = { \
2760 #define END_EVENT_TABLE() DECLARE_EVENT_TABLE_ENTRY( wxEVT_NULL, 0, 0, 0, 0 ) };
2763 * Event table macros
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)
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)
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))
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))
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))
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))
2815 #define EVT_HOTKEY(winid, func) wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func))
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))
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))
2868 #define EVT_MOUSE_EVENTS(func) \
2869 EVT_LEFT_DOWN(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) \
2885 EVT_LEAVE_WINDOW(func) \
2886 EVT_ENTER_WINDOW(func) \
2887 EVT_MOUSEWHEEL(func)
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))
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)
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))
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)
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))
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)
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
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)
2970 # define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_BUTTON_CLICKED, winid, wxCommandEventHandler(func))
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))
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))
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))
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) \
3011 #define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func))
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))
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))
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))
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))
3032 // ----------------------------------------------------------------------------
3034 // ----------------------------------------------------------------------------
3036 // list containing event handlers with pending events for them
3038 // notice that each event handler should occur at most once in this list
3039 extern WXDLLIMPEXP_BASE wxList
*wxPendingEvents
;
3041 extern WXDLLIMPEXP_BASE wxCriticalSection
*wxPendingEventsLocker
;
3044 // ----------------------------------------------------------------------------
3046 // ----------------------------------------------------------------------------
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
);
3056 #endif // _WX_EVENT_H_