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
32namespace FormatParser {
33
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
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
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),
69 {
70 }
71};
72
109std::vector<FormatSegment> ParseFormattedText(const std::string& input, int charWidth = 8);
110
117bool ParseColor(const std::string& colorStr, PColor& outColor);
118
122std::string StripFormatting(const std::string& input);
123
124} // namespace FormatParser
125
126#endif // __FORMATPARSER_H__
Justification
Justification types for paragraph-level alignment.
std::vector< FormatSegment > ParseFormattedText(const std::string &input, int charWidth)
Parse formatted text into segments.
std::string StripFormatting(const std::string &input)
Strip all formatting tags from text.
bool ParseColor(const std::string &colorStr, PColor &outColor)