/**********************************************************************
 *
 *   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
 *
 **********************************************************************/

#ifdef USE_UI_GTK
#ifndef GTK_RULES_HEADER
#define GTK_RULES_HEADER

#include "widget.h"

#include "../../party/rule.h"

namespace GTK_DOKO {
#include <gtk/gtkwidget.h>

  // Rules
  // +-other
  // | +-show tricks number
  // | +-show all hands
  // | +-show if valid
  // | +-show tricks in trickpiles
  // | +-show trickpiles points
  // | +-card hint
  // | `-take back tricks
  // +-Poverty
  // | +-poverty
  // | +-poverty shift
  // | +-poverty shift only trump
  // | +-throw with one trump
  // | +-throw with five nines
  // | +-throw with six kings
  // | `-throw when fox highest trump
  // +-Marriage
  // | +-marriage determination
  // | +-marriage first color
  // | +-marriage first single color
  // | +-marriage first trump
  // | `-genscher
  // +-soli
  // | +-soli
  // | +-color solo
  // | +-koehler solo
  // | +-meatless solo
  // | +-jack solo
  // | +-queen solo
  // | +-king solo
  // | +-queen-jack solo
  // | +-king-jack solo
  // | `-king-queen solo
  // +-dollen
  // | +-dollen
  // | +-second over first
  // | `-contrary in last trick
  // +-swines
  // | +-swines
  // | +-in solo
  // | +-announcement begin
  // | +-only second
  // | +-hyperswines
  // | +-in solo
  // | `-announcement begin
  // +-extrapoints
  // | +-catch fox
  // | +-fox last trick
  // | +-double fox last trick
  // | +-karlchen
  // | +-catch karlchen
  // | +-both karlchen
  // | +-catch both karlchen
  // | +-dolle jabs dolle
  // | `-heart trick
  // +-announcements
  // | +-announcement first trick thirty points
  // | +-announcement reply
  // | +-announcement re doubles
  // | +-no 120
  // | +-no 90
  // | +-no 60
  // | +-no 30
  // | `-no 0
  // `-tournament
  //   +-number of rounds limited
  //   +-number of ronds
  //   +-points limited
  //   +-points
  //   +-number of players
  //   +-number of players in game
  //   +-with nines
  //   +-number of duty soli
  //   +-number of duty color soli
  //   +-number of duty picture soli
  //   `-lustsolo player leads

  // *** missing: point summing mode

  class Rules {
    public:
      // constructor
      Rules(class PartySettings* const party_settings);

      // destructor
      ~Rules();

      // update the sensitivity
      void sensitivity_update();

      // create a backup
      void backup();
      // destroy the backup
      void backup_destroy();

      // reset the rules
      void reset(); 

      // updates all rules
      void update();
      // updates the type from the rules
      void update(int const type);


      // the variables

      // the gui
      class GTK_GUI& gui();
      // the party settings
      class PartySettings& party_settings();

      // the widget
      GtkWidget* widget();
      // the widget for the rule
      XGtkCheckButton& button(const Rule::TypeBool type);
      // the widget for the rule
      XGtkLabelAdjustment& button(const Rule::TypeUnsigned type);

      // change of a button
    private:
      static void change_event(GtkWidget* widget, gpointer rules);
      static void save_event(GtkWidget* file_selection, gpointer rules);
    public:
      void change(int const type);
      void save();

    private:
      static void load_select_event(GtkWidget*, gpointer rules);
      void load_menu_create(GtkWidget* menu);
      void load_menu_add_subdir(GtkWidget* menu,
				string const& main_directory,
				string const& directory,
				unsigned const depth);
      static void load_menu_select_event(GtkWidget* menu_item,
					 gpointer rules);
      static void menu_destroy(GtkWidget* menu, gpointer);
    public:
      // update the language
      void language_update();
      // a key press
      void key(GdkEventKey* key);

    private:
      class PartySettings* const party_settings_;

      Rule const* rule_backup;

      GtkWidget* container;
      GtkWidget* notebook;

      GtkWidget* button_load;
      GtkWidget* button_save;
      GtkWidget* file_selection_save;

      vector<XGtkLabel*> label_;
      vector<XGtkCheckButton*> bool_;
      vector<XGtkLabelAdjustment*> unsigned_;

    private: // not to be used
      Rules();
      Rules(Rules const&);
      Rules& operator=(Rules const&);
  }; // class Rules

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