Code

fix by Preben S for LP bug 389780, flatness
[inkscape.git] / src / ui / widget / preferences-widget.h
1 /**
2  * \brief Inkscape Preferences dialog
3  *
4  * Authors:
5  *   Marco Scholten
6  *   Bruno Dilly <bruno.dilly@gmail.com>
7  *
8  * Copyright (C) 2004, 2006, 2007  Authors
9  *
10  * Released under GNU GPL.  Read the file 'COPYING' for more information.
11  */
13 #ifndef INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
14 #define INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
16 #include <iostream>
17 #include <vector>
18 #include <gtkmm/table.h>
19 #include <gtkmm/comboboxtext.h>
20 #include <gtkmm/spinbutton.h>
21 #include <gtkmm/tooltips.h>
22 #include <gtkmm/treeview.h>
23 #include <gtkmm/radiobutton.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/scale.h>
26 #include <gtkmm/drawingarea.h>
27 #include <gtkmm/frame.h>
28 #include <gtkmm/filechooserbutton.h>
29 #include <sigc++/sigc++.h>
30 #include <glibmm/i18n.h>
32 #include "ui/widget/color-picker.h"
33 #include "ui/widget/unit-menu.h"
35 namespace Inkscape {
36 namespace UI {
37 namespace Widget {
39 class PrefCheckButton : public Gtk::CheckButton
40 {
41 public:
42     void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
43               bool default_value);
44 protected:
45     Glib::ustring _prefs_path;
46     void on_toggled();
47 };
49 class PrefRadioButton : public Gtk::RadioButton
50 {
51 public:
52     void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
53               int int_value, bool default_value, PrefRadioButton* group_member);
54     void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
55               Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member);
56     sigc::signal<void, bool> changed_signal;
57 protected:
58     Glib::ustring _prefs_path;
59     Glib::ustring _string_value;
60     int _value_type;
61     enum
62     {
63         VAL_INT,
64         VAL_STRING
65     };
66     int _int_value;
67     void on_toggled();
68 };
70 class PrefSpinButton : public Gtk::SpinButton
71 {
72 public:
73     void init(Glib::ustring const &prefs_path,
74               double lower, double upper, double step_increment, double page_increment,
75               double default_value, bool is_int, bool is_percent);
76 protected:
77     Glib::ustring _prefs_path;
78     bool _is_int;
79     bool _is_percent;
80     void on_value_changed();
81 };
83 class ZoomCorrRuler : public Gtk::DrawingArea {
84 public:
85     ZoomCorrRuler(int width = 100, int height = 20);
86     void set_size(int x, int y);
87     void set_unit_conversion(double conv) { _unitconv = conv; }
88     void set_cairo_context(Cairo::RefPtr<Cairo::Context> cr);
89     void redraw();
91     int width() { return _min_width + _border*2; }
93     static const double textsize;
94     static const double textpadding;
96 private:
97     bool on_expose_event(GdkEventExpose *event);
98     void draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval);
100     double _unitconv;
101     int _min_width;
102     int _height;
103     int _border;
104     int _drawing_width;
105 };
107 class ZoomCorrRulerSlider : public Gtk::VBox
109 public:
110     void init(int ruler_width, int ruler_height, double lower, double upper,
111               double step_increment, double page_increment, double default_value);
113 private:
114     void on_slider_value_changed();
115     void on_spinbutton_value_changed();
116     void on_unit_changed();
118     Gtk::SpinButton _sb;
119     UnitMenu        _unit;
120     Gtk::HScale     _slider;
121     ZoomCorrRuler   _ruler;
122     bool freeze; // used to block recursive updates of slider and spinbutton
123 };
125 class PrefSlider : public Gtk::HBox
127 public:
128     void init(Glib::ustring const &prefs_path,
129                   double lower, double upper, double step_increment, double page_increment, double default_value, int digits);
131 private:
132     void on_slider_value_changed();
133     void on_spinbutton_value_changed();
134     
135     Glib::ustring _prefs_path;
136     Gtk::SpinButton _sb;
137     Gtk::HScale     _slider;
138     bool freeze; // used to block recursive updates of slider and spinbutton
139 };
142 class PrefCombo : public Gtk::ComboBoxText
144 public:
145     void init(Glib::ustring const &prefs_path,
146               Glib::ustring labels[], int values[], int num_items, int default_value);
147     void init(Glib::ustring const &prefs_path,
148               Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value);
149 protected:
150     Glib::ustring _prefs_path;
151     std::vector<int> _values;
152     std::vector<Glib::ustring> _ustr_values;    ///< string key values used optionally instead of numeric _values
153     void on_changed();
154 };
156 class PrefEntry : public Gtk::Entry
158 public:
159     void init(Glib::ustring const &prefs_path, bool mask);
160 protected:
161     Glib::ustring _prefs_path;
162     void on_changed();
163 };
165 class PrefEntryButtonHBox : public Gtk::HBox
167 public:
168     void init(Glib::ustring const &prefs_path,
169             bool mask, Glib::ustring const &default_string);
170 protected:
171     Glib::ustring _prefs_path;
172     Glib::ustring _default_string;
173     Gtk::Button *relatedButton;
174     Gtk::Entry *relatedEntry;
175     void onRelatedEntryChangedCallback();
176     void onRelatedButtonClickedCallback();
177 };
179 class PrefFileButton : public Gtk::FileChooserButton
181 public:
182     void init(Glib::ustring const &prefs_path);
184 protected:
185     Glib::ustring _prefs_path;
186     void onFileChanged();
187 };
189 class PrefColorPicker : public ColorPicker
191 public:
192     PrefColorPicker() : ColorPicker("", "", 0, false) {};
193     virtual ~PrefColorPicker() {};
195     void init(Glib::ustring const &abel, Glib::ustring const &prefs_path,
196               guint32 default_rgba);
198 protected:
199     Glib::ustring _prefs_path;
200     virtual void on_changed (guint32 rgba);
201 };
203 class PrefUnit : public UnitMenu
205 public:
206     void init(Glib::ustring const &prefs_path);
207 protected:
208     Glib::ustring _prefs_path;
209     void on_changed();
210 };
212 class DialogPage : public Gtk::Table
214 public:
215     DialogPage();
216     void add_line(bool indent, Glib::ustring const &label, Gtk::Widget& widget, Glib::ustring const &suffix, Glib::ustring const &tip, bool expand = true);
217     void add_group_header(Glib::ustring name);
218     void set_tip(Gtk::Widget &widget, Glib::ustring const &tip);
219 protected:
220     Gtk::Tooltips _tooltips;
221 };
224 } // namespace Widget
225 } // namespace UI
226 } // namespace Inkscape
228 #endif //INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
230 /*
231   Local Variables:
232   mode:c++
233   c-file-style:"stroustrup"
234   c-file-offsets:((innamespace . 0)(inline-open . 0))
235   indent-tabs-mode:nil
236   fill-column:99
237   End:
238 */
239 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :