Subversion Repositories Scribus

Rev

Rev 12340 | 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>
12337 pierre 21
#include "resourcecollection.h"
8337 avox 22
#include "style.h"
12340 pierre 23
// #include "styles/stylecontextproxy.h"
8337 avox 24
 
25
class SCRIBUS_API LineStyle : public Style {
26
public:
27
 
28
 
12340 pierre 29
    LineStyle() : Style() {
8337 avox 30
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
31
                m_##attr_NAME = attr_DEFAULT; \
32
                inh_##attr_NAME = true;
33
#include "linestyle.attrdefs.cxx"
34
#undef ATTRDEF
35
    };
36
 
12340 pierre 37
    LineStyle(double width, const QString& color, double shade=100) : Style()  {
8337 avox 38
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
39
                m_##attr_NAME = attr_DEFAULT; \
40
                inh_##attr_NAME = true;
41
#include "linestyle.attrdefs.cxx"
42
#undef ATTRDEF
43
                setWidth(width);
44
                setColor(color);
45
                setShade(shade);
46
    };
47
 
48
        LineStyle(const LineStyle & other);
49
 
50
        LineStyle & operator=(const LineStyle & other);
51
 
52
        static const Xml_string saxxDefaultElem;
8834 cbradney 53
        static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
8337 avox 54
 
8800 jghali 55
        virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
8337 avox 56
        virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
57
 
8455 avox 58
        void getNamedResources(ResourceCollection& lists) const;
59
        void replaceNamedResources(ResourceCollection& newNames);
8337 avox 60
 
12340 pierre 61
        bool equiv(const QString& other) const;
8337 avox 62
 
12340 pierre 63
        void applyLineStyle(const QString& other);
64
        void eraseLineStyle(const QString& other);
65
        void setStyle(const QString& other);
66
        void erase() { eraseLineStyle(uuid()); }
8337 avox 67
 
68
        QString asString() const;
69
 
70
        /** getter: validates and returns the attribute's value */
71
 
72
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
10508 cbradney 73
        attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
8337 avox 74
#include "linestyle.attrdefs.cxx"
75
#undef ATTRDEF
76
 
77
        /** setter: sets the attribute's value and clears inherited flag */
78
 
79
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
80
        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
81
#include "linestyle.attrdefs.cxx"
82
#undef ATTRDEF
83
        void appendSubline(const LineStyle& subline) { validate(); m_Sublines.append(subline); inh_Sublines = false; }
84
 
85
        /** setter: resets the attribute's value and sets inherited flag */
86
 
87
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
88
        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
89
#include "linestyle.attrdefs.cxx"
90
#undef ATTRDEF
91
 
92
        /** isInherited: returns true if the attribute is inherited */
93
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
94
        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
95
#include "linestyle.attrdefs.cxx"
96
#undef ATTRDEF
97
 
98
 
99
        /** isDefined: returns true if the attribute is defined in this style or any parent */
100
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
101
        bool isDef##attr_NAME() const { \
102
                if ( !inh_##attr_NAME ) return true; \
103
                const LineStyle * par = dynamic_cast<const LineStyle*>(parentStyle()); \
104
                return par && par->isDef##attr_NAME(); \
105
        }
106
#include "linestyle.attrdefs.cxx"
107
#undef ATTRDEF
108
 
109
 
110
private:
111
 
12340 pierre 112
//      StyleContextProxy lineStyleProxy;
8337 avox 113
        // FIXME: see pstyle how this works for nested styles
114
 
115
 
116
        // member declarations:
117
 
118
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
119
        attr_TYPE m_##attr_NAME; \
120
        bool inh_##attr_NAME;
121
#include "linestyle.attrdefs.cxx"
122
#undef ATTRDEF
123
};
124
 
12343 pierre 125
/*
8337 avox 126
inline LineStyle & LineStyle::operator=(const LineStyle & other)
127
{
128
        static_cast<Style&>(*this) = static_cast<const Style&>(other);
129
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
130
        m_##attr_NAME = other.m_##attr_NAME; \
131
        inh_##attr_NAME = other.inh_##attr_NAME;
132
#include "linestyle.attrdefs.cxx"
133
#undef ATTRDEF
134
        return *this;
135
}
12343 pierre 136
*/
8337 avox 137
 
12340 pierre 138
inline LineStyle::LineStyle(const LineStyle & other) : Style(other)
8337 avox 139
{
140
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
141
        m_##attr_NAME = other.m_##attr_NAME; \
142
        inh_##attr_NAME = other.inh_##attr_NAME;
143
#include "linestyle.attrdefs.cxx"
144
#undef ATTRDEF
145
}
146
 
147
#endif