Code

Fixes for transient dialogs in win32.
[inkscape.git] / src / ui / widget / registered-widget.h
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;
41 class Random;
43 class RegisteredWidget {
44 public:
45     void set_undo_parameters(const unsigned int _event_type, Glib::ustring _event_description)
46     {
47         event_type = _event_type;
48         event_description = _event_description;
49         write_undo = true;
50     }
52 protected:
53     RegisteredWidget()
54     {
55         _wr = NULL;
56         repr = NULL;
57         doc = NULL;
58         write_undo = false;
59     }
61     void init_parent(const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
62     {
63         _wr = &wr;
64         _key = key;
65         repr = repr_in;
66         doc = doc_in;
67         if (repr && !doc)  // doc cannot be NULL when repr is not NULL
68             g_warning("Initialization of registered widget using defined repr but with doc==NULL");
69     }
71     void write_to_xml(const char * svgstr);
73     Registry * _wr;
74     Glib::ustring _key;
75     Inkscape::XML::Node * repr;
76     SPDocument * doc;
77     unsigned int event_type;
78     Glib::ustring event_description;
79     bool write_undo;
80 };
82 //#######################################################
84 class RegisteredCheckButton : public RegisteredWidget {
85 public:
86     RegisteredCheckButton();
87     ~RegisteredCheckButton();
88     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);
89     void setActive (bool);
91     Gtk::ToggleButton *_button;
92     std::list<Gtk::ToggleButton*> _slavebuttons;
93     
94     // a slave button is only sensitive when the master button is active
95     // i.e. a slave button is greyed-out when the master button is not checked
96     
97     void setSlaveButton(std::list<Gtk::ToggleButton*> btns) {
98         _slavebuttons = btns;
99     }
100     
102 protected:
103     Gtk::Tooltips     _tt;
104     sigc::connection  _toggled_connection;
105     void on_toggled();
106 };
108 class RegisteredUnitMenu : public RegisteredWidget {
109 public:
110     RegisteredUnitMenu();
111     ~RegisteredUnitMenu();
112     void init ( const Glib::ustring& label,
113                 const Glib::ustring& key,
114                 Registry& wr,
115                 Inkscape::XML::Node* repr_in,
116                 SPDocument *doc_in);
117     inline void init ( const Glib::ustring& label, 
118                        const Glib::ustring& key, 
119                        Registry& wr)
120         { init(label, key, wr, NULL, NULL); };
122     void setUnit (const SPUnit*);
123     Gtk::Label   *_label;
124     UnitMenu     *_sel;
125     sigc::connection _changed_connection;
127 protected:
128     void on_changed();
129 };
131 class RegisteredScalarUnit : public RegisteredWidget {
132 public:
133     RegisteredScalarUnit();
134     ~RegisteredScalarUnit();
135     void init (const Glib::ustring& label, 
136             const Glib::ustring& tip, 
137             const Glib::ustring& key, 
138             const RegisteredUnitMenu &rum,
139             Registry& wr,
140             Inkscape::XML::Node* repr_in,
141             SPDocument *doc_in);
142     inline void init ( const Glib::ustring& label, 
143                        const Glib::ustring& tip, 
144                        const Glib::ustring& key, 
145                        const RegisteredUnitMenu &rum,
146                        Registry& wr)
147         { init(label, tip, key, rum, wr, NULL, NULL); };
149     ScalarUnit* getSU();
150     void setValue (double);
152 protected:
153     ScalarUnit   *_widget;
154     sigc::connection  _value_changed_connection;
155     UnitMenu         *_um;
156     void on_value_changed();
157 };
159 class RegisteredScalar : public RegisteredWidget {
160 public:
161     RegisteredScalar();
162     ~RegisteredScalar();
163     void init (const Glib::ustring& label, 
164             const Glib::ustring& tip, 
165             const Glib::ustring& key, 
166             Registry& wr,
167             Inkscape::XML::Node* repr_in,
168             SPDocument *doc_in);
169     inline void init ( const Glib::ustring& label, 
170                        const Glib::ustring& tip, 
171                        const Glib::ustring& key, 
172                        Registry& wr)
173         { init(label, tip, key, wr, NULL, NULL); };
175     Scalar* getS();
176     void setValue (double);
178 protected:
179     Scalar   *_widget;
180     sigc::connection  _value_changed_connection;
181     void on_value_changed();
182 };
184 class RegisteredColorPicker : public RegisteredWidget {
185 public:
186     RegisteredColorPicker();
187     ~RegisteredColorPicker();
188     void init (const Glib::ustring& label, 
189             const Glib::ustring& title, 
190             const Glib::ustring& tip, 
191             const Glib::ustring& ckey, 
192             const Glib::ustring& akey,
193             Registry& wr,
194             Inkscape::XML::Node* repr_in,
195             SPDocument *doc_in);
196     inline void init ( const Glib::ustring& label, 
197                        const Glib::ustring& title, 
198                        const Glib::ustring& tip, 
199                        const Glib::ustring& ckey, 
200                        const Glib::ustring& akey, 
201                        Registry& wr)
202         { init(label, title, tip, ckey, akey, wr, NULL, NULL); };
204     void setRgba32 (guint32);
205     void closeWindow();
207     Gtk::Label *_label;
208     ColorPicker *_cp;
210 protected:
211     Glib::ustring _ckey, _akey;
212     void on_changed (guint32);
213     sigc::connection _changed_connection;
214 };
216 class RegisteredSuffixedInteger : public RegisteredWidget {
217 public:
218     RegisteredSuffixedInteger();
219     ~RegisteredSuffixedInteger();
220     void init (const Glib::ustring& label1, 
221                const Glib::ustring& label2, 
222                const Glib::ustring& key,
223                Registry& wr,
224                Inkscape::XML::Node* repr_in,
225                SPDocument *doc_in);
226     inline void init ( const Glib::ustring& label1, 
227                        const Glib::ustring& label2, 
228                        const Glib::ustring& key, 
229                        Registry& wr)
230         { init(label1, label2, key, wr, NULL, NULL); };
232     void setValue (int);
233     Gtk::Label *_label;
234     Gtk::HBox _hbox;
236 protected:
237     Gtk::SpinButton *_sb;
238     Gtk::Adjustment _adj;
239     Gtk::Label      *_suffix;
240     sigc::connection _changed_connection;
241     void on_value_changed();
242 };
244 class RegisteredRadioButtonPair : public RegisteredWidget {
245 public:
246     RegisteredRadioButtonPair();
247     ~RegisteredRadioButtonPair();
248     void init (const Glib::ustring& label, 
249                const Glib::ustring& label1, 
250                const Glib::ustring& label2, 
251                const Glib::ustring& tip1, 
252                const Glib::ustring& tip2, 
253                const Glib::ustring& key,
254                Registry& wr,
255                Inkscape::XML::Node* repr_in,
256                SPDocument *doc_in);
257     inline void init ( const Glib::ustring& label, 
258                        const Glib::ustring& label1, 
259                        const Glib::ustring& label2, 
260                        const Glib::ustring& tip1, 
261                        const Glib::ustring& tip2, 
262                        const Glib::ustring& key, 
263                        Registry& wr)
264         { init(label, label1, label2, tip1, tip2, key, wr, NULL, NULL); };
266     void setValue (bool second);
267     Gtk::HBox *_hbox;
269 protected:
270     Gtk::RadioButton *_rb1, *_rb2;
271     Gtk::Tooltips     _tt;
272     sigc::connection _changed_connection;
273     void on_value_changed();
274 };
276 class RegisteredPoint : public RegisteredWidget {
277 public:
278     RegisteredPoint();
279     ~RegisteredPoint();
280     void init (const Glib::ustring& label, 
281                const Glib::ustring& tip, 
282                const Glib::ustring& key, 
283                Registry& wr,
284                Inkscape::XML::Node* repr_in,
285                SPDocument *doc_in);
286     inline void init ( const Glib::ustring& label, 
287                        const Glib::ustring& tip, 
288                        const Glib::ustring& key, 
289                        Registry& wr)
290         { init(label, tip, key, wr, NULL, NULL); };
292     Point* getPoint();
293     void setValue (double xval, double yval);
295 protected:
296     Point   *_widget;
297     sigc::connection  _value_x_changed_connection;
298     sigc::connection  _value_y_changed_connection;
299     void on_value_changed();
300 };
302 class RegisteredRandom : public RegisteredWidget {
303 public:
304     RegisteredRandom();
305     ~RegisteredRandom();
306     void init (const Glib::ustring& label, 
307             const Glib::ustring& tip, 
308             const Glib::ustring& key, 
309             Registry& wr,
310             Inkscape::XML::Node* repr_in,
311             SPDocument *doc_in);
312     inline void init ( const Glib::ustring& label, 
313                        const Glib::ustring& tip, 
314                        const Glib::ustring& key, 
315                        Registry& wr)
316         { init(label, tip, key, wr, NULL, NULL); };
318     Random* getR();
319     void setValue (double val, long startseed);
321 protected:
322     Random   *_widget;
323     sigc::connection  _value_changed_connection;
324     sigc::connection  _reseeded_connection;
325     void on_value_changed();
326 };
328 } // namespace Widget
329 } // namespace UI
330 } // namespace Inkscape
332 #endif // INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
334 /*
335   Local Variables:
336   mode:c++
337   c-file-style:"stroustrup"
338   c-file-offsets:((innamespace . 0)(inline-open . 0))
339   indent-tabs-mode:nil
340   fill-column:99
341   End:
342 */
343 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :