]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listctrl.cpp
Reenabled deleteallitems events, marked
[wxWidgets.git] / src / msw / listctrl.cpp
index b521e1c58358764b6b210a821c4030c1c7d001cc..15d33a55c195ec713f1c62f4c0e091ec417eeb92 100644 (file)
@@ -19,6 +19,7 @@
 
 #ifdef __GNUG__
     #pragma implementation "listctrl.h"
+    #pragma implementation "listctrlbase.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
@@ -61,13 +62,48 @@ static void wxConvertFromMSWListItem(const wxListCtrl *ctrl, wxListItem& info, L
 // macros
 // ----------------------------------------------------------------------------
 
-    IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
-    IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
 
 // ============================================================================
 // implementation
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// wxListEvent
+// ----------------------------------------------------------------------------
+
+void wxListEvent::CopyObject(wxObject& object_dest) const
+{
+    wxListEvent *obj = (wxListEvent *)&object_dest;
+
+    wxNotifyEvent::CopyObject(object_dest);
+
+    obj->m_code = m_code;
+    obj->m_itemIndex = m_itemIndex;
+    obj->m_oldItemIndex = m_oldItemIndex;
+    obj->m_col = m_col;
+    obj->m_cancelled = m_cancelled;
+    obj->m_pointDrag = m_pointDrag;
+    obj->m_item.m_mask = m_item.m_mask;
+    obj->m_item.m_itemId = m_item.m_itemId;
+    obj->m_item.m_col = m_item.m_col;
+    obj->m_item.m_state = m_item.m_state;
+    obj->m_item.m_stateMask = m_item.m_stateMask;
+    obj->m_item.m_text = m_item.m_text;
+    obj->m_item.m_image = m_item.m_image;
+    obj->m_item.m_data = m_item.m_data;
+    obj->m_item.m_format = m_item.m_format;
+    obj->m_item.m_width = m_item.m_width;
+
+    if ( m_item.HasAttributes() )
+    {
+        obj->m_item.SetTextColour(m_item.GetTextColour());
+        obj->m_item.SetBackgroundColour(m_item.GetBackgroundColour());
+        obj->m_item.SetFont(m_item.GetFont());
+    }
+}
+
 // ----------------------------------------------------------------------------
 // wxListCtrl construction
 // ----------------------------------------------------------------------------
@@ -91,7 +127,10 @@ bool wxListCtrl::Create(wxWindow *parent,
                         const wxValidator& validator,
                         const wxString& name)
 {
+#if wxUSE_VALIDATORS
     SetValidator(validator);
+#endif // wxUSE_VALIDATORS
+
     SetName(name);
 
     int x = pos.x;
@@ -1256,19 +1295,20 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             }
 
         case LVN_DELETEALLITEMS:
-            // what's the sense of generating a wxWin event for this when
-            // it's absolutely not portable?
-#if 0
-            eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
+            // What's the sense of generating a wxWin event for this when
+           // it's absolutely not portable?
+            // This is perfectly portable, RR
+#if 1
+           eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
             event.m_itemIndex = -1;
-#endif // 0
+#endif // 1
 
             // return TRUE to suppress all additional LVN_DELETEITEM
             // notifications - this makes deleting all items from a list ctrl
             // much faster
             *result = TRUE;
 
-            return TRUE;
+           break;
 
         case LVN_DELETEITEM:
             {
@@ -1382,9 +1422,16 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             }
 
             // else translate it into wxEVT_COMMAND_LIST_ITEM_ACTIVATED event
+            // if it happened on an item (and not on empty place)
             {
-                eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
                 NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+                if ( hdr->iItem == -1 )
+                {
+                    // not on item
+                    return FALSE;
+                }
+
+                eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
                 event.m_itemIndex = hdr->iItem;
             }
             break;
@@ -1532,6 +1579,14 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
     if ( !GetEventHandler()->ProcessEvent(event) )
         return FALSE;
 
+    if (eventType == wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
+    {
+       // No postprocessing, because we want *return to
+       // be TRUE so that no further DeleteItem events
+       // are sent, RR.
+        return TRUE;
+    }
+
     // post processing
     // ---------------