1 /**
2 * \brief Abstraction for different style widget operands
3 *
4 * Copyright (C) 2007 MenTaLguY <mental@rydia.net>
5 *
6 * Released under GNU GPL. Read the file 'COPYING' for more information.
7 */
9 #ifndef SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H
10 #define SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H
12 #include "util/glib-list-iterators.h"
13 #include <boost/optional.hpp>
14 #include "libnr/nr-rect.h"
15 #include <2geom/rect.h>
16 #include "sp-item.h"
17 #include <sigc++/sigc++.h>
19 class SPDesktop;
20 class SPObject;
21 class SPCSSAttr;
22 class SPStyle;
24 namespace Inkscape {
25 class Selection;
26 }
28 namespace Inkscape {
29 namespace UI {
30 namespace Widget {
32 class StyleSubject {
33 public:
34 class Selection;
35 class CurrentLayer;
37 typedef Util::GSListConstIterator<SPObject *> iterator;
39 StyleSubject();
40 virtual ~StyleSubject();
42 void setDesktop(SPDesktop *desktop);
43 SPDesktop *getDesktop() const { return _desktop; }
45 virtual iterator begin() = 0;
46 virtual iterator end() { return iterator(NULL); }
47 virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0;
48 virtual int queryStyle(SPStyle *query, int property) = 0;
49 virtual void setCSS(SPCSSAttr *css) = 0;
51 sigc::connection connectChanged(sigc::signal<void>::slot_type slot) {
52 return _changed_signal.connect(slot);
53 }
55 protected:
56 virtual void _afterDesktopSwitch(SPDesktop */*desktop*/) {}
57 void _emitChanged() { _changed_signal.emit(); }
59 private:
60 sigc::signal<void> _changed_signal;
61 SPDesktop *_desktop;
62 };
64 class StyleSubject::Selection : public StyleSubject {
65 public:
66 Selection();
67 ~Selection();
69 virtual iterator begin();
70 virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
71 virtual int queryStyle(SPStyle *query, int property);
72 virtual void setCSS(SPCSSAttr *css);
74 protected:
75 virtual void _afterDesktopSwitch(SPDesktop *desktop);
77 private:
78 Inkscape::Selection *_getSelection() const;
80 sigc::connection _sel_changed;
81 sigc::connection _subsel_changed;
82 sigc::connection _sel_modified;
83 };
85 class StyleSubject::CurrentLayer : public StyleSubject {
86 public:
87 CurrentLayer();
88 ~CurrentLayer();
90 virtual iterator begin();
91 virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
92 virtual int queryStyle(SPStyle *query, int property);
93 virtual void setCSS(SPCSSAttr *css);
95 protected:
96 virtual void _afterDesktopSwitch(SPDesktop *desktop);
98 private:
99 SPObject *_getLayer() const;
100 void _setLayer(SPObject *layer);
101 GSList *_getLayerSList() const;
103 sigc::connection _layer_switched;
104 sigc::connection _layer_release;
105 sigc::connection _layer_modified;
106 mutable GSList _element;
107 };
109 }
110 }
111 }
113 #endif
115 /*
116 Local Variables:
117 mode:c++
118 c-file-style:"stroustrup"
119 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
120 indent-tabs-mode:nil
121 fill-column:99
122 End:
123 */
124 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :