bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCol, wxDataViewItemAttr& aAttr ) const { if( IsFrozen() ) return false; // change attributes only for the name field if( aCol != 0 ) return false; auto node = ToNode( aItem ); wxCHECK( node, false ); switch( node->Type ) { case CMP_TREE_NODE::LIB: // mark modified libs with bold font aAttr.SetBold( m_libMgr->IsLibraryModified( node->Name ) ); #ifdef __WXGTK__ // The native wxGTK+ impl ignores background colour, so set the text colour instead. // This works reasonably well in dark themes, and quite poorly in light ones.... if( node->Name == m_libMgr->GetCurrentLib() ) aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); #else // mark the current library with background color if( node->Name == m_libMgr->GetCurrentLib() ) aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); #endif break; case CMP_TREE_NODE::LIBID: // mark modified part with bold font aAttr.SetBold( m_libMgr->IsPartModified( node->Name, node->Parent->Name ) ); // mark aliases with italic font aAttr.SetItalic( !node->IsRoot ); #ifdef __WXGTK__ // The native wxGTK+ impl ignores background colour, so set the text colour instead. // This works reasonably well in dark themes, and quite poorly in light ones.... if( node->LibId == m_libMgr->GetCurrentLibId() ) aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); #else // mark the current part with background color if( node->LibId == m_libMgr->GetCurrentLibId() ) aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); #endif break; default: return false; } return true; }
virtual bool GetAttrByRow( unsigned int row, unsigned int col, wxDataViewItemAttr &attr ) const { wxColour colors[]={*wxWHITE,wxColor(230,230,230)}; attr.SetBackgroundColour(colors[(row)%(sizeof(colors)/sizeof(colors[0]))]); return true; }
bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col, wxDataViewItemAttr &attr ) const { switch ( col ) { case Col_EditableText: case Col_Date: return false; case Col_IconText: if ( !(row % 2) ) return false; attr.SetColour(*wxYELLOW); attr.SetBackgroundColour(*wxLIGHT_GREY); break; case Col_TextWithAttr: case Col_Custom: // do what the labels defined in GetValueByRow() hint at switch ( row % 5 ) { case 0: attr.SetColour(*wxBLUE); break; case 1: attr.SetColour(*wxGREEN); break; case 2: attr.SetColour(*wxRED); break; case 3: attr.SetColour(*wxCYAN); attr.SetBold(true); break; case 4: return false; } break; case Col_Max: wxFAIL_MSG( "invalid column" ); } return true; }