1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006-2013 Andreas Persson |
* Copyright (C) 2006-2015 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
24 |
|
|
25 |
#include <cmath> |
#include <cmath> |
26 |
|
|
27 |
|
#include <glibmm/convert.h> |
28 |
#include <gtkmm/adjustment.h> |
#include <gtkmm/adjustment.h> |
29 |
#include <gtkmm/alignment.h> |
#include <gtkmm/alignment.h> |
30 |
#include <gtkmm/box.h> |
#include <gtkmm/box.h> |
42 |
#include <gtkmm/tooltips.h> |
#include <gtkmm/tooltips.h> |
43 |
#endif |
#endif |
44 |
|
|
45 |
|
|
46 |
|
Glib::ustring gig_to_utf8(const gig::String& gig_string); |
47 |
|
gig::String gig_from_utf8(const Glib::ustring& utf8_string); |
48 |
|
|
49 |
|
int note_value(const Glib::ustring& note); |
50 |
|
Glib::ustring note_str(int note); |
51 |
|
|
52 |
|
void spin_button_show_notes(Gtk::SpinButton& spin_button); |
53 |
|
|
54 |
class LabelWidget { |
class LabelWidget { |
55 |
public: |
public: |
56 |
Gtk::Label label; |
Gtk::Label label; |
68 |
sigc::signal<void> sig_changed; |
sigc::signal<void> sig_changed; |
69 |
}; |
}; |
70 |
|
|
71 |
|
class ReadOnlyLabelWidget : public LabelWidget { |
72 |
|
public: |
73 |
|
Gtk::Label text; |
74 |
|
|
75 |
|
ReadOnlyLabelWidget(const char* leftHandText); |
76 |
|
ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText); |
77 |
|
}; |
78 |
|
|
79 |
class NumEntry : public LabelWidget { |
class NumEntry : public LabelWidget { |
80 |
protected: |
protected: |
81 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
219 |
template<typename T> |
template<typename T> |
220 |
ChoiceEntry<T>::ChoiceEntry(const char* labelText) : |
ChoiceEntry<T>::ChoiceEntry(const char* labelText) : |
221 |
LabelWidget(labelText, align), |
LabelWidget(labelText, align), |
222 |
align(0, 0, 0, 0) |
align(0, 0, 0, 0), |
223 |
|
values(0) |
224 |
{ |
{ |
225 |
combobox.signal_changed().connect(sig_changed.make_slot()); |
combobox.signal_changed().connect(sig_changed.make_slot()); |
226 |
align.add(combobox); |
align.add(combobox); |
230 |
void ChoiceEntry<T>::set_choices(const char** texts, const T* values) |
void ChoiceEntry<T>::set_choices(const char** texts, const T* values) |
231 |
{ |
{ |
232 |
for (int i = 0 ; texts[i] ; i++) { |
for (int i = 0 ; texts[i] ; i++) { |
233 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
234 |
combobox.append_text(texts[i]); |
combobox.append_text(texts[i]); |
235 |
#else |
#else |
236 |
combobox.append(texts[i]); |
combobox.append(texts[i]); |
268 |
ChoiceEntryLeverageCtrl(const char* labelText); |
ChoiceEntryLeverageCtrl(const char* labelText); |
269 |
gig::leverage_ctrl_t get_value() const { return value; } |
gig::leverage_ctrl_t get_value() const { return value; } |
270 |
void set_value(gig::leverage_ctrl_t value); |
void set_value(gig::leverage_ctrl_t value); |
271 |
|
void set_tip(const Glib::ustring& tip_text) { |
272 |
|
combobox.set_tooltip_text(tip_text); |
273 |
|
} |
274 |
}; |
}; |
275 |
|
|
276 |
|
|
304 |
void set_value(int32_t value); |
void set_value(int32_t value); |
305 |
}; |
}; |
306 |
|
|
307 |
|
|
308 |
class StringEntry : public LabelWidget { |
class StringEntry : public LabelWidget { |
309 |
private: |
private: |
310 |
Gtk::Entry entry; |
Gtk::Entry entry; |
311 |
public: |
public: |
312 |
StringEntry(const char* labelText); |
StringEntry(const char* labelText); |
313 |
gig::String get_value() const { return entry.get_text(); } |
gig::String get_value() const; |
314 |
void set_value(gig::String value) { entry.set_text(value); } |
void set_value(const gig::String& value); |
315 |
void set_width_chars(int n_chars) { entry.set_width_chars(n_chars); } |
void set_width_chars(int n_chars) { entry.set_width_chars(n_chars); } |
316 |
}; |
}; |
317 |
|
|
323 |
public: |
public: |
324 |
StringEntryMultiLine(const char* labelText); |
StringEntryMultiLine(const char* labelText); |
325 |
gig::String get_value() const; |
gig::String get_value() const; |
326 |
void set_value(gig::String value); |
void set_value(const gig::String& value); |
327 |
}; |
}; |
328 |
|
|
329 |
|
|
357 |
protected: |
protected: |
358 |
M* m; |
M* m; |
359 |
int update_model; // to prevent infinite update loops |
int update_model; // to prevent infinite update loops |
360 |
PropEditor() : update_model(0) { } |
PropEditor() : m(0), update_model(0) { } |
361 |
sigc::signal<void> sig_changed; |
sigc::signal<void> sig_changed; |
362 |
|
|
363 |
template<class C, typename T> |
template<class C, typename T> |