]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/event.cpp
Added chapter on collection and container classes to contents
[wxWidgets.git] / src / common / event.cpp
index 8843bd11c87a9a520629bf027481c1d86df05d01..3ace246251136bc2af953944ede28d1f2c09eb7a 100644 (file)
@@ -205,19 +205,6 @@ wxScrollEvent::wxScrollEvent(wxEventType commandType,
 {
     m_extraLong = orient;
     m_commandInt = pos;
-<<<<<<< event.cpp
-    m_isScrolling = TRUE;
-}
-
-void wxScrollEvent::CopyObject(wxObject& obj_d) const
-{
-    wxScrollEvent *obj = (wxScrollEvent*)&obj_d;
-
-    wxCommandEvent::CopyObject(obj_d);
-
-    obj->m_isScrolling  = m_isScrolling;
-=======
->>>>>>> 1.69
 }
 
 /*
@@ -537,14 +524,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 +795,45 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
 
 bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
 {
-    int i = 0;
-    int commandId = event.GetId();
-
-    // BC++ doesn't like while (table.entries[i].m_fn)
+    wxEventType eventType = event.GetEventType();
+    int eventId = event.GetId();
 
-#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;
+
+            if ( (tableId1 == -1) ||
+                 (tableId2 == -1 && eventId == tableId1) ||
+                 (tableId2 != -1 &&
+                    (eventId >= tableId1 && eventId <= tableId2)) )
+            {
+                event.Skip(FALSE);
+                event.m_callbackUserData = entry.m_callbackUserData;
 
-            (this->*((wxEventFunction) (table.entries[i].m_fn)))(event);
+                (this->*((wxEventFunction) (entry.m_fn)))(event);
 
-            if ( event.GetSkipped() )
-                return FALSE;
-            else
-                return TRUE;
+                return !event.GetSkipped();
+            }
         }
-        i++;
     }
+
     return FALSE;
 }