/**********************************************************************
 *
 *   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_PARTY_SETTINGS_PLAYERS_AICONFIGS_AICONFIG_HEADER
#define GTK_PARTY_SETTINGS_PLAYERS_AICONFIGS_AICONFIG_HEADER

#include "widget.h"

#include "aiconfigs.h"

#include "../../player/aiconfig.h"
#include "../../player/player.h"

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

  /**
   **
   ** @brief	the configuration dialog for an ai
   **
   ** @author	Diether Knof
   **
   ** @todo	update the maximal future limit when changed in the settings
   **
   **/
  class PartySettings::Players::AiConfigs::AiConfig {
    public:
      // constructor
      AiConfig(class PartySettings::Players::AiConfigs* const aiconfigs,
	       class PartySettings::Players::Player* const player_config);
      // destructor
      ~AiConfig();


      // the variables
      class AiConfigs& aiconfigs(); // the corresponding aiconfiguration
      class PartySettings::Players::Player& player_config();
      class ::Player& player(); // the corresponding player
      class ::Aiconfig& aiconfig(); // the corresponding configuration

      // the widget with all elements
      GtkWidget* widget();

      // the widget for the configuration
      XGtkCheckButton& button(Aiconfig::TypeBool const type);
      // the widget for the configuration
      XGtkLabelAdjustment& button(Aiconfig::TypeUnsigned const type);


      // change of a button
      static void aitype_change_event(GtkWidget* widget, gpointer aiconfig);
      static void change_event(GtkWidget* widget, gpointer aiconfig);
      void change(int const type);
      void aitype_change(int const type);


      // update the sensitivity
      void sensitivity_update();

      // update the aiconfig
      void update();

      static void hardcoded_select_event(GtkWidget*, gpointer aiconfig);
      void hardcoded_get();

      static void load_select_event(GtkWidget*, gpointer aiconfig);
      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 aiconfig);
      static void menu_destroy(GtkWidget* menu, gpointer);
      // load the aiconfig
      void load(string const& filename);

      // save the aiconfig
      static void save_event(GtkWidget* file_selection, gpointer aiconfig);
      void save();

      // select an aiconfig to adopt
      static void adopt_select_event(GtkWidget*, gpointer aiconfig);
      void adopt_select();
      // adopt the aiconfig
      static void adopt_event(GtkWidget* widget, gpointer aiconfig);
      void adopt(::Aiconfig const& aiconfig);

      // allot aiconfig to all players
      static void allot_event(GtkWidget*, gpointer aiconfig);
      // allot aiconfig to all players
      void allot();

      // update the language
      void language_update();

      // key event
      void key(GdkEventKey* key);

    private:
      class PartySettings::Players::AiConfigs* const aiconfigs_;
      class PartySettings::Players::Player* const player_config_;

      GtkWidget* container;
      GtkWidget* notebook_;

      GtkWidget* button_hardcoded;
      GtkWidget* button_load;
      GtkWidget* button_save;
      GtkWidget* file_selection_save;
      GtkWidget* button_adopt;
      GtkWidget* button_allot;


      vector<XGtkRadioButton*> aitype_;
      vector<XGtkCheckButton*> bool_;
      vector<XGtkLabelAdjustment*> unsigned_;

      vector<XGtkLabel*> label_;
      // ***ToDo  vector<XGtkLabelSpinbutton*> card_;

    private: // not to be used
      AiConfig();
      AiConfig(AiConfig const&);
      AiConfig& operator=(AiConfig const&);
  }; // class PartySettings::Players::Player::AiConfig : public Dialog

} // namespace GTK_DOKO

#endif // #ifndef GTK_PARTY_SETTINGS_PLAYERS_AICONFIGS_AICONFIG_HEADER
#endif // #ifdef USE_UI_GTK
