Fix row shading.

Don't use the wxGrid convenience covers.  They assume
you're doing nothing else with attributes.
This commit is contained in:
Jeff Young 2025-02-03 20:05:43 +00:00
parent 28b2e656e5
commit fec6882e0a
4 changed files with 10 additions and 11 deletions

View File

@ -157,13 +157,13 @@ public:
class WX_GRID_ALT_ROW_COLOR_PROVIDER : public wxGridCellAttrProvider
{
public:
WX_GRID_ALT_ROW_COLOR_PROVIDER( const wxColor& aBaseColor ) : wxGridCellAttrProvider(),
m_attrEven( new wxGridCellAttr() )
WX_GRID_ALT_ROW_COLOR_PROVIDER( const wxColor& aBaseColor ) :
wxGridCellAttrProvider(),
m_attrEven( new wxGridCellAttr() )
{
UpdateColors( aBaseColor );
}
void UpdateColors( const wxColor& aBaseColor )
{
// Choose the default color, taking into account if the dark mode theme is enabled
@ -172,9 +172,7 @@ public:
m_attrEven->SetBackgroundColour( rowColor );
}
wxGridCellAttr* GetAttr( int row, int col,
wxGridCellAttr::wxAttrKind kind ) const override
wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) const override
{
wxGridCellAttrPtr cellAttr( wxGridCellAttrProvider::GetAttr( row, col, kind ) );

View File

@ -432,13 +432,15 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties( int aCol )
{
attr->SetReadOnly();
m_grid->SetColAttr( aCol, attr );
m_grid->SetColFormatNumber( aCol );
attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
attr->SetRenderer( new wxGridCellNumberRenderer() );
}
else if( m_dataModel->ColIsAttribute( aCol ) )
{
attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
attr->SetRenderer( new wxGridCellBoolRenderer() );
attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
m_grid->SetColAttr( aCol, attr );
m_grid->SetColFormatBool( aCol );
}
else if( IsTextVar( m_dataModel->GetColFieldName( aCol ) ) )
{
@ -449,7 +451,6 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties( int aCol )
{
attr->SetEditor( m_grid->GetDefaultEditor() );
m_grid->SetColAttr( aCol, attr );
m_grid->SetColFormatCustom( aCol, wxGRID_VALUE_STRING );
}
}

View File

@ -108,7 +108,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RenameColumn( int aCol, const wxString& newN
}
int FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol( wxString aFieldName )
int FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol( const wxString& aFieldName )
{
for( size_t i = 0; i < m_cols.size(); i++ )
{

View File

@ -143,7 +143,7 @@ public:
return m_cols[aCol].m_fieldName;
}
int GetFieldNameCol( wxString aFieldName );
int GetFieldNameCol( const wxString& aFieldName );
const std::vector<BOM_FIELD> GetFieldsOrdered();
void SetFieldsOrder( const std::vector<wxString>& aNewOrder );