diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2011-04-11 19:20:20 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2011-04-11 19:20:20 +0000 |
| commit | ae45a98ae609d27cf5cf8471c2cea685bde5da70 (patch) | |
| tree | 5ed81c53c032092299a5315f9203bcd565511e68 /src/ui/widget | |
| parent | revert silly error in r10147 (diff) | |
| download | inkscape-ae45a98ae609d27cf5cf8471c2cea685bde5da70.tar.gz inkscape-ae45a98ae609d27cf5cf8471c2cea685bde5da70.zip | |
Use the subclassed SpinButton class for numeric inputs, such that '.' and ',' both can be used as decimal point.
(related to bug 484187)
(bzr r10159)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/preferences-widget.h | 3 | ||||
| -rw-r--r-- | src/ui/widget/scalar.cpp | 39 | ||||
| -rw-r--r-- | src/ui/widget/scalar.h | 3 | ||||
| -rw-r--r-- | src/ui/widget/spinbutton.h | 6 |
4 files changed, 26 insertions, 25 deletions
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 6c7f9ce4a..4cd2ff569 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -32,6 +32,7 @@ #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" +#include "ui/widget/spinbutton.h" namespace Inkscape { namespace UI { @@ -68,7 +69,7 @@ protected: void on_toggled(); }; -class PrefSpinButton : public Gtk::SpinButton +class PrefSpinButton : public SpinButton { public: void init(Glib::ustring const &prefs_path, diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 26a1f6541..eda8cd2cc 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -18,6 +18,7 @@ #include "scalar.h" +#include "spinbutton.h" namespace Inkscape { namespace UI { @@ -37,10 +38,10 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); + static_cast<SpinButton*>(_widget)->set_numeric(); } /** @@ -59,10 +60,10 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); + static_cast<SpinButton*>(_widget)->set_numeric(); } /** @@ -83,10 +84,10 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); + static_cast<SpinButton*>(_widget)->set_numeric(); } /** Fetches the precision of the spin buton */ @@ -94,7 +95,7 @@ unsigned Scalar::getDigits() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_digits(); + return static_cast<SpinButton*>(_widget)->get_digits(); } /** Gets the current step ingrement used by the spin button */ @@ -103,7 +104,7 @@ Scalar::getStep() const { g_assert(_widget != NULL); double step, page; - static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page); + static_cast<SpinButton*>(_widget)->get_increments(step, page); return step; } @@ -113,7 +114,7 @@ Scalar::getPage() const { g_assert(_widget != NULL); double step, page; - static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page); + static_cast<SpinButton*>(_widget)->get_increments(step, page); return page; } @@ -123,7 +124,7 @@ Scalar::getRangeMin() const { g_assert(_widget != NULL); double min, max; - static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max); + static_cast<SpinButton*>(_widget)->get_range(min, max); return min; } @@ -133,7 +134,7 @@ Scalar::getRangeMax() const { g_assert(_widget != NULL); double min, max; - static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max); + static_cast<SpinButton*>(_widget)->get_range(min, max); return max; } @@ -142,7 +143,7 @@ double Scalar::getValue() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_value(); + return static_cast<SpinButton*>(_widget)->get_value(); } /** Get the value spin_button represented as an integer. */ @@ -150,7 +151,7 @@ int Scalar::getValueAsInt() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_value_as_int(); + return static_cast<SpinButton*>(_widget)->get_value_as_int(); } @@ -159,7 +160,7 @@ void Scalar::setDigits(unsigned digits) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_digits(digits); + static_cast<SpinButton*>(_widget)->set_digits(digits); } /** Sets the step and page increments for the spin button @@ -169,7 +170,7 @@ void Scalar::setIncrements(double step, double /*page*/) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_increments(step, 0); + static_cast<SpinButton*>(_widget)->set_increments(step, 0); } /** Sets the minimum and maximum range allowed for the spin button */ @@ -177,7 +178,7 @@ void Scalar::setRange(double min, double max) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_range(min, max); + static_cast<SpinButton*>(_widget)->set_range(min, max); } /** Sets the value of the spin button */ @@ -186,14 +187,14 @@ Scalar::setValue(double value) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares - static_cast<Gtk::SpinButton*>(_widget)->set_value(value); + static_cast<SpinButton*>(_widget)->set_value(value); } /** Manually forces an update of the spin button */ void Scalar::update() { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->update(); + static_cast<SpinButton*>(_widget)->update(); } @@ -202,7 +203,7 @@ Scalar::update() { Glib::SignalProxy0<void> Scalar::signal_value_changed() { - return static_cast<Gtk::SpinButton*>(_widget)->signal_value_changed(); + return static_cast<SpinButton*>(_widget)->signal_value_changed(); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 6de128edb..7142ba93f 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -15,9 +15,6 @@ #ifndef INKSCAPE_UI_WIDGET_SCALAR_H #define INKSCAPE_UI_WIDGET_SCALAR_H -#include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> - #include "labelled.h" namespace Inkscape { diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index d9b382b08..408310d09 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -25,8 +25,10 @@ namespace Widget { class SpinButton : public Gtk::SpinButton { public: - SpinButton() : Gtk::SpinButton() {}; - /// @todo perhaps more constructors should be added here + SpinButton(double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(climb_rate, digits) {}; + explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(adjustment, climb_rate, digits) {}; virtual ~SpinButton() {}; |
