X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8b669d34b64c0332bc70eb0959bd6de31397898..8868ab33139845e438a4493ddee209e5849481b4:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index 60d6cf3dcb..b2dc2e82f4 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -389,6 +389,8 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType) void wxMouseEvent::Assign(const wxMouseEvent& event) { + m_eventType = event.m_eventType; + m_x = event.m_x; m_y = event.m_y; @@ -543,8 +545,36 @@ wxKeyEvent::wxKeyEvent(wxEventType type) m_altDown = FALSE; m_keyCode = 0; m_scanCode = 0; +#if wxUSE_UNICODE + m_uniChar = 0; +#endif +} + +wxKeyEvent::wxKeyEvent(const wxKeyEvent& evt) + : wxEvent(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 wxUSE_UNICODE + m_uniChar = evt.m_uniChar; +#endif } +long wxKeyEvent::KeyCode() const +{ + return m_keyCode; +} wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win) { @@ -603,19 +633,19 @@ wxEvtHandler::~wxEvtHandler() if (m_dynamicEvents) { - wxNode *node = m_dynamicEvents->First(); + wxNode *node = m_dynamicEvents->GetFirst(); while (node) { #if WXWIN_COMPATIBILITY_EVENT_TYPES - wxEventTableEntry *entry = (wxEventTableEntry*)node->Data(); + wxEventTableEntry *entry = (wxEventTableEntry*)node->GetData(); #else // !WXWIN_COMPATIBILITY_EVENT_TYPES - wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->Data(); + wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData(); #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES if (entry->m_callbackUserData) delete entry->m_callbackUserData; delete entry; - node = node->Next(); + node = node->GetNext(); } delete m_dynamicEvents; }; @@ -626,6 +656,15 @@ wxEvtHandler::~wxEvtHandler() # if !defined(__VISAGECPP__) delete m_eventsLocker; # endif + + // Remove us from wxPendingEvents if necessary. + if(wxPendingEventsLocker) + wxENTER_CRIT_SECT(*wxPendingEventsLocker); + if ( wxPendingEvents ) { + wxPendingEvents->DeleteObject(this); + } + if(wxPendingEventsLocker) + wxLEAVE_CRIT_SECT(*wxPendingEventsLocker); #endif // we only delete object data, not untyped @@ -700,10 +739,10 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( *m_eventsLocker); #endif - wxNode *node = m_pendingEvents->First(); + wxNode *node = m_pendingEvents->GetFirst(); while ( node ) { - wxEvent *event = (wxEvent *)node->Data(); + wxEvent *event = (wxEvent *)node->GetData(); delete node; // In ProcessEvent, new events might get added and @@ -721,7 +760,7 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( *m_eventsLocker); #endif - node = m_pendingEvents->First(); + node = m_pendingEvents->GetFirst(); } #if defined(__VISAGECPP__) @@ -956,7 +995,8 @@ void wxEvtHandler::Connect( int id, int lastId, if (!m_dynamicEvents) m_dynamicEvents = new wxList; - m_dynamicEvents->Append( (wxObject*) entry ); + // Insert at the front of the list so most recent additions are found first + m_dynamicEvents->Insert( (wxObject*) entry ); } bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType, @@ -966,13 +1006,13 @@ bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType, if (!m_dynamicEvents) return FALSE; - wxNode *node = m_dynamicEvents->First(); + wxNode *node = m_dynamicEvents->GetFirst(); while (node) { #if WXWIN_COMPATIBILITY_EVENT_TYPES - wxEventTableEntry *entry = (wxEventTableEntry*)node->Data(); + wxEventTableEntry *entry = (wxEventTableEntry*)node->GetData(); #else // !WXWIN_COMPATIBILITY_EVENT_TYPES - wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->Data(); + wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData(); #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES if ((entry->m_id == id) && @@ -987,7 +1027,7 @@ bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType, delete entry; return TRUE; } - node = node->Next(); + node = node->GetNext(); } return FALSE; } @@ -999,13 +1039,13 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) int commandId = event.GetId(); - wxNode *node = m_dynamicEvents->First(); + wxNode *node = m_dynamicEvents->GetFirst(); while (node) { #if WXWIN_COMPATIBILITY_EVENT_TYPES - wxEventTableEntry *entry = (wxEventTableEntry*)node->Data(); + wxEventTableEntry *entry = (wxEventTableEntry*)node->GetData(); #else // !WXWIN_COMPATIBILITY_EVENT_TYPES - wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->Data(); + wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData(); #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES if (entry->m_fn) @@ -1022,13 +1062,11 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) (this->*((wxEventFunction) (entry->m_fn)))(event); - if (event.GetSkipped()) - return FALSE; - else + if ( ! event.GetSkipped() ) return TRUE; } } - node = node->Next(); + node = node->GetNext(); } return FALSE; };