+ return wxDynamicCast( wxMacControl::GetWX() , wxWindow );
+}
+*/
+
+//
+// List Methods
+//
+
+wxMacDataBrowserColumn* wxMacDataBrowserListControl::DoInsertColumn( unsigned int pos, DataBrowserPropertyID property,
+ const wxString& title, bool editable,
+ DataBrowserPropertyType colType, SInt16 just, int width )
+{
+ DataBrowserListViewColumnDesc columnDesc;
+ columnDesc.headerBtnDesc.titleOffset = 0;
+ columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
+
+ columnDesc.headerBtnDesc.btnFontStyle.flags =
+ kControlUseFontMask | kControlUseJustMask;
+
+ columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
+ columnDesc.headerBtnDesc.btnFontStyle.just = just;
+ columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
+ columnDesc.headerBtnDesc.btnFontStyle.style = normal;
+
+ // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
+ // defined for other modes?
+ wxFontEncoding enc;
+ if ( m_font.Ok() )
+ enc = m_font.GetEncoding();
+ else
+ enc = wxLocale::GetSystemEncoding();
+ wxCFStringRef cfTitle( title, enc );
+ columnDesc.headerBtnDesc.titleString = cfTitle;
+
+ columnDesc.headerBtnDesc.minimumWidth = 0;
+ columnDesc.headerBtnDesc.maximumWidth = 30000;
+
+ columnDesc.propertyDesc.propertyID = property;
+ columnDesc.propertyDesc.propertyType = colType;
+ columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
+ columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
+ columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
+
+ if ( editable )
+ columnDesc.propertyDesc.propertyFlags |= kDataBrowserPropertyIsMutable;
+
+ verify_noerr( AddColumn( &columnDesc, pos ) );
+
+ if (width > 0)
+ {
+ wxMacDataBrowserControl::SetColumnWidth(property, width);
+ }
+
+ wxMacDataBrowserColumn *col = new wxMacDataBrowserColumn( property, colType, editable );
+
+ m_columns.Insert( col, pos );
+
+ return col;
+}
+
+wxListWidgetColumn* wxMacDataBrowserListControl::InsertTextColumn( unsigned pos, const wxString& title, bool editable,
+ wxAlignment just, int defaultWidth)
+{
+ DataBrowserPropertyID property = kMinColumnId + m_nextColumnId++;
+
+ SInt16 j = teFlushLeft;
+ if ( just & wxALIGN_RIGHT )
+ j = teFlushRight;
+ else if ( just & wxALIGN_CENTER_HORIZONTAL )
+ j = teCenter;
+
+ return DoInsertColumn( pos, property, title, editable, kDataBrowserTextType, just, defaultWidth );
+}
+
+wxListWidgetColumn* wxMacDataBrowserListControl::InsertCheckColumn( unsigned pos , const wxString& title, bool editable,
+ wxAlignment just, int defaultWidth )
+{
+ DataBrowserPropertyID property = kMinColumnId + m_nextColumnId++;
+
+ SInt16 j = teFlushLeft;
+ if ( just & wxALIGN_RIGHT )
+ j = teFlushRight;
+ else if ( just & wxALIGN_CENTER_HORIZONTAL )
+ j = teCenter;
+
+ return DoInsertColumn( pos, property, title, editable, kDataBrowserCheckboxType, just, defaultWidth );
+}
+
+wxMacDataBrowserColumn* wxMacDataBrowserListControl::GetColumnFromProperty( DataBrowserPropertyID property)
+{
+ for ( unsigned int i = 0; i < m_columns.size() ; ++ i )
+ if ( m_columns[i]->GetProperty() == property )
+ return m_columns[i];
+
+ return NULL;
+}
+
+/*
+wxMacDataItem* wxMacDataBrowserListControl::ListGetLineItem( unsigned int n )
+{
+ return (wxMacDataItem*) GetItemFromLine(n);
+}
+*/
+
+unsigned int wxMacDataBrowserListControl::ListGetCount() const
+{
+ return MacGetCount();
+}
+
+void wxMacDataBrowserListControl::ListDelete( unsigned int n )
+{
+ MacDelete( n );
+}
+
+void wxMacDataBrowserListControl::ListInsert( unsigned int n )
+{
+ MacInsert( n , new wxMacListBoxItem() );
+}
+
+void wxMacDataBrowserListControl::ListClear()
+{
+ MacClear();
+}
+
+void wxMacDataBrowserListControl::ListDeselectAll()
+{
+ wxMacDataItemBrowserSelectionSuppressor suppressor(this);
+ SetSelectedAllItems( kDataBrowserItemsRemove );
+}
+
+void wxMacDataBrowserListControl::ListSetSelection( unsigned int n, bool select, bool multi )
+{
+ wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
+ wxMacDataItemBrowserSelectionSuppressor suppressor(this);
+
+ if ( IsItemSelected( item ) != select )
+ {
+ if ( select )
+ SetSelectedItem( item, multi ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
+ else
+ SetSelectedItem( item, kDataBrowserItemsRemove );
+ }
+
+ ListScrollTo( n );
+}
+
+bool wxMacDataBrowserListControl::ListIsSelected( unsigned int n ) const
+{
+ wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
+ return IsItemSelected( item );
+}
+
+int wxMacDataBrowserListControl::ListGetSelection() const
+{
+ wxMacDataItemPtr first, last;
+ GetSelectionAnchor( &first, &last );
+
+ if ( first != NULL )
+ {
+ return GetLineFromItem( first );
+ }
+
+ return -1;
+}
+
+int wxMacDataBrowserListControl::ListGetSelections( wxArrayInt& aSelections ) const
+{
+ aSelections.Empty();
+ wxArrayMacDataItemPtr selectedItems;
+ GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
+
+ int count = selectedItems.GetCount();
+
+ for ( int i = 0; i < count; ++i)
+ {
+ aSelections.Add(GetLineFromItem(selectedItems[i]));
+ }
+
+ return count;
+}
+
+void wxMacDataBrowserListControl::ListScrollTo( unsigned int n )
+{
+ UInt32 top , left ;
+ GetScrollPosition( &top , &left ) ;
+ wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
+
+ // there is a bug in RevealItem that leads to situations
+ // in large lists, where the item does not get scrolled
+ // into sight, so we do a pre-scroll if necessary
+ UInt16 height ;
+ GetRowHeight( (DataBrowserItemID) item , &height ) ;
+ UInt32 linetop = n * ((UInt32) height );
+ UInt32 linebottom = linetop + height;
+ Rect rect ;
+ GetControlBounds( m_controlRef, &rect );
+
+ if ( linetop < top || linebottom > (top + rect.bottom - rect.top ) )
+ SetScrollPosition( wxMax( n-2, 0 ) * ((UInt32)height) , left ) ;
+
+ RevealItem( item , kDataBrowserRevealWithoutSelecting );
+}
+
+void wxMacDataBrowserListControl::UpdateLine( unsigned int n, wxListWidgetColumn* col )
+{
+ wxMacDataBrowserColumn* dbcol = dynamic_cast<wxMacDataBrowserColumn*> (col);
+ wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
+ UpdateItem(wxMacDataBrowserRootContainer, item, dbcol ? dbcol->GetProperty() : kDataBrowserNoItem );
+}
+
+void wxMacDataBrowserListControl::UpdateLineToEnd( unsigned int n)
+{
+ // with databrowser inserting does not need updating the entire model, it's done by databrowser itself
+ wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
+ UpdateItem(wxMacDataBrowserRootContainer, item, kDataBrowserNoItem );
+}
+
+// value setters
+
+void wxMacDataBrowserCellValue::Set( CFStringRef value )
+{
+ SetDataBrowserItemDataText( m_data, value );
+}
+
+void wxMacDataBrowserCellValue::Set( const wxString& value )
+{
+ wxCFStringRef cf(value);
+ SetDataBrowserItemDataText( m_data, (CFStringRef) cf);
+}
+
+void wxMacDataBrowserCellValue::Set( int value )
+{
+ SetDataBrowserItemDataValue( m_data, value );
+}
+
+void wxMacDataBrowserCellValue::Check( bool check )
+{
+ SetDataBrowserItemDataButtonValue( m_data, check ? kThemeButtonOn : kThemeButtonOff);
+}
+
+int wxMacDataBrowserCellValue::GetIntValue() const
+{
+ SInt32 value;
+ GetDataBrowserItemDataValue( m_data, &value );
+ return value;