+ return m_selStore ? m_selStore->IsSelected(line) : (int)line == m_current;
+}
+
+bool wxVListBox::Select(size_t item, bool select)
+{
+ wxCHECK_MSG( m_selStore, false,
+ _T("Select() may only be used with multiselection listbox") );
+
+ wxCHECK_MSG( item < GetItemCount(), false,
+ _T("Select(): invalid item index") );
+
+ bool changed = m_selStore->SelectItem(item, select);
+ if ( changed )
+ {
+ // selection really changed
+ RefreshRow(item);
+ }
+
+ DoSetCurrent(item);
+
+ return changed;
+}
+
+bool wxVListBox::SelectRange(size_t from, size_t to)
+{
+ wxCHECK_MSG( m_selStore, false,
+ _T("SelectRange() may only be used with multiselection listbox") );
+
+ // make sure items are in correct order
+ if ( from > to )
+ {
+ size_t tmp = from;
+ from = to;
+ to = tmp;
+ }
+
+ wxCHECK_MSG( to < GetItemCount(), false,
+ _T("SelectRange(): invalid item index") );
+
+ wxArrayInt changed;
+ if ( !m_selStore->SelectRange(from, to, true, &changed) )
+ {
+ // too many items have changed, we didn't record them in changed array
+ // so we have no choice but to refresh everything between from and to
+ RefreshRows(from, to);
+ }
+ else // we've got the indices of the changed items
+ {
+ const size_t count = changed.GetCount();
+ if ( !count )
+ {
+ // nothing changed
+ return false;
+ }
+
+ // refresh just the lines which have really changed
+ for ( size_t n = 0; n < count; n++ )
+ {
+ RefreshRow(changed[n]);
+ }
+ }
+
+ // something changed
+ return true;
+}
+
+bool wxVListBox::DoSelectAll(bool select)
+{
+ wxCHECK_MSG( m_selStore, false,
+ _T("SelectAll may only be used with multiselection listbox") );
+
+ size_t count = GetItemCount();
+ if ( count )
+ {
+ wxArrayInt changed;
+ if ( !m_selStore->SelectRange(0, count - 1, select) ||
+ !changed.IsEmpty() )
+ {
+ Refresh();
+
+ // something changed
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool wxVListBox::DoSetCurrent(int current)
+{
+ wxASSERT_MSG( current == wxNOT_FOUND ||
+ (current >= 0 && (size_t)current < GetItemCount()),
+ _T("wxVListBox::DoSetCurrent(): invalid item index") );
+
+ if ( current == m_current )