/**********************************************************************
 *
 *   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_GUI_HEADER
#define GTK_GUI_HEADER

#include "pixmap.h"

#include "../../game/reservation.h"
#include "../../card/card.h"

class Player;

// GTK_GUI
// +-Cards
// +-Icons
// +-Splash
// +-Settings
// +-BugReport
// +-Help
// +-License
// +-LicenseCardset
// +-About
// +-MainWindow
// | `-Menu
// `-Playfield
//   +-Table
//   | +-Hands
//   | +-IconGroups
//   | +-Names
//   | +-TrickPiles
//   | +-Trick
//   | +-FullTrick
//   | +-LastTrick
//   | '-PartyPoints
//   +-PartySettings
//   | +-Players
//   | | +-Player
//   | | `-AiConfigs
//   | |   `-AiConfig
//   | `-Rules
//   +-Reservation
//   +-GameType
//   `-GameFinished

namespace GTK_DOKO {
  class Pixmap;
  class Cards;
  class Icons;
  class Splash;
  class Settings;
  class BugReport;
  class Help;
  class License;
  class LicenseCardset;
  class About;
  class MainWindow;
  class Playfield;

  /// all the elements of the gui
  class GTK_GUI {
    public:
    // updates the GUI
    static void update();
    // sleeps 'sleep_usec' thousands of seconds
    // (UINT_MAX for infinity)
    static void sleep(unsigned const sleep_usec);

    // quits the main loop
    static void main_quit();
    static gint main_quit(gpointer);

    // show the window
    static void window_show(GtkWidget*, gpointer window);
    // hide the window
    static void window_hide(GtkWidget*, gpointer window);

    public:
    // constructor
    GTK_GUI(int& argc, char**& argv);

    // inits the gui
    void init();

    // returns the logo
    Pixmap& logo();

    Cards& cards(); // the cards
    Icons& icons(); // the icons
    Splash& splash(); // the splash screen
    Settings& settings(); // the settings window
    BugReport& bug_report(); // the bug report
    Help& help(); // the help
    License& license(); // the license window
    LicenseCardset& license_cardset(); // the cardset license window
    About& about(); // the about window
    MainWindow& main_window(); // the main window
    Playfield& playfield(); // the playfield


    // quit the program
    static void quit_event(GtkWidget*, gpointer gui);
    void quit();

    void party_open(); // the party is opened
    void party_start(); // the party is opened
    void game_open(); // the game is opened
    void game_start(); // the game is started
    void game_finish(); // the game is finished
    void game_close(); // the game is closed
    void party_finish(); // the party is finished
    void party_close(); // the party is closed

    // get the reservation from the player
    ::Reservation reservation_get(Player const& player);

    // show the gametype
    void gametype_show();

    // get a card
    Card card_get(Player const& player);

    // the selected card
    unsigned selected_card() const;

    // selects the card
    bool select_card_all(unsigned const card_all_no_a);

    public:
    // updates the language
    void language_update();

    // key event in an entrye
    // just take <Escape> for quitting the program
    static gboolean key_event_in_entry(GtkWidget*, GdkEventKey* key,
				       gpointer);

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

    // event for resetting the cursor
    static gint cursor_reset_event(gpointer gtk_gui);
    // reset the cursor
    void cursor_reset();

    public:
    // the color depth
    gint color_depth;
    // a window for creating gc's and so on
    GdkWindow* ref_window;

    // the GC
    GdkGC* gc;

    private:
    // the number of the selected card
    unsigned selected_card_p;

    // the logo
    Pixmap logo_p;

    // the cards
    Cards* cards_p;
    // the icons
    Icons* icons_p;

    // the splash screen
    Splash* splash_p;

    // the settings window
    Settings* settings_p;

    // the bug report
    BugReport* bug_report_p;

    // the help system
    Help* help_p;

    // the license windows
    License* license_p;
    // the cardset license windows
    LicenseCardset* license_cardset_p;
    // the about windows
    About* about_p;

    // the main window
    MainWindow* main_window_p;

    // the playfield
    Playfield* playfield_p;

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

} // namespace GTK_DOKO

#endif // #ifdef USE_UI_GTK_GUI_HEADER
#endif // #ifdef USE_UI_GTK
