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...
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 );
// 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)
}
}
- verify_noerr( m_dbImpl->SetHeaderDesc( kMinColumnId + col, &columnDesc ) );
+ verify_noerr( m_dbImpl->SetHeaderDesc( id, &columnDesc ) );
}
return true;
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 )
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;
}
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.
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;
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.
{
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 );
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
long itemOrder;
long otherItemOrder;
- int colId = sortProperty - kMinColumnId;
+ DataBrowserTableViewColumnIndex colId = 0;
+ verify_noerr( GetColumnPosition( sortProperty, &colId ) );
wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl );
// 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 );
+ }
}
}
return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
}
-OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ){
+OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id )
+{
return GetDataBrowserTableViewColumnProperty( m_controlRef, position, id );
}
delete [] items;
}
-void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyType colType,
+static int column_id_counter = 0;
+
+void wxMacDataItemBrowserControl::InsertColumn(int col, DataBrowserPropertyType colType,
const wxString& title, SInt16 just, int defaultWidth)
{
DataBrowserListViewColumnDesc columnDesc;
columnDesc.headerBtnDesc.minimumWidth = 0;
columnDesc.headerBtnDesc.maximumWidth = 30000;
- columnDesc.propertyDesc.propertyID = (kMinColumnId + colId);
+ DataBrowserPropertyID id = kMinColumnId + column_id_counter;
+ column_id_counter++;
+
+ columnDesc.propertyDesc.propertyID = id;
columnDesc.propertyDesc.propertyType = colType;
columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
- verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
+ verify_noerr( AddColumn( &columnDesc, col ) );
if (defaultWidth > 0){
- SetColumnWidth(colId, defaultWidth);
+ SetColumnWidth(col, defaultWidth);
}
-
}
void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width)