/* This file is part of cardwords
   (c) 1999 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_handdisplay.hh

#ifndef CARDWORDS_GTK_HANDDISPLAY_HH
#define CARDWORDS_GTK_HANDDISPLAY_HH

#include "cardwords_hand.hh"
#include "cardwords_gtk_cardcell.hh"
#include <vector>

class CardWords_Gtk_HandDisplay : public Gtk_HBox
{
public:
  CardWords_Gtk_HandDisplay(const
                            CardWords_Gtk_Common_Card_Cell_Styles *
                            styles,
                            const CardWords_Hand *);
  ~CardWords_Gtk_HandDisplay();

  // Call this when the hand has changed:
  void
  update(void);

  // This signal is raised when the user clicks on a card in the hand
  Signal1<CardWords_Card *> card_clicked;
  
private:
  const CardWords_Hand * hand;

  const CardWords_Gtk_Common_Card_Cell_Styles * styles;

  class cell {
  public:
    CardWords_Gtk_CardCell * gtk_card_cell;
    CardWords_Card   * card; // Remember which card.
    CardWords_Card   * old_card; // Remember the card that was here before
    //                                  if the cell is empty now.
    cell (); // init with no card;

    ~cell(); // delete the card cell if it is != 0
    void set(CardWords_Hand::const_iterator); // set to this card;
    void set(CardWords_Card *);
  };
  vector<cell> cells;

  void
  received_click_on_card(const CardWords_Gtk_CardCell *);
};

#endif

