f9c54497603b4b2763452569ec97f55e150658c9
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 "libnr/nr-maybe.h"
14 #include "libnr/nr-rect.h"
15 #include "sp-item.h"
16 #include <sigc++/sigc++.h>
18 class SPDesktop;
19 class SPObject;
20 class SPCSSAttr;
21 class SPStyle;
23 namespace Inkscape {
24 class Selection;
25 }
27 namespace Inkscape {
28 namespace UI {
29 namespace Widget {
31 class StyleSubject {
32 public:
33 class Selection;
34 class CurrentLayer;
36 typedef Util::GSListConstIterator<SPObject *> iterator;
38 StyleSubject();
39 virtual ~StyleSubject();
41 void setDesktop(SPDesktop *desktop);
42 SPDesktop *getDesktop() const { return _desktop; }
44 virtual iterator begin() = 0;
45 virtual iterator end() { return iterator(NULL); }
46 virtual NR::Maybe<NR::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0;
47 virtual int queryStyle(SPStyle *query, int property) = 0;
48 virtual void setCSS(SPCSSAttr *css) = 0;
50 sigc::connection connectChanged(sigc::signal<void>::slot_type slot) {
51 return _changed_signal.connect(slot);
52 }
54 protected:
55 virtual void _afterDesktopSwitch(SPDesktop */*desktop*/) {}
56 void _emitChanged() { _changed_signal.emit(); }
58 private:
59 sigc::signal<void> _changed_signal;
60 SPDesktop *_desktop;
61 };
63 class StyleSubject::Selection : public StyleSubject {
64 public:
65 Selection();
66 ~Selection();
68 virtual iterator begin();
69 virtual NR::Maybe<NR::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
70 virtual int queryStyle(SPStyle *query, int property);
71 virtual void setCSS(SPCSSAttr *css);
73 protected:
74 virtual void _afterDesktopSwitch(SPDesktop *desktop);
76 private:
77 Inkscape::Selection *_getSelection() const;
79 sigc::connection _sel_changed;
80 sigc::connection _subsel_changed;
81 sigc::connection _sel_modified;
82 };
84 class StyleSubject::CurrentLayer : public StyleSubject {
85 public:
86 CurrentLayer();
87 ~CurrentLayer();
89 virtual iterator begin();
90 virtual NR::Maybe<NR::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
91 virtual int queryStyle(SPStyle *query, int property);
92 virtual void setCSS(SPCSSAttr *css);
94 protected:
95 virtual void _afterDesktopSwitch(SPDesktop *desktop);
97 private:
98 SPObject *_getLayer() const;
99 void _setLayer(SPObject *layer);
100 GSList *_getLayerSList() const;
102 sigc::connection _layer_switched;
103 sigc::connection _layer_release;
104 sigc::connection _layer_modified;
105 mutable GSList _element;
106 };
108 }
109 }
110 }
112 #endif
114 /*
115 Local Variables:
116 mode:c++
117 c-file-style:"stroustrup"
118 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
119 indent-tabs-mode:nil
120 fill-column:99
121 End:
122 */
123 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :