Code

Cleanup of device internal handling and API.
[inkscape.git] / src / ui / dialog / fill-and-stroke.cpp
1 /** @file
2  * @brief Fill and Stroke dialog - implementation
3  *
4  * Based on the old sp_object_properties_dialog.
5  */
6 /* Authors:
7  *   Bryce W. Harrington <bryce@bryceharrington.org>
8  *   Gustav Broberg <broberg@kth.se>
9  *   Jon A. Cruz <jon@joncruz.org>
10  *
11  * Copyright (C) 2004--2007 Authors
12  * Copyright (C) 2010 Jon A. Cruz
13  *
14  * Released under GNU GPL.  Read the file 'COPYING' for more information.
15  */
17 #include "desktop-handles.h"
18 #include "desktop-style.h"
19 #include "document.h"
20 #include "fill-and-stroke.h"
21 #include "filter-chemistry.h"
22 #include "inkscape.h"
23 #include "selection.h"
24 #include "style.h"
25 #include "svg/css-ostringstream.h"
26 #include "ui/icon-names.h"
27 #include "verbs.h"
28 #include "widgets/fill-style.h"
29 #include "widgets/icon.h"
30 #include "widgets/paint-selector.h"
31 #include "widgets/stroke-style.h"
32 #include "xml/repr.h"
34 #include "ui/view/view-widget.h"
36 namespace Inkscape {
37 namespace UI {
38 namespace Dialog {
40 FillAndStroke::FillAndStroke()
41     : UI::Widget::Panel ("", "/dialogs/fillstroke", SP_VERB_DIALOG_FILL_STROKE),
42       _page_fill(1, 1, true, true),
43       _page_stroke_paint(1, 1, true, true),
44       _page_stroke_style(1, 1, true, true),
45       _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke", UI::Widget::SimpleFilterModifier::BLUR),
46       deskTrack(),
47       targetDesktop(0),
48       fillWdgt(0),
49       strokeWdgt(0),
50       desktopChangeConn()
51 {
52     Gtk::Box *contents = _getContents();
53     contents->set_spacing(0);
55     contents->pack_start(_notebook, true, true);
57     _notebook.append_page(_page_fill, _createPageTabLabel(_("Fill"), INKSCAPE_ICON_OBJECT_FILL));
58     _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON_OBJECT_STROKE));
59     _notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON_OBJECT_STROKE_STYLE));
61     _layoutPageFill();
62     _layoutPageStrokePaint();
63     _layoutPageStrokeStyle();
65     contents->pack_start(_composite_settings, false, false, 0);
67     show_all_children();
69     _composite_settings.setSubject(&_subject);
71     // Connect this up last
72     desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &FillAndStroke::setTargetDesktop) );
73     deskTrack.connect(GTK_WIDGET(gobj()));
74 }
76 FillAndStroke::~FillAndStroke()
77 {
78     _composite_settings.setSubject(NULL);
80     desktopChangeConn.disconnect();
81     deskTrack.disconnect();
82 }
84 void FillAndStroke::setDesktop(SPDesktop *desktop)
85 {
86     Panel::setDesktop(desktop);
87     deskTrack.setBase(desktop);
88 }
90 void FillAndStroke::setTargetDesktop(SPDesktop *desktop)
91 {
92     if (targetDesktop != desktop) {
93         targetDesktop = desktop;
94         if (fillWdgt) {
95             sp_fill_style_widget_set_desktop(fillWdgt, desktop);
96         }
97         if (strokeWdgt) {
98             sp_stroke_style_widget_set_desktop(strokeWdgt, desktop);
99         }
100     }
103 void
104 FillAndStroke::_layoutPageFill()
106     fillWdgt = manage(sp_fill_style_widget_new());
107     _page_fill.table().attach(*fillWdgt, 0, 1, 0, 1);
110 void
111 FillAndStroke::_layoutPageStrokePaint()
113     strokeWdgt = manage(sp_stroke_style_paint_widget_new());
114     _page_stroke_paint.table().attach(*strokeWdgt, 0, 1, 0, 1);
117 void
118 FillAndStroke::_layoutPageStrokeStyle()
120     //Gtk::Widget *ssl = manage(Glib::wrap(sp_stroke_style_line_widget_new()));
121     //Gtk::Widget *ssl = static_cast<Gtk::Widget *>(sp_stroke_style_line_widget_new());
122     Gtk::Widget *ssl = sp_stroke_style_line_widget_new();
123     _page_stroke_style.table().attach(*ssl, 0, 1, 0, 1);
126 void
127 FillAndStroke::showPageFill()
129     present();
130     _notebook.set_current_page(0);
133 void
134 FillAndStroke::showPageStrokePaint()
136     present();
137     _notebook.set_current_page(1);
140 void
141 FillAndStroke::showPageStrokeStyle()
143     present();
144     _notebook.set_current_page(2);
147 Gtk::HBox&
148 FillAndStroke::_createPageTabLabel(const Glib::ustring& label, const char *label_image)
150     Gtk::HBox *_tab_label_box = manage(new Gtk::HBox(false, 0));
151     _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION,
152                                                        label_image)));
154     Gtk::Label *_tab_label = manage(new Gtk::Label(label, true));
155     _tab_label_box->pack_start(*_tab_label);
156     _tab_label_box->show_all();
158     return *_tab_label_box;
161 } // namespace Dialog
162 } // namespace UI
163 } // namespace Inkscape
165 /*
166   Local Variables:
167   mode:c++
168   c-file-style:"stroustrup"
169   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
170   indent-tabs-mode:nil
171   fill-column:99
172   End:
173 */
174 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :