/* 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_actionselection.hh

#ifndef CARDWORDS_GTK_ACTIONSELECTION_HH
#define CARDWORDS_GTK_ACTIONSELECTION_HH

#include "cardwords_actionselection.hh"
#include "cardwords_gtk_cardtable.hh"
namespace Gtk {class Button;}
namespace Gtk {class ToggleButton;}
namespace Gtk {class Pixmap;}

class CardWords_Gtk_ActionSelection : public CardWords_ActionSelection,
                                      public Gtk::HBox
{
public:
  int key_pressed (GdkEventKey *);

  SigC::Signal0<void> action_selection_activated; // Return was pressed.

  SigC::Signal0<void> invalid_key_press; // Beep someone.

  SigC::Signal1<void, CardWords_Card *> card_clicked;// mouse click on a card:
  //                                              remove it
  
  CardWords_Gtk_ActionSelection(CardWords_Hand *, // The hand from where to
                                // get the cards. The hand will be modified,
                                // but will be restored when reset() is
                                // called.
                                CardWords_Gtk_CardTable * // With this
                                // pointer, invalid geometric moves will be
                                // detected. Moves will be displayed on the
                                // table.
                                );

  void
  update(void);// something changed, redraw screen

private:
  CardWords_Gtk_CardTable * gtk_card_table;

  Gtk::Label  *       tablelocation_label;
  Gtk::Button *       ok_button;
  Gtk::ToggleButton * horizontal_vertikal_button;
  Gtk::Label  *       horizontal_vertikal_label;

  Gtk::Pixmap *       horizontal_pixmap;
  Gtk::Pixmap *       vertikal_pixmap;
  
  Gtk::Label *        start_location_label;
  
  bool currently_updating;// something changed, redrawing screen
  
  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 *);

  void
  toggle_button_clicked(void);

};
                                    
#endif
