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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1153 - (show annotations) (download) (as text)
Mon Apr 9 21:05:01 2007 UTC (17 years ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6581 byte(s)
* added couple tooltips to dimregionedit

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_PARAMEDIT_H
21 #define GIGEDIT_PARAMEDIT_H
22
23 #include <gig.h>
24
25 #include <gtkmm/adjustment.h>
26 #include <gtkmm/alignment.h>
27 #include <gtkmm/box.h>
28 #include <gtkmm/comboboxtext.h>
29 #include <gtkmm/label.h>
30 #include <gtkmm/scale.h>
31 #include <gtkmm/spinbutton.h>
32 #include <gtkmm/tooltips.h>
33
34 extern bool update_gui;
35
36 class LabelWidget {
37 public:
38 Gtk::Label label;
39 Gtk::Widget& widget;
40
41 LabelWidget(char* labelText, Gtk::Widget& widget);
42 void set_sensitive(bool sensitive = true);
43 protected:
44 Gtk::Tooltips tooltips;
45 };
46
47 class NumEntry : public LabelWidget {
48 protected:
49 Gtk::Adjustment adjust;
50 Gtk::HScale scale;
51 Gtk::SpinButton spinbutton;
52 Gtk::HBox box;
53 public:
54 NumEntry(char* labelText, double lower = 0, double upper = 127,
55 int decimals = 0);
56 void set_value(double value) {
57 spinbutton.set_value(value);
58 }
59 Glib::SignalProxy0<void> signal_value_changed() {
60 return spinbutton.signal_value_changed();
61 }
62 double get_value() const {
63 return spinbutton.get_value();
64 }
65 void set_tip(const Glib::ustring& tip_text) {
66 tooltips.set_tip(spinbutton, tip_text);
67 }
68 };
69
70 class NumEntryGain : public NumEntry {
71 private:
72 void value_changed();
73 int32_t* ptr;
74 double coeff;
75 public:
76 NumEntryGain(char* labelText,
77 double lower, double upper, int decimals, double coeff);
78 void set_ptr(int32_t* ptr);
79 };
80
81 template<typename T>
82 class NumEntryTemp : public NumEntry {
83 private:
84 T* ptr;
85 void value_changed();
86 public:
87 NumEntryTemp(char* labelText,
88 double lower = 0, double upper = 127, int decimals = 0);
89 void set_ptr(T* ptr);
90 };
91
92 template<typename T>
93 NumEntryTemp<T>::NumEntryTemp(char* labelText,
94 double lower, double upper, int decimals) :
95 NumEntry(labelText, lower, upper, decimals)
96 {
97 spinbutton.signal_value_changed().connect(
98 sigc::mem_fun(*this, &NumEntryTemp::value_changed));
99 }
100
101 template<typename T>
102 void NumEntryTemp<T>::value_changed()
103 {
104 if (ptr && update_gui) {
105 *ptr = T(spinbutton.get_value());
106 }
107 }
108
109 template<typename T>
110 void NumEntryTemp<T>::set_ptr(T* ptr)
111 {
112 this->ptr = 0;
113 set_value(*ptr);
114 this->ptr = ptr;
115 }
116
117
118 class NoteEntry : public NumEntryTemp<uint8_t> {
119 public:
120 NoteEntry(char* labelText);
121 private:
122 int on_input(double* new_value);
123 bool on_output();
124 };
125
126
127 class NumEntryPermille : public NumEntry {
128 private:
129 uint16_t* ptr;
130 void value_changed();
131 public:
132 NumEntryPermille(char* labelText,
133 double lower = 0, double upper = 127, int decimals = 0);
134 void set_ptr(uint16_t* ptr);
135 };
136
137
138 template<typename T>
139 class ChoiceEntry : public LabelWidget {
140 private:
141 Gtk::ComboBoxText combobox;
142 Gtk::Alignment align;
143 T* ptr;
144 void value_changed();
145 const T* values;
146 public:
147 ChoiceEntry(char* labelText);
148 void set_choices(char** texts, const T* values);
149 void set_ptr(T* ptr);
150 int get_active_row_number() { return combobox.get_active_row_number(); }
151 Glib::SignalProxy0<void> signal_changed() {
152 return combobox.signal_changed();
153 }
154 };
155
156 template<typename T>
157 ChoiceEntry<T>::ChoiceEntry(char* labelText) :
158 align(0, 0, 0, 0),
159 LabelWidget(labelText, align)
160 {
161 combobox.signal_changed().connect(
162 sigc::mem_fun(*this, &ChoiceEntry::value_changed));
163 align.add(combobox);
164 }
165
166 template<typename T>
167 void ChoiceEntry<T>::set_choices(char** texts, const T* values)
168 {
169 for (int i = 0 ; texts[i] ; i++) {
170 combobox.append_text(texts[i]);
171 }
172 this->values = values;
173 }
174
175 template<typename T>
176 void ChoiceEntry<T>::value_changed()
177 {
178 if (ptr && update_gui) {
179 int rowno = combobox.get_active_row_number();
180 if (rowno != -1) *ptr = values[rowno];
181 }
182 }
183
184 template<typename T>
185 void ChoiceEntry<T>::set_ptr(T* ptr)
186 {
187 this->ptr = 0;
188 T value = *ptr;
189 int row = 0;
190 int nb_rows = combobox.get_model()->children().size();
191 for (; row < nb_rows ; row++) {
192 if (value == values[row]) break;
193 }
194 combobox.set_active(row == nb_rows ? -1 : row);
195 this->ptr = ptr;
196 }
197
198
199 class ChoiceEntryLeverageCtrl : public LabelWidget {
200 private:
201 Gtk::ComboBoxText combobox;
202 Gtk::Alignment align;
203 gig::leverage_ctrl_t* ptr;
204 void value_changed();
205 public:
206 ChoiceEntryLeverageCtrl(char* labelText);
207 void set_ptr(gig::leverage_ctrl_t* ptr);
208 int get_active_row_number() { return combobox.get_active_row_number(); }
209 Glib::SignalProxy0<void> signal_changed() {
210 return combobox.signal_changed();
211 }
212 };
213
214
215 class BoolEntry : public LabelWidget {
216 private:
217 Gtk::CheckButton checkbutton;
218 bool* ptr;
219 void value_changed();
220 public:
221 BoolEntry(char* labelText);
222 bool get_active() { return checkbutton.get_active(); }
223 Glib::SignalProxy0<void> signal_toggled() {
224 return checkbutton.signal_toggled();
225 }
226 void set_ptr(bool* ptr);
227 void set_tip(const Glib::ustring& tip_text) {
228 tooltips.set_tip(checkbutton, tip_text);
229 }
230 };
231
232
233 class BoolEntryPlus6 : public LabelWidget {
234 private:
235 Gtk::CheckButton checkbutton;
236 int32_t* ptr;
237 void value_changed();
238 NumEntryGain& eGain;
239 int32_t plus6value;
240 public:
241 BoolEntryPlus6(char* labelText, NumEntryGain& eGain, int32_t plus6value);
242 void set_ptr(int32_t* ptr);
243 bool get_active() { return checkbutton.get_active(); }
244 Glib::SignalProxy0<void> signal_toggled() {
245 return checkbutton.signal_toggled();
246 }
247 };
248
249 class StringEntry : public LabelWidget {
250 private:
251 Gtk::Entry entry;
252 gig::String* ptr;
253 void value_changed();
254 public:
255 StringEntry(char* labelText);
256 void set_ptr(gig::String* ptr);
257 };
258
259
260 #endif

  ViewVC Help
Powered by ViewVC