X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c33522fca7cddc441a316f5b9fb50d7685435ba..f8d0234d39c66f3d1d7fc2346562cb96c8c7be20:/src/osx/carbon/listctrl_mac.cpp diff --git a/src/osx/carbon/listctrl_mac.cpp b/src/osx/carbon/listctrl_mac.cpp index 655502d3a9..c916795c59 100644 --- a/src/osx/carbon/listctrl_mac.cpp +++ b/src/osx/carbon/listctrl_mac.cpp @@ -148,7 +148,10 @@ static pascal OSStatus wxMacListCtrlEventHandler( EventHandlerCallRef handler , if (result == kControlButtonPart){ DataBrowserPropertyID col; GetDataBrowserSortProperty(controlRef, &col); - int column = col - kMinColumnId; + + DataBrowserTableViewColumnIndex column = 0; + verify_noerr( GetDataBrowserTableViewColumnPosition( controlRef, col, &column ) ); + le.m_col = column; // FIXME: we can't use the sort property for virtual listctrls // so we need to find a better way to determine which column was clicked... @@ -945,13 +948,9 @@ bool wxListCtrl::SetColumn(int col, wxListItem& item) if (m_dbImpl) { + wxASSERT_MSG( col < (int)m_colsInfo.GetCount(), _T("invalid column index in wxMacListCtrlItem") ); + long mask = item.GetMask(); - if ( col >= (int)m_colsInfo.GetCount() ) - { - wxListItem* listItem = new wxListItem(item); - m_colsInfo.Append( listItem ); - } - else { wxListItem listItem; GetColumn( col, listItem ); @@ -973,7 +972,10 @@ bool wxListCtrl::SetColumn(int col, wxListItem& item) // change the appearance in the databrowser. DataBrowserListViewHeaderDesc columnDesc; columnDesc.version=kDataBrowserListViewLatestHeaderDesc; - verify_noerr( m_dbImpl->GetHeaderDesc( kMinColumnId + col, &columnDesc ) ); + + DataBrowserTableViewColumnID id = 0; + verify_noerr( m_dbImpl->GetColumnIDFromIndex( col, &id ) ); + verify_noerr( m_dbImpl->GetHeaderDesc( id, &columnDesc ) ); /* if (item.GetMask() & wxLIST_MASK_TEXT) @@ -1003,7 +1005,7 @@ bool wxListCtrl::SetColumn(int col, wxListItem& item) } } - verify_noerr( m_dbImpl->SetHeaderDesc( kMinColumnId + col, &columnDesc ) ); + verify_noerr( m_dbImpl->SetHeaderDesc( id, &columnDesc ) ); } return true; @@ -1383,6 +1385,15 @@ wxRect wxListCtrl::GetViewRect() const return rect; } +bool wxListCtrl::GetSubItemRect( long item, long subItem, wxRect& rect, int code ) const +{ + if (m_genericImpl) + return m_genericImpl->GetItemRect(item, rect, code); + + // TODO: implement for DataBrowser implementation + return false; +} + // Gets the item rectangle bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const { @@ -1393,7 +1404,10 @@ bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const if (m_dbImpl) { DataBrowserItemID id; - DataBrowserPropertyID col = kMinColumnId; + + DataBrowserTableViewColumnID col = 0; + verify_noerr( m_dbImpl->GetColumnIDFromIndex( 0, &col ) ); + Rect bounds; DataBrowserPropertyPart part = kDataBrowserPropertyEnclosingPart; if ( code == wxLIST_RECT_LABEL ) @@ -1874,7 +1888,11 @@ bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel)) return true; // m_genericImpl->EndEditLabel(cancel); if (m_dbImpl) - verify_noerr( SetDataBrowserEditItem(m_dbImpl->GetControlRef(), kDataBrowserNoItem, kMinColumnId) ); + { + DataBrowserTableViewColumnID id = 0; + verify_noerr( m_dbImpl->GetColumnIDFromIndex( 0, &id ) ); + verify_noerr( SetDataBrowserEditItem(m_dbImpl->GetControlRef(), kDataBrowserNoItem, id ) ); + } return true; } @@ -2129,6 +2147,9 @@ long wxListCtrl::InsertColumn(long col, wxListItem& item) just = teFlushRight; } m_dbImpl->InsertColumn(col, type, item.GetText(), just, width); + + wxListItem* listItem = new wxListItem(item); + m_colsInfo.Insert( col, listItem ); SetColumn(col, item); // set/remove options based on the wxListCtrl type. @@ -2659,8 +2680,10 @@ void wxMacDataBrowserListCtrlControl::DrawItem( wxString text; wxFont font = wxNullFont; int imgIndex = -1; - short listColumn = property - kMinColumnId; - + + DataBrowserTableViewColumnIndex listColumn = 0; + OSStatus err = GetColumnPosition( property, &listColumn ); + wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl ); wxMacListCtrlItem* lcItem; wxColour color = *wxBLACK; @@ -2671,7 +2694,8 @@ void wxMacDataBrowserListCtrlControl::DrawItem( if (!m_isVirtual) { lcItem = (wxMacListCtrlItem*) itemID; - if (lcItem->HasColumnInfo(listColumn)){ + if (lcItem->HasColumnInfo(listColumn)) + { wxListItem* item = lcItem->GetColumnInfo(listColumn); // we always use the 0 column to get font and text/background colors. @@ -2894,7 +2918,9 @@ OSStatus wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemI { wxString text; int imgIndex = -1; - short listColumn = property - kMinColumnId; + + DataBrowserTableViewColumnIndex listColumn = 0; + verify_noerr( GetColumnPosition( property, &listColumn ) ); OSStatus err = errDataBrowserPropertyNotSupported; wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl ); @@ -2968,7 +2994,8 @@ OSStatus wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemI default: if ( property >= kMinColumnId ) { - short listColumn = property - kMinColumnId; + DataBrowserTableViewColumnIndex listColumn = 0; + verify_noerr( GetColumnPosition( property, &listColumn ) ); // TODO probably send the 'end edit' from here, as we // can then deal with the veto @@ -3092,7 +3119,8 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI long itemOrder; long otherItemOrder; - int colId = sortProperty - kMinColumnId; + DataBrowserTableViewColumnIndex colId = 0; + verify_noerr( GetColumnPosition( sortProperty, &colId ) ); wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl ); @@ -3176,7 +3204,11 @@ void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row, unsign // would be shown. Making sure not to update items until the control is visible // seems to fix this issue. if (hasInfo && list->IsShown()) - UpdateItem( wxMacDataBrowserRootContainer, listItem , kMinColumnId + column ); + { + DataBrowserTableViewColumnID id = 0; + verify_noerr( GetColumnIDFromIndex( column, &id ) ); + UpdateItem( wxMacDataBrowserRootContainer, listItem , id ); + } } }