PEBL
2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
FormatParser.h
Go to the documentation of this file.
1
#ifndef __FORMATPARSER_H__
2
#define __FORMATPARSER_H__
3
4
#include <string>
5
#include <vector>
6
#include "../objects/PColor.h"
7
31
32
namespace
FormatParser
{
33
35
enum
Justification
{
36
JUSTIFY_NONE
= 0,
// No justification set (use default)
37
JUSTIFY_LEFT
= 1,
// Left-aligned
38
JUSTIFY_CENTER
= 2,
// Center-aligned
39
JUSTIFY_RIGHT
= 3
// Right-aligned
40
};
41
44
struct
FormatSegment
{
45
std::string
text
;
// The actual text to render
46
int
style
;
// Font style: 0=normal, 1=bold, 2=italic, 4=underline (bitwise OR)
47
bool
hasColorOverride
;
// True if color was specified in tag
48
PColor
colorOverride
;
// Color override (if hasColorOverride=true)
49
bool
hasSizeOverride
;
// True if size was specified in tag
50
int
sizeOverride
;
// Font size as percentage of base (100 = base font, 150 = 150% of base)
51
52
// Block-level formatting (TextBox only)
53
int
indentPixels
;
// Horizontal indent in pixels (0 = no indent)
54
bool
isHorizontalRule
;
// True if this segment is a <hr>
55
bool
isBulletItem
;
// True if this segment is a <li>
56
Justification
justification
;
// Text justification (left, center, right)
57
58
FormatSegment
() :
59
text
(
""
),
60
style
(0),
61
hasColorOverride
(false),
62
colorOverride
(0, 0, 0, 255),
// Default black color
63
hasSizeOverride
(false),
64
sizeOverride
(0),
65
indentPixels
(0),
66
isHorizontalRule
(false),
67
isBulletItem
(false),
68
justification
(
JUSTIFY_NONE
)
69
{
70
}
71
};
72
109
std::vector<FormatSegment>
ParseFormattedText
(
const
std::string& input,
int
charWidth = 8);
110
117
bool
ParseColor
(
const
std::string& colorStr,
PColor
& outColor);
118
122
std::string
StripFormatting
(
const
std::string& input);
123
124
}
// namespace FormatParser
125
126
#endif
// __FORMATPARSER_H__
PColor
Definition
PColor.h:37
FormatParser
Definition
FormatParser.cpp:6
FormatParser::Justification
Justification
Justification types for paragraph-level alignment.
Definition
FormatParser.h:35
FormatParser::JUSTIFY_CENTER
@ JUSTIFY_CENTER
Definition
FormatParser.h:38
FormatParser::JUSTIFY_LEFT
@ JUSTIFY_LEFT
Definition
FormatParser.h:37
FormatParser::JUSTIFY_NONE
@ JUSTIFY_NONE
Definition
FormatParser.h:36
FormatParser::JUSTIFY_RIGHT
@ JUSTIFY_RIGHT
Definition
FormatParser.h:39
FormatParser::ParseFormattedText
std::vector< FormatSegment > ParseFormattedText(const std::string &input, int charWidth)
Parse formatted text into segments.
Definition
FormatParser.cpp:56
FormatParser::StripFormatting
std::string StripFormatting(const std::string &input)
Strip all formatting tags from text.
Definition
FormatParser.cpp:395
FormatParser::ParseColor
bool ParseColor(const std::string &colorStr, PColor &outColor)
Definition
FormatParser.cpp:18
FormatParser::FormatSegment
Definition
FormatParser.h:44
FormatParser::FormatSegment::text
std::string text
Definition
FormatParser.h:45
FormatParser::FormatSegment::hasColorOverride
bool hasColorOverride
Definition
FormatParser.h:47
FormatParser::FormatSegment::style
int style
Definition
FormatParser.h:46
FormatParser::FormatSegment::FormatSegment
FormatSegment()
Definition
FormatParser.h:58
FormatParser::FormatSegment::isHorizontalRule
bool isHorizontalRule
Definition
FormatParser.h:54
FormatParser::FormatSegment::colorOverride
PColor colorOverride
Definition
FormatParser.h:48
FormatParser::FormatSegment::justification
Justification justification
Definition
FormatParser.h:56
FormatParser::FormatSegment::indentPixels
int indentPixels
Definition
FormatParser.h:53
FormatParser::FormatSegment::hasSizeOverride
bool hasSizeOverride
Definition
FormatParser.h:49
FormatParser::FormatSegment::sizeOverride
int sizeOverride
Definition
FormatParser.h:50
FormatParser::FormatSegment::isBulletItem
bool isBulletItem
Definition
FormatParser.h:55
src
utility
FormatParser.h
Generated by
1.9.8