+ wxLogStatus(this, wxT("item %d was %schecked"), nItem,
+ m_pListBox->IsChecked(nItem) ? wxT("") : wxT("un"));
+}
+
+void CheckListBoxFrame::OnButtonUp(wxCommandEvent& WXUNUSED(event))
+{
+ OnButtonMove(TRUE);
+}
+
+void CheckListBoxFrame::OnButtonDown(wxCommandEvent& WXUNUSED(event))
+{
+ OnButtonMove(FALSE);
+}
+
+void CheckListBoxFrame::OnButtonMove(bool up)
+{
+ int selection = m_pListBox->GetSelection();
+ if ( selection != -1 )
+ {
+ wxString label = m_pListBox->GetString(selection);
+
+ int positionNew = up ? selection - 1 : selection + 2;
+ if ( positionNew < 0 || positionNew > m_pListBox->GetCount() )
+ {
+ wxLogStatus(this, wxT("Can't move this item %s"), up ? wxT("up") : wxT("down"));
+ }
+ else
+ {
+ bool wasChecked = m_pListBox->IsChecked(selection);
+
+ int positionOld = up ? selection + 1 : selection;
+
+ // insert the item
+ m_pListBox->InsertItems(1, &label, positionNew);
+
+ // and delete the old one
+ m_pListBox->Delete(positionOld);
+
+ int selectionNew = up ? positionNew : positionNew - 1;
+ m_pListBox->Check(selectionNew, wasChecked);
+ m_pListBox->SetSelection(selectionNew);
+
+ AdjustColour(selection);
+ AdjustColour(selectionNew);
+
+ wxLogStatus(this, wxT("Item moved %s"), up ? wxT("up") : wxT("down"));
+ }
+ }
+ else
+ {
+ wxLogStatus(this, wxT("Please select an item"));
+ }
+}
+
+void CheckListBoxFrame::AdjustColour(size_t index)
+{
+ // not implemented in other ports yet
+#ifdef __WXMSW__
+ // even items have grey backround, odd ones - white
+ unsigned char c = index % 2 ? 255 : 200;
+ m_pListBox->GetItem(index)->SetBackgroundColour(wxColor(c, c, c));
+#endif // wxMSW