Subversion Repositories Scribus

Rev

Rev 12313 | Rev 12337 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8337 avox 1
/*
2
 For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 to the COPYING file provided with the program. Following this notice may exist
4
 a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 for which a new license (GPL+exception) is in place.
6
 */
7
/***************************************************************************
8
*                                                                         *
9
*   This program is free software; you can redistribute it and/or modify  *
10
*   it under the terms of the GNU General Public License as published by  *
11
*   the Free Software Foundation; either version 2 of the License, or     *
12
*   (at your option) any later version.                                   *
13
*                                                                         *
14
***************************************************************************/
15
 
16
 
17
#ifndef LINESTYLE_H
18
#define LINESTYLE_H
19
 
10223 cbradney 20
#include <QString>
8337 avox 21
#include "style.h"
22
#include "styles/stylecontextproxy.h"
23
 
24
class SCRIBUS_API LineStyle : public Style {
25
public:
26
 
27
 
28
    LineStyle() : Style(), lineStyleProxy(this) {
29
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
30
                m_##attr_NAME = attr_DEFAULT; \
31
                inh_##attr_NAME = true;
32
#include "linestyle.attrdefs.cxx"
33
#undef ATTRDEF
34
    };
35
 
36
    LineStyle(double width, const QString& color, double shade=100) : Style(), lineStyleProxy(this)  {
37
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
38
                m_##attr_NAME = attr_DEFAULT; \
39
                inh_##attr_NAME = true;
40
#include "linestyle.attrdefs.cxx"
41
#undef ATTRDEF
42
                setWidth(width);
43
                setColor(color);
44
                setShade(shade);
45
    };
46
 
47
        LineStyle(const LineStyle & other);
48
 
49
        LineStyle & operator=(const LineStyle & other);
50
 
51
        static const Xml_string saxxDefaultElem;
8834 cbradney 52
        static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
8337 avox 53
 
8800 jghali 54
        virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
8337 avox 55
        virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
56
 
8455 avox 57
        void getNamedResources(ResourceCollection& lists) const;
58
        void replaceNamedResources(ResourceCollection& newNames);
59
 
12314 pierre 60
//      QString displayName() const;
8337 avox 61
 
62
        void update(const StyleContext * b);
63
 
64
        bool equiv(const Style& other) const;  
65
 
66
        void applyLineStyle(const LineStyle & other);
67
        void eraseLineStyle(const LineStyle & other);
68
        void setStyle(const LineStyle & other);
69
        void erase() { eraseLineStyle(*this); }
70
 
71
        QString asString() const;
72
 
73
        /** getter: validates and returns the attribute's value */
74
 
75
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
10508 cbradney 76
        attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
8337 avox 77
#include "linestyle.attrdefs.cxx"
78
#undef ATTRDEF
79
 
80
        /** setter: sets the attribute's value and clears inherited flag */
81
 
82
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
83
        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
84
#include "linestyle.attrdefs.cxx"
85
#undef ATTRDEF
86
        void appendSubline(const LineStyle& subline) { validate(); m_Sublines.append(subline); inh_Sublines = false; }
87
 
88
        /** setter: resets the attribute's value and sets inherited flag */
89
 
90
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
91
        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
92
#include "linestyle.attrdefs.cxx"
93
#undef ATTRDEF
94
 
95
        /** isInherited: returns true if the attribute is inherited */
96
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
97
        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
98
#include "linestyle.attrdefs.cxx"
99
#undef ATTRDEF
100
 
101
 
102
        /** isDefined: returns true if the attribute is defined in this style or any parent */
103
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
104
        bool isDef##attr_NAME() const { \
105
                if ( !inh_##attr_NAME ) return true; \
106
                const LineStyle * par = dynamic_cast<const LineStyle*>(parentStyle()); \
107
                return par && par->isDef##attr_NAME(); \
108
        }
109
#include "linestyle.attrdefs.cxx"
110
#undef ATTRDEF
111
 
112
 
113
private:
114
 
115
        StyleContextProxy lineStyleProxy;
116
        // FIXME: see pstyle how this works for nested styles
117
 
118
 
119
        // member declarations:
120
 
121
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
122
        attr_TYPE m_##attr_NAME; \
123
        bool inh_##attr_NAME;
124
#include "linestyle.attrdefs.cxx"
125
#undef ATTRDEF
126
};
127
 
128
 
129
inline LineStyle & LineStyle::operator=(const LineStyle & other)
130
{
131
        static_cast<Style&>(*this) = static_cast<const Style&>(other);
132
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
133
        m_##attr_NAME = other.m_##attr_NAME; \
134
        inh_##attr_NAME = other.inh_##attr_NAME;
135
#include "linestyle.attrdefs.cxx"
136
#undef ATTRDEF
137
        m_contextversion = -1;
138
        return *this;
139
}
140
 
141
inline LineStyle::LineStyle(const LineStyle & other) : Style(other), lineStyleProxy(this)
142
{
143
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
144
        m_##attr_NAME = other.m_##attr_NAME; \
145
        inh_##attr_NAME = other.inh_##attr_NAME;
146
#include "linestyle.attrdefs.cxx"
147
#undef ATTRDEF
148
        m_contextversion = -1;
149
}
150
 
151
#endif