dbc319c1ad0634d58793561a7a2ae546f63e34a7
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
108 {
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 PrefCombo : public Gtk::ComboBoxText
126 {
127 public:
128 void init(Glib::ustring const &prefs_path,
129 Glib::ustring labels[], int values[], int num_items, int default_value);
130 protected:
131 Glib::ustring _prefs_path;
132 std::vector<int> _values;
133 void on_changed();
134 };
136 class PrefEntry : public Gtk::Entry
137 {
138 public:
139 void init(Glib::ustring const &prefs_path, bool mask);
140 protected:
141 Glib::ustring _prefs_path;
142 void on_changed();
143 };
145 class PrefEntryButtonHBox : public Gtk::HBox
146 {
147 public:
148 void init(Glib::ustring const &prefs_path,
149 bool mask, Glib::ustring const &default_string);
150 protected:
151 Glib::ustring _prefs_path;
152 Glib::ustring _default_string;
153 Gtk::Button *relatedButton;
154 Gtk::Entry *relatedEntry;
155 void onRelatedEntryChangedCallback();
156 void onRelatedButtonClickedCallback();
157 };
159 class PrefFileButton : public Gtk::FileChooserButton
160 {
161 public:
162 void init(Glib::ustring const &prefs_path);
164 protected:
165 Glib::ustring _prefs_path;
166 void onFileChanged();
167 };
169 class PrefColorPicker : public ColorPicker
170 {
171 public:
172 PrefColorPicker() : ColorPicker("", "", 0, false) {};
173 virtual ~PrefColorPicker() {};
175 void init(Glib::ustring const &abel, Glib::ustring const &prefs_path,
176 guint32 default_rgba);
178 protected:
179 Glib::ustring _prefs_path;
180 virtual void on_changed (guint32 rgba);
181 };
183 class PrefUnit : public UnitMenu
184 {
185 public:
186 void init(Glib::ustring const &prefs_path);
187 protected:
188 Glib::ustring _prefs_path;
189 void on_changed();
190 };
192 class DialogPage : public Gtk::Table
193 {
194 public:
195 DialogPage();
196 void add_line(bool indent, Glib::ustring const &label, Gtk::Widget& widget, Glib::ustring const &suffix, Glib::ustring const &tip, bool expand = true);
197 void add_group_header(Glib::ustring name);
198 void set_tip(Gtk::Widget &widget, Glib::ustring const &tip);
199 protected:
200 Gtk::Tooltips _tooltips;
201 };
204 } // namespace Widget
205 } // namespace UI
206 } // namespace Inkscape
208 #endif //INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
210 /*
211 Local Variables:
212 mode:c++
213 c-file-style:"stroustrup"
214 c-file-offsets:((innamespace . 0)(inline-open . 0))
215 indent-tabs-mode:nil
216 fill-column:99
217 End:
218 */
219 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :