/[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 2894 - (show annotations) (download) (as text)
Sat Apr 30 14:42:14 2016 UTC (7 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4710 byte(s)
* Enabled auto save & restore of window size & position of all
  remaining windows.
* Bumped version (1.0.0.svn7).

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

  ViewVC Help
Powered by ViewVC