/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2004  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public License as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#include "constants.h"

#ifdef USE_UI_GTK

#include "table.h"
#include "playfield.h"
#include "gametype.h"
#include "gtk_gui.h"
#include "card.h"

#include "../../party/party.h"
#include "../../game/game.h"
#include "../../misc/setting.h"
#include "../../basistypes.h"

namespace GTK_DOKO {
#include <gtk/gtkeventbox.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtksignal.h>

  /*****************************************************************************
   *
   * Table::Table(Playfield* playfield_a)
   *
   * Parameters:	playfield_a - pointer to the playfield
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	constructor
   *
   ****************************************************************************/
  Table::Table(Playfield* const playfield) :
    playfield_p(playfield), // the playfield
  event_box_p(gtk_event_box_new()), // event box
  drawing_area_p(gtk_drawing_area_new()), // drawing area
  pixmap_p(NULL), // pixmap
  width_p(1), // width
  height_p(1), // height
  background_pm_p(), // background pixmap
  background_gc_p(NULL), // background gc
  hands_p(this), // the hands of the players
  names_p(this), // the names of the players
  icongroups_p(this), // the icongroups of the players
  trick_p(this), // the trick
  poverty_p(this), // the poverty
  trickpiles_p(this), // the trickpiles of the players
  full_trick_p(this), // the full trick window
  last_trick_p(this), // the last trick (window)
  party_points_p(this), // the party points (window)
  border_card()
  {
    DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_INIT,
		  "Table::Table()");

    // create table pixmap
    this->pixmap_p = gdk_pixmap_new(NULL,
				    this->width(), this->height(),
				    this->gui().color_depth);

    gtk_signal_connect(GTK_OBJECT(drawing_area()), "key_press_event",
		       GTK_SIGNAL_FUNC(Table::key_event), gpointer(this));

    // create the order of the border cards manual
    border_card.push_back(Card(Card::HEART, Card::TEN));

    border_card.push_back(Card(Card::CLUB, Card::QUEEN));
    border_card.push_back(Card(Card::SPADE, Card::QUEEN));
    border_card.push_back(Card(Card::HEART, Card::QUEEN));
    border_card.push_back(Card(Card::DIAMOND, Card::QUEEN));

    border_card.push_back(Card(Card::CLUB, Card::JACK));
    border_card.push_back(Card(Card::SPADE, Card::JACK));
    border_card.push_back(Card(Card::HEART, Card::JACK));
    border_card.push_back(Card(Card::DIAMOND, Card::JACK));

    border_card.push_back(Card(Card::DIAMOND, Card::ACE));
    border_card.push_back(Card(Card::DIAMOND, Card::TEN));
    border_card.push_back(Card(Card::DIAMOND, Card::KING));
    border_card.push_back(Card(Card::DIAMOND, Card::NINE));

    border_card.push_back(Card(Card::CLUB, Card::ACE));
    border_card.push_back(Card(Card::CLUB, Card::TEN));
    border_card.push_back(Card(Card::CLUB, Card::KING));
    border_card.push_back(Card(Card::CLUB, Card::NINE));

    border_card.push_back(Card(Card::HEART, Card::ACE));
    border_card.push_back(Card(Card::HEART, Card::KING));
    border_card.push_back(Card(Card::HEART, Card::NINE));

    border_card.push_back(Card(Card::SPADE, Card::ACE));
    border_card.push_back(Card(Card::SPADE, Card::TEN));
    border_card.push_back(Card(Card::SPADE, Card::KING));
    border_card.push_back(Card(Card::SPADE, Card::NINE));

    this->min_size_set();

    gtk_container_add(GTK_CONTAINER(this->widget()), this->drawing_area());

    // redraw
    gtk_signal_connect(GTK_OBJECT(this->drawing_area()),"expose_event",
		       GTK_SIGNAL_FUNC(Table::expose_event), this);
    // resize
    gtk_signal_connect(GTK_OBJECT(this->drawing_area()),"configure_event",
		       GTK_SIGNAL_FUNC(Table::resize_event), this);
    // Mouse button
    gtk_signal_connect(GTK_OBJECT(this->widget()), "button_press_event",
		       GTK_SIGNAL_FUNC(Table::mouse_click_event), this);

    gtk_widget_show(this->drawing_area());
    gtk_widget_show_all(this->widget());

    // load background
    this->background_load();

    this->hands().init();
    this->names().init();
    this->icongroups().init();
    this->trick().init();
    this->trickpiles().init();
    this->full_trick().init();
    this->last_trick().init();
    this->party_points().init();

