OChess v0.0.2
Programmer's Manual
BoardCanvas Class Reference

This class draws the chess board (squares, pieces, arrows and every other board related components). More...

#include <BoardCanvas.hpp>

Inheritance diagram for BoardCanvas:

Public Member Functions

 BoardCanvas (wxFrame *parent)
 
 BoardCanvas (wxFrame *parent, std::uint32_t square_width, bool frozen)
 
void ApplyPreferences ()
 
void DrawBoard (wxDC &dc)
 Draw current board state BoardCanvas::gs on the given wxDC.
 
void OnPaint (wxPaintEvent &event)
 Callback called by wxWidgets to refresh the canvas.
 
void MouseEvent (wxMouseEvent &event)
 Callback called by wxWidgets to handle mouse events. More...
 
void Zoom (std::int32_t zoom)
 Zomm in/out on the canvas.
 
void Swap ()
 Change between black side and white side.
 
void SetupBoard (const GameState &new_gs)
 Display a position on the canvas.
 
void Animate (const GameState &new_gs, const std::string &src, const std::string &dst, bool faster)
 Animate a piece front src to dst from current position.
 
void SetClockTime (short hours, short min, short sec, bool IsBlack)
 Setup clock on displayed on the canvas.
 

Private Member Functions

void DrawArrow (wxDC &dc, int xsrc, int ysrc, int xdst, int ydst, std::uint8_t thickness=50)
 Draw an arrow from a source point to a destination point on DC.
 
void DrawLArrow (wxDC &dc, int xsrc, int ysrc, int xdst, int ydst, bool flip=false, std::uint8_t thickness=50)
 Draw an arrow with a L shape (such as knight moves)
 

Private Attributes

Themet
 Contains the theme for squares and pieces (see Theme)
 
Themet_captures
 Scale down version of BoardCanvas::t for the captured pieces by black and white.
 
wxColour color_arrows
 Stores the color of the arrows.
 
int arrows_offset
 Offset used for the start point of the arrows (this way, arrows do not completely overlap on the pieces)
 
std::uint8_t arrow_thickness
 Thickness of the arrows.
 
std::string white_player
 Player names.
 
std::string black_player
 
std::vector< GameState::Squaresquares_hl
 Current highlighted squares that were highlighted with the mouse.
 
std::vector< GameState::Arrowarrows
 Current drawn arrows that were drawn with the mouse.
 
bool black_side
 
bool is_dragging
 
bool valid_drag
 
bool arrow_drag
 
bool is_black_turn
 
std::int32_t boardX
 
std::int32_t boardY
 
std::int32_t square_width
 
std::int32_t piece_width
 
std::int32_t mouseX
 
std::int32_t mouseY
 
std::int32_t lastClickX
 
std::int32_t lastClickY
 
wxSize canvas_size
 Contains an up to date dimension of the canvas size and its use in various places.
 
wxPoint active_square
 Used for drag and drop.
 
std::map< char, std::uint8_t > captures
 
bool frozen
 Board can be frozen (to preview the board themes in the preference menu for example)
 
bool lock_square_size
 
AnimState adata
 Current animation state.
 
GameState gs
 Current board state (contains all the game state)
 

Detailed Description

This class draws the chess board (squares, pieces, arrows and every other board related components).

Member Function Documentation

◆ MouseEvent()

void BoardCanvas::MouseEvent ( wxMouseEvent &  event)

Callback called by wxWidgets to handle mouse events.

Play the move


The documentation for this class was generated from the following files: