Classes | Macros | Typedefs | Functions
CwChessboard.h File Reference

This file contains the declaration of the GTK+ widget CwChessboard. More...

#include <math.h>
#include <glib.h>
#include <gtk/gtkdrawingarea.h>
#include "CwChessboardCodes.h"
Include dependency graph for CwChessboard.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CwChessboard
 A GTK+ chessboard widget. More...
 
struct  CwChessboardClass
 The Class structure of CwChessboard. More...
 

Macros

#define CWCHESSBOARD_INLINE
 
#define CWCHESSBOARD_DEFINE_INLINE   0
 
#define CW_TYPE_CHESSBOARD   (cw_chessboard_get_type())
 
#define CW_CHESSBOARD(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), CW_TYPE_CHESSBOARD, CwChessboard))
 
#define CW_CHESSBOARD_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), CW_TYPE_CHESSBOARD, CwChessboardClass))
 
#define CW_IS_CHESSBOARD(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CW_TYPE_CHESSBOARD))
 
#define CW_IS_CHESSBOARD_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), CW_TYPE_CHESSBOARD))
 
#define CW_CHESSBOARD_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), CW_TYPE_CHESSBOARD, CwChessboardClass))
 

Typedefs

typedef struct _CwChessboard CwChessboard
 
typedef struct _CwChessboardClass CwChessboardClass
 
typedef struct _CwChessboardPrivate CwChessboardPrivate
 
typedef unsigned char CwChessboardColorHandle
 A color handle used for background markers. More...
 

Functions

G_BEGIN_DECLS GType cw_chessboard_get_type (void) G_GNUC_CONST
 
CWCHESSBOARD_INLINE void cw_chessboard_colrow2xy (CwChessboard* chessboard, gint col, gint row, gint* x, gint* y)
 
CWCHESSBOARD_INLINE gint cw_chessboard_x2col (CwChessboard* chessboard, gdouble x)
 
CWCHESSBOARD_INLINE gint cw_chessboard_y2row (CwChessboard* chessboard, gdouble y)
 
Creation
GtkWidget*  cw_chessboard_new (void)
 
Chess Position
void cw_chessboard_set_square (CwChessboard* chessboard, gint col, gint row, CwChessboardCode code)
 
CwChessboardCode cw_chessboard_get_square (CwChessboard* chessboard, gint col, gint row)
 
Border
void cw_chessboard_set_draw_border (CwChessboard* chessboard, gboolean draw)
 
void cw_chessboard_set_draw_turn_indicators (CwChessboard* chessboard, gboolean draw)
 
void cw_chessboard_set_active_turn_indicator (CwChessboard* chessboard, gboolean white)
 
void cw_chessboard_set_flip_board (CwChessboard* chessboard, gboolean flip)
 
gboolean cw_chessboard_get_draw_border (CwChessboard* chessboard)
 
gboolean cw_chessboard_get_draw_turn_indicators (CwChessboard* chessboard)
 
gboolean cw_chessboard_get_active_turn_indicator (CwChessboard* chessboard)
 
gboolean cw_chessboard_get_flip_board (CwChessboard* chessboard)
 
gint cw_chessboard_default_calc_board_border_width (CwChessboard const* chessboard, gint sside)
 
Colors
void cw_chessboard_set_dark_square_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_set_light_square_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_set_border_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_set_white_fill_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_set_white_line_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_set_black_fill_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_set_black_line_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_get_dark_square_color (CwChessboard* chessboard, GdkColor* color)
 
void cw_chessboard_get_light_square_color (CwChessboard* chessboard, GdkColor* color)
 
void cw_chessboard_get_border_color (CwChessboard* chessboard, GdkColor* color)
 
void cw_chessboard_get_white_fill_color (CwChessboard* chessboard, GdkColor* color)
 
void cw_chessboard_get_white_line_color (CwChessboard* chessboard, GdkColor* color)
 
void cw_chessboard_get_black_fill_color (CwChessboard* chessboard, GdkColor* color)
 
void cw_chessboard_get_black_line_color (CwChessboard* chessboard, GdkColor* color)
 
