+ 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 = -1;
+ if(m_pListBox->GetWindowStyle() & wxLB_EXTENDED)
+ {
+ wxArrayInt list;
+ m_pListBox->GetSelections(list);
+ if(list.Count()==1)
+ {
+ selection = list.Item(0);
+ }
+ }
+ else
+ {
+ 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 single item"));
+ }
+}
+
+// not implemented in ports other than (native) MSW yet
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
+void CheckListBoxFrame::AdjustColour(size_t index)
+{
+ // even items have grey backround, odd ones - white
+ unsigned char c = index % 2 ? 255 : 200;
+ m_pListBox->GetItem(index)->SetBackgroundColour(wxColor(c, c, c));
+}
+#else
+void CheckListBoxFrame::AdjustColour(size_t WXUNUSED(index))
+{