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
jkqtmathtextverticallistnode.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 JKQTMATHTEXTVERTCALLISTNODE_H
25#define JKQTMATHTEXTVERTCALLISTNODE_H
26#include "jkqtmathtext/jkqtmathtext_imexport.h"
27#include "jkqtmathtext/jkqtmathtexttools.h"
28#include "jkqtmathtext/nodes/jkqtmathtextnode.h"
29#include <QPainter>
30#include <QFontMetricsF>
31
32class JKQTMathText; // forward
33// JKQTMATHTEXT_LIB_EXPORT
34
35
36/** \brief subclass representing a list of nodes in the syntax tree, layed out vertically
37 * \ingroup jkqtmathtext_items
38 *
39 * Each child can be thought of as a line, so this node represents a list of lines.
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 *
48 * \see JKQTMathTextHorizontalListNode
49 */
51 public:
52
53 explicit JKQTMathTextVerticalListNode(JKQTMathText* parent, JKQTMathTextHorizontalAlignment _alignment=MTHACentered, double _linespacingFactor=1.0, JKQTMathTextLineSpacingMode spacingMode_=MTSMDefaultSpacing, JKQTMathTextVerticalOrientation _verticalOrientation=MTVOFirstLine);
55 /** \copydoc JKQTMathTextNode::getTypeName() */
56 virtual QString getTypeName() const override;
57 /** \copydoc JKQTMathTextNode::draw() */
58 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
59 /** \copydoc JKQTMathTextNode::toHtml() */
60 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
61 /** \brief add a child node */
63 /** \copydoc JKQTMathTextMultiChildNode::getChildren() */
64 virtual QList<JKQTMathTextNode*> getChildren() override;
65 /** \copydoc JKQTMathTextMultiChildNode::childCount() */
66 virtual int childCount() const override;
67 /** \copydoc JKQTMathTextMultiChildNode::clearChildren() */
68 virtual void clearChildren(bool deleteChildren=true) override;
69 /** \copydoc JKQTMathTextMultiChildNode::deleteChild() */
70 virtual void deleteChild(int i) override;
71 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
72 virtual JKQTMathTextNode* getChild(int i) override;
73 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
74 virtual const JKQTMathTextNode* getChild(int i) const override;
75 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
76 virtual JKQTMathTextNode* replaceChild(int i, JKQTMathTextNode* newChild) override;
77 /** \copydoc alignment */
79 /** \copydoc verticalOrientation */
81 /** \copydoc lineSpacingFactor */
82 double getLineSpacingFactor() const;
83 /** \copydoc spacingMode */
84 JKQTMathTextLineSpacingMode getSpacingMode() const;
85 /** \copydoc alignment */
87 /** \copydoc verticalOrientation */
89 /** \copydoc lineSpacingFactor */
90 void setLineSpacingFactor(double value);
91 /** \copydoc spacingMode */
92 void setSpacingMode(JKQTMathTextLineSpacingMode value) ;
93 protected:
94 /** \copydoc JKQTMathTextNode::getSizeInternal() */
95 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
96
97 /** \brief describes the layout of the whole node */
100 LayoutInfo(const LayoutInfo& other);
104 /** \brief drawing position for each line */
105 QList<QPointF> X;
106 };
107 /** \brief calclates the layout of the whole block/node */
108 LayoutInfo calcLayout(QPainter& painter, JKQTMathTextEnvironment currentEv) const;
109
110 /** \brief list of child nodes, each representing one line */
111 QList<JKQTMathTextNode*> nodes;
112 /** \brief alignment scheme used to lay out all lines
113 *
114 * \image html jkqtmathtext_horizontalalignment.png
115 */
117 /** \brief spacing of the separate lines, as factor of the default line-spacing [Default: 1].
118 *
119 * This property can be used to move the lines closer together or farther apart.
120 *
121 * \image html jkqtmathtext_verticallist.png
122 */
124 /** \brief vertical orientation of the baseline of the whole block (with respect to the single lines)
125 *
126 * \image html jkqtmathtext_verticalorientation.png
127 */
129 /** \brief defines how the layout algorithm (see calcLayout() ) lays out the single lines */
130 JKQTMathTextLineSpacingMode spacingMode;
131
132
133
134 private:
135 /** \brief internal implementation of clearChildren() that is non-virtual, so can be used in the destructor */
136 void clearChildrenImpl(bool deleteChildren);
137};
138
139
140
141#endif // JKQTMATHTEXTVERTCALLISTNODE_H
142
143
144
145
146
147
148
149
150
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
subclass representing a node in the syntax tree, that has two children
Definition jkqtmathtextnode.h:202
subclass representing one node in the syntax tree
Definition jkqtmathtextnode.h:37
subclass representing a list of nodes in the syntax tree, layed out vertically
Definition jkqtmathtextverticallistnode.h:50
JKQTMathTextVerticalOrientation verticalOrientation
vertical orientation of the baseline of the whole block (with respect to the single lines)
Definition jkqtmathtextverticallistnode.h:128
virtual const JKQTMathTextNode * getChild(int i) const override
returns the i-th child node
void setAlignment(JKQTMathTextHorizontalAlignment value)
alignment scheme used to lay out all lines
JKQTMathTextVerticalListNode(JKQTMathText *parent, JKQTMathTextHorizontalAlignment _alignment=MTHACentered, double _linespacingFactor=1.0, JKQTMathTextLineSpacingMode spacingMode_=MTSMDefaultSpacing, JKQTMathTextVerticalOrientation _verticalOrientation=MTVOFirstLine)
JKQTMathTextVerticalOrientation getVerticalOrientation() const
vertical orientation of the baseline of the whole block (with respect to the single lines)
void setLineSpacingFactor(double value)
spacing of the separate lines, as factor of the default line-spacing [Default: 1].
virtual JKQTMathTextNode * getChild(int i) override
returns the i-th child node
void setSpacingMode(JKQTMathTextLineSpacingMode value)
defines how the layout algorithm (see calcLayout() ) lays out the single lines
void clearChildrenImpl(bool deleteChildren)
internal implementation of clearChildren() that is non-virtual, so can be used in the destructor
JKQTMathTextLineSpacingMode spacingMode
defines how the layout algorithm (see calcLayout() ) lays out the single lines
Definition jkqtmathtextverticallistnode.h:130
virtual QString getTypeName() const override
return the name of this class as a string
QList< JKQTMathTextNode * > nodes
list of child nodes, each representing one line
Definition jkqtmathtextverticallistnode.h:111
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
JKQTMathTextHorizontalAlignment alignment
alignment scheme used to lay out all lines
Definition jkqtmathtextverticallistnode.h:116
double getLineSpacingFactor() const
spacing of the separate lines, as factor of the default line-spacing [Default: 1].
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
virtual void deleteChild(int i) override
delete the i-th child
JKQTMathTextLineSpacingMode getSpacingMode() const
defines how the layout algorithm (see calcLayout() ) lays out the single lines
double lineSpacingFactor
spacing of the separate lines, as factor of the default line-spacing [Default: 1].
Definition jkqtmathtextverticallistnode.h:123
virtual ~JKQTMathTextVerticalListNode() override
void addChild(JKQTMathTextNode *n)
add a child node
virtual void clearChildren(bool deleteChildren=true) override
clear all children, deleting them if deleteChildren==true
LayoutInfo calcLayout(QPainter &painter, JKQTMathTextEnvironment currentEv) const
calclates the layout of the whole block/node
void setVerticalOrientation(JKQTMathTextVerticalOrientation value)
vertical orientation of the baseline of the whole block (with respect to the single lines)
JKQTMathTextHorizontalAlignment getAlignment() const
alignment scheme used to lay out all lines
virtual JKQTMathTextNode * replaceChild(int i, JKQTMathTextNode *newChild) override
returns the i-th child node
virtual bool toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override
convert node to HTML and returns true on success
virtual QList< JKQTMathTextNode * > getChildren() override
returns a list of all child node
virtual int childCount() const override
returns the number of child nodes
#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
@ MTHACentered
align centered
Definition jkqtmathtexttools.h:663
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 jkqtmathtextverticallistnode.h:98
QList< QPointF > X
drawing position for each line
Definition jkqtmathtextverticallistnode.h:105
LayoutInfo(const JKQTMathTextNodeSize &other)
LayoutInfo(const LayoutInfo &other)
LayoutInfo & operator=(const JKQTMathTextNodeSize &other)
LayoutInfo & operator=(const LayoutInfo &other)