/**********************************************************************
 *
 *   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_SETTINGS_HEADER
#define GTK_SETTINGS_HEADER

#include "dialog.h"
#include "widget.h"

#include "../../misc/setting.h"

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

  // Settings
  // +-general
  // | +-name
  // | +-language
  // | +-sound
  // | `-max future limit
  // +-behaviour
  // | +-show full trick window
  // | +-full trick delay
  // | +-show if valid
  // | +-card invalid delay
  // | +-card play delay
  // | +-show all hands
  // | `-show tripiles points
  // +-cards order
  // | `-cards order
  // `-appearance
  //   +-cards
  //   | +-graphic size
  //   | +-rotate trick cards
  //   | `-rotate icons
  //   +-theme
  //   | +-background
  //   | +-graphic family
  //   | +-graphic style
  //   | `-cards back
  //   +-fonts
  //   | +-name font
  //   | +-name font color
  //   | +-trickpiles points font
  //   | +-trickpiles points font color
  //   | `-poverty shift arrow color
  //   `-splash screen
  //     +-show splash screen
  //     `-transparent splash screen
  // browser

  class Settings : public Dialog {
    public:
      class CardsOrder;

    public:
      // constructor
      Settings(class GTK_GUI* gui_a);

      // destructor
      ~Settings();

      // initialize the settings
      void init();
      void font_selector_init();

      // show the cards order
      void show_cards_order();

      // update the sensitivity
      void sensitivity_update();

    private:
      // event for applying the settings
      static void apply_event(GtkWidget*, gpointer settings);
      // event for resetting the settings
      static void reset_event(GtkWidget*, gpointer settings);

    public:
      void apply(); // apply the settings
      void reset(); // reset the settings

      // updates the type from the settings
      void update(int const type);
      void font_update(gchar const* const font_name,
		       GtkWidget* font_label);
      void font_color_update(gchar const* const font_color_name,
			     GtkWidget* font_color_label);
      // the variables
      Setting& setting_backup();

      // the widget for the setting
      XGtkCheckButton& button(const Setting::TypeBool type);
      // the widget for the setting
      XGtkLabelAdjustment& button(const Setting::TypeUnsigned type);
      // the widget for the setting
      XGtkWidget& button(const Setting::TypeString type);

      // change of a button
      static void change_event(GtkWidget*, gpointer settings);
      void change();

    private:
#include "settings.menu.h"  

      // select the font and color with a dialog
    private:
      static void open_name_font_selector_event(GtkWidget*,
						gpointer settings);
      static void take_name_font_event(GtkWidget*,
				       gpointer settings);
      static void open_name_font_color_selector_event(GtkWidget*,
						      gpointer settings);
      static void take_name_font_color_event(GtkWidget*,
					     gpointer settings);
      static void open_name_active_font_color_selector_event(GtkWidget*,
							     gpointer settings);
      static void take_name_active_font_color_event(GtkWidget*,
						    gpointer settings);
      static void open_trickpile_points_font_selector_event(GtkWidget*,
							    gpointer settings);
      static void take_trickpile_points_font_event(GtkWidget*,
						   gpointer settings);
      static void open_trickpile_points_font_color_selector_event(GtkWidget*,
								  gpointer settings);
      static void take_trickpile_points_font_color_event(GtkWidget*,
							 gpointer settings);

      static void open_poverty_shift_arrow_color_selector_event(GtkWidget*,
								gpointer settings);
      static void take_poverty_shift_arrow_color_event(GtkWidget*,
						       gpointer settings);

    public:
      void open_name_font_selector();
      void take_name_font();
      void open_name_font_color_selector();
      void take_name_font_color();
      void open_name_active_font_color_selector();
      void take_name_active_font_color();
      void open_trickpile_points_font_selector();
      void take_trickpile_points_font();
      void open_trickpile_points_font_color_selector();
      void take_trickpile_points_font_color();
      void open_poverty_shift_arrow_color_selector();
      void take_poverty_shift_arrow_color();

      // update the language
      void language_update();

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

    private:
      // button for resetting the settings
      GtkWidget* button_reset;

      // the notebook
      GtkWidget* notebook;
      GtkWidget* notebook_appearance;

      // labels for the bookmarks
      vector<XGtkLabel*> label_p;

      vector<XGtkCheckButton*> bool_p;
      vector<XGtkLabelAdjustment*> unsigned_p;
      vector<XGtkWidget*> string_p;

      GtkWidget* name_font_selector;
      GtkWidget* name_font_color_selector;
      GtkWidget* name_active_font_color_selector;
      GtkWidget* trickpile_points_font_selector;
      GtkWidget* trickpile_points_font_color_selector;
      GtkWidget* poverty_shift_arrow_color_selector;

    public:
      CardsOrder* cards_order;

    private:
      Setting setting_backup_p;

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

} // namespace GTK_DOKO

#endif // #ifndef GTK_SETTINGS_HEADER
#endif // #ifdef USE_UI_GTK
