Code

trivial: ui/widget/*, ui/dialog/*: svn propset svn:eol-style native *.h *.cpp.
[inkscape.git] / src / ui / widget / point.cpp
1 /**
2  * \brief Point Widget - A labelled text box, with spin buttons and optional
3  *        icon or suffix, for entering arbitrary coordinate values.
4  *
5  * Authors:
6  *   Johan Engelen <j.b.c.engelen@utwente.nl>
7  *   Carl Hetherington <inkscape@carlh.net>
8  *   Derek P. Moore <derekm@hackunix.org>
9  *   Bryce Harrington <bryce@bryceharrington.org>
10  *
11  * Copyright (C) 2007 Authors
12  * Copyright (C) 2004 Authors
13  *
14  * Released under GNU GPL.  Read the file 'COPYING' for more information.
15  */
17 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
22 #include "ui/widget/point.h"
23 #include "ui/widget/labelled.h"
24 #include "ui/widget/scalar.h"
25 #include <gtkmm/box.h>
27 namespace Inkscape {
28 namespace UI {
29 namespace Widget {
31 /**
32  * Construct a Point Widget.
33  *
34  * \param label     Label.
35  * \param suffix    Suffix, placed after the widget (defaults to "").
36  * \param icon      Icon filename, placed before the label (defaults to "").
37  * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label
38  *                  indicates the next character should be used for the
39  *                  mnemonic accelerator key (defaults to false).
40  */
41 Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
42                Glib::ustring const &suffix,
43                Glib::ustring const &icon,
44                bool mnemonic)
45     : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),
46       xwidget("X:",""),
47       ywidget("Y:","")
48 {
49     static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);
50     static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);
51     static_cast<Gtk::VBox*>(_widget)->show_all_children();
52 }
54 /**
55  * Construct a Point Widget.
56  *
57  * \param label     Label.
58  * \param digits    Number of decimal digits to display.
59  * \param suffix    Suffix, placed after the widget (defaults to "").
60  * \param icon      Icon filename, placed before the label (defaults to "").
61  * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label
62  *                  indicates the next character should be used for the
63  *                  mnemonic accelerator key (defaults to false).
64  */
65 Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
66                unsigned digits,
67                Glib::ustring const &suffix,
68                Glib::ustring const &icon,
69                bool mnemonic)
70     : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),
71       xwidget("X:","", digits),
72       ywidget("Y:","", digits)
73 {
74     static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);
75     static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);
76     static_cast<Gtk::VBox*>(_widget)->show_all_children();
77 }
79 /**
80  * Construct a Point Widget.
81  *
82  * \param label     Label.
83  * \param adjust    Adjustment to use for the SpinButton.
84  * \param digits    Number of decimal digits to display (defaults to 0).
85  * \param suffix    Suffix, placed after the widget (defaults to "").
86  * \param icon      Icon filename, placed before the label (defaults to "").
87  * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label
88  *                  indicates the next character should be used for the
89  *                  mnemonic accelerator key (defaults to true).
90  */
91 Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
92                Gtk::Adjustment &adjust,
93                unsigned digits,
94                Glib::ustring const &suffix,
95                Glib::ustring const &icon,
96                bool mnemonic)
97     : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),
98       xwidget("X:","", adjust, digits),
99       ywidget("Y:","", adjust, digits)
101     static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);
102     static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);
103     static_cast<Gtk::VBox*>(_widget)->show_all_children();
106 /** Fetches the precision of the spin buton */
107 unsigned
108 Point::getDigits() const
110     return xwidget.getDigits();
113 /** Gets the current step ingrement used by the spin button */
114 double
115 Point::getStep() const
117     return xwidget.getStep();
120 /** Gets the current page increment used by the spin button */
121 double
122 Point::getPage() const
124     return xwidget.getPage();
127 /** Gets the minimum range value allowed for the spin button */
128 double
129 Point::getRangeMin() const
131     return xwidget.getRangeMin();
134 /** Gets the maximum range value allowed for the spin button */
135 double
136 Point::getRangeMax() const
138     return xwidget.getRangeMax();
141 /** Get the value in the spin_button . */
142 double
143 Point::getXValue() const
145     return xwidget.getValue();
147 double
148 Point::getYValue() const
150     return ywidget.getValue();
153 /** Get the value spin_button represented as an integer. */
154 int
155 Point::getXValueAsInt() const
157     return xwidget.getValueAsInt();
159 int
160 Point::getYValueAsInt() const
162     return ywidget.getValueAsInt();
166 /** Sets the precision to be displayed by the spin button */
167 void
168 Point::setDigits(unsigned digits)
170     xwidget.setDigits(digits);
171     ywidget.setDigits(digits);
174 /** Sets the step and page increments for the spin button */
175 void
176 Point::setIncrements(double step, double page)
178     xwidget.setIncrements(step, page);
179     ywidget.setIncrements(step, page);
182 /** Sets the minimum and maximum range allowed for the spin button */
183 void
184 Point::setRange(double min, double max)
186     xwidget.setRange(min, max);
187     ywidget.setRange(min, max);
190 /** Sets the value of the spin button */
191 void
192 Point::setValue(double xvalue, double yvalue)
194     xwidget.setValue(xvalue);
195     ywidget.setValue(yvalue);
198 /** Manually forces an update of the spin button */
199 void
200 Point::update() {
201     xwidget.update();
202     ywidget.update();
205 /** Check 'setProgrammatically' of both scalar widgets.   False if value is changed by user by clicking the widget. */
206 bool
207 Point::setProgrammatically() {
208     return (xwidget.setProgrammatically || ywidget.setProgrammatically);
211 void
212 Point::clearProgrammatically() {
213     xwidget.setProgrammatically = false;
214     ywidget.setProgrammatically = false;
218 /** Signal raised when the spin button's value changes */
219 Glib::SignalProxy0<void>
220 Point::signal_x_value_changed()
222     return xwidget.signal_value_changed();
224 Glib::SignalProxy0<void>
225 Point::signal_y_value_changed()
227     return ywidget.signal_value_changed();
231 } // namespace Widget
232 } // namespace UI
233 } // namespace Inkscape
235 /*
236   Local Variables:
237   mode:c++
238   c-file-style:"stroustrup"
239   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
240   indent-tabs-mode:nil
241   fill-column:99
242   End:
243 */
244 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :