/[svn]/gigedit/trunk/src/gigedit/dimensionmanager.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/dimensionmanager.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2844 - (show annotations) (download) (as text)
Sun Sep 20 08:49:40 2015 UTC (8 years, 7 months ago) by persson
File MIME type: text/x-c++hdr
File size: 4131 byte(s)
* allow building with gtkmm 2 and G/GDK/GTK_DISABLE_DEPRECATED

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/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 #include <gig.h>
35 #include <set>
36
37 class DimTypeCellRenderer : public Gtk::CellRendererText {
38 public:
39 Glib::PropertyProxy<gig::dimension_t> propertyDimType() {
40 return m_propertyDimType.get_proxy();
41 }
42
43 Glib::PropertyProxy<int> propertyUsageCount() {
44 return m_propertyUsageCount.get_proxy();
45 }
46
47 Glib::PropertyProxy<int> propertyTotalRegions() {
48 return m_propertyTotalRegions.get_proxy();
49 }
50
51 DimTypeCellRenderer();
52 protected:
53 void typeChanged();
54 void statsChanged();
55 private:
56 Glib::Property<gig::dimension_t> m_propertyDimType;
57 Glib::Property<int> m_propertyUsageCount;
58 Glib::Property<int> m_propertyTotalRegions;
59 };
60
61 class IntSetCellRenderer : public Gtk::CellRendererText {
62 public:
63 Glib::PropertyProxy<std::set<int> > propertyValue() {
64 return m_propertyValue.get_proxy();
65 }
66
67 IntSetCellRenderer();
68 protected:
69 void valueChanged();
70 private:
71 Glib::Property<std::set<int> > m_propertyValue;
72 };
73
74 class DimensionManager : public Gtk::Window {
75 public:
76 sigc::signal<void, gig::Region*> region_to_be_changed_signal;
77 sigc::signal<void, gig::Region*> region_changed_signal;
78
79 DimensionManager();
80 void show(gig::Region* region);
81 void set_region(gig::Region* region);
82 protected:
83 gig::Region* region;
84 Gtk::VBox vbox;
85 Gtk::HButtonBox buttonBox;
86 Gtk::ScrolledWindow scrolledWindow;
87 Gtk::TreeView treeView;
88 Gtk::Button addButton;
89 Gtk::Button removeButton;
90 Gtk::CheckButton allRegionsCheckBox;
91
92 DimTypeCellRenderer m_cellRendererDimType;
93 IntSetCellRenderer m_cellRendererIntSet;
94
95 class ModelColumns : public Gtk::TreeModel::ColumnRecord {
96 public:
97 ModelColumns() {
98 add(m_type);
99 add(m_bits);
100 add(m_zones);
101 add(m_description);
102 add(m_usageCount);
103 add(m_totalRegions);
104 }
105
106 Gtk::TreeModelColumn<gig::dimension_t> m_type;
107 Gtk::TreeModelColumn<std::set<int> > m_bits;
108 Gtk::TreeModelColumn<std::set<int> > m_zones;
109 Gtk::TreeModelColumn<Glib::ustring> m_description;
110 Gtk::TreeModelColumn<int> m_usageCount;
111 Gtk::TreeModelColumn<int> m_totalRegions;
112 } tableModel;
113
114 class ComboModelColumns : public Gtk::TreeModel::ColumnRecord {
115 public:
116 ComboModelColumns() {
117 add(m_type_id);
118 add(m_type_name);
119 }
120
121 Gtk::TreeModelColumn<int> m_type_id;
122 Gtk::TreeModelColumn<Glib::ustring> m_type_name;
123 } comboModel;
124
125 Glib::RefPtr<Gtk::ListStore> refTableModel;
126 bool ignoreColumnClicked; //HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired
127
128 void onAllRegionsCheckBoxToggled();
129 void onColumnClicked();
130 void refreshManager();
131 void addDimension();
132 void removeDimension();
133 bool allRegions() const;
134 };
135
136 #endif // GIGEDIT_DIMENSIONMANAGER_H

  ViewVC Help
Powered by ViewVC