Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
6443 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
// DONT INCLUDE this file directly, include "style.h" instead!
18
 
19
 
20
enum StyleFlag {
21
        ScStyle_Default       = 0,
22
    ScStyle_Superscript   = 1,
23
    ScStyle_Subscript     = 2,
24
    ScStyle_Outline       = 4,
25
    ScStyle_Underline     = 8,
26
    ScStyle_Strikethrough = 16,
27
    ScStyle_AllCaps       = 32,
28
    ScStyle_SmallCaps     = 64,
29
    ScStyle_HyphenationPossible=128, //Hyphenation possible here (Smart Hyphen)
30
    ScStyle_Shadowed      = 256,
31
    ScStyle_UnderlineWords= 512,
32
    ScStyle_Reserved01    = 1024, //free, not used in the moment
33
    ScStyle_DropCap       = 2048,
34
    ScStyle_SuppressSpace = 4096,//internal use in PageItem (Suppresses spaces when in Block alignment)
35
    ScStyle_SmartHyphenVisible=8192, //Smart Hyphen visible at line end
36
    ScStyle_StartOfLine   = 16384,
7017 avox 37
        ScStyle_UserStyles    = 2047, // 1919, // == 1024 + 512 + 256 + 64 + 32 + 16 + 8 + 4 + 2 + 1
6443 avox 38
        ScStyle_None          = 65535
39
};
40
 
41
SCRIBUS_API StyleFlag& operator&= (StyleFlag& left, StyleFlag right);
42
 
43
SCRIBUS_API StyleFlag& operator|= (StyleFlag& left, StyleFlag right);
44
 
45
SCRIBUS_API StyleFlag operator& (StyleFlag left, StyleFlag right);
46
 
47
SCRIBUS_API StyleFlag operator| (StyleFlag left, StyleFlag right);
48
 
49
SCRIBUS_API StyleFlag operator^ (StyleFlag left, StyleFlag right);
50
 
51
SCRIBUS_API StyleFlag operator~ (StyleFlag arg);
52
 
7017 avox 53
SCRIBUS_API bool operator== (StyleFlag left, StyleFlag right);
6443 avox 54
 
7017 avox 55
SCRIBUS_API bool operator!= (StyleFlag left, StyleFlag right);
6443 avox 56
 
57
 
7005 avox 58
class SCRIBUS_API CharStyle : public Style {
6443 avox 59
public:
60
 
61
 
62
    CharStyle() : Style() {
63
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
64
                m_##attr_NAME = attr_DEFAULT; \
65
                inh_##attr_NAME = true;
66
#include "charstyle.attrdefs.cxx"
67
#undef ATTRDEF
68
    };
69
 
70
    CharStyle(const ScFace& font, int size, StyleFlag style = ScStyle_Default) : Style() {
71
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
72
                m_##attr_NAME = attr_DEFAULT; \
73
                inh_##attr_NAME = true;
74
#include "charstyle.attrdefs.cxx"
75
#undef ATTRDEF
76
                m_Font = font;
77
        m_FontSize = size;
78
                m_Effects = style;
79
    };
80
 
81
        CharStyle(const CharStyle & other);
82
 
83
        CharStyle & operator=(const CharStyle & other);
84
 
85
        QString displayName() const;
86
 
6805 avox 87
        void update(const StyleBase * b);
6443 avox 88
 
89
        bool equiv(const Style& other) const;  
90
 
91
        void applyCharStyle(const CharStyle & other);
92
        void eraseCharStyle(const CharStyle & other);
7242 avox 93
        void setStyle(const CharStyle & other);
6443 avox 94
        void erase() { eraseCharStyle(*this); }
95
 
96
        QString asString() const;
97
 
98
        /** getter: validates and returns the attribute's value */
99
 
100
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
101
        const attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
102
#include "charstyle.attrdefs.cxx"
103
#undef ATTRDEF
104
 
105
        /** setter: sets the attribute's value and clears inherited flag */
106
 
107
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
108
        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
109
#include "charstyle.attrdefs.cxx"
110
#undef ATTRDEF
111
 
112
        /** setter: resets the attribute's value and sets inherited flag */
113
 
114
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
115
        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
116
#include "charstyle.attrdefs.cxx"
117
#undef ATTRDEF
118
 
6733 avox 119
        /** isInherited: returns true if the attribute is inherited */
6443 avox 120
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
6733 avox 121
        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
6443 avox 122
#include "charstyle.attrdefs.cxx"
123
#undef ATTRDEF
124
 
125
 
6733 avox 126
        /** isDefined: returns true if the attribute is defined in this style or any parent */
127
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
128
        bool isDef##attr_NAME() const { \
6805 avox 129
                if ( !inh_##attr_NAME ) return true; \
6733 avox 130
                const CharStyle * par = dynamic_cast<const CharStyle*>(parentStyle()); \
131
                return par && par->isDef##attr_NAME(); \
132
        }
133
#include "charstyle.attrdefs.cxx"
134
#undef ATTRDEF
135
 
136
 
6443 avox 137
private:
138
 
139
        // member declarations:
140
 
141
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
142
        attr_TYPE m_##attr_NAME; \
143
        bool inh_##attr_NAME;
144
#include "charstyle.attrdefs.cxx"
145
#undef ATTRDEF
146
};
147
 
148
 
149
inline CharStyle & CharStyle::operator=(const CharStyle & other)
150
{
151
        static_cast<Style&>(*this) = static_cast<const Style&>(other);
152
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
153
        m_##attr_NAME = other.m_##attr_NAME; \
154
        inh_##attr_NAME = other.inh_##attr_NAME;
155
#include "charstyle.attrdefs.cxx"
156
#undef ATTRDEF
7059 avox 157
        m_base = NULL;
6908 avox 158
        m_baseversion = -1;
6443 avox 159
        return *this;
160
}
161
 
162
inline CharStyle::CharStyle(const CharStyle & other) : Style(other)
163
{
164
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
165
        m_##attr_NAME = other.m_##attr_NAME; \
166
        inh_##attr_NAME = other.inh_##attr_NAME;
167
#include "charstyle.attrdefs.cxx"
168
#undef ATTRDEF
7059 avox 169
        m_base = NULL;
6908 avox 170
        m_baseversion = -1;
6443 avox 171
}
172