]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/rearrangectrl.cpp
Send generic wxTreeCtrl wxEVT_COMMAND_TREE_KEY_DOWN events from OnKeyDown rather...
[wxWidgets.git] / src / common / rearrangectrl.cpp
index a77167f47b11c226540fc57a73939b08831dc943..c9a27121cb98bf9726e0b2f3cadfc69bf0dc8242 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 = DetachClientObject(pos1);
+                SetClientObject(pos1, DetachClientObject(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)
@@ -256,8 +285,19 @@ bool wxRearrangeDialog::Create(wxWindow *parent,
     // notice that the items in this sizer should be inserted accordingly to
     // wxRearrangeDialogSizerPositions order
     wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
     // notice that the items in this sizer should be inserted accordingly to
     // wxRearrangeDialogSizerPositions order
     wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
-    sizerTop->Add(new wxStaticText(this, wxID_ANY, message),
-                  wxSizerFlags().Border());
+
+    if ( !message.empty() )
+    {
+        sizerTop->Add(new wxStaticText(this, wxID_ANY, message),
+                      wxSizerFlags().Border());
+    }
+    else
+    {
+        // for convenience of other wxRearrangeDialog code that depends on
+        // positions of sizer items, insert a dummy zero-sized item
+        sizerTop->AddSpacer(0);
+    }
+
     sizerTop->Add(m_ctrl,
                   wxSizerFlags(1).Expand().Border());
     sizerTop->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL),
     sizerTop->Add(m_ctrl,
                   wxSizerFlags(1).Expand().Border());
     sizerTop->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL),