]> git.saurik.com Git - wxWidgets.git/blob - include/wx/event.h
df4641fa56c3a4002025e155c3c89b4185c4375e
[wxWidgets.git] / include / wx / event.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/event.h
3 // Purpose: Event classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_EVENTH__
13 #define _WX_EVENTH__
14
15 #ifdef __GNUG__
16 #pragma interface "event.h"
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21
22 #if wxUSE_GUI
23 #include "wx/gdicmn.h"
24 #include "wx/cursor.h"
25 #endif
26
27 #include "wx/thread.h"
28
29 // ----------------------------------------------------------------------------
30 // forward declarations
31 // ----------------------------------------------------------------------------
32
33 class WXDLLEXPORT wxList;
34
35 #if wxUSE_GUI
36 class WXDLLEXPORT wxClientData;
37 class WXDLLEXPORT wxDC;
38 class WXDLLEXPORT wxMenu;
39 class WXDLLEXPORT wxWindow;
40 #endif // wxUSE_GUI
41
42 // ----------------------------------------------------------------------------
43 // Event types
44 // ----------------------------------------------------------------------------
45
46 typedef int wxEventType;
47
48 // in previous versions of wxWindows the event types used to be constants
49 // which created difficulties with custom/user event types definition
50 //
51 // starting from wxWindows 2.4 the event types are now dynamically assigned
52 // using wxNewEventType() which solves this problem, however at price of
53 // several incompatibilities:
54 //
55 // a) event table macros declaration changed, it now uses wxEventTableEntry
56 // ctor instead of initialisation from an agregate - the macro
57 // DECLARE_EVENT_TABLE_ENTRY may be used to write code which can compile
58 // with all versions of wxWindows
59 //
60 // b) event types can't be used as switch() cases as they're not really
61 // constant any more - there is no magic solution here, you just have to
62 // change the switch()es to if()s
63 //
64 // if these are real problems for you, define WXWIN_COMPATIBILITY_EVENT_TYPES
65 // to get 100% old behaviour, however you won't be able to use the libraries
66 // using the new dynamic event type allocation in such case, so avoid it if
67 // possible.
68
69 #if WXWIN_COMPATIBILITY_EVENT_TYPES
70
71 #define DECLARE_EVENT_TABLE_ENTRY(type, id, idLast, fn, obj) \
72 { type, id, idLast, fn, obj }
73
74 #define DECLARE_EVENT_TYPE(name, value) name = wxEVT_FIRST + value,
75
76 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
77
78 #define DECLARE_EVENT_TABLE_ENTRY(type, id, idLast, fn, obj) \
79 wxEventTableEntry(type, id, idLast, fn, obj)
80
81 #define DECLARE_EVENT_TYPE(name, value) extern wxEventType name;
82
83 // generate a new unique event type
84 extern WXDLLEXPORT wxEventType wxNewEventType();
85
86 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
87
88 #if WXWIN_COMPATIBILITY_EVENT_TYPES
89 enum
90 {
91 wxEVT_NULL = 0,
92 wxEVT_FIRST = 10000,
93 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
94 // it is important to still have these as constants to avoid
95 // initialization order related problems
96 const wxEventType wxEVT_NULL = 0;
97 const wxEventType wxEVT_FIRST = 10000;
98 const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
99 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
100
101 DECLARE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED, 1)
102 DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKBOX_CLICKED, 2)
103 DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHOICE_SELECTED, 3)
104 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED, 4)
105 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 5)
106 DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 6)
107 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7)
108 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8)
109 DECLARE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED, 9)
110 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED, 10)
111 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED, 11)
112 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBUTTON_SELECTED, 12)
113
114 // wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use
115 // wxEVT_SCROLL... events
116
117 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SCROLLBAR_UPDATED, 13)
118 DECLARE_EVENT_TYPE(wxEVT_COMMAND_VLBOX_SELECTED, 14)
119 DECLARE_EVENT_TYPE(wxEVT_COMMAND_COMBOBOX_SELECTED, 15)
120 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_RCLICKED, 16)
121 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER, 17)
122 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED, 18)
123
124 // Sockets and timers send events, too
125 DECLARE_EVENT_TYPE(wxEVT_SOCKET, 50)
126 DECLARE_EVENT_TYPE(wxEVT_TIMER , 80)
127
128 // Mouse event types
129 DECLARE_EVENT_TYPE(wxEVT_LEFT_DOWN, 100)
130 DECLARE_EVENT_TYPE(wxEVT_LEFT_UP, 101)
131 DECLARE_EVENT_TYPE(wxEVT_MIDDLE_DOWN, 102)
132 DECLARE_EVENT_TYPE(wxEVT_MIDDLE_UP, 103)
133 DECLARE_EVENT_TYPE(wxEVT_RIGHT_DOWN, 104)
134 DECLARE_EVENT_TYPE(wxEVT_RIGHT_UP, 105)
135 DECLARE_EVENT_TYPE(wxEVT_MOTION, 106)
136 DECLARE_EVENT_TYPE(wxEVT_ENTER_WINDOW, 107)
137 DECLARE_EVENT_TYPE(wxEVT_LEAVE_WINDOW, 108)
138 DECLARE_EVENT_TYPE(wxEVT_LEFT_DCLICK, 109)
139 DECLARE_EVENT_TYPE(wxEVT_MIDDLE_DCLICK, 110)
140 DECLARE_EVENT_TYPE(wxEVT_RIGHT_DCLICK, 111)
141 DECLARE_EVENT_TYPE(wxEVT_SET_FOCUS, 112)
142 DECLARE_EVENT_TYPE(wxEVT_KILL_FOCUS, 113)
143
144 // Non-client mouse events
145 DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN, 200)
146 DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_UP, 201)
147 DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_DOWN, 202)
148 DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_UP, 203)
149 DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_DOWN, 204)
150 DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_UP, 205)
151 DECLARE_EVENT_TYPE(wxEVT_NC_MOTION, 206)
152 DECLARE_EVENT_TYPE(wxEVT_NC_ENTER_WINDOW, 207)
153 DECLARE_EVENT_TYPE(wxEVT_NC_LEAVE_WINDOW, 208)
154 DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DCLICK, 209)
155 DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_DCLICK, 210)
156 DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_DCLICK, 211)
157
158 // Character input event type
159 DECLARE_EVENT_TYPE(wxEVT_CHAR, 212)
160 DECLARE_EVENT_TYPE(wxEVT_CHAR_HOOK, 213)
161 DECLARE_EVENT_TYPE(wxEVT_NAVIGATION_KEY, 214)
162 DECLARE_EVENT_TYPE(wxEVT_KEY_DOWN, 215)
163 DECLARE_EVENT_TYPE(wxEVT_KEY_UP, 216)
164
165 // Set cursor event
166 DECLARE_EVENT_TYPE(wxEVT_SET_CURSOR, 230)
167
168 // wxScrollbar and wxSlider event identifiers
169 DECLARE_EVENT_TYPE(wxEVT_SCROLL_TOP, 300)
170 DECLARE_EVENT_TYPE(wxEVT_SCROLL_BOTTOM, 301)
171 DECLARE_EVENT_TYPE(wxEVT_SCROLL_LINEUP, 302)
172 DECLARE_EVENT_TYPE(wxEVT_SCROLL_LINEDOWN, 303)
173 DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP, 304)
174 DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN, 305)
175 DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK, 306)
176 DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE, 307)
177
178 // Scroll events from wxWindow
179 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP, 320)
180 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_BOTTOM, 321)
181 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEUP, 322)
182 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEDOWN, 323)
183 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEUP, 324)
184 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEDOWN, 325)
185 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBTRACK, 326)
186 DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBRELEASE, 327)
187
188 // System events
189 DECLARE_EVENT_TYPE(wxEVT_SIZE, 400)
190 DECLARE_EVENT_TYPE(wxEVT_MOVE, 401)
191 DECLARE_EVENT_TYPE(wxEVT_CLOSE_WINDOW, 402)
192 DECLARE_EVENT_TYPE(wxEVT_END_SESSION, 403)
193 DECLARE_EVENT_TYPE(wxEVT_QUERY_END_SESSION, 404)
194 DECLARE_EVENT_TYPE(wxEVT_ACTIVATE_APP, 405)
195 DECLARE_EVENT_TYPE(wxEVT_POWER, 406)
196 DECLARE_EVENT_TYPE(wxEVT_ACTIVATE, 409)
197 DECLARE_EVENT_TYPE(wxEVT_CREATE, 410)
198 DECLARE_EVENT_TYPE(wxEVT_DESTROY, 411)
199 DECLARE_EVENT_TYPE(wxEVT_SHOW, 412)
200 DECLARE_EVENT_TYPE(wxEVT_ICONIZE, 413)
201 DECLARE_EVENT_TYPE(wxEVT_MAXIMIZE, 414)
202 DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED, 415)
203 DECLARE_EVENT_TYPE(wxEVT_PAINT, 416)
204 DECLARE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND, 417)
205 DECLARE_EVENT_TYPE(wxEVT_NC_PAINT, 418)
206 DECLARE_EVENT_TYPE(wxEVT_PAINT_ICON, 419)
207 DECLARE_EVENT_TYPE(wxEVT_MENU_CHAR, 420)
208 DECLARE_EVENT_TYPE(wxEVT_MENU_INIT, 421)
209 DECLARE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT, 422)
210 DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423)
211 DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424)
212 DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425)
213 DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 426)
214 DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 427)
215 DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 428)
216 DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 429)
217 DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 430)
218 DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 431)
219 DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 432)
220 DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 433)
221 DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 434)
222 DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 435)
223 DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 436)
224 DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 437)
225 DECLARE_EVENT_TYPE(wxEVT_IDLE, 438)
226 DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 439)
227
228 // System misc.
229 DECLARE_EVENT_TYPE(wxEVT_END_PROCESS, 440)
230
231 // Dial up events
232 DECLARE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED, 450)
233 DECLARE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED, 451)
234
235 // Generic command events
236 // Note: a click is a higher-level event than button down/up
237 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LEFT_CLICK, 500)
238 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LEFT_DCLICK, 501)
239 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_CLICK, 502)
240 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_DCLICK, 503)
241 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SET_FOCUS, 504)
242 DECLARE_EVENT_TYPE(wxEVT_COMMAND_KILL_FOCUS, 505)
243 DECLARE_EVENT_TYPE(wxEVT_COMMAND_ENTER, 506)
244
245 // Tree control event types
246 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_DRAG, 600)
247 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_RDRAG, 601)
248 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, 602)
249 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_END_LABEL_EDIT, 603)
250 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_DELETE_ITEM, 604)
251 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_GET_INFO, 605)
252 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_SET_INFO, 606)
253 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_EXPANDED, 607)
254 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_EXPANDING, 608)
255 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, 609)
256 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, 610)
257 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_SEL_CHANGED, 611)
258 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_SEL_CHANGING, 612)
259 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_KEY_DOWN, 613)
260 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, 614)
261 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, 615)
262 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, 616)
263 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_END_DRAG, 617)
264
265 // List control event types
266 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG, 700)
267 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG, 701)
268 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, 702)
269 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT, 703)
270 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM, 704)
271 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, 705)
272 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO, 706)
273 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO, 707)
274 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED, 708)
275 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED, 709)
276 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN, 710)
277 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM, 711)
278 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK, 712)
279 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, 713)
280 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, 714)
281 DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, 715)
282
283 // Tab and notebook control event types
284 #if defined(__BORLANDC__) && defined(__WIN16__)
285 // For 16-bit BC++, these 2 would be identical otherwise (truncated)
286 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_COMMAND_NB_PAGE_CHANGED
287 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_COMMAND_NB_PAGE_CHANGING
288 #endif
289
290 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGED, 800)
291 DECLARE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGING, 801)
292 DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 802)
293 DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 803)
294
295 // Splitter events
296 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, 850)
297 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, 851)
298 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, 852)
299 DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT, 853)
300
301 // Wizard events
302 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGED, 900)
303 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGING, 901)
304 DECLARE_EVENT_TYPE(wxEVT_WIZARD_CANCEL, 902)
305
306 // Calendar events
307 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED, 950)
308 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED, 951)
309 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED, 952)
310 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED, 953)
311 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED, 954)
312 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED, 955)
313
314 // Help events
315 DECLARE_EVENT_TYPE(wxEVT_HELP, 1050)
316 DECLARE_EVENT_TYPE(wxEVT_DETAILED_HELP, 1051)
317
318 #if WXWIN_COMPATIBILITY_EVENT_TYPES
319 };
320 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES
321
322 // these 2 events are the same
323 #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED
324
325 // Compatibility
326
327 #if WXWIN_COMPATIBILITY
328
329 #define wxEVENT_TYPE_BUTTON_COMMAND wxEVT_COMMAND_BUTTON_CLICKED
330 #define wxEVENT_TYPE_CHECKBOX_COMMAND wxEVT_COMMAND_CHECKBOX_CLICKED
331 #define wxEVENT_TYPE_CHOICE_COMMAND wxEVT_COMMAND_CHOICE_SELECTED
332 #define wxEVENT_TYPE_LISTBOX_COMMAND wxEVT_COMMAND_LISTBOX_SELECTED
333 #define wxEVENT_TYPE_LISTBOX_DCLICK_COMMAND wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
334 #define wxEVENT_TYPE_TEXT_COMMAND wxEVT_COMMAND_TEXT_UPDATED
335 #define wxEVENT_TYPE_MULTITEXT_COMMAND wxEVT_COMMAND_TEXT_UPDATED
336 #define wxEVENT_TYPE_MENU_COMMAND wxEVT_COMMAND_MENU_SELECTED
337 #define wxEVENT_TYPE_SLIDER_COMMAND wxEVT_COMMAND_SLIDER_UPDATED
338 #define wxEVENT_TYPE_RADIOBOX_COMMAND wxEVT_COMMAND_RADIOBOX_SELECTED
339 #define wxEVENT_TYPE_RADIOBUTTON_COMMAND wxEVT_COMMAND_RADIOBUTTON_SELECTED
340 #define wxEVENT_TYPE_TEXT_ENTER_COMMAND wxEVT_COMMAND_TEXT_ENTER
341 #define wxEVENT_TYPE_SET_FOCUS wxEVT_SET_FOCUS
342 #define wxEVENT_TYPE_KILL_FOCUS wxEVT_KILL_FOCUS
343 #define wxEVENT_TYPE_SCROLLBAR_COMMAND wxEVT_COMMAND_SCROLLBAR_UPDATED
344 #define wxEVENT_TYPE_VIRT_LISTBOX_COMMAND wxEVT_COMMAND_VLBOX_SELECTED
345 #define wxEVENT_TYPE_COMBOBOX_COMMAND wxEVT_COMMAND_COMBOBOX_SELECTED
346
347 #define wxEVENT_TYPE_LEFT_DOWN wxEVT_LEFT_DOWN
348 #define wxEVENT_TYPE_LEFT_UP wxEVT_LEFT_UP
349 #define wxEVENT_TYPE_MIDDLE_DOWN wxEVT_MIDDLE_DOWN
350 #define wxEVENT_TYPE_MIDDLE_UP wxEVT_MIDDLE_UP
351 #define wxEVENT_TYPE_RIGHT_DOWN wxEVT_RIGHT_DOWN
352 #define wxEVENT_TYPE_RIGHT_UP wxEVT_RIGHT_UP
353 #define wxEVENT_TYPE_MOTION wxEVT_MOTION
354 #define wxEVENT_TYPE_ENTER_WINDOW wxEVT_ENTER_WINDOW
355 #define wxEVENT_TYPE_LEAVE_WINDOW wxEVT_LEAVE_WINDOW
356 #define wxEVENT_TYPE_LEFT_DCLICK wxEVT_LEFT_DCLICK
357 #define wxEVENT_TYPE_MIDDLE_DCLICK wxEVT_MIDDLE_DCLICK
358 #define wxEVENT_TYPE_RIGHT_DCLICK wxEVT_RIGHT_DCLICK
359 #define wxEVENT_TYPE_CHAR wxEVT_CHAR
360 #define wxEVENT_TYPE_SCROLL_TOP wxEVT_SCROLL_TOP
361 #define wxEVENT_TYPE_SCROLL_BOTTOM wxEVT_SCROLL_BOTTOM
362 #define wxEVENT_TYPE_SCROLL_LINEUP wxEVT_SCROLL_LINEUP
363 #define wxEVENT_TYPE_SCROLL_LINEDOWN wxEVT_SCROLL_LINEDOWN
364 #define wxEVENT_TYPE_SCROLL_PAGEUP wxEVT_SCROLL_PAGEUP
365 #define wxEVENT_TYPE_SCROLL_PAGEDOWN wxEVT_SCROLL_PAGEDOWN
366 #define wxEVENT_TYPE_SCROLL_THUMBTRACK wxEVT_SCROLL_THUMBTRACK
367
368 #endif // WXWIN_COMPATIBILITY
369
370 /*
371 * wxWindows events, covering all interesting things that might happen
372 * (button clicking, resizing, setting text in widgets, etc.).
373 *
374 * For each completely new event type, derive a new event class.
375 * An event CLASS represents a C++ class defining a range of similar event TYPES;
376 * examples are canvas events, panel item command events.
377 * An event TYPE is a unique identifier for a particular system event,
378 * such as a button press or a listbox deselection.
379 *
380 */
381
382 class WXDLLEXPORT wxEvent : public wxObject
383 {
384 DECLARE_ABSTRACT_CLASS(wxEvent)
385
386 public:
387 wxEvent(int id = 0);
388 ~wxEvent() {}
389
390 void SetEventType(wxEventType typ) { m_eventType = typ; }
391 wxEventType GetEventType() const { return m_eventType; }
392 wxObject *GetEventObject() const { return m_eventObject; }
393 void SetEventObject(wxObject *obj) { m_eventObject = obj; }
394 long GetTimestamp() const { return m_timeStamp; }
395 void SetTimestamp(long ts = 0) { m_timeStamp = ts; }
396 int GetId() const { return m_id; }
397 void SetId(int Id) { m_id = Id; }
398
399 // Can instruct event processor that we wish to ignore this event
400 // (treat as if the event table entry had not been found): this must be done
401 // to allow the event processing by the base classes (calling event.Skip()
402 // is the analog of calling the base class verstion of a virtual function)
403 void Skip(bool skip = TRUE) { m_skipped = skip; }
404 bool GetSkipped() const { return m_skipped; };
405
406 // implementation only: this test is explicitlty anti OO and this functions
407 // exists only for optimization purposes
408 bool IsCommandEvent() const { return m_isCommandEvent; }
409
410 void CopyObject(wxObject& object_dest) const;
411
412 public:
413 wxObject* m_eventObject;
414 wxEventType m_eventType;
415 long m_timeStamp;
416 int m_id;
417 wxObject* m_callbackUserData;
418 bool m_skipped;
419
420 // optimization: instead of using costly IsKindOf() we keep a flag telling
421 // whether we're a command event (by far the most common case)
422 bool m_isCommandEvent;
423 };
424
425 #if wxUSE_GUI
426
427 // Item or menu event class
428 /*
429 wxEVT_COMMAND_BUTTON_CLICKED
430 wxEVT_COMMAND_CHECKBOX_CLICKED
431 wxEVT_COMMAND_CHOICE_SELECTED
432 wxEVT_COMMAND_LISTBOX_SELECTED
433 wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
434 wxEVT_COMMAND_TEXT_UPDATED
435 wxEVT_COMMAND_TEXT_ENTER
436 wxEVT_COMMAND_MENU_SELECTED
437 wxEVT_COMMAND_SLIDER_UPDATED
438 wxEVT_COMMAND_RADIOBOX_SELECTED
439 wxEVT_COMMAND_RADIOBUTTON_SELECTED
440 wxEVT_COMMAND_SCROLLBAR_UPDATED
441 wxEVT_COMMAND_VLBOX_SELECTED
442 wxEVT_COMMAND_COMBOBOX_SELECTED
443 */
444
445 class WXDLLEXPORT wxCommandEvent : public wxEvent
446 {
447 DECLARE_DYNAMIC_CLASS(wxCommandEvent)
448
449 public:
450 wxCommandEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
451 ~wxCommandEvent() {}
452
453 /*
454 * Accessors dependent on context
455 *
456 */
457
458 // Set/Get client data from controls
459 void SetClientData(void* clientData) { m_clientData = clientData; }
460 void *GetClientData() const { return m_clientData; }
461
462 // Set/Get client object from controls
463 void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; }
464 void *GetClientObject() const { return m_clientObject; }
465
466 // Get listbox selection if single-choice
467 int GetSelection() const { return m_commandInt; }
468
469 // Set/Get listbox/choice selection string
470 void SetString(const wxString& s) { m_commandString = s; }
471 wxString GetString() const { return m_commandString; }
472
473 // Get checkbox value
474 bool IsChecked() const { return m_commandInt != 0; }
475
476 // TRUE if the listbox event was a selection.
477 bool IsSelection() const { return (m_extraLong != 0); }
478
479 void SetExtraLong(long extraLong) { m_extraLong = extraLong; }
480 long GetExtraLong() const { return m_extraLong ; }
481
482 void SetInt(int i) { m_commandInt = i; }
483 long GetInt() const { return m_commandInt ; }
484
485 void CopyObject(wxObject& obj) const;
486
487 #ifdef WXWIN_COMPATIBILITY_2
488 bool Checked() const { return IsChecked(); }
489 #endif // WXWIN_COMPATIBILITY_2
490
491 public:
492 wxString m_commandString; // String event argument
493 int m_commandInt;
494 long m_extraLong; // Additional information (e.g. select/deselect)
495 void* m_clientData; // Arbitrary client data
496 wxClientData* m_clientObject; // Arbitrary client object
497 };
498
499 // this class adds a possibility to react (from the user) code to a control
500 // notification: allow or veto the operation being reported.
501 class WXDLLEXPORT wxNotifyEvent : public wxCommandEvent
502 {
503 public:
504 wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
505 : wxCommandEvent(commandType, id) { m_bAllow = TRUE; }
506
507 // veto the operation (usually it's allowed by default)
508 void Veto() { m_bAllow = FALSE; }
509
510 // allow the operation if it was disabled by default
511 void Allow() { m_bAllow = TRUE; }
512
513 // for implementation code only: is the operation allowed?
514 bool IsAllowed() const { return m_bAllow; }
515
516 // probably useless: CopyObject() is used for deferred event
517 // handling but wxNotifyEvent must be processed immediately
518 void CopyObject(wxObject& obj) const;
519
520 private:
521 bool m_bAllow;
522
523 DECLARE_DYNAMIC_CLASS(wxNotifyEvent)
524 };
525
526 // Scroll event class, derived form wxCommandEvent. wxScrollEvents are
527 // sent by wxSlider and wxScrollbar.
528 /*
529 wxEVT_SCROLL_TOP
530 wxEVT_SCROLL_BOTTOM
531 wxEVT_SCROLL_LINEUP
532 wxEVT_SCROLL_LINEDOWN
533 wxEVT_SCROLL_PAGEUP
534 wxEVT_SCROLL_PAGEDOWN
535 wxEVT_SCROLL_THUMBTRACK
536 wxEVT_SCROLL_THUMBRELEASE
537 */
538
539 class WXDLLEXPORT wxScrollEvent : public wxCommandEvent
540 {
541 DECLARE_DYNAMIC_CLASS(wxScrollEvent)
542
543 public:
544 wxScrollEvent(wxEventType commandType = wxEVT_NULL,
545 int id = 0, int pos = 0, int orient = 0);
546 ~wxScrollEvent() {}
547
548 /*
549 * Accessors
550 *
551 */
552
553 int GetOrientation() const { return (int) m_extraLong ; }
554 int GetPosition() const { return m_commandInt ; }
555 void SetOrientation(int orient) { m_extraLong = (long) orient; }
556 void SetPosition(int pos) { m_commandInt = pos; }
557 };
558
559 // ScrollWin event class, derived fom wxEvent. wxScrollWinEvents
560 // are sent by wxWindow.
561 /*
562 wxEVT_SCROLLWIN_TOP
563 wxEVT_SCROLLWIN_BOTTOM
564 wxEVT_SCROLLWIN_LINEUP
565 wxEVT_SCROLLWIN_LINEDOWN
566 wxEVT_SCROLLWIN_PAGEUP
567 wxEVT_SCROLLWIN_PAGEDOWN
568 wxEVT_SCROLLWIN_THUMBTRACK
569 wxEVT_SCROLLWIN_THUMBRELEASE
570 */
571
572 class WXDLLEXPORT wxScrollWinEvent : public wxEvent
573 {
574 DECLARE_DYNAMIC_CLASS(wxScrollWinEvent)
575
576 public:
577 wxScrollWinEvent(wxEventType commandType = wxEVT_NULL,
578 int pos = 0, int orient = 0);
579 ~wxScrollWinEvent() {}
580
581 /*
582 * Accessors
583 */
584
585 int GetOrientation() const { return (int) m_extraLong ; }
586 int GetPosition() const { return m_commandInt ; }
587 void SetOrientation(int orient) { m_extraLong = (long) orient; }
588 void SetPosition(int pos) { m_commandInt = pos; }
589
590 void CopyObject(wxObject& object_dest) const;
591 public:
592 int m_commandInt; // Additional information
593 long m_extraLong;
594 };
595
596 // Mouse event class
597
598 /*
599 wxEVT_LEFT_DOWN
600 wxEVT_LEFT_UP
601 wxEVT_MIDDLE_DOWN
602 wxEVT_MIDDLE_UP
603 wxEVT_RIGHT_DOWN
604 wxEVT_RIGHT_UP
605 wxEVT_MOTION
606 wxEVT_ENTER_WINDOW
607 wxEVT_LEAVE_WINDOW
608 wxEVT_LEFT_DCLICK
609 wxEVT_MIDDLE_DCLICK
610 wxEVT_RIGHT_DCLICK
611 wxEVT_NC_LEFT_DOWN
612 wxEVT_NC_LEFT_UP,
613 wxEVT_NC_MIDDLE_DOWN,
614 wxEVT_NC_MIDDLE_UP,
615 wxEVT_NC_RIGHT_DOWN,
616 wxEVT_NC_RIGHT_UP,
617 wxEVT_NC_MOTION,
618 wxEVT_NC_ENTER_WINDOW,
619 wxEVT_NC_LEAVE_WINDOW,
620 wxEVT_NC_LEFT_DCLICK,
621 wxEVT_NC_MIDDLE_DCLICK,
622 wxEVT_NC_RIGHT_DCLICK,
623 */
624
625 class WXDLLEXPORT wxMouseEvent : public wxEvent
626 {
627 DECLARE_DYNAMIC_CLASS(wxMouseEvent)
628
629 public:
630 wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
631
632 // Was it a button event? (*doesn't* mean: is any button *down*?)
633 bool IsButton() const { return Button(-1); }
634
635 // Was it a down event from button 1, 2 or 3 or any?
636 bool ButtonDown(int but = -1) const;
637
638 // Was it a dclick event from button 1, 2 or 3 or any?
639 bool ButtonDClick(int but = -1) const;
640
641 // Was it a up event from button 1, 2 or 3 or any?
642 bool ButtonUp(int but = -1) const;
643
644 // Was the given button 1,2,3 or any changing state?
645 bool Button(int but) const;
646
647 // Was the given button 1,2,3 or any in Down state?
648 bool ButtonIsDown(int but) const;
649
650 // Find state of shift/control keys
651 bool ControlDown() const { return m_controlDown; }
652 bool MetaDown() const { return m_metaDown; }
653 bool AltDown() const { return m_altDown; }
654 bool ShiftDown() const { return m_shiftDown; }
655
656 // Find which event was just generated
657 bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); }
658 bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); }
659 bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); }
660
661 bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); }
662 bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); }
663 bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); }
664
665 bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); }
666 bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); }
667 bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); }
668
669 // Find the current state of the mouse buttons (regardless
670 // of current event type)
671 bool LeftIsDown() const { return m_leftDown; }
672 bool MiddleIsDown() const { return m_middleDown; }
673 bool RightIsDown() const { return m_rightDown; }
674
675 // True if a button is down and the mouse is moving
676 bool Dragging() const
677 {
678 return ((m_eventType == wxEVT_MOTION) &&
679 (LeftIsDown() || MiddleIsDown() || RightIsDown()));
680 }
681
682 // True if the mouse is moving, and no button is down
683 bool Moving() const { return (m_eventType == wxEVT_MOTION); }
684
685 // True if the mouse is just entering the window
686 bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); }
687
688 // True if the mouse is just leaving the window
689 bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
690
691 // Find the position of the event
692 void GetPosition(wxCoord *xpos, wxCoord *ypos) const
693 {
694 if (xpos)
695 *xpos = m_x;
696 if (ypos)
697 *ypos = m_y;
698 }
699
700 #ifndef __WIN16__
701 void GetPosition(long *xpos, long *ypos) const
702 {
703 if (xpos)
704 *xpos = (long)m_x;
705 if (ypos)
706 *ypos = (long)m_y;
707 }
708 #endif
709
710 // Find the position of the event
711 wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
712
713 // Find the logical position of the event given the DC
714 wxPoint GetLogicalPosition(const wxDC& dc) const ;
715
716 // Compatibility
717 #if WXWIN_COMPATIBILITY
718 void Position(long *xpos, long *ypos) const
719 {
720 if (xpos)
721 *xpos = (long)m_x;
722 if (ypos)
723 *ypos = (long)m_y;
724 }
725
726 void Position(float *xpos, float *ypos) const
727 {
728 *xpos = (float) m_x; *ypos = (float) m_y;
729 }
730 #endif // WXWIN_COMPATIBILITY
731
732 // Get X position
733 wxCoord GetX() const { return m_x; }
734
735 // Get Y position
736 wxCoord GetY() const { return m_y; }
737
738 void CopyObject(wxObject& obj) const;
739
740 public:
741 wxCoord m_x, m_y;
742
743 bool m_leftDown;
744 bool m_middleDown;
745 bool m_rightDown;
746
747 bool m_controlDown;
748 bool m_shiftDown;
749 bool m_altDown;
750 bool m_metaDown;
751 };
752
753 // Cursor set event
754
755 /*
756 wxEVT_SET_CURSOR
757 */
758
759 class WXDLLEXPORT wxSetCursorEvent : public wxEvent
760 {
761 public:
762 wxSetCursorEvent(wxCoord x, wxCoord y)
763 {
764 m_eventType = wxEVT_SET_CURSOR;
765
766 m_x = x;
767 m_y = y;
768 }
769
770 wxCoord GetX() const { return m_x; }
771 wxCoord GetY() const { return m_y; }
772
773 void SetCursor(const wxCursor& cursor) { m_cursor = cursor; }
774 const wxCursor& GetCursor() const { return m_cursor; }
775 bool HasCursor() const { return m_cursor.Ok(); }
776
777 private:
778 wxCoord m_x, m_y;
779 wxCursor m_cursor;
780 };
781
782 // Keyboard input event class
783
784 /*
785 wxEVT_CHAR
786 wxEVT_CHAR_HOOK
787 wxEVT_KEY_DOWN
788 wxEVT_KEY_UP
789 */
790
791 class WXDLLEXPORT wxKeyEvent : public wxEvent
792 {
793 DECLARE_DYNAMIC_CLASS(wxKeyEvent)
794
795 public:
796 wxKeyEvent(wxEventType keyType = wxEVT_NULL);
797
798 // Find state of shift/control keys
799 bool ControlDown() const { return m_controlDown; }
800 bool MetaDown() const { return m_metaDown; }
801 bool AltDown() const { return m_altDown; }
802 bool ShiftDown() const { return m_shiftDown; }
803
804 bool HasModifiers() const { return ControlDown() || AltDown() || MetaDown(); }
805
806 // get the key code: an ASCII7 char or an element of wxKeyCode enum
807 int GetKeyCode() const { return (int)m_keyCode; }
808
809 // Find the position of the event
810 void GetPosition(wxCoord *xpos, wxCoord *ypos) const
811 {
812 if (xpos) *xpos = m_x;
813 if (ypos) *ypos = m_y;
814 }
815
816 #ifndef __WIN16__
817 void GetPosition(long *xpos, long *ypos) const
818 {
819 if (xpos) *xpos = (long)m_x;
820 if (ypos) *ypos = (long)m_y;
821 }
822 #endif
823
824 wxPoint GetPosition() const
825 { return wxPoint(m_x, m_y); }
826
827 // Get X position
828 wxCoord GetX() const { return m_x; }
829
830 // Get Y position
831 wxCoord GetY() const { return m_y; }
832
833 void CopyObject(wxObject& obj) const;
834
835 // deprecated
836 long KeyCode() const { return m_keyCode; }
837
838 public:
839 wxCoord m_x, m_y;
840
841 long m_keyCode;
842
843 bool m_controlDown;
844 bool m_shiftDown;
845 bool m_altDown;
846 bool m_metaDown;
847 bool m_scanCode;
848 };
849
850 // Size event class
851 /*
852 wxEVT_SIZE
853 */
854
855 class WXDLLEXPORT wxSizeEvent : public wxEvent
856 {
857 DECLARE_DYNAMIC_CLASS(wxSizeEvent)
858
859 public:
860 wxSize m_size;
861
862 wxSizeEvent() { m_eventType = wxEVT_SIZE; }
863 wxSizeEvent(const wxSize& sz, int id = 0)
864 : m_size(sz)
865 { m_eventType = wxEVT_SIZE; m_id = id; }
866
867 wxSize GetSize() const { return m_size; }
868
869 void CopyObject(wxObject& obj) const;
870 };
871
872 // Move event class
873
874 /*
875 wxEVT_MOVE
876 */
877
878 class WXDLLEXPORT wxMoveEvent : public wxEvent
879 {
880 DECLARE_DYNAMIC_CLASS(wxMoveEvent)
881
882 public:
883 wxPoint m_pos;
884
885 wxMoveEvent() { m_eventType = wxEVT_MOVE; }
886 wxMoveEvent(const wxPoint& pos, int id = 0)
887 : m_pos(pos)
888 { m_eventType = wxEVT_MOVE; m_id = id; }
889
890 wxPoint GetPosition() const { return m_pos; }
891
892 void CopyObject(wxObject& obj) const;
893 };
894
895 // Paint event class
896 /*
897 wxEVT_PAINT
898 wxEVT_NC_PAINT
899 wxEVT_PAINT_ICON
900 */
901
902 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
903 // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
904 extern WXDLLEXPORT int g_isPainting;
905 #endif // debug
906
907 class WXDLLEXPORT wxPaintEvent : public wxEvent
908 {
909 DECLARE_DYNAMIC_CLASS(wxPaintEvent)
910
911 public:
912 wxPaintEvent(int Id = 0)
913 {
914 m_eventType = wxEVT_PAINT;
915 m_id = Id;
916
917 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
918 // set the internal flag for the duration of processing of WM_PAINT
919 g_isPainting++;
920 #endif // debug
921 }
922
923 #if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
924 ~wxPaintEvent()
925 {
926 g_isPainting--;
927 }
928 #endif // debug
929 };
930
931 // Erase background event class
932 /*
933 wxEVT_ERASE_BACKGROUND
934 */
935
936 class WXDLLEXPORT wxEraseEvent : public wxEvent
937 {
938 DECLARE_DYNAMIC_CLASS(wxEraseEvent)
939
940 public:
941 wxDC *m_dc;
942
943 wxEraseEvent(int Id = 0, wxDC *dc = (wxDC *) NULL)
944 { m_eventType = wxEVT_ERASE_BACKGROUND; m_id = Id; m_dc = dc; }
945 wxDC *GetDC() const { return m_dc; }
946
947 void CopyObject(wxObject& obj) const;
948 };
949
950 // Focus event class
951 /*
952 wxEVT_SET_FOCUS
953 wxEVT_KILL_FOCUS
954 */
955
956 class WXDLLEXPORT wxFocusEvent : public wxEvent
957 {
958 DECLARE_DYNAMIC_CLASS(wxFocusEvent)
959
960 public:
961 wxFocusEvent(wxEventType type = wxEVT_NULL, int Id = 0)
962 { m_eventType = type; m_id = Id; }
963 };
964
965 // Activate event class
966 /*
967 wxEVT_ACTIVATE
968 wxEVT_ACTIVATE_APP
969 */
970
971 class WXDLLEXPORT wxActivateEvent : public wxEvent
972 {
973 DECLARE_DYNAMIC_CLASS(wxActivateEvent)
974
975 public:
976 wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = TRUE, int Id = 0)
977 { m_eventType = type; m_active = active; m_id = Id; }
978 bool GetActive() const { return m_active; }
979
980 void CopyObject(wxObject& obj) const;
981
982 private:
983 bool m_active;
984 };
985
986 // InitDialog event class
987 /*
988 wxEVT_INIT_DIALOG
989 */
990
991 class WXDLLEXPORT wxInitDialogEvent : public wxEvent
992 {
993 DECLARE_DYNAMIC_CLASS(wxInitDialogEvent)
994
995 public:
996 wxInitDialogEvent(int Id = 0)
997 { m_eventType = wxEVT_INIT_DIALOG; m_id = Id; }
998 };
999
1000 // Miscellaneous menu event class
1001 /*
1002 wxEVT_MENU_CHAR,
1003 wxEVT_MENU_INIT,
1004 wxEVT_MENU_HIGHLIGHT,
1005 wxEVT_POPUP_MENU_INIT,
1006 wxEVT_CONTEXT_MENU,
1007 */
1008
1009 class WXDLLEXPORT wxMenuEvent : public wxEvent
1010 {
1011 DECLARE_DYNAMIC_CLASS(wxMenuEvent)
1012
1013 public:
1014 wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0)
1015 { m_eventType = type; m_menuId = id; }
1016
1017 int GetMenuId() const { return m_menuId; }
1018
1019 void CopyObject(wxObject& obj) const;
1020 private:
1021 int m_menuId;
1022 };
1023
1024 // Window close or session close event class
1025 /*
1026 wxEVT_CLOSE_WINDOW,
1027 wxEVT_END_SESSION,
1028 wxEVT_QUERY_END_SESSION
1029 */
1030
1031 class WXDLLEXPORT wxCloseEvent : public wxEvent
1032 {
1033 DECLARE_DYNAMIC_CLASS(wxCloseEvent)
1034
1035 public:
1036 wxCloseEvent(wxEventType type = wxEVT_NULL, int id = 0)
1037 {
1038 m_eventType = type;
1039 m_loggingOff = TRUE;
1040 m_veto = FALSE; // should be FALSE by default
1041 m_id = id;
1042 #if WXWIN_COMPATIBILITY
1043 m_force = FALSE;
1044 #endif // WXWIN_COMPATIBILITY
1045 m_canVeto = TRUE;
1046 }
1047
1048 void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
1049 bool GetLoggingOff() const { return m_loggingOff; }
1050
1051 void Veto(bool veto = TRUE)
1052 {
1053 // GetVeto() will return FALSE anyhow...
1054 wxCHECK_RET( m_canVeto,
1055 wxT("call to Veto() ignored (can't veto this event)") );
1056
1057 m_veto = veto;
1058 }
1059 void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
1060 // No more asserts here please, the one you put here was wrong.
1061 bool CanVeto() const { return m_canVeto; }
1062 bool GetVeto() const { return m_canVeto && m_veto; }
1063
1064 #if WXWIN_COMPATIBILITY
1065 // This is probably obsolete now, since we use CanVeto instead, in
1066 // both OnCloseWindow and OnQueryEndSession.
1067 // m_force == ! m_canVeto i.e., can't veto means we must force it to close.
1068 void SetForce(bool force) { m_force = force; }
1069 bool GetForce() const { return m_force; }
1070 #endif
1071
1072 void CopyObject(wxObject& obj) const;
1073
1074 protected:
1075 bool m_loggingOff;
1076 bool m_veto, m_canVeto;
1077
1078 #if WXWIN_COMPATIBILITY
1079 bool m_force;
1080 #endif
1081 };
1082
1083 /*
1084 wxEVT_SHOW
1085 */
1086
1087 class WXDLLEXPORT wxShowEvent : public wxEvent
1088 {
1089 DECLARE_DYNAMIC_CLASS(wxShowEvent)
1090
1091 public:
1092
1093 wxShowEvent(int id = 0, bool show = FALSE)
1094 { m_eventType = wxEVT_SHOW; m_id = id; m_show = show; }
1095
1096 void SetShow(bool show) { m_show = show; }
1097 bool GetShow() const { return m_show; }
1098
1099 void CopyObject(wxObject& obj) const;
1100
1101 protected:
1102 bool m_show;
1103 };
1104
1105 /*
1106 wxEVT_ICONIZE
1107 */
1108
1109 class WXDLLEXPORT wxIconizeEvent : public wxEvent
1110 {
1111 DECLARE_DYNAMIC_CLASS(wxIconizeEvent)
1112
1113 public:
1114 wxIconizeEvent(int id = 0)
1115 { m_eventType = wxEVT_ICONIZE; m_id = id; }
1116 };
1117
1118 /*
1119 wxEVT_MAXIMIZE
1120 */
1121
1122 class WXDLLEXPORT wxMaximizeEvent : public wxEvent
1123 {
1124 DECLARE_DYNAMIC_CLASS(wxMaximizeEvent)
1125
1126 public:
1127 wxMaximizeEvent(int id = 0)
1128 { m_eventType = wxEVT_MAXIMIZE; m_id = id; }
1129 };
1130
1131 // Joystick event class
1132 /*
1133 wxEVT_JOY_BUTTON_DOWN,
1134 wxEVT_JOY_BUTTON_UP,
1135 wxEVT_JOY_MOVE,
1136 wxEVT_JOY_ZMOVE
1137 */
1138
1139 // Which joystick? Same as Windows ids so no conversion necessary.
1140 #define wxJOYSTICK1 0
1141 #define wxJOYSTICK2 1
1142
1143 // Which button is down?
1144 #define wxJOY_BUTTON1 1
1145 #define wxJOY_BUTTON2 2
1146 #define wxJOY_BUTTON3 4
1147 #define wxJOY_BUTTON4 8
1148 #define wxJOY_BUTTON_ANY -1
1149
1150 class WXDLLEXPORT wxJoystickEvent : public wxEvent
1151 {
1152 DECLARE_DYNAMIC_CLASS(wxJoystickEvent)
1153
1154 public:
1155 wxPoint m_pos;
1156 int m_zPosition;
1157 int m_buttonChange; // Which button changed?
1158 int m_buttonState; // Which buttons are down?
1159 int m_joyStick; // Which joystick?
1160
1161 wxJoystickEvent(wxEventType type = wxEVT_NULL,
1162 int state = 0,
1163 int joystick = wxJOYSTICK1,
1164 int change = 0)
1165 {
1166 m_eventType = type;
1167 m_buttonState = state;
1168 m_pos = wxPoint(0,0);
1169 m_zPosition = 0;
1170 m_joyStick = joystick;
1171 m_buttonChange = change;
1172 }
1173
1174 wxPoint GetPosition() const { return m_pos; }
1175 int GetZPosition() const { return m_zPosition; }
1176 int GetButtonState() const { return m_buttonState; }
1177 int GetButtonChange() const { return m_buttonChange; }
1178 int GetJoystick() const { return m_joyStick; }
1179
1180 void SetJoystick(int stick) { m_joyStick = stick; }
1181 void SetButtonState(int state) { m_buttonState = state; }
1182 void SetButtonChange(int change) { m_buttonChange = change; }
1183 void SetPosition(const wxPoint& pos) { m_pos = pos; }
1184 void SetZPosition(int zPos) { m_zPosition = zPos; }
1185
1186 // Was it a button event? (*doesn't* mean: is any button *down*?)
1187 bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) ||
1188 (GetEventType() == wxEVT_JOY_BUTTON_UP)); }
1189
1190 // Was it a move event?
1191 bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE) ; }
1192
1193 // Was it a zmove event?
1194 bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE) ; }
1195
1196 // Was it a down event from button 1, 2, 3, 4 or any?
1197 bool ButtonDown(int but = wxJOY_BUTTON_ANY) const
1198 { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) &&
1199 ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
1200
1201 // Was it a up event from button 1, 2, 3 or any?
1202 bool ButtonUp(int but = wxJOY_BUTTON_ANY) const
1203 { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) &&
1204 ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
1205
1206 // Was the given button 1,2,3,4 or any in Down state?
1207 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const
1208 { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) ||
1209 ((m_buttonState & but) == but)); }
1210
1211 void CopyObject(wxObject& obj) const;
1212 };
1213
1214 // Drop files event class
1215 /*
1216 wxEVT_DROP_FILES
1217 */
1218
1219 class WXDLLEXPORT wxDropFilesEvent : public wxEvent
1220 {
1221 DECLARE_DYNAMIC_CLASS(wxDropFilesEvent)
1222
1223 public:
1224 int m_noFiles;
1225 wxPoint m_pos;
1226 wxString* m_files; // Memory (de)allocated by code calling ProcessEvent
1227
1228 wxDropFilesEvent(wxEventType type = wxEVT_NULL,
1229 int noFiles = 0,
1230 wxString *files = (wxString *) NULL)
1231 { m_eventType = type; m_noFiles = noFiles; m_files = files; }
1232
1233 wxPoint GetPosition() const { return m_pos; }
1234 int GetNumberOfFiles() const { return m_noFiles; }
1235 wxString *GetFiles() const { return m_files; }
1236
1237 void CopyObject(wxObject& obj) const;
1238 };
1239
1240 // Update UI event
1241 /*
1242 wxEVT_UPDATE_UI
1243 */
1244
1245 class WXDLLEXPORT wxUpdateUIEvent : public wxCommandEvent
1246 {
1247 DECLARE_DYNAMIC_CLASS(wxUpdateUIEvent)
1248
1249 public:
1250 wxUpdateUIEvent(wxWindowID commandId = 0)
1251 {
1252 m_eventType = wxEVT_UPDATE_UI;
1253 m_id = commandId;
1254 m_checked = FALSE;
1255 m_setChecked = FALSE;
1256 m_enabled = FALSE;
1257 m_setEnabled = FALSE;
1258 m_setText = FALSE;
1259 m_text = "";
1260 }
1261
1262 bool GetChecked() const { return m_checked; }
1263 bool GetEnabled() const { return m_enabled; }
1264 wxString GetText() const { return m_text; }
1265 bool GetSetText() const { return m_setText; }
1266 bool GetSetChecked() const { return m_setChecked; }
1267 bool GetSetEnabled() const { return m_setEnabled; }
1268
1269 void Check(bool check) { m_checked = check; m_setChecked = TRUE; }
1270 void Enable(bool enable) { m_enabled = enable; m_setEnabled = TRUE; }
1271 void SetText(const wxString& text) { m_text = text; m_setText = TRUE; }
1272
1273 void CopyObject(wxObject& obj) const;
1274
1275 protected:
1276 bool m_checked;
1277 bool m_enabled;
1278 bool m_setEnabled;
1279 bool m_setText;
1280 bool m_setChecked;
1281 wxString m_text;
1282 };
1283
1284 /*
1285 wxEVT_SYS_COLOUR_CHANGED
1286 */
1287
1288 // TODO: shouldn't all events record the window ID?
1289 class WXDLLEXPORT wxSysColourChangedEvent : public wxEvent
1290 {
1291 DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent)
1292
1293 public:
1294 wxSysColourChangedEvent()
1295 { m_eventType = wxEVT_SYS_COLOUR_CHANGED; }
1296 };
1297
1298 /*
1299 wxEVT_PALETTE_CHANGED
1300 */
1301
1302 class WXDLLEXPORT wxPaletteChangedEvent : public wxEvent
1303 {
1304 DECLARE_DYNAMIC_CLASS(wxPaletteChangedEvent)
1305
1306 public:
1307 wxPaletteChangedEvent(wxWindowID id = 0) : wxEvent(id)
1308 {
1309 m_eventType = wxEVT_PALETTE_CHANGED;
1310 m_changedWindow = (wxWindow *) NULL;
1311 }
1312
1313 void SetChangedWindow(wxWindow* win) { m_changedWindow = win; }
1314 wxWindow* GetChangedWindow() const { return m_changedWindow; }
1315
1316 void CopyObject(wxObject& obj) const;
1317
1318 protected:
1319 wxWindow* m_changedWindow;
1320 };
1321
1322 /*
1323 wxEVT_QUERY_NEW_PALETTE
1324 Indicates the window is getting keyboard focus and should re-do its palette.
1325 */
1326
1327 class WXDLLEXPORT wxQueryNewPaletteEvent : public wxEvent
1328 {
1329 DECLARE_DYNAMIC_CLASS(wxQueryNewPaletteEvent)
1330
1331 public:
1332 wxQueryNewPaletteEvent(wxWindowID id = 0): wxEvent(id)
1333 { m_eventType = wxEVT_QUERY_NEW_PALETTE; m_paletteRealized = FALSE; }
1334
1335 // App sets this if it changes the palette.
1336 void SetPaletteRealized(bool realized) { m_paletteRealized = realized; }
1337 bool GetPaletteRealized() const { return m_paletteRealized; }
1338
1339 void CopyObject(wxObject& obj) const;
1340
1341 protected:
1342 bool m_paletteRealized;
1343 };
1344
1345 /*
1346 Event generated by dialog navigation keys
1347 wxEVT_NAVIGATION_KEY
1348 */
1349 // NB: don't derive from command event to avoid being propagated to the parent
1350 class WXDLLEXPORT wxNavigationKeyEvent : public wxEvent
1351 {
1352 public:
1353 wxNavigationKeyEvent()
1354 {
1355 SetEventType(wxEVT_NAVIGATION_KEY);
1356
1357 m_flags = IsForward | Propagate; // defaults are for TAB
1358 m_focus = (wxWindow *)NULL;
1359 }
1360
1361 // direction: forward (true) or backward (false)
1362 bool GetDirection() const
1363 { return (m_flags & IsForward) != 0; }
1364 void SetDirection(bool bForward)
1365 { if ( bForward ) m_flags |= IsForward; else m_flags &= ~IsForward; }
1366
1367 // it may be a window change event (MDI, notebook pages...) or a control
1368 // change event
1369 bool IsWindowChange() const
1370 { return (m_flags & WinChange) != 0; }
1371 void SetWindowChange(bool bIs)
1372 { if ( bIs ) m_flags |= WinChange; else m_flags &= ~WinChange; }
1373
1374 // some navigation events are meant to be propagated upwards (Windows
1375 // convention is to do this for TAB events) while others should always
1376 // cycle inside the panel/radiobox/whatever we're current inside
1377 bool ShouldPropagate() const
1378 { return (m_flags & Propagate) != 0; }
1379 void SetPropagate(bool bDoIt)
1380 { if ( bDoIt ) m_flags |= Propagate; else m_flags &= ~Propagate; }
1381
1382 // the child which has the focus currently (may be NULL - use
1383 // wxWindow::FindFocus then)
1384 wxWindow* GetCurrentFocus() const { return m_focus; }
1385 void SetCurrentFocus(wxWindow *win) { m_focus = win; }
1386
1387 private:
1388 enum
1389 {
1390 IsForward = 0x0001,
1391 WinChange = 0x0002,
1392 Propagate = 0x0004
1393 };
1394
1395 long m_flags;
1396 wxWindow *m_focus;
1397
1398 DECLARE_DYNAMIC_CLASS(wxNavigationKeyEvent)
1399 };
1400
1401 // Window creation/destruction events: the first is sent as soon as window is
1402 // created (i.e. the underlying GUI object exists), but when the C++ object is
1403 // fully initialized (so virtual functions may be called). The second,
1404 // wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
1405 // still safe to call virtual functions at this moment
1406 /*
1407 wxEVT_CREATE
1408 wxEVT_DESTROY
1409 */
1410
1411 class WXDLLEXPORT wxWindowCreateEvent : public wxCommandEvent
1412 {
1413 DECLARE_DYNAMIC_CLASS(wxWindowCreateEvent)
1414
1415 public:
1416 wxWindowCreateEvent(wxWindow *win = NULL);
1417
1418 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
1419 };
1420
1421 class WXDLLEXPORT wxWindowDestroyEvent : public wxCommandEvent
1422 {
1423 DECLARE_DYNAMIC_CLASS(wxWindowDestroyEvent)
1424
1425 public:
1426 wxWindowDestroyEvent(wxWindow *win = NULL);
1427
1428 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
1429 };
1430
1431 // A help event is sent when the user clicks on a window in context-help mode.
1432 /*
1433 wxEVT_HELP
1434 wxEVT_DETAILED_HELP
1435 */
1436
1437 class WXDLLEXPORT wxHelpEvent : public wxCommandEvent
1438 {
1439 public:
1440 wxHelpEvent(wxEventType type = wxEVT_NULL,
1441 wxWindowID id = 0,
1442 const wxPoint& pt = wxDefaultPosition)
1443 {
1444 m_eventType = type;
1445 m_id = id;
1446 m_pos = pt;
1447 }
1448
1449 // Position of event (in screen coordinates)
1450 const wxPoint& GetPosition() const { return m_pos; }
1451 void SetPosition(const wxPoint& pos) { m_pos = pos; }
1452
1453 // Optional link to further help
1454 const wxString& GetLink() const { return m_link; }
1455 void SetLink(const wxString& link) { m_link = link; }
1456
1457 // Optional target to display help in. E.g. a window specification
1458 const wxString& GetTarget() const { return m_target; }
1459 void SetTarget(const wxString& target) { m_target = target; }
1460
1461 protected:
1462 wxPoint m_pos;
1463 wxString m_target;
1464 wxString m_link;
1465
1466 private:
1467 DECLARE_DYNAMIC_CLASS(wxHelpEvent)
1468 };
1469
1470 #endif // wxUSE_GUI
1471
1472 // Idle event
1473 /*
1474 wxEVT_IDLE
1475 */
1476
1477 class WXDLLEXPORT wxIdleEvent : public wxEvent
1478 {
1479 DECLARE_DYNAMIC_CLASS(wxIdleEvent)
1480
1481 public:
1482 wxIdleEvent()
1483 { m_eventType = wxEVT_IDLE; m_requestMore = FALSE; }
1484
1485 void RequestMore(bool needMore = TRUE) { m_requestMore = needMore; }
1486 bool MoreRequested() const { return m_requestMore; }
1487
1488 void CopyObject(wxObject& obj) const;
1489
1490 protected:
1491 bool m_requestMore;
1492 };
1493
1494 /* TODO
1495 wxEVT_POWER,
1496 wxEVT_MOUSE_CAPTURE_CHANGED,
1497 wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
1498 // wxEVT_FONT_CHANGED, // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate
1499 // wxEVT_FONT_CHANGED to all other windows (maybe).
1500 wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific.
1501 wxEVT_MEASURE_ITEM,
1502 wxEVT_COMPARE_ITEM
1503 */
1504
1505 // ============================================================================
1506 // event handler and related classes
1507 // ============================================================================
1508
1509 typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
1510
1511 // struct containing the members common to static and dynamic event tables
1512 // entries
1513 struct WXDLLEXPORT wxEventTableEntryBase
1514 {
1515 // provide default ctors for everything in backwards compatibility mode
1516 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1517 wxEventTableEntryBase() { }
1518 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1519 wxEventTableEntryBase(int id, int idLast,
1520 wxObjectEventFunction fn, wxObject *data)
1521 {
1522 m_id = id;
1523 m_lastId = idLast;
1524 m_fn = fn;
1525 m_callbackUserData = data;
1526 }
1527 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1528
1529 // the range of ids for this entry: if m_lastId == -1, the range consists
1530 // only of m_id, otherwise it is m_id..m_lastId inclusive
1531 int m_id, m_lastId;
1532
1533 // function to call: not wxEventFunction, because of dependency problems
1534 wxObjectEventFunction m_fn;
1535
1536 // arbitrary user data asosciated with the callback
1537 wxObject* m_callbackUserData;
1538 };
1539
1540 // an entry from a static event table
1541 struct WXDLLEXPORT wxEventTableEntry : public wxEventTableEntryBase
1542 {
1543 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1544 wxEventTableEntry() { }
1545 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1546 wxEventTableEntry(const int& evType, int id, int idLast,
1547 wxObjectEventFunction fn, wxObject *data)
1548 : wxEventTableEntryBase(id, idLast, fn, data),
1549 m_eventType(evType)
1550 {
1551 }
1552 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1553
1554 // the reference to event type: this allows us to not care about the
1555 // (undefined) order in which the event table entries and the event types
1556 // are initialized: initially the value of this reference might be
1557 // invalid, but by the time it is used for the first time, all global
1558 // objects will have been initialized (including the event type constants)
1559 // and so it will have the correct value when it is needed
1560 const int& m_eventType;
1561 };
1562
1563 // an entry used in dynamic event table managed by wxEvtHandler::Connect()
1564 struct WXDLLEXPORT wxDynamicEventTableEntry : public wxEventTableEntryBase
1565 {
1566 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1567 wxDynamicEventTableEntry() { }
1568 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1569 wxDynamicEventTableEntry(int evType, int id, int idLast,
1570 wxObjectEventFunction fn, wxObject *data)
1571 : wxEventTableEntryBase(id, idLast, fn, data)
1572 {
1573 m_eventType = evType;
1574 }
1575 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1576
1577 // not a reference here as we can't keep a reference to a temporary int
1578 // created to wrap the constant value typically passed to Connect() - nor
1579 // do we need it
1580 int m_eventType;
1581 };
1582
1583 struct WXDLLEXPORT wxEventTable
1584 {
1585 const wxEventTable *baseTable; // base event table (next in chain)
1586 const wxEventTableEntry *entries; // bottom of entry array
1587 };
1588
1589 // ----------------------------------------------------------------------------
1590 // wxEvtHandler: the base class for all objects handling wxWindows events
1591 // ----------------------------------------------------------------------------
1592
1593 class WXDLLEXPORT wxEvtHandler : public wxObject
1594 {
1595 public:
1596 wxEvtHandler();
1597 virtual ~wxEvtHandler();
1598
1599 wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
1600 wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
1601 void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
1602 void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }
1603
1604 void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
1605 bool GetEvtHandlerEnabled() const { return m_enabled; }
1606
1607 // process an event right now
1608 virtual bool ProcessEvent(wxEvent& event);
1609
1610 // add an event to be processed later
1611 void AddPendingEvent(wxEvent& event);
1612
1613 // process all pending events
1614 void ProcessPendingEvents();
1615
1616 // add a
1617 #if wxUSE_THREADS
1618 bool ProcessThreadEvent(wxEvent& event);
1619 #endif
1620
1621 // Dynamic association of a member function handler with the event handler,
1622 // id and event type
1623 void Connect( int id, int lastId, int eventType,
1624 wxObjectEventFunction func,
1625 wxObject *userData = (wxObject *) NULL );
1626
1627 // Convenience function: take just one id
1628 void Connect( int id, int eventType,
1629 wxObjectEventFunction func,
1630 wxObject *userData = (wxObject *) NULL )
1631 { Connect(id, -1, eventType, func, userData); }
1632
1633 bool Disconnect( int id, int lastId = -1, wxEventType eventType = wxEVT_NULL,
1634 wxObjectEventFunction func = NULL,
1635 wxObject *userData = (wxObject *) NULL );
1636
1637 // Convenience function: take just one id
1638 bool Disconnect( int id, wxEventType eventType = wxEVT_NULL,
1639 wxObjectEventFunction func = NULL,
1640 wxObject *userData = (wxObject *) NULL )
1641 { return Disconnect(id, -1, eventType, func, userData); }
1642
1643 // implementation from now on
1644 virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
1645 bool SearchDynamicEventTable( wxEvent& event );
1646
1647 #if wxUSE_THREADS
1648 void ClearEventLocker()
1649 {
1650 # if !defined(__VISAGECPP__)
1651 delete m_eventsLocker;
1652 m_eventsLocker = NULL;
1653 #endif
1654 };
1655 #endif
1656
1657 // old stuff
1658
1659 #if WXWIN_COMPATIBILITY_2
1660 virtual void OnCommand(wxWindow& WXUNUSED(win),
1661 wxCommandEvent& WXUNUSED(event))
1662 {
1663 wxFAIL_MSG(wxT("shouldn't be called any more"));
1664 }
1665
1666 // Called if child control has no callback function
1667 virtual long Default()
1668 { return GetNextHandler() ? GetNextHandler()->Default() : 0; };
1669 #endif // WXWIN_COMPATIBILITY_2
1670
1671 #if WXWIN_COMPATIBILITY
1672 virtual bool OnClose();
1673 #endif
1674
1675 private:
1676 static const wxEventTableEntry sm_eventTableEntries[];
1677
1678 protected:
1679 static const wxEventTable sm_eventTable;
1680
1681 virtual const wxEventTable *GetEventTable() const;
1682
1683 wxEvtHandler* m_nextHandler;
1684 wxEvtHandler* m_previousHandler;
1685 wxList* m_dynamicEvents;
1686 wxList* m_pendingEvents;
1687
1688 #if wxUSE_THREADS
1689 #if defined (__VISAGECPP__)
1690 wxCriticalSection m_eventsLocker;
1691 # else
1692 wxCriticalSection* m_eventsLocker;
1693 # endif
1694 #endif
1695
1696 // optimization: instead of using costly IsKindOf() to decide whether we're
1697 // a window (which is true in 99% of cases), use this flag
1698 bool m_isWindow;
1699
1700 // Is event handler enabled?
1701 bool m_enabled;
1702
1703 private:
1704 DECLARE_DYNAMIC_CLASS(wxEvtHandler)
1705 };
1706
1707 typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
1708 #if wxUSE_GUI
1709 typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);
1710 typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&);
1711 typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&);
1712 typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&);
1713 typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&);
1714 typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&);
1715 typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&);
1716 typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&);
1717 typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&);
1718 typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&);
1719 typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&);
1720 typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&);
1721 typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&);
1722 typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&);
1723 typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&);
1724 typedef void (wxEvtHandler::*wxSysColourChangedFunction)(wxSysColourChangedEvent&);
1725 typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&);
1726 typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
1727 typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&);
1728 typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&);
1729 typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxShowEvent&);
1730 typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxShowEvent&);
1731 typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&);
1732 typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&);
1733 typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&);
1734 typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&);
1735 typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&);
1736 typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&);
1737 typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&);
1738 typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&);
1739 #endif // wxUSE_GUI
1740
1741 // N.B. In GNU-WIN32, you *have* to take the address of a member function
1742 // (use &) or the compiler crashes...
1743
1744 #define DECLARE_EVENT_TABLE() \
1745 private:\
1746 static const wxEventTableEntry sm_eventTableEntries[];\
1747 protected:\
1748 static const wxEventTable sm_eventTable;\
1749 virtual const wxEventTable* GetEventTable() const;
1750
1751 #define BEGIN_EVENT_TABLE(theClass, baseClass) \
1752 const wxEventTable *theClass::GetEventTable() const { return &theClass::sm_eventTable; }\
1753 const wxEventTable theClass::sm_eventTable =\
1754 { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] };\
1755 const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
1756
1757 #define END_EVENT_TABLE() \
1758 wxEventTableEntry( 0, 0, 0, 0, 0 ) };
1759
1760 /*
1761 * Event table macros
1762 */
1763
1764 // Generic events
1765 #define EVT_CUSTOM(event, id, func) wxEventTableEntry( event, id, -1, (wxObjectEventFunction) (wxEventFunction) & func, (wxObject *) NULL ),
1766 #define EVT_CUSTOM_RANGE(event, id1, id2, func) wxEventTableEntry( event, id1, id2, (wxObjectEventFunction) (wxEventFunction) & func, (wxObject *) NULL ),
1767
1768 // Miscellaneous
1769 #define EVT_SIZE(func) wxEventTableEntry( wxEVT_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) & func, (wxObject *) NULL ),
1770 #define EVT_MOVE(func) wxEventTableEntry( wxEVT_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMoveEventFunction) & func, (wxObject *) NULL ),
1771 #define EVT_CLOSE(func) wxEventTableEntry( wxEVT_CLOSE_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
1772 #define EVT_END_SESSION(func) wxEventTableEntry( wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
1773 #define EVT_QUERY_END_SESSION(func) wxEventTableEntry( wxEVT_QUERY_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
1774 #define EVT_PAINT(func) wxEventTableEntry( wxEVT_PAINT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaintEventFunction) & func, (wxObject *) NULL ),
1775 #define EVT_ERASE_BACKGROUND(func) wxEventTableEntry( wxEVT_ERASE_BACKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxEraseEventFunction) & func, (wxObject *) NULL ),
1776 #define EVT_CHAR(func) wxEventTableEntry( wxEVT_CHAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
1777 #define EVT_KEY_DOWN(func) wxEventTableEntry( wxEVT_KEY_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
1778 #define EVT_KEY_UP(func) wxEventTableEntry( wxEVT_KEY_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
1779 #define EVT_CHAR_HOOK(func) wxEventTableEntry( wxEVT_CHAR_HOOK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, NULL ),
1780 #define EVT_MENU_HIGHLIGHT(id, func) wxEventTableEntry( wxEVT_MENU_HIGHLIGHT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ),
1781 #define EVT_MENU_HIGHLIGHT_ALL(func) wxEventTableEntry( wxEVT_MENU_HIGHLIGHT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ),
1782 #define EVT_SET_FOCUS(func) wxEventTableEntry( wxEVT_SET_FOCUS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxFocusEventFunction) & func, (wxObject *) NULL ),
1783 #define EVT_KILL_FOCUS(func) wxEventTableEntry( wxEVT_KILL_FOCUS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxFocusEventFunction) & func, (wxObject *) NULL ),
1784 #define EVT_ACTIVATE(func) wxEventTableEntry( wxEVT_ACTIVATE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxActivateEventFunction) & func, (wxObject *) NULL ),
1785 #define EVT_ACTIVATE_APP(func) wxEventTableEntry( wxEVT_ACTIVATE_APP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxActivateEventFunction) & func, (wxObject *) NULL ),
1786 #define EVT_END_SESSION(func) wxEventTableEntry( wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
1787 #define EVT_QUERY_END_SESSION(func) wxEventTableEntry( wxEVT_QUERY_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
1788 #define EVT_DROP_FILES(func) wxEventTableEntry( wxEVT_DROP_FILES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDropFilesEventFunction) & func, (wxObject *) NULL ),
1789 #define EVT_INIT_DIALOG(func) wxEventTableEntry( wxEVT_INIT_DIALOG, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxInitDialogEventFunction) & func, (wxObject *) NULL ),
1790 #define EVT_SYS_COLOUR_CHANGED(func) wxEventTableEntry( wxEVT_SYS_COLOUR_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSysColourChangedFunction) & func, (wxObject *) NULL ),
1791 #define EVT_SHOW(func) wxEventTableEntry( wxEVT_SHOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxShowEventFunction) & func, (wxObject *) NULL ),
1792 #define EVT_MAXIMIZE(func) wxEventTableEntry( wxEVT_MAXIMIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMaximizeEventFunction) & func, (wxObject *) NULL ),
1793 #define EVT_ICONIZE(func) wxEventTableEntry( wxEVT_ICONIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIconizeEventFunction) & func, (wxObject *) NULL ),
1794 #define EVT_NAVIGATION_KEY(func) wxEventTableEntry( wxEVT_NAVIGATION_KEY, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNavigationKeyEventFunction) & func, (wxObject *) NULL ),
1795 #define EVT_PALETTE_CHANGED(func) wxEventTableEntry( wxEVT_PALETTE_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaletteChangedEventFunction) & func, (wxObject *) NULL ),
1796 #define EVT_QUERY_NEW_PALETTE(func) wxEventTableEntry( wxEVT_QUERY_NEW_PALETTE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryNewPaletteEventFunction) & func, (wxObject *) NULL ),
1797 #define EVT_WINDOW_CREATE(func) wxEventTableEntry( wxEVT_CREATE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxWindowCreateEventFunction) & func, (wxObject *) NULL ),
1798 #define EVT_WINDOW_DESTROY(func) wxEventTableEntry( wxEVT_DESTROY, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxWindowDestroyEventFunction) & func, (wxObject *) NULL ),
1799 #define EVT_SET_CURSOR(func) wxEventTableEntry( wxEVT_SET_CURSOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSetCursorEventFunction) & func, (wxObject *) NULL ),
1800
1801 // Mouse events
1802 #define EVT_LEFT_DOWN(func) wxEventTableEntry( wxEVT_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1803 #define EVT_LEFT_UP(func) wxEventTableEntry( wxEVT_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1804 #define EVT_MIDDLE_DOWN(func) wxEventTableEntry( wxEVT_MIDDLE_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1805 #define EVT_MIDDLE_UP(func) wxEventTableEntry( wxEVT_MIDDLE_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1806 #define EVT_RIGHT_DOWN(func) wxEventTableEntry( wxEVT_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1807 #define EVT_RIGHT_UP(func) wxEventTableEntry( wxEVT_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1808 #define EVT_MOTION(func) wxEventTableEntry( wxEVT_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1809 #define EVT_LEFT_DCLICK(func) wxEventTableEntry( wxEVT_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1810 #define EVT_MIDDLE_DCLICK(func) wxEventTableEntry( wxEVT_MIDDLE_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1811 #define EVT_RIGHT_DCLICK(func) wxEventTableEntry( wxEVT_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1812 #define EVT_LEAVE_WINDOW(func) wxEventTableEntry( wxEVT_LEAVE_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1813 #define EVT_ENTER_WINDOW(func) wxEventTableEntry( wxEVT_ENTER_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1814
1815 // All mouse events
1816 #define EVT_MOUSE_EVENTS(func) \
1817 wxEventTableEntry( wxEVT_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1818 wxEventTableEntry( wxEVT_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1819 wxEventTableEntry( wxEVT_MIDDLE_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1820 wxEventTableEntry( wxEVT_MIDDLE_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1821 wxEventTableEntry( wxEVT_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1822 wxEventTableEntry( wxEVT_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1823 wxEventTableEntry( wxEVT_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1824 wxEventTableEntry( wxEVT_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1825 wxEventTableEntry( wxEVT_MIDDLE_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1826 wxEventTableEntry( wxEVT_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1827 wxEventTableEntry( wxEVT_ENTER_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),\
1828 wxEventTableEntry( wxEVT_LEAVE_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
1829
1830 // EVT_COMMAND
1831 #define EVT_COMMAND(id, event, fn) wxEventTableEntry( event, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1832 #define EVT_COMMAND_RANGE(id1, id2, event, fn) wxEventTableEntry( event, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1833
1834 // Scrolling from wxWindow (sent to wxScrolledWindow)
1835 #define EVT_SCROLLWIN(func) \
1836 wxEventTableEntry( wxEVT_SCROLLWIN_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1837 wxEventTableEntry( wxEVT_SCROLLWIN_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1838 wxEventTableEntry( wxEVT_SCROLLWIN_LINEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1839 wxEventTableEntry( wxEVT_SCROLLWIN_LINEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1840 wxEventTableEntry( wxEVT_SCROLLWIN_PAGEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1841 wxEventTableEntry( wxEVT_SCROLLWIN_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1842 wxEventTableEntry( wxEVT_SCROLLWIN_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),\
1843 wxEventTableEntry( wxEVT_SCROLLWIN_THUMBRELEASE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1844
1845 #define EVT_SCROLLWIN_TOP(func) wxEventTableEntry( wxEVT_SCROLLWIN_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1846 #define EVT_SCROLLWIN_BOTTOM(func) wxEventTableEntry( wxEVT_SCROLLWIN_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1847 #define EVT_SCROLLWIN_LINEUP(func) wxEventTableEntry( wxEVT_SCROLLWIN_LINEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1848 #define EVT_SCROLLWIN_LINEDOWN(func) wxEventTableEntry( wxEVT_SCROLLWIN_LINEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1849 #define EVT_SCROLLWIN_PAGEUP(func) wxEventTableEntry( wxEVT_SCROLLWIN_PAGEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1850 #define EVT_SCROLLWIN_PAGEDOWN(func) wxEventTableEntry( wxEVT_SCROLLWIN_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1851 #define EVT_SCROLLWIN_THUMBTRACK(func) wxEventTableEntry( wxEVT_SCROLLWIN_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1852 #define EVT_SCROLLWIN_THUMBRELEASE(func) wxEventTableEntry( wxEVT_SCROLLWIN_THUMBRELEASE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL ),
1853
1854 // Scrolling from wxSlider and wxScrollBar
1855 #define EVT_SCROLL(func) \
1856 wxEventTableEntry( wxEVT_SCROLL_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1857 wxEventTableEntry( wxEVT_SCROLL_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1858 wxEventTableEntry( wxEVT_SCROLL_LINEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1859 wxEventTableEntry( wxEVT_SCROLL_LINEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1860 wxEventTableEntry( wxEVT_SCROLL_PAGEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1861 wxEventTableEntry( wxEVT_SCROLL_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1862 wxEventTableEntry( wxEVT_SCROLL_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1863 wxEventTableEntry( wxEVT_SCROLL_THUMBRELEASE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1864
1865 #define EVT_SCROLL_TOP(func) wxEventTableEntry( wxEVT_SCROLL_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1866 #define EVT_SCROLL_BOTTOM(func) wxEventTableEntry( wxEVT_SCROLL_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1867 #define EVT_SCROLL_LINEUP(func) wxEventTableEntry( wxEVT_SCROLL_LINEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1868 #define EVT_SCROLL_LINEDOWN(func) wxEventTableEntry( wxEVT_SCROLL_LINEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1869 #define EVT_SCROLL_PAGEUP(func) wxEventTableEntry( wxEVT_SCROLL_PAGEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1870 #define EVT_SCROLL_PAGEDOWN(func) wxEventTableEntry( wxEVT_SCROLL_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1871 #define EVT_SCROLL_THUMBTRACK(func) wxEventTableEntry( wxEVT_SCROLL_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1872 #define EVT_SCROLL_THUMBRELEASE(func) wxEventTableEntry( wxEVT_SCROLL_THUMBRELEASE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1873
1874 // Scrolling from wxSlider and wxScrollBar, with an id
1875 #define EVT_COMMAND_SCROLL(id, func) \
1876 wxEventTableEntry( wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1877 wxEventTableEntry( wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1878 wxEventTableEntry( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1879 wxEventTableEntry( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1880 wxEventTableEntry( wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1881 wxEventTableEntry( wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1882 wxEventTableEntry( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),\
1883 wxEventTableEntry( wxEVT_SCROLL_THUMBRELEASE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1884
1885 #define EVT_COMMAND_SCROLL_TOP(id, func) wxEventTableEntry( wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1886 #define EVT_COMMAND_SCROLL_BOTTOM(id, func) wxEventTableEntry( wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1887 #define EVT_COMMAND_SCROLL_LINEUP(id, func) wxEventTableEntry( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1888 #define EVT_COMMAND_SCROLL_LINEDOWN(id, func) wxEventTableEntry( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1889 #define EVT_COMMAND_SCROLL_PAGEUP(id, func) wxEventTableEntry( wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1890 #define EVT_COMMAND_SCROLL_PAGEDOWN(id, func) wxEventTableEntry( wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1891 #define EVT_COMMAND_SCROLL_THUMBTRACK(id, func) wxEventTableEntry( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1892 #define EVT_COMMAND_SCROLL_THUMBRELEASE(id, func) wxEventTableEntry( wxEVT_SCROLL_THUMBRELEASE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL ),
1893
1894 // Convenience macros for commonly-used commands
1895 #define EVT_BUTTON(id, fn) wxEventTableEntry( wxEVT_COMMAND_BUTTON_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1896 #define EVT_CHECKBOX(id, fn) wxEventTableEntry( wxEVT_COMMAND_CHECKBOX_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1897 #define EVT_CHOICE(id, fn) wxEventTableEntry( wxEVT_COMMAND_CHOICE_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1898 #define EVT_LISTBOX(id, fn) wxEventTableEntry( wxEVT_COMMAND_LISTBOX_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1899 #define EVT_LISTBOX_DCLICK(id, fn) wxEventTableEntry( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1900 #define EVT_TEXT(id, fn) wxEventTableEntry( wxEVT_COMMAND_TEXT_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1901 #define EVT_TEXT_ENTER(id, fn) wxEventTableEntry( wxEVT_COMMAND_TEXT_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1902 #define EVT_MENU(id, fn) wxEventTableEntry( wxEVT_COMMAND_MENU_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1903 #define EVT_MENU_RANGE(id1, id2, fn) wxEventTableEntry( wxEVT_COMMAND_MENU_SELECTED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1904 #define EVT_SLIDER(id, fn) wxEventTableEntry( wxEVT_COMMAND_SLIDER_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1905 #define EVT_RADIOBOX(id, fn) wxEventTableEntry( wxEVT_COMMAND_RADIOBOX_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1906 #define EVT_RADIOBUTTON(id, fn) wxEventTableEntry( wxEVT_COMMAND_RADIOBUTTON_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1907 // EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events
1908 #define EVT_SCROLLBAR(id, fn) wxEventTableEntry( wxEVT_COMMAND_SCROLLBAR_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1909 #define EVT_VLBOX(id, fn) wxEventTableEntry( wxEVT_COMMAND_VLBOX_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1910 #define EVT_COMBOBOX(id, fn) wxEventTableEntry( wxEVT_COMMAND_COMBOBOX_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1911 #define EVT_TOOL(id, fn) wxEventTableEntry( wxEVT_COMMAND_TOOL_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1912 #define EVT_TOOL_RANGE(id1, id2, fn) wxEventTableEntry( wxEVT_COMMAND_TOOL_CLICKED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1913 #define EVT_TOOL_RCLICKED(id, fn) wxEventTableEntry( wxEVT_COMMAND_TOOL_RCLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1914 #define EVT_TOOL_RCLICKED_RANGE(id1, id2, fn) wxEventTableEntry( wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1915 #define EVT_TOOL_ENTER(id, fn) wxEventTableEntry( wxEVT_COMMAND_TOOL_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1916 #define EVT_CHECKLISTBOX(id, fn) wxEventTableEntry( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1917
1918 // Generic command events
1919 #define EVT_COMMAND_LEFT_CLICK(id, fn) wxEventTableEntry( wxEVT_COMMAND_LEFT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1920 #define EVT_COMMAND_LEFT_DCLICK(id, fn) wxEventTableEntry( wxEVT_COMMAND_LEFT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1921 #define EVT_COMMAND_RIGHT_CLICK(id, fn) wxEventTableEntry( wxEVT_COMMAND_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1922 #define EVT_COMMAND_RIGHT_DCLICK(id, fn) wxEventTableEntry( wxEVT_COMMAND_RIGHT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1923 #define EVT_COMMAND_SET_FOCUS(id, fn) wxEventTableEntry( wxEVT_COMMAND_SET_FOCUS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1924 #define EVT_COMMAND_KILL_FOCUS(id, fn) wxEventTableEntry( wxEVT_COMMAND_KILL_FOCUS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1925 #define EVT_COMMAND_ENTER(id, fn) wxEventTableEntry( wxEVT_COMMAND_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
1926
1927 // Joystick events
1928 #define EVT_JOY_DOWN(func) \
1929 wxEventTableEntry( wxEVT_JOY_BUTTON_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),
1930 #define EVT_JOY_UP(func) \
1931 wxEventTableEntry( wxEVT_JOY_BUTTON_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),
1932 #define EVT_JOY_MOVE(func) \
1933 wxEventTableEntry( wxEVT_JOY_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),
1934 #define EVT_JOY_ZMOVE(func) \
1935 wxEventTableEntry( wxEVT_JOY_ZMOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),
1936
1937 // All joystick events
1938 #define EVT_JOYSTICK_EVENTS(func) \
1939 wxEventTableEntry( wxEVT_JOY_BUTTON_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),\
1940 wxEventTableEntry( wxEVT_JOY_BUTTON_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),\
1941 wxEventTableEntry( wxEVT_JOY_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),\
1942 wxEventTableEntry( wxEVT_JOY_ZMOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL ),
1943
1944 // Idle event
1945 #define EVT_IDLE(func) \
1946 wxEventTableEntry( wxEVT_IDLE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIdleEventFunction) & func, (wxObject *) NULL ),
1947
1948 // Update UI event
1949 #define EVT_UPDATE_UI(id, func) \
1950 wxEventTableEntry( wxEVT_UPDATE_UI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxUpdateUIEventFunction) & func, (wxObject *) NULL ),
1951 #define EVT_UPDATE_UI_RANGE(id1, id2, func) \
1952 wxEventTableEntry( wxEVT_UPDATE_UI, id1, id2, (wxObjectEventFunction)(wxEventFunction)(wxUpdateUIEventFunction)&func, (wxObject *) NULL ),
1953
1954 // Help events
1955 #define EVT_HELP(id, func) \
1956 wxEventTableEntry( wxEVT_HELP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL ),
1957
1958 #define EVT_HELP_RANGE(id1, id2, func) \
1959 wxEventTableEntry( wxEVT_HELP, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL ),
1960
1961 #define EVT_DETAILED_HELP(id, func) \
1962 wxEventTableEntry( wxEVT_DETAILED_HELP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL ),
1963
1964 #define EVT_DETAILED_HELP_RANGE(id1, id2, func) \
1965 wxEventTableEntry( wxEVT_DETAILED_HELP, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL ),
1966
1967 // ----------------------------------------------------------------------------
1968 // Global data
1969 // ----------------------------------------------------------------------------
1970
1971 // for pending event processing - notice that there is intentionally no
1972 // WXDLLEXPORT here
1973 extern wxList *wxPendingEvents;
1974 #if wxUSE_THREADS
1975 extern wxCriticalSection *wxPendingEventsLocker;
1976 #endif
1977
1978 // ----------------------------------------------------------------------------
1979 // Helper functions
1980 // ----------------------------------------------------------------------------
1981
1982 #if wxUSE_GUI
1983
1984 // Find a window with the focus, that is also a descendant of the given window.
1985 // This is used to determine the window to initially send commands to.
1986 wxWindow* wxFindFocusDescendant(wxWindow* ancestor);
1987
1988 #endif // wxUSE_GUI
1989
1990 #endif
1991 // _WX_EVENTH__