summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/point.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-08-14 20:54:48 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-08-14 20:54:48 +0000
commit55d43e4e27e0ba58a47fad70957dfa989aa173ad (patch)
tree2ccfbac1c50023d08ae32975c876fa2478c1ad2a /src/ui/widget/point.cpp
parentFix for bug #1752113; added set_preview_widget_active(false) to FileSaveDialo... (diff)
downloadinkscape-55d43e4e27e0ba58a47fad70957dfa989aa173ad.tar.gz
inkscape-55d43e4e27e0ba58a47fad70957dfa989aa173ad.zip
Commit LivePathEffect branch to trunk!
(disabled extension/internal/bitmap/*.* in build.xml to fix compilation) (bzr r3472)
Diffstat (limited to 'src/ui/widget/point.cpp')
-rw-r--r--src/ui/widget/point.cpp237
1 files changed, 237 insertions, 0 deletions
diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp
new file mode 100644
index 000000000..cfaa4303d
--- /dev/null
+++ b/src/ui/widget/point.cpp
@@ -0,0 +1,237 @@
+/**
+ * \brief Point Widget - A labelled text box, with spin buttons and optional
+ * icon or suffix, for entering arbitrary coordinate values.
+ *
+ * Authors:
+ * Johan Engelen <j.b.c.engelen@utwente.nl>
+ * Carl Hetherington <inkscape@carlh.net>
+ * Derek P. Moore <derekm@hackunix.org>
+ * Bryce Harrington <bryce@bryceharrington.org>
+ *
+ * Copyright (C) 2007 Authors
+ * Copyright (C) 2004 Authors
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+
+#include "ui/widget/point.h"
+#include "ui/widget/labelled.h"
+#include "ui/widget/scalar.h"
+#include <gtkmm/box.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * Construct a Point Widget.
+ *
+ * \param label Label.
+ * \param suffix Suffix, placed after the widget (defaults to "").
+ * \param icon Icon filename, placed before the label (defaults to "").
+ * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
+ * indicates the next character should be used for the
+ * mnemonic accelerator key (defaults to false).
+ */
+Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
+ Glib::ustring const &suffix,
+ Glib::ustring const &icon,
+ bool mnemonic)
+ : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),
+ setProgrammatically(false),
+ xwidget("X:",""),
+ ywidget("Y:","")
+{
+ static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);
+ static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);
+ static_cast<Gtk::VBox*>(_widget)->show_all_children();
+}
+
+/**
+ * Construct a Point Widget.
+ *
+ * \param label Label.
+ * \param digits Number of decimal digits to display.
+ * \param suffix Suffix, placed after the widget (defaults to "").
+ * \param icon Icon filename, placed before the label (defaults to "").
+ * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
+ * indicates the next character should be used for the
+ * mnemonic accelerator key (defaults to false).
+ */
+Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
+ unsigned digits,
+ Glib::ustring const &suffix,
+ Glib::ustring const &icon,
+ bool mnemonic)
+ : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),
+ setProgrammatically(false),
+ xwidget("X:","", digits),
+ ywidget("Y:","", digits)
+{
+ static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);
+ static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);
+ static_cast<Gtk::VBox*>(_widget)->show_all_children();
+}
+
+/**
+ * Construct a Point Widget.
+ *
+ * \param label Label.
+ * \param adjust Adjustment to use for the SpinButton.
+ * \param digits Number of decimal digits to display (defaults to 0).
+ * \param suffix Suffix, placed after the widget (defaults to "").
+ * \param icon Icon filename, placed before the label (defaults to "").
+ * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
+ * indicates the next character should be used for the
+ * mnemonic accelerator key (defaults to true).
+ */
+Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
+ Gtk::Adjustment &adjust,
+ unsigned digits,
+ Glib::ustring const &suffix,
+ Glib::ustring const &icon,
+ bool mnemonic)
+ : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),
+ setProgrammatically(false),
+ xwidget("X:","", adjust, digits),
+ ywidget("Y:","", adjust, digits)
+{
+ static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);
+ static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);
+ static_cast<Gtk::VBox*>(_widget)->show_all_children();
+}
+
+/** Fetches the precision of the spin buton */
+unsigned
+Point::getDigits() const
+{
+ return xwidget.getDigits();
+}
+
+/** Gets the current step ingrement used by the spin button */
+double
+Point::getStep() const
+{
+ return xwidget.getStep();
+}
+
+/** Gets the current page increment used by the spin button */
+double
+Point::getPage() const
+{
+ return xwidget.getPage();
+}
+
+/** Gets the minimum range value allowed for the spin button */
+double
+Point::getRangeMin() const
+{
+ return xwidget.getRangeMin();
+}
+
+/** Gets the maximum range value allowed for the spin button */
+double
+Point::getRangeMax() const
+{
+ return xwidget.getRangeMax();
+}
+
+/** Get the value in the spin_button . */
+double
+Point::getXValue() const
+{
+ return xwidget.getValue();
+}
+double
+Point::getYValue() const
+{
+ return ywidget.getValue();
+}
+
+/** Get the value spin_button represented as an integer. */
+int
+Point::getXValueAsInt() const
+{
+ return xwidget.getValueAsInt();
+}
+int
+Point::getYValueAsInt() const
+{
+ return ywidget.getValueAsInt();
+}
+
+
+/** Sets the precision to be displayed by the spin button */
+void
+Point::setDigits(unsigned digits)
+{
+ xwidget.setDigits(digits);
+ ywidget.setDigits(digits);
+}
+
+/** Sets the step and page increments for the spin button */
+void
+Point::setIncrements(double step, double page)
+{
+ xwidget.setIncrements(step, page);
+ ywidget.setIncrements(step, page);
+}
+
+/** Sets the minimum and maximum range allowed for the spin button */
+void
+Point::setRange(double min, double max)
+{
+ xwidget.setRange(min, max);
+ ywidget.setRange(min, max);
+}
+
+/** Sets the value of the spin button */
+void
+Point::setValue(double xvalue, double yvalue)
+{
+ setProgrammatically = true; // callback is supposed to reset back, if it cares
+ xwidget.setValue(xvalue);
+ ywidget.setValue(yvalue);
+}
+
+/** Manually forces an update of the spin button */
+void
+Point::update() {
+ xwidget.update();
+ ywidget.update();
+}
+
+
+
+/** Signal raised when the spin button's value changes */
+Glib::SignalProxy0<void>
+Point::signal_x_value_changed()
+{
+ return xwidget.signal_value_changed();
+}
+Glib::SignalProxy0<void>
+Point::signal_y_value_changed()
+{
+ return ywidget.signal_value_changed();
+}
+
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :