29 #ifndef CDPL_VIS_TEXTBLOCKPRIMITIVE2D_HPP
30 #define CDPL_VIS_TEXTBLOCKPRIMITIVE2D_HPP
46 template <
typename C>
class xml_node;
262 bool underlined{
false};
263 bool overlined{
false};
264 bool strikedOut{
false};
265 bool subscripted{
false};
266 bool superscripted{
false};
272 TextFragment(std::string& text,
const Style& style,
const Color& color,
273 bool def_color, std::size_t line):
274 style(style), color(color), defColor(def_color), line(line)
276 this->text.swap(text);
288 typedef rapidxml::xml_node<char> XMLNode;
289 typedef std::vector<Color> ColorStack;
290 typedef std::vector<Style> StyleStack;
291 typedef std::vector<TextFragment> TextFragmentList;
293 void processText(
const std::string& text);
294 void processNode(XMLNode* node);
296 void applyStyle(Font& font,
const Style& style)
const;
302 unsigned int alignment;
304 ColorStack colorStack;
305 StyleStack styleStack;
308 std::size_t currLine;
309 TextFragmentList textFragments;
Definition of the class CDPL::Vis::Font.
Definition of the class CDPL::Vis::GraphicsPrimitive2D.
Definition of the class CDPL::Vis::Pen.
Definition of vector data types.
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
An interface class with methods that provide information about the metrics of a font.
Definition: FontMetrics.hpp:71
Specifies a font for drawing text.
Definition: Font.hpp:54
The abstract base class of all 2D graphics primitives.
Definition: GraphicsPrimitive2D.hpp:57
std::shared_ptr< GraphicsPrimitive2D > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated GraphicsPrimitive2D instances.
Definition: GraphicsPrimitive2D.hpp:63
Specifies how to draw lines and outlines of shapes.
Definition: Pen.hpp:53
Specifies an axis aligned rectangular area in 2D space.
Definition: Rectangle2D.hpp:51
An interface that provides methods for low level 2D drawing operations.
Definition: Renderer2D.hpp:86
A graphics primitive representing a block of styled text.
Definition: TextBlockPrimitive2D.hpp:69
const Pen & getPen() const
Returns the pen defining the default text color.
void setText(const std::string &text)
Specifies the block's text content.
TextBlockPrimitive2D()
Construct an empty text block primitive at position (0, 0).
const Math::Vector2D & getPosition() const
Returns the position of the text block.
bool hasText() const
Tells whether the text block has any visible text (includes whitespace).
double getLineSpacing() const
Returns the active line spacing value.
std::shared_ptr< TextBlockPrimitive2D > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated TextBlockPrimitive2D instances.
Definition: TextBlockPrimitive2D.hpp:75
void render(Renderer2D &renderer) const
Visualizes the graphics primitive by means of the Renderer2D instance renderer.
void clearText()
Clears the block's text content.
GraphicsPrimitive2D::SharedPointer clone() const
Creates a dynamically allocated copy of the graphics primitive.
void setPosition(double x, double y)
Sets the position of the text block to (x, y).
void setLineSpacing(double spacing)
Sets the line spacing value.
void setAlignment(unsigned int alignment)
Specifies the way lines should be horizontally aligned.
void layout(FontMetrics &font_metrics)
Performs a layout of the text for the currently specified font using the provided Vis::FontMetrics in...
unsigned int getAlignment() const
Returns the active horizontal text alignment specification.
void setFont(const Font &font)
Sets the font used for text rendering.
const Font & getFont() const
Returns the font used for text rendering.
void getBounds(Rectangle2D &bounds, FontMetrics *font_metrics) const
Calculates the bounds of the graphics primitive.
const std::string & getText() const
Returns the block's text content.
void setPen(const Pen &pen)
Sets the pen defining the default text color.
void setPosition(const Math::Vector2D &pos)
Sets the position of the text block in 2D space.
CVector< double, 2 > Vector2D
A bounded 2 element vector holding floating point values of type double.
Definition: Vector.hpp:1632
CDPL_VIS_API const Color & getColor(const Chem::Atom &atom)
The namespace of the Chemical Data Processing Library.