initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / stack-editor-dialog.h
1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17 //  02110-1301, USA.
18
19 #ifndef STACK_EDITOR_DIALOG_H
20 #define STACK_EDITOR_DIALOG_H
21
22 #include <memory>
23 #include <sigc++/trackable.h>
24 #include <gtkmm.h>
25
26
27 class Stack;
28 class Army;
29 class Player;
30
31 //! Scenario editor.  Change the contents of a Stack.
32 class StackEditorDialog: public sigc::trackable
33 {
34  public:
35     StackEditorDialog(Stack *stack, int min_size = 1);
36     ~StackEditorDialog();
37
38     void set_parent_window(Gtk::Window &parent);
39
40     int run();
41     
42  private:
43     Gtk::Dialog* dialog;
44     Gtk::ComboBoxText *player_combobox;
45
46     Gtk::TreeView *army_treeview;
47     
48     class ArmyColumns: public Gtk::TreeModelColumnRecord {
49     public:
50         ArmyColumns()
51             { add(army); add(image); add(strength); add(moves); add(upkeep); 
52             add(name);}
53
54         Gtk::TreeModelColumn<Army *> army;
55         Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > image;
56         Gtk::TreeModelColumn<int> strength, moves, upkeep;
57         Gtk::TreeModelColumn<Glib::ustring> name;
58     };
59     const ArmyColumns army_columns;
60     Glib::RefPtr<Gtk::ListStore> army_list;
61
62     Gtk::CellRendererSpin strength_renderer;
63     Gtk::TreeViewColumn strength_column;
64     Gtk::CellRendererSpin moves_renderer;
65     Gtk::TreeViewColumn moves_column;
66     Gtk::CellRendererSpin upkeep_renderer;
67     Gtk::TreeViewColumn upkeep_column;
68     Gtk::Button *add_button;
69     Gtk::Button *remove_button;
70     Gtk::Button *copy_button;
71     Gtk::Button *edit_hero_button;
72     Gtk::CheckButton *fortified_checkbutton;
73
74     Stack *stack;
75     int min_size;
76
77     void on_add_clicked();
78     void on_remove_clicked();
79     void on_copy_clicked();
80     void on_edit_hero_clicked();
81     void on_selection_changed();
82     void on_fortified_toggled();
83     void on_player_changed();
84
85     void add_army(Army *a);
86     void set_button_sensitivity();
87     void cell_data_strength(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
88     void on_strength_edited(const Glib::ustring &path, const Glib::ustring &new_text);
89     void cell_data_moves(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
90     void on_moves_edited(const Glib::ustring &path, const Glib::ustring &new_text);
91     void cell_data_upkeep(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
92     void on_upkeep_edited(const Glib::ustring &path, const Glib::ustring &new_text);
93
94     Player *get_selected_player();
95 };
96
97 #endif