initial commit, lordsawar source, slightly modified
[lordsawar] / src / gui / report-dialog.h
1 //  Copyright (C) 2007, 2008, 2009 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 #ifndef REPORT_DIALOG_H
19 #define REPORT_DIALOG_H
20
21 #include <memory>
22 #include <vector>
23 #include <sigc++/trackable.h>
24 #include <gtkmm.h>
25
26 #include "LocationList.h"
27 #include "vectormap.h"
28 #include "citymap.h"
29 #include "armymap.h"
30 #include "player.h"
31
32 class Action;
33 class BarChart;
34
35 #include "decorated.h"
36
37 //
38 //
39 class ReportDialog: public Decorated
40 {
41  public:
42     enum ReportType {ARMY = 0, CITY, GOLD, PRODUCTION, WINNING};
43
44     ReportDialog(Player *player, ReportType type);
45     ~ReportDialog();
46
47     void set_parent_window(Gtk::Window &parent);
48
49     static std::string calculateRank(std::list<guint32> scores, guint32 score);
50     void run();
51     void hide();
52     
53  private:
54     Gtk::Dialog* dialog;
55     VectorMap* vectormap;
56     ArmyMap* armymap;
57     CityMap* citymap;
58
59     Gtk::Image *map_image;
60     
61     Gtk::Label *army_label;
62     Gtk::Label *city_label;
63     Gtk::Label *gold_label;
64     Gtk::Label *production_label;
65     Gtk::Label *winning_label;
66     Gtk::Notebook *report_notebook;
67     Gtk::Alignment *army_alignment;
68     BarChart *army_chart;
69     Gtk::Alignment *city_alignment;
70     BarChart *city_chart;
71     Gtk::Alignment *gold_alignment;
72     BarChart *gold_chart;
73     Gtk::Alignment *winning_alignment;
74     BarChart *winning_chart;
75
76     Player *d_player;
77     void on_army_map_changed(Glib::RefPtr<Gdk::Pixmap> map);
78     void on_city_map_changed(Glib::RefPtr<Gdk::Pixmap> map);
79     void on_vector_map_changed(Glib::RefPtr<Gdk::Pixmap> map);
80     void on_switch_page(GtkNotebookPage *page, guint number);
81
82     Gtk::TreeView *armies_treeview;
83
84     class ArmiesColumns: public Gtk::TreeModelColumnRecord {
85     public:
86         ArmiesColumns() 
87         { add(city_id) ;add(image); add(desc);}
88         
89         Gtk::TreeModelColumn<guint32> city_id;
90         Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > image;
91         Gtk::TreeModelColumn<Glib::ustring> desc;
92     };
93     const ArmiesColumns armies_columns;
94     Glib::RefPtr<Gtk::ListStore> armies_list;
95     void addProduction(const Action *action);
96     void on_close_button();
97     bool closing;
98     void fill_in_info();
99     void updateArmyChart();
100     void updateCityChart();
101     void updateGoldChart();
102     void updateWinningChart();
103     void on_army_selected();
104 };
105
106 #endif