]> git.saurik.com Git - wxWidgets.git/commitdiff
Swap client data pointers in wxRearrangeList too.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 Jul 2010 10:43:23 +0000 (10:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 Jul 2010 10:43:23 +0000 (10:43 +0000)
If the list box uses client data, we need to swap the data pointers too when
exchanging items in it.

Closes #12201.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/rearrangectrl.cpp

index fa37a190b9f6f87242f54028b10c8933ad6dc8cc..db6210764c2770fd4a7ccf3ee0786e120f5de3c6 100644 (file)
@@ -530,6 +530,7 @@ All (GUI):
 - Added "filter changed" event to wxFileCtrl (Bill Jones).
 - wxAUI: update floating window position and not only size on resize (MacGyver).
 - Added wxComboCtrl::SetTextCtrlStyle().
 - Added "filter changed" event to wxFileCtrl (Bill Jones).
 - wxAUI: update floating window position and not only size on resize (MacGyver).
 - Added wxComboCtrl::SetTextCtrlStyle().
+- Also update client data in wxRearrangeList control (John Roberts).
 
 GTK:
 
 
 GTK:
 
index a77167f47b11c226540fc57a73939b08831dc943..5f6bc2bf0680597fe9fada703f7732de135b881f 100644 (file)
@@ -125,16 +125,45 @@ bool wxRearrangeList::MoveCurrentDown()
 
 void wxRearrangeList::Swap(int pos1, int pos2)
 {
 
 void wxRearrangeList::Swap(int pos1, int pos2)
 {
+    // update the internally stored order
     wxSwap(m_order[pos1], m_order[pos2]);
 
     wxSwap(m_order[pos1], m_order[pos2]);
 
-    const wxString stringTmp = GetString(pos1);
-    const bool checkedTmp = IsChecked(pos1);
 
 
+    // and now also swap all the attributes of the items
+
+    // first the label
+    const wxString stringTmp = GetString(pos1);
     SetString(pos1, GetString(pos2));
     Check(pos1, IsChecked(pos2));
 
     SetString(pos1, GetString(pos2));
     Check(pos1, IsChecked(pos2));
 
+    // then the checked state
+    const bool checkedTmp = IsChecked(pos1);
     SetString(pos2, stringTmp);
     Check(pos2, checkedTmp);
     SetString(pos2, stringTmp);
     Check(pos2, checkedTmp);
+
+    // and finally the client data, if necessary
+    switch ( GetClientDataType() )
+    {
+        case wxClientData_None:
+            // nothing to do
+            break;
+
+        case wxClientData_Object:
+            {
+                wxClientData * const dataTmp = GetClientObject(pos1);
+                SetClientObject(pos1, GetClientObject(pos2));
+                SetClientObject(pos2, dataTmp);
+            }
+            break;
+
+        case wxClientData_Void:
+            {
+                void * const dataTmp = GetClientData(pos1);
+                SetClientData(pos1, GetClientData(pos2));
+                SetClientData(pos2, dataTmp);
+            }
+            break;
+    }
 }
 
 void wxRearrangeList::OnCheck(wxCommandEvent& event)
 }
 
 void wxRearrangeList::OnCheck(wxCommandEvent& event)