X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1afe8c83072c52d957db8a9877ca28011258ecac..306f34a3681b0d8d87ac5fb3dfd76817f4a8ba7c:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 4ebbb27f5b..7af59c38d7 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -106,62 +106,58 @@ extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); // Define/Declare a wxEventType-based event type: #define wxDEFINE_EVENT( name, type ) \ - const wxEventType name( wxNewEventType() ); + const wxEventType name( wxNewEventType() ) #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \ - extern const expdecl wxEventType name; + extern const expdecl wxEventType name // Define/Declare a wxEventType-based event type and initialize it with a // predefined event type. (Only used for wxEVT_SPIN_XXX for backward // compatibility) #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ - const wxEventType name = value; + const wxEventType name = value #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ - extern const expdecl wxEventType name; + extern const expdecl wxEventType name // Declare a local (not exported) wxEventType-based event type: - #define wxDECLARE__EVENT( name, type ) \ - wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) + #define wxDECLARE_EVENT( name, type ) \ + wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ); - // Try to cast the given event handler to the correct handler type: - - #define wxEVENT_HANDLER_CAST( functype, func ) \ - ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func ) #else // Define/Declare a templatized event type with the corresponding event as // a nested typedef: #define wxDEFINE_EVENT( name, type ) \ - const wxEventTypeTag< type > name( wxNewEventType() ); + const wxEventTypeTag< type > name( wxNewEventType() ) #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \ - extern const expdecl wxEventTypeTag< type > name; + extern const expdecl wxEventTypeTag< type > name // Define/Declare a templatized event type and initialize it with a // predefined event type. (Only used for wxEVT_SPIN_XXX for backward // compatibility) #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ - const wxEventTypeTag< type > name( value ); + const wxEventTypeTag< type > name( value ) #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ - extern const expdecl wxEventTypeTag< type > name; + extern const expdecl wxEventTypeTag< type > name // Declare a local (not exported) templatized event type: - #define wxDECLARE__EVENT( name, type ) \ - wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) - - // Don't cast the given event handler so that wxEvtHandler::Connect() sees - // the actual type: + #define wxDECLARE_EVENT( name, type ) \ + wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ); - #define wxEVENT_HANDLER_CAST( functype, func ) \ - ( &func ) #endif +// Try to cast the given event handler to the correct handler type: + +#define wxEVENT_HANDLER_CAST( functype, func ) \ + ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func ) + // Template which associates the correct event object with the event type #if !wxEVENTS_COMPATIBILITY_2_8 @@ -237,12 +233,7 @@ public: m_method = method; } - virtual void operator()(wxEvtHandler *handler, wxEvent& event) - { - wxEvtHandler * const realHandler = m_handler ? m_handler : handler; - - (realHandler->*m_method)(event); - } + virtual void operator()(wxEvtHandler *handler, wxEvent& event); virtual bool Matches(const wxEventFunctor& func) const { @@ -397,7 +388,7 @@ class wxEventFunctorMethod < Class, EventArg, - wxConvertibleTo::value + wxConvertibleTo::value != 0 > { private: @@ -589,74 +580,74 @@ class WXDLLIMPEXP_FWD_CORE wxHelpEvent; // Command events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SLIDER_UPDATED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SLIDER_UPDATED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEvent); // wxEVT_COMMAND_SCROLLBAR_UPDATED is deprecated, use wxEVT_SCROLL... events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SCROLLBAR_UPDATED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_VLBOX_SELECTED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_RCLICKED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SCROLLBAR_UPDATED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_VLBOX_SELECTED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_RCLICKED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent); // Thread events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_THREAD, wxThreadEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_THREAD, wxThreadEvent); // Mouse event types -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DOWN, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_UP, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DOWN, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_UP, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DOWN, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_UP, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOTION, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ENTER_WINDOW, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEAVE_WINDOW, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DCLICK, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DCLICK, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DCLICK, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_FOCUS, wxFocusEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KILL_FOCUS, wxFocusEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHILD_FOCUS, wxChildFocusEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSEWHEEL, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DOWN, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_UP, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DOWN, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_UP, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DOWN, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_UP, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DOWN, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_UP, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOTION, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ENTER_WINDOW, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEAVE_WINDOW, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DCLICK, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DCLICK, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DCLICK, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_FOCUS, wxFocusEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KILL_FOCUS, wxFocusEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHILD_FOCUS, wxChildFocusEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSEWHEEL, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DOWN, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_UP, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent); // Character input event type -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR_HOOK, wxKeyEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_DOWN, wxKeyEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR_HOOK, wxKeyEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_DOWN, wxKeyEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent); #if wxUSE_HOTKEY -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent); #endif // Set cursor event -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent); // wxScrollBar and wxSlider event identifiers -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_TOP, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_BOTTOM, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEUP, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEDOWN, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEUP, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEDOWN, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBTRACK, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBRELEASE, wxScrollEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_TOP, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_BOTTOM, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEUP, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEDOWN, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEUP, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEDOWN, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBTRACK, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBRELEASE, wxScrollEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent); // Due to a bug in older wx versions, wxSpinEvents were being sent with type of // wxEVT_SCROLL_LINEUP, wxEVT_SCROLL_LINEDOWN and wxEVT_SCROLL_THUMBTRACK. But @@ -667,80 +658,80 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent) #if wxUSE_SPINBTN -wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent ) -wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent ) -wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent ) +wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent ); +wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent ); +wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent ); #endif // Scroll events from wxWindow -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_TOP, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEUP, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_TOP, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEUP, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEvent); // System events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZE, wxSizeEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE, wxMoveEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CLOSE_WINDOW, wxCloseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_END_SESSION, wxCloseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_END_SESSION, wxCloseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE_APP, wxActivateEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE, wxActivateEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CREATE, wxWindowCreateEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DESTROY, wxWindowDestroyEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SHOW, wxShowEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ICONIZE, wxIconizeEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAXIMIZE, wxMaximizeEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PAINT, wxPaintEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ERASE_BACKGROUND, wxEraseEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NC_PAINT, wxNcPaintEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_OPEN, wxMenuEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_CLOSE, wxMenuEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_HIGHLIGHT, wxMenuEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CONTEXT_MENU, wxContextMenuEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DISPLAY_CHANGED, wxDisplayChangedEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PALETTE_CHANGED, wxPaletteChangedEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_DOWN, wxJoystickEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_UP, wxJoystickEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_MOVE, wxJoystickEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_ZMOVE, wxJoystickEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DROP_FILES, wxDropFilesEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_INIT_DIALOG, wxInitDialogEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_IDLE, wxIdleEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_UPDATE_UI, wxUpdateUIEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZING, wxSizeEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVING, wxMoveEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_START, wxMoveEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_END, wxMoveEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HIBERNATE, wxActivateEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZE, wxSizeEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE, wxMoveEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CLOSE_WINDOW, wxCloseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_END_SESSION, wxCloseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_END_SESSION, wxCloseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE_APP, wxActivateEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE, wxActivateEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CREATE, wxWindowCreateEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DESTROY, wxWindowDestroyEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SHOW, wxShowEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ICONIZE, wxIconizeEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAXIMIZE, wxMaximizeEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PAINT, wxPaintEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ERASE_BACKGROUND, wxEraseEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NC_PAINT, wxNcPaintEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_OPEN, wxMenuEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_CLOSE, wxMenuEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_HIGHLIGHT, wxMenuEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CONTEXT_MENU, wxContextMenuEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DISPLAY_CHANGED, wxDisplayChangedEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PALETTE_CHANGED, wxPaletteChangedEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_DOWN, wxJoystickEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_UP, wxJoystickEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_MOVE, wxJoystickEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_ZMOVE, wxJoystickEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DROP_FILES, wxDropFilesEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_INIT_DIALOG, wxInitDialogEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_IDLE, wxIdleEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_UPDATE_UI, wxUpdateUIEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZING, wxSizeEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVING, wxMoveEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_START, wxMoveEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_END, wxMoveEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HIBERNATE, wxActivateEvent); // Clipboard events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_COPY, wxClipboardTextEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_CUT, wxClipboardTextEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_PASTE, wxClipboardTextEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_COPY, wxClipboardTextEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_CUT, wxClipboardTextEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_PASTE, wxClipboardTextEvent); // Generic command events // Note: a click is a higher-level event than button down/up -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_CLICK, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_DCLICK, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_DCLICK, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SET_FOCUS, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_KILL_FOCUS, wxCommandEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_ENTER, wxCommandEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_CLICK, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_DCLICK, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_DCLICK, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SET_FOCUS, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_KILL_FOCUS, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_ENTER, wxCommandEvent); // Help events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HELP, wxHelpEvent) -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HELP, wxHelpEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent); // these 2 events are the same #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED @@ -753,7 +744,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent) // wx/textctrl.h in all ports [yet], so declare it here as well // // still, any new code using it should include wx/textctrl.h explicitly -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent); // ---------------------------------------------------------------------------- @@ -772,7 +763,7 @@ enum wxEventPropagation }; // The different categories for a wxEvent; see wxEvent::GetEventCategory. -// NOTE: they are used as OR-combinable flags by wxApp::Yield +// NOTE: they are used as OR-combinable flags by wxEventLoopBase::YieldFor enum wxEventCategory { // this is the category for those events which are generated to update @@ -802,10 +793,10 @@ enum wxEventCategory // implementation only - // used in the implementations of DoYield() + // used in the implementations of wxEventLoopBase::YieldFor wxEVT_CATEGORY_UNKNOWN = 32, - // a special category used as an argument to wxApp::Yield() to indicate that + // a special category used as an argument to wxEventLoopBase::YieldFor to indicate that // Yield() should leave all wxEvents on the queue while emptying the native event queue // (native events will be processed but the wxEvents they generate will be queued) wxEVT_CATEGORY_CLIPBOARD = 64, @@ -817,10 +808,11 @@ enum wxEventCategory // events of the native toolkit and which typically are not-"delayable". wxEVT_CATEGORY_NATIVE_EVENTS = wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT, - // used in wxApp::Yield to specify all event categories should be processed: + // used in wxEventLoopBase::YieldFor to specify all event categories should be processed: wxEVT_CATEGORY_ALL = wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_SOCKET| \ - wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD + wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD|wxEVT_CATEGORY_UNKNOWN| \ + wxEVT_CATEGORY_CLIPBOARD }; /* @@ -864,7 +856,7 @@ public: // for them wouldn't work (it needs to do a copy of the event) virtual wxEvent *Clone() const = 0; - // this function is used to selectively process events in wxApp::YieldFor + // this function is used to selectively process events in wxEventLoopBase::YieldFor // NOTE: by default it returns wxEVT_CATEGORY_UI just because the major // part of wxWidgets events belong to that category. virtual wxEventCategory GetEventCategory() const @@ -963,7 +955,7 @@ private: wxEvent& m_event; int m_propagationLevelOld; - DECLARE_NO_COPY_CLASS(wxPropagationDisabler) + wxDECLARE_NO_COPY_CLASS(wxPropagationDisabler); }; /* @@ -988,7 +980,7 @@ public: private: wxEvent& m_event; - DECLARE_NO_COPY_CLASS(wxPropagateOnce) + wxDECLARE_NO_COPY_CLASS(wxPropagateOnce); }; @@ -1110,6 +1102,14 @@ public: : wxCommandEvent(eventType, id) { } + wxThreadEvent(const wxThreadEvent& event) + : wxCommandEvent(event) + { + // make sure our string member (which uses COW, aka refcounting) is not + // shared by other wxString instances: + SetString(GetString().c_str()); + } + virtual wxEvent *Clone() const { wxThreadEvent* ev = new wxThreadEvent(*this); @@ -1120,7 +1120,7 @@ public: return ev; } - // this is important to avoid that calling wxApp::Yield() thread events + // this is important to avoid that calling wxEventLoopBase::YieldFor thread events // gets processed when this is unwanted: virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_THREAD; } @@ -1524,7 +1524,6 @@ public: m_keyCode = evt.m_keyCode; - m_scanCode = evt.m_scanCode; m_rawCode = evt.m_rawCode; m_rawFlags = evt.m_rawFlags; #if wxUSE_UNICODE @@ -1539,9 +1538,6 @@ public: long m_keyCode; - // FIXME: what is this for? relation to m_rawXXX? - bool m_scanCode; - #if wxUSE_UNICODE // This contains the full Unicode character // in a character events in Unicode mode @@ -2429,7 +2425,7 @@ public: virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); } - enum + enum wxNavigationKeyEventFlags { IsBackward = 0x0000, IsForward = 0x0001, @@ -2723,7 +2719,7 @@ struct WXDLLIMPEXP_BASE wxEventTableEntryBase wxObject* m_callbackUserData; private: - DECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase) + wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase); }; // an entry from a static event table @@ -2744,7 +2740,7 @@ struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase const int& m_eventType; private: - DECLARE_NO_ASSIGN_CLASS(wxEventTableEntry) + wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntry); }; // an entry used in dynamic event table managed by wxEvtHandler::Connect() @@ -2762,7 +2758,7 @@ struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase int m_eventType; private: - DECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry) + wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry); }; // ---------------------------------------------------------------------------- @@ -2835,7 +2831,7 @@ protected: wxEventHashTable* m_previous; wxEventHashTable* m_next; - DECLARE_NO_COPY_CLASS(wxEventHashTable) + wxDECLARE_NO_COPY_CLASS(wxEventHashTable); }; // ---------------------------------------------------------------------------- @@ -2869,7 +2865,6 @@ public: // Event queuing and processing // ---------------------------- - // Process an event right now: this can only be called from the main // thread, use QueueEvent() for scheduling the events for // processing from other threads. @@ -2905,9 +2900,11 @@ public: void ProcessPendingEvents(); // NOTE: uses ProcessEvent() + void DeletePendingEvents(); + #if wxUSE_THREADS bool ProcessThreadEvent(const wxEvent& event); - // NOTE: uses AddPendingEvent() + // NOTE: uses AddPendingEvent(); call only from secondary threads #endif @@ -2978,121 +2975,44 @@ public: { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); } #if !wxEVENTS_COMPATIBILITY_2_8 - // Event handling in functions (including generalized functors): - + // Bind arbitrary functor (including just a function) to an event: template - void Connect(int winid, - int lastId, - const EventTag& eventType, - Functor func) + void Bind(const EventTag& eventType, + Functor func, + int winid = wxID_ANY, + int lastId = wxID_ANY, + wxObject *userData = NULL) { DoConnect(winid, lastId, eventType, - wxNewEventFunctor(eventType, func)); - } - - template - void Connect(int winid, const EventTag& eventType, Functor func) - { Connect(winid, wxID_ANY, eventType, func); } - - template - void Connect(const EventTag& eventType, Functor func) - { Connect(wxID_ANY, eventType, func); } - - - template - bool Disconnect(int winid, - int lastId, - const EventTag& eventType, - Functor func) - { - return DoDisconnect(winid, lastId, eventType, - wxMakeEventFunctor(eventType, func)); - } - - template - bool Disconnect(int winid, const EventTag& eventType, Functor func) - { return Disconnect(winid, wxID_ANY, eventType, func); } - - template - bool Disconnect(const EventTag& eventType, Functor func) - { return Disconnect(wxID_ANY, eventType, func); } - - - - // Event handling in class methods: the object handling the event (i.e. - // this object itself by default or eventSink if specified) must be - // convertible to this class. - // - // Notice that we need to have separate overloads for the versions with and - // without eventSink because in the latter case we must check that this - // object itself derives from Class while in the former this is not - // necessarily true - - // Methods connecting/disconnecting event to this object itself - - template - void Connect(int winid, - int lastId, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL) - { - DoConnect(winid, lastId, eventType, - wxNewEventFunctor(eventType, func, static_cast(this)), + wxNewEventFunctor(eventType, func), userData); } - template - void Connect(int winid, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL) - { Connect(winid, wxID_ANY, eventType, func, userData); } - - template - void Connect(const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL) - { Connect(wxID_ANY, eventType, func, userData); } - - template - bool Disconnect(int winid, - int lastId, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL) + template + bool Unbind(const EventTag& eventType, + Functor func, + int winid = wxID_ANY, + int lastId = wxID_ANY, + wxObject *userData = NULL) { return DoDisconnect(winid, lastId, eventType, - wxMakeEventFunctor(eventType, func, - static_cast(this)), + wxMakeEventFunctor(eventType, func), userData); } - template - bool Disconnect(int winid, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL) - { return Disconnect(winid, wxID_ANY, eventType, func, userData); } - - template - bool Disconnect(const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL) - { return Disconnect(wxID_ANY, eventType, func, userData); } - - // Methods connecting/disconnecting event to another object + // Bind a method of a class (called on the specified eventSink which must + // be convertible to this class) object to an event: template - void Connect(int winid, - int lastId, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData, - ObjClass *eventSink) + void Bind(const EventTag &eventType, + void (Class::*func)(EventArg &), + ObjClass *eventSink, + int winid = wxID_ANY, + int lastId = wxID_ANY, + wxObject *userData = NULL) { DoConnect(winid, lastId, eventType, wxNewEventFunctor(eventType, func, eventSink), @@ -3101,136 +3021,19 @@ public: template - void Connect(int winid, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData, - ObjClass *eventSink) - { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); } - - template - - void Connect(const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData, - ObjClass *eventSink) - { Connect(wxID_ANY, eventType, func, userData, eventSink); } - - - template - - bool Disconnect(int winid, - int lastId, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData, - ObjClass *eventSink) + bool Unbind(const EventTag &eventType, + void (Class::*func)(EventArg&), + ObjClass *eventSink, + int winid = wxID_ANY, + int lastId = wxID_ANY, + wxObject *userData = NULL ) { return DoDisconnect(winid, lastId, eventType, wxMakeEventFunctor(eventType, func, eventSink), userData); } - - template - - bool Disconnect(int winid, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData, - ObjClass *eventSink) - { return Disconnect(winid, wxID_ANY, eventType, func, - userData, eventSink); } - - template - - bool Disconnect(const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData, - ObjClass *eventSink) - { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); } - - - - // Static version of Connect() which allows to specify the event source and - // event handler in a more symmetric way - template - static void Connect(ObjSource *eventSrc, - int winid, - int lastId, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL, - ObjClass *eventSink = NULL) - { - eventSrc->Connect(winid, lastId, eventType, func, userData, eventSink); - } - - template - static void Connect(ObjSource *eventSrc, - int winid, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL, - ObjClass *eventSink = NULL) - { - Connect(eventSrc, winid, wxID_ANY, eventType, func, userData, eventSink); - } - - template - static void Connect(ObjSource *eventSrc, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL, - ObjClass *eventSink = NULL) - { - Connect(eventSrc, wxID_ANY, eventType, func, userData, eventSink); - } - - - template - static bool Disconnect(ObjSource *eventSrc, - int winid, - int lastId, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL, - ObjClass *eventSink = NULL) - { - return eventSrc->Disconnect(winid, lastId, eventType, func, - userData, eventSink); - } - - template - static bool Disconnect(ObjSource *eventSrc, - int winid, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL, - ObjClass *eventSink = NULL) - { - return Disconnect(eventSrc, winid, wxID_ANY, eventType, func, - userData, eventSink); - } - - template - static bool Disconnect(ObjSource *eventSrc, - const EventTag& eventType, - void (Class::*func)(EventArg&), - wxObject *userData = NULL, - ObjClass *eventSink = NULL) - { - return Disconnect(eventSrc, wxID_ANY, eventType, func, - userData, eventSink); - } #endif // !wxEVENTS_COMPATIBILITY_2_8 - wxList* GetDynamicEventTable() const { return m_dynamicEvents ; } // User data can be associated with each wxEvtHandler @@ -3266,7 +3069,7 @@ public: // // It is meant to be called from ProcessEvent() only and is not virtual, // additional event handlers can be hooked into the normal event processing - // logic using TryValidator() hook. + // logic using TryBefore() and TryAfter() hooks. bool ProcessEventHere(wxEvent& event); @@ -3289,21 +3092,25 @@ protected: // hooks for wxWindow used by ProcessEvent() // ----------------------------------------- - // This one is called before trying our own event table to allow plugging - // in the validators. - // - // NB: This method is intentionally *not* inside wxUSE_VALIDATORS! - // It is part of wxBase which doesn't use validators and the code - // is compiled out when building wxBase w/o GUI classes, which affects - // binary compatibility and wxBase library can't be used by GUI - // ports. - virtual bool TryValidator(wxEvent& WXUNUSED(event)) { return false; } + // this one is called before trying our own event table to allow plugging + // in the event handlers overriding the default logic, this is used by e.g. + // validators. + virtual bool TryBefore(wxEvent& event); // this one is called after failing to find the event handle in our own // table to give a chance to the other windows to process it // // base class implementation passes the event to wxTheApp - virtual bool TryParent(wxEvent& event); + virtual bool TryAfter(wxEvent& event); + +#ifdef WXWIN_COMPATIBILITY_2_8 + // deprecated method: override TryBefore() instead of this one + wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( + virtual bool TryValidator(wxEvent& WXUNUSED(event)), return false; ) + + wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( + virtual bool TryParent(wxEvent& event), return DoTryApp(event); ) +#endif // WXWIN_COMPATIBILITY_2_8 static const wxEventTable sm_eventTable; @@ -3351,10 +3158,13 @@ protected: wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *eventSink); private: + // pass the event to wxTheApp instance, called from TryAfter() + bool DoTryApp(wxEvent& event); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler) }; -WX_DEFINE_EXPORTED_ARRAY_PTR(wxEvtHandler*, wxEvtHandlerArray); +WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler *, wxEvtHandlerArray, class WXDLLIMPEXP_BASE); // ---------------------------------------------------------------------------- // wxEventConnectionRef represents all connections between two event handlers @@ -3402,9 +3212,16 @@ private: friend class wxEvtHandler; - DECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef) + wxDECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef); }; +inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& event) +{ + wxEvtHandler * const realHandler = m_handler ? m_handler : handler; + + (realHandler->*m_method)(event); +} + // Post a message to the given event handler which will be processed during the // next event loop iteration. // @@ -3457,7 +3274,7 @@ protected: wxArrayInt m_eventsToBlock; wxWindow *m_window; - DECLARE_NO_COPY_CLASS(wxEventBlocker) + wxDECLARE_NO_COPY_CLASS(wxEventBlocker); }; typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); @@ -3986,26 +3803,43 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #define EVT_THREAD(id, func) wx__DECLARE_EVT1(wxEVT_COMMAND_THREAD, id, wxThreadEventHandler(func)) // ---------------------------------------------------------------------------- -// Global data +// Helper functions // ---------------------------------------------------------------------------- -// list containing event handlers with pending events for them +// This is an ugly hack to allow the use of Bind() instead of Connect() inside +// the library code if the library was built with support for it, here is how +// it is used: // -// notice that each event handler should occur at most once in this list -extern WXDLLIMPEXP_BASE wxList *wxHandlersWithPendingEvents; -extern WXDLLIMPEXP_BASE wxList *wxHandlersWithPendingDelayedEvents; -#if wxUSE_THREADS - // this critical section protectes both the lists above - extern WXDLLIMPEXP_BASE wxCriticalSection *wxHandlersWithPendingEventsLocker; -#endif - -// old list names: -#define wxPendingEvents wxHandlersWithPendingEvents -#define wxPendingEventsLocker wxHandlersWithPendingEventsLocker - -// ---------------------------------------------------------------------------- -// Helper functions -// ---------------------------------------------------------------------------- +// class SomeEventHandlingClass : wxBIND_OR_CONNECT_HACK_BASE_CLASS +// public SomeBaseClass +// { +// public: +// SomeEventHandlingClass(wxWindow *win) +// { +// // connect to the event for the given window +// wxBIND_OR_CONNECT_HACK(win, wxEVT_SOMETHING, wxSomeEventHandler, +// SomeEventHandlingClass::OnSomeEvent, this); +// } +// +// private: +// void OnSomeEvent(wxSomeEvent&) { ... } +// }; +// +// This is *not* meant to be used by library users, it is only defined here +// (and not in a private header) because the base class must be visible from +// other public headers, please do NOT use this in your code, it will be +// removed from future wx versions without warning. +#if wxEVENTS_COMPATIBILITY_2_8 + #define wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxEvtHandler, + #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS : public wxEvtHandler + #define wxBIND_OR_CONNECT_HACK(w, evt, handler, func, obj) \ + win->Connect(evt, handler(func), NULL, obj) +#else // wxEVENTS_COMPATIBILITY_2_8 + #define wxBIND_OR_CONNECT_HACK_BASE_CLASS + #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS + #define wxBIND_OR_CONNECT_HACK(w, evt, handler, func, obj) \ + win->Bind(evt, &func, obj) +#endif // wxEVENTS_COMPATIBILITY_2_8/!wxEVENTS_COMPATIBILITY_2_8 #if wxUSE_GUI