CwChessboardColorHandle cw_chessboard_allocate_color_handle_rgb (CwChessboard* chessboard, gdouble red, gdouble green, gdouble blue)
 
CWCHESSBOARD_INLINE CwChessboardColorHandle cw_chessboard_allocate_color_handle (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_free_color_handle (CwChessboard* chessboard, CwChessboardColorHandle handle)
 
void cw_chessboard_set_background_color (CwChessboard* chessboard, gint col, gint row, CwChessboardColorHandle handle)
 
CwChessboardColorHandle cw_chessboard_get_background_color (CwChessboard* chessboard, gint col, gint row)
 
void cw_chessboard_set_background_colors (CwChessboard* chessboard, CwChessboardColorHandle const* handles)
 
void cw_chessboard_get_background_colors (CwChessboard* chessboard, CwChessboardColorHandle* handles)
 
Floating Pieces
gint cw_chessboard_add_floating_piece (CwChessboard* chessboard, CwChessboardCode code, gdouble x, gdouble y, gboolean pointer_device)
 
void cw_chessboard_move_floating_piece (CwChessboard* chessboard, gint handle, gdouble x, gdouble y)
 
void cw_chessboard_remove_floating_piece (CwChessboard* chessboard, gint handle)
 
CwChessboardCode cw_chessboard_get_floating_piece (CwChessboard* chessboard, gint handle)
 
Default Drawing Functions
void cw_chessboard_draw_pawn (CwChessboard* chessboard, cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 
void cw_chessboard_draw_rook (CwChessboard* chessboard, cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 
void cw_chessboard_draw_knight (CwChessboard* chessboard, cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 
void cw_chessboard_draw_bishop (CwChessboard* chessboard, cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 
void cw_chessboard_draw_queen (CwChessboard* chessboard, cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 
void cw_chessboard_draw_king (CwChessboard* chessboard, cairo_t* cr, gdouble x, gdouble y, gdouble sside, gboolean white)
 
void cw_chessboard_default_draw_hud_layer (CwChessboard* chessboard, cairo_t* cr, gint sside, guint hud)
 
gboolean cw_chessboard_default_draw_hud_square (CwChessboard* chessboard, cairo_t* cr, gint col, gint row, gint sside, guint hud)
 
void cw_chessboard_default_draw_border (CwChessboard* chessboard)
 
void cw_chessboard_default_draw_turn_indicator (CwChessboard* chessboard, gboolean white, gboolean on)
 
HUD Layers
void cw_chessboard_enable_hud_layer (CwChessboard* chessboard, guint hud)
 
void cw_chessboard_disable_hud_layer (CwChessboard* chessboard, guint hud)
 
Markers
void cw_chessboard_set_marker_color (CwChessboard* chessboard, gint col, gint row, CwChessboardColorHandle mahandle)
 
CwChessboardColorHandle cw_chessboard_get_marker_color (CwChessboard* chessboard, gint col, gint row)
 
void cw_chessboard_set_marker_thickness (CwChessboard* chessboard, gdouble thickness)
 
gdouble cw_chessboard_get_marker_thickness (CwChessboard* chessboard)
 
void cw_chessboard_set_marker_level (CwChessboard* chessboard, gboolean below)
 
Cursor
void cw_chessboard_show_cursor (CwChessboard* chessboard)
 
void cw_chessboard_hide_cursor (CwChessboard* chessboard)
 
void cw_chessboard_set_cursor_thickness (CwChessboard* chessboard, gdouble thickness)
 
gdouble cw_chessboard_get_cursor_thickness (CwChessboard* chessboard)
 
void cw_chessboard_set_cursor_color (CwChessboard* chessboard, GdkColor const* color)
 
void cw_chessboard_get_cursor_color (CwChessboard* chessboard, GdkColor* color)
 
Arrows
gpointer cw_chessboard_add_arrow (CwChessboard* chessboard, gint begin_col, gint begin_row, gint end_col, gint end_row, GdkColor const* color)
 
void cw_chessboard_remove_arrow (CwChessboard* chessboard, gpointer ptr)
 

Detailed Description

This file contains the declaration of the GTK+ widget CwChessboard.

arrowsandmarkers.png

Definition in file CwChessboard.h.

Typedef Documentation

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
cw_chessboard_allocate_color_handle_rgb, cw_chessboard_allocate_color_handle, cw_chessboard_free_color_handle, cw_chessboard_set_background_color, cw_chessboard_get_background_color, cw_chessboard_set_background_colors, cw_chessboard_get_background_colors, cw_chessboard_set_marker_color, cw_chessboard_get_marker_color

Definition at line 79 of file CwChessboard.h.

Function Documentation

gpointer cw_chessboard_add_arrow ( CwChessboard*   chessboard,
gint  begin_col,
gint  begin_row,
gint  end_col,
gint  end_row,
GdkColor const*   color 
)

Draw an arrow on the board.

Parameters
chessboardA CwChessboard.
begin_colThe column of the starting square.
begin_rowThe row of the starting square.
end_colThe column of the ending square.
end_rowThe row of the ending square.
colorThe color to draw the arrow in.
Returns
A handle that can be used to remove the arrow again.
See also
cw_chessboard_remove_arrow

Definition at line 2303 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::add_arrow().

gint cw_chessboard_add_floating_piece ( CwChessboard*   chessboard,
CwChessboardCode  code,
gdouble  x,
gdouble  y,
gboolean  pointer_device 
)

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
chessboardA CwChessboard.
codeThe code of the chess piece to be drawn.
xThe center x-coordinate of the piece.
yThe center y-coordinate of the piece.
pointer_deviceWhether this piece is under the pointer device or not.
Returns
A handle that can be passed to each of the functions below.
See also
cw_chessboard_get_floating_piece, cw_chessboard_remove_floating_piece, cw_chessboard_move_floating_piece

Definition at line 2098 of file CwChessboard.cc.

References empty_square.

Referenced by cwmm::ChessboardWidget::add_floating_piece().

CWCHESSBOARD_INLINE CwChessboardColorHandle cw_chessboard_allocate_color_handle ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Allocate a new CwChessboardColorHandle. From more information, see cw_chessboard_allocate_color_handle_rgb.

Parameters
chessboardA CwChessboard.
colorThe color to allocate.
Returns
A color handle that can be used with cw_chessboard_set_background_color and cw_chessboard_set_marker_color.
See also
cw_chessboard_free_color_handle

Referenced by cwmm::ChessboardWidget::allocate_color_handle().

CwChessboardColorHandle cw_chessboard_allocate_color_handle_rgb ( CwChessboard*   chessboard,
gdouble  red,
gdouble  green,
gdouble  blue 
)

Allocate a new CwChessboardColorHandle. 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
chessboardA CwChessboard.
redThe red component of the color in the range [0...1].
greenThe green component of the color in the range [0...1].
blueThe blue component of the color in the range [0...1].
Returns
A color handle that can be used with cw_chessboard_set_background_color and cw_chessboard_set_marker_color.
See also
cw_chessboard_allocate_color_handle, cw_chessboard_free_color_handle

Definition at line 1645 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::allocate_color_handle_rgb().

CWCHESSBOARD_INLINE void cw_chessboard_colrow2xy ( CwChessboard*   chessboard,
gint  col,
gint  row,
gint*   x,
gint*   y 
)

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

Parameters
chessboardA CwChessboard.
colA column, in the range [0, 7].
rowA row, in the range [0, 7].
xA pointer to where the x-coordinate of the result will be written to.
yA pointer to where the y-coordinate of the result will be written to.

Referenced by cwmm::ChessboardWidget::colrow2xy().

gint cw_chessboard_default_calc_board_border_width ( CwChessboard const*   chessboard,
gint  sside 
)

This is the default value of CwChessboardClass::calc_board_border_width. The formula used by this default function is MAX(8.0, round(1.0 + (sside - 12) / 25.0) + sside / 3.0).

Parameters
chessboardA CwChessboard.
ssideThe size of one side of a square in pixels.
Returns
The border width in pixels.
See also
CwChessboardClass::calc_board_border_width

Definition at line 1401 of file CwChessboard.cc.

References cw_chessboard_default_draw_hud_square().

void cw_chessboard_default_draw_border ( CwChessboard*   chessboard)

This is the default value of CwChessboardClass::draw_border.

Parameters
chessboardA CwChessboard.

Definition at line 750 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::draw_border().

void cw_chessboard_default_draw_hud_layer ( CwChessboard*   chessboard,
cairo_t*   cr,
gint  sside,
guint  hud 
)

The default CwChessboardClass::draw_hud_layer function. You can restore the default behaviour with:

1 CW_CHESSBOARD_GET_CLASS(chessboard)->draw_hud_layer = cw_chessboard_default_draw_hud_layer;
Parameters
chessboardA CwChessboard.
crThe cairo drawing context.
ssideThe side of one square in pixels.
hudThe HUD layer (0 or 1).

This function calls CwChessboardClass::draw_hud_square for every square.

Definition at line 1452 of file CwChessboard.cc.

References cwchess::col_mask, cw_chessboard_default_draw_hud_layer(), and cwchess::row_mask.

Referenced by cw_chessboard_default_draw_hud_layer(), and cwmm::ChessboardWidget::draw_hud_layer().

gboolean cw_chessboard_default_draw_hud_square ( CwChessboard*   chessboard,
cairo_t*   cr,
gint  col,
gint  row,
gint  sside,
guint  hud 
)

The default CwChessboardClass::draw_hud_square function. This function is only used by cw_chessboard_default_draw_hud_layer. You can restore the default behaviour of cw_chessboard_default_draw_hud_layer with:

1 CW_CHESSBOARD_GET_CLASS(chessboard)->draw_hud_square = cw_chessboard_default_draw_hud_square;

This function hatches the dark squares with fine, diagonal lines.

Parameters
chessboardA CwChessboard.
crThe cairo drawing context.
colThe column of the square.
rowThe row of the square.
ssideThe side of one square in pixels.
hudThe HUD layer (0 or 1).
Returns
TRUE if anything was drawn. FALSE otherwise.

Referenced by cw_chessboard_default_calc_board_border_width(), and cwmm::ChessboardWidget::draw_hud_square().

void cw_chessboard_default_draw_turn_indicator ( CwChessboard*   chessboard,
gboolean  white,
gboolean  on 
)

This is the default value of CwChessboardClass::draw_turn_indicator.

Parameters
chessboardA CwChessboard.
whiteTRUE if it's whites indicator.
onTRUE if the indicator has to be drawn, FALSE if the indicator has to be removed.

Definition at line 838 of file CwChessboard.cc.

References cw_chessboard_disable_hud_layer(), cw_chessboard_enable_hud_layer(), CwChessboard::sside, CwChessboard::top_left_a1_x, and CwChessboard::top_left_a1_y.

Referenced by cwmm::ChessboardWidget::draw_turn_indicator().

void cw_chessboard_disable_hud_layer ( CwChessboard*   chessboard,
guint  hud 
)

Disable the HUD layer again. Used resources are returned to the system.

Parameters
chessboardA CwChessboard.
hudThe HUD layer (0 or 1).
See also
cw_chessboard_enable_hud_layer

Definition at line 2216 of file CwChessboard.cc.

Referenced by cw_chessboard_default_draw_turn_indicator(), and cwmm::ChessboardWidget::disable_hud_layer().

void cw_chessboard_draw_bishop ( CwChessboard*   chessboard,
cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)

This is the default function used by CwChessboard to draw a bishop.

bishop.png

See cw_chessboard_draw_pawn for more details.

Definition at line 3148 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::draw_bishop().

void cw_chessboard_draw_king ( CwChessboard*   chessboard,
cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)

This is the default function used by CwChessboard to draw a king.

king.png

See cw_chessboard_draw_pawn for more details.

Definition at line 2475 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::draw_king().

void cw_chessboard_draw_knight ( CwChessboard*   chessboard,
cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)

This is the default function used by CwChessboard to draw a knight.

knight.png

See cw_chessboard_draw_pawn for more details.

Definition at line 3484 of file CwChessboard.cc.

References cw_chessboard_move_floating_piece(), and CwChessboard::sside.

Referenced by cwmm::ChessboardWidget::draw_knight().

void cw_chessboard_draw_pawn ( CwChessboard*   chessboard,
cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)

This is the default function used by CwChessboard to draw pawns.

If white is set, a white pawn will be drawn. Otherwise a black pawn.

cw_chessboard_draw_pawn is the default function called via a call to CwChessboardClass::draw_piece. It is called every time the chessboard is resized.

The function uses vector graphics (by doing direct calls to cairo), and is therefore capable of drawing the piece in any arbitrary size and uses anti-aliasing.

pawn.png
Parameters
chessboardA CwChessboard.
crThe cairo drawing context.
xThe (widget) x-coordinate of the center of the piece.
yThe (widget) y-coordinate of the center of the piece.
ssideThe assumed side of a square, in pixels. chessboard->sside is ignored, so that this function can be used to draw pieces elsewhere with a different size than what is used on the chessboard.
whiteA boolean that determines if a black or white piece is drawn.

Definition at line 2394 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::draw_pawn().

void cw_chessboard_draw_queen ( CwChessboard*   chessboard,
cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)

This is the default function used by CwChessboard to draw a queen.

queen.png

See cw_chessboard_draw_pawn for more details.

Definition at line 2706 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::draw_queen().

void cw_chessboard_draw_rook ( CwChessboard*   chessboard,
cairo_t*   cr,
gdouble  x,
gdouble  y,
gdouble  sside,
gboolean  white 
)

This is the default function used by CwChessboard to draw a rook.

rook.png

See cw_chessboard_draw_pawn for more details.

Definition at line 3021 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::draw_rook().

void cw_chessboard_enable_hud_layer ( CwChessboard*   chessboard,
guint  hud 
)

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
chessboardA CwChessboard.
hudThe HUD layer (0 or 1).
See also
CwChessboardClass::draw_hud_layer, cw_chessboard_disable_hud_layer

Definition at line 2209 of file CwChessboard.cc.

Referenced by cw_chessboard_default_draw_turn_indicator(), and cwmm::ChessboardWidget::enable_hud_layer().

void cw_chessboard_free_color_handle ( CwChessboard*   chessboard,
CwChessboardColorHandle  handle 
)

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

Parameters
chessboardA CwChessboard.
handleA color handle as returned by cw_chessboard_allocate_color_handle_rgb or cw_chessboard_allocate_color_handle.
See also
cw_chessboard_allocate_color_handle_rgb, cw_chessboard_allocate_color_handle

Definition at line 1663 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::free_color_handle().

gboolean cw_chessboard_get_active_turn_indicator ( CwChessboard*   chessboard)

Get the boolean that detemines which turn indicator is active (blacks or whites).

Parameters
chessboardA CwChessboard.
Returns
TRUE if whites turn indicator is active (independent on whether or not it is being drawn).
See also
cw_chessboard_set_active_turn_indicator

Definition at line 1835 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_active_turn_indicator().

CwChessboardColorHandle cw_chessboard_get_background_color ( CwChessboard*   chessboard,
gint  col,
gint  row 
)

Convenience function.

Parameters
chessboardA CwChessboard.
colThe column of the square.
rowThe row of the square.
Returns
The handle that was passed to cw_chessboard_set_background_color for this square, or 0 if the square is not associated with a color handle.

Definition at line 1720 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_background_color().

void cw_chessboard_get_background_colors ( CwChessboard*   chessboard,
CwChessboardColorHandle*   handles 
)

Fill the array handles with the current color handles.

Parameters
chessboardA CwChessboard.
handlesThe output array. Should be an array of 64 CwChessboardColorHandles.

Definition at line 1734 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_background_colors().

void cw_chessboard_get_black_fill_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current fill color of the black chess pieces.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_black_fill_color

Definition at line 1938 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_black_fill_color().

void cw_chessboard_get_black_line_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current line color of the black chess pieces.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_black_line_color

Definition at line 1956 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_black_line_color().

void cw_chessboard_get_border_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current color of the border around the chessboard.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_border_color

Definition at line 1884 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_border_color().

void cw_chessboard_get_cursor_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Get the current cursor color.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.

Definition at line 1973 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_cursor_color().

gdouble cw_chessboard_get_cursor_thickness ( CwChessboard*   chessboard)

Get the current cursor thickness as fraction of sside.

Parameters
chessboardA CwChessboard.
See also
cw_chessboard_set_cursor_thickness

Definition at line 1989 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_cursor_thickness().

void cw_chessboard_get_dark_square_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current background color of the dark squares.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_dark_square_color

Definition at line 1849 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_dark_square_color().

gboolean cw_chessboard_get_draw_border ( CwChessboard*   chessboard)

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

Parameters
chessboardA CwChessboard.
Returns
TRUE if the border is being drawn.
See also
cw_chessboard_set_draw_border

Definition at line 1773 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_draw_border().

gboolean cw_chessboard_get_draw_turn_indicators ( CwChessboard*   chessboard)

Get the boolean that determines whether or not turn indicators are being drawn.

Parameters
chessboardA CwChessboard.
Returns
TRUE if turn indicators are being drawn.
See also
cw_chessboard_set_draw_turn_indicators

Definition at line 1815 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_draw_turn_indicators().

gboolean cw_chessboard_get_flip_board ( CwChessboard*   chessboard)

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

Parameters
chessboardA CwChessboard.
Returns
FALSE if white plays upwards and TRUE if white plays downwards.
See also
cw_chessboard_set_flip_board

Definition at line 1796 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_flip_board().

CwChessboardCode cw_chessboard_get_floating_piece ( CwChessboard*   chessboard,
gint  handle 
)

Get the CwChessboardCode of the floating piece represented by handle. handle must be a handle as returned by cw_chessboard_add_floating_piece.

Parameters
chessboardA CwChessboard.
handleThe floating piece handle.

Definition at line 2203 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_floating_piece().

void cw_chessboard_get_light_square_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current background color of the light squares.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_light_square_color

Definition at line 1866 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_light_square_color().

CwChessboardColorHandle cw_chessboard_get_marker_color ( CwChessboard*   chessboard,
gint  col,
gint  row 
)

Convenience function.

Parameters
chessboardA CwChessboard.
colThe column of the square.
rowThe row of the square.
Returns
The handle that was passed to cw_chessboard_set_marker_color for this square, or 0 if the square doesn't have a marker.

Definition at line 1686 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_marker_color().

gdouble cw_chessboard_get_marker_thickness ( CwChessboard*   chessboard)

Get the current marker thickness as fraction of sside.

Parameters
chessboardA CwChessboard.
See also
cw_chessboard_set_marker_thickness

Definition at line 1699 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_marker_thickness().

CwChessboardCode cw_chessboard_get_square ( CwChessboard*   chessboard,
gint  col,
gint  row 
)

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

Definition at line 1755 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_square().

void cw_chessboard_get_white_fill_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current fill color of the white chess pieces.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_white_fill_color

Definition at line 1902 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_white_fill_color().

void cw_chessboard_get_white_line_color ( CwChessboard*   chessboard,
GdkColor*   color 
)

Retrieve the current line color of the white chess pieces.

Parameters
chessboardA CwChessboard.
colorPointer to the output variable.
See also
cw_chessboard_set_white_line_color

Definition at line 1920 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::get_white_line_color().

void cw_chessboard_hide_cursor ( CwChessboard*   chessboard)

Hide the cursor.

Parameters
chessboardA CwChessboard.
See also
cw_chessboard_show_cursor

Definition at line 2008 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::hide_cursor().

void cw_chessboard_move_floating_piece ( CwChessboard*   chessboard,
gint  handle,
gdouble  x,
gdouble  y 
)

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

Parameters
chessboardA CwChessboard.
handleThe floating piece handle.
xThe new x coordinate.
yThe new y coordinate.
See also
cw_chessboard_add_floating_piece

Definition at line 2015 of file CwChessboard.cc.

References cw_chessboard_x2col(), and cw_chessboard_y2row().

Referenced by cw_chessboard_draw_knight(), and cwmm::ChessboardWidget::move_floating_piece().

GtkWidget* cw_chessboard_new ( void  )

Create a new chessboard widget.

Returns
Newly created CwChessboard.

Definition at line 1639 of file CwChessboard.cc.

void cw_chessboard_remove_arrow ( CwChessboard*   chessboard,
gpointer  ptr 
)

Remove a previously added arrow.

Parameters
chessboardA CwChessboard.
ptrThe arrow handle as returned by cw_chessboard_add_arrow.

Definition at line 2328 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::remove_arrow().

void cw_chessboard_remove_floating_piece ( CwChessboard*   chessboard,
gint  handle 
)

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

Parameters
chessboardA CwChessboard.
handleThe floating piece handle.

Definition at line 2143 of file CwChessboard.cc.

References cw_chessboard_x2col(), cw_chessboard_y2row(), and empty_square.

Referenced by cwmm::ChessboardWidget::remove_floating_piece().

void cw_chessboard_set_active_turn_indicator ( CwChessboard*   chessboard,
gboolean  white 
)

Set the boolean that detemines which turn indicator is active (blacks or whites). If drawing turn indicators is enabled and the color is changed then the old indicator is erased. If the turn indicators are disabled, nothing happens.

Parameters
chessboardA CwChessboard.
whiteTRUE if the white turn indicator should be on (and blacks off).
See also
cw_chessboard_set_draw_turn_indicators

Definition at line 1820 of file CwChessboard.cc.

References cwchess::white.

Referenced by cwmm::ChessboardWidget::set_active_turn_indicator().

void cw_chessboard_set_background_color ( CwChessboard*   chessboard,
gint  col,
gint  row,
CwChessboardColorHandle  handle 
)

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

Parameters
chessboardA CwChessboard.
colThe column of the square.
rowThe row of the square.
handleA color handle as returned by cw_chessboard_allocate_color_handle_rgb or cw_chessboard_allocate_color_handle. A handle with a value of 0 means the default background color.

Definition at line 1709 of file CwChessboard.cc.

Referenced by cw_chessboard_set_background_colors(), and cwmm::ChessboardWidget::set_background_color().

void cw_chessboard_set_background_colors ( CwChessboard*   chessboard,
CwChessboardColorHandle const*   handles 
)

Set new background colors of any number of squares.

Parameters
chessboardA CwChessboard.
handlesArray of 64 CwChessboardColorHandles. A handle with a value of 0 means the default background color.

Definition at line 1725 of file CwChessboard.cc.

References cw_chessboard_set_background_color().

Referenced by cwmm::ChessboardWidget::set_background_colors().

void cw_chessboard_set_black_fill_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Set the fill color of the black chess pieces. Default: black

Parameters
chessboardA CwChessboard.
colorThe new fill color of the black pieces.

Definition at line 1928 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_black_fill_color().

void cw_chessboard_set_black_line_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Set the line color of the black chess pieces. Default: white

Parameters
chessboardA CwChessboard.
colorThe new line color of the black pieces.

Definition at line 1946 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_black_line_color().

void cw_chessboard_set_border_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Set the color of the border around the chessboard.

Parameters
chessboardA CwChessboard.
colorThe new color of the border.
See also
cw_chessboard_get_border_color, cw_chessboard_set_draw_border

Definition at line 1874 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_border_color().

void cw_chessboard_set_cursor_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Set the color of the cursor.

Parameters
chessboardA CwChessboard.
colorThe color to be used for the cursor.

Definition at line 1964 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_cursor_color().

void cw_chessboard_set_cursor_thickness ( CwChessboard*   chessboard,
gdouble  thickness 
)

Set the cursor thickness. This is a value between 0 and 0.5.

Parameters
chessboardA CwChessboard.
thicknessThe thickness of the cursor as fraction of sside. Range [0...0.5]
See also
cw_chessboard_get_cursor_thickness

Definition at line 1981 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_cursor_thickness().

void cw_chessboard_set_dark_square_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

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

Parameters
chessboardA CwChessboard.
colorThe new color of the dark squares.

Definition at line 1840 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_dark_square_color().

void cw_chessboard_set_draw_border ( CwChessboard*   chessboard,
gboolean  draw 
)

Set the boolean which determines whether or not the chessboard widget draws a border around the chessboard. Default: TRUE (draw border).

Parameters
chessboardA CwChessboard.
drawBoolean, determining if the border should be drawn.
See also
CwChessboardClass::calc_board_border_width, CwChessboardClass::draw_border

Definition at line 1763 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_draw_border().

void cw_chessboard_set_draw_turn_indicators ( CwChessboard*   chessboard,
gboolean  draw 
)

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
chessboardA CwChessboard.
drawBoolean, determining if the indicators should be drawn.
See also
cw_chessboard_set_draw_border, CwChessboardClass::draw_turn_indicator

Definition at line 1801 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_draw_turn_indicators().

void cw_chessboard_set_flip_board ( CwChessboard*   chessboard,
gboolean  flip 
)

Set the boolean which determines whether white is playing bottom up or top down. Default: FALSE (white plays upwards).

Parameters
chessboardA CwChessboard.
flipBoolean, determining if white plays upwards or not.

Definition at line 1778 of file CwChessboard.cc.

References CwChessboard::flip_board.

Referenced by cwmm::ChessboardWidget::set_flip_board().

void cw_chessboard_set_light_square_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

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

Parameters
chessboardA CwChessboard.
colorThe new color of the light squares.

Definition at line 1857 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_light_square_color().

void cw_chessboard_set_marker_color ( CwChessboard*   chessboard,
gint  col,
gint  row,
CwChessboardColorHandle  mahandle 
)

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

Parameters
chessboardA CwChessboard.
colThe column of the square.
rowThe row of the square.
mahandleA color handle as returned by cw_chessboard_allocate_color_handle_rgb or cw_chessboard_allocate_color_handle. A handle with a value of 0 means the default background color.

Definition at line 1674 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_marker_color().

void cw_chessboard_set_marker_level ( CwChessboard*   chessboard,
gboolean  below 
)

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
chessboardA CwChessboard.
belowTRUE when markers should be drawn below HUD layer 0.

Definition at line 1704 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_marker_level().

void cw_chessboard_set_marker_thickness ( CwChessboard*   chessboard,
gdouble  thickness 
)

Set the marker thickness. This is a value between 0 and 0.5.

Parameters
chessboardA CwChessboard.
thicknessThe thickness of the marker as fraction of sside. Range [0...0.5]
See also
cw_chessboard_get_marker_thickness

Definition at line 1691 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_marker_thickness().

void cw_chessboard_set_square ( CwChessboard*   chessboard,
gint  col,
gint  row,
CwChessboardCode  code 
)

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
chessboardA CwChessboard.
colA column [0..7]
rowA row [0..7]
codeA CwChessboardCode.

Definition at line 1741 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_square().

void cw_chessboard_set_white_fill_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Set the fill color of the white chess pieces. Default: white

Parameters
chessboardA CwChessboard.
colorThe new fill color of the white pieces.

Definition at line 1892 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_white_fill_color().

void cw_chessboard_set_white_line_color ( CwChessboard*   chessboard,
GdkColor const*   color 
)

Set the line color of the white chess pieces. Default: black

Parameters
chessboardA CwChessboard.
colorThe new line color of the white pieces.

Definition at line 1910 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::set_white_line_color().

void cw_chessboard_show_cursor ( CwChessboard*   chessboard)

Show the cursor.

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

Parameters
chessboardA CwChessboard.
See also
cw_chessboard_set_cursor_thickness, cw_chessboard_get_cursor_thickness

Definition at line 1994 of file CwChessboard.cc.

Referenced by cwmm::ChessboardWidget::show_cursor().

CWCHESSBOARD_INLINE gint cw_chessboard_x2col ( CwChessboard*   chessboard,
gdouble  x 
)

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
chessboardA CwChessboard.
xAn x coordinate, relative to the left-side of the widget.
Returns
A column number.

Referenced by cw_chessboard_move_floating_piece(), cw_chessboard_remove_floating_piece(), and cwmm::ChessboardWidget::x2col().

CWCHESSBOARD_INLINE gint cw_chessboard_y2row ( CwChessboard*   chessboard,
gdouble  y 
)

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
chessboardA CwChessboard.
yA y coordinate, relative to the top-side of the widget.
Returns
A row number.

Referenced by cw_chessboard_move_floating_piece(), cw_chessboard_remove_floating_piece(), and cwmm::ChessboardWidget::y2row().


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