/* draws alternating background colours */ void CBOINCGridCellRenderer::DrawBackground(wxGrid& grid, wxDC& dc, const wxRect& rect, int row, bool isSelected) { dc.SetBackgroundMode( wxSOLID ); // grey out fields if the grid is disabled if( grid.IsEnabled() ) { if ( isSelected ) { dc.SetBrush( wxBrush(grid.GetSelectionBackground(), wxSOLID) ); } else { //alternate background colours if(row % 2 == 0) { dc.SetBrush(wxBrush(wxColour(240,240,240))); } else { dc.SetBrush(*wxWHITE_BRUSH); } } } else { dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID)); } dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle(rect); }
void TimeRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); wxGridTableBase *table = grid.GetTable(); TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col); wxString tstr; if (te) { double value; table->GetValue(row, col).ToDouble(&value); NumericTextCtrl tt(NumericConverter::TIME, &grid, wxID_ANY, te->GetFormat(), value, te->GetRate(), wxPoint(10000, 10000), // create offscreen wxDefaultSize, true); tstr = tt.GetString(); te->DecRef(); } dc.SetBackgroundMode(wxTRANSPARENT); if (grid.IsEnabled()) { if (isSelected) { dc.SetTextBackground(grid.GetSelectionBackground()); dc.SetTextForeground(grid.GetSelectionForeground()); } else { dc.SetTextBackground(attr.GetBackgroundColour()); dc.SetTextForeground(attr.GetTextColour()); } } else { dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } dc.SetFont(attr.GetFont()); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign); }
void NumericRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); wxGridTableBase *table = grid.GetTable(); NumericEditor *ne = static_cast<NumericEditor *>(grid.GetCellEditor(row, col)); wxString tstr; if (ne) { double value; table->GetValue(row, col).ToDouble(&value); NumericTextCtrl tt(&grid, wxID_ANY, mType, ne->GetFormat(), value, ne->GetRate(), NumericTextCtrl::Options{}.AutoPos(true), wxPoint(10000, 10000)); // create offscreen tstr = tt.GetString(); ne->DecRef(); } dc.SetBackgroundMode(wxTRANSPARENT); if (grid.IsEnabled()) { if (isSelected) { dc.SetTextBackground(grid.GetSelectionBackground()); dc.SetTextForeground(grid.GetSelectionForeground()); } else { dc.SetTextBackground(attr.GetBackgroundColour()); dc.SetTextForeground(attr.GetTextColour()); } } else { dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } dc.SetFont(attr.GetFont()); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign); }