27 using namespace GtkCRN;
35 tmpvalue(el.GetValue())
42 if (std::dynamic_pointer_cast<crn::Int>(tmpvalue))
44 else if (std::dynamic_pointer_cast<crn::Real>(tmpvalue))
46 else if (std::dynamic_pointer_cast<crn::Prop3>(tmpvalue))
48 else if (std::dynamic_pointer_cast<crn::String>(tmpvalue))
50 else if (std::dynamic_pointer_cast<crn::StringUTF8>(tmpvalue))
52 else if (std::dynamic_pointer_cast<crn::Path>(tmpvalue))
55 Gtk::Label *lab = Gtk::manage(
new Gtk::Label(el.
GetName().
CStr()));
57 pack_start(*lab,
false,
true, 2);
64 pack_start(*p,
true,
true, 2);
68 Gtk::ComboBoxText *cb = Gtk::manage(
new Gtk::ComboBoxText);
71 #ifdef CRN_USING_GTKMM3
72 cb->append(val.CStr());
74 cb->append_text(val.CStr());
77 cb->signal_changed().connect(sigc::bind(sigc::mem_fun(
this, &ConfigElement::on_combo_changed), cb));
79 pack_start(*cb,
true,
true, 2);
81 else if (typ == U
"Int")
85 #ifdef CRN_USING_GTKMM3
86 auto *s = Gtk::manage(
new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
88 s->set_increments(1, 1);
93 s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(
this, &ConfigElement::on_range_changed), s));
95 pack_start(*s,
true,
true, 2);
99 Gtk::SpinButton *s = Gtk::manage(
new Gtk::SpinButton);
100 int m = std::numeric_limits<int>::min(), M = std::numeric_limits<int>::max();
106 s->set_increments(1, 10);
108 s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(
this, &ConfigElement::on_spin_changed), s));
110 pack_start(*s,
true,
true, 2);
113 else if (typ == U
"Real")
117 #ifdef CRN_USING_GTKMM3
118 auto *s = Gtk::manage(
new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
120 s->set_increments(0.01, 0.01);
122 Gtk::HScale *s = Gtk::manage(
new Gtk::HScale(el.
GetMinValue<
double>(), el.
GetMaxValue<
double>() + 0.01, 0.01));
125 s->set_value(el.
GetValue<
double>());
126 s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(
this, &ConfigElement::on_range_changed), s));
128 pack_start(*s,
true,
true, 2);
132 Gtk::SpinButton *s = Gtk::manage(
new Gtk::SpinButton(0, 2));
133 double m = -std::numeric_limits<double>::max(), M = std::numeric_limits<double>::max();
139 s->set_increments(0.01, 1);
140 s->set_value(el.
GetValue<
double>());
141 s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(
this, &ConfigElement::on_spin_changed), s));
143 pack_start(*s,
true,
true, 2);
148 Gtk::Entry *e = Gtk::manage(
new Gtk::Entry);
150 e->signal_changed().connect(sigc::bind(sigc::mem_fun(
this, &ConfigElement::on_entry_changed), e));
152 pack_start(*e,
true,
true, 2);
154 lab = Gtk::manage(
new Gtk::Label(
"?"));
157 pack_start(*lab,
false,
true, 2);
165 *std::static_pointer_cast<
crn::Int>(value) = *std::static_pointer_cast<crn::Int>(tmpvalue);
167 else if (typ == U
"Real")
169 *std::static_pointer_cast<
crn::Real>(value) = *std::static_pointer_cast<crn::Real>(tmpvalue);
171 else if (typ == U
"Prop3")
173 *std::static_pointer_cast<
crn::Prop3>(value) = *std::static_pointer_cast<crn::Prop3>(tmpvalue);
175 else if (typ == U
"String")
177 *std::static_pointer_cast<
crn::String>(value) = *std::static_pointer_cast<crn::String>(tmpvalue);
179 else if (typ == U
"StringUTF8")
181 *std::static_pointer_cast<
crn::StringUTF8>(value) = *std::static_pointer_cast<crn::StringUTF8>(tmpvalue);
183 else if (typ == U
"Path")
185 *std::static_pointer_cast<
crn::Path>(value) = *std::static_pointer_cast<crn::Path>(tmpvalue);
189 void ConfigElement::on_p3_changed(
crn::Prop3 p3)
191 *std::static_pointer_cast<
crn::Prop3>(tmpvalue) = p3;
194 void ConfigElement::on_combo_changed(Gtk::ComboBoxText *combo)
199 *std::static_pointer_cast<
crn::Int>(tmpvalue) = val.ToInt();
201 else if (typ == U
"Real")
203 *std::static_pointer_cast<
crn::Real>(tmpvalue) = val.ToDouble();
205 else if (typ == U
"String")
207 *std::static_pointer_cast<
crn::String>(tmpvalue) = val;
209 else if (typ == U
"StringUTF8")
213 else if (typ == U
"Path")
215 *std::static_pointer_cast<
crn::Path>(tmpvalue) = val;
219 void ConfigElement::on_range_changed(
Gtk::Range *range)
223 *std::static_pointer_cast<
crn::Int>(tmpvalue) =
int(range->get_value());
225 else if (typ == U
"Real")
227 *std::static_pointer_cast<
crn::Real>(tmpvalue) = range->get_value();
231 void ConfigElement::on_spin_changed(Gtk::SpinButton *spin)
235 *std::static_pointer_cast<
crn::Int>(tmpvalue) = spin->get_value_as_int();
237 else if (typ == U
"Real")
239 *std::static_pointer_cast<
crn::Real>(tmpvalue) = spin->get_value();
243 void ConfigElement::on_entry_changed(Gtk::Entry *entry)
245 if (typ == U
"String")
247 *std::static_pointer_cast<
crn::String>(tmpvalue) = entry->get_text().c_str();
249 else if (typ == U
"StringUTF8")
251 *std::static_pointer_cast<
crn::StringUTF8>(tmpvalue) = entry->get_text().c_str();
253 else if (typ == U
"Path")
255 *std::static_pointer_cast<
crn::Path>(tmpvalue) = entry->get_text().c_str();
ConfigElement(crn::ConfigElement &el, bool differ=false)
Constructor.
ScalarRange< T > Range(T b, T e)
Creates a range [[b, e[[.
const SObject & GetMinValue() noexcept
Gets the inner representation of the element's min value.
const crn::Vector & GetAllowedValues() const
Returns the list of allowed values.
const char * CStr() const
Conversion to UTF8 cstring.
Unintialized object error.
bool HasMaxValue() const noexcept
Tells if the element has max value.
A UTF32 character string class.
void apply_changes()
In differ mode, validates the changes to the value.
void Scale(ITER it_begin, ITER it_end, const double s)
Scale a collection of numbers.
Interface class for the metric real number class.
const SObject & GetMaxValue() noexcept
Gets the inner representation of the element's max value.
const char * CStr() const noexcept
Conversion to UTF8 cstring.
A convenience class for file paths.
const String & GetName() const noexcept
Gets the translated name of the element.
A element of configuration.
const String & GetDescription() const noexcept
Gets the description of the element.
const SObject & GetValue() noexcept
Gets the inner representation of the element's value.
Interface class for the metric real number class.
A widget for ternary values representation.
A character string class.
UObject Clone(const Object &obj)
Clones an object if possible.
sigc::signal< void, crn::Prop3 > signal_value_changed()
Signals when the value was changed. Connect to void on_value_changed(crn::Prop3). ...
bool HasMinValue() const noexcept
Tells if the element has min value.
bool IsEmpty() const noexcept
Tests if the vector is empty.