diff options
| author | MenTaLguY <mental@rydia.net> | 2008-01-01 04:40:11 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2008-01-01 04:40:11 +0000 |
| commit | dbe58d32dd09f976f41badfb80cd31f9656e5af5 (patch) | |
| tree | 706dfc0cf4f3a0054c157194cdc008b7b4a462b6 /src/ui/widget/style-subject.h | |
| parent | factor filter and opacity controls into separate metawidget (diff) | |
| download | inkscape-dbe58d32dd09f976f41badfb80cd31f9656e5af5.tar.gz inkscape-dbe58d32dd09f976f41badfb80cd31f9656e5af5.zip | |
abstraction for style widget subjects
(bzr r4353)
Diffstat (limited to 'src/ui/widget/style-subject.h')
| -rw-r--r-- | src/ui/widget/style-subject.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h new file mode 100644 index 000000000..07ab64ab6 --- /dev/null +++ b/src/ui/widget/style-subject.h @@ -0,0 +1,123 @@ +/** + * \brief Abstraction for different style widget operands + * + * Copyright (C) 2007 MenTaLguY <mental@rydia.net> + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H +#define SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H + +#include "util/glib-list-iterators.h" +#include "libnr/nr-maybe.h" +#include "libnr/nr-rect.h" +#include "sp-item.h" +#include <sigc++/sigc++.h> + +class SPDesktop; +class SPObject; +class SPCSSAttr; +class SPStyle; + +namespace Inkscape { +class Selection; +} + +namespace Inkscape { +namespace UI { +namespace Widget { + +class StyleSubject { +public: + class Selection; + class CurrentLayer; + + typedef Util::GSListConstIterator<SPObject *> iterator; + + StyleSubject(); + virtual ~StyleSubject(); + + void setDesktop(SPDesktop *desktop); + SPDesktop *getDesktop() const { return _desktop; } + + virtual iterator begin() = 0; + virtual iterator end() { return iterator(NULL); } + virtual NR::Maybe<NR::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0; + virtual int queryStyle(SPStyle *query, int property) = 0; + virtual void setCSS(SPCSSAttr *css) = 0; + + sigc::connection connectChanged(sigc::signal<void>::slot_type slot) { + return _changed_signal.connect(slot); + } + +protected: + virtual void _afterDesktopSwitch(SPDesktop *desktop) {} + void _emitChanged() { _changed_signal.emit(); } + +private: + sigc::signal<void> _changed_signal; + SPDesktop *_desktop; +}; + +class StyleSubject::Selection : public StyleSubject { +public: + Selection(); + ~Selection(); + + virtual iterator begin(); + virtual NR::Maybe<NR::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + virtual int queryStyle(SPStyle *query, int property); + virtual void setCSS(SPCSSAttr *css); + +protected: + virtual void _afterDesktopSwitch(SPDesktop *desktop); + +private: + Inkscape::Selection *_getSelection() const; + + sigc::connection _sel_changed; + sigc::connection _subsel_changed; + sigc::connection _sel_modified; +}; + +class StyleSubject::CurrentLayer : public StyleSubject { +public: + CurrentLayer(); + ~CurrentLayer(); + + virtual iterator begin(); + virtual NR::Maybe<NR::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + virtual int queryStyle(SPStyle *query, int property); + virtual void setCSS(SPCSSAttr *css); + +protected: + virtual void _afterDesktopSwitch(SPDesktop *desktop); + +private: + SPObject *_getLayer() const; + void _setLayer(SPObject *layer); + GSList *_getLayerSList() const; + + sigc::connection _layer_switched; + sigc::connection _layer_release; + sigc::connection _layer_modified; + mutable GSList _element; +}; + +} +} +} + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
