1 // Copyright (C) 2011, 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_ARMY_BUTTON_H 20 #define STACK_ARMY_BUTTON_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 ArmyInfoTip; 29 class Army; 30 class Stack; 31 // a button-pair. shows an army button, and maybe another button for the stack. 32 class StackArmyButton: public Gtk::Box 33 { 34 public: 35 //! Constructor for building this object with gtk::builder 36 StackArmyButton(BaseObjectType* base, const Glib::RefPtr<Gtk::Builder> &xml); 37 38 //!Destructor. 39 ~StackArmyButton(); 40 get_active()41 bool get_active() const { return army_button->get_active();} 42 void update_stack_button(bool selected); 43 void reset(); //go back to an empty disabled, untoggled button with the circle 44 void draw(Stack *s, Army *a, guint32 circle_colour_id, bool toggled); 45 46 //Signals 47 sigc::signal<void> stack_clicked; 48 sigc::signal<void> army_toggled; 49 50 //Statics 51 static StackArmyButton * create(); 52 53 protected: 54 55 private: 56 Stack *d_stack; 57 Army *d_army; 58 guint32 d_circle_colour_id; 59 60 Gtk::ToggleButton *army_button; 61 Gtk::Image *army_image; 62 Gtk::Label *army_label; 63 Gtk::Button *stack_button; 64 Gtk::Image *stack_image; 65 Gtk::Box *stack_button_container; 66 Gtk::EventBox *eventbox; 67 ArmyInfoTip *army_info_tip; 68 69 sigc::connection stack_conn; 70 sigc::connection army_conn[3]; 71 72 bool on_army_button_event(GdkEventButton *e); 73 void fill_buttons(); 74 void fill_army_button(); 75 void fill_stack_button(); 76 void setup_signals(); 77 void clear_signals(); 78 }; 79 80 #endif // STACK_ARMY_BUTTON 81