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

#ifndef CARDWORDS_GTK_ACTIONSELECTION_HH
#define CARDWORDS_GTK_ACTIONSELECTION_HH

#include "cardwords_actionselection.hh"
#include "cardwords_hand.hh"
#include <gtk--/box.h>

namespace Gtk {class Button;}
namespace Gtk {class ToggleButton;}
namespace Gtk {class Pixmap;}
namespace CardWords {
class Gtk_CardTable;
class Gtk_Common_Card_Cell_Styles;
class Gtk_CardCell;


class Gtk_ActionSelection : public 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, Card *> card_clicked;// mouse click on a card:
  //                                              remove it
  
  Gtk_ActionSelection(Hand *, // The hand from where to
                                // get the cards. The hand will be modified,
                                // but will be restored when reset() is
                                // called.
                                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:
  // Declaring the copy constructor private. It must not be used.
  Gtk_ActionSelection(const Gtk_ActionSelection &);

  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 Gtk_Common_Card_Cell_Styles * styles;

  class cell {
  public:
    Gtk_CardCell * gtk_card_cell;
    Card   * card; // Remember which card.
    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(Hand::const_iterator); // set to this card;
    void set(Card *);
  };
  vector<cell> cells;

  void
  received_click_on_card(const Gtk_CardCell *);

  void
  toggle_button_clicked(void);

};
}
#endif

