summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/scalar-unit.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2011-04-14 23:02:53 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2011-04-14 23:02:53 +0000
commit91d5bb754933ec128238a3a570d59e4d74c5c349 (patch)
tree6c6d8d6219e5f56e85d2a2d153a0cfb2b6fca42d /src/ui/widget/scalar-unit.cpp
parentsmall tweaks (diff)
downloadinkscape-91d5bb754933ec128238a3a570d59e4d74c5c349.tar.gz
inkscape-91d5bb754933ec128238a3a570d59e4d74c5c349.zip
ScalarUnit: add functionality to grab focus and select the entry text. and add setValueKeepUnit
(bzr r10165)
Diffstat (limited to 'src/ui/widget/scalar-unit.cpp')
-rw-r--r--src/ui/widget/scalar-unit.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp
index e00e82198..533f0a200 100644
--- a/src/ui/widget/scalar-unit.cpp
+++ b/src/ui/widget/scalar-unit.cpp
@@ -118,6 +118,19 @@ ScalarUnit::setValue(double number, Glib::ustring const &units) {
Scalar::setValue(number);
}
+/** Convert and sets the number only and keeps the current unit. */
+void
+ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) {
+ g_assert(_unit_menu != NULL);
+ if (units == "") {
+ // set the value in the default units
+ Scalar::setValue(number);
+ } else {
+ double conversion = _unit_menu->getConversion(units);
+ Scalar::setValue(number / conversion);
+ }
+}
+
/** Sets the number only */
void
ScalarUnit::setValue(double number) {
@@ -137,6 +150,15 @@ ScalarUnit::getValue(Glib::ustring const &unit_name) const {
}
}
+/** Grab focus, and select the text that is in the entry field.
+ */
+void
+ScalarUnit::grabFocusAndSelectEntry() {
+ _widget->grab_focus();
+ static_cast<SpinButton*>(_widget)->select_region(0, 20);
+}
+
+
void
ScalarUnit::setHundredPercent(double number)
{