-
Notifications
You must be signed in to change notification settings - Fork 0
/
SVGText.h
152 lines (110 loc) · 4.11 KB
/
SVGText.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef _SVG_TEXT_H_
#define _SVG_TEXT_H_
#include "SVGPath.h"
#include "SVGDefs.h"
class BSVGString;
class BSVGTextSpan;
class BSVGText;
class BSVGTextSpan : public BSVGPath {
public:
BSVGTextSpan(BSVGView *parent);
BSVGTextSpan(BSVGView *parent, SVGState state);
virtual ~BSVGTextSpan();
BSVGTextSpan(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void GetBounds(BRect *bounds);
virtual void PrepareFont();
virtual void GetCharpos(CharposList *charpos, FloatList *chunklengths, int32 *index, bool *first);
virtual void AddToShape(CharposList *charpos, FloatList *chunklengths, BPoint *absolute, BPoint *relative, float *rotation, progress_t progress);
virtual void HandleAttribute(attribute_s *attr);
virtual void RecreateData();
virtual BSVGString *FirstText();
virtual BSVGString *LastText();
virtual BSVGTextSpan *LastTextContainer();
virtual void AddChar(char chr);
virtual void AddString(const char *string);
virtual void AddString(const BString &string);
virtual void AddSpan(BSVGTextSpan *span);
virtual BString WholeText();
virtual void StripInterSpaces(bool *kept_last);
void OverlapOffset(offset_t type);
void OverlapOffsets();
void SetBase(BSVGText *base);
BSVGTextSpan *TextParent();
virtual BSVGText *ParentText();
virtual BSVGTextSpan *ParentSpan();
virtual BSVGTextPath *ParentPath();
FloatList *GetOffsetList(offset_t which);
virtual element_t Type() { return B_SVG_TEXTSPAN; };
virtual void PrepareRendering(SVGState *inherit = NULL);
virtual void Render(BView *view);
virtual void Render(BWindow *window);
virtual void Render(BBitmap *bitmap);
private:
friend class BSVGTextPath;
FloatList fOffsetX;
FloatList fOffsetY;
FloatList fOffsetDX;
FloatList fOffsetDY;
FloatList fOffsetR;
};
class BSVGString : public BSVGTextSpan {
public:
BSVGString(BSVGView *parent, const BString &text);
BSVGString(BSVGView *parent, const char *text);
BSVGString(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void RecreateData();
void SetText(const BString &text);
void SetText(const char *text);
void ClearText();
BString Text();
int32 Length();
virtual BString WholeText();
virtual void GetBounds(BRect *bounds);
virtual void PrepareFont();
virtual void GetCharpos(CharposList *charpos, FloatList *chunklengths, int32 *index, bool *first);
virtual void AddToShape(CharposList *charpos, FloatList *chunklengths, BPoint *absolute, BPoint *relative, float *rotation, progress_t progress);
virtual void StripInterSpaces(bool *kept_last);
virtual BSVGString *FirstText();
virtual BSVGString *LastText();
virtual BSVGTextSpan *LastTextContainer();
virtual element_t Type() { return B_SVG_STRING; };
private:
BFont fFont;
BString fText;
};
class BSVGTextPath : public BSVGTextSpan {
public:
BSVGTextPath(BSVGView *parent);
BSVGTextPath(BSVGView *parent, BString path);
BSVGTextPath(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual element_t Type() { return B_SVG_TEXTPATH; };
virtual void FinalizeShape();
virtual void RecreateData();
BSVGPath *ResolvedPath();
};
class BSVGText : public BSVGTextSpan {
public:
BSVGText(BSVGView *parent);
BSVGText(BSVGView *parent, SVGState state);
BSVGText(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual element_t Type() { return B_SVG_TEXT; };
virtual void FinalizeShape();
void StripWhiteSpaces();
virtual void RecreateData();
virtual void PrepareRendering(SVGState *inherit = NULL);
virtual void Render(BView *view);
virtual void Render(BWindow *window);
virtual void Render(BBitmap *bitmap);
virtual void RenderCommon();
virtual BRect ShapeBounds();
virtual void CollectBounds(BRect &bounds, bool *first);
};
#endif