X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/67b81440f079f88e6202a199fd5763af73bbac0f..dbb88122c9b22aa02f8840d3bf92007781d11f25:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index aa4c5d9172..87eda81fdb 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -46,53 +46,53 @@ #include "wx/validate.h" #endif // wxUSE_GUI - // ---------------------------------------------------------------------------- // wxWin macros // ---------------------------------------------------------------------------- - IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) - IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) - IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent) +IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent) - #if wxUSE_GUI - IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent) - #endif // wxUSE_GUI +#if wxUSE_GUI + IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent, wxCommandEvent) +#endif // wxUSE_GUI - const wxEventTable *wxEvtHandler::GetEventTable() const - { return &wxEvtHandler::sm_eventTable; } +const wxEventTable *wxEvtHandler::GetEventTable() const + { return &wxEvtHandler::sm_eventTable; } - const wxEventTable wxEvtHandler::sm_eventTable = - { (const wxEventTable *)NULL, &wxEvtHandler::sm_eventTableEntries[0] }; +const wxEventTable wxEvtHandler::sm_eventTable = + { (const wxEventTable *)NULL, &wxEvtHandler::sm_eventTableEntries[0] }; - const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = - { { 0, 0, 0, (wxObjectEventFunction) NULL, (wxObject*) NULL } }; +const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = + { { 0, 0, 0, (wxObjectEventFunction) NULL, (wxObject*) NULL } }; // ---------------------------------------------------------------------------- @@ -206,16 +206,6 @@ wxScrollEvent::wxScrollEvent(wxEventType commandType, { m_extraLong = orient; m_commandInt = pos; - m_isScrolling = TRUE; -} - -void wxScrollEvent::CopyObject(wxObject& obj_d) const -{ - wxScrollEvent *obj = (wxScrollEvent*)&obj_d; - - wxCommandEvent::CopyObject(obj_d); - - obj->m_isScrolling = m_isScrolling; } /* @@ -229,7 +219,6 @@ wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType, m_eventType = commandType; m_extraLong = orient; m_commandInt = pos; - m_isScrolling = TRUE; } void wxScrollWinEvent::CopyObject(wxObject& obj_d) const @@ -240,7 +229,6 @@ void wxScrollWinEvent::CopyObject(wxObject& obj_d) const obj->m_extraLong = m_extraLong; obj->m_commandInt = m_commandInt; - obj->m_isScrolling = m_isScrolling; } /* @@ -537,14 +525,12 @@ void wxQueryNewPaletteEvent::CopyObject(wxObject& obj_d) const } wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win) - : wxEvent() { SetEventType(wxEVT_CREATE); SetEventObject(win); } wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow *win) - : wxEvent() { SetEventType(wxEVT_DESTROY); SetEventObject(win); @@ -810,35 +796,45 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event) bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event) { - int i = 0; - int commandId = event.GetId(); + wxEventType eventType = event.GetEventType(); + int eventId = event.GetId(); - // BC++ doesn't like while (table.entries[i].m_fn) - -#ifdef __SC__ - while (table.entries[i].m_fn != 0) + // BC++ doesn't like testing for m_fn without != 0 + for ( int i = 0; table.entries[i].m_fn != 0; i++ ) + { + // the line using reference exposes a bug in gcc: although it _seems_ + // to work, it leads to weird crashes later on during program + // execution +#ifdef __GNUG__ + wxEventTableEntry entry = table.entries[i]; #else - while (table.entries[i].m_fn != 0L) + const wxEventTableEntry& entry = table.entries[i]; #endif - { - if ((event.GetEventType() == table.entries[i].m_eventType) && - (table.entries[i].m_id == -1 || // Match, if event spec says any id will do (id == -1) - (table.entries[i].m_lastId == -1 && commandId == table.entries[i].m_id) || - (table.entries[i].m_lastId != -1 && - (commandId >= table.entries[i].m_id && commandId <= table.entries[i].m_lastId)))) + + // match only if the event type is the same and the id is either -1 in + // the event table (meaning "any") or the event id matches the id + // specified in the event table either exactly or by falling into + // range between first and last + if ( eventType == entry.m_eventType ) { - event.Skip(FALSE); - event.m_callbackUserData = table.entries[i].m_callbackUserData; + int tableId1 = entry.m_id, + tableId2 = entry.m_lastId; - (this->*((wxEventFunction) (table.entries[i].m_fn)))(event); + if ( (tableId1 == -1) || + (tableId2 == -1 && eventId == tableId1) || + (tableId2 != -1 && + (eventId >= tableId1 && eventId <= tableId2)) ) + { + event.Skip(FALSE); + event.m_callbackUserData = entry.m_callbackUserData; - if ( event.GetSkipped() ) - return FALSE; - else - return TRUE; + (this->*((wxEventFunction) (entry.m_fn)))(event); + + return !event.GetSkipped(); + } } - i++; } + return FALSE; }