openMSX
IntegerSetting.cc
Go to the documentation of this file.
1#include "IntegerSetting.hh"
2
3namespace openmsx {
4
6 std::string_view name_, static_string_view description_,
7 int initialValue, int minValue_, int maxValue_,
8 SaveSetting save_)
9 : Setting(commandController_, name_, description_,
10 TclObject(initialValue), save_)
11 , minValue(minValue_)
12 , maxValue(maxValue_)
13{
14 auto& interp = getInterpreter();
15 setChecker([this, &interp](TclObject& newValue) {
16 int val = newValue.getInt(interp); // may throw
17 newValue = std::clamp(val, minValue, maxValue);
18 });
19 init();
20}
21
22std::string_view IntegerSetting::getTypeString() const
23{
24 return "integer";
25}
26
28{
29 result.addListElement(makeTclList(minValue, maxValue));
30}
31
33{
35}
36
37} // namespace openmsx
IntegerSetting(CommandController &commandController, std::string_view name, static_string_view description, int initialValue, int minValue, int maxValue, SaveSetting save=SAVE)
void additionalInfo(TclObject &result) const override
Helper method for info().
std::string_view getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
void setChecker(std::function< void(TclObject &)> checkFunc_)
Set value-check-callback.
Definition Setting.hh:146
Interpreter & getInterpreter() const
Definition Setting.cc:139
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
Definition Setting.cc:81
void addListElement(const T &t)
Definition TclObject.hh:131
int getInt(Interpreter &interp) const
Definition TclObject.cc:69
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11
TclObject makeTclList(Args &&... args)
Definition TclObject.hh:293