+ m_macIsUserPane = false;
+
+ wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
+ wxT("only one of listbox selection modes can be specified") );
+
+ if ( !wxListBoxBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
+ return false;
+
+ // this will be increased by our Append command
+ m_noItems = 0;
+ m_selected = 0;
+
+ Rect bounds = wxMacGetBoundsForControl( this, pos, size );
+
+ m_peer = new wxMacControl( this );
+ OSStatus err = ::CreateDataBrowserControl(
+ MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
+ &bounds, kDataBrowserListView, m_peer->GetControlRefAddr() );
+ verify_noerr( err );
+
+ DataBrowserSelectionFlags options = kDataBrowserDragSelect;
+ if ( style & wxLB_MULTIPLE )
+ {
+ options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
+ }
+ else if ( style & wxLB_EXTENDED )
+ {
+ // default behaviour
+ }
+ else
+ {
+ options |= kDataBrowserSelectOnlyOne;
+ }
+
+ err = m_peer->SetSelectionFlags( options );
+ verify_noerr( err );
+
+ DataBrowserListViewColumnDesc columnDesc;
+ columnDesc.headerBtnDesc.titleOffset = 0;
+ columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
+
+ columnDesc.headerBtnDesc.btnFontStyle.flags =
+ kControlUseFontMask | kControlUseJustMask;
+
+ columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
+ columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
+ columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
+ columnDesc.headerBtnDesc.btnFontStyle.style = normal;
+ columnDesc.headerBtnDesc.titleString = NULL; // CFSTR( "" );
+
+ // check column
+
+ columnDesc.headerBtnDesc.minimumWidth = 30;
+ columnDesc.headerBtnDesc.maximumWidth = 30;
+
+ columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
+ columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
+ columnDesc.propertyDesc.propertyFlags =
+ kDataBrowserPropertyIsMutable
+ | kDataBrowserTableViewSelectionColumn
+ | kDataBrowserDefaultPropertyFlags;
+ err = m_peer->AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn );
+ verify_noerr( err );
+
+ // text column
+
+ columnDesc.headerBtnDesc.minimumWidth = 0;
+ columnDesc.headerBtnDesc.maximumWidth = 10000;
+
+ columnDesc.propertyDesc.propertyID = kTextColumnId;
+ columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
+ columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+ | kDataBrowserListViewTypeSelectColumn
+#endif
+ ;
+
+ verify_noerr( m_peer->AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
+
+ verify_noerr( m_peer->AutoSizeListViewColumns() );
+ verify_noerr( m_peer->SetHasScrollBars( false, true ) );
+ verify_noerr( m_peer->SetTableViewHiliteStyle( kDataBrowserTableViewFillHilite ) );
+ verify_noerr( m_peer->SetListViewHeaderBtnHeight( 0 ) );
+
+ DataBrowserCallbacks callbacks;
+ callbacks.version = kDataBrowserLatestCallbacks;
+ InitDataBrowserCallbacks( &callbacks );
+ callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP( &ListBoxGetSetItemData );
+ callbacks.u.v1.itemNotificationCallback =
+#if TARGET_API_MAC_OSX
+ (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP( &DataBrowserItemNotificationProc );
+#else
+ NewDataBrowserItemNotificationUPP( &DataBrowserItemNotificationProc );
+#endif
+ m_peer->SetCallbacks( &callbacks );
+
+#if 0
+ // shouldn't be necessary anymore under 10.2
+ m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
+ m_peer->SetNeedsFocusRect( true );
+#endif
+
+ MacPostControlCreate( pos, size );
+
+ for ( int i = 0; i < n; i++ )
+ {
+ Append( choices[i] );
+ }
+
+ // Needed because it is a wxControlWithItems
+ SetBestSize( size );
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+// wxCheckListBox functions
+// ----------------------------------------------------------------------------
+
+bool wxCheckListBox::IsChecked(size_t item) const
+{
+ wxCHECK_MSG( item < m_checks.GetCount(), false,
+ wxT("invalid index in wxCheckListBox::IsChecked") );
+
+ return m_checks[item] != 0;
+}
+
+void wxCheckListBox::Check(size_t item, bool check)
+{
+ wxCHECK_RET( item < m_checks.GetCount(),
+ wxT("invalid index in wxCheckListBox::Check") );
+
+ bool isChecked = m_checks[item] != 0;
+ if ( check != isChecked )
+ {
+ m_checks[item] = check;
+ UInt32 id = item + 1;
+ OSStatus err = m_peer->UpdateItems(
+ kDataBrowserNoItem, 1, &id,
+ kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
+ verify_noerr( err );
+ }
+}
+
+// ----------------------------------------------------------------------------
+// methods forwarded to wxCheckListBox
+// ----------------------------------------------------------------------------
+
+void wxCheckListBox::Delete(int n)
+{
+ wxCHECK_RET( (size_t)n < GetCount(), wxT("invalid index in wxCheckListBox::Delete") );
+
+ wxListBox::Delete( n );
+ m_checks.RemoveAt( n );
+}
+
+int wxCheckListBox::DoAppend(const wxString& item)
+{
+ int pos = wxListBox::DoAppend( item );
+
+ // the item is initially unchecked
+ m_checks.Insert( false, pos );
+
+ return pos;