35
#include "ipeattributes.h"
37
36
#include "ipetext.h"
39
38
// --------------------------------------------------------------------
41
class IPE_EXPORT IpeStyleSheet {
44
//! Style of the title on a page.
46
//! Is this style undefined (null)?
47
bool isNull() const { return iSize.IsNull(); }
48
//! Position on the page (in Ipe coordinate system)
54
//! Horizontal alignment.
55
IpeText::THorizontalAlignment iHorizontalAlignment;
56
//! Vertical alignment.
57
IpeText::TVerticalAlignment iVerticalAlignment;
60
IpeStyleSheet(IpeRepository *rep);
63
static IpeStyleSheet *Standard(IpeRepository *rep);
65
void AddTemplate(IpeAttribute name, const IpeObject *obj);
66
const IpeObject *FindTemplate(IpeAttribute sym) const;
68
void Add(IpeAttribute name, IpeAttribute value);
69
IpeAttribute Find(IpeAttribute sym) const;
71
void SaveAsXml(IpeStream &stream, bool saveBitmaps = false) const;
72
void SaveCascadeAsXml(IpeStream &stream) const;
74
void AllNames(IpeKind kind, IpeAttributeSeq &seq) const;
75
void AllNames(IpeAttributeSeq *attr) const;
77
//! Return whether this is the standard style sheet built into Ipe.
78
inline bool IsStandard() const { return iStandard; }
80
//! Return preamble of this style sheet (not including the cascade).
81
inline IpeString Preamble() const { return iPreamble; }
82
IpeString TotalPreamble() const;
83
//! Set LaTeX preamble.
84
inline void SetPreamble(const IpeString &str) { iPreamble = str; }
86
void setLayout(const IpeLayout &margins);
87
IpeLayout findLayout() const;
89
void setTitleStyle(const STitleStyle &ts);
90
STitleStyle findTitleStyle() const;
92
void SetShading(const IpeShading &s);
93
IpeShading FindShading() const;
95
void AddCMap(IpeString s);
96
void AllCMaps(std::vector<IpeString> &seq) const;
98
void SetStrokeStyle(IpeStrokeStyle s);
99
IpeAttribute LineCap() const;
100
IpeAttribute LineJoin() const;
101
IpeAttribute WindRule() const;
103
inline const IpeStyleSheet *Cascade() const;
104
inline IpeStyleSheet *Cascade();
106
void SetCascade(IpeStyleSheet *sheet);
108
//! Return name of style sheet.
109
inline IpeString Name() const { return iName; }
110
//! Set name of style sheet.
111
inline void SetName(const IpeString &name) { iName = name; }
113
//! Return attribute repository.
114
inline IpeRepository *Repository() { return iRepository; }
115
//! Return attribute repository (const version).
116
inline const IpeRepository *Repository() const { return iRepository; }
119
IpeStyleSheet(const IpeStyleSheet &rhs);
120
IpeStyleSheet &operator=(const IpeStyleSheet &rhs);
122
typedef std::map<int, const IpeObject *> TemplateMap;
123
typedef std::map<int, IpeAttribute> Map;
127
IpeStyleSheet *iCascade;
128
TemplateMap iTemplates;
132
STitleStyle iTitleStyle;
133
IpeRepository *iRepository;
136
IpeStrokeStyle iStrokeStyle;
138
std::vector<IpeString> iCMaps;
141
// --------------------------------------------------------------------
143
//! Return next sheet in cascade (const version).
144
inline const IpeStyleSheet *IpeStyleSheet::Cascade() const
149
//! Return the next level style sheet.
150
inline IpeStyleSheet *IpeStyleSheet::Cascade()
44
Symbol(Object *object);
45
Symbol(const Symbol &rhs);
46
Symbol &operator=(const Symbol &rhs);
50
TTransformations iTransformations;
57
//! Style of the title on a page.
59
//! Has a TitleStyle been defined in the style sheet?
61
//! Position on the page (in Ipe coordinate system)
67
//! Horizontal alignment.
68
THorizontalAlignment iHorizontalAlignment;
69
//! Vertical alignment.
70
TVerticalAlignment iVerticalAlignment;
73
//! How to show page numbers on the paper.
74
struct PageNumberStyle {
75
//! Has a PageNumberStyle been defined in the style sheet?
77
//! Position on the page
87
static StyleSheet *standard();
89
void addSymbol(Attribute name, const Symbol &symbol);
90
const Symbol *findSymbol(Attribute sym) const;
92
void addGradient(Attribute name, const Gradient &s);
93
const Gradient *findGradient(Attribute sym) const;
95
void addTiling(Attribute name, const Tiling &s);
96
const Tiling *findTiling(Attribute sym) const;
98
void addEffect(Attribute name, const Effect &e);
99
const Effect *findEffect(Attribute sym) const;
101
void add(Kind kind, Attribute name, Attribute value);
102
bool has(Kind kind, Attribute sym) const;
103
Attribute find(Kind, Attribute sym) const;
105
void saveAsXml(Stream &stream, bool saveBitmaps = false) const;
107
void allNames(Kind kind, AttributeSeq &seq) const;
109
//! Return whether this is the standard style sheet built into Ipe.
110
inline bool isStandard() const { return iStandard; }
112
//! Return Latex preamble.
113
inline String preamble() const { return iPreamble; }
114
//! Set LaTeX preamble.
115
inline void setPreamble(const String &str) { iPreamble = str; }
117
const Layout *layout() const;
118
void setLayout(const Layout &margins);
120
const TitleStyle *titleStyle() const;
121
void setTitleStyle(const TitleStyle &ts);
123
const PageNumberStyle *pageNumberStyle();
124
void setPageNumberStyle(const PageNumberStyle &pns);
126
void addCMap(String s);
127
void allCMaps(std::vector<String> &seq) const;
129
void setLineCap(TLineCap s);
130
void setLineJoin(TLineJoin s);
131
void setFillRule(TFillRule s);
133
TLineCap lineCap() const { return iLineCap; }
134
//! Return line join.
135
TLineJoin lineJoin() const { return iLineJoin; }
136
//! Return path fill rule.
137
TFillRule fillRule() const { return iFillRule; }
139
//! Return name of style sheet.
140
inline String name() const { return iName; }
141
//! Set name of style sheet.
142
inline void setName(const String &name) { iName = name; }
145
typedef std::map<int, Symbol> SymbolMap;
146
typedef std::map<int, Gradient> GradientMap;
147
typedef std::map<int, Tiling> TilingMap;
148
typedef std::map<int, Effect> EffectMap;
149
typedef std::map<int, Attribute> Map;
154
GradientMap iGradients;
160
TitleStyle iTitleStyle;
161
PageNumberStyle iPageNumberStyle;
167
std::vector<String> iCMaps;
174
Cascade(const Cascade &rhs);
175
Cascade &operator=(const Cascade &rhs);
178
//! Return number of style sheets.
179
inline int count() const { return iSheets.size(); }
180
//! Return StyleSheet at \a index.
181
inline StyleSheet *sheet(int index) { return iSheets[index]; }
183
void insert(int index, StyleSheet *sheet);
184
void remove(int index);
186
void saveAsXml(Stream &stream) const;
188
bool has(Kind kind, Attribute sym) const;
189
Attribute find(Kind, Attribute sym) const;
190
const Symbol *findSymbol(Attribute sym) const;
191
const Gradient *findGradient(Attribute sym) const;
192
const Tiling *findTiling(Attribute sym) const;
193
const Effect *findEffect(Attribute sym) const;
194
const Layout *findLayout() const;
195
const StyleSheet::TitleStyle *findTitleStyle() const;
196
const StyleSheet::PageNumberStyle *findPageNumberStyle() const;
197
String findPreamble() const;
199
TLineCap lineCap() const;
200
TLineJoin lineJoin() const;
201
TFillRule fillRule() const;
203
void allNames(Kind kind, AttributeSeq &seq) const;
204
int findDefinition(Kind kind, Attribute sym) const;
205
void allCMaps(std::vector<String> &seq) const;
207
String update(String dir);
210
std::vector<StyleSheet *> iSheets;
155
215
// --------------------------------------------------------------------