Code

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