1 /**********************************************************************
2  *
3  *   FreeDoko a Doppelkopf-Game
4  *
5  *   Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders
6  *
7  *   This program is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU General Public License as
9  *   published by the Free Software Foundation; either version 2 of
10  *   the License, or (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *   You can find this license in the file 'gpl.txt'.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  *   MA  02111-1307  USA
22  *
23  *  Contact:
24  *    Diether Knof dknof@posteo.de
25  *
26  **********************************************************************/
27 
28 #ifdef USE_UI_GTKMM
29 
30 #pragma once
31 
32 #include "htin.h"
33 
34 #include "../../game/reservation.h"
35 
36 #include "widgets/sticky_dialog.h"
37 namespace Gtk {
38 class CheckButton;
39 class RadioButton;
40 class Notebook;
41 class Label;
42 class Table;
43 } // namespace Gtk
44 
45 namespace UI_GTKMM_NS {
46 class Table;
47 
48 /**
49  ** the reservation
50  **
51  ** @todo   ordering of the swines
52  **/
53 class Reservation : public HTIN, public Gtk::StickyDialog {
54   public:
55     Reservation(Table& table, Position position);
56     ~Reservation() override;
57 
58     // the corresponding player
59     Player& player();
60     // the corresponding game
61     Game& game();
62 
63     bool changed() const override;
64     void draw(Cairo::RefPtr<::Cairo::Context> cr) override;
65     Outline outline() const override;
66 
67     // show the reservation for selecting before it is the turn of the player
68     void show_for_selection();
69 
70     // get a reservation
71     ::Reservation get();
72 
73     // dummy function
74     void draw(Cairo::RefPtr<::Cairo::Context> cr, bool update);
75 
76     // set the default reservation
77     void set_default();
78     // the gametype has changed (by the user)
79     void gametype_changed(GameType gametype);
80     // the marriage selector has changed (by the user)
81     void marriage_selector_changed(MarriageSelector marriage_selector);
82     // the swines butten has changed (by the user)
83     void swines_changed();
84 
85     // update the game/swines announcement, ... according to the selected reservation
86     void update_for_reservation();
87 
88     // update the sensitivity (i.e. swines, marriage, poverty)
89     void sensitivity_update();
90 
91     // update the selected reservation (when the page was changed)
92     void update_player_reservation();
93 
94   private:
95     // initialize the window
96     void init();
97 
98     // the selected page has changed
99     void switch_page_event(Widget* widget, guint pageno);
100 
101     // close the window and announce the reservation
102     void announce();
103 
104   private:
105     Gtk::Button* announce_button = nullptr;
106 
107     Gtk::Label* bock_label = nullptr;
108 
109     Gtk::Notebook* notebook = nullptr;
110     Gtk::CheckButton* swines_button = nullptr;
111     Gtk::CheckButton* hyperswines_button = nullptr;
112     Gtk::CheckButton* solo_swines_button = nullptr;
113     Gtk::CheckButton* solo_hyperswines_button = nullptr;
114     std::map<GameType, Gtk::RadioButton*> gametype_buttons;
115     std::map<MarriageSelector, Gtk::RadioButton*> marriage_selector_buttons;
116 
117     Gtk::Label* remaining_rounds_label = nullptr;
118     Gtk::Label* remaining_rounds_number = nullptr;
119     Gtk::Label* remaining_games_label = nullptr;
120     Gtk::Label* remaining_games_number = nullptr;
121     Gtk::Label* remaining_points_label = nullptr;
122     Gtk::Label* remaining_points_number = nullptr;
123     Gtk::Label* duty_free_soli_label = nullptr;
124     Gtk::Label* duty_free_soli_number = nullptr;
125     Gtk::Label* duty_color_soli_label = nullptr;
126     Gtk::Label* duty_color_soli_number = nullptr;
127     Gtk::Label* duty_picture_soli_label = nullptr;
128     Gtk::Label* duty_picture_soli_number = nullptr;
129 
130     Gtk::CheckButton* offer_duty_solo_button = nullptr;
131 
132     // whether this reservation is already announced
133     bool announced = false;
134     // whether the window is in an update mode
135     bool in_update = false;
136 
137   private: // unused
138     Reservation() = delete;
139     Reservation(Reservation const&) = delete;
140     Reservation& operator=(Reservation const&) = delete;
141 }; // class Reservation : public Base, public Gtk::StickyDialog
142 
143 } // namespace UI_GTKMM_NS
144 
145 #endif // #ifdef USE_UI_GTKMM
146