1 /** \file
2 * \brief
3 *
4 * Authors:
5 * Ralf Stephan <ralf@ark.in-berlin.de>
6 *
7 * Copyright (C) 2005 Authors
8 *
9 * Released under GNU GPL. Read the file 'COPYING' for more information.
10 */
12 #ifndef INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
13 #define INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
15 #include <gtkmm/box.h>
16 #include <gtkmm/adjustment.h>
17 #include <gtkmm/tooltips.h>
19 #include "xml/node.h"
20 #include "registry.h"
22 class SPUnit;
23 class SPDocument;
25 namespace Gtk {
26 class HScale;
27 class RadioButton;
28 class SpinButton;
29 class ToggleButton;
30 }
32 namespace Inkscape {
33 namespace UI {
34 namespace Widget {
36 class ColorPicker;
37 class Registry;
38 class Scalar;
39 class ScalarUnit;
40 class UnitMenu;
41 class Point;
42 class Random;
44 class RegisteredWidget {
45 public:
46 void set_undo_parameters(const unsigned int _event_type, Glib::ustring _event_description)
47 {
48 event_type = _event_type;
49 event_description = _event_description;
50 write_undo = true;
51 }
53 bool is_updating() {if (_wr) return _wr->isUpdating(); else return false;}
55 protected:
56 RegisteredWidget()
57 {
58 _wr = NULL;
59 repr = NULL;
60 doc = NULL;
61 write_undo = false;
62 }
64 void init_parent(const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
65 {
66 _wr = ≀
67 _key = key;
68 repr = repr_in;
69 doc = doc_in;
70 if (repr && !doc) // doc cannot be NULL when repr is not NULL
71 g_warning("Initialization of registered widget using defined repr but with doc==NULL");
72 }
74 void write_to_xml(const char * svgstr);
76 Registry * _wr;
77 Glib::ustring _key;
78 Inkscape::XML::Node * repr;
79 SPDocument * doc;
80 unsigned int event_type;
81 Glib::ustring event_description;
82 bool write_undo;
83 };
85 //#######################################################
87 class RegisteredCheckButton : public RegisteredWidget {
88 public:
89 RegisteredCheckButton();
90 ~RegisteredCheckButton();
91 void init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL);
92 void setActive (bool);
94 Gtk::ToggleButton *_button;
95 std::list<Gtk::ToggleButton*> _slavebuttons;
97 // a slave button is only sensitive when the master button is active
98 // i.e. a slave button is greyed-out when the master button is not checked
100 void setSlaveButton(std::list<Gtk::ToggleButton*> btns) {
101 _slavebuttons = btns;
102 }
105 protected:
106 Gtk::Tooltips _tt;
107 sigc::connection _toggled_connection;
108 void on_toggled();
109 };
111 class RegisteredUnitMenu : public RegisteredWidget {
112 public:
113 RegisteredUnitMenu();
114 ~RegisteredUnitMenu();
115 void init ( const Glib::ustring& label,
116 const Glib::ustring& key,
117 Registry& wr,
118 Inkscape::XML::Node* repr_in,
119 SPDocument *doc_in);
120 inline void init ( const Glib::ustring& label,
121 const Glib::ustring& key,
122 Registry& wr)
123 { init(label, key, wr, NULL, NULL); };
125 void setUnit (const SPUnit*);
126 Gtk::Label *_label;
127 UnitMenu *_sel;
128 sigc::connection _changed_connection;
130 protected:
131 void on_changed();
132 };
134 class RegisteredScalarUnit : public RegisteredWidget {
135 public:
136 RegisteredScalarUnit();
137 ~RegisteredScalarUnit();
138 void init (const Glib::ustring& label,
139 const Glib::ustring& tip,
140 const Glib::ustring& key,
141 const RegisteredUnitMenu &rum,
142 Registry& wr,
143 Inkscape::XML::Node* repr_in,
144 SPDocument *doc_in);
145 inline void init ( const Glib::ustring& label,
146 const Glib::ustring& tip,
147 const Glib::ustring& key,
148 const RegisteredUnitMenu &rum,
149 Registry& wr)
150 { init(label, tip, key, rum, wr, NULL, NULL); };
152 ScalarUnit* getSU();
153 void setValue (double);
155 protected:
156 ScalarUnit *_widget;
157 sigc::connection _value_changed_connection;
158 UnitMenu *_um;
159 void on_value_changed();
160 };
162 class RegisteredScalar : public RegisteredWidget {
163 public:
164 RegisteredScalar();
165 ~RegisteredScalar();
166 void init (const Glib::ustring& label,
167 const Glib::ustring& tip,
168 const Glib::ustring& key,
169 Registry& wr,
170 Inkscape::XML::Node* repr_in,
171 SPDocument *doc_in);
172 inline void init ( const Glib::ustring& label,
173 const Glib::ustring& tip,
174 const Glib::ustring& key,
175 Registry& wr)
176 { init(label, tip, key, wr, NULL, NULL); };
178 Scalar* getS();
179 void setValue (double);
181 protected:
182 Scalar *_widget;
183 sigc::connection _value_changed_connection;
184 void on_value_changed();
185 };
187 class RegisteredColorPicker : public RegisteredWidget {
188 public:
189 RegisteredColorPicker();
190 ~RegisteredColorPicker();
191 void init (const Glib::ustring& label,
192 const Glib::ustring& title,
193 const Glib::ustring& tip,
194 const Glib::ustring& ckey,
195 const Glib::ustring& akey,
196 Registry& wr,
197 Inkscape::XML::Node* repr_in,
198 SPDocument *doc_in);
199 inline void init ( const Glib::ustring& label,
200 const Glib::ustring& title,
201 const Glib::ustring& tip,
202 const Glib::ustring& ckey,
203 const Glib::ustring& akey,
204 Registry& wr)
205 { init(label, title, tip, ckey, akey, wr, NULL, NULL); };
207 void setRgba32 (guint32);
208 void closeWindow();
210 Gtk::Label *_label;
211 ColorPicker *_cp;
213 protected:
214 Glib::ustring _ckey, _akey;
215 void on_changed (guint32);
216 sigc::connection _changed_connection;
217 };
219 class RegisteredSuffixedInteger : public RegisteredWidget {
220 public:
221 RegisteredSuffixedInteger();
222 ~RegisteredSuffixedInteger();
223 void init (const Glib::ustring& label1,
224 const Glib::ustring& label2,
225 const Glib::ustring& key,
226 Registry& wr,
227 Inkscape::XML::Node* repr_in,
228 SPDocument *doc_in);
229 inline void init ( const Glib::ustring& label1,
230 const Glib::ustring& label2,
231 const Glib::ustring& key,
232 Registry& wr)
233 { init(label1, label2, key, wr, NULL, NULL); };
235 void setValue (int);
236 Gtk::Label *_label;
237 Gtk::HBox _hbox;
239 protected:
240 Gtk::SpinButton *_sb;
241 Gtk::Adjustment _adj;
242 Gtk::Label *_suffix;
243 sigc::connection _changed_connection;
244 void on_value_changed();
245 };
247 class RegisteredRadioButtonPair : public RegisteredWidget {
248 public:
249 RegisteredRadioButtonPair();
250 ~RegisteredRadioButtonPair();
251 void init (const Glib::ustring& label,
252 const Glib::ustring& label1,
253 const Glib::ustring& label2,
254 const Glib::ustring& tip1,
255 const Glib::ustring& tip2,
256 const Glib::ustring& key,
257 Registry& wr,
258 Inkscape::XML::Node* repr_in,
259 SPDocument *doc_in);
260 inline void init ( const Glib::ustring& label,
261 const Glib::ustring& label1,
262 const Glib::ustring& label2,
263 const Glib::ustring& tip1,
264 const Glib::ustring& tip2,
265 const Glib::ustring& key,
266 Registry& wr)
267 { init(label, label1, label2, tip1, tip2, key, wr, NULL, NULL); };
269 void setValue (bool second);
270 Gtk::HBox *_hbox;
272 protected:
273 Gtk::RadioButton *_rb1, *_rb2;
274 Gtk::Tooltips _tt;
275 sigc::connection _changed_connection;
276 void on_value_changed();
277 };
279 class RegisteredPoint : public RegisteredWidget {
280 public:
281 RegisteredPoint();
282 ~RegisteredPoint();
283 void init (const Glib::ustring& label,
284 const Glib::ustring& tip,
285 const Glib::ustring& key,
286 Registry& wr,
287 Inkscape::XML::Node* repr_in,
288 SPDocument *doc_in);
289 inline void init ( const Glib::ustring& label,
290 const Glib::ustring& tip,
291 const Glib::ustring& key,
292 Registry& wr)
293 { init(label, tip, key, wr, NULL, NULL); };
295 Point* getPoint();
296 void setValue (double xval, double yval);
298 protected:
299 Point *_widget;
300 sigc::connection _value_x_changed_connection;
301 sigc::connection _value_y_changed_connection;
302 void on_value_changed();
303 };
305 class RegisteredRandom : public RegisteredWidget {
306 public:
307 RegisteredRandom();
308 ~RegisteredRandom();
309 void init (const Glib::ustring& label,
310 const Glib::ustring& tip,
311 const Glib::ustring& key,
312 Registry& wr,
313 Inkscape::XML::Node* repr_in,
314 SPDocument *doc_in);
315 inline void init ( const Glib::ustring& label,
316 const Glib::ustring& tip,
317 const Glib::ustring& key,
318 Registry& wr)
319 { init(label, tip, key, wr, NULL, NULL); };
321 Random* getR();
322 void setValue (double val, long startseed);
324 protected:
325 Random *_widget;
326 sigc::connection _value_changed_connection;
327 sigc::connection _reseeded_connection;
328 void on_value_changed();
329 };
331 } // namespace Widget
332 } // namespace UI
333 } // namespace Inkscape
335 #endif // INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
337 /*
338 Local Variables:
339 mode:c++
340 c-file-style:"stroustrup"
341 c-file-offsets:((innamespace . 0)(inline-open . 0))
342 indent-tabs-mode:nil
343 fill-column:99
344 End:
345 */
346 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :