2
* \brief Very basic interface for classes that control attributes
5
* Nicholas Bishop <nicholasbishop@gmail.com>
6
* Rodrigo Kumpera <kumpera@gmail.com>
8
* Copyright (C) 2007 Authors
10
* Released under GNU GPL. Read the file 'COPYING' for more information.
13
#ifndef INKSCAPE_UI_WIDGET_ATTR_WIDGET_H
14
#define INKSCAPE_UI_WIDGET_ATTR_WIDGET_H
16
#include "attributes.h"
17
#include "sp-object.h"
19
#include <gtkmm/tooltips.h>
35
class DefaultValueHolder
37
DefaultValueType type;
40
std::vector<double>* vt_val;
42
unsigned int uint_val;
46
//FIXME remove copy ctor and assignment operator as private to avoid double free of the vector
48
DefaultValueHolder () {
52
DefaultValueHolder (double d) {
57
DefaultValueHolder (std::vector<double>* d) {
62
DefaultValueHolder (char* c) {
67
DefaultValueHolder (bool d) {
72
DefaultValueHolder (unsigned int ui) {
77
~DefaultValueHolder() {
78
if (type == T_VECT_DOUBLE)
82
unsigned int as_uint() {
83
g_assert (type == T_UINT);
84
return value.uint_val;
88
g_assert (type == T_BOOL);
93
g_assert (type == T_DOUBLE);
97
std::vector<double>* as_vector() {
98
g_assert (type == T_VECT_DOUBLE);
103
g_assert (type == T_CHARPTR);
104
return value.cptr_val;
111
AttrWidget(const SPAttributeEnum a, unsigned int value)
116
AttrWidget(const SPAttributeEnum a, double value)
121
AttrWidget(const SPAttributeEnum a, bool value)
126
AttrWidget(const SPAttributeEnum a)
131
virtual ~AttrWidget()
134
virtual Glib::ustring get_as_attribute() const = 0;
135
virtual void set_from_attribute(SPObject*) = 0;
137
SPAttributeEnum get_attribute() const
142
sigc::signal<void>& signal_attr_changed()
147
DefaultValueHolder* get_default() { return &_default; }
148
const gchar* attribute_value(SPObject* o) const
150
const gchar* name = (const gchar*)sp_attribute_name(_attr);
152
const gchar* val = SP_OBJECT_REPR(o)->attribute(name);
162
const SPAttributeEnum _attr;
163
DefaultValueHolder _default;
164
sigc::signal<void> _signal;
176
c-file-style:"stroustrup"
177
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
182
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :