/* This file is part of cardwords
   (c) 1999 2000 Tobias Peters
   see file COPYING for the copyright terms.
   
   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 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
*/

// cardwords_gtk_cardtable.hh

#ifndef CARDWORDS_GTK_CARDTABLE_HH
#define CARDWORDS_GTK_CARDTABLE_HH

#include <slist.h>
#include <gtk--/table.h>
#include "cardwords_matrix.hh"
#include "cardwords_cardtablelocation.hh"

namespace Gtk {class Label;}
namespace CardWords {
class Gtk_CardTableInfo;
class Gtk_CardTable;
class Gtk_Common_Card_Cell_Styles;
class Gtk_CardCell;
class CardTable;
class Move;

class Gtk_CardTable : public Gtk::Table
{
private:
  const CardTable * card_table;
  
public:
  const CardTable *
  get_card_table(void) const { return card_table; }

  Gtk_CardTable( const CardTable *,
                           size_t cell_width,
                           size_t cell_height,

                           bool use_digits_for_the_columns,
                           // and chars for the rows, otherwise the other way
                           // round
                          
                           bool column_indices_grow_rightwards,
                           // if true, the rightmost column has the greatest
                           // index
                          
                           bool row_indices_grow_upwards,

                           Gtk_CardTableInfo *);
  ~Gtk_CardTable();

  // A click on the card cell at this location has been performed:
  SigC::Signal1<void, CardTableLocation> cell_clicked;

  // When this method is called, the move has already been added to the
  // CardTable. The info is for the display:
  // Automatically calls unpre(). New Cards will be displayed in recent
  // style.
  void
  show_move(const Move &);

  // When unrecent() is called, all cards displayed in the special way for
  // recently added cards are converted to be displayed normally:
  void
  unrecent(void);

  // unpre() without args removes all cards that are currently being dis-
  // played but are not yet really on the card-table. This is for the user to
  // try moves out.
  void
  unpre(void);

  // pre (const Move &) displays this move, but it is not really on
  // the card-table. Calls unpre() to delete previous pre() moves.
  void
  pre (const Move &);

  const Gtk_Common_Card_Cell_Styles *
  get_styles(void) const;

  bool
  uses_digits_for_the_columns(void) const;
  // and chars for the rows, otherwise the other way
  // round
                          
  bool
  do_column_indices_grow_rightwards(void) const;
  // if true, the rightmost column has the greatest
  // index
                          
  bool
  do_row_indices_grow_upwards(void) const;

private:
  // Declaring the copy constructor private. It must not be used.
  Gtk_CardTable(const Gtk_CardTable &);

  void
  receive_click_on_cell(const Gtk_CardCell *);
  
  slist<CardTableLocation> recent_locations;
  slist<CardTableLocation> pre_locations;

  Matrix<Gtk_CardCell *> cells;

  Gtk_Common_Card_Cell_Styles * styles;

  vector<Gtk::Label *> upper_labels;
  vector<Gtk::Label *> lower_labels;
  vector<Gtk::Label *> left_labels;
  vector<Gtk::Label *> right_labels;

  // Where to display the info about the cell under the pointer:
  Gtk_CardTableInfo * card_table_info;

  bool use_digits_for_the_columns;
  // and chars for the rows, otherwise the other way
  // round
                          
  bool column_indices_grow_rightwards;
  // if true, the rightmost column has the greatest
  // index
                          
  bool row_indices_grow_upwards;
};
}
#endif

