git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6102
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
- // drawn using DrawPoint
dc.SetPen(*wxBLACK_PEN);
}
else
{
dc.SetPen(*wxBLACK_PEN);
}
else
{
- // drawn using DrawRectangle
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
}
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
}
}
else if ((m_mi != i) || (m_mj != j))
{
}
else if ((m_mi != i) || (m_mj != j))
{
+ bool alive = (m_status == MOUSE_DRAWING);
+
+ // prepare DC and pen + brush to optimize drawing
+ wxClientDC dc(this);
+ dc.SetPen(alive? *wxBLACK_PEN : *wxWHITE_PEN);
+ dc.SetBrush(alive? *wxBLACK_BRUSH : *wxWHITE_BRUSH);
+ dc.BeginDrawing();
+
// draw a line of cells using Bresenham's algorithm
wxInt32 d, ii, jj, di, ai, si, dj, aj, sj;
di = i - m_mi;
// draw a line of cells using Bresenham's algorithm
wxInt32 d, ii, jj, di, ai, si, dj, aj, sj;
di = i - m_mi;
- m_life->SetCell(ii, jj, m_status == MOUSE_DRAWING);
- DrawCell(ii, jj, m_status == MOUSE_DRAWING);
+ m_life->SetCell(ii, jj, alive);
+ DrawCell(ii, jj, dc);
- m_life->SetCell(ii, jj, m_status == MOUSE_DRAWING);
- DrawCell(ii, jj, m_status == MOUSE_DRAWING);
+ m_life->SetCell(ii, jj, alive);
+ DrawCell(ii, jj, dc);
- m_life->SetCell(ii, jj, m_status == MOUSE_DRAWING);
- DrawCell(ii, jj, m_status == MOUSE_DRAWING);
+ m_life->SetCell(ii, jj, alive);
+ DrawCell(ii, jj, dc);
}
GET_FRAME()->UpdateInfoText();
}
GET_FRAME()->UpdateInfoText();