    DEBUG_RETURNING(VOID,
		    INFO_GTK_TABLE && INFO_GTK_INIT,
		    "Table::Table()");
  } // Table::Table(Playfield* playfield_a)

  /*****************************************************************************
   *
   * void Table::init()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	Inits the table
   *
   ****************************************************************************/
  void
    Table::init()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_INIT,
		    "Table::init()");


      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_INIT,
		      "Table::init()");
    } // void Table::init()

  /**
   **
   ** loads the background
   **
   ** @param	-
   **
   ** @return	whether a new background was loaded
   ** 
   ** @version	0.4.5
   **
   ** @author	Diether Knof
   **
   **/
  bool
    Table::background_load()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_INIT,
		    "Table::background_load()");

      vector<string> file;

      file.push_back(::setting(Setting::PRIVATE_DATA_DIRECTORY) + "/"
		     + ::setting(Setting::BACKGROUND));
      file.push_back(::setting(Setting::PUBLIC_DATA_DIRECTORY) + "/"
		     + ::setting(Setting::BACKGROUND));
      file.push_back(::setting_default(Setting::PUBLIC_DATA_DIRECTORY) + "/"
		     + ::setting(Setting::BACKGROUND));
      file.push_back("./" + ::setting(Setting::BACKGROUND));
      if (!this->background_pm_p)
	file.push_back(::setting_default(Setting::PUBLIC_DATA_DIRECTORY) + "/"
		       + ::setting_default(Setting::BACKGROUND));

      vector<string>::iterator f;
      for (f = file.begin(); f != file.end(); f++) {
	Pixmap pixmap = Pixmap(*f + "." + setting(Setting::GRAPHIC_EXTENSION));
	if (pixmap) {
	  this->background_load(*f);
	  break;
	} // if (pixmap)
      } // for (f = file.begin(); f != file.end(); f++)

      if (!this->background_pm_p) {
	cerr << "Error at loading the background "
	  << ::setting(Setting::BACKGROUND) << ".\n"
	  << "Exiting." << endl;
	exit(1);
      } // if (!this->back(0))

      DEBUG_RETURNING((f != file.end()),
		      INFO_GTK_TABLE && INFO_GTK_INIT,
		      "Table::background_load()");
    } // bool Table::background_load()

  /**
   **
   ** loads the background from 'filename'
   **
   ** @param	filename	file to load
   **
   ** @return	whether a new background was loaded
   ** 
   ** @version	0.4.5
   **
   ** @author	Diether Knof
   **
   **/
  bool
    Table::background_load(string const& filename)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_INIT,
		    "Table::background_load()");

      Pixmap pixmap_new = Pixmap(filename + "."
				 + setting(Setting::GRAPHIC_EXTENSION));
      if (!pixmap_new)
	// use the old background
	DEBUG_RETURNING(false,
			INFO_GTK_TABLE && INFO_GTK_INIT,
			"Table::background_load()");

      // set the values
      this->background_pm_p = pixmap_new;
      this->background_gc_p = gdk_gc_new(this->background_pm().pixmap());
      gdk_gc_copy(this->background_gc(), gui().gc);
      gdk_gc_set_fill(this->background_gc(), GDK_TILED);
      gdk_gc_set_tile(this->background_gc(), this->background_pm().pixmap());

      DEBUG_RETURNING(true,
		      INFO_GTK_TABLE && INFO_GTK_INIT,
		      "Table::background_load()");
    } // bool Table::background_load(string filename)

  /*****************************************************************************
   *
   * GTK_GUI& Table::gui()
   *
   * Parameters:	-
   *
   * Result:	the gui
   *
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  GTK_GUI&
    Table::gui()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::gui()");

      DEBUG_RETURNING(playfield().gui(),
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::gui()");
    } // GTK_GUI& Table::gui()

  /*****************************************************************************
   *
   * Playfield& Table::playfield()
   *
   * Parameters:	-
   *
   * Result:	The playfield
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  Playfield&
    Table::playfield()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::playfield()");

      DEBUG_ASSERTION((playfield_p != NULL),
		      "Table::playfield()\n"
		      "  `playfield_p` == NULL");

      DEBUG_RETURNING(*playfield_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::playfield()");
    } // Playfield& Table::playfield()

  /*****************************************************************************
   *
   * Handgs& Table::hands()
   *
   * Parameters:	-
   *
   * Result:	The hands of the players
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  Handgs&
    Table::hands()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::hands()");

      DEBUG_RETURNING(this->hands_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::hands()");
    } // Handgs& Table::hands()

  /*****************************************************************************
   *
   * Handg& Table::hand(Player const& player)
   *
   * Parameters:	player - the player, whose hand is returned
   *
   * Result:	The hand of the given player
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  Handg&
    Table::hand(Player const& player)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::hand(player)");

      DEBUG_RETURNING(this->hands().hand(player),
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::hand(player)");
    } // Handg& Table::hand(Player const& player)

  /*****************************************************************************
   *
   * IconGroups& Table::icongroups()
   *
   * Parameters:	-
   *
   * Result:	The icongroups of the players
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  IconGroups&
    Table::icongroups()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::icongroups(player)");

      DEBUG_RETURNING(this->icongroups_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::icongroups(player)");
    } // IconGroups& Table::icongroups()

  /*****************************************************************************
   *
   * IconGroup& Table::icongroup(Player const& player)
   *
   * Parameters:	player - the player, whose icongroup is returned
   *
   * Result:	The icongroup of the given player
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  IconGroup&
    Table::icongroup(Player const& player)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::icongroup(player)");

      DEBUG_RETURNING(this->icongroups().icongroup(player),
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::icongroup(player)");
    } // IconGroup& Table::icongroup(Player const& player)

  /*****************************************************************************
   *
   * Names& Table::names()
   *
   * Parameters:	-
   *
   * Result:	The names of the players
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  Names&
    Table::names()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::names()");

      DEBUG_RETURNING(this->names_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::names()");
    } // Names& Table::names()

  /*****************************************************************************
   *
   * Name& Table::name(Player const& player)
   *
   * Parameters:	player - the player, whose name is returned
   *
   * Result:	The name of the given player
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  Name&
    Table::name(Player const& player)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::name(player)");

      DEBUG_RETURNING(this->names().name(player),
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::name(player)");
    } // Name& Table::name(Player const& player)

  /*****************************************************************************
   *
   * TrickPiles& Table::trickpiles()
   *
   * Parameters:	-
   *
   * Result:	The trickpiles of the players
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  TrickPiles&
    Table::trickpiles()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::trickpiles()");

      DEBUG_RETURNING(this->trickpiles_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::trickpiles()");
    } // TrickPiles& Table::trickpiles()

  /*****************************************************************************
   *
   * TrickPile& Table::trickpile(Player const& player)
   *
   * Parameters:	player - the player, whose trickpile is returned
   *
   * Result:	The trickpile of the given player
   * 
   * Version:	0.4.4
   *
   * Description:	Result
   *
   ****************************************************************************/
  TrickPile&
    Table::trickpile(Player const& player)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::trickpile(player)");

      DEBUG_RETURNING(this->trickpiles().trickpile(player),
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::trickpile(player)");
    } // TrickPile& Table::trickpile(Player const& player)

  /*****************************************************************************
   *
   * Trick& Table::trick()
   *
   * Parameters:	-
   *
   * Result:	The trick
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  Trick&
    Table::trick()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::trick()");

      DEBUG_RETURNING(trick_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::trick()");
    } // Trick& Table::trick()

  /*****************************************************************************
   *
   * Poverty& Table::poverty()
   *
   * Parameters:	-
   *
   * Result:	The poverty elements
   * 
   * Version:	0.5
   *
   * Description:	Result
   *
   ****************************************************************************/
  Poverty&
    Table::poverty()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::poverty()");

      DEBUG_RETURNING(poverty_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::poverty()");
    } // Poverty& Table::poverty()

  /*****************************************************************************
   *
   * FullTrick& Table::full_trick()
   *
   * Parameters:	-
   *
   * Result:	the full trick
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  FullTrick&
    Table::full_trick()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::full_trick()");

      DEBUG_RETURNING(full_trick_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::full_trick()");
    } // FullTrick& Table::full_trick()

  /*****************************************************************************
   *
   * LastTrick& Table::last_trick()
   *
   * Parameters:	-
   *
   * Result:	the party points
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  LastTrick&
    Table::last_trick()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::last_trick()");

      DEBUG_RETURNING(last_trick_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::last_trick()");
    } // LastTrick& Table::last_trick()

  /*****************************************************************************
   *
   * PartyPoints& Table::party_points()
   *
   * Parameters:	-
   *
   * Result:	the party points
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  PartyPoints&
    Table::party_points()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::party_points()");

      DEBUG_RETURNING(party_points_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::party_points()");
    } // PartyPoints& Table::party_points()

  /*****************************************************************************
   *
   * unsigned Table::width() const
   *
   * Parameters:	-
   *
   * Result:	the width of the table
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  unsigned
    Table::width() const
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::width()");

      DEBUG_RETURNING(width_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::width()");
    } // unsigned Table::width() const

  /*****************************************************************************
   *
   * unsigned Table::height() const
   *
   * Parameters:	-
   *
   * Result:	the height of the table
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  unsigned
    Table::height() const
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::height()");

      DEBUG_RETURNING(height_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::height()");
    } // unsigned Table::height() const

  /*****************************************************************************
   *
   * GtkWidget* Table::widget()
   *
   * Parameters:	-
   *
   * Result:	the table widget
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  GtkWidget*
    Table::widget()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::widget()");

      DEBUG_ASSERTION(this->event_box_p != NULL,
		      "Table::widget():\n"
		      "  'this->event_box_p' == NULL");

      DEBUG_RETURNING(event_box_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::widget()");
    } // GtkWidget* Table::widget()

  /*****************************************************************************
   *
   * GtkWidget* Table::widget()
   *
   * Parameters:	-
   *
   * Result:	the drawing area
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  GtkWidget*
    Table::drawing_area()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::widget()");

      DEBUG_ASSERTION(event_box_p != NULL,
		      "Table::widget():\n"
		      "  'event_box_p' == NULL");

      DEBUG_RETURNING(drawing_area_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::widget()");
    } // GtkWidget* Table::drawing_area()

  /*****************************************************************************
   *
   * GdkPixmap* Table::pixmap()
   *
   * Parameters:	-
   *
   * Result:	the pixmap
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  GdkPixmap*
    Table::pixmap()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::pixmap()");

      DEBUG_ASSERTION(pixmap_p != NULL,
		      "Table::pixmap():\n"
		      "  'pixmap_p' == NULL");

      DEBUG_RETURNING(pixmap_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::pixmap()");
    } // GdkPixmap* Table::pixmap()

  /*****************************************************************************
   *
   * Pixmap& Table::background_pm()
   *
   * Parameters:	-
   *
   * Result:	the pixmap of the background
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  Pixmap&
    Table::background_pm()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::background_pm()");

      DEBUG_ASSERTION(background_pm_p,
		      "Table::background_pm():\n"
		      "  'background_pm_p' == Pixmap()");

      DEBUG_RETURNING(background_pm_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::background_pm()");
    } // GdkPixmap* Table::pixmap()

  /*****************************************************************************
   *
   * GdkGC& Table::background_gc()
   *
   * Parameters:	-
   *
   * Result:	the GC for the background
   * 
   * Version:	0.3.7
   *
   * Description:	Result
   *
   ****************************************************************************/
  GdkGC*
    Table::background_gc()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_VALUE,
		    "Table::background_gc()");

      DEBUG_ASSERTION(background_gc_p != NULL,
		      "Table::background_gc():\n"
		      "  'background_gc_p' == NULL");

      DEBUG_RETURNING(background_gc_p,
		      INFO_GTK_TABLE && INFO_GTK_VALUE,
		      "Table::background_gc()");
    } // GdkGC* Table::background_gc()

  /*****************************************************************************
   *
   * void Table::min_size_set()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	set the minimum size of the table
   *
   ****************************************************************************/
  void
    Table::min_size_set()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_UPDATE,
		    "Table::min_size_set()");

      // make the table beautiful :-)
      //    width = int(height * 1.3);
      this->height_p = int(5.2 * gui().cards().height()); // height
      //  this->width_p = int((5.2 + 1) * gui().cards().height()); // width
      this->width_p = int((5.2 + 1) * gui().cards().height()); // width

      gtk_widget_set_usize(drawing_area(),
			   -1, -1);
      gtk_widget_set_usize(drawing_area(),
			   this->width(), this->height());

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_UPDATE,
		      "Table::min_size_set()");
    } // void Table::min_size_set()

  /*****************************************************************************
   *
   * void Table::party_open()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the party is opened
   *
   ****************************************************************************/
  void
    Table::party_open()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::party_open()");

      this->draw_all();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::party_open()");
    } // void Table::party_open()

  /*****************************************************************************
   *
   * void Table::party_start()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the party is started
   *
   ****************************************************************************/
  void
    Table::party_start()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::party_start()");

      this->party_points().party_start();
      gdk_window_set_cursor(this->widget()->window,
			    gdk_cursor_new(GDK_HAND1));

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::party_start()");
    } // void Table::party_start()

  /*****************************************************************************
   *
   * void Table::game_open()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the game is opened
   *
   ****************************************************************************/
  void
    Table::game_open()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::game_open()");

      this->hands_p.game_open(::party.game());
      this->trickpiles_p.game_open(::party.game());
      this->names_p.game_open(::party.game());
      this->icongroups_p.game_open(::party.game());

      this->draw_all();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::game_open()");
    } // void Table::game_open()

  /*****************************************************************************
   *
   * void Table::game_start()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the game is started
   *
   ****************************************************************************/
  void
    Table::game_start()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::game_start()");

      this->icongroups().draw();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::game_start()");
    } // void Table::game_start()

  /*****************************************************************************
   *
   * void Table::game_finish()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the game is finished
   *
   ****************************************************************************/
  void
    Table::game_finish()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::game_finish()");

      this->party_points().game_finish();
      this->draw_all();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::game_finish()");
    } // void Table::game_finish()

  /*****************************************************************************
   *
   * void Table::game_close()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the game is closeed
   *
   ****************************************************************************/
  void
    Table::game_close()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::game_close()");

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::game_close()");
    } // void Table::game_close()

  /*****************************************************************************
   *
   * void Table::party_finish()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the party is finished
   *
   ****************************************************************************/
  void
    Table::party_finish()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::party_finish()");

      this->hands().draw();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::party_finish()");
    } // void Table::party_finish()

  /*****************************************************************************
   *
   * void Table::party_close()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the party is closeed
   *
   ****************************************************************************/
  void
    Table::party_close()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		    "Table::party_close()");

      this->party_points().party_close();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_GAMEPLAY,
		      "Table::party_close()");
    } // void Table::party_close()

  /*****************************************************************************
   *
   * void Table::cards_update()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	updates the cards in the table
   *
   ****************************************************************************/
  void
    Table::cards_update()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_UPDATE,
		    "Table::cards_update()");

      draw_all();
      full_trick().cards_update();
      last_trick().cards_update();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_UPDATE,
		      "Table::cards_update()");
    } // void Table::cards_update()

  /*****************************************************************************
   *
   * void Table::language_update()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	updates the language
   *
   ****************************************************************************/
  void
    Table::language_update()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_UPDATE,
		    "Table::language_update()");

      trick().language_update();
      hands().language_update();
      icongroups().language_update();
      names().language_update();
      trickpiles().language_update();
      full_trick().language_update();
      last_trick().language_update();
      party_points().language_update();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_UPDATE,
		      "Table::language_update()");
    } // void Table::language_update()



  /*****************************************************************************
   *
   * void Table::update(int const x, int const y,
   *			  int const width, int const height)
   *
   * Parameters:	x	- starting position of the area
   *		y	- starting positino of the area
   *		width	- width of the area
   *		height	- height of the area
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	copies the area from the pixmap in the drawing area
   *
   ****************************************************************************/
  void
    Table::update(int const x, int const y,
		  int const width, int const height)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_DRAW,
		    "Table::update(x, y, width, height)");

      // just copy the area from the pixmap into the drawing area
      if ( (drawing_area()->window != NULL)
	   && (pixmap() != NULL))
	gdk_draw_pixmap(drawing_area()->window, gui().gc, pixmap(),
			x, y, x, y, width, height);


      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_DRAW,
		      "Table::update(x, y, width, height)");
    } // void Table::update(x, y, width, height)

  /*****************************************************************************
   *
   * void Table::update()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	copies the whole pixmap in the drawing area
   *
   ****************************************************************************/
  void
    Table::update()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_DRAW,
		    "Table::update()");

      update(0, 0, width(), height());

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_DRAW,
		      "Table::update()");
    } // void Table::update()

  /*****************************************************************************
   *
   * void Table::draw_all()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	draws the whole table and copies it in the drawing area
   *
   ****************************************************************************/
  void
    Table::draw_all()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_DRAW,
		    "Table::draw_all()");

      // draw the background
      background_draw();

      if ((::game_status & GAMESTATUS::GAME)
	  && (::game_status >= GAMESTATUS::GAME_RESERVATION)) {
	// draw the hands, the names and the icongroups
	this->hands().draw(false);
	this->icongroups().draw(false);
	this->names().draw(false);
	this->trickpiles().draw(false);

	// draw the trick (when the window is to small,
	// the trick will overlap the icongroups, ...
	if (::game_status == GAMESTATUS::GAME_POVERTY_SHIFT) {
	  this->poverty().draw(::party.game().player_current(), false);
	} else if (::game_status == GAMESTATUS::GAME_FINISHED) {
	  if (this->last_trick().trickno() != UINT_MAX)
	    this->trick().draw(party.game().trick(this->last_trick().trickno()), false);
	} else if (::party.game().trick_current_no() != UINT_MAX) {
	  this->trick().draw(::party.game().trick_current(), false);
	} // if (::game_status == ...)

      } else if (!(::game_status & GAMESTATUS::GAME)) {
	{ // put the border cards to the border
	  unsigned c;
	  unsigned const border_x = (this->gui().cards().width()
				     + ( (7 * this->gui().cards().height() + this->gui().cards().width() >= this->width())
					 ? 0
					 : (this->width() - (7 * this->gui().cards().height() + this->gui().cards().width())) / 7
				       )
				    );
	  unsigned const border_y = (this->gui().cards().width()
				     + ( (5 * this->gui().cards().height() + this->gui().cards().width() >= this->height())
					 ? 0
					 : (this->height() - (5 * this->gui().cards().height() + this->gui().cards().width())) / 5
				       )
				    );
	  for (c = 0; c < 7; c++)
	    this->gui().cards().card(this->border_card[c]
				    ).rotated(LEFT).draw(this->pixmap(),
								 border_x
								 + c * (this->width()
									- this->gui().cards().height()
									- 2 * border_x
								       ) / (7 - 1),
								 this->gui().cards().width() / 2);
	  for (c = 0; c < 5; c++)
	    this->gui().cards().card(this->border_card[7 + c]
				    ).rotated(UP).draw(this->pixmap(),
							       this->width()
							       - (this->gui().cards().width() * 3) / 2,
							       border_y
							       + c * (this->height()
								      - this->gui().cards().height()
								      - 2 * border_y
								     ) / (5 - 1)
							      );
	  for (c = 0; c < 7; c++)
	    this->gui().cards().card(this->border_card[7 + 5 + (7 - 1 - c)]
				    ).rotated(RIGHT).draw(this->pixmap(),
								  border_x
								  + c * (this->width()
									 - this->gui().cards().height()
									 - 2 * border_x
									) / (7 - 1),
								  this->height()
								  - (this->gui().cards().width() * 3 / 2)
								 );
	  // because of the overlapping with the upper row,
	  // I have to work here manually
	  // use a separate gc
	  GdkGC* gc = gdk_gc_new(this->pixmap());
	  GdkGC* gc_mask = gdk_gc_new(this->gui().cards().card(this->border_card[3 * 6]).mask());
	  GdkBitmap* mask = NULL;
	  unsigned x = 0;
	  unsigned y = 0;
	  for (c = 0; c < 5; c++) {
	    x = this->gui().cards().width() / 2;
	    y = (border_y + c * (this->height()
				 - this->gui().cards().height()
				 - 2 * border_y
				) / (5 - 1)
		);
	    mask = gdk_pixmap_new(NULL,
				  this->gui().cards().card(this->border_card[7 + 5 + 7 - (5 - 1 - c)]).width(),
				  this->gui().cards().card(this->border_card[7 + 5 + 7 - (5 - 1 - c)]).height(),
				  1);

	    gdk_gc_set_function(gc_mask, GDK_COPY);
	    gdk_window_copy_area(mask,
				 gc_mask,
				 0, 0,
				 this->gui().cards().card(this->border_card[7 + 5 + 7 - (5 - 1 - c)]).rotated(DOWN).mask(),
				 0, 0,
				 this->gui().cards().card(this->border_card[7 + 5 + 7 - (5 - 1 - c)]).width(),
				 this->gui().cards().card(this->border_card[7 + 5 + 7 - (5 - 1 - c)]).height());
	    gdk_gc_set_function(gc_mask, GDK_AND_INVERT);
	    gdk_window_copy_area(mask,
				 gc_mask,
				 border_x
				 + c * (this->width()
					- this->gui().cards().height()
					- 2 * border_x
				       ) / (5 - 1)
				 - x,
				 this->gui().cards().width() / 2 - y,
				 this->gui().cards().card(this->border_card[c]).rotated(LEFT).mask(),
				 0, 0,
				 this->gui().cards().card(this->border_card[c]).height(),
				 this->gui().cards().card(this->border_card[c]).width());

	    gdk_gc_set_clip_mask(gc, mask);
	    gdk_gc_set_clip_origin(gc, x, y);

	    gdk_draw_pixmap(this->pixmap(), gc,
			    this->gui().cards().card(this->border_card[7 + 5 + 7
						     + (5 - 1
							- c)]
						    ).rotated(DOWN).pixmap(),
			    0, 0,
			    x, y,
			    -1, -1);

#if 0	
	    this->gui().cards().card(this->border_card[7 + 5 + 7 + (5 - 1 - c)]
				    ).draw(this->pixmap(),
					   x, y);
#endif
	  } // for (c)
	  gdk_gc_unref(gc);
	  gdk_gc_unref(gc_mask);

	} // put the border cards to the border
	// center the logo
	this->gui().logo().draw(this->pixmap(),
				(this->width() - this->gui().logo().width()) / 2,
				(this->height() - this->gui().logo().height()) / 2
			       );

      } // if !(::game_status & GAME)

      // copy the whole pixmap into the table
      this->update(0, 0, -1, -1);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_DRAW,
		      "Table::draw_all()");
    } // void Table::draw_all()

  /*****************************************************************************
   *
   * void Table::background_draw()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	draws the background of the table
   *
   ****************************************************************************/
  void
    Table::background_draw()
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_DRAW,
		    "Table::background_draw()");

      background_draw(0, 0, width(), height());

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_DRAW,
		      "Table::background_draw()");
    } // void Table::background_draw()

  /*****************************************************************************
   *
   * void Table::background_draw(int const x, int const y,
   *				   int const width, int const height)
   *
   * Parameters:	x	- starting position of the area
   *		y	- starting positino of the area
   *		width	- width of the area
   *		height	- height of the area
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	draws the background of the area
   *
   ****************************************************************************/
  void
    Table::background_draw(int const x, int const y,
			   int const width, int const height)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_DRAW,
		    "Table::background_draw(x, y, width, height)");

      if (!background_pm()) {
	// background could not be loaded -- use the default background
	gdk_draw_rectangle(pixmap(), gui().gc, TRUE,
			   x, y, width, height);

      } else {

#ifdef WINDOWS

	int offset_a, offset_b;
	for (int b = y / background_pm().height();
	     b < (y + height) / int(background_pm().height()) + 1;
	     b++) {
	  offset_b = max(0, int(y - b * background_pm().height()));
	  for (int a = x / background_pm().width();
	       a < (x + width) / int(background_pm().width()) + 1;
	       a++) {
	    offset_a = max(0, int(x - a * background_pm().width()));
	    gdk_window_copy_area(pixmap(), gui().gc,
				 a * background_pm().width() + offset_a,
				 b * background_pm().height() + offset_b,
				 background_pm().pixmap(),
				 offset_a, offset_b,
				 min(background_pm().width(),
				     x + width - a * background_pm().width() - offset_a),
				 min(background_pm().height(),
				     y + height - b * background_pm().height() - offset_b)
				);
	  } // for(a)
	} // for(b)
#else
	// use a separat gc
	gdk_draw_rectangle(pixmap(), background_gc(), TRUE,
			   x, y, width, height);
#endif
      }

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_DRAW,
		      "Table::background_draw(x, y, width, height)");
    } // void Table::background_draw(x, y, width, height)


  /*****************************************************************************
   *
   * void Table::expose(GdkEventExpose* expose_event)
   *
   * Parameters:	expose_event	- data of the expose evet
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	redaw part of the table
   *
   ****************************************************************************/
  void
    Table::expose(GdkEventExpose* expose_event)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_EVENT,
		    "Table::expose()");

      update(expose_event->area.x, expose_event->area.y,
	     expose_event->area.width,
	     expose_event->area.height);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_EVENT,
		      "Table::expose()");
    } // void Table::expose(GdkEventExpose*)

  /*****************************************************************************
   *
   * void Table::resize(GdkEventConfigure* configure_event)
   *
   * Parameters:	configure_event	- data of the configure
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	the table is resized:
   *		recreate the pixmap and redraw the table
   *
   ****************************************************************************/
  void
    Table::resize(GdkEventConfigure* configure_event)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_EVENT,
		    "Table::resize()");

      update(0, 0, -1, -1);

      width_p = configure_event->width;
      height_p = configure_event->height;

      // create a new pixmap
      if (pixmap() != NULL)
	gdk_pixmap_unref(pixmap());

      pixmap_p = gdk_pixmap_new(NULL,
				width(), height(),
				gui().color_depth);

      // draw all
      draw_all();


      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_EVENT,
		      "Table::resize()");
    } // void Table::resize(GdkEventConfigure*)


  /*****************************************************************************
   *
   * void Table::mouse_click(GdkEventButton* button_event)
   *
   * Parameters:	button_event	- data of the button event
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	a mouse button is pressed:
   *		close the gametype window
   *		close the full trick window
   *		close the last trick window
   *		pass the event to the hands
   *
   ****************************************************************************/
  void
    Table::mouse_click(GdkEventButton* button_event)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_EVENT,
		    "Table::mouse_click()");

      if (GTK_WIDGET_VISIBLE(this->playfield().gametype().window()))
	this->playfield().gametype().close();
      else if (::game_status == GAMESTATUS::GAME_POVERTY_SHIFT)
	this->poverty().mouse_click(button_event),
      this->hands().mouse_click(button_event);
      else if (::game_status == GAMESTATUS::GAME_PLAY)
	this->hands().mouse_click(button_event);
      else if (::game_status == GAMESTATUS::GAME_SHOW_FULL_TRICK)
	this->full_trick().close();
      else if (::game_status == GAMESTATUS::GAME_SHOW_LAST_TRICK)
	this->last_trick().close();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_EVENT,
		      "Table::mouse_click()");
    } // void Table::mouse_click(GdkEventButton)



  /*****************************************************************************
   *
   * gboolean Table::expose_event(GtkWidget*,
   *				    GdkEventExpose* expose_event,
   *				    gpointer table_p)
   *
   * Parameters:	expose_event	- data of the expose evet
   * 		table_p	- pointer to the table
   *
   * Result:	TRUE
   * 
   * Version:	0.3.7
   *
   * Description:	call table.expose()
   *
   ****************************************************************************/
  gboolean
    Table::expose_event(GtkWidget*, GdkEventExpose* expose_event,
			gpointer table_p)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_EVENT,
		    "Table::expose_event()");

      ((Table*)table_p)->expose(expose_event);

      DEBUG_RETURNING(TRUE,
		      INFO_GTK_TABLE && INFO_GTK_EVENT,
		      "Table::expose_event()");
    } // gboolean Table::expose_event()

  /*****************************************************************************
   *
   * gboolean Table::resize_event(GtkWidget*,
   *				    GdkEventConfigure* configure_event,
   *				    gpointer table_p)
   *
   * Parameters:	configure_event	- data of the configure
   * 		table_p	- pointer to the table
   *
   * Result:	TRUE
   * 
   * Version:	0.3.7
   *
   * Description:	call table.resize()
   *
   ****************************************************************************/
  gboolean
    Table::resize_event(GtkWidget*, GdkEventConfigure* configure_event,
			gpointer table_p)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_EVENT,
		    "Table::resize_event()");

      ((Table*)table_p)->resize(configure_event);

      DEBUG_RETURNING(TRUE,
		      INFO_GTK_TABLE && INFO_GTK_EVENT,
		      "Table::resize_event()");
    } // gboolean Table::resize_event(GtkWidget*, GdkEventConfigure*, gpointer)


  /*****************************************************************************
   *
   * gboolean Table::mouse_click_event(GtkWidget*,
   *					 GdkEventButton* button_event,
   *					 gpointer table_p)
   *
   * Parameters:	button_event	- data of the button event
   * 		table_p	- pointer to the table
   *
   * Result:	TRUE
   * 
   * Version:	0.3.7
   *
   * Description:	call table.mouse_click()
   *
   ****************************************************************************/
  gboolean
    Table::mouse_click_event(GtkWidget*, GdkEventButton* button_event,
			     gpointer table_p)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_EVENT,
		    "Table::mouse_click_event()");

      ((Table*)table_p)->mouse_click(button_event);

      DEBUG_RETURNING(TRUE,
		      INFO_GTK_TABLE && INFO_GTK_EVENT,
		      "Table::mouse_click_event()");
    } // gboolean Table::mouse_click_event(GtkWidget*, GdkEventButton, gpointer)

  /*****************************************************************************
   *
   * static gboolean Table::key_event(GtkWidget* widget, GdkEventKey* key,
   *				    gpointer table)
   *
   * Parameters:	widget - the widget with the key
   *		key - the pressed key
   *		table - Table of the event
   *
   * Result:	-
   *
   * Version:	0.3.7
   *
   * Description:	calls table->key(key)
   *
   ****************************************************************************/
  gboolean
    Table::key_event(GtkWidget* widget, GdkEventKey* key, gpointer table)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_KEY && INFO_GTK_EVENT,
		    "Table::key_event()");

      DEBUG_ASSERTION((table != NULL),
		      "Table::key_event():\n"
		      "  'table' == NULL");

      ((Table*)table)->key(key);

      DEBUG_RETURNING(FALSE,
		      INFO_GTK_TABLE && INFO_GTK_KEY && INFO_GTK_EVENT,
		      "Table::key_event()");
    } // static gboolean Table::key_event(GtkWidget*, GdkEventKey*, gpointer)

  /*****************************************************************************
   *
   * void Table::key(GdkEventKey* key)
   *
   * Parameters:	key - the pressed key
   *
   * Result:	-
   * 
   * Version:	0.3.7
   *
   * Description:	manages the pressed keys for the Table window
   *
   ****************************************************************************/
  void
    Table::key(GdkEventKey* key)
    {
      DEBUG_CALLING(INFO_GTK_TABLE && INFO_GTK_KEY,
		    "Table::key()");

#include <gdk/gdkkeysyms.h>

      switch (key->keyval) {
      default: // pass the key to the playfield
	this->playfield().key(key);
	break;
      } // switch (key->keyval)

      DEBUG_RETURNING(VOID,
		      INFO_GTK_TABLE && INFO_GTK_KEY,
		      "Table::key()");
    } // void Table::key(GdkKeyEvent);

} // namespace GTK_DOKO
#endif // #ifdef USE_UI_GTK
