From bdfd348bf0d4f59ffde2fbcc0965ac8a79cdf12c Mon Sep 17 00:00:00 2001 From: Peter Moulder Date: Thu, 11 Oct 2007 14:28:57 +0000 Subject: trivial: ui/widget/*, ui/dialog/*: svn propset svn:eol-style native *.h *.cpp. (bzr r3883) --- src/ui/widget/point.cpp | 488 +++++++++++++++++++-------------------- src/ui/widget/point.h | 194 ++++++++-------- src/ui/widget/random.cpp | 296 ++++++++++++------------ src/ui/widget/random.h | 144 ++++++------ src/ui/widget/registered-enums.h | 230 +++++++++--------- 5 files changed, 676 insertions(+), 676 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index ae7197c29..634329ddc 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -1,244 +1,244 @@ -/** - * \brief Point Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary coordinate values. - * - * Authors: - * Johan Engelen - * Carl Hetherington - * Derek P. Moore - * Bryce Harrington - * - * Copyright (C) 2007 Authors - * Copyright (C) 2004 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "ui/widget/point.h" -#include "ui/widget/labelled.h" -#include "ui/widget/scalar.h" -#include - -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(_widget)->pack_start(xwidget, true, true); - static_cast(_widget)->pack_start(ywidget, true, true); - static_cast(_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(_widget)->pack_start(xwidget, true, true); - static_cast(_widget)->pack_start(ywidget, true, true); - static_cast(_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(_widget)->pack_start(xwidget, true, true); - static_cast(_widget)->pack_start(ywidget, true, true); - static_cast(_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 -Point::signal_x_value_changed() -{ - return xwidget.signal_value_changed(); -} -Glib::SignalProxy0 -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 : +/** + * \brief Point Widget - A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary coordinate values. + * + * Authors: + * Johan Engelen + * Carl Hetherington + * Derek P. Moore + * Bryce Harrington + * + * Copyright (C) 2007 Authors + * Copyright (C) 2004 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + + +#include "ui/widget/point.h" +#include "ui/widget/labelled.h" +#include "ui/widget/scalar.h" +#include + +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(_widget)->pack_start(xwidget, true, true); + static_cast(_widget)->pack_start(ywidget, true, true); + static_cast(_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(_widget)->pack_start(xwidget, true, true); + static_cast(_widget)->pack_start(ywidget, true, true); + static_cast(_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(_widget)->pack_start(xwidget, true, true); + static_cast(_widget)->pack_start(ywidget, true, true); + static_cast(_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 +Point::signal_x_value_changed() +{ + return xwidget.signal_value_changed(); +} +Glib::SignalProxy0 +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 : diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index 7653ceaa4..b65a13e20 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -1,97 +1,97 @@ -/** - * \brief Point Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary coordinate values. - * - * Authors: - * Johan Engelen - * Carl Hetherington - * Derek P. Moore - * Bryce Harrington - * - * Copyright (C) 2007 Authors - * Copyright (C) 2004 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifndef INKSCAPE_UI_WIDGET_POINT_H -#define INKSCAPE_UI_WIDGET_POINT_H - -#include -#include - -#include "ui/widget/labelled.h" -#include "ui/widget/scalar.h" - -namespace Inkscape { -namespace UI { -namespace Widget { - -class Point : public Labelled -{ -public: - Point( Glib::ustring const &label, - Glib::ustring const &tooltip, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - Point( Glib::ustring const &label, - Glib::ustring const &tooltip, - unsigned digits, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - Point( Glib::ustring const &label, - Glib::ustring const &tooltip, - Gtk::Adjustment &adjust, - unsigned digits = 0, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - - unsigned getDigits() const; - double getStep() const; - double getPage() const; - double getRangeMin() const; - double getRangeMax() const; - bool getSnapToTicks() const; - double getXValue() const; - double getYValue() const; - int getXValueAsInt() const; - int getYValueAsInt() const; - - void setDigits(unsigned digits); - void setIncrements(double step, double page); - void setRange(double min, double max); - void setValue(double xvalue, double yvalue); - - void update(); - - Glib::SignalProxy0 signal_x_value_changed(); - Glib::SignalProxy0 signal_y_value_changed(); - - bool setProgrammatically(); // true if the value was set by setValue, not changed by the user; - // if a callback checks it, it must reset it back to false - void clearProgrammatically(); - -protected: - Scalar xwidget, ywidget; - -}; - -} // namespace Widget -} // namespace UI -} // namespace Inkscape - -#endif // INKSCAPE_UI_WIDGET_POINT_H - -/* - 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 : +/** + * \brief Point Widget - A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary coordinate values. + * + * Authors: + * Johan Engelen + * Carl Hetherington + * Derek P. Moore + * Bryce Harrington + * + * Copyright (C) 2007 Authors + * Copyright (C) 2004 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_POINT_H +#define INKSCAPE_UI_WIDGET_POINT_H + +#include +#include + +#include "ui/widget/labelled.h" +#include "ui/widget/scalar.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +class Point : public Labelled +{ +public: + Point( Glib::ustring const &label, + Glib::ustring const &tooltip, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + Point( Glib::ustring const &label, + Glib::ustring const &tooltip, + unsigned digits, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + Point( Glib::ustring const &label, + Glib::ustring const &tooltip, + Gtk::Adjustment &adjust, + unsigned digits = 0, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + + unsigned getDigits() const; + double getStep() const; + double getPage() const; + double getRangeMin() const; + double getRangeMax() const; + bool getSnapToTicks() const; + double getXValue() const; + double getYValue() const; + int getXValueAsInt() const; + int getYValueAsInt() const; + + void setDigits(unsigned digits); + void setIncrements(double step, double page); + void setRange(double min, double max); + void setValue(double xvalue, double yvalue); + + void update(); + + Glib::SignalProxy0 signal_x_value_changed(); + Glib::SignalProxy0 signal_y_value_changed(); + + bool setProgrammatically(); // true if the value was set by setValue, not changed by the user; + // if a callback checks it, it must reset it back to false + void clearProgrammatically(); + +protected: + Scalar xwidget, ywidget; + +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_POINT_H + +/* + 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 : diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 1d99f406c..9fb0e7be2 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -1,148 +1,148 @@ -/** - * \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 - * Derek P. Moore - * Bryce Harrington - * - * Copyright (C) 2004 Carl Hetherington - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "random.h" -#include "widgets/icon.h" - -#include - -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( "draw_spiral", 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 : +/** + * \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 + * Derek P. Moore + * Bryce Harrington + * + * Copyright (C) 2004 Carl Hetherington + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + + +#include "random.h" +#include "widgets/icon.h" + +#include + +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( "draw_spiral", 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 : diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h index 56c39ccc1..93c6c2ff4 100644 --- a/src/ui/widget/random.h +++ b/src/ui/widget/random.h @@ -1,72 +1,72 @@ -/** - * \brief Random Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values and generating a random number from it. - * - * Authors: - * Johan Engelen - * - * Copyright (C) 2007 Author - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifndef INKSCAPE_UI_WIDGET_RANDOM_H -#define INKSCAPE_UI_WIDGET_RANDOM_H - -#include "scalar.h" - -namespace Inkscape { -namespace UI { -namespace Widget { - -class Random : public Scalar -{ -public: - Random(Glib::ustring const &label, - Glib::ustring const &tooltip, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - Random(Glib::ustring const &label, - Glib::ustring const &tooltip, - unsigned digits, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - Random(Glib::ustring const &label, - Glib::ustring const &tooltip, - Gtk::Adjustment &adjust, - unsigned digits = 0, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - - long getStartSeed() const; - void setStartSeed(long newseed); - - sigc::signal signal_reseeded; - -protected: - long startseed; - -private: - void addReseedButton(); - void onReseedButtonClick(); -}; - -} // namespace Widget -} // namespace UI -} // namespace Inkscape - -#endif // INKSCAPE_UI_WIDGET_RANDOM_H - -/* - 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 : +/** + * \brief Random Scalar Widget - A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary number values and generating a random number from it. + * + * Authors: + * Johan Engelen + * + * Copyright (C) 2007 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_RANDOM_H +#define INKSCAPE_UI_WIDGET_RANDOM_H + +#include "scalar.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +class Random : public Scalar +{ +public: + Random(Glib::ustring const &label, + Glib::ustring const &tooltip, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + Random(Glib::ustring const &label, + Glib::ustring const &tooltip, + unsigned digits, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + Random(Glib::ustring const &label, + Glib::ustring const &tooltip, + Gtk::Adjustment &adjust, + unsigned digits = 0, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + + long getStartSeed() const; + void setStartSeed(long newseed); + + sigc::signal signal_reseeded; + +protected: + long startseed; + +private: + void addReseedButton(); + void onReseedButtonClick(); +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_RANDOM_H + +/* + 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 : diff --git a/src/ui/widget/registered-enums.h b/src/ui/widget/registered-enums.h index 41b404978..6dfa48b7a 100644 --- a/src/ui/widget/registered-enums.h +++ b/src/ui/widget/registered-enums.h @@ -1,115 +1,115 @@ -/** - * \brief Simplified management of enumerations in the UI as combobox. - * - * Authors: - * Johan Engelen - * - * Copyright (C) 2007 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifndef INKSCAPE_UI_WIDGET_REGISTERED_ENUMS_H -#define INKSCAPE_UI_WIDGET_REGISTERED_ENUMS_H - -#include "ui/widget/combo-enums.h" -#include "ui/widget/registered-widget.h" - -namespace Inkscape { -namespace UI { -namespace Widget { - -template class RegisteredEnum : public RegisteredWidget -{ -public: - RegisteredEnum() { - labelled = NULL; - } - - ~RegisteredEnum() { - _changed_connection.disconnect(); - if (labelled) - delete labelled; - } - - void init ( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, - const Util::EnumDataConverter& c, - Registry& wr, - Inkscape::XML::Node* repr_in, - SPDocument *doc_in) - { - init_parent(key, wr, repr_in, doc_in); - - labelled = new LabelledComboBoxEnum (label, tip, c); - - _changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed)); - } - - inline void init ( const Glib::ustring& label, - const Glib::ustring& key, - Registry& wr) - { - init(label, key, wr, NULL, NULL); - } - - void set_active_by_id (E id) { - combobox()->set_active_by_id(id); - }; - - void set_active_by_key (const Glib::ustring& key) { - combobox()->set_active_by_key(key); - } - - inline const Util::EnumData* get_active_data() { - return combobox()->get_active_data(); - } - - ComboBoxEnum * combobox() { - if (labelled) { - return labelled->getCombobox(); - } else { - return NULL; - } - } - - LabelledComboBoxEnum * labelled; - sigc::connection _changed_connection; - -protected: - void on_changed() { - if (combobox()->setProgrammatically) { - combobox()->setProgrammatically = false; - return; - } - - if (_wr->isUpdating()) - return; - _wr->setUpdating (true); - - const Util::EnumData* data = combobox()->get_active_data(); - if (data) { - write_to_xml(data->key.c_str()); - } - - _wr->setUpdating (false); - } -}; - -} -} -} - -#endif - -/* - 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 : +/** + * \brief Simplified management of enumerations in the UI as combobox. + * + * Authors: + * Johan Engelen + * + * Copyright (C) 2007 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_REGISTERED_ENUMS_H +#define INKSCAPE_UI_WIDGET_REGISTERED_ENUMS_H + +#include "ui/widget/combo-enums.h" +#include "ui/widget/registered-widget.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +template class RegisteredEnum : public RegisteredWidget +{ +public: + RegisteredEnum() { + labelled = NULL; + } + + ~RegisteredEnum() { + _changed_connection.disconnect(); + if (labelled) + delete labelled; + } + + void init ( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + const Util::EnumDataConverter& c, + Registry& wr, + Inkscape::XML::Node* repr_in, + SPDocument *doc_in) + { + init_parent(key, wr, repr_in, doc_in); + + labelled = new LabelledComboBoxEnum (label, tip, c); + + _changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed)); + } + + inline void init ( const Glib::ustring& label, + const Glib::ustring& key, + Registry& wr) + { + init(label, key, wr, NULL, NULL); + } + + void set_active_by_id (E id) { + combobox()->set_active_by_id(id); + }; + + void set_active_by_key (const Glib::ustring& key) { + combobox()->set_active_by_key(key); + } + + inline const Util::EnumData* get_active_data() { + return combobox()->get_active_data(); + } + + ComboBoxEnum * combobox() { + if (labelled) { + return labelled->getCombobox(); + } else { + return NULL; + } + } + + LabelledComboBoxEnum * labelled; + sigc::connection _changed_connection; + +protected: + void on_changed() { + if (combobox()->setProgrammatically) { + combobox()->setProgrammatically = false; + return; + } + + if (_wr->isUpdating()) + return; + _wr->setUpdating (true); + + const Util::EnumData* data = combobox()->get_active_data(); + if (data) { + write_to_xml(data->key.c_str()); + } + + _wr->setUpdating (false); + } +}; + +} +} +} + +#endif + +/* + 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 : -- cgit v1.2.3