+const short kCheckboxColumnId = 1026;
+
+wxMacDataBrowserCheckListControl::wxMacDataBrowserCheckListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
+ : wxMacDataBrowserListControl( peer, pos, size, style )
+{
+ OSStatus err = noErr;
+
+ 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;
+
+ columnDesc.headerBtnDesc.minimumWidth = 30;
+ columnDesc.headerBtnDesc.maximumWidth = 30;
+
+ columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
+ columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
+ columnDesc.propertyDesc.propertyFlags =
+ kDataBrowserPropertyIsMutable
+ | kDataBrowserTableViewSelectionColumn
+ | kDataBrowserDefaultPropertyFlags;
+
+ err = AddColumn( &columnDesc, 0 );
+ verify_noerr( err );
+}
+
+wxMacDataBrowserCheckListControl::~wxMacDataBrowserCheckListControl()
+{
+
+}
+
+class wxMacCheckListBoxItem : public wxMacListBoxItem
+{
+public :
+ wxMacCheckListBoxItem()
+ {
+ m_isChecked = false;
+ }
+
+ virtual ~wxMacCheckListBoxItem()
+ {
+ }
+
+ virtual OSStatus GetSetData( wxMacDataItemBrowserControl *owner ,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ bool changeValue )
+ {
+ OSStatus err = errDataBrowserPropertyNotSupported;
+
+ wxCheckListBox *checklist = wxDynamicCast( owner->GetPeer() , wxCheckListBox );
+ wxCHECK_MSG( checklist != NULL , errDataBrowserPropertyNotSupported , wxT("wxCheckListBox expected"));
+
+ if ( !changeValue )
+ {
+ switch (property)
+ {
+ case kCheckboxColumnId:
+ verify_noerr(SetDataBrowserItemDataButtonValue( itemData, m_isChecked ? kThemeButtonOn : kThemeButtonOff ));
+ err = noErr;
+ break;
+
+ case kDataBrowserItemIsEditableProperty:
+ verify_noerr(SetDataBrowserItemDataBooleanValue( itemData, true ));
+ err = noErr;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (property)
+ {
+ case kCheckboxColumnId:
+ {
+ // we have to change this behind the back, since Check() would be triggering another update round
+ bool newVal = !m_isChecked;
+ verify_noerr(SetDataBrowserItemDataButtonValue( itemData, newVal ? kThemeButtonOn : kThemeButtonOff ));
+ m_isChecked = newVal;
+ err = noErr;
+
+ wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, checklist->GetId() );
+ event.SetInt( owner->GetLineFromItem( this ) );
+ event.SetEventObject( checklist );
+ checklist->GetEventHandler()->ProcessEvent( event );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if ( err == errDataBrowserPropertyNotSupported )
+ err = wxMacListBoxItem::GetSetData( owner , property, itemData , changeValue);
+
+ return err;
+ }
+
+ void Check( bool check )
+ {
+ m_isChecked = check;
+ }
+ bool IsChecked() const
+ {
+ return m_isChecked;
+ }
+
+protected :
+ bool m_isChecked;
+};
+
+wxMacListBoxItem* wxMacDataBrowserCheckListControl::CreateItem()
+{
+ return new wxMacCheckListBoxItem();
+}
+
+void wxMacDataBrowserCheckListControl::MacCheck( unsigned int n, bool bCheck)
+{
+ wxMacCheckListBoxItem* item = dynamic_cast<wxMacCheckListBoxItem*>( GetItemFromLine( n) );
+ item->Check( bCheck);
+ UpdateItem(wxMacDataBrowserRootContainer, item , kCheckboxColumnId);
+}
+
+bool wxMacDataBrowserCheckListControl::MacIsChecked( unsigned int n) const
+{
+ wxMacCheckListBoxItem * item = dynamic_cast<wxMacCheckListBoxItem*>( GetItemFromLine( n ) );
+ return item->IsChecked();
+}
+
+