forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttributedString.h
More file actions
92 lines (68 loc) · 1.58 KB
/
AttributedString.h
File metadata and controls
92 lines (68 loc) · 1.58 KB
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
//
// DocumentTemplate.h
//
#ifndef PDF_AttributedString_INCLUDED
#define PDF_AttributedString_INCLUDED
#include "Poco/PDF/PDF.h"
#include "Poco/PDF/Font.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace PDF {
class PDF_API AttributedString
{
public:
enum Alignment
{
ALIGN_LEFT = -1,
ALIGN_CENTER = 0,
ALIGN_RIGHT = 1
};
enum Style
{
STYLE_PLAIN = 0,
STYLE_BOLD = 1,
STYLE_ITALIC = 2
};
enum Attributes
{
ATTR_FONT = 1, // font name (std::string)
ATTR_SIZE = 2, // font size (int)
ATTR_STYLE = 3, // style bitmask (int)
ATTR_ALIGN = 4, // alignment (-1 = left, 0 = center, 1 = right)
};
AttributedString();
~AttributedString();
AttributedString(const char* str);
AttributedString(const std::string& str, Alignment align = ALIGN_LEFT, int style = (int)STYLE_PLAIN);
AttributedString& operator=(const std::string&);
AttributedString& operator=(const char*);
operator const std::string&();
void setAttribute(int attr, const Poco::Dynamic::Var& value);
Poco::Dynamic::Var getAttribute(int attr);
void clearAttribute(int attr);
private:
std::string _content;
Alignment _align;
int _style;
std::string _fontName;
int _fontSize;
};
//
// inlines
//
inline AttributedString& AttributedString::operator=(const std::string& content)
{
_content = content;
return *this;
}
inline AttributedString& AttributedString::operator=(const char* content)
{
_content = content;
return *this;
}
inline AttributedString::operator const std::string&()
{
return _content;
}
} } // namespace Poco::PDF
#endif // PDF_AttributedString_INCLUDED