diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index 4b5f3fb..fec281e 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -12,6 +12,8 @@ BoardCanvas::BoardCanvas(wxFrame *parent) SetClockTime(-1, -1, -1, false); SetClockTime(-1, -1, -1, true); ApplyPreferences(); + // The following should be called when using an EVT_PAINT handler + SetBackgroundStyle(wxBG_STYLE_PAINT); } BoardCanvas::~BoardCanvas() { @@ -29,7 +31,9 @@ BoardCanvas::BoardCanvas(wxFrame *parent, std::uint32_t square_width, } void BoardCanvas::OnPaint(wxPaintEvent &event) { - wxPaintDC dc(this); + wxBufferedPaintDC dc(this); + dc.SetBackground(*wxWHITE_BRUSH); + dc.Clear(); REFRESH_MOUSE_LOCATION(); square_width = t->GetSquaresSizes(); canvas_size = dc.GetSize(); @@ -72,7 +76,7 @@ void BoardCanvas::SetupBoard(std::string board, bool is_black_turn, Refresh(); } -void BoardCanvas::DrawBoard(wxPaintDC &dc) { +void BoardCanvas::DrawBoard(wxBufferedPaintDC &dc) { std::uint32_t piece_width = t->GetPiecesSizes(); std::uint32_t centrer_offset = (square_width - piece_width) / 2; diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp index 83c960a..7645414 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.hpp +++ b/src/game_tab/left_panel/board/BoardCanvas.hpp @@ -7,6 +7,7 @@ #include #include #include +#include // Local events wxDECLARE_EVENT(PLAY_MOVE_EVENT, wxCommandEvent); @@ -56,7 +57,7 @@ public: BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen); ~BoardCanvas(); void ApplyPreferences(); - void DrawBoard(wxPaintDC &dc); + void DrawBoard(wxBufferedPaintDC &dc); void OnPaint(wxPaintEvent &event); void OnKeyEvent(wxKeyEvent &event); void MouseEvent(wxMouseEvent &event);