Code

UI generalisation
[inkscape.git] / src / ui / widget / random.cpp
index 1d99f406cf4ef5824066e0807e464de7078413de..c06051098633fb501ba0ea89c735e8b48ef5c00d 100644 (file)
-/**\r
- * \brief Scalar Widget - A labelled text box, with spin buttons and optional\r
- *        icon or suffix, for entering arbitrary number values. It adds an extra\r
- *       number called "startseed", that is not UI edittable, but should be put in SVG.\r
- *      This does NOT generate a random number, but provides merely the saving of \r
- *      the startseed value.\r
- *\r
- * Authors:\r
- *   Carl Hetherington <inkscape@carlh.net>\r
- *   Derek P. Moore <derekm@hackunix.org>\r
- *   Bryce Harrington <bryce@bryceharrington.org>\r
- *\r
- * Copyright (C) 2004 Carl Hetherington\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 "random.h"\r
-#include "widgets/icon.h"\r
-\r
-#include <glibmm/i18n.h>\r
-\r
-namespace Inkscape {\r
-namespace UI {\r
-namespace Widget {\r
-\r
-/**\r
- * Construct a Random scalar 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
-Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,\r
-               Glib::ustring const &suffix,\r
-               Glib::ustring const &icon,\r
-               bool mnemonic)\r
-    : Scalar(label, tooltip, suffix, icon, mnemonic)\r
-{\r
-    startseed = 0;\r
-    addReseedButton();\r
-}\r
-\r
-/**\r
- * Construct a  Random Scalar 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
-Random::Random(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
-    : Scalar(label, tooltip, digits, suffix, icon, mnemonic)\r
-{\r
-    startseed = 0;\r
-    addReseedButton();\r
-}\r
-\r
-/**\r
- * Construct a Random Scalar 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
-Random::Random(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
-    : Scalar(label, tooltip, adjust, digits, suffix, icon, mnemonic)\r
-{\r
-    startseed = 0;\r
-    addReseedButton();\r
-}\r
-\r
-/** Gets the startseed  */\r
-long\r
-Random::getStartSeed() const\r
-{\r
-    return startseed;\r
-}\r
-\r
-/** Sets the startseed number */\r
-void\r
-Random::setStartSeed(long newseed)\r
-{\r
-    startseed = newseed;\r
-}\r
-\r
-/** Add reseed button to the widget */\r
-void\r
-Random::addReseedButton()\r
-{\r
-    Gtk::Widget*  pIcon = Gtk::manage( sp_icon_get_icon( "draw_spiral", Inkscape::ICON_SIZE_BUTTON) );\r
-    Gtk::Button * pButton = Gtk::manage(new Gtk::Button());\r
-    pButton->set_relief(Gtk::RELIEF_NONE);\r
-    pIcon->show();\r
-    pButton->add(*pIcon);\r
-    pButton->show();\r
-    pButton->signal_clicked().connect(sigc::mem_fun(*this, &Random::onReseedButtonClick));\r
-    _tooltips.set_tip(*pButton, _("Reseed the random number generator; this creates a different sequence of random numbers."));\r
-\r
-    pack_start(*pButton, Gtk::PACK_SHRINK, 0);\r
-}\r
-\r
-void\r
-Random::onReseedButtonClick()\r
-{\r
-    startseed = g_random_int();\r
-    signal_reseeded.emit();\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 Scalar Widget - A labelled text box, with spin buttons and optional
+ *        icon or suffix, for entering arbitrary number values. It adds an extra
+ *       number called "startseed", that is not UI edittable, but should be put in SVG.
+ *      This does NOT generate a random number, but provides merely the saving of 
+ *      the startseed value.
+ *
+ * Authors:
+ *   Carl Hetherington <inkscape@carlh.net>
+ *   Derek P. Moore <derekm@hackunix.org>
+ *   Bryce Harrington <bryce@bryceharrington.org>
+ *
+ * Copyright (C) 2004 Carl Hetherington
+ *
+ * Released under GNU GPL.  Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+
+#include "random.h"
+#include "widgets/icon.h"
+
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * Construct a Random scalar 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).
+ */
+Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
+               Glib::ustring const &suffix,
+               Glib::ustring const &icon,
+               bool mnemonic)
+    : Scalar(label, tooltip, suffix, icon, mnemonic)
+{
+    startseed = 0;
+    addReseedButton();
+}
+
+/**
+ * Construct a  Random Scalar 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).
+ */
+Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
+               unsigned digits,
+               Glib::ustring const &suffix,
+               Glib::ustring const &icon,
+               bool mnemonic)
+    : Scalar(label, tooltip, digits, suffix, icon, mnemonic)
+{
+    startseed = 0;
+    addReseedButton();
+}
+
+/**
+ * Construct a Random Scalar 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).
+ */
+Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
+               Gtk::Adjustment &adjust,
+               unsigned digits,
+               Glib::ustring const &suffix,
+               Glib::ustring const &icon,
+               bool mnemonic)
+    : Scalar(label, tooltip, adjust, digits, suffix, icon, mnemonic)
+{
+    startseed = 0;
+    addReseedButton();
+}
+
+/** Gets the startseed  */
+long
+Random::getStartSeed() const
+{
+    return startseed;
+}
+
+/** Sets the startseed number */
+void
+Random::setStartSeed(long newseed)
+{
+    startseed = newseed;
+}
+
+/** Add reseed button to the widget */
+void
+Random::addReseedButton()
+{
+    Gtk::Widget*  pIcon = Gtk::manage( sp_icon_get_icon( "randomize", Inkscape::ICON_SIZE_BUTTON) );
+    Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+    pButton->set_relief(Gtk::RELIEF_NONE);
+    pIcon->show();
+    pButton->add(*pIcon);
+    pButton->show();
+    pButton->signal_clicked().connect(sigc::mem_fun(*this, &Random::onReseedButtonClick));
+    _tooltips.set_tip(*pButton, _("Reseed the random number generator; this creates a different sequence of random numbers."));
+
+    pack_start(*pButton, Gtk::PACK_SHRINK, 0);
+}
+
+void
+Random::onReseedButtonClick()
+{
+    startseed = g_random_int();
+    signal_reseeded.emit();
+}
+
+} // 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 :