1 // Copyright (C) 2011, 2014, 2015, 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 STACK_TILE_BOX_H 20 #define STACK_TILE_BOX_H 21 22 #include <sigc++/trackable.h> 23 #include <gtkmm.h> 24 #include <glibmm.h> 25 #include "Configuration.h" 26 27 class StackTile; 28 class Stack; 29 class ArmyInfoTip; 30 class Army; 31 class StackArmyButton; 32 33 // shows the listing of army units that coexist on a single map tile. 34 class StackTileBox: public Gtk::Box 35 { 36 public: 37 //! Constructor for building this object with gtk::builder 38 StackTileBox(BaseObjectType* base, const Glib::RefPtr<Gtk::Builder> &xml); 39 40 //!Destructor. 41 ~StackTileBox(); 42 43 static StackTileBox * create(); 44 void on_stack_info_changed(Stack *s); setInhibit(bool inhibit)45 void setInhibit(bool inhibit) {d_inhibit = inhibit;}; get_currently_selected_stack()46 Stack * get_currently_selected_stack() const {return currently_selected_stack;}; 47 void show_stack(StackTile *s); clear_selected_stack()48 void clear_selected_stack() {currently_selected_stack = NULL;}; set_selected_stack(Stack * s)49 void set_selected_stack(Stack*s) {currently_selected_stack =s;}; 50 void toggle_group_ungroup(); 51 52 //! Signals 53 sigc::signal<void, Stack*> stack_composition_modified; 54 sigc::signal<void, bool> stack_tile_group_toggle; 55 protected: 56 57 private: 58 bool d_inhibit; 59 Stack *currently_selected_stack; 60 ArmyInfoTip *army_info_tip; 61 typedef std::vector<StackArmyButton *> stack_army_buttons_type; 62 stack_army_buttons_type stack_army_buttons; 63 Gtk::Box *stack_info_box; 64 Gtk::Box *stack_info_container; 65 Gtk::Label *group_moves_label; 66 Gtk::Image *terrain_image; 67 Gtk::ToggleButton *group_ungroup_toggle; 68 bool d_inhibit_group_toggle; 69 70 sigc::connection army_conn[MAX_ARMIES_ON_A_SINGLE_TILE]; 71 sigc::connection stack_conn[MAX_ARMIES_ON_A_SINGLE_TILE]; 72 73 void pad_image(Gtk::Image *image); 74 void fill_in_group_info (StackTile *stile, Stack *s); 75 void on_army_toggled(StackArmyButton *toggle, Stack *stack, Army *army); 76 void on_stack_toggled(Stack *stack); 77 void on_group_toggled(Gtk::ToggleButton *toggle); 78 void reset_army_buttons(); 79 80 }; 81 82 #endif // STACK_TILE_BOX 83