JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtmathtextverbatimnode.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3 with contributions from: Razi Alavizadeh
4
5
6
7 This software is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License (LGPL) as published by
9 the Free Software Foundation, either version 2.1 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License (LGPL) for more details.
16
17 You should have received a copy of the GNU Lesser General Public License (LGPL)
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22
23
24#ifndef JKQTMATHTEXTVERBATIMNODE_H
25#define JKQTMATHTEXTVERBATIMNODE_H
26#include "jkqtmathtext/jkqtmathtext_imexport.h"
27#include "jkqtmathtext/jkqtmathtexttools.h"
28#include "jkqtmathtext/nodes/jkqtmathtextnode.h"
29#include "jkqtmathtext/nodes/jkqtmathtexttextnode.h"
30#include <QPainter>
31
32class JKQTMathText; // forward
33// JKQTMATHTEXT_LIB_EXPORT
34
35
36
37/** \brief subclass representing a verbatim (plain-text) node with support for line-breaks in the syntax tree
38 * \ingroup jkqtmathtext_items
39 *
40 * The layout of the lines can left-aligned, right-aligned or centered.
41 *
42 * \image html jkqtmathtext_verticallist.png
43 *
44 * \image html jkqtmathtext_verticalalignment.png
45 *
46 * \image html jkqtmathtext_horizontalalignment.png
47 */
49 public:
50 explicit JKQTMathTextVerbatimNode(JKQTMathText* parent, const QString& text, bool visibleWhitespace=false, JKQTMathTextHorizontalAlignment _alignment=MTHALeft, double _linespacingFactor=1.0, JKQTMathTextVerticalOrientation _verticalOrientation=MTVOFirstLine, size_t tabSize_=4);
51 /** \copydoc JKQTMathTextNode::getTypeName() */
52 virtual QString getTypeName() const override;
53 /** \copydoc alignment */
55 /** \copydoc verticalOrientation */
57 /** \copydoc lineSpacingFactor */
58 double getLineSpacingFactor() const;
59 /** \copydoc visibleWhitespace */
61 /** \copydoc tabSize */
62 size_t getTabSize() const;
63 /** \copydoc JKQTMathTextNode::draw() */
64 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
65 /** \copydoc JKQTMathTextNode::toHtml() */
66 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
67 protected:
68 /** \brief alignment scheme used to lay out all lines
69 *
70 * \image html jkqtmathtext_horizontalalignment.png
71 */
73 /** \brief spacing of the separate lines, as factor of the default line-spacing [Default: 1].
74 *
75 * This property can be used to move the lines closer together or farther apart.
76 *
77 * \image html jkqtmathtext_verticallist.png
78 */
80 /** \brief vertical orientation of the baseline of the whole block (with respect to the single lines)
81 *
82 * \image html jkqtmathtext_verticalorientation.png
83 */
85 /** \brief when \c true, whitespaces are displayed with a visible character */
87 /** \brief number of whitespaces, each tab character stands for */
88 size_t tabSize;
89
90 /** \copydoc JKQTMathTextNode::getSizeInternal() */
91 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
92 /** \brief sets all necessary settings in \a currentEv for drawing this node */
93 virtual void transformEnvironment(JKQTMathTextEnvironment& currentEv) const;
94
95 /** \brief describes the layout of the whole node */
98 /** \brief the text from JKQTMathTextVerbatimNode::text, split into lines */
99 QStringList lines;
100 /** \brief drawing position for each line */
101 QList<QPointF> X;
102 };
103 /** \brief calclates the layout of the whole block/node
104 *
105 * \note This function does NOT call transformEnvironment();
106 * it has to be called before calling this!
107 */
108 LayoutInfo calcLayout(QPainter& painter, const JKQTMathTextEnvironment& currentEv) const;
109 /** \brief transforms the \a text before sizing/drawing (may e.g. exchange special letters for other unicode symbols etc.) */
110 virtual QString textTransform(const QString& text, const JKQTMathTextEnvironment& currentEv) const override;
111};
112
113
114#endif // JKQTMATHTEXTVERBATIMNODE_H
115
116
117
118
119
120
121
122
123
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
base class for nodes representing text in the syntax tree
Definition jkqtmathtexttextnode.h:44
subclass representing a verbatim (plain-text) node with support for line-breaks in the syntax tree
Definition jkqtmathtextverbatimnode.h:48
size_t getTabSize() const
number of whitespaces, each tab character stands for
double lineSpacingFactor
spacing of the separate lines, as factor of the default line-spacing [Default: 1].
Definition jkqtmathtextverbatimnode.h:79
double getLineSpacingFactor() const
spacing of the separate lines, as factor of the default line-spacing [Default: 1].
virtual QString getTypeName() const override
return the name of this class as a string
JKQTMathTextVerticalOrientation verticalOrientation
vertical orientation of the baseline of the whole block (with respect to the single lines)
Definition jkqtmathtextverbatimnode.h:84
virtual QString textTransform(const QString &text, const JKQTMathTextEnvironment &currentEv) const override
transforms the text before sizing/drawing (may e.g. exchange special letters for other unicode symbol...
virtual bool toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override
convert node to HTML and returns true on success
size_t tabSize
number of whitespaces, each tab character stands for
Definition jkqtmathtextverbatimnode.h:88
bool visibleWhitespace
when true, whitespaces are displayed with a visible character
Definition jkqtmathtextverbatimnode.h:86
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
JKQTMathTextHorizontalAlignment getAlignment() const
alignment scheme used to lay out all lines
JKQTMathTextVerticalOrientation getVerticalOrientation() const
vertical orientation of the baseline of the whole block (with respect to the single lines)
LayoutInfo calcLayout(QPainter &painter, const JKQTMathTextEnvironment &currentEv) const
calclates the layout of the whole block/node
JKQTMathTextHorizontalAlignment alignment
alignment scheme used to lay out all lines
Definition jkqtmathtextverbatimnode.h:72
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
virtual void transformEnvironment(JKQTMathTextEnvironment &currentEv) const
sets all necessary settings in currentEv for drawing this node
JKQTMathTextVerbatimNode(JKQTMathText *parent, const QString &text, bool visibleWhitespace=false, JKQTMathTextHorizontalAlignment _alignment=MTHALeft, double _linespacingFactor=1.0, JKQTMathTextVerticalOrientation _verticalOrientation=MTVOFirstLine, size_t tabSize_=4)
bool getVisibleWhitespace() const
when true, whitespaces are displayed with a visible character
#define JKQTMATHTEXT_LIB_EXPORT
Definition jkqtmathtext_imexport.h:108
JKQTMathTextVerticalOrientation
type of ffractions represented by JKQTMathTextFracNode
Definition jkqtmathtexttools.h:682
JKQTMathTextHorizontalAlignment
types of horizontal alignment
Definition jkqtmathtexttools.h:661
@ MTVOFirstLine
baseline of the whole block is at the baseline of the first line
Definition jkqtmathtexttools.h:684
@ MTHALeft
align left
Definition jkqtmathtexttools.h:662
describes the current drawing environment (base fontname ...)
Definition jkqtmathtexttools.h:304
beschreibt die Größe(n) eines Knotens
Definition jkqtmathtexttools.h:393
describes the layout of the whole node
Definition jkqtmathtextverbatimnode.h:96
QStringList lines
the text from JKQTMathTextVerbatimNode::text, split into lines
Definition jkqtmathtextverbatimnode.h:99
QList< QPointF > X
drawing position for each line
Definition jkqtmathtextverbatimnode.h:101