Code

9f10f8ca864ac6394ced8fde2a7065574262a091
[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(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
43               bool default_value);
44 protected:
45     std::string _prefs_path;
46     std::string _attr;
47     bool _int_value;
48     void on_toggled();
49 };
51 class PrefRadioButton : public Gtk::RadioButton
52 {
53 public:
54     void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
55               int int_value, bool default_value, PrefRadioButton* group_member);
56     void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
57               const std::string& string_value, bool default_value, PrefRadioButton* group_member);
58     sigc::signal<void, bool> changed_signal;
59 protected:
60     std::string _prefs_path;
61     std::string _attr;
62     std::string _string_value;
63     int _value_type;
64     enum
65     {
66         VAL_INT,
67         VAL_STRING
68     };
69     int _int_value;
70     void on_toggled();
71 };
73 class PrefSpinButton : public Gtk::SpinButton
74 {
75 public:
76     void init(const std::string& prefs_path, const std::string& attr,
77               double lower, double upper, double step_increment, double page_increment,
78               double default_value, bool is_int, bool is_percent);
79 protected:
80     std::string _prefs_path;
81     std::string _attr;
82     bool _is_int;
83     bool _is_percent;
84     void on_value_changed();
85 };
87 class ZoomCorrRuler : public Gtk::DrawingArea {
88 public:
89     ZoomCorrRuler(int width = 100, int height = 20);
90     void set_size(int x, int y);
91     void set_unit_conversion(double conv) { _unitconv = conv; }
92     void set_cairo_context(Cairo::RefPtr<Cairo::Context> cr);
93     void redraw();
95     int width() { return _min_width + _border*2; }
97     static const double textsize;
98     static const double textpadding;
100 private:
101     bool on_expose_event(GdkEventExpose *event);
102     void draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval);
104     double _unitconv;
105     int _min_width;
106     int _height;
107     int _border;
108     int _drawing_width;
109 };
111 class ZoomCorrRulerSlider : public Gtk::VBox
113 public:
114     void init(int ruler_width, int ruler_height, double lower, double upper,
115               double step_increment, double page_increment, double default_value);
117 private:
118     void on_slider_value_changed();
119     void on_spinbutton_value_changed();
120     void on_unit_changed();
122     Gtk::SpinButton _sb;
123     UnitMenu        _unit;
124     Gtk::HScale     _slider;
125     ZoomCorrRuler   _ruler;
126     bool freeze; // used to block recursive updates of slider and spinbutton
127 };
129 class PrefCombo : public Gtk::ComboBoxText
131 public:
132     void init(const std::string& prefs_path, const std::string& attr,
133               Glib::ustring labels[], int values[], int num_items, int default_value);
134 protected:
135     std::string _prefs_path;
136     std::string _attr;
137     std::vector<int> _values;
138     void on_changed();
139 };
141 class PrefEntry : public Gtk::Entry
143 public:
144     void init(const std::string& prefs_path, const std::string& attr,
145             bool mask);
146 protected:
147     std::string _prefs_path;
148     std::string _attr;
149     void on_changed();
150 };
152 class PrefEntryButtonHBox : public Gtk::HBox
154 public:
155     void init(const std::string& prefs_path, const std::string& attr,
156             bool mask, gchar* default_string);
157 protected:
158     std::string _prefs_path;
159     std::string _attr;
160     gchar* _default_string;
161     Gtk::Button *relatedButton;
162     Gtk::Entry *relatedEntry;
163     void onRelatedEntryChangedCallback();
164     void onRelatedButtonClickedCallback();
165 };
167 class PrefFileButton : public Gtk::FileChooserButton
169 public:
170     void init(const std::string& prefs_path, const std::string& attr);
172 protected:
173     std::string _prefs_path;
174     std::string _attr;
175     void onFileChanged();
176 };
178 class PrefColorPicker : public ColorPicker
180 public:
181     PrefColorPicker() : ColorPicker("", "", 0, false) {};
182     virtual ~PrefColorPicker() {};
184     void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
185               guint32 default_rgba);
187 protected:
188     std::string _prefs_path;
189     std::string _attr;
190     virtual void on_changed (guint32 rgba);
191 };
193 class PrefUnit : public UnitMenu
195 public:
196     void init(const std::string& prefs_path, const std::string& attr);
197 protected:
198     std::string _prefs_path;
199     std::string _attr;
200     void on_changed();
201 };
203 class DialogPage : public Gtk::Table
205 public:
206     DialogPage();
207     void add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand = true);
208     void add_group_header(Glib::ustring name);
209     void set_tip(Gtk::Widget& widget, const Glib::ustring& tip);
210 protected:
211     Gtk::Tooltips _tooltips;
212 };
215 } // namespace Widget
216 } // namespace UI
217 } // namespace Inkscape
219 #endif //INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
221 /*
222   Local Variables:
223   mode:c++
224   c-file-style:"stroustrup"
225   c-file-offsets:((innamespace . 0)(inline-open . 0))
226   indent-tabs-mode:nil
227   fill-column:99
228   End:
229 */
230 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :