37
35
#include "ipetext.h"
39
37
// --------------------------------------------------------------------
47
class IPE_EXPORT IpeLayer {
49
explicit IpeLayer(IpeString name);
50
explicit IpeLayer(const IpeXmlAttributes &attr);
51
void SaveAsXml(IpeStream &stream) const;
53
inline IpeString Name() const { return iName; }
55
inline void SetName(const IpeString &name) { iName = name; }
58
inline bool IsDimmed() const { return !!(iFlags & EDim); }
60
inline bool IsLocked() const { return !!(iFlags & ELocked); }
61
//! Is snapping enabled?
62
inline bool IsSnapping() const { return !(iFlags & ENoSnapping); }
64
void SetDimmed(bool flag);
65
void SetLocked(bool flag);
66
void SetSnapping(bool flag);
69
enum {EDim = 0x01, ELocked = 0x02, ENoSnapping = 0x04 };
75
typedef std::vector<IpeLayer> IpeLayerSeq;
77
// --------------------------------------------------------------------
79
class IPE_EXPORT IpeView {
81
//! The various fancy effects that Acrobat Reader will show.
83
ENormal, ESplitHI, ESplitHO, ESplitVI, ESplitVO,
84
EBlindsH, EBlindsV, EBoxI, EBoxO,
85
EWipeLR, EWipeBT, EWipeRL, EWipeTB,
86
EDissolve, EGlitterLR, EGlitterTB, EGlitterD };
89
IpeView(const IpeXmlAttributes &attr);
90
void SaveAsXml(IpeStream &stream) const;
91
void PageDictionary(IpeStream &stream) const;
93
//! How many layers are visible in this view?
94
inline int CountLayers() const { return iLayers.size(); }
95
//! Return name of one visible layer.
96
inline IpeString Layer(int i) const { return iLayers[i]; }
97
bool HasLayer(IpeString name) const;
98
void DeleteLayer(IpeString name);
99
void AddLayer(IpeString name);
100
inline void ClearLayers() { iLayers.clear(); }
102
//! The layer active in this view.
103
inline IpeString Active() const { return iActive; }
104
//! Set active layer.
105
inline void SetActive(const IpeString &l) { iActive = l; }
106
//! The transition effect when switching to this view.
107
inline TEffect Effect() const { return iEffect; }
108
//! Set transition effect for switching to this view.
109
inline void SetEffect(TEffect e) { iEffect = e; }
110
//! How long will this view be shown (in secs)?
111
inline int Duration() const { return iDuration; }
112
//! Set duration of this view (in secs).
113
inline void SetDuration(int secs) { iDuration = secs; }
114
//! The transition time for the effect (in secs).
115
inline int TransitionTime() const { return iTransitionTime; }
116
//! Set transition time for the effect (in secs).
117
inline void SetTransitionTime(int secs) { iTransitionTime = secs; }
119
std::vector<IpeString> iLayers;
126
//! View sequence of a page.
127
typedef std::vector<IpeView> IpeViewSeq;
129
// --------------------------------------------------------------------
131
class IPE_EXPORT IpePage : public IpePgObjectSeq {
135
void SaveAsXml(IpePainter &painter, IpeStream &stream) const;
137
//! Return number of layers.
138
inline int CountLayers() const { return iLayers.size(); }
140
inline const IpeLayer &Layer(int index) const { return iLayers[index]; }
142
inline IpeLayer &Layer(int index) { return iLayers[index]; }
143
int FindLayer(IpeString name) const;
144
int AddLayer(const IpeLayer &layer, int index = -1);
145
int NewLayer(int index);
146
void DeleteLayer(int index);
147
bool IsLayerActiveInView(int index) const;
149
//! Return presentation sequence of this page.
150
inline const IpeViewSeq &Views() const {return iViews;}
151
//! Return number of views.
152
inline int CountViews() const { return iViews.size(); }
154
inline const IpeView &View(int index) const { return iViews[index]; }
156
inline IpeView &View(int index) { return iViews[index]; }
157
void SetView(int index, const IpeView &view);
158
void AddView(const IpeView &view, int index = -1);
159
void DeleteView(int index);
160
void renameLayer(IpeString oldName, IpeString newName);
162
IpeRect TextBox(const IpeStyleSheet *sheet) const;
164
void SetEdited(bool edited);
165
//! Return true if page has been modified since last save.
166
inline bool IsEdited() const { return iEdited; }
168
//! Return title of this page.
169
IpeString title() const;
170
void setTitle(IpeString title);
171
IpeString section(int level) const;
172
void setSection(int level, bool useTitle, IpeString name);
173
//! Does this section title reflect the page title?
174
bool sectionUsesTitle(int level) const { return iUseTitle[level]; }
175
const IpeText *titleText() const;
176
void applyTitleStyle(const IpeStyleSheet *sheet);
179
void DeselectLayer(int layer);
180
void DeselectNotInView(int view);
181
bool HasSelection() const;
182
iterator PrimarySelection();
183
void EnsurePrimarySelection();
184
void ExtractSelection(IpePgObjectSeq &seq);
185
bool UpdateCloseSelection(const IpeVector &pos, double d,
186
bool primaryOnly, int view);
188
void Copy(IpeStream &stream, const IpeStyleSheet *sheet) const;
189
bool Paste(int layer, IpeDataSource &source, IpeRepository *rep);
190
void CopyPage(IpeStream &stream, const IpeStyleSheet *sheet) const;
192
void MakeLayerTable(std::vector<bool> &layers, int view,
193
bool excludeLocked) const;
195
void MoveToLayer(int layer);
197
void SelectAll(int view);
198
void SelectAllInLayer(int layer);
199
void Group(int layer);
200
bool Ungroup(int layer);
205
void movePrimaryBeforeSecondary();
206
void movePrimaryBehindSecondary();
207
void Duplicate(int layer);
208
void SetStroke(IpeAttribute color);
209
void SetFill(IpeAttribute color);
210
void SetLineWidth(IpeAttribute attr);
211
void SetDashStyle(IpeAttribute attr);
212
void SetArrows(bool forward, bool backward, IpeAttribute size);
213
void SetArrowSize(IpeAttribute size);
214
void SetMarkShape(int shape);
215
void SetMarkSize(IpeAttribute size);
216
void SetTextSize(IpeAttribute size);
217
void setTransformable(bool transf);
218
void setTextStyle(IpeAttribute style);
219
void setLabelHorizontalAlignment(IpeText::THorizontalAlignment align);
220
void setLabelVerticalAlignment(IpeText::TVerticalAlignment align);
221
void setPinned(IpeObject::TPinned pin);
222
void setLineJoin(IpeAttribute join);
223
void setLineCap(IpeAttribute cap);
224
void setWindRule(IpeAttribute rule);
226
bool ComposePaths(int layer);
227
bool DecomposePath(int layer);
228
bool JoinPaths(int layer);
230
//! Return grid size for this page (0 if not set).
231
inline int GridSize() const { return iGridSize; }
233
inline void SetGridSize(int gs) { iGridSize = gs; }
236
IpePath *DoJoinPaths(IpePath *prim, SSubPath *subs, int size);
243
IpeText iTitleObject;
245
IpeString iSection[2];
248
//! Constructor takes ownership of object.
249
inline IpePgObject::IpePgObject(TSelect sel, int layer, IpeObject *obj)
250
: iSelect(sel), iLayer(layer), iObject(obj)
44
// --------------------------------------------------------------------
52
void saveAsXml(Stream &stream) const;
53
void saveAsIpePage(Stream &stream) const;
54
void saveSelection(Stream &stream) const;
56
//! Return number of layers.
57
inline int countLayers() const { return iLayers.size(); }
58
//! Return name of layer \a index.
59
inline String layer(int index) const { return iLayers[index].iName; }
61
//! Is layer \a i locked?
62
inline bool isLocked(int i) const {
63
return !!(iLayers[i].iFlags & ELocked); }
64
//! Does layer \a i have active snapping?
65
inline bool hasSnapping(int i) const {
66
return !(iLayers[i].iFlags & ENoSnapping); }
68
void setLocked(int i, bool flag);
69
void setSnapping(int i, bool flag);
71
int findLayer(String name) const;
72
void addLayer(String name);
74
void removeLayer(String name);
75
void renameLayer(String oldName, String newName);
77
//! Return number of views.
78
inline int countViews() const { return iViews.size(); }
79
//! Return effect of view.
80
inline Attribute effect(int index) const { return iViews[index].iEffect; }
81
void setEffect(int index, Attribute sym);
82
//! Return active layer of view.
83
inline String active(int index) const { return iViews[index].iActive; }
84
//! Set active layer of view.
85
void setActive(int index, String name);
87
void insertView(int i, String active);
88
void removeView(int i);
91
//! Is \a layer visible in \a view?
92
inline bool visible(int view, int layer) const {
93
return iLayers[layer].iVisible[view]; }
94
//! Is object at index \a objno visible in \a view?
95
inline bool objectVisible(int view, int objno) const {
96
return iLayers[layerOf(objno)].iVisible[view]; }
98
void setVisible(int view, String layer, bool vis);
100
Rect textBox(const Cascade *sheet) const;
102
//! Return title of this page.
103
String title() const;
104
void setTitle(String title);
105
String section(int level) const;
106
void setSection(int level, bool useTitle, String name);
107
//! Does this section title reflect the page title?
108
bool sectionUsesTitle(int level) const { return iUseTitle[level]; }
109
const Text *titleText() const;
110
void applyTitleStyle(const Cascade *sheet);
112
//! Return number of objects on the page.
113
inline int count() const { return int(iObjects.size()); }
115
//! Return object at index \a i.
116
inline Object *object(int i) { return iObjects[i].iObject; }
117
//! Return object at index \a i (const version).
118
inline const Object *object(int i) const { return iObjects[i].iObject; }
120
//! Return selection status of object at index \a i.
121
inline TSelect select(int i) const { return iObjects[i].iSelect; }
122
//! Return layer of object at index \a i.
123
inline int layerOf(int i) const { return iObjects[i].iLayer; }
125
//! Set selection status of object at index \a i.
126
inline void setSelect(int i, TSelect sel) { iObjects[i].iSelect = sel; }
127
//! Set layer of object at index \a i.
128
inline void setLayerOf(int i, int layer) { iObjects[i].iLayer = layer; }
130
Rect pageBBox(const Cascade *sheet) const;
131
Rect viewBBox(const Cascade *sheet, int view) const;
132
Rect bbox(int i) const;
134
void transform(int i, const Matrix &m);
135
double distance(int i, const Vector &v, double bound) const;
136
void snapVtx(int i, const Vector &mouse, Vector &pos, double &bound) const;
137
void snapBnd(int i, const Vector &mouse, Vector &pos, double &bound) const;
138
void invalidateBBox(int i) const;
140
void insert(int i, TSelect sel, int layer, Object *obj);
141
void append(TSelect sel, int layer, Object *obj);
143
void replace(int i, Object *obj);
144
bool setAttribute(int i, Property prop, Attribute value,
145
Attribute stroke, Attribute fill);
147
int primarySelection() const;
148
bool hasSelection() const;
150
void ensurePrimarySelection();
153
enum { ELocked = 0x01, ENoSnapping = 0x02 };
161
// Invariant: iVisible.size() == iViews.size()
162
std::vector<bool> iVisible;
164
typedef std::vector<SLayer> LayerSeq;
168
SView() { iEffect = Attribute::NORMAL(); }
173
typedef std::vector<SView> ViewSeq;
177
SObject(const SObject &rhs);
179
SObject &operator=(const SObject &rhs);
186
typedef std::vector<SObject> ObjSeq;
255
200
// --------------------------------------------------------------------