summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/attr-widget.h
blob: acf44b2d0cd1ea972f61f7b664647d3c5f117373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
 * \brief Very basic interface for classes that control attributes
 *
 * Authors:
 *   Nicholas Bishop <nicholasbishop@gmail.com>
 *
 * Copyright (C) 2007 Authors
 *
 * Released under GNU GPL.  Read the file 'COPYING' for more information.
 */

#ifndef INKSCAPE_UI_WIDGET_ATTR_WIDGET_H
#define INKSCAPE_UI_WIDGET_ATTR_WIDGET_H

#include "attributes.h"
#include "sp-object.h"
#include "xml/node.h"

namespace Inkscape {
namespace UI {
namespace Widget {

class AttrWidget
{
public:
    AttrWidget(const SPAttributeEnum a)
        : _attr(a)
    {}

    virtual ~AttrWidget()
    {}

    virtual Glib::ustring get_as_attribute() const = 0;
    virtual void set_from_attribute(SPObject*) = 0;

    SPAttributeEnum get_attribute() const
    {
        return _attr;
    }

    sigc::signal<void>& signal_attr_changed()
    {
        return _signal;
    }
protected:
    const gchar* attribute_value(SPObject* o) const
    {
        const gchar* name = (const gchar*)sp_attribute_name(_attr);
        if(name && o) {
            const gchar* val = SP_OBJECT_REPR(o)->attribute(name);
            return val;
        }
        return 0;
    }

private:
    const SPAttributeEnum _attr;
    sigc::signal<void> _signal;
};

}
}
}

#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 :