1 //  Copyright (C) 2011, 2020 Ben Asselstine
2 //
3 //  This program is free software; you can redistribute it and/or modify
4 //  it under the terms of the GNU General Public License as published by
5 //  the Free Software Foundation; either version 3 of the License, or
6 //  (at your option) any later version.
7 //
8 //  This program is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //  GNU Library General Public License for more details.
12 //
13 //  You should have received a copy of the GNU General Public License
14 //  along with this program; if not, write to the Free Software
15 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 //  02110-1301, USA.
17 
18 #pragma once
19 #ifndef GAME_BUTTON_BOX_H
20 #define GAME_BUTTON_BOX_H
21 
22 #include <memory>
23 #include <sigc++/trackable.h>
24 #include <gtkmm.h>
25 #include <glibmm.h>
26 #include "Configuration.h"
27 
28 class Game;
29 // shows the game buttons in the main game window
30 class GameButtonBox: public Gtk::Box
31 {
32  public:
33      //! Constructor for building this object with gtk::builder
34     GameButtonBox(BaseObjectType* base, const Glib::RefPtr<Gtk::Builder> &xml);
35 
36     //!Destructor.
~GameButtonBox()37     ~GameButtonBox() {drop_connections();};
38 
39     void give_some_cheese();
40     bool get_end_turn_button_sensitive();
41     void setup_signals(Game *game);
42 
43     //Signals
44     sigc::signal<void> diplomacy_clicked;
45 
46     // Statics
47     static GameButtonBox * create();
48 
49  protected:
50 
51  private:
52     std::list<sigc::connection> connections;
53     Gtk::Button *next_movable_button;
54     Gtk::Button *center_button;
55     Gtk::Button *diplomacy_button;
56     Gtk::Button *defend_button;
57     Gtk::Button *park_button;
58     Gtk::Button *deselect_button;
59     Gtk::Button *search_button;
60     Gtk::Button *move_button;
61     Gtk::Button *move_all_button;
62     Gtk::Button *end_turn_button;
63 
64     void setup_button(Gtk::Button *button, sigc::slot<void> slot,
65                       sigc::signal<void, bool> &game_signal);
66 
67     void change_diplomacy_button_image (bool proposals_present);
68     void update_diplomacy_button (bool sensitive);
69 
70     void add_pictures_to_buttons();
71     void drop_connections();
72     void pad_image(Gtk::Image *image);
73     void add_picture_to_button (guint32 icontype, Gtk::Button *button);
74 };
75 
76 #endif // GAME_BUTTON_BOX
77