1 |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006 - 2017 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/box.h> |
25 |
#include <gtkmm/window.h> |
26 |
#include <gtkmm/layout.h> |
27 |
#include <gtkmm/button.h> |
28 |
#include <gtkmm/buttonbox.h> |
29 |
#include <gtkmm/treeview.h> |
30 |
#include <gtkmm/liststore.h> |
31 |
#include <gtkmm/scrolledwindow.h> |
32 |
#include <gtkmm/checkbutton.h> |
33 |
|
34 |
#ifdef LIBGIG_HEADER_FILE |
35 |
# include LIBGIG_HEADER_FILE(gig.h) |
36 |
#else |
37 |
# include <gig.h> |
38 |
#endif |
39 |
|
40 |
#include <set> |
41 |
#include "ManagedWindow.h" |
42 |
|
43 |
class DimTypeCellRenderer : public Gtk::CellRendererText { |
44 |
public: |
45 |
Glib::PropertyProxy<gig::dimension_t> propertyDimType() { |
46 |
return m_propertyDimType.get_proxy(); |
47 |
} |
48 |
|
49 |
Glib::PropertyProxy<int> propertyUsageCount() { |
50 |
return m_propertyUsageCount.get_proxy(); |
51 |
} |
52 |
|
53 |
Glib::PropertyProxy<int> propertyTotalRegions() { |
54 |
return m_propertyTotalRegions.get_proxy(); |
55 |
} |
56 |
|
57 |
DimTypeCellRenderer(); |
58 |
protected: |
59 |
void typeChanged(); |
60 |
void statsChanged(); |
61 |
private: |
62 |
Glib::Property<gig::dimension_t> m_propertyDimType; |
63 |
Glib::Property<int> m_propertyUsageCount; |
64 |
Glib::Property<int> m_propertyTotalRegions; |
65 |
}; |
66 |
|
67 |
class IntSetCellRenderer : public Gtk::CellRendererText { |
68 |
public: |
69 |
Glib::PropertyProxy<std::set<int> > propertyValue() { |
70 |
return m_propertyValue.get_proxy(); |
71 |
} |
72 |
|
73 |
IntSetCellRenderer(); |
74 |
protected: |
75 |
void valueChanged(); |
76 |
private: |
77 |
Glib::Property<std::set<int> > m_propertyValue; |
78 |
}; |
79 |
|
80 |
class DimensionManager : public ManagedWindow { |
81 |
public: |
82 |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
83 |
sigc::signal<void, gig::Region*> region_changed_signal; |
84 |
|
85 |
DimensionManager(); |
86 |
void show(gig::Region* region); |
87 |
void set_region(gig::Region* region); |
88 |
|
89 |
// implementation for abstract methods of interface class "ManagedWindow" |
90 |
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->dimensionManagerWindowX; } |
91 |
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->dimensionManagerWindowY; } |
92 |
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->dimensionManagerWindowW; } |
93 |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->dimensionManagerWindowH; } |
94 |
|
95 |
protected: |
96 |
gig::Region* region; |
97 |
Gtk::VBox vbox; |
98 |
Gtk::HButtonBox buttonBox; |
99 |
Gtk::ScrolledWindow scrolledWindow; |
100 |
Gtk::TreeView treeView; |
101 |
Gtk::Button addButton; |
102 |
Gtk::Button removeButton; |
103 |
Gtk::CheckButton allRegionsCheckBox; |
104 |
|
105 |
DimTypeCellRenderer m_cellRendererDimType; |
106 |
IntSetCellRenderer m_cellRendererIntSet; |
107 |
|
108 |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
109 |
public: |
110 |
ModelColumns() { |
111 |
add(m_type); |
112 |
add(m_bits); |
113 |
add(m_zones); |
114 |
add(m_description); |
115 |
add(m_usageCount); |
116 |
add(m_totalRegions); |
117 |
} |
118 |
|
119 |
Gtk::TreeModelColumn<gig::dimension_t> m_type; |
120 |
Gtk::TreeModelColumn<std::set<int> > m_bits; |
121 |
Gtk::TreeModelColumn<std::set<int> > m_zones; |
122 |
Gtk::TreeModelColumn<Glib::ustring> m_description; |
123 |
Gtk::TreeModelColumn<int> m_usageCount; |
124 |
Gtk::TreeModelColumn<int> m_totalRegions; |
125 |
} tableModel; |
126 |
|
127 |
class ComboModelColumns : public Gtk::TreeModel::ColumnRecord { |
128 |
public: |
129 |
ComboModelColumns() { |
130 |
add(m_type_id); |
131 |
add(m_type_name); |
132 |
} |
133 |
|
134 |
Gtk::TreeModelColumn<int> m_type_id; |
135 |
Gtk::TreeModelColumn<Glib::ustring> m_type_name; |
136 |
} comboModel; |
137 |
|
138 |
Glib::RefPtr<Gtk::ListStore> refTableModel; |
139 |
bool ignoreColumnClicked; //HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired |
140 |
|
141 |
void onAllRegionsCheckBoxToggled(); |
142 |
void onColumnClicked(); |
143 |
void refreshManager(); |
144 |
void addDimension(); |
145 |
void removeDimension(); |
146 |
bool allRegions() const; |
147 |
}; |
148 |
|
149 |
#endif // GIGEDIT_DIMENSIONMANAGER_H |