1 /**
2 * \brief Very basic interface for classes that control attributes
3 *
4 * Authors:
5 * Nicholas Bishop <nicholasbishop@gmail.com>
6 *
7 * Copyright (C) 2007 Authors
8 *
9 * Released under GNU GPL. Read the file 'COPYING' for more information.
10 */
12 #ifndef INKSCAPE_UI_WIDGET_ATTR_WIDGET_H
13 #define INKSCAPE_UI_WIDGET_ATTR_WIDGET_H
15 #include "attributes.h"
16 #include "sp-object.h"
17 #include "xml/node.h"
19 namespace Inkscape {
20 namespace UI {
21 namespace Widget {
23 class AttrWidget
24 {
25 public:
26 AttrWidget(const SPAttributeEnum a)
27 : _attr(a)
28 {}
30 virtual ~AttrWidget()
31 {}
33 virtual Glib::ustring get_as_attribute() const = 0;
34 virtual void set_from_attribute(SPObject*) = 0;
36 SPAttributeEnum get_attribute() const
37 {
38 return _attr;
39 }
41 sigc::signal<void>& signal_attr_changed()
42 {
43 return _signal;
44 }
45 protected:
46 const gchar* attribute_value(SPObject* o) const
47 {
48 const gchar* name = (const gchar*)sp_attribute_name(_attr);
49 if(name && o) {
50 const gchar* val = SP_OBJECT_REPR(o)->attribute(name);
51 return val;
52 }
53 return 0;
54 }
56 private:
57 const SPAttributeEnum _attr;
58 sigc::signal<void> _signal;
59 };
61 }
62 }
63 }
65 #endif
67 /*
68 Local Variables:
69 mode:c++
70 c-file-style:"stroustrup"
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
72 indent-tabs-mode:nil
73 fill-column:99
74 End:
75 */
76 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :