#endif
#include "wx/dynarray.h"
+#include "wx/thread.h"
+#include "wx/tracker.h"
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_BASE wxList;
-#if wxUSE_THREADS
- class WXDLLIMPEXP_FWD_BASE wxCriticalSection;
-#endif
#if wxUSE_GUI
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxMenu;
#endif // wxUSE_GUI
class WXDLLIMPEXP_FWD_BASE wxEvtHandler;
+class wxEventConnectionRef;
// ----------------------------------------------------------------------------
// Event types
#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
wxEventTableEntry(type, winid, idLast, fn, obj)
+// obsolete event declaration/definition macros, we don't need them any longer
+// but we keep them for compatibility as it doesn't cost us anything anyhow
#define BEGIN_DECLARE_EVENT_TYPES()
#define END_DECLARE_EVENT_TYPES()
#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
// generate a new unique event type
extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();
-BEGIN_DECLARE_EVENT_TYPES()
- // it is important to still have these as constants to avoid
- // initialization order related problems
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_NULL, 0)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_FIRST, 10000)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_USER_FIRST, wxEVT_FIRST + 2000)
-
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED, 1)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKBOX_CLICKED, 2)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHOICE_SELECTED, 3)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED, 4)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 5)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 6)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED, 9)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED, 10)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED, 11)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBUTTON_SELECTED, 12)
-
- // wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use
- // wxEVT_SCROLL... events
-
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_SCROLLBAR_UPDATED, 13)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_VLBOX_SELECTED, 14)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_COMBOBOX_SELECTED, 15)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_RCLICKED, 16)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER, 17)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED, 18)
-
- // Toolbar dropdown arrows
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, 19)
-
- // Sockets and timers send events, too
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_SOCKET, 50)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_TIMER , 80)
-
- // Mouse event types
- DECLARE_EVENT_TYPE(wxEVT_LEFT_DOWN, 100)
- DECLARE_EVENT_TYPE(wxEVT_LEFT_UP, 101)
- DECLARE_EVENT_TYPE(wxEVT_MIDDLE_DOWN, 102)
- DECLARE_EVENT_TYPE(wxEVT_MIDDLE_UP, 103)
- DECLARE_EVENT_TYPE(wxEVT_RIGHT_DOWN, 104)
- DECLARE_EVENT_TYPE(wxEVT_RIGHT_UP, 105)
- DECLARE_EVENT_TYPE(wxEVT_MOTION, 106)
- DECLARE_EVENT_TYPE(wxEVT_ENTER_WINDOW, 107)
- DECLARE_EVENT_TYPE(wxEVT_LEAVE_WINDOW, 108)
- DECLARE_EVENT_TYPE(wxEVT_LEFT_DCLICK, 109)
- DECLARE_EVENT_TYPE(wxEVT_MIDDLE_DCLICK, 110)
- DECLARE_EVENT_TYPE(wxEVT_RIGHT_DCLICK, 111)
- DECLARE_EVENT_TYPE(wxEVT_SET_FOCUS, 112)
- DECLARE_EVENT_TYPE(wxEVT_KILL_FOCUS, 113)
- DECLARE_EVENT_TYPE(wxEVT_CHILD_FOCUS, 114)
- DECLARE_EVENT_TYPE(wxEVT_MOUSEWHEEL, 115)
- DECLARE_EVENT_TYPE(wxEVT_AUX1_DOWN, 116)
- DECLARE_EVENT_TYPE(wxEVT_AUX1_UP, 117)
- DECLARE_EVENT_TYPE(wxEVT_AUX1_DCLICK, 118)
- DECLARE_EVENT_TYPE(wxEVT_AUX2_DOWN, 119)
- DECLARE_EVENT_TYPE(wxEVT_AUX2_UP, 120)
- DECLARE_EVENT_TYPE(wxEVT_AUX2_DCLICK, 121)
-
- // Non-client mouse events
- DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN, 200)
- DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_UP, 201)
- DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_DOWN, 202)
- DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_UP, 203)
- DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_DOWN, 204)
- DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_UP, 205)
- DECLARE_EVENT_TYPE(wxEVT_NC_MOTION, 206)
- DECLARE_EVENT_TYPE(wxEVT_NC_ENTER_WINDOW, 207)
- DECLARE_EVENT_TYPE(wxEVT_NC_LEAVE_WINDOW, 208)
- DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DCLICK, 209)
- DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_DCLICK, 210)
- DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_DCLICK, 211)
-
- // Character input event type
- DECLARE_EVENT_TYPE(wxEVT_CHAR, 212)
- DECLARE_EVENT_TYPE(wxEVT_CHAR_HOOK, 213)
- DECLARE_EVENT_TYPE(wxEVT_NAVIGATION_KEY, 214)
- DECLARE_EVENT_TYPE(wxEVT_KEY_DOWN, 215)
- DECLARE_EVENT_TYPE(wxEVT_KEY_UP, 216)
+// many, but not all, standard event types
+
+ // some generic events
+extern WXDLLIMPEXP_BASE const wxEventType wxEVT_NULL;
+extern WXDLLIMPEXP_BASE const wxEventType wxEVT_FIRST;
+extern WXDLLIMPEXP_BASE const wxEventType wxEVT_USER_FIRST;
+
+ // Command events
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_BUTTON_CLICKED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICE_SELECTED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOX_SELECTED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_MENU_SELECTED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_SLIDER_UPDATED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED;
+
+// wxEVT_COMMAND_SCROLLBAR_UPDATED is deprecated, use wxEVT_SCROLL... events
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_VLBOX_SELECTED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOL_RCLICKED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOL_ENTER;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED;
+
+ // Sockets and timers send events, too
+extern WXDLLIMPEXP_BASE const wxEventType wxEVT_SOCKET;
+extern WXDLLIMPEXP_BASE const wxEventType wxEVT_TIMER;
+
+ // Mouse event types
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_LEFT_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_LEFT_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MIDDLE_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MIDDLE_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_RIGHT_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_RIGHT_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOTION;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_ENTER_WINDOW;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_LEAVE_WINDOW;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_LEFT_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MIDDLE_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_RIGHT_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SET_FOCUS;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_KILL_FOCUS;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_CHILD_FOCUS;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOUSEWHEEL;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_AUX1_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_AUX1_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_AUX1_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_AUX2_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_AUX2_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_AUX2_DCLICK;
+
+ // Non-client mouse events
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_LEFT_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_LEFT_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_MIDDLE_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_MIDDLE_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_RIGHT_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_RIGHT_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_MOTION;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_ENTER_WINDOW;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_LEAVE_WINDOW;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_LEFT_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_MIDDLE_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_RIGHT_DCLICK;
+
+ // Character input event type
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_CHAR;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_CHAR_HOOK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NAVIGATION_KEY;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_KEY_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_KEY_UP;
#if wxUSE_HOTKEY
- DECLARE_EVENT_TYPE(wxEVT_HOTKEY, 217)
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_HOTKEY;
#endif
- // Set cursor event
- DECLARE_EVENT_TYPE(wxEVT_SET_CURSOR, 230)
-
- // wxScrollBar and wxSlider event identifiers
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_TOP, 300)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_BOTTOM, 301)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_LINEUP, 302)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_LINEDOWN, 303)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP, 304)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN, 305)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK, 306)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE, 307)
- DECLARE_EVENT_TYPE(wxEVT_SCROLL_CHANGED, 308)
-
- // Scroll events from wxWindow
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP, 320)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_BOTTOM, 321)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEUP, 322)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEDOWN, 323)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEUP, 324)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEDOWN, 325)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBTRACK, 326)
- DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBRELEASE, 327)
-
- // System events
- DECLARE_EVENT_TYPE(wxEVT_SIZE, 400)
- DECLARE_EVENT_TYPE(wxEVT_MOVE, 401)
- DECLARE_EVENT_TYPE(wxEVT_CLOSE_WINDOW, 402)
- DECLARE_EVENT_TYPE(wxEVT_END_SESSION, 403)
- DECLARE_EVENT_TYPE(wxEVT_QUERY_END_SESSION, 404)
- DECLARE_EVENT_TYPE(wxEVT_ACTIVATE_APP, 405)
- // 406..408 are power events
- DECLARE_EVENT_TYPE(wxEVT_ACTIVATE, 409)
- DECLARE_EVENT_TYPE(wxEVT_CREATE, 410)
- DECLARE_EVENT_TYPE(wxEVT_DESTROY, 411)
- DECLARE_EVENT_TYPE(wxEVT_SHOW, 412)
- DECLARE_EVENT_TYPE(wxEVT_ICONIZE, 413)
- DECLARE_EVENT_TYPE(wxEVT_MAXIMIZE, 414)
- DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED, 415)
- DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_LOST, 416)
- DECLARE_EVENT_TYPE(wxEVT_PAINT, 417)
- DECLARE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND, 418)
- DECLARE_EVENT_TYPE(wxEVT_NC_PAINT, 419)
- DECLARE_EVENT_TYPE(wxEVT_PAINT_ICON, 420)
- DECLARE_EVENT_TYPE(wxEVT_MENU_OPEN, 421)
- DECLARE_EVENT_TYPE(wxEVT_MENU_CLOSE, 422)
- DECLARE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT, 423)
- DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424)
- DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425)
- DECLARE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED, 426)
- DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 427)
- DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 428)
- DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 429)
- DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 430)
- DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 431)
- DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 432)
- DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 433)
- DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 434)
- DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 435)
- DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 436)
- DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 437)
- DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_IDLE, 439)
- DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440)
- DECLARE_EVENT_TYPE(wxEVT_SIZING, 441)
- DECLARE_EVENT_TYPE(wxEVT_MOVING, 442)
- DECLARE_EVENT_TYPE(wxEVT_MOVE_START, 443)
- DECLARE_EVENT_TYPE(wxEVT_MOVE_END, 444)
- DECLARE_EVENT_TYPE(wxEVT_HIBERNATE, 445)
- // more power events follow -- see wx/power.h
-
- // Clipboard events
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY, 446)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT, 447)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE, 448)
-
- // Generic command events
- // Note: a click is a higher-level event than button down/up
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_LEFT_CLICK, 500)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_LEFT_DCLICK, 501)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_CLICK, 502)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_DCLICK, 503)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_SET_FOCUS, 504)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_KILL_FOCUS, 505)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_ENTER, 506)
-
- // Help events
- DECLARE_EVENT_TYPE(wxEVT_HELP, 1050)
- DECLARE_EVENT_TYPE(wxEVT_DETAILED_HELP, 1051)
-
-END_DECLARE_EVENT_TYPES()
+ // Set cursor event
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SET_CURSOR;
+
+ // wxScrollBar and wxSlider event identifiers
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_TOP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_BOTTOM;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_LINEUP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_LINEDOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_PAGEUP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_PAGEDOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_THUMBTRACK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_THUMBRELEASE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_CHANGED;
+
+ // Scroll events from wxWindow
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_TOP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_BOTTOM;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_LINEUP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_LINEDOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_PAGEUP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_PAGEDOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_THUMBTRACK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLLWIN_THUMBRELEASE;
+
+ // System events
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SIZE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOVE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_CLOSE_WINDOW;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_END_SESSION;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_QUERY_END_SESSION;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_ACTIVATE_APP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_ACTIVATE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_CREATE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DESTROY;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SHOW;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_ICONIZE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MAXIMIZE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOUSE_CAPTURE_LOST;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_PAINT;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_ERASE_BACKGROUND;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_NC_PAINT;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_PAINT_ICON;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MENU_OPEN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MENU_CLOSE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MENU_HIGHLIGHT;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_CONTEXT_MENU;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SYS_COLOUR_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DISPLAY_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SETTING_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_QUERY_NEW_PALETTE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_PALETTE_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_JOY_BUTTON_DOWN;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_JOY_BUTTON_UP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_JOY_MOVE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_JOY_ZMOVE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DROP_FILES;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DRAW_ITEM;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MEASURE_ITEM;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMPARE_ITEM;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_INIT_DIALOG;
+extern WXDLLIMPEXP_BASE const wxEventType wxEVT_IDLE;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_UPDATE_UI;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SIZING;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOVING;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOVE_START;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_MOVE_END;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_HIBERNATE;
+
+ // Clipboard events
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TEXT_COPY;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TEXT_CUT;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TEXT_PASTE;
+
+ // Generic command events
+ // Note: a click is a higher-level event than button down/up
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LEFT_CLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LEFT_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_RIGHT_CLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_RIGHT_DCLICK;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_SET_FOCUS;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_KILL_FOCUS;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_ENTER;
+
+ // Help events
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_HELP;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DETAILED_HELP;
// these 2 events are the same
#define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED
virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
- wxMouseEvent& operator=(const wxMouseEvent& event) { Assign(event); return *this; }
+ wxMouseEvent& operator=(const wxMouseEvent& event) { if (&event != this) Assign(event); return *this; }
public:
wxCoord m_x, m_y;
// example)
wxKeyEvent& operator=(const wxKeyEvent& evt)
{
- m_x = evt.m_x;
- m_y = evt.m_y;
-
- m_keyCode = evt.m_keyCode;
-
- m_controlDown = evt.m_controlDown;
- m_shiftDown = evt.m_shiftDown;
- m_altDown = evt.m_altDown;
- m_metaDown = evt.m_metaDown;
- m_scanCode = evt.m_scanCode;
- m_rawCode = evt.m_rawCode;
- m_rawFlags = evt.m_rawFlags;
+ if (&evt != this)
+ {
+ m_x = evt.m_x;
+ m_y = evt.m_y;
+
+ m_keyCode = evt.m_keyCode;
+
+ m_controlDown = evt.m_controlDown;
+ m_shiftDown = evt.m_shiftDown;
+ m_altDown = evt.m_altDown;
+ m_metaDown = evt.m_metaDown;
+ m_scanCode = evt.m_scanCode;
+ m_rawCode = evt.m_rawCode;
+ m_rawFlags = evt.m_rawFlags;
#if wxUSE_UNICODE
- m_uniChar = evt.m_uniChar;
+ m_uniChar = evt.m_uniChar;
#endif
-
+ }
return *this;
}
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
+#if wxUSE_WEAKREF
+ , public wxTrackable
+#endif
{
public:
wxEvtHandler();
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
bool SearchDynamicEventTable( wxEvent& event );
-#if wxUSE_THREADS
- void ClearEventLocker();
-#endif // wxUSE_THREADS
-
// Avoid problems at exit by cleaning up static hash table gracefully
void ClearEventHashTable() { GetEventHashTable().Clear(); }
+#if wxUSE_WEAKREF
+ void OnSinkDestroyed( wxEvtHandler *sink );
+#endif
private:
static const wxEventTableEntry sm_eventTableEntries[];
wxList* m_pendingEvents;
#if wxUSE_THREADS
-#if defined (__VISAGECPP__)
- const wxCriticalSection& Lock() const { return m_eventsLocker; }
- wxCriticalSection& Lock() { return m_eventsLocker; }
-
- wxCriticalSection m_eventsLocker;
-# else
- const wxCriticalSection& Lock() const { return *m_eventsLocker; }
- wxCriticalSection& Lock() { return *m_eventsLocker; }
-
- wxCriticalSection* m_eventsLocker;
-# endif
-#endif
+ // critical section protecting m_pendingEvents
+ wxCriticalSection m_pendingEventsLock;
+#endif // wxUSE_THREADS
// Is event handler enabled?
bool m_enabled;
virtual void DoSetClientData( void *data );
virtual void *DoGetClientData() const;
+#if wxUSE_WEAKREF
+ // Search tracker objects for event connection with this sink
+ wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *eventSink);
+#endif
+
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler)
};
+#if wxUSE_WEAKREF
+// ----------------------------------------------------------------------------
+// wxEventConnectionRef represents all connections between two event handlers
+// and enables automatic disconnect when an event handler sink goes out of
+// scope. Each connection/disconnect increases/decreases ref count, and
+// when it reaches zero the node goes out of scope.
+// ----------------------------------------------------------------------------
+
+class wxEventConnectionRef : public wxTrackerNode
+{
+public:
+ wxEventConnectionRef() : m_src(NULL), m_sink(NULL), m_refCount(0) { }
+ wxEventConnectionRef(wxEvtHandler *src, wxEvtHandler *sink)
+ : m_src(src), m_sink(sink), m_refCount(1)
+ {
+ m_sink->AddNode(this);
+ }
+
+ // The sink is being destroyed
+ virtual void OnObjectDestroy( )
+ {
+ if ( m_src )
+ m_src->OnSinkDestroyed( m_sink );
+ delete this;
+ }
+
+ virtual wxEventConnectionRef *ToEventConnection() { return this; }
+
+ void IncRef() { m_refCount++; }
+ void DecRef()
+ {
+ if ( !--m_refCount )
+ {
+ // The sink holds the only external pointer to this object
+ if ( m_sink )
+ m_sink->RemoveNode(this);
+ delete this;
+ }
+ }
+
+private:
+ wxEvtHandler *m_src,
+ *m_sink;
+ int m_refCount;
+
+ friend class wxEvtHandler;
+
+ DECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef)
+};
+#endif // wxUSE_WEAKREF
+
// Post a message to the given eventhandler which will be processed during the
// next event loop iteration
inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event)
}
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
+typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
#define wxEventHandler(func) \
(wxObjectEventFunction)wxStaticCastEvent(wxEventFunction, &func)
+#define wxIdleEventHandler(func) \
+ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIdleEventFunction, &func)
#if wxUSE_GUI
typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&);
typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&);
typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&);
-typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&);
typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&);
typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&);
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDisplayChangedEventFunction, &func)
#define wxUpdateUIEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxUpdateUIEventFunction, &func)
-#define wxIdleEventHandler(func) \
- (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIdleEventFunction, &func)
#define wxCloseEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCloseEventFunction, &func)
#define wxShowEventHandler(func) \
// Global data
// ----------------------------------------------------------------------------
-// for pending event processing - notice that there is intentionally no
-// WXDLLEXPORT here
+// list containing event handlers with pending events for them
+//
+// notice that each event handler should occur at most once in this list
extern WXDLLIMPEXP_BASE wxList *wxPendingEvents;
#if wxUSE_THREADS
extern WXDLLIMPEXP_BASE wxCriticalSection *wxPendingEventsLocker;