mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Switch to buffered DC
This commit is contained in:
parent
214d46b8e2
commit
15f713b58e
2 changed files with 8 additions and 3 deletions
|
@ -12,6 +12,8 @@ BoardCanvas::BoardCanvas(wxFrame *parent)
|
||||||
SetClockTime(-1, -1, -1, false);
|
SetClockTime(-1, -1, -1, false);
|
||||||
SetClockTime(-1, -1, -1, true);
|
SetClockTime(-1, -1, -1, true);
|
||||||
ApplyPreferences();
|
ApplyPreferences();
|
||||||
|
// The following should be called when using an EVT_PAINT handler
|
||||||
|
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardCanvas::~BoardCanvas() {
|
BoardCanvas::~BoardCanvas() {
|
||||||
|
@ -29,7 +31,9 @@ BoardCanvas::BoardCanvas(wxFrame *parent, std::uint32_t square_width,
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardCanvas::OnPaint(wxPaintEvent &event) {
|
void BoardCanvas::OnPaint(wxPaintEvent &event) {
|
||||||
wxPaintDC dc(this);
|
wxBufferedPaintDC dc(this);
|
||||||
|
dc.SetBackground(*wxWHITE_BRUSH);
|
||||||
|
dc.Clear();
|
||||||
REFRESH_MOUSE_LOCATION();
|
REFRESH_MOUSE_LOCATION();
|
||||||
square_width = t->GetSquaresSizes();
|
square_width = t->GetSquaresSizes();
|
||||||
canvas_size = dc.GetSize();
|
canvas_size = dc.GetSize();
|
||||||
|
@ -72,7 +76,7 @@ void BoardCanvas::SetupBoard(std::string board, bool is_black_turn,
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardCanvas::DrawBoard(wxPaintDC &dc) {
|
void BoardCanvas::DrawBoard(wxBufferedPaintDC &dc) {
|
||||||
std::uint32_t piece_width = t->GetPiecesSizes();
|
std::uint32_t piece_width = t->GetPiecesSizes();
|
||||||
std::uint32_t centrer_offset = (square_width - piece_width) / 2;
|
std::uint32_t centrer_offset = (square_width - piece_width) / 2;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/artprov.h>
|
#include <wx/artprov.h>
|
||||||
|
#include <wx/dcbuffer.h>
|
||||||
|
|
||||||
// Local events
|
// Local events
|
||||||
wxDECLARE_EVENT(PLAY_MOVE_EVENT, wxCommandEvent);
|
wxDECLARE_EVENT(PLAY_MOVE_EVENT, wxCommandEvent);
|
||||||
|
@ -56,7 +57,7 @@ public:
|
||||||
BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen);
|
BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen);
|
||||||
~BoardCanvas();
|
~BoardCanvas();
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
void DrawBoard(wxPaintDC &dc);
|
void DrawBoard(wxBufferedPaintDC &dc);
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
void OnKeyEvent(wxKeyEvent &event);
|
void OnKeyEvent(wxKeyEvent &event);
|
||||||
void MouseEvent(wxMouseEvent &event);
|
void MouseEvent(wxMouseEvent &event);
|
||||||
|
|
Loading…
Add table
Reference in a new issue