initial commit, lordsawar source, slightly modified
[lordsawar] / src / gui / hero-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 HERO_DIALOG_H
20 #define HERO_DIALOG_H
21
22 #include <memory>
23 #include <sigc++/trackable.h>
24 #include <gtkmm.h>
25
26 #include "vector.h"
27 #include "heroesmap.h"
28
29 class Hero;
30 class Item;
31 class History;
32
33 #include "decorated.h"
34
35 // dialog for showing info about a hero, esp. about the hero's items
36 class HeroDialog: public Decorated
37 {
38  public:
39     HeroDialog(Hero *hero, Vector<int> pos);
40     ~HeroDialog();
41
42     void set_parent_window(Gtk::Window &parent);
43
44     void run();
45     void hide();
46     
47  private:
48     Gtk::Dialog* dialog;
49     HeroesMap* heroesmap;
50
51     Hero *hero;
52     Vector<int> pos;
53     Gtk::Image *map_image;
54     Gtk::TreeView *heroes_treeview;
55     Gtk::TreeView *item_treeview;
56     Gtk::TreeView *events_treeview;
57     Gtk::Button *drop_button;
58     Gtk::Button *pickup_button;
59     Gtk::Label *info_label1;
60     Gtk::Label *info_label2;
61     Gtk::Button *next_button;
62     Gtk::Button *prev_button;
63
64     class HeroesColumns: public Gtk::TreeModelColumnRecord {
65     public:
66         HeroesColumns() 
67         { add(hero); add(name); }
68         
69         Gtk::TreeModelColumn<Hero *> hero;
70         Gtk::TreeModelColumn<Glib::ustring> name;
71     };
72     const HeroesColumns heroes_columns;
73     Glib::RefPtr<Gtk::ListStore> heroes_list;
74
75     class ItemColumns: public Gtk::TreeModelColumnRecord {
76     public:
77         ItemColumns() 
78         { add(image); add(name); add(attributes); add(status); add(item); }
79         
80         Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixmap> > image;
81         Gtk::TreeModelColumn<Glib::ustring> name;
82         Gtk::TreeModelColumn<Glib::ustring> attributes;
83         Gtk::TreeModelColumn<Glib::ustring> status;
84         Gtk::TreeModelColumn<Item *> item;
85     };
86     const ItemColumns item_columns;
87     Glib::RefPtr<Gtk::ListStore> item_list;
88
89     class EventsColumns: public Gtk::TreeModelColumnRecord {
90     public:
91         EventsColumns() 
92         { add(desc); add(history); }
93         
94         Gtk::TreeModelColumn<Glib::ustring> desc;
95         Gtk::TreeModelColumn<History *> history;
96     };
97     const EventsColumns events_columns;
98     Glib::RefPtr<Gtk::ListStore> events_list;
99
100     void on_hero_changed();
101     void on_item_selection_changed();
102     void on_drop_clicked();
103     void on_pickup_clicked();
104     void on_next_clicked();
105     void on_prev_clicked();
106
107     void add_item(Item *item, bool in_backpack);
108     void add_hero(Hero *hero);
109     void addHistoryEvent(History *event);
110     void fill_in_info_labels();
111
112     void on_map_changed(Glib::RefPtr<Gdk::Pixmap> map);
113     bool on_map_mouse_button_event(GdkEventButton *e);
114     void show_hero();
115     void update_buttons();
116     bool inhibit_hero_changed;
117     void update_hero_list();
118 };
119
120 #endif