void CustomGrid::DrawColLabel( wxDC& dc, int col ) { //init dc font and colours dc.SetFont(m_labelFont); if(col == m_gParent->m_pIndex){ dc.SetBrush(wxBrush(m_greenColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_greenColour, 1)); }else { dc.SetBrush(wxBrush(m_labelBackgroundColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_labelBackgroundColour, 1)); } //draw retangle wxRect tRect( GetColLeft(col), 1, GetColWidth(col)-2, m_colLabelHeight -2); dc.DrawRectangle(tRect); //draw lines aroud label dc.SetPen(GetDefaultGridLinePen()); dc.DrawLine( GetColLeft(col) -1, 0, GetColRight(col), 0 ); if( col > -1 && (col == 0 || GetColLabelValue( col ).BeforeFirst('-') != GetColLabelValue( col - 1 ).BeforeFirst('-')) ) dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColLeft(col) -1, 0, GetColLeft(col) - 1, m_colLabelHeight); if( col == m_numCols - 1 ){ dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColRight(col), 0, GetColRight(col), m_colLabelHeight); } //then draw label dc.DrawLabel(GetColLabelValue(col), tRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL); }
/* not virtual in wxGrid, so code copied and modified her for painting sorting icons */ void CBOINCGridCtrl::DrawColLabel( wxDC& dc, int col ) { if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 ) return; int colLeft = GetColLeft(col); wxRect rect; int colRight = GetColRight(col) - 1; dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) ); dc.DrawLine( colRight, 0, colRight, m_colLabelHeight-1 ); dc.DrawLine( colLeft, 0, colRight, 0 ); dc.DrawLine( colLeft, m_colLabelHeight-1, colRight+1, m_colLabelHeight-1 ); dc.SetPen( *wxWHITE_PEN ); dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 ); dc.DrawLine( colLeft, 1, colRight, 1 ); dc.SetBackgroundMode( wxTRANSPARENT ); dc.SetTextForeground( GetLabelTextColour() ); dc.SetFont( GetLabelFont() ); int hAlign, vAlign, orient; GetColLabelAlignment( &hAlign, &vAlign ); orient = GetColLabelTextOrientation(); rect.SetX( colLeft + 2 ); rect.SetY( 2 ); rect.SetWidth( GetColWidth(col) - 4 ); rect.SetHeight( m_colLabelHeight - 4 ); DrawTextRectangle( dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient ); //paint sorting indicators, if needed if(col == sortColumn) { int x = rect.GetRight() - ascBitmap.GetWidth() - 2; int y = rect.GetY(); dc.DrawBitmap(this->sortAscending ? descBitmap : ascBitmap,x,y,true); } }