MyChessboardWidget Class Reference

Inheritance diagram for MyChessboardWidget:

List of all members.

Public Member Functions

void on_menu_mode_editposition (void)
void on_menu_mode_editgame (void)
void on_menu_mode_showcandidates (void)
void on_menu_mode_showreachables (void)
void on_menu_mode_showattacked (void)
void on_menu_mode_showdefendables (void)
void on_menu_mode_showdefended_black (void)
void on_menu_mode_showdefended_white (void)
void on_menu_mode_showmoves (void)
void on_menu_mode_placepieces (void)
void picked_up (cwchess::Index const& index, cwchess::ChessPosition const& chess_position)
void dropped (gint col, gint row, cwchess::ChessPosition const& chess_position)
void moved (cwchess::Move const& move, cwchess::ChessPosition const& previous_position, cwchess::ChessPosition const& current_position)
void illegal (cwchess::Move const& move, cwchess::ChessPosition const& chess_position)
 MyChessboardWidget (Gtk::Window* drawable)

Protected Member Functions

virtual void draw_hud_layer (cairo_t* cr, gint sside, guint hud)
 Draw the HUD layer.
virtual bool on_button_press (gint col, gint row, GdkEventButton const* event)
 Called when a mouse button is pressed while the mouse is on the chessboard.
virtual bool on_button_release (gint col, gint row, GdkEventButton const* event)
 Called when a mouse button is released.

Detailed Description

Definition at line 56 of file tstcpp.cc.


Member Function Documentation

void MyChessboardWidget::draw_hud_layer ( cairo_t*   cr,
gint  sside,
guint  hud 
) [protected, virtual]

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 from cwmm::ChessboardWidget.

Definition at line 405 of file tstcpp.cc.

References cwchess::white.

bool MyChessboardWidget::on_button_press ( gint  col,
gint  row,
GdkEventButton const*   event 
) [protected, virtual]

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

Parameters:
col : The column of the square the mouse is on.
row : The row of the square the mouse is on.
event : The button press event.

Useful members of the event are:

  • event->button : The number of the button that is pressed.
  • event->type : GDK_BUTTON_PRESS for a normal click, GDK_2BUTTON_PRESS for a double click.
  • event->x, event->y : The exact pixel coordinates where was clicked.

The default does nothing but return false.

This function should normally return false. If it returns true then the event is considered to be completely handled and nothing else will be done.

In case of a double click, this function is called three times. First with event->type == GDK_BUTTON_PRESS, followed by a call to on_button_release. Next again with event->type == GDK_BUTTON_PRESS and then with event->type == GDK_2BUTTON_PRESS. Finally on_button_release will be called a second time. Therefore, a call to this function with event->type == GDK_BUTTON_PRESS and a subsequent on_button_release at the same coordinates should be a non-operation (if you want to use double clicks too).

Reimplemented from cwmm::ChessPositionWidget.

Definition at line 305 of file tstcpp.cc.

References cwmm::ChessboardWidget::enable_hud_layer(), cwmm::ChessboardWidget::set_marker_color(), and cwmm::ChessboardWidget::show_cursor().

bool MyChessboardWidget::on_button_release ( gint  col,
gint  row,
GdkEventButton const*   event 
) [protected, virtual]

Called when a mouse button is released.

Parameters:
col : The column of the square the mouse is on, or -1 if the mouse is outside the chessboard.
row : The row of the square the mouse is on, or -1 if the mouse is outside the chessboard.
event : The button release event.

Useful members of the event are:

  • event->button : The number of the button that is released.
  • event->x, event->y : The exact pixel coordinates where it is released.

The default does nothing but return false.

This function should normally return false. If it returns true then the event is considered to be completely handled and nothing else will be done.

Reimplemented from cwmm::ChessPositionWidget.

Definition at line 354 of file tstcpp.cc.

References cwmm::ChessboardWidget::add_arrow(), cwmm::ChessboardWidget::hide_cursor(), cwmm::ChessboardWidget::is_inside_board(), and cwmm::ChessboardWidget::set_marker_color().


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

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