KiCad PCB EDA Suite
Loading...
Searching...
No Matches
grid_striped_renderer.cpp
Go to the documentation of this file.
1
3
4void STRIPED_CELL_RENDERER::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
5 const wxRect& rect, int row, int col, bool isSelected)
6{
7 // First draw the striped background for empty cells
8 wxString cellValue = grid.GetCellValue(row, col);
9 if (cellValue.IsEmpty())
10 {
11 DrawStripedBackground(dc, rect, isSelected);
12 }
13
14 // Then draw the text content using the parent class
15 wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
16}
17
18void STRIPED_CELL_RENDERER::drawStripedBackground(wxDC& dc, const wxRect& rect, bool isSelected) const
19{
20 if (isSelected)
21 {
22 // For selected cells, use the selection color
23 dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)));
24 dc.SetPen(*wxTRANSPARENT_PEN);
25 dc.DrawRectangle(rect);
26 return;
27 }
28
29 // Draw horizontal stripes
30 const int stripeHeight = 3;
31 wxColour color1 = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
32 wxColour color2(240, 240, 240); // Light gray
33
34 dc.SetPen(*wxTRANSPARENT_PEN);
35
36 bool useColor1 = true;
37 for (int y = rect.GetTop(); y < rect.GetBottom(); y += stripeHeight)
38 {
39 wxColour currentColor = useColor1 ? color1 : color2;
40 dc.SetBrush(wxBrush(currentColor));
41
42 int stripeBottom = wxMin(y + stripeHeight, rect.GetBottom());
43 dc.DrawRectangle(rect.GetLeft(), y, rect.GetWidth(), stripeBottom - y);
44
45 useColor1 = !useColor1;
46 }
47}
void drawStripedBackground(wxDC &dc, wxGridCellAttr &attr, const wxRect &rect, bool isSelected) const
void Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) override