1 // This file is part of GtkEveMon.
2 //
3 // GtkEveMon 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 // You should have received a copy of the GNU General Public License
9 // along with GtkEveMon. If not, see <http://www.gnu.org/licenses/>.
10
11 #ifndef GTK_ITEM_DEATILS_HEADER
12 #define GTK_ITEM_DEATILS_HEADER
13
14 #include <gtkmm.h>
15
16 #include "api/apiskilltree.h"
17 #include "api/apicerttree.h"
18 #include "bits/character.h"
19 #include "gtkplannerbase.h"
20
21 /* The maximum history size. */
22 #define HISTORY_MAX_SIZE 9
23
24 /*
25 * This class keeps a history of recently viewed API elements (these
26 * are skills, certificates and items). New elements need to be added
27 * with append_element. A signal is then fired to notify the GUI
28 * to update to the new element.
29 */
30 class GtkItemHistory : public Gtk::Box
31 {
32 private:
33 std::vector<ApiElement const*> history;
34 std::size_t history_pos;
35 SignalApiElementSelected sig_elem_changed;
36
37 Gtk::Button back_but;
38 Gtk::Button next_but;
39 Gtk::Label position_label;
40
41 void update_sensitive (void);
42 void update_pos_label (void);
43 void back_clicked (void);
44 void next_clicked (void);
45
46 public:
47 GtkItemHistory (void);
48
49 void append_element (ApiElement const* elem);
50 SignalApiElementSelected& signal_elem_changed (void);
51 };
52
53 /* ---------------------------------------------------------------- */
54
55 /*
56 * A base class for various GUI elements that need the character sheet
57 * and fire two important events: Selection of new API elements and
58 * requests for enqueing a skill to the training plan.
59 */
60 class GtkItemDetailsBase
61 {
62 protected:
63 CharacterPtr character;
64 SignalPlanningRequested sig_planning_requested;
65 SignalApiElementSelected sig_element_selected;
66
67 public:
68 void set_character (CharacterPtr character);
69 SignalPlanningRequested& signal_planning_requested (void);
70 SignalApiElementSelected& signal_element_selected (void);
71 };
72
73 /* ---------------------------------------------------------------- */
74
75 /*
76 * Creates a list of dependencies (skills or certificates) for the
77 * specified element. The list contains both, skills and certificates
78 * if the subject element is a certificate.
79 */
80 class GtkDependencyList : public GtkItemDetailsBase, public Gtk::ScrolledWindow
81 {
82 private:
83 class GtkDependencyCols : public GuiPlannerElemCols
84 {
85 public:
86 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > elem_icon;
GtkDependencyCols(void)87 GtkDependencyCols (void)
88 { this->add(elem_icon); }
89 } deps_cols;
90 Glib::RefPtr<Gtk::TreeStore> deps_store;
91 GtkListViewHelper deps_view;
92
93 protected:
94 void recurse_append_skill_req (ApiSkill const* skill,
95 Gtk::TreeModel::iterator slot, int level, bool recurse = true);
96 void recurse_append_cert_req (ApiCert const* cert,
97 Gtk::TreeModel::iterator slot);
98 void on_row_activated (Gtk::TreeModel::Path const& path,
99 Gtk::TreeViewColumn* col);
100 void on_view_button_pressed (GdkEventButton* event);
101 bool on_query_element_tooltip (int x, int y, bool key,
102 Glib::RefPtr<Gtk::Tooltip> const& tooltip);
103
104 public:
105 GtkDependencyList (bool elem_indicator);
106 void set_skill (ApiSkill const* skill);
107 void set_cert (ApiCert const* cert);
108 };
109
110 /* ---------------------------------------------------------------- */
111
112 /* This GUI class shows details for skills. */
113 class GtkSkillDetails : public GtkItemDetailsBase, public Gtk::Box
114 {
115 private:
116 /* Skill details. */
117 Gtk::Label skill_primary;
118 Gtk::Label skill_secondary;
119 Gtk::Label skill_level[5];
120 Glib::RefPtr<Gtk::TextBuffer> desc_buffer;
121 GtkDependencyList deps;
122
123 public:
124 GtkSkillDetails (void);
125 void set_skill (ApiSkill const* skill);
126 };
127
128 /* ---------------------------------------------------------------- */
129
130 /* This GUI class shows details for certificates. */
131 class GtkCertDetails : public GtkItemDetailsBase, public Gtk::Box
132 {
133 private:
134 Glib::RefPtr<Gtk::TextBuffer> desc_buffer;
135 GtkDependencyList deps;
136
137 public:
138 GtkCertDetails (void);
139 void set_certificate (ApiCert const* cert);
140 };
141
142 /* ---------------------------------------------------------------- */
143
144 /*
145 * This GUI class is a container for detail GUIs. It shows the
146 * icon and name of the item and displays the appropriate detail GUI.
147 */
148 class GtkItemDetails : public GtkItemDetailsBase, public Gtk::Box
149 {
150 private:
151 ApiElement const* element;
152 Gtk::Image element_icon;
153 Gtk::Label element_path;
154 Gtk::Label element_name;
155 GtkItemHistory history;
156 Gtk::Box details_box;
157 GtkSkillDetails skill_details;
158 GtkCertDetails cert_details;
159
160 protected:
161 void on_element_changed (ApiElement const* elem);
162
163 public:
164 GtkItemDetails (void);
165
166 void set_element (ApiElement const* elem);
167 };
168
169 /* ---------------------------------------------------------------- */
170
171 inline SignalApiElementSelected&
signal_elem_changed(void)172 GtkItemHistory::signal_elem_changed (void)
173 {
174 return this->sig_elem_changed;
175 }
176
177 inline void
set_character(CharacterPtr character)178 GtkItemDetailsBase::set_character (CharacterPtr character)
179 {
180 this->character = character;
181 }
182
183 inline SignalPlanningRequested&
signal_planning_requested(void)184 GtkItemDetailsBase::signal_planning_requested (void)
185 {
186 return this->sig_planning_requested;
187 }
188
189 inline SignalApiElementSelected&
signal_element_selected(void)190 GtkItemDetailsBase::signal_element_selected (void)
191 {
192 return this->sig_element_selected;
193 }
194
195 #endif /* GTK_ITEM_DEATILS_HEADER */
196