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 protected:
37 const gchar* attribute_value(SPObject* o) const
38 {
39 const gchar* name = (const gchar*)sp_attribute_name(_attr);
40 if(name && o) {
41 const gchar* val = SP_OBJECT_REPR(o)->attribute(name);
42 return val;
43 }
44 return 0;
45 }
47 private:
48 const SPAttributeEnum _attr;
49 };
51 }
52 }
53 }
55 #endif
57 /*
58 Local Variables:
59 mode:c++
60 c-file-style:"stroustrup"
61 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
62 indent-tabs-mode:nil
63 fill-column:99
64 End:
65 */
66 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :