Code

The dialog to panel refactoring:
[inkscape.git] / src / ui / widget / point.cpp
index cfaa4303d47eb8746175be2d6bead5aa97215c69..634329ddcb45892d884ffcf3eb02f4a48340d47f 100644 (file)
-/**\r
- * \brief Point Widget - A labelled text box, with spin buttons and optional\r
- *        icon or suffix, for entering arbitrary coordinate values.\r
- *\r
- * Authors:\r
- *   Johan Engelen <j.b.c.engelen@utwente.nl>\r
- *   Carl Hetherington <inkscape@carlh.net>\r
- *   Derek P. Moore <derekm@hackunix.org>\r
- *   Bryce Harrington <bryce@bryceharrington.org>\r
- *\r
- * Copyright (C) 2007 Authors\r
- * Copyright (C) 2004 Authors\r
- *\r
- * Released under GNU GPL.  Read the file 'COPYING' for more information.\r
- */\r
-\r
-#ifdef HAVE_CONFIG_H\r
-# include <config.h>\r
-#endif\r
-\r
-\r
-#include "ui/widget/point.h"\r
-#include "ui/widget/labelled.h"\r
-#include "ui/widget/scalar.h"\r
-#include <gtkmm/box.h>\r
-\r
-namespace Inkscape {\r
-namespace UI {\r
-namespace Widget {\r
-\r
-/**\r
- * Construct a Point Widget.\r
- *\r
- * \param label     Label.\r
- * \param suffix    Suffix, placed after the widget (defaults to "").\r
- * \param icon      Icon filename, placed before the label (defaults to "").\r
- * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label\r
- *                  indicates the next character should be used for the\r
- *                  mnemonic accelerator key (defaults to false).\r
- */\r
-Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,\r
-               Glib::ustring const &suffix,\r
-               Glib::ustring const &icon,\r
-               bool mnemonic)\r
-    : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
-      setProgrammatically(false),\r
-      xwidget("X:",""),\r
-      ywidget("Y:","")\r
-{\r
-    static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);\r
-    static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);\r
-    static_cast<Gtk::VBox*>(_widget)->show_all_children();\r
-}\r
-\r
-/**\r
- * Construct a Point Widget.\r
- *\r
- * \param label     Label.\r
- * \param digits    Number of decimal digits to display.\r
- * \param suffix    Suffix, placed after the widget (defaults to "").\r
- * \param icon      Icon filename, placed before the label (defaults to "").\r
- * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label\r
- *                  indicates the next character should be used for the\r
- *                  mnemonic accelerator key (defaults to false).\r
- */\r
-Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,\r
-               unsigned digits,\r
-               Glib::ustring const &suffix,\r
-               Glib::ustring const &icon,\r
-               bool mnemonic)\r
-    : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
-      setProgrammatically(false),\r
-      xwidget("X:","", digits),\r
-      ywidget("Y:","", digits)\r
-{\r
-    static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);\r
-    static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);\r
-    static_cast<Gtk::VBox*>(_widget)->show_all_children();\r
-}\r
-\r
-/**\r
- * Construct a Point Widget.\r
- *\r
- * \param label     Label.\r
- * \param adjust    Adjustment to use for the SpinButton.\r
- * \param digits    Number of decimal digits to display (defaults to 0).\r
- * \param suffix    Suffix, placed after the widget (defaults to "").\r
- * \param icon      Icon filename, placed before the label (defaults to "").\r
- * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label\r
- *                  indicates the next character should be used for the\r
- *                  mnemonic accelerator key (defaults to true).\r
- */\r
-Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,\r
-               Gtk::Adjustment &adjust,\r
-               unsigned digits,\r
-               Glib::ustring const &suffix,\r
-               Glib::ustring const &icon,\r
-               bool mnemonic)\r
-    : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
-      setProgrammatically(false),\r
-      xwidget("X:","", adjust, digits),\r
-      ywidget("Y:","", adjust, digits)\r
-{\r
-    static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);\r
-    static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);\r
-    static_cast<Gtk::VBox*>(_widget)->show_all_children();\r
-}\r
-\r
-/** Fetches the precision of the spin buton */\r
-unsigned\r
-Point::getDigits() const\r
-{\r
-    return xwidget.getDigits();\r
-}\r
-\r
-/** Gets the current step ingrement used by the spin button */\r
-double\r
-Point::getStep() const\r
-{\r
-    return xwidget.getStep();\r
-}\r
-\r
-/** Gets the current page increment used by the spin button */\r
-double\r
-Point::getPage() const\r
-{\r
-    return xwidget.getPage();\r
-}\r
-\r
-/** Gets the minimum range value allowed for the spin button */\r
-double\r
-Point::getRangeMin() const\r
-{\r
-    return xwidget.getRangeMin();\r
-}\r
-\r
-/** Gets the maximum range value allowed for the spin button */\r
-double\r
-Point::getRangeMax() const\r
-{\r
-    return xwidget.getRangeMax();\r
-}\r
-\r
-/** Get the value in the spin_button . */\r
-double\r
-Point::getXValue() const\r
-{\r
-    return xwidget.getValue();\r
-}\r
-double\r
-Point::getYValue() const\r
-{\r
-    return ywidget.getValue();\r
-}\r
-\r
-/** Get the value spin_button represented as an integer. */\r
-int\r
-Point::getXValueAsInt() const\r
-{\r
-    return xwidget.getValueAsInt();\r
-}\r
-int\r
-Point::getYValueAsInt() const\r
-{\r
-    return ywidget.getValueAsInt();\r
-}\r
-\r
-\r
-/** Sets the precision to be displayed by the spin button */\r
-void\r
-Point::setDigits(unsigned digits)\r
-{\r
-    xwidget.setDigits(digits);\r
-    ywidget.setDigits(digits);\r
-}\r
-\r
-/** Sets the step and page increments for the spin button */\r
-void\r
-Point::setIncrements(double step, double page)\r
-{\r
-    xwidget.setIncrements(step, page);\r
-    ywidget.setIncrements(step, page);\r
-}\r
-\r
-/** Sets the minimum and maximum range allowed for the spin button */\r
-void\r
-Point::setRange(double min, double max)\r
-{\r
-    xwidget.setRange(min, max);\r
-    ywidget.setRange(min, max);\r
-}\r
-\r
-/** Sets the value of the spin button */\r
-void\r
-Point::setValue(double xvalue, double yvalue)\r
-{\r
-    setProgrammatically = true; // callback is supposed to reset back, if it cares\r
-    xwidget.setValue(xvalue);\r
-    ywidget.setValue(yvalue);\r
-}\r
-\r
-/** Manually forces an update of the spin button */\r
-void\r
-Point::update() {\r
-    xwidget.update();\r
-    ywidget.update();\r
-}\r
-\r
-\r
-\r
-/** Signal raised when the spin button's value changes */\r
-Glib::SignalProxy0<void>\r
-Point::signal_x_value_changed()\r
-{\r
-    return xwidget.signal_value_changed();\r
-}\r
-Glib::SignalProxy0<void>\r
-Point::signal_y_value_changed()\r
-{\r
-    return ywidget.signal_value_changed();\r
-}\r
-\r
-\r
-} // namespace Widget\r
-} // namespace UI\r
-} // namespace Inkscape\r
-\r
-/*\r
-  Local Variables:\r
-  mode:c++\r
-  c-file-style:"stroustrup"\r
-  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
-  indent-tabs-mode:nil\r
-  fill-column:99\r
-  End:\r
-*/\r
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :\r
+/**
+ * \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),
+      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),
+      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),
+      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)
+{
+    xwidget.setValue(xvalue);
+    ywidget.setValue(yvalue);
+}
+
+/** Manually forces an update of the spin button */
+void
+Point::update() {
+    xwidget.update();
+    ywidget.update();
+}
+
+/** Check 'setProgrammatically' of both scalar widgets.   False if value is changed by user by clicking the widget. */
+bool
+Point::setProgrammatically() {
+    return (xwidget.setProgrammatically || ywidget.setProgrammatically);
+}
+
+void
+Point::clearProgrammatically() {
+    xwidget.setProgrammatically = false;
+    ywidget.setProgrammatically = false;
+}
+
+
+/** 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 :