Code

search and reset buttons added to ocal related features. fixed signals in import...
[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       setProgrammatically(false),\r
47       xwidget("X:",""),\r
48       ywidget("Y:","")\r
49 {\r
50     static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);\r
51     static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);\r
52     static_cast<Gtk::VBox*>(_widget)->show_all_children();\r
53 }\r
54 \r
55 /**\r
56  * Construct a Point Widget.\r
57  *\r
58  * \param label     Label.\r
59  * \param digits    Number of decimal digits to display.\r
60  * \param suffix    Suffix, placed after the widget (defaults to "").\r
61  * \param icon      Icon filename, placed before the label (defaults to "").\r
62  * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label\r
63  *                  indicates the next character should be used for the\r
64  *                  mnemonic accelerator key (defaults to false).\r
65  */\r
66 Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,\r
67                unsigned digits,\r
68                Glib::ustring const &suffix,\r
69                Glib::ustring const &icon,\r
70                bool mnemonic)\r
71     : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
72       setProgrammatically(false),\r
73       xwidget("X:","", digits),\r
74       ywidget("Y:","", digits)\r
75 {\r
76     static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);\r
77     static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);\r
78     static_cast<Gtk::VBox*>(_widget)->show_all_children();\r
79 }\r
80 \r
81 /**\r
82  * Construct a Point Widget.\r
83  *\r
84  * \param label     Label.\r
85  * \param adjust    Adjustment to use for the SpinButton.\r
86  * \param digits    Number of decimal digits to display (defaults to 0).\r
87  * \param suffix    Suffix, placed after the widget (defaults to "").\r
88  * \param icon      Icon filename, placed before the label (defaults to "").\r
89  * \param mnemonic  Mnemonic toggle; if true, an underscore (_) in the label\r
90  *                  indicates the next character should be used for the\r
91  *                  mnemonic accelerator key (defaults to true).\r
92  */\r
93 Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,\r
94                Gtk::Adjustment &adjust,\r
95                unsigned digits,\r
96                Glib::ustring const &suffix,\r
97                Glib::ustring const &icon,\r
98                bool mnemonic)\r
99     : Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
100       setProgrammatically(false),\r
101       xwidget("X:","", adjust, digits),\r
102       ywidget("Y:","", adjust, digits)\r
103 {\r
104     static_cast<Gtk::VBox*>(_widget)->pack_start(xwidget, true, true);\r
105     static_cast<Gtk::VBox*>(_widget)->pack_start(ywidget, true, true);\r
106     static_cast<Gtk::VBox*>(_widget)->show_all_children();\r
107 }\r
108 \r
109 /** Fetches the precision of the spin buton */\r
110 unsigned\r
111 Point::getDigits() const\r
112 {\r
113     return xwidget.getDigits();\r
114 }\r
115 \r
116 /** Gets the current step ingrement used by the spin button */\r
117 double\r
118 Point::getStep() const\r
119 {\r
120     return xwidget.getStep();\r
121 }\r
122 \r
123 /** Gets the current page increment used by the spin button */\r
124 double\r
125 Point::getPage() const\r
126 {\r
127     return xwidget.getPage();\r
128 }\r
129 \r
130 /** Gets the minimum range value allowed for the spin button */\r
131 double\r
132 Point::getRangeMin() const\r
133 {\r
134     return xwidget.getRangeMin();\r
135 }\r
136 \r
137 /** Gets the maximum range value allowed for the spin button */\r
138 double\r
139 Point::getRangeMax() const\r
140 {\r
141     return xwidget.getRangeMax();\r
142 }\r
143 \r
144 /** Get the value in the spin_button . */\r
145 double\r
146 Point::getXValue() const\r
147 {\r
148     return xwidget.getValue();\r
149 }\r
150 double\r
151 Point::getYValue() const\r
152 {\r
153     return ywidget.getValue();\r
154 }\r
155 \r
156 /** Get the value spin_button represented as an integer. */\r
157 int\r
158 Point::getXValueAsInt() const\r
159 {\r
160     return xwidget.getValueAsInt();\r
161 }\r
162 int\r
163 Point::getYValueAsInt() const\r
164 {\r
165     return ywidget.getValueAsInt();\r
166 }\r
167 \r
168 \r
169 /** Sets the precision to be displayed by the spin button */\r
170 void\r
171 Point::setDigits(unsigned digits)\r
172 {\r
173     xwidget.setDigits(digits);\r
174     ywidget.setDigits(digits);\r
175 }\r
176 \r
177 /** Sets the step and page increments for the spin button */\r
178 void\r
179 Point::setIncrements(double step, double page)\r
180 {\r
181     xwidget.setIncrements(step, page);\r
182     ywidget.setIncrements(step, page);\r
183 }\r
184 \r
185 /** Sets the minimum and maximum range allowed for the spin button */\r
186 void\r
187 Point::setRange(double min, double max)\r
188 {\r
189     xwidget.setRange(min, max);\r
190     ywidget.setRange(min, max);\r
191 }\r
192 \r
193 /** Sets the value of the spin button */\r
194 void\r
195 Point::setValue(double xvalue, double yvalue)\r
196 {\r
197     setProgrammatically = true; // callback is supposed to reset back, if it cares\r
198     xwidget.setValue(xvalue);\r
199     ywidget.setValue(yvalue);\r
200 }\r
201 \r
202 /** Manually forces an update of the spin button */\r
203 void\r
204 Point::update() {\r
205     xwidget.update();\r
206     ywidget.update();\r
207 }\r
208 \r
209 \r
210 \r
211 /** Signal raised when the spin button's value changes */\r
212 Glib::SignalProxy0<void>\r
213 Point::signal_x_value_changed()\r
214 {\r
215     return xwidget.signal_value_changed();\r
216 }\r
217 Glib::SignalProxy0<void>\r
218 Point::signal_y_value_changed()\r
219 {\r
220     return ywidget.signal_value_changed();\r
221 }\r
222 \r
223 \r
224 } // namespace Widget\r
225 } // namespace UI\r
226 } // namespace Inkscape\r
227 \r
228 /*\r
229   Local Variables:\r
230   mode:c++\r
231   c-file-style:"stroustrup"\r
232   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
233   indent-tabs-mode:nil\r
234   fill-column:99\r
235   End:\r
236 */\r
237 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :\r