2
* \brief Scalar Widget - A labelled text box, with spin buttons and optional
3
* icon or suffix, for entering arbitrary number values.
6
* Carl Hetherington <inkscape@carlh.net>
7
* Derek P. Moore <derekm@hackunix.org>
8
* Bryce Harrington <bryce@bryceharrington.org>
10
* Copyright (C) 2004 Carl Hetherington
12
* Released under GNU GPL. Read the file 'COPYING' for more information.
27
* Construct a Scalar Widget.
30
* \param suffix Suffix, placed after the widget (defaults to "").
31
* \param icon Icon filename, placed before the label (defaults to "").
32
* \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
33
* indicates the next character should be used for the
34
* mnemonic accelerator key (defaults to false).
36
Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
37
Glib::ustring const &suffix,
38
Glib::ustring const &icon,
40
: Labelled(label, tooltip, new Gtk::SpinButton(), suffix, icon, mnemonic),
41
setProgrammatically(false)
43
static_cast<Gtk::SpinButton*>(_widget)->set_numeric();
47
* Construct a Scalar Widget.
50
* \param digits Number of decimal digits to display.
51
* \param suffix Suffix, placed after the widget (defaults to "").
52
* \param icon Icon filename, placed before the label (defaults to "").
53
* \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
54
* indicates the next character should be used for the
55
* mnemonic accelerator key (defaults to false).
57
Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
59
Glib::ustring const &suffix,
60
Glib::ustring const &icon,
62
: Labelled(label, tooltip, new Gtk::SpinButton(0.0, digits), suffix, icon, mnemonic),
63
setProgrammatically(false)
65
static_cast<Gtk::SpinButton*>(_widget)->set_numeric();
69
* Construct a Scalar Widget.
72
* \param adjust Adjustment to use for the SpinButton.
73
* \param digits Number of decimal digits to display (defaults to 0).
74
* \param suffix Suffix, placed after the widget (defaults to "").
75
* \param icon Icon filename, placed before the label (defaults to "").
76
* \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
77
* indicates the next character should be used for the
78
* mnemonic accelerator key (defaults to true).
80
Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
81
Gtk::Adjustment &adjust,
83
Glib::ustring const &suffix,
84
Glib::ustring const &icon,
86
: Labelled(label, tooltip, new Gtk::SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic),
87
setProgrammatically(false)
89
static_cast<Gtk::SpinButton*>(_widget)->set_numeric();
92
/** Fetches the precision of the spin buton */
94
Scalar::getDigits() const
96
g_assert(_widget != NULL);
97
return static_cast<Gtk::SpinButton*>(_widget)->get_digits();
100
/** Gets the current step ingrement used by the spin button */
102
Scalar::getStep() const
104
g_assert(_widget != NULL);
106
static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page);
110
/** Gets the current page increment used by the spin button */
112
Scalar::getPage() const
114
g_assert(_widget != NULL);
116
static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page);
120
/** Gets the minimum range value allowed for the spin button */
122
Scalar::getRangeMin() const
124
g_assert(_widget != NULL);
126
static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max);
130
/** Gets the maximum range value allowed for the spin button */
132
Scalar::getRangeMax() const
134
g_assert(_widget != NULL);
136
static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max);
140
/** Get the value in the spin_button . */
142
Scalar::getValue() const
144
g_assert(_widget != NULL);
145
return static_cast<Gtk::SpinButton*>(_widget)->get_value();
148
/** Get the value spin_button represented as an integer. */
150
Scalar::getValueAsInt() const
152
g_assert(_widget != NULL);
153
return static_cast<Gtk::SpinButton*>(_widget)->get_value_as_int();
157
/** Sets the precision to be displayed by the spin button */
159
Scalar::setDigits(unsigned digits)
161
g_assert(_widget != NULL);
162
static_cast<Gtk::SpinButton*>(_widget)->set_digits(digits);
165
/** Sets the step and page increments for the spin button
166
* @todo Remove the second parameter - deprecated
169
Scalar::setIncrements(double step, double /*page*/)
171
g_assert(_widget != NULL);
172
static_cast<Gtk::SpinButton*>(_widget)->set_increments(step, 0);
175
/** Sets the minimum and maximum range allowed for the spin button */
177
Scalar::setRange(double min, double max)
179
g_assert(_widget != NULL);
180
static_cast<Gtk::SpinButton*>(_widget)->set_range(min, max);
183
/** Sets the value of the spin button */
185
Scalar::setValue(double value)
187
g_assert(_widget != NULL);
188
setProgrammatically = true; // callback is supposed to reset back, if it cares
189
static_cast<Gtk::SpinButton*>(_widget)->set_value(value);
192
/** Manually forces an update of the spin button */
195
g_assert(_widget != NULL);
196
static_cast<Gtk::SpinButton*>(_widget)->update();
201
/** Signal raised when the spin button's value changes */
202
Glib::SignalProxy0<void>
203
Scalar::signal_value_changed()
205
return static_cast<Gtk::SpinButton*>(_widget)->signal_value_changed();
209
} // namespace Widget
211
} // namespace Inkscape
216
c-file-style:"stroustrup"
217
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
222
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :