void wxListBox::MacDelete( int n ) { wxArrayInt selectionBefore ; MacGetSelections( selectionBefore ) ; UInt32 id = m_noItems+1 ; verify_noerr( m_peer->RemoveItems( kDataBrowserNoItem , 1 , (UInt32*) &id , kDataBrowserItemNoProperty ) ) ; for ( size_t i = 0 ; i < selectionBefore.GetCount() ; ++i ) { int current = selectionBefore[i] ; if ( current == n ) { // selection was deleted MacSetSelection( current , false ) ; } else if ( current > n ) { // something behind the deleted item was selected -> move up MacSetSelection( current - 1 , true ) ; MacSetSelection( current , false ) ; } } // refresh all verify_noerr( m_peer->UpdateItems( kDataBrowserNoItem , 1 , (UInt32*) kDataBrowserNoItem , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ; }
void wxListBox::MacInsert( int n , const wxString& text) { wxArrayInt selectionBefore ; MacGetSelections( selectionBefore ) ; UInt32 id = m_noItems ; // this has already been increased verify_noerr( m_peer->AddItems( kDataBrowserNoItem , 1 , (UInt32*) &id , kDataBrowserItemNoProperty ) ) ; for ( int i = selectionBefore.GetCount()-1 ; i >= 0 ; --i ) { int current = selectionBefore[i] ; if ( current >= n ) { MacSetSelection( current + 1 , true ) ; MacSetSelection( current , false ) ; } } // refresh all verify_noerr( m_peer->UpdateItems( kDataBrowserNoItem , 1 , (UInt32*) kDataBrowserNoItem , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ; }
// Return number of selections and an array of selected integers int wxListBox::GetSelections(wxArrayInt& aSelections) const { return MacGetSelections( aSelections ) ; }