1 |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006, 2007 Andreas Persson |
3 |
* |
4 |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
6 |
* published by the Free Software Foundation; either version 2, or (at |
7 |
* your option) any later version. |
8 |
* |
9 |
* This program is distributed in the hope that it will be useful, but |
10 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 |
* General Public License for more details. |
13 |
* |
14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with program; see the file COPYING. If not, write to the Free |
16 |
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
17 |
* 02110-1301 USA. |
18 |
*/ |
19 |
|
20 |
#ifndef GIGEDIT_DIMENSIONMANAGER_H |
21 |
#define GIGEDIT_DIMENSIONMANAGER_H |
22 |
|
23 |
#include <glibmm/property.h> |
24 |
#include <gtkmm/window.h> |
25 |
#include <gtkmm/layout.h> |
26 |
#include <gtkmm/button.h> |
27 |
#include <gtkmm/buttonbox.h> |
28 |
#include <gtkmm/treeview.h> |
29 |
#include <gtkmm/liststore.h> |
30 |
#include <gtkmm/scrolledwindow.h> |
31 |
#include <gtkmm/checkbutton.h> |
32 |
|
33 |
#include <gig.h> |
34 |
#include <set> |
35 |
|
36 |
class DimTypeCellRenderer : public Gtk::CellRendererText { |
37 |
public: |
38 |
Glib::PropertyProxy<gig::dimension_t> propertyDimType() { |
39 |
return m_propertyDimType.get_proxy(); |
40 |
} |
41 |
|
42 |
Glib::PropertyProxy<int> propertyUsageCount() { |
43 |
return m_propertyUsageCount.get_proxy(); |
44 |
} |
45 |
|
46 |
Glib::PropertyProxy<int> propertyTotalRegions() { |
47 |
return m_propertyTotalRegions.get_proxy(); |
48 |
} |
49 |
|
50 |
DimTypeCellRenderer(); |
51 |
protected: |
52 |
void typeChanged(); |
53 |
void statsChanged(); |
54 |
private: |
55 |
Glib::Property<gig::dimension_t> m_propertyDimType; |
56 |
Glib::Property<int> m_propertyUsageCount; |
57 |
Glib::Property<int> m_propertyTotalRegions; |
58 |
}; |
59 |
|
60 |
class IntSetCellRenderer : public Gtk::CellRendererText { |
61 |
public: |
62 |
Glib::PropertyProxy<std::set<int> > propertyValue() { |
63 |
return m_propertyValue.get_proxy(); |
64 |
} |
65 |
|
66 |
IntSetCellRenderer(); |
67 |
protected: |
68 |
void valueChanged(); |
69 |
private: |
70 |
Glib::Property<std::set<int> > m_propertyValue; |
71 |
}; |
72 |
|
73 |
class DimensionManager : public Gtk::Window { |
74 |
public: |
75 |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
76 |
sigc::signal<void, gig::Region*> region_changed_signal; |
77 |
|
78 |
DimensionManager(); |
79 |
void show(gig::Region* region); |
80 |
void set_region(gig::Region* region); |
81 |
protected: |
82 |
gig::Region* region; |
83 |
Gtk::VBox vbox; |
84 |
Gtk::HButtonBox buttonBox; |
85 |
Gtk::ScrolledWindow scrolledWindow; |
86 |
Gtk::TreeView treeView; |
87 |
Gtk::Button addButton; |
88 |
Gtk::Button removeButton; |
89 |
Gtk::CheckButton allRegionsCheckBox; |
90 |
|
91 |
DimTypeCellRenderer m_cellRendererDimType; |
92 |
IntSetCellRenderer m_cellRendererIntSet; |
93 |
|
94 |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
95 |
public: |
96 |
ModelColumns() { |
97 |
add(m_type); |
98 |
add(m_bits); |
99 |
add(m_zones); |
100 |
add(m_description); |
101 |
add(m_usageCount); |
102 |
add(m_totalRegions); |
103 |
} |
104 |
|
105 |
Gtk::TreeModelColumn<gig::dimension_t> m_type; |
106 |
Gtk::TreeModelColumn<std::set<int> > m_bits; |
107 |
Gtk::TreeModelColumn<std::set<int> > m_zones; |
108 |
Gtk::TreeModelColumn<Glib::ustring> m_description; |
109 |
Gtk::TreeModelColumn<int> m_usageCount; |
110 |
Gtk::TreeModelColumn<int> m_totalRegions; |
111 |
} tableModel; |
112 |
|
113 |
class ComboModelColumns : public Gtk::TreeModel::ColumnRecord { |
114 |
public: |
115 |
ComboModelColumns() { |
116 |
add(m_type_id); |
117 |
add(m_type_name); |
118 |
} |
119 |
|
120 |
Gtk::TreeModelColumn<int> m_type_id; |
121 |
Gtk::TreeModelColumn<Glib::ustring> m_type_name; |
122 |
} comboModel; |
123 |
|
124 |
Glib::RefPtr<Gtk::ListStore> refTableModel; |
125 |
bool ignoreColumnClicked; //HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired |
126 |
|
127 |
void onAllRegionsCheckBoxToggled(); |
128 |
void onColumnClicked(); |
129 |
void refreshManager(); |
130 |
void addDimension(); |
131 |
void removeDimension(); |
132 |
bool allRegions() const; |
133 |
}; |
134 |
|
135 |
#endif // GIGEDIT_DIMENSIONMANAGER_H |