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"
21 class SPUnit;
22 class SPDocument;
24 namespace Gtk {
25 class HScale;
26 class RadioButton;
27 class SpinButton;
28 class ToggleButton;
29 }
31 namespace Inkscape {
32 namespace UI {
33 namespace Widget {
35 class ColorPicker;
36 class Registry;
37 class Scalar;
38 class ScalarUnit;
39 class UnitMenu;
40 class Point;
42 class RegisteredWidget {
43 public:
44 void set_undo_parameters(const unsigned int _event_type, Glib::ustring _event_description)
45 {
46 event_type = _event_type;
47 event_description = _event_description;
48 write_undo = true;
49 }
51 protected:
52 RegisteredWidget()
53 {
54 _wr = NULL;
55 repr = NULL;
56 doc = NULL;
57 write_undo = false;
58 }
60 void init_parent(const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
61 {
62 _wr = ≀
63 _key = key;
64 repr = repr_in;
65 doc = doc_in;
66 if (repr && !doc) // doc cannot be NULL when repr is not NULL
67 g_warning("Initialization of registered widget using defined repr but with doc==NULL");
68 }
70 void write_to_xml(const char * svgstr);
72 Registry * _wr;
73 Glib::ustring _key;
74 Inkscape::XML::Node * repr;
75 SPDocument * doc;
76 unsigned int event_type;
77 Glib::ustring event_description;
78 bool write_undo;
79 };
81 //#######################################################
83 class RegisteredCheckButton : public RegisteredWidget {
84 public:
85 RegisteredCheckButton();
86 ~RegisteredCheckButton();
87 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);
88 void setActive (bool);
90 Gtk::ToggleButton *_button;
91 std::list<Gtk::ToggleButton*> _slavebuttons;
93 // a slave button is only sensitive when the master button is active
94 // i.e. a slave button is greyed-out when the master button is not checked
96 void setSlaveButton(std::list<Gtk::ToggleButton*> btns) {
97 _slavebuttons = btns;
98 }
101 protected:
102 Gtk::Tooltips _tt;
103 sigc::connection _toggled_connection;
104 void on_toggled();
105 };
107 class RegisteredUnitMenu : public RegisteredWidget {
108 public:
109 RegisteredUnitMenu();
110 ~RegisteredUnitMenu();
111 void init ( const Glib::ustring& label,
112 const Glib::ustring& key,
113 Registry& wr,
114 Inkscape::XML::Node* repr_in,
115 SPDocument *doc_in);
116 inline void init ( const Glib::ustring& label,
117 const Glib::ustring& key,
118 Registry& wr)
119 { init(label, key, wr, NULL, NULL); };
121 void setUnit (const SPUnit*);
122 Gtk::Label *_label;
123 UnitMenu *_sel;
124 sigc::connection _changed_connection;
126 protected:
127 void on_changed();
128 };
130 class RegisteredScalarUnit : public RegisteredWidget {
131 public:
132 RegisteredScalarUnit();
133 ~RegisteredScalarUnit();
134 void init (const Glib::ustring& label,
135 const Glib::ustring& tip,
136 const Glib::ustring& key,
137 const RegisteredUnitMenu &rum,
138 Registry& wr,
139 Inkscape::XML::Node* repr_in,
140 SPDocument *doc_in);
141 inline void init ( const Glib::ustring& label,
142 const Glib::ustring& tip,
143 const Glib::ustring& key,
144 const RegisteredUnitMenu &rum,
145 Registry& wr)
146 { init(label, tip, key, rum, wr, NULL, NULL); };
148 ScalarUnit* getSU();
149 void setValue (double);
151 protected:
152 ScalarUnit *_widget;
153 sigc::connection _value_changed_connection;
154 UnitMenu *_um;
155 void on_value_changed();
156 };
158 class RegisteredScalar : public RegisteredWidget {
159 public:
160 RegisteredScalar();
161 ~RegisteredScalar();
162 void init (const Glib::ustring& label,
163 const Glib::ustring& tip,
164 const Glib::ustring& key,
165 Registry& wr,
166 Inkscape::XML::Node* repr_in,
167 SPDocument *doc_in);
168 inline void init ( const Glib::ustring& label,
169 const Glib::ustring& tip,
170 const Glib::ustring& key,
171 Registry& wr)
172 { init(label, tip, key, wr, NULL, NULL); };
174 Scalar* getS();
175 void setValue (double);
177 protected:
178 Scalar *_widget;
179 sigc::connection _value_changed_connection;
180 void on_value_changed();
181 };
183 class RegisteredColorPicker : public RegisteredWidget {
184 public:
185 RegisteredColorPicker();
186 ~RegisteredColorPicker();
187 void init (const Glib::ustring& label,
188 const Glib::ustring& title,
189 const Glib::ustring& tip,
190 const Glib::ustring& ckey,
191 const Glib::ustring& akey,
192 Registry& wr,
193 Inkscape::XML::Node* repr_in,
194 SPDocument *doc_in);
195 inline void init ( const Glib::ustring& label,
196 const Glib::ustring& title,
197 const Glib::ustring& tip,
198 const Glib::ustring& ckey,
199 const Glib::ustring& akey,
200 Registry& wr)
201 { init(label, title, tip, ckey, akey, wr, NULL, NULL); };
203 void setRgba32 (guint32);
204 void closeWindow();
206 Gtk::Label *_label;
207 ColorPicker *_cp;
209 protected:
210 Glib::ustring _ckey, _akey;
211 void on_changed (guint32);
212 sigc::connection _changed_connection;
213 };
215 class RegisteredSuffixedInteger : public RegisteredWidget {
216 public:
217 RegisteredSuffixedInteger();
218 ~RegisteredSuffixedInteger();
219 void init (const Glib::ustring& label1,
220 const Glib::ustring& label2,
221 const Glib::ustring& key,
222 Registry& wr,
223 Inkscape::XML::Node* repr_in,
224 SPDocument *doc_in);
225 inline void init ( const Glib::ustring& label1,
226 const Glib::ustring& label2,
227 const Glib::ustring& key,
228 Registry& wr)
229 { init(label1, label2, key, wr, NULL, NULL); };
231 void setValue (int);
232 Gtk::Label *_label;
233 Gtk::HBox _hbox;
235 protected:
236 Gtk::SpinButton *_sb;
237 Gtk::Adjustment _adj;
238 Gtk::Label *_suffix;
239 sigc::connection _changed_connection;
240 void on_value_changed();
241 };
243 class RegisteredRadioButtonPair : public RegisteredWidget {
244 public:
245 RegisteredRadioButtonPair();
246 ~RegisteredRadioButtonPair();
247 void init (const Glib::ustring& label,
248 const Glib::ustring& label1,
249 const Glib::ustring& label2,
250 const Glib::ustring& tip1,
251 const Glib::ustring& tip2,
252 const Glib::ustring& key,
253 Registry& wr,
254 Inkscape::XML::Node* repr_in,
255 SPDocument *doc_in);
256 inline void init ( const Glib::ustring& label,
257 const Glib::ustring& label1,
258 const Glib::ustring& label2,
259 const Glib::ustring& tip1,
260 const Glib::ustring& tip2,
261 const Glib::ustring& key,
262 Registry& wr)
263 { init(label, label1, label2, tip1, tip2, key, wr, NULL, NULL); };
265 void setValue (bool second);
266 Gtk::HBox *_hbox;
268 protected:
269 Gtk::RadioButton *_rb1, *_rb2;
270 Gtk::Tooltips _tt;
271 sigc::connection _changed_connection;
272 void on_value_changed();
273 };
275 class RegisteredPoint : public RegisteredWidget {
276 public:
277 RegisteredPoint();
278 ~RegisteredPoint();
279 void init (const Glib::ustring& label,
280 const Glib::ustring& tip,
281 const Glib::ustring& key,
282 Registry& wr,
283 Inkscape::XML::Node* repr_in,
284 SPDocument *doc_in);
285 inline void init ( const Glib::ustring& label,
286 const Glib::ustring& tip,
287 const Glib::ustring& key,
288 Registry& wr)
289 { init(label, tip, key, wr, NULL, NULL); };
291 Point* getPoint();
292 void setValue (double xval, double yval);
294 protected:
295 Point *_widget;
296 sigc::connection _value_x_changed_connection;
297 sigc::connection _value_y_changed_connection;
298 void on_value_changed();
299 };
301 } // namespace Widget
302 } // namespace UI
303 } // namespace Inkscape
305 #endif // INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
307 /*
308 Local Variables:
309 mode:c++
310 c-file-style:"stroustrup"
311 c-file-offsets:((innamespace . 0)(inline-open . 0))
312 indent-tabs-mode:nil
313 fill-column:99
314 End:
315 */
316 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :