diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2011-04-13 22:04:49 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2011-04-13 22:04:49 +0000 |
| commit | fe875852760883dd20b6a57b57be50de83e37fc2 (patch) | |
| tree | 60832d184f5899591b918ff551bb561aca6846a1 /src/ui/widget/spinbutton.h | |
| parent | Breton translation update (diff) | |
| download | inkscape-fe875852760883dd20b6a57b57be50de83e37fc2.tar.gz inkscape-fe875852760883dd20b6a57b57be50de83e37fc2.zip | |
add expression evaluator for spinbox input boxes. also knows a little about units.
needs more work to fully integrate it in all of inkscape spinboxes
also needs documentation rework
(bzr r10162)
Diffstat (limited to 'src/ui/widget/spinbutton.h')
| -rw-r--r-- | src/ui/widget/spinbutton.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 408310d09..0eb58bb9e 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -19,21 +19,37 @@ namespace Inkscape { namespace UI { namespace Widget { +class UnitMenu; + /** - * SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu). + * + * Calling "set_numeric()" effectively disables the expression parsing. If no unit menu is linked, all unitlike characters are ignored. */ class SpinButton : public Gtk::SpinButton { public: SpinButton(double climb_rate = 0.0, guint digits = 0) - : Gtk::SpinButton(climb_rate, digits) {}; + : Gtk::SpinButton(climb_rate, digits), + _unit_menu(NULL) + { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + }; explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) - : Gtk::SpinButton(adjustment, climb_rate, digits) {}; + : Gtk::SpinButton(adjustment, climb_rate, digits), + _unit_menu(NULL) + { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + }; virtual ~SpinButton() {}; + void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + protected: - virtual void on_insert_text(const Glib::ustring& text, int* position); + UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + + int on_input(double* newvalue); private: // noncopyable |
