+void wxMacDataBrowserListControl::MacInsert( int n, const wxArrayString& items)
+{
+ wxArrayInt selectionBefore;
+ MacGetSelections( selectionBefore );
+ size_t itemsCount = items.GetCount();
+
+ UInt32 *ids = new UInt32[itemsCount];
+ for ( unsigned int i = 0; i < itemsCount; ++i )
+ ids[i] = GetPeer()->GetCount() - itemsCount + i + 1;
+
+ OSStatus err = AddItems( kDataBrowserNoItem, itemsCount, ids, kDataBrowserItemNoProperty );
+ verify_noerr( err );
+ delete [] ids;
+
+ 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
+ err = UpdateItems(
+ kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
+ kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
+ verify_noerr( err );
+}
+
+void wxMacDataBrowserListControl::MacAppend( const wxString& text)
+{
+ UInt32 id = GetPeer()->GetCount(); // this has already been increased
+ verify_noerr( AddItems( kDataBrowserNoItem, 1, (UInt32*) &id, kDataBrowserItemNoProperty ) );
+ // no need to deal with selections nor refreshed, as we have appended
+}
+
+void wxMacDataBrowserListControl::MacClear()
+{
+ verify_noerr( RemoveItems( kDataBrowserNoItem, 0, NULL, kDataBrowserItemNoProperty ) );
+}
+
+void wxMacDataBrowserListControl::MacDeselectAll()
+{
+ bool former = MacSuppressSelection( true );
+ verify_noerr(SetSelectedItems( 0, NULL, kDataBrowserItemsRemove ) );
+ MacSuppressSelection( former );
+}
+
+void wxMacDataBrowserListControl::MacSetSelection( int n, bool select )
+{
+ UInt32 id = n + 1;
+ bool former = MacSuppressSelection( true );
+
+ if ( IsItemSelected( id ) != select )
+ {
+ OSStatus err;
+
+ if ( select )
+ err = SetSelectedItems( 1, &id, GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
+ else
+ err = SetSelectedItems( 1, &id, kDataBrowserItemsRemove );
+
+ verify_noerr( err );
+ }
+
+ MacScrollTo( n );
+ MacSuppressSelection( former );
+}
+
+bool wxMacDataBrowserListControl::MacSuppressSelection( bool suppress )
+{
+ bool former = m_suppressSelection;
+ m_suppressSelection = suppress;
+
+ return former;
+}
+
+bool wxMacDataBrowserListControl::MacIsSelected( int n ) const
+{
+ return IsItemSelected( n + 1 );
+}
+
+int wxMacDataBrowserListControl::MacGetSelection() const
+{
+ for ( unsigned int i = 0; i < GetPeer()->GetCount(); ++i )
+ {
+ if ( IsItemSelected( i + 1 ) )
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+int wxMacDataBrowserListControl::MacGetSelections( wxArrayInt& aSelections ) const
+{
+ int no_sel = 0;
+
+ aSelections.Empty();
+
+ UInt32 first, last;
+ GetSelectionAnchor( &first, &last );
+ if ( first != kDataBrowserNoItem )
+ {
+ for ( size_t i = first; i <= last; ++i )
+ {
+ if ( IsItemSelected( i ) )
+ {
+ aSelections.Add( i - 1 );
+ no_sel++;
+ }
+ }
+ }
+
+ return no_sel;
+}
+
+void wxMacDataBrowserListControl::MacSet( int n, const wxString& text )
+{
+ // as we don't store the strings we only have to issue a redraw
+ UInt32 id = n + 1;
+ verify_noerr( UpdateItems( kDataBrowserNoItem, 1, &id, kDataBrowserItemNoProperty, kDataBrowserItemNoProperty ) );
+}
+
+void wxMacDataBrowserListControl::MacScrollTo( int n )
+{
+ UInt32 id = n + 1;
+ verify_noerr( RevealItem( id, kTextColumnId, kDataBrowserRevealWithoutSelecting ) );
+}
+
+void wxMacDataBrowserListControl::UpdateLine( int n )
+{
+ UInt32 id = n + 1;
+ verify_noerr( UpdateItems(kDataBrowserNoItem, 1, &id, kDataBrowserItemNoProperty, kDataBrowserItemNoProperty ) );
+}
+
+//
+// Databrowser
+//
+
+OSStatus wxMacDataBrowserListControl::SetSelectionFlags( DataBrowserSelectionFlags options )
+{
+ return SetDataBrowserSelectionFlags( m_controlRef, options );
+}
+
+OSStatus wxMacDataBrowserListControl::AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
+ DataBrowserTableViewColumnIndex position )
+{
+ return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
+}
+
+OSStatus wxMacDataBrowserListControl::AutoSizeListViewColumns()
+{
+ return AutoSizeDataBrowserListViewColumns(m_controlRef);
+}
+
+OSStatus wxMacDataBrowserListControl::SetHasScrollBars( bool horiz, bool vert )
+{
+ return SetDataBrowserHasScrollBars( m_controlRef, horiz, vert );
+}
+
+OSStatus wxMacDataBrowserListControl::SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
+{
+ return SetDataBrowserTableViewHiliteStyle( m_controlRef, hiliteStyle );
+}
+
+OSStatus wxMacDataBrowserListControl::SetListViewHeaderBtnHeight(UInt16 height)
+{
+ return SetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
+}
+
+OSStatus wxMacDataBrowserListControl::SetCallbacks(const DataBrowserCallbacks *callbacks)
+{
+ return SetDataBrowserCallbacks( m_controlRef, callbacks );
+}
+
+OSStatus wxMacDataBrowserListControl::UpdateItems(
+ DataBrowserItemID container,
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty,
+ DataBrowserPropertyID propertyID )
+{
+ return UpdateDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty, propertyID );
+}
+
+bool wxMacDataBrowserListControl::IsItemSelected( DataBrowserItemID item ) const
+{
+ return IsDataBrowserItemSelected( m_controlRef, item );
+}
+
+OSStatus wxMacDataBrowserListControl::AddItems(
+ DataBrowserItemID container,
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty )
+{
+ return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
+}
+
+OSStatus wxMacDataBrowserListControl::RemoveItems(
+ DataBrowserItemID container,
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty )
+{
+ return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
+}
+
+OSStatus wxMacDataBrowserListControl::RevealItem(
+ DataBrowserItemID item,
+ DataBrowserPropertyID propertyID,
+ DataBrowserRevealOptions options )
+{
+ return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
+}
+
+OSStatus wxMacDataBrowserListControl::SetSelectedItems(
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserSetOption operation )
+{
+ return SetDataBrowserSelectedItems( m_controlRef, numItems, items, operation );
+}
+
+OSStatus wxMacDataBrowserListControl::GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const
+{
+ return GetDataBrowserSelectionAnchor( m_controlRef, first, last );
+}
+
+#if 0
+
+// in case we need that one day
+
+// ============================================================================
+// HIView owner-draw-based implementation
+// ============================================================================
+
+static pascal void ListBoxDrawProc(
+ ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property,
+ DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice )