Public Types | List of all members
cwmm::ChessboardWidget Class Reference

A gtkmm chessboard widget. More...

#include <ChessboardWidget.h>

Inheritance diagram for cwmm::ChessboardWidget:
Inheritance graph
[legend]

Public Types

typedef CwChessboardColorHandle ColorHandle
 A color handle used for background markers. More...
 
typedef CwChessboardCode code_t
 A code to specify a chess piece. More...
 

Public Member Functions

Construction/Destruction
 ChessboardWidget (void)
 Create a ChessboardWidget object.
 
virtual ~ChessboardWidget ()
 Destructor.
 
Accessors
gint sside (void) const
 The side of a square in pixels.
 
gint top_left_a1_x (void) const
 The x coordinate of the top-left pixel of square a1. More...
 
gint top_left_a1_y (void) const
 The y coordinate of the top-left pixel of square a1. More...
 
Chess Position
void set_square (gint col, gint row, code_t code)
 Change the piece on a square. More...
 
code_t get_square (gint col, gint row) const
 Get what is currently on a square. More...
 
Border
void set_draw_border (gboolean draw)
 Set the boolean which determines whether or not the chessboard widget draws a border around the chessboard. More...
 
gboolean get_draw_border (void) const
 Get the boolean that determines whether or not the chessboard widget draws a border around the chessboard. More...
 
void set_draw_turn_indicators (gboolean draw)
 Set the boolean which determines whether or not to draw turn indicators. More...
 
gboolean get_draw_turn_indicators (void) const
 Get the boolean which determines whether or not to draw turn indicators. More...
 
void set_active_turn_indicator (gboolean white)
 Set the color of the active turn indicator. More...
 
gboolean get_active_turn_indicator (void) const
 Get the boolean which determines whether whites or black turn indicator is active. More...
 
void set_flip_board (gboolean flip)
 Set the boolean which determines whether white is playing bottom up or top down. More...
 
gboolean get_flip_board (void) const
 Get the boolean which determines whether white is playing bottom up or top down. More...
 
void set_calc_board_border_width (gint(*new_calc_board_border_width)(CwChessboard const* , gint))
 Set the calc_board_border_width function. More...
 
Colors
void set_dark_square_color (GdkColor const& color)
 Set the color of the dark squares. More...
 
void set_light_square_color (GdkColor const& color)
 Set the color of the light squares. More...
 
void set_border_color (GdkColor const& color)
 Set the color of the border around the chessboard. More...
 
void set_white_fill_color (GdkColor const& color)
 Set the fill color of the white chess pieces. More...
 
void set_white_line_color (GdkColor const& color)
 Set the line color of the white chess pieces. More...
 
void set_black_fill_color (GdkColor const& color)
 Set the fill color of the black chess pieces. More...
 
void set_black_line_color (GdkColor const& color)
 Set the line color of the black chess pieces. More...
 
void get_dark_square_color (GdkColor& color) const
 Retrieve the current background color of the dark squares. More...
 
void get_light_square_color (GdkColor& color) const
 Retrieve the current background color of the light squares. More...
 
void get_border_color (GdkColor& color) const
 Retrieve the current color of the border around the chessboard. More...
 
void get_white_fill_color (GdkColor& color) const
 Retrieve the current fill color of the white chess pieces. More...
 
void get_white_line_color (GdkColor& color) const
 Retrieve the current line color of the white chess pieces. More...
 
void get_black_fill_color (GdkColor& color) const
 Retrieve the current fill color of the black chess pieces. More...
 
void get_black_line_color (GdkColor& color) const
 Retrieve the current line color of the black chess pieces. More...
 
ColorHandle allocate_color_handle_rgb (gdouble red, gdouble green, gdouble blue)
 Allocate a new ColorHandle. More...
 
ColorHandle allocate_color_handle (GdkColor const& color)
 Allocate a new CwChessboardColorHandle. More...
 
void free_color_handle (ColorHandle handle)
 Free up the color handle handle, so it can be reused. More...
 
void set_background_color (gint col, gint row, ColorHandle handle)
 Set the background color of the square at col, row. More...
 
ColorHandle get_background_color (gint col, gint row) const
 Get the current background color handle. More...
 
void set_background_colors (ColorHandle const* handles)
 Set new background colors of any number of squares. More...
 
void get_background_colors (ColorHandle* handles) const
 Get all background colors handles. More...
 
Floating Pieces
gint add_floating_piece (code_t code, gdouble x, gdouble y, gboolean pointer_device)
 Add a new floating chess piece. More...
 
void move_floating_piece (gint handle, gdouble x, gdouble y)
 Move a floating chess piece to a new position. More...
 
void remove_floating_piece (gint handle)
 Remove a floating piece. More...
 
code_t get_floating_piece (gint handle) const
 Determine what piece a given floating piece is. More...
 
HUD Layers
void enable_hud_layer (guint hud)
 Active a HUD layer. More...
 
void disable_hud_layer (guint hud)
 Disable the HUD layer again. More...
 
Markers
void set_marker_color (gint col, gint row, ColorHandle mahandle)
 Change the color of the marker. More...
 
ColorHandle get_marker_color (gint col, gint row) const
 Get marker color. More...
 
void set_marker_thickness (gdouble thickness)
 Set the marker thickness. More...
 
gdouble get_marker_thickness (void) const
 Get the current marker thickness as fraction of sside. More...
 
void set_marker_level (gboolean below)
 Choose whether markers should be drawn below or above HUD layer 0. More...
 
Cursor
void show_cursor (void)
 Show the cursor. More...
 
void hide_cursor (void)
 Hide the cursor. More...
 
void set_cursor_thickness (gdouble thickness)
 Set the thickness of the cursor. More...
 
gdouble get_cursor_thickness (void) const
 Get the current cursor thickness as fraction of sside. More...
 
void set_cursor_color (GdkColor const& color)
 Set the color of the cursor. More...
 
void get_cursor_color (GdkColor& color) const
 Get the current cursor color. More...
 
Arrows
gpointer add_arrow (gint begin_col, gint begin_row, gint end_col, gint end_row, GdkColor const& color)
 Draw an arrow on the board. More...
 
void remove_arrow (gpointer ptr)
 Remove a previously added arrow. More...
 

Protected Member Functions

Events
virtual bool on_button_press_event (GdkEventButton* event)
 Called when the mouse button is pressed while on the chessboard widget. More...
 
virtual bool on_button_release_event (GdkEventButton* event)
 Called when the mouse button is released again. More...
 
virtual void on_cursor_left_chessboard (gint prev_col, gint prev_row)
 Called when the mouse pointer left the chessboard. More...
 
virtual void on_cursor_entered_square (gint prev_col, gint prev_row, gint col, gint row)
 Called when the mouse pointer entered a new square. More...
 
Drawing primitives
virtual void draw_pawn (cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 Called to draw a pawn. More...
 
virtual void draw_rook (cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 Called to draw a rook. More...
 
virtual void draw_knight (cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 Called to draw a knight. More...
 
virtual void draw_bishop (cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 Called to draw a bishop. More...
 
virtual void draw_queen (cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 Called to draw a queen. More...
 
virtual void draw_king (cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 Called to draw a king. More...
 
virtual void draw_hud_layer (cairo_t* cr, gint sside, guint hud)
 Draw the HUD layer. More...
 
virtual gboolean draw_hud_square (cairo_t* cr, gint col, gint row, gint sside, guint hud)
 Draw a single HUD square at col, row. More...
 
virtual void draw_border (void)
 Draw the border around the chessboard. More...
 
virtual void draw_turn_indicator (gboolean white, gboolean on)
 Draw the indicator that indicates whose turn it is. More...
 

Public Conversion Functions

void colrow2xy (gint col, gint row, gint& x, gint& y) const
 Convert a (col, row) pair to the top-left coordinates of the corresponding square, relative to the top-left of the widget. More...
 
gint x2col (gdouble x) const
 Convert an x-coordinate to the column number that it matches. More...
 
gint y2row (gdouble y) const
 Convert a y-coordinate to the row number that it matches. More...
 
static gboolean is_inside_board (gint col, gint row)
 Test if a given column and row are on the chessboard. More...
 

Additional Inherited Members

- Protected Attributes inherited from cwmm::CwChessboardPtr
CwChessboard*  M_chessboard
 

Detailed Description

A gtkmm chessboard widget.

This is a chessboard widget for use with gtkmm.

A detailed overview can be found on the Main Page.

See also
ChessPositionWidget

Definition at line 58 of file ChessboardWidget.h.

Member Typedef Documentation

A code to specify a chess piece.

One of the following constants: empty_square, black_pawn, white_pawn, black_rook, white_rook, black_knight, white_knight, black_bishop, white_bishop, black_queen, white_queen, black_king or white_king.

See also
set_square, floating_piece, get_floating_piece

Definition at line 259 of file ChessboardWidget.h.

A color handle used for background markers.

The five least significant bits determine the color from a user defined color palet, used by the background squares and markers. A value of zero meaning the default background value for that square, or no marker - respectively.

See also
allocate_color_handle_rgb, allocate_color_handle, free_color_handle, set_background_color, get_background_color, set_background_colors, get_background_colors, set_marker_color, get_marker_color

Definition at line 248 of file ChessboardWidget.h.

Member Function Documentation

gpointer cwmm::ChessboardWidget::add_arrow ( gint  begin_col,
gint  begin_row,
gint  end_col,
gint  end_row,
GdkColor const&   color 
)
inline

Draw an arrow on the board.

Parameters
begin_col: The column of the starting square.
begin_row: The row of the starting square.
end_col: The column of the ending square.
end_row: The row of the ending square.
color: The color to draw the arrow in.
Returns
A handle that can be used to remove the arrow again.
See also
remove_arrow

Definition at line 881 of file ChessboardWidget.h.

References cw_chessboard_add_arrow().

Referenced by MyChessboardWidget::on_button_release(), and cwmm::ChessPositionWidget::place().

gint cwmm::ChessboardWidget::add_floating_piece ( code_t  code,
gdouble  x,
gdouble  y,
gboolean  pointer_device 
)
inline

Add a new floating chess piece.

This function displays a chess piece with code code at widget coordinates (x, y). Half the side of a square will be subtracted from the coordinates passed, and the result truncated, in order to determine where to draw the top-left corner of the piece. The result is that (x, y) is more or less the center of the piece.

Setting pointer_device will cause gdk_window_get_pointer to be called after the next redraw has finished. This is needed to receive the next motion notify event with GDK_POINTER_MOTION_HINT_MASK being used.

There may only be one floating piece related the pointer device at a time. If there is already another floating piece related to the pointer device then the value of pointer_device is ignored.

Parameters
code: The code of the chess piece to be drawn.
x: The center x-coordinate of the piece.
y: The center y-coordinate of the piece.
pointer_device: Whether this piece is under the pointer device or not.
Returns
A handle that can be passed to each of the functions below.
See also
get_floating_piece, remove_floating_piece, move_floating_piece

Definition at line 686 of file ChessboardWidget.h.

References cw_chessboard_add_floating_piece().

Referenced by cwmm::ChessPositionWidget::place().

ColorHandle cwmm::ChessboardWidget::allocate_color_handle ( GdkColor const&   color)
inline

Allocate a new CwChessboardColorHandle.

From more information, see allocate_color_handle_rgb.

Parameters
color: The color to allocate.
Returns
A color handle that can be used with set_background_color and set_marker_color.
See also
free_color_handle

Definition at line 603 of file ChessboardWidget.h.

References cw_chessboard_allocate_color_handle().

Referenced by cwmm::ChessPositionWidget::place().

ColorHandle cwmm::ChessboardWidget::allocate_color_handle_rgb ( gdouble  red,
gdouble  green,
gdouble  blue 
)
inline

Allocate a new ColorHandle.

Simultaneous, there can be at most 31 different colors. It is the responsibility of the user to free the colors if they are no longer used.

Parameters
red: The red component of the color in the range [0...1].
green: The green component of the color in the range [0...1].
blue: The blue component of the color in the range [0...1].
Returns
A color handle that can be used with set_background_color and set_marker_color.
See also
allocate_color_handle, free_color_handle

Definition at line 590 of file ChessboardWidget.h.

References cw_chessboard_allocate_color_handle_rgb().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::colrow2xy ( gint  col,
gint  row,
gint&   x,
gint&   y 
) const
inline

Convert a (col, row) pair to the top-left coordinates of the corresponding square, relative to the top-left of the widget.

Parameters
col: A column, in the range [0, 7].
row: A row, in the range [0, 7].
x: A reference to where the x-coordinate of the result will be written to.
y: A reference to where the y-coordinate of the result will be written to.

Definition at line 291 of file ChessboardWidget.h.

References cw_chessboard_colrow2xy().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget().

void cwmm::ChessboardWidget::disable_hud_layer ( guint  hud)
inline

Disable the HUD layer again.

Used resources are returned to the system.

Parameters
hud: The HUD layer (0 or 1).
See also
enable_hud_layer

Definition at line 750 of file ChessboardWidget.h.

References cw_chessboard_disable_hud_layer().

Referenced by cwmm::ChessPositionWidget::place().

virtual void cwmm::ChessboardWidget::draw_bishop ( cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)
inlineprotectedvirtual

Called to draw a bishop.

The default calls cw_chessboard_draw_bishop.

Definition at line 148 of file ChessboardWidget.h.

References cw_chessboard_draw_bishop().

virtual void cwmm::ChessboardWidget::draw_border ( void  )
inlineprotectedvirtual

Draw the border around the chessboard.

This function is called when the border is first drawn, and every time the chessboard is resized. The width of the drawn border should be the value returned by CwChessboardClass::calc_board_border_width.

The default calls cw_chessboard_default_draw_border.

See also
set_draw_border

Definition at line 212 of file ChessboardWidget.h.

References cw_chessboard_default_draw_border().

virtual void cwmm::ChessboardWidget::draw_hud_layer ( cairo_t*   cr,
gint  sside,
guint  hud 
)
inlineprotectedvirtual

Draw the HUD layer.

This is a layer in between the background (existing of the 64 squares with a single color) and the layer with the pieces. It can be used to add some texture to the background.

If the HUD layer is active, then this function is called whenever the widget is resized.

Parameters
cr: A cairo drawing context.
sside: The size of one side of a square, in pixels.
hud: The HUD index number, see the detailed documentation on the main page for more info.

The default calls cw_chessboard_default_draw_hud_layer.

See also
enable_hud_layer, disable_hud_layer

Reimplemented in MyChessboardWidget.

Definition at line 182 of file ChessboardWidget.h.

References cw_chessboard_default_draw_hud_layer().

virtual gboolean cwmm::ChessboardWidget::draw_hud_square ( cairo_t*   cr,
gint  col,
gint  row,
gint  sside,
guint  hud 
)
inlineprotectedvirtual

Draw a single HUD square at col, row.

This function is called by ChessboardWidget::draw_hud_layer for each square. You can use it if you don't override draw_hud_layer.

Parameters
cr: A cairo drawing context.
col: The column of the square.
row: The row of the square.
sside: The size of one side of the square, in pixels.
hud: The HUD index number, see the detailed documentation of main page for more info.
Returns
TRUE if anything was drawn at all, FALSE if the HUD square is fully transparent.

The default calls cw_chessboard_default_draw_hud_square.

Definition at line 200 of file ChessboardWidget.h.

References cw_chessboard_default_draw_hud_square().

virtual void cwmm::ChessboardWidget::draw_king ( cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)
inlineprotectedvirtual

Called to draw a king.

The default calls cw_chessboard_draw_king.

Definition at line 162 of file ChessboardWidget.h.

References cw_chessboard_draw_king().

virtual void cwmm::ChessboardWidget::draw_knight ( cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)
inlineprotectedvirtual

Called to draw a knight.

The default calls cw_chessboard_draw_knight.

Definition at line 141 of file ChessboardWidget.h.

References cw_chessboard_draw_knight().

virtual void cwmm::ChessboardWidget::draw_pawn ( cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)
inlineprotectedvirtual

Called to draw a pawn.

The default calls cw_chessboard_draw_pawn.

Definition at line 127 of file ChessboardWidget.h.

References cw_chessboard_draw_pawn().

virtual void cwmm::ChessboardWidget::draw_queen ( cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)
inlineprotectedvirtual

Called to draw a queen.

The default calls cw_chessboard_draw_queen.

Definition at line 155 of file ChessboardWidget.h.

References cw_chessboard_draw_queen().

virtual void cwmm::ChessboardWidget::draw_rook ( cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)
inlineprotectedvirtual

Called to draw a rook.

The default calls cw_chessboard_draw_rook.

Definition at line 134 of file ChessboardWidget.h.

References cw_chessboard_draw_rook().

virtual void cwmm::ChessboardWidget::draw_turn_indicator ( gboolean  white,
gboolean  on 
)
inlineprotectedvirtual

Draw the indicator that indicates whose turn it is.

This function is called every time the border is redrawn, as well as every time set_draw_turn_indicators is called.

Parameters
whiteTrue if the indicator of the white color has to be drawn.
onTrue if the indictor is on, false if it is off.

The default calls cw_chessboard_default_draw_turn_indicator.

See also
set_draw_border, set_draw_turn_indicators

Definition at line 227 of file ChessboardWidget.h.

References cw_chessboard_default_draw_turn_indicator().

void cwmm::ChessboardWidget::enable_hud_layer ( guint  hud)
inline

Active a HUD layer.

HUD 0 lays between the background and the pieces. HUD 1 lays above the pieces. A custom HUD layer can be created by setting CwChessboardClass::draw_hud_layer.

Parameters
hud: The HUD layer (0 or 1).
See also
CwChessboardClass::draw_hud_layer, disable_hud_layer

Definition at line 739 of file ChessboardWidget.h.

References cw_chessboard_enable_hud_layer().

Referenced by MyChessboardWidget::on_button_press(), and cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::free_color_handle ( ColorHandle  handle)
inline

Free up the color handle handle, so it can be reused.

Parameters
handle: A color handle as returned by allocate_color_handle_rgb or allocate_color_handle.
See also
allocate_color_handle_rgb, allocate_color_handle

Definition at line 612 of file ChessboardWidget.h.

References cw_chessboard_free_color_handle().

Referenced by cwmm::ChessPositionWidget::place().

gboolean cwmm::ChessboardWidget::get_active_turn_indicator ( void  ) const
inline

Get the boolean which determines whether whites or black turn indicator is active.

See also
set_active_turn_indicator

Definition at line 413 of file ChessboardWidget.h.

References cw_chessboard_get_active_turn_indicator().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget().

ColorHandle cwmm::ChessboardWidget::get_background_color ( gint  col,
gint  row 
) const
inline

Get the current background color handle.

Convenience function.

Parameters
col: The column of the square.
row: The row of the square.
Returns
The handle that was passed to set_background_color for this square, or 0 if the square is not associated with a color handle.

Definition at line 637 of file ChessboardWidget.h.

References cw_chessboard_get_background_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_background_colors ( ColorHandle*   handles) const
inline

Get all background colors handles.

Fill the array handles with the current color handles.

Parameters
handles: The output array. Should be an array of 64 ColorHandles.

Definition at line 654 of file ChessboardWidget.h.

References cw_chessboard_get_background_colors().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_black_fill_color ( GdkColor&   color) const
inline

Retrieve the current fill color of the black chess pieces.

Parameters
color: Pointer to the output variable.
See also
set_black_fill_color

Definition at line 565 of file ChessboardWidget.h.

References cw_chessboard_get_black_fill_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_black_line_color ( GdkColor&   color) const
inline

Retrieve the current line color of the black chess pieces.

Parameters
color: Pointer to the output variable.
See also
set_black_line_color

Definition at line 574 of file ChessboardWidget.h.

References cw_chessboard_get_black_line_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_border_color ( GdkColor&   color) const
inline

Retrieve the current color of the border around the chessboard.

Parameters
color: Pointer to the output variable.
See also
set_border_color

Definition at line 538 of file ChessboardWidget.h.

References cw_chessboard_get_border_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_cursor_color ( GdkColor&   color) const
inline

Get the current cursor color.

Parameters
color: Pointer to the output variable.

Definition at line 861 of file ChessboardWidget.h.

References cw_chessboard_get_cursor_color().

Referenced by cwmm::ChessPositionWidget::place().

gdouble cwmm::ChessboardWidget::get_cursor_thickness ( void  ) const
inline

Get the current cursor thickness as fraction of sside.

See also
set_cursor_thickness

Definition at line 847 of file ChessboardWidget.h.

References cw_chessboard_get_cursor_thickness().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_dark_square_color ( GdkColor&   color) const
inline

Retrieve the current background color of the dark squares.

Parameters
color: Pointer to the output variable.
See also
set_dark_square_color

Definition at line 520 of file ChessboardWidget.h.

References cw_chessboard_get_dark_square_color().

Referenced by cwmm::ChessPositionWidget::place().

gboolean cwmm::ChessboardWidget::get_draw_border ( void  ) const
inline

Get the boolean that determines whether or not the chessboard widget draws a border around the chessboard.

Returns
TRUE if the border is being drawn.
See also
set_draw_border

Definition at line 376 of file ChessboardWidget.h.

References cw_chessboard_get_draw_border().

Referenced by cwmm::ChessPositionWidget::place().

gboolean cwmm::ChessboardWidget::get_draw_turn_indicators ( void  ) const
inline

Get the boolean which determines whether or not to draw turn indicators.

See also
set_draw_turn_indicators

Definition at line 395 of file ChessboardWidget.h.

References cw_chessboard_get_draw_turn_indicators().

Referenced by cwmm::ChessPositionWidget::place().

gboolean cwmm::ChessboardWidget::get_flip_board ( void  ) const
inline

Get the boolean which determines whether white is playing bottom up or top down.

See also
set_flip_board

Definition at line 429 of file ChessboardWidget.h.

References cw_chessboard_get_flip_board().

Referenced by cwmm::ChessPositionWidget::place().

code_t cwmm::ChessboardWidget::get_floating_piece ( gint  handle) const
inline

Determine what piece a given floating piece is.

Get the code_t of the floating piece represented by handle. handle must be a handle as returned by add_floating_piece.

Parameters
handle: The floating piece handle.

Definition at line 721 of file ChessboardWidget.h.

References cw_chessboard_get_floating_piece().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_light_square_color ( GdkColor&   color) const
inline

Retrieve the current background color of the light squares.

Parameters
color: Pointer to the output variable.
See also
set_light_square_color

Definition at line 529 of file ChessboardWidget.h.

References cw_chessboard_get_light_square_color().

Referenced by cwmm::ChessPositionWidget::place().

ColorHandle cwmm::ChessboardWidget::get_marker_color ( gint  col,
gint  row 
) const
inline

Get marker color.

Convenience function.

Parameters
col: The column of the square.
row: The row of the square.
Returns
The handle that was passed to set_marker_color for this square, or 0 if the square doesn't have a marker.

Definition at line 780 of file ChessboardWidget.h.

References cw_chessboard_get_marker_color().

Referenced by cwmm::ChessPositionWidget::place().

gdouble cwmm::ChessboardWidget::get_marker_thickness ( void  ) const
inline

Get the current marker thickness as fraction of sside.

See also
set_marker_thickness

Definition at line 798 of file ChessboardWidget.h.

References cw_chessboard_get_marker_thickness().

Referenced by cwmm::ChessPositionWidget::place().

code_t cwmm::ChessboardWidget::get_square ( gint  col,
gint  row 
) const
inline

Get what is currently on a square.

Get the chess piece code for the square at (col, row).

Definition at line 351 of file ChessboardWidget.h.

References cw_chessboard_get_square().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget().

void cwmm::ChessboardWidget::get_white_fill_color ( GdkColor&   color) const
inline

Retrieve the current fill color of the white chess pieces.

Parameters
color: Pointer to the output variable.
See also
set_white_fill_color

Definition at line 547 of file ChessboardWidget.h.

References cw_chessboard_get_white_fill_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::get_white_line_color ( GdkColor&   color) const
inline

Retrieve the current line color of the white chess pieces.

Parameters
color: Pointer to the output variable.
See also
set_white_line_color

Definition at line 556 of file ChessboardWidget.h.

References cw_chessboard_get_white_line_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::hide_cursor ( void  )
inline

Hide the cursor.

See also
show_cursor

Definition at line 829 of file ChessboardWidget.h.

References cw_chessboard_hide_cursor().

Referenced by MyChessboardWidget::on_button_release(), and cwmm::ChessPositionWidget::place().

static gboolean cwmm::ChessboardWidget::is_inside_board ( gint  col,
gint  row 
)
inlinestatic

Test if a given column and row are on the chessboard.

Parameters
col: A column, in the range [0, 7].
row: A row, in the range [0, 7].
Returns
True if (col, row) falls inside the chessboard.

Definition at line 325 of file ChessboardWidget.h.

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget(), and MyChessboardWidget::on_button_release().

void cwmm::ChessboardWidget::move_floating_piece ( gint  handle,
gdouble  x,
gdouble  y 
)
inline

Move a floating chess piece to a new position.

Move a floating piece with handle handle to the new widget coordinates at (x, y). handle must be a handle as returned by add_floating_piece.

Parameters
handle: The floating piece handle.
x: The new x coordinate.
y: The new y coordinate.
See also
add_floating_piece

Definition at line 701 of file ChessboardWidget.h.

References cw_chessboard_move_floating_piece().

Referenced by cwmm::ChessPositionWidget::place().

virtual bool cwmm::ChessboardWidget::on_button_press_event ( GdkEventButton*   event)
inlineprotectedvirtual

Called when the mouse button is pressed while on the chessboard widget.

This function should be overridden. See the example tstcpp.cc in the source code for an example.

Definition at line 92 of file ChessboardWidget.h.

Referenced by ChessboardWidget().

virtual bool cwmm::ChessboardWidget::on_button_release_event ( GdkEventButton*   event)
inlineprotectedvirtual

Called when the mouse button is released again.

This function should be overridden. See the example tstcpp.cc in the source code for an example.

Definition at line 98 of file ChessboardWidget.h.

Referenced by ChessboardWidget().

virtual void cwmm::ChessboardWidget::on_cursor_entered_square ( gint  prev_col,
gint  prev_row,
gint  col,
gint  row 
)
inlineprotectedvirtual

Called when the mouse pointer entered a new square.

Parameters
prev_col: The column of the last square, or -1 if we entered from outside the chessboard.
prev_row: The row of the last square, or -1 if we entered from outside the chessboard.
col: The column of the entered square.
row: The row of the entered square.

Reimplemented in cwmm::ChessPositionWidget.

Definition at line 115 of file ChessboardWidget.h.

virtual void cwmm::ChessboardWidget::on_cursor_left_chessboard ( gint  prev_col,
gint  prev_row 
)
inlineprotectedvirtual

Called when the mouse pointer left the chessboard.

Parameters
prev_col: The column of the last square.
prev_row: The row of the last square.

Reimplemented in cwmm::ChessPositionWidget.

Definition at line 105 of file ChessboardWidget.h.

void cwmm::ChessboardWidget::remove_arrow ( gpointer  ptr)
inline

Remove a previously added arrow.

Parameters
ptr: The arrow handle as returned by add_arrow.

Definition at line 888 of file ChessboardWidget.h.

References cw_chessboard_remove_arrow().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::remove_floating_piece ( gint  handle)
inline

Remove a floating piece.

Delete the floating piece with handle handle. handle must be a handle as returned by add_floating_piece.

Parameters
handle: The floating piece handle.

Definition at line 711 of file ChessboardWidget.h.

References cw_chessboard_remove_floating_piece().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_active_turn_indicator ( gboolean  white)
inline

Set the color of the active turn indicator.

Default: TRUE

Parameters
whiteTRUE if whites turn indicator should be active.
See also
set_draw_turn_indicators

Definition at line 406 of file ChessboardWidget.h.

References cw_chessboard_set_active_turn_indicator().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget(), cwmm::ChessPositionWidget::set_en_passant(), cwmm::ChessPositionWidget::skip_move(), and cwmm::ChessPositionWidget::to_move().

void cwmm::ChessboardWidget::set_background_color ( gint  col,
gint  row,
ColorHandle  handle 
)
inline

Set the background color of the square at col, row.

Parameters
col: The column of the square.
row: The row of the square.
handle: A color handle as returned by allocate_color_handle_rgb or allocate_color_handle. A handle with a value of 0 means the default background color.

Definition at line 623 of file ChessboardWidget.h.

References cw_chessboard_set_background_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_background_colors ( ColorHandle const*   handles)
inline

Set new background colors of any number of squares.

Parameters
handles: Array of 64 ColorHandles. A handle with a value of 0 means the default background color.

Definition at line 645 of file ChessboardWidget.h.

References cw_chessboard_set_background_colors().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_black_fill_color ( GdkColor const&   color)
inline

Set the fill color of the black chess pieces.

Default: black

Parameters
color: The new fill color of the black pieces.

Definition at line 502 of file ChessboardWidget.h.

References cw_chessboard_set_black_fill_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_black_line_color ( GdkColor const&   color)
inline

Set the line color of the black chess pieces.

Default: white

Parameters
color: The new line color of the black pieces.

Definition at line 511 of file ChessboardWidget.h.

References cw_chessboard_set_black_line_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_border_color ( GdkColor const&   color)
inline

Set the color of the border around the chessboard.

Parameters
color: The new color of the border.
See also
get_border_color, set_draw_border

Definition at line 475 of file ChessboardWidget.h.

References cw_chessboard_set_border_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_calc_board_border_width ( gint(*)(CwChessboard const* , gint)  new_calc_board_border_width)
inline

Set the calc_board_border_width function.

Change the function that calculates the border width as function of the size of the squares.

Parameters
new_calc_board_border_width: The new function.
See also
CwChessboardClass::calc_board_border_width

Definition at line 440 of file ChessboardWidget.h.

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_cursor_color ( GdkColor const&   color)
inline

Set the color of the cursor.

Parameters
color: The color to be used for the cursor.

Definition at line 854 of file ChessboardWidget.h.

References cw_chessboard_set_cursor_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_cursor_thickness ( gdouble  thickness)
inline

Set the thickness of the cursor.

This is a value between 0 and 0.5.

Parameters
thickness: The thickness of the cursor as fraction of sside. Range [0...0.5]
See also
get_cursor_thickness

Definition at line 840 of file ChessboardWidget.h.

References cw_chessboard_set_cursor_thickness().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_dark_square_color ( GdkColor const&   color)
inline

Set the color of the dark squares.

Set the background color of the dark squares (a1, c1 etc). Default: light green.

Parameters
color: The new color of the dark squares.

Definition at line 456 of file ChessboardWidget.h.

References cw_chessboard_set_dark_square_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_draw_border ( gboolean  draw)
inline

Set the boolean which determines whether or not the chessboard widget draws a border around the chessboard.

Default: TRUE (draw border).

Parameters
draw: Boolean, determining if the border should be drawn.
See also
draw_border

Definition at line 367 of file ChessboardWidget.h.

References cw_chessboard_set_draw_border().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_draw_turn_indicators ( gboolean  draw)
inline

Set the boolean which determines whether or not to draw turn indicators.

Indicators will only be drawn if also the border is drawn. Default: TRUE (draw indicators).

Parameters
drawBoolean, determining if the indicators should be drawn.
See also
set_draw_border, draw_turn_indicator

Definition at line 388 of file ChessboardWidget.h.

References cw_chessboard_set_draw_turn_indicators().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_flip_board ( gboolean  flip)
inline

Set the boolean which determines whether white is playing bottom up or top down.

Default: FALSE (white plays upwards).

Parameters
flipBoolean, determining if white plays upwards or not.

Definition at line 422 of file ChessboardWidget.h.

References cw_chessboard_set_flip_board().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_light_square_color ( GdkColor const&   color)
inline

Set the color of the light squares.

Set the background color of the light squares (b1, d1 etc). Default: yellow/white.

Parameters
color: The new color of the light squares.

Definition at line 466 of file ChessboardWidget.h.

References cw_chessboard_set_light_square_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_marker_color ( gint  col,
gint  row,
ColorHandle  mahandle 
)
inline

Change the color of the marker.

Add a marker to, or remove a marker from the square at col, row.

Parameters
col: The column of the square.
row: The row of the square.
mahandle: A color handle as returned by allocate_color_handle_rgb or allocate_color_handle. A handle with a value of 0 removes the marker (if any was there).

Definition at line 767 of file ChessboardWidget.h.

References cw_chessboard_set_marker_color().

Referenced by MyChessboardWidget::on_button_press(), MyChessboardWidget::on_button_release(), and cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_marker_level ( gboolean  below)
inline

Choose whether markers should be drawn below or above HUD layer 0.

Markers can be drawn directly below or directly above HUD layer 0.

Parameters
below: TRUE when markers should be drawn below HUD layer 0.

Definition at line 807 of file ChessboardWidget.h.

References cw_chessboard_set_marker_level().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_marker_thickness ( gdouble  thickness)
inline

Set the marker thickness.

This is a value between 0 and 0.5.

Parameters
thickness: The thickness of the marker as fraction of sside. Range [0...0.5]
See also
get_marker_thickness

Definition at line 791 of file ChessboardWidget.h.

References cw_chessboard_set_marker_thickness().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_square ( gint  col,
gint  row,
code_t  code 
)
inline

Change the piece on a square.

Change or remove the piece on the square (col, row), by replacing the contents of the square with code. This does not change any other attribute of the square, like it's background color or marker.

Parameters
col: A column [0..7]
row: A row [0..7]
code: A code_t.

Definition at line 344 of file ChessboardWidget.h.

References cw_chessboard_set_square().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget(), and cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_white_fill_color ( GdkColor const&   color)
inline

Set the fill color of the white chess pieces.

Default: white

Parameters
color: The new fill color of the white pieces.

Definition at line 484 of file ChessboardWidget.h.

References cw_chessboard_set_white_fill_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::set_white_line_color ( GdkColor const&   color)
inline

Set the line color of the white chess pieces.

Default: black

Parameters
color: The new line color of the white pieces.

Definition at line 493 of file ChessboardWidget.h.

References cw_chessboard_set_white_line_color().

Referenced by cwmm::ChessPositionWidget::place().

void cwmm::ChessboardWidget::show_cursor ( void  )
inline

Show the cursor.

This high-lights the square under the mouse by drawing a square with a configurable thickness and color.

See also
set_cursor_thickness, get_cursor_thickness

Definition at line 822 of file ChessboardWidget.h.

References cw_chessboard_show_cursor().

Referenced by MyChessboardWidget::on_button_press(), MyChessboardWidget::on_button_release(), and cwmm::ChessPositionWidget::place().

gint cwmm::ChessboardWidget::top_left_a1_x ( void  ) const
inline

The x coordinate of the top-left pixel of square a1.

If the board is flipped, then the x coordinate of the top-left pixel of square h8 is returned. In other words, this value is not depending on whether or not the board is flipped.

Definition at line 271 of file ChessboardWidget.h.

Referenced by cwmm::ChessPositionWidget::place().

gint cwmm::ChessboardWidget::top_left_a1_y ( void  ) const
inline

The y coordinate of the top-left pixel of square a1.

If the board is flipped, then the y coordinate of the top-left pixel of square h8 is returned. In other words, this value is not depending on whether or not the board is flipped.

Definition at line 277 of file ChessboardWidget.h.

Referenced by cwmm::ChessPositionWidget::place().

gint cwmm::ChessboardWidget::x2col ( gdouble  x) const
inline

Convert an x-coordinate to the column number that it matches.

If the x coordinate falls outside the board, then the returned value will be outside the range [0, 7].

Parameters
x: An x coordinate, relative to the left-side of the widget.
Returns
A column number.

Definition at line 303 of file ChessboardWidget.h.

References cw_chessboard_x2col().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget().

gint cwmm::ChessboardWidget::y2row ( gdouble  y) const
inline

Convert a y-coordinate to the row number that it matches.

If the y coordinate falls outside the board, then the returned value will be outside the range [0, 7].

Parameters
y: A y coordinate, relative to the top-side of the widget.
Returns
A row number.

Definition at line 315 of file ChessboardWidget.h.

References cw_chessboard_y2row().

Referenced by cwmm::ChessPositionWidget::ChessPositionWidget().


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

Copyright © 2006 - 2010 Carlo Wood.  All rights reserved.