JKQTMathText: Code Cleanup: using JKQTMathTextNodeSize for all size-calculation functions and got rid of all functions that take the output parameters with call-by-reference
JKQTMathText: JKQTMathTextBraceNode now properly supports different opening and closing braces e.g. |...> for bra-vetors
@ -58,6 +58,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
|||||||
<li>IMPROVED/REWORKED rendering of blackboard font: now several different rendering modes can be selected using JKQTMathText::setFontBlackboradMode()</li>
|
<li>IMPROVED/REWORKED rendering of blackboard font: now several different rendering modes can be selected using JKQTMathText::setFontBlackboradMode()</li>
|
||||||
<li>BREAKING/REWORKED: The \\verb!...!-command now works the same as in LaTeX</li>
|
<li>BREAKING/REWORKED: The \\verb!...!-command now works the same as in LaTeX</li>
|
||||||
<li>BREAKING/CLEANUP: cleanup: Removed Parameter prevNodeSize from JKQTMathTextNode::draw() and JKQTMathTextNode::getSize()/JKQTMathTextNode::getSizeInternal(), since it is only really necessary for JKQTMathTextSubscriptNode and JKQTMathTextSuperscriptNode</li>
|
<li>BREAKING/CLEANUP: cleanup: Removed Parameter prevNodeSize from JKQTMathTextNode::draw() and JKQTMathTextNode::getSize()/JKQTMathTextNode::getSizeInternal(), since it is only really necessary for JKQTMathTextSubscriptNode and JKQTMathTextSuperscriptNode</li>
|
||||||
|
<li>BREAKING/CLEANUP: using JKQTMathTextNodeSize for all size-calculation functions and got rid of all functions that take the output parameters with call-by-reference, additional information can be outut by local size-classes that derive from JKQTMathTextNodeSize, see e.g. JKQTMathTextSymbolNode::NodeSize and JKQTMathTextSymbolNode::getSymbolSize()</li>
|
||||||
<li>NEW: JKQTMathTextVerticalListNode allows to typeset a vertical list of lines</li>
|
<li>NEW: JKQTMathTextVerticalListNode allows to typeset a vertical list of lines</li>
|
||||||
<li>NEW: JKQTMathText::parse() by default allows linebreaks in the LaTeX string to be parsed. This can be switched off by a parameter</li>
|
<li>NEW: JKQTMathText::parse() by default allows linebreaks in the LaTeX string to be parsed. This can be switched off by a parameter</li>
|
||||||
<li>NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request <a href="https://github.com/jkriege2/JKQtPlotter/issues/76">#76</a> from <a href="https://github.com/igormironchik">user:igormironchik</a> </li>
|
<li>NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request <a href="https://github.com/jkriege2/JKQtPlotter/issues/76">#76</a> from <a href="https://github.com/igormironchik">user:igormironchik</a> </li>
|
||||||
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
@ -38,7 +38,7 @@ jkqtmathtext_limits.png
|
|||||||
no specifier: $\sum_{i=0}^\infty k_i^2\ \ \lim_{x\rightarrow0}f(x)\ \ \nabla_{x}f(x)$ \ \ \ \ \ {\backslash}limits: $\sum\limits_{i=0}^\infty k_i^2\ \ \lim\limits_{x\rightarrow0}f(x)\ \ \nabla\limits_{x}f(x)$ \ \ \ \ \ {\backslash}nolimits: $\sum\nolimits_{i=0}^\infty k_i^2\ \ \lim\nolimits_{x\rightarrow0}f(x)\ \ \nabla\nolimits_{x}f(x)$
|
no specifier: $\sum_{i=0}^\infty k_i^2\ \ \lim_{x\rightarrow0}f(x)\ \ \nabla_{x}f(x)$ \ \ \ \ \ {\backslash}limits: $\sum\limits_{i=0}^\infty k_i^2\ \ \lim\limits_{x\rightarrow0}f(x)\ \ \nabla\limits_{x}f(x)$ \ \ \ \ \ {\backslash}nolimits: $\sum\nolimits_{i=0}^\infty k_i^2\ \ \lim\nolimits_{x\rightarrow0}f(x)\ \ \nabla\nolimits_{x}f(x)$
|
||||||
---
|
---
|
||||||
jkqtmathtext_doc_subsupershift_integral.png
|
jkqtmathtext_doc_subsupershift_integral.png
|
||||||
--fontsoze=30
|
--fontsize=30
|
||||||
sub-/superscript:\\
|
sub-/superscript:\\
|
||||||
\begin{tabular}{c:c|c:c}
|
\begin{tabular}{c:c|c:c}
|
||||||
shifted & subs. shifted & unshifted & unshifted\\\hdashline
|
shifted & subs. shifted & unshifted & unshifted\\\hdashline
|
||||||
@ -46,7 +46,7 @@ $\int\limits_{\textcolor{blue}{\leftarrow}}^{\textcolor{blue}{\rightarrow}}$ & $
|
|||||||
\end{tabular}
|
\end{tabular}
|
||||||
---
|
---
|
||||||
jkqtmathtext_doc_subsupershift_integral_boxes.png
|
jkqtmathtext_doc_subsupershift_integral_boxes.png
|
||||||
--drawboxes --fontsoze=30
|
--drawboxes --fontsize=30
|
||||||
sub-/superscript:\\
|
sub-/superscript:\\
|
||||||
\begin{tabular}{c:c|c:c}
|
\begin{tabular}{c:c|c:c}
|
||||||
shifted & subs. shifted & unshifted & unshifted\\\hdashline
|
shifted & subs. shifted & unshifted & unshifted\\\hdashline
|
||||||
@ -54,7 +54,7 @@ $\int\limits_{\textcolor{blue}{\leftarrow}}^{\textcolor{blue}{\rightarrow}}$ & $
|
|||||||
\end{tabular}
|
\end{tabular}
|
||||||
---
|
---
|
||||||
jkqtmathtext_doc_subsuper_italiccorrection.png
|
jkqtmathtext_doc_subsuper_italiccorrection.png
|
||||||
--fontsoze=30
|
--fontsize=30
|
||||||
sub-/superscript:\\
|
sub-/superscript:\\
|
||||||
\begin{tabular}{c|c}
|
\begin{tabular}{c|c}
|
||||||
italic-correction & no correction\\\hdashline
|
italic-correction & no correction\\\hdashline
|
||||||
@ -62,7 +62,7 @@ $x_\textcolor{blue}{\leftarrow}^\textcolor{red}{0}$ & $\mathrm{M}_\textcolor{red
|
|||||||
\end{tabular}
|
\end{tabular}
|
||||||
---
|
---
|
||||||
jkqtmathtext_doc_subsuper_italiccorrection_boxes.png
|
jkqtmathtext_doc_subsuper_italiccorrection_boxes.png
|
||||||
--drawboxes --fontsoze=30
|
--drawboxes --fontsize=30
|
||||||
sub-/superscript:\\
|
sub-/superscript:\\
|
||||||
\begin{tabular}{c|c}
|
\begin{tabular}{c|c}
|
||||||
italic-correction & no correction\\\hdashline
|
italic-correction & no correction\\\hdashline
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
\item \sout{x \fbox{\ } \fbox{\hspace*{1cm}} \fbox{\vspace*{2cm}}}
|
||||||
\item $x_1^2 X_1^2 q_1^2$
|
\item $x_1^2 X_1^2 q_1^2$
|
||||||
\item\textbf{Text: Umlaute \& fonts: }\\ rm: \textrm{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
\item\textbf{Text: Umlaute \& fonts: }\\ rm: \textrm{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
||||||
it: \textit{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
it: \textit{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
||||||
|
@ -509,7 +509,7 @@ JKQTMathTextFontEncoding JKQTMathTextEnvironment::getFontEncoding(JKQTMathText*
|
|||||||
return MTFEStandard;
|
return MTFEStandard;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont JKQTMathTextEnvironment::getFont(JKQTMathText* parent) const {
|
QFont JKQTMathTextEnvironment::getFont(const JKQTMathText* parent) const {
|
||||||
QFont f;
|
QFont f;
|
||||||
switch (font) {
|
switch (font) {
|
||||||
case MTEsans: if (insideMath) {
|
case MTEsans: if (insideMath) {
|
||||||
|
@ -301,7 +301,7 @@ struct JKQTMATHTEXT_LIB_EXPORT JKQTMathTextEnvironment {
|
|||||||
|
|
||||||
|
|
||||||
/** \brief build a <a href="https://doc.qt.io/qt-5/qfont.html">QFont</a> object from the settings in this object */
|
/** \brief build a <a href="https://doc.qt.io/qt-5/qfont.html">QFont</a> object from the settings in this object */
|
||||||
QFont getFont(JKQTMathText* parent) const;
|
QFont getFont(const JKQTMathText *parent) const;
|
||||||
/** \brief return a copy of this object with the font exchanged for \a font */
|
/** \brief return a copy of this object with the font exchanged for \a font */
|
||||||
JKQTMathTextEnvironment exchangedFontFor(JKQTMathTextEnvironmentFont font) const;
|
JKQTMathTextEnvironment exchangedFontFor(JKQTMathTextEnvironmentFont font) const;
|
||||||
/** \brief return a copy of this object with the font exchanged for the matching roman font */
|
/** \brief return a copy of this object with the font exchanged for the matching roman font */
|
||||||
|
@ -47,25 +47,21 @@ JKQTMathTextBraceNode::JKQTMathTextBraceNode(JKQTMathText* _parent, JKQTMathText
|
|||||||
JKQTMathTextBraceNode::~JKQTMathTextBraceNode() {
|
JKQTMathTextBraceNode::~JKQTMathTextBraceNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextBraceNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextBraceNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
double braceWidth=0, braceHeight=0;
|
return getSizeInternalAndBrace(painter, currentEv);
|
||||||
getSizeInternalAndBrace(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos, braceWidth, braceHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextBraceNode::getSizeInternalAndBrace(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos, double &bracewidth, double &braceheight)
|
JKQTMathTextBraceNode::NodeSize JKQTMathTextBraceNode::getSizeInternalAndBrace(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
width=0;
|
NodeSize s;
|
||||||
baselineHeight=0;
|
const NodeSize childSize=getChild()->getSize(painter, currentEv);
|
||||||
overallHeight=0;
|
|
||||||
strikeoutPos=0;
|
|
||||||
getChild()->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
const double minChildHeight=fm.tightBoundingRect("l").height();
|
const double minChildHeight=fm.tightBoundingRect("l").height();
|
||||||
|
|
||||||
double cAscentAboveStrike=0;
|
double cAscentAboveStrike=0;
|
||||||
double cDescentBelowStrike=0;
|
double cDescentBelowStrike=0;
|
||||||
cAscentAboveStrike=qMax(minChildHeight-strikeoutPos, baselineHeight-strikeoutPos);
|
cAscentAboveStrike=qMax(minChildHeight-childSize.strikeoutPos, childSize.baselineHeight-childSize.strikeoutPos);
|
||||||
cDescentBelowStrike=qMax(strikeoutPos, overallHeight-baselineHeight+strikeoutPos);
|
cDescentBelowStrike=qMax(childSize.strikeoutPos, childSize.getDescent()+childSize.strikeoutPos);
|
||||||
|
|
||||||
//qDebug()<<"getSizeInternalAndBrace(): showOpeningBrace="<<showOpeningBrace<<", openbrace="<<openbrace<<", showClosingBrace="<<showClosingBrace<<", closebrace="<<closebrace;
|
//qDebug()<<"getSizeInternalAndBrace(): showOpeningBrace="<<showOpeningBrace<<", openbrace="<<openbrace<<", showClosingBrace="<<showClosingBrace<<", closebrace="<<closebrace;
|
||||||
//qDebug()<<"getSizeInternalAndBrace(): child: baselineHeight="<<baselineHeight<<", strikeoutPos="<<strikeoutPos<<", overallHeight="<<overallHeight;
|
//qDebug()<<"getSizeInternalAndBrace(): child: baselineHeight="<<baselineHeight<<", strikeoutPos="<<strikeoutPos<<", overallHeight="<<overallHeight;
|
||||||
@ -73,29 +69,25 @@ void JKQTMathTextBraceNode::getSizeInternalAndBrace(QPainter &painter, JKQTMathT
|
|||||||
|
|
||||||
const double heightAboveBelowStrike=qMax(cAscentAboveStrike, cDescentBelowStrike);
|
const double heightAboveBelowStrike=qMax(cAscentAboveStrike, cDescentBelowStrike);
|
||||||
|
|
||||||
|
s.width=childSize.width;
|
||||||
baselineHeight=strikeoutPos+heightAboveBelowStrike*parentMathText->getBraceFactor();
|
s.strikeoutPos=childSize.strikeoutPos;
|
||||||
overallHeight=2.0*heightAboveBelowStrike*parentMathText->getBraceFactor(); //fm.height();
|
s.baselineHeight=childSize.strikeoutPos+heightAboveBelowStrike*parentMathText->getBraceFactor();
|
||||||
|
s.overallHeight=2.0*heightAboveBelowStrike*parentMathText->getBraceFactor(); //fm.height();
|
||||||
|
|
||||||
//qDebug()<<"getSizeInternalAndBrace(): heightAboveBelowStrike="<<heightAboveBelowStrike<<", baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight;
|
//qDebug()<<"getSizeInternalAndBrace(): heightAboveBelowStrike="<<heightAboveBelowStrike<<", baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight;
|
||||||
|
|
||||||
bracewidth=0;
|
calcBraceSizes(s, painter, currentEv, childSize);
|
||||||
braceheight=0;
|
|
||||||
getBraceSize(painter, currentEv, baselineHeight, overallHeight, bracewidth, braceheight);
|
|
||||||
|
|
||||||
if (openbrace!=MTBTNone && openbrace!=MTBTAny) width+=bracewidth;
|
if (openbrace!=MTBTNone && openbrace!=MTBTAny) s.width+=s.openBraceWidth;
|
||||||
if (closebrace!=MTBTNone && closebrace!=MTBTAny) width+=bracewidth;
|
if (closebrace!=MTBTNone && closebrace!=MTBTAny) s.width+=s.closeBraceWidth;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
//std::cout<<"drawing brace-node: '"<<openbrace.toStdString()<<"' ... '"<<closebrace.toStdString()<<"'\n";
|
//std::cout<<"drawing brace-node: '"<<openbrace.toStdString()<<"' ... '"<<closebrace.toStdString()<<"'\n";
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
|
||||||
|
|
||||||
double nodeWidth=0;
|
const NodeSize nodesize=getSizeInternalAndBrace(painter, currentEv);
|
||||||
double nodeBaselineHeight=0;
|
doDrawBoxes(painter, x, y, nodesize);
|
||||||
double nodeOverallHeight=0, nodeStrikeoutPos=0;
|
|
||||||
double bracewidth=0, braceheight=0;
|
|
||||||
getSizeInternalAndBrace(painter, currentEv, nodeWidth, nodeBaselineHeight, nodeOverallHeight, nodeStrikeoutPos, bracewidth, braceheight);
|
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText));
|
const QFontMetricsF fm(currentEv.getFont(parentMathText));
|
||||||
|
|
||||||
const double lw=fm.lineWidth();
|
const double lw=fm.lineWidth();
|
||||||
@ -117,12 +109,12 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
{
|
{
|
||||||
bool showOpeningBrace=true;
|
bool showOpeningBrace=true;
|
||||||
const double xbrace1=xnew+lw;
|
const double xbrace1=xnew+lw;
|
||||||
const double xbrace2=xnew+qMin(paren_fraction*bracewidth, bracewidth-lw/2.0);
|
const double xbrace2=xnew+qMin(paren_fraction*nodesize.openBraceWidth, nodesize.openBraceWidth-lw/2.0);
|
||||||
const double xbraceC=xnew+bracewidth/2.0;
|
const double xbraceC=xnew+nodesize.openBraceWidth/2.0;
|
||||||
if (openbrace==MTBTParenthesis) {
|
if (openbrace==MTBTParenthesis) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const QPointF pb1(xbrace2-paren_topwidth/2.0, y1);
|
const QPointF pb1(xbrace2-paren_topwidth/2.0, y1);
|
||||||
const QPointF pbc1(xbrace1-paren_centerwidth/2.0, (y1+y2)/2.0+fabs(y1-y2)/6.0);
|
const QPointF pbc1(xbrace1-paren_centerwidth/2.0, (y1+y2)/2.0+fabs(y1-y2)/6.0);
|
||||||
const QPointF ptc1(xbrace1-paren_centerwidth/2.0, (y1+y2)/2.0-fabs(y1-y2)/6.0);
|
const QPointF ptc1(xbrace1-paren_centerwidth/2.0, (y1+y2)/2.0-fabs(y1-y2)/6.0);
|
||||||
@ -144,8 +136,8 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
painter.drawLine(pt2,ptc2);*/
|
painter.drawLine(pt2,ptc2);*/
|
||||||
} else if (openbrace==MTBTAngleBracket) {
|
} else if (openbrace==MTBTAngleBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const double yc=(y1+y2)/2.0;
|
const double yc=(y1+y2)/2.0;
|
||||||
const QPointF pb1(xbrace2-paren_topwidth/2.0, y1);
|
const QPointF pb1(xbrace2-paren_topwidth/2.0, y1);
|
||||||
const QPointF pc1(xbrace1-angle_centerwidth/2.0, yc);
|
const QPointF pc1(xbrace1-angle_centerwidth/2.0, yc);
|
||||||
@ -163,8 +155,8 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
painter.fillPath(path, QBrush(currentEv.color, Qt::SolidPattern));
|
painter.fillPath(path, QBrush(currentEv.color, Qt::SolidPattern));
|
||||||
} else if (openbrace==MTBTSquareBracket) {
|
} else if (openbrace==MTBTSquareBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight)-lw/2.0;
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight)-lw/2.0;
|
||||||
const double y2=y-nodeBaselineHeight+lw/2.0;
|
const double y2=y-nodesize.baselineHeight+lw/2.0;
|
||||||
path.moveTo(xbrace2, y1);
|
path.moveTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace1, y1);
|
path.lineTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace1, y2);
|
path.lineTo(xbrace1, y2);
|
||||||
@ -173,7 +165,7 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
} else if (openbrace==MTBTTopCorner) {
|
} else if (openbrace==MTBTTopCorner) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double dx=fabs(xbrace2-xbrace1);
|
const double dx=fabs(xbrace2-xbrace1);
|
||||||
const double y1=y-nodeBaselineHeight+lw/2.0;
|
const double y1=y-nodesize.baselineHeight+lw/2.0;
|
||||||
path.moveTo(xbrace2, y1);
|
path.moveTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace1, y1);
|
path.lineTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace1, y1+dx);
|
path.lineTo(xbrace1, y1+dx);
|
||||||
@ -181,38 +173,38 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
} else if (openbrace==MTBTBottomCorner) {
|
} else if (openbrace==MTBTBottomCorner) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double dx=fabs(xbrace2-xbrace1);
|
const double dx=fabs(xbrace2-xbrace1);
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight)-lw/2.0;
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight)-lw/2.0;
|
||||||
path.moveTo(xbrace2, y1);
|
path.moveTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace1, y1);
|
path.lineTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace1, y1-dx);
|
path.lineTo(xbrace1, y1-dx);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
} else if (openbrace==MTBTCurlyBracket) {
|
} else if (openbrace==MTBTCurlyBracket) {
|
||||||
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0,nodeOverallHeight, bracewidth*paren_fraction, p.widthF());
|
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0,nodesize.overallHeight, nodesize.openBraceWidth*paren_fraction, p.widthF());
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.translate(xbraceC, y-nodeBaselineHeight+nodeOverallHeight/2.0);
|
painter.translate(xbraceC, y-nodesize.baselineHeight+nodesize.overallHeight/2.0);
|
||||||
painter.rotate(90);
|
painter.rotate(90);
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(0.0001);
|
plocal.setWidthF(0.0001);
|
||||||
painter.fillPath(path, QBrush(currentEv.color));
|
painter.fillPath(path, QBrush(currentEv.color));
|
||||||
} else if (openbrace==MTBTFloorBracket) {
|
} else if (openbrace==MTBTFloorBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight)-lw/2.0;
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight)-lw/2.0;
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
path.moveTo(xbrace2, y1);
|
path.moveTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace1, y1);
|
path.lineTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace1, y2);
|
path.lineTo(xbrace1, y2);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
} else if (openbrace==MTBTCeilBracket) {
|
} else if (openbrace==MTBTCeilBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight+lw/2.0;
|
const double y2=y-nodesize.baselineHeight+lw/2.0;
|
||||||
path.moveTo(xbrace1, y1);
|
path.moveTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace1, y2);
|
path.lineTo(xbrace1, y2);
|
||||||
path.lineTo(xbrace2, y2);
|
path.lineTo(xbrace2, y2);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
} else if (openbrace==MTBTSingleLine) {
|
} else if (openbrace==MTBTSingleLine) {
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const QLineF l(xbraceC, y1, xbraceC, y2);
|
const QLineF l(xbraceC, y1, xbraceC, y2);
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
||||||
@ -220,8 +212,8 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
} else if (openbrace==MTBTDoubleLine) {
|
} else if (openbrace==MTBTDoubleLine) {
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
||||||
painter.setPen(plocal);
|
painter.setPen(plocal);
|
||||||
@ -234,7 +226,7 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
showOpeningBrace=false;
|
showOpeningBrace=false;
|
||||||
}
|
}
|
||||||
if (showOpeningBrace) {
|
if (showOpeningBrace) {
|
||||||
xnew=xnew+bracewidth;
|
xnew=xnew+nodesize.openBraceWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,14 +236,14 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
|
|
||||||
{
|
{
|
||||||
bool showClosingBrace=true;
|
bool showClosingBrace=true;
|
||||||
const double xbrace1=qMax(xnew+bracewidth-paren_fraction*bracewidth, xnew+lw/2.0);
|
const double xbrace1=qMax(xnew+nodesize.closeBraceWidth-paren_fraction*nodesize.closeBraceWidth, xnew+lw/2.0);
|
||||||
const double xbrace2=xnew+bracewidth-lw;
|
const double xbrace2=xnew+nodesize.closeBraceWidth-lw;
|
||||||
const double xbraceC=xnew+bracewidth/2.0;
|
const double xbraceC=xnew+nodesize.closeBraceWidth/2.0;
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
if (closebrace==MTBTParenthesis) {
|
if (closebrace==MTBTParenthesis) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const QPointF pb1(xbrace1-paren_topwidth/2.0, y1);
|
const QPointF pb1(xbrace1-paren_topwidth/2.0, y1);
|
||||||
const QPointF pbc1(xbrace2-paren_centerwidth/2.0, (y1+y2)/2.0+fabs(y1-y2)/6.0);
|
const QPointF pbc1(xbrace2-paren_centerwidth/2.0, (y1+y2)/2.0+fabs(y1-y2)/6.0);
|
||||||
const QPointF ptc1(xbrace2-paren_centerwidth/2.0, (y1+y2)/2.0-fabs(y1-y2)/6.0);
|
const QPointF ptc1(xbrace2-paren_centerwidth/2.0, (y1+y2)/2.0-fabs(y1-y2)/6.0);
|
||||||
@ -273,8 +265,8 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
painter.drawLine(pt2,ptc2);*/
|
painter.drawLine(pt2,ptc2);*/
|
||||||
} else if (closebrace==MTBTAngleBracket) {
|
} else if (closebrace==MTBTAngleBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const double yc=(y1+y2)/2.0;
|
const double yc=(y1+y2)/2.0;
|
||||||
const QPointF pb1(xbrace1-paren_topwidth/2.0, y1);
|
const QPointF pb1(xbrace1-paren_topwidth/2.0, y1);
|
||||||
const QPointF pc1(xbrace2-angle_centerwidth/2.0, yc);
|
const QPointF pc1(xbrace2-angle_centerwidth/2.0, yc);
|
||||||
@ -292,8 +284,8 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
painter.fillPath(path, QBrush(currentEv.color, Qt::SolidPattern));
|
painter.fillPath(path, QBrush(currentEv.color, Qt::SolidPattern));
|
||||||
} else if (closebrace==MTBTSquareBracket) {
|
} else if (closebrace==MTBTSquareBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight)-lw/2.0;
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight)-lw/2.0;
|
||||||
const double y2=y-nodeBaselineHeight+lw/2.0;
|
const double y2=y-nodesize.baselineHeight+lw/2.0;
|
||||||
path.moveTo(xbrace1, y1);
|
path.moveTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace2, y1);
|
path.lineTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace2, y2);
|
path.lineTo(xbrace2, y2);
|
||||||
@ -302,7 +294,7 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
} else if (closebrace==MTBTBottomCorner) {
|
} else if (closebrace==MTBTBottomCorner) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double dx=fabs(xbrace1-xbrace2);
|
const double dx=fabs(xbrace1-xbrace2);
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight)-lw/2.0;
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight)-lw/2.0;
|
||||||
path.moveTo(xbrace1, y1);
|
path.moveTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace2, y1);
|
path.lineTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace2, y1-dx);
|
path.lineTo(xbrace2, y1-dx);
|
||||||
@ -310,38 +302,38 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
} else if (closebrace==MTBTTopCorner) {
|
} else if (closebrace==MTBTTopCorner) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double dx=fabs(xbrace1-xbrace2);
|
const double dx=fabs(xbrace1-xbrace2);
|
||||||
const double y1=y-nodeBaselineHeight+lw/2.0;
|
const double y1=y-nodesize.baselineHeight+lw/2.0;
|
||||||
path.moveTo(xbrace1, y1);
|
path.moveTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace2, y1);
|
path.lineTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace2, y1+dx);
|
path.lineTo(xbrace2, y1+dx);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
} else if (closebrace==MTBTCurlyBracket) {
|
} else if (closebrace==MTBTCurlyBracket) {
|
||||||
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0,nodeOverallHeight, bracewidth*paren_fraction, p.widthF());
|
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0,nodesize.overallHeight, nodesize.closeBraceWidth*paren_fraction, p.widthF());
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.translate(xbraceC, y-nodeBaselineHeight+nodeOverallHeight/2.0);
|
painter.translate(xbraceC, y-nodesize.baselineHeight+nodesize.overallHeight/2.0);
|
||||||
painter.rotate(270);
|
painter.rotate(270);
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(0.0001);
|
plocal.setWidthF(0.0001);
|
||||||
painter.fillPath(path, QBrush(currentEv.color));
|
painter.fillPath(path, QBrush(currentEv.color));
|
||||||
} else if (closebrace==MTBTFloorBracket) {
|
} else if (closebrace==MTBTFloorBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight)-lw/2.0;
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight)-lw/2.0;
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
path.moveTo(xbrace1, y1);
|
path.moveTo(xbrace1, y1);
|
||||||
path.lineTo(xbrace2, y1);
|
path.lineTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace2, y2);
|
path.lineTo(xbrace2, y2);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
} else if (closebrace==MTBTCeilBracket) {
|
} else if (closebrace==MTBTCeilBracket) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight+lw/2.0;
|
const double y2=y-nodesize.baselineHeight+lw/2.0;
|
||||||
path.moveTo(xbrace2, y1);
|
path.moveTo(xbrace2, y1);
|
||||||
path.lineTo(xbrace2, y2);
|
path.lineTo(xbrace2, y2);
|
||||||
path.lineTo(xbrace1, y2);
|
path.lineTo(xbrace1, y2);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
} else if (closebrace==MTBTSingleLine) {
|
} else if (closebrace==MTBTSingleLine) {
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const QLineF l(xbraceC, y1, xbraceC, y2);
|
const QLineF l(xbraceC, y1, xbraceC, y2);
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
||||||
@ -349,8 +341,8 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
} else if (closebrace==MTBTDoubleLine) {
|
} else if (closebrace==MTBTDoubleLine) {
|
||||||
const double y1=y+(nodeOverallHeight-nodeBaselineHeight);
|
const double y1=y+(nodesize.overallHeight-nodesize.baselineHeight);
|
||||||
const double y2=y-nodeBaselineHeight;
|
const double y2=y-nodesize.baselineHeight;
|
||||||
const QLineF l(xbraceC-lw, y1, xbraceC-lw, y2);
|
const QLineF l(xbraceC-lw, y1, xbraceC-lw, y2);
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
plocal.setWidthF(plocal.widthF()*absnorm_linewidth_factor);
|
||||||
@ -364,7 +356,7 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
}
|
}
|
||||||
painter.setPen(pold);
|
painter.setPen(pold);
|
||||||
if (showClosingBrace) {
|
if (showClosingBrace) {
|
||||||
xnew=xnew+bracewidth;
|
xnew=xnew+nodesize.closeBraceWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +364,7 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
|||||||
return xnew;
|
return xnew;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextBraceNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextBraceNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
QString ob;
|
QString ob;
|
||||||
QString cb;
|
QString cb;
|
||||||
if (openbrace==MTBTAngleBracket) ob="⟨";
|
if (openbrace==MTBTAngleBracket) ob="⟨";
|
||||||
@ -419,19 +411,85 @@ JKQTMathTextBraceType JKQTMathTextBraceNode::getClosebrace() const {
|
|||||||
return this->closebrace;
|
return this->closebrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextBraceNode::getBraceSize(QPainter &painter, JKQTMathTextEnvironment ev, double /*baselineHeight*/, double overallHeight, double &bracewidth, double &braceheight) const
|
|
||||||
{
|
|
||||||
const QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
|
||||||
const double lw=fm.lineWidth();
|
|
||||||
const double dblline_distance=2.0*lw;
|
|
||||||
braceheight=overallHeight*parentMathText->getBraceFactor();
|
|
||||||
bracewidth=lw*5.0;
|
|
||||||
if (openbrace==MTBTCurlyBracket || closebrace==MTBTCurlyBracket) bracewidth=lw*6.5;
|
|
||||||
if (openbrace==MTBTParenthesis || closebrace==MTBTParenthesis) bracewidth=lw*6.0;
|
|
||||||
if (openbrace==MTBTDoubleLine || closebrace==MTBTDoubleLine) bracewidth=dblline_distance+3.0*lw;
|
|
||||||
if (openbrace==MTBTSingleLine || closebrace==MTBTSingleLine) bracewidth=3.0*lw;
|
|
||||||
|
|
||||||
const double overSizeFactor=braceheight/fm.height();
|
|
||||||
if (overSizeFactor>1.2) bracewidth=bracewidth*sqrt(overSizeFactor);
|
JKQTMathTextBraceNode::NodeSize::NodeSize():
|
||||||
|
JKQTMathTextNodeSize(),
|
||||||
|
openBraceWidth(0.0),
|
||||||
|
openBraceHeight(0.0),
|
||||||
|
closeBraceWidth(0.0),
|
||||||
|
closeBraceHeight(0.0)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JKQTMathTextBraceNode::NodeSize::NodeSize(const JKQTMathTextNodeSize &other):
|
||||||
|
JKQTMathTextNodeSize(other),
|
||||||
|
openBraceWidth(0.0),
|
||||||
|
openBraceHeight(0.0),
|
||||||
|
closeBraceWidth(0.0),
|
||||||
|
closeBraceHeight(0.0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextBraceNode::NodeSize &JKQTMathTextBraceNode::NodeSize::operator=(const JKQTMathTextNodeSize &other)
|
||||||
|
{
|
||||||
|
JKQTMathTextNodeSize::operator=(other);
|
||||||
|
openBraceWidth=0.0;
|
||||||
|
openBraceHeight=0.0;
|
||||||
|
closeBraceWidth=0.0;
|
||||||
|
closeBraceHeight=0.0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextBraceNode::NodeSize &JKQTMathTextBraceNode::NodeSize::operator=(const NodeSize &other)
|
||||||
|
{
|
||||||
|
JKQTMathTextNodeSize::operator=(dynamic_cast<const JKQTMathTextNodeSize&>(other));
|
||||||
|
openBraceWidth=other.openBraceWidth;
|
||||||
|
openBraceHeight=other.openBraceHeight;
|
||||||
|
closeBraceWidth=other.closeBraceWidth;
|
||||||
|
closeBraceHeight=other.closeBraceHeight;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextBraceNode::NodeSize::NodeSize(const NodeSize &other):
|
||||||
|
JKQTMathTextNodeSize(dynamic_cast<const JKQTMathTextNodeSize&>(other)),
|
||||||
|
openBraceWidth(other.openBraceWidth),
|
||||||
|
openBraceHeight(other.openBraceHeight),
|
||||||
|
closeBraceWidth(other.closeBraceWidth),
|
||||||
|
closeBraceHeight(other.closeBraceHeight)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void JKQTMathTextBraceNode::calcBraceSizes(NodeSize& out, QPainter &painter, const JKQTMathTextEnvironment &ev, const JKQTMathTextNodeSize &childSize) const
|
||||||
|
{
|
||||||
|
const QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
||||||
|
const QSizeF openBraceS=calcBraceSize(fm, openbrace, childSize);
|
||||||
|
const QSizeF closeBraceS=calcBraceSize(fm, closebrace, childSize);
|
||||||
|
out.openBraceWidth=openBraceS.width();
|
||||||
|
out.openBraceHeight=openBraceS.width();
|
||||||
|
out.closeBraceWidth=closeBraceS.width();
|
||||||
|
out.closeBraceHeight=closeBraceS.width();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF JKQTMathTextBraceNode::calcBraceSize(const QFontMetricsF &fm, JKQTMathTextBraceType bracetype, const JKQTMathTextNodeSize &childSize) const
|
||||||
|
{
|
||||||
|
double braceWidth=0.0;
|
||||||
|
double braceHeight=0.0;
|
||||||
|
const double lw=fm.lineWidth();
|
||||||
|
const double dblline_distance=2.0*lw;
|
||||||
|
braceHeight=childSize.overallHeight*parentMathText->getBraceFactor();
|
||||||
|
braceWidth=lw*5.0;
|
||||||
|
if (bracetype==MTBTCurlyBracket) braceWidth=lw*6.5;
|
||||||
|
if (bracetype==MTBTParenthesis) braceWidth=lw*6.0;
|
||||||
|
if (bracetype==MTBTDoubleLine) braceWidth=dblline_distance+3.0*lw;
|
||||||
|
if (bracetype==MTBTSingleLine) braceWidth=3.0*lw;
|
||||||
|
|
||||||
|
const double overSizeFactor=braceHeight/fm.height();
|
||||||
|
if (overSizeFactor>1.2) braceWidth=braceWidth*sqrt(overSizeFactor);
|
||||||
|
|
||||||
|
return QSizeF(braceWidth, braceHeight);
|
||||||
|
}
|
||||||
|
@ -48,9 +48,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceNode: public JKQTMathTextSingleCh
|
|||||||
JKQTMathTextBraceNode(JKQTMathText* parent, JKQTMathTextBraceType openbrace, JKQTMathTextBraceType closebrace, JKQTMathTextNode* child);
|
JKQTMathTextBraceNode(JKQTMathText* parent, JKQTMathTextBraceType openbrace, JKQTMathTextBraceType closebrace, JKQTMathTextNode* child);
|
||||||
virtual ~JKQTMathTextBraceNode() override;
|
virtual ~JKQTMathTextBraceNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc openbrace */
|
/** \copydoc openbrace */
|
||||||
@ -58,19 +58,50 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceNode: public JKQTMathTextSingleCh
|
|||||||
/** \copydoc closebrace */
|
/** \copydoc closebrace */
|
||||||
JKQTMathTextBraceType getClosebrace() const;
|
JKQTMathTextBraceType getClosebrace() const;
|
||||||
protected:
|
protected:
|
||||||
|
/** \brief defines the size of the node (JKQTMathTextNodeSize) and additional information */
|
||||||
|
struct NodeSize: public JKQTMathTextNodeSize {
|
||||||
|
NodeSize();
|
||||||
|
NodeSize(const NodeSize& other);
|
||||||
|
NodeSize(const JKQTMathTextNodeSize& other);
|
||||||
|
NodeSize& operator=(const NodeSize& other);
|
||||||
|
NodeSize& operator=(const JKQTMathTextNodeSize& other);
|
||||||
|
/** \brief width of the opening brace */
|
||||||
|
double openBraceWidth;
|
||||||
|
/** \brief height of the opening brace */
|
||||||
|
double openBraceHeight;
|
||||||
|
/** \brief width of the closing brace */
|
||||||
|
double closeBraceWidth;
|
||||||
|
/** \brief height of the closing brace */
|
||||||
|
double closeBraceHeight;
|
||||||
|
};
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal()
|
/** \copydoc JKQTMathTextNode::getSizeInternal()
|
||||||
*
|
*
|
||||||
* \note This function internally calls getSizeInternalAndBrace() and returns part of its results.
|
* \note This function internally calls getSizeInternalAndBrace() and returns part of its results.
|
||||||
*/
|
*/
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** calculates the size of this node (also returned by getSizeInternal() ) and of the brace */
|
/** calculates the size of this node (also returned by getSizeInternal() ) and of the brace */
|
||||||
void getSizeInternalAndBrace(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, double& bracewidth, double&braceheight);
|
NodeSize getSizeInternalAndBrace(QPainter& painter, JKQTMathTextEnvironment currentEv) const;
|
||||||
/**\brief opening brace */
|
/**\brief opening brace */
|
||||||
JKQTMathTextBraceType openbrace;
|
JKQTMathTextBraceType openbrace;
|
||||||
/**\brief closing brace */
|
/**\brief closing brace */
|
||||||
JKQTMathTextBraceType closebrace;
|
JKQTMathTextBraceType closebrace;
|
||||||
/** \brief calculate the width of the brace */
|
/** \brief calculate the width of the braces, fills NodeSize::openbracewidth/NodeSize::closebracewidth and NodeSize::braceheight/NodeSize::closeheight in \a out, based on \a childSize
|
||||||
void getBraceSize(QPainter& painter, JKQTMathTextEnvironment currentEv, double baselineHeight, double overallHeight, double& bracewidth, double& braceheight) const;
|
*
|
||||||
|
* \param[out] out this function fills NodeSize::openbracewidth/NodeSize::closebracewidth and NodeSize::braceheight/NodeSize::closeheight in \a out
|
||||||
|
* \param painter a QPainter used for size-calculation/drawing
|
||||||
|
* \param currentEv font environment
|
||||||
|
* \param childSize size of the child node surrounded by the node
|
||||||
|
*/
|
||||||
|
void calcBraceSizes(NodeSize& out, QPainter& painter, const JKQTMathTextEnvironment& currentEv, const JKQTMathTextNodeSize &childSize) const;
|
||||||
|
/** \brief calculate the width and height of a brace, based on \a childSize
|
||||||
|
*
|
||||||
|
* \param fm QFontMetricsF object describing the font of the current environment
|
||||||
|
* \param bracetype brace type
|
||||||
|
* \param childSize size of the child node surrounded by the node
|
||||||
|
*
|
||||||
|
* \return width and hieght of the brace
|
||||||
|
*/
|
||||||
|
QSizeF calcBraceSize(const QFontMetricsF& fm, JKQTMathTextBraceType bracetype, const JKQTMathTextNodeSize &childSize) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JKQTMATHTEXTBRACENODE_H
|
#endif // JKQTMATHTEXTBRACENODE_H
|
||||||
|
@ -129,28 +129,28 @@ JKQTMathTextDecoratedNode::JKQTMathTextDecoratedNode(JKQTMathText* _parent, Deco
|
|||||||
JKQTMathTextDecoratedNode::~JKQTMathTextDecoratedNode() {
|
JKQTMathTextDecoratedNode::~JKQTMathTextDecoratedNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
|
JKQTMathTextNodeSize s;
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
double cwidth=0, cbaselineHeight=0, coverallHeight=0, cstrikeoutPos=0;
|
JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, cwidth, cbaselineHeight, coverallHeight, cstrikeoutPos);
|
const double cDescent=cs.getDescent();
|
||||||
const double cDescent=coverallHeight-cbaselineHeight;
|
|
||||||
const QFont font=ev.getFont(parentMathText);
|
const QFont font=ev.getFont(parentMathText);
|
||||||
const QFontMetricsF fm(font, painter.device());
|
const QFontMetricsF fm(font, painter.device());
|
||||||
const double decoSeparation=parentMathText->getDecorationSeparationFactor()*fm.ascent();
|
const double decoSeparation=parentMathText->getDecorationSeparationFactor()*fm.ascent();
|
||||||
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
|
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
|
||||||
const double deco_ypos=cbaselineHeight+decoSeparation;
|
const double deco_ypos=cs.baselineHeight+decoSeparation;
|
||||||
const double decoAboveAscent_ypos=fm.ascent()+decoSeparation;
|
const double decoAboveAscent_ypos=fm.ascent()+decoSeparation;
|
||||||
const double decobelow_ypos=cDescent+decoSeparation;
|
const double decobelow_ypos=cDescent+decoSeparation;
|
||||||
const double italic_xcorrection=getNonItalicXCorretion(painter, cwidth, ev, getChild());
|
const double italic_xcorrection=getNonItalicXCorretion(painter, cs.width, ev, getChild());
|
||||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("~").width():fm.boundingRect("^").width())-italic_xcorrection;
|
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("~").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||||
const double linewidth=qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth());
|
const double linewidth=qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double descent=coverallHeight-cbaselineHeight;
|
double descent=cs.getDescent();
|
||||||
double ascent=cbaselineHeight;
|
double ascent=cs.baselineHeight;
|
||||||
if (decoration==MTDbar) {
|
if (decoration==MTDbar) {
|
||||||
ascent=std::max<double>(baselineHeight+decoSeparation, decoAboveAscent_ypos)+linewidth/2.0;
|
ascent=std::max<double>(cs.baselineHeight+decoSeparation, decoAboveAscent_ypos)+linewidth/2.0;
|
||||||
} else if (decoration==MTDunderline || decoration==MTDunderlineDashed || decoration==MTDunderlineDotted) {
|
} else if (decoration==MTDunderline || decoration==MTDunderlineDashed || decoration==MTDunderlineDotted) {
|
||||||
descent=std::max<double>(decobelow_ypos, cDescent)+linewidth/2.0;
|
descent=std::max<double>(decobelow_ypos, cDescent)+linewidth/2.0;
|
||||||
} else if (decoration==MTDdoubleunderline) {
|
} else if (decoration==MTDdoubleunderline) {
|
||||||
@ -160,10 +160,11 @@ void JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painter, JKQTMathTextE
|
|||||||
} else {
|
} else {
|
||||||
ascent=deco_ypos+deco_height;
|
ascent=deco_ypos+deco_height;
|
||||||
}
|
}
|
||||||
overallHeight=ascent+descent;
|
s.overallHeight=ascent+descent;
|
||||||
baselineHeight=ascent;
|
s.baselineHeight=ascent;
|
||||||
strikeoutPos=cstrikeoutPos;
|
s.strikeoutPos=cs.strikeoutPos;
|
||||||
width=std::max<double>(deco_miniwidth,cwidth);
|
s.width=std::max<double>(deco_miniwidth,cs.width);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, JKQTMathTextDecoratedNode::DecorationType> JKQTMathTextDecoratedNode::instructions;
|
QHash<QString, JKQTMathTextDecoratedNode::DecorationType> JKQTMathTextDecoratedNode::instructions;
|
||||||
@ -224,12 +225,11 @@ void JKQTMathTextDecoratedNode::fillInstructions()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
double cwidth=0, cbaselineHeight=0, coverallHeight=0, cstrikeoutPos=0;
|
auto cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, cwidth, cbaselineHeight, coverallHeight, cstrikeoutPos);
|
const double cDescent=cs.overallHeight-cs.baselineHeight;
|
||||||
const double cDescent=coverallHeight-cbaselineHeight;
|
|
||||||
const QFont font=ev.getFont(parentMathText);
|
const QFont font=ev.getFont(parentMathText);
|
||||||
const QFontMetricsF fm(font, painter.device());
|
const QFontMetricsF fm(font, painter.device());
|
||||||
const double width_X=fm.boundingRect("X").width();
|
const double width_X=fm.boundingRect("X").width();
|
||||||
@ -240,24 +240,24 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
|||||||
const double linewidthArrow=linewidth*0.65;
|
const double linewidthArrow=linewidth*0.65;
|
||||||
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
|
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
|
||||||
const double decoAboveAscent_ypos=y-fm.ascent()-decoSeparation;
|
const double decoAboveAscent_ypos=y-fm.ascent()-decoSeparation;
|
||||||
const double strike_ypos=y-cbaselineHeight/2.0;
|
const double strike_ypos=y-cs.baselineHeight/2.0;
|
||||||
const double decobelow_ypos=y+cDescent+decoSeparation;
|
const double decobelow_ypos=y+cDescent+decoSeparation;
|
||||||
const double italic_xcorrection=getNonItalicXCorretion(painter, cwidth, ev, getChild());
|
const double italic_xcorrection=getNonItalicXCorretion(painter, cs.width, ev, getChild());
|
||||||
const double deco_xoffset=parentMathText->getDecorationWidthReductionXFactor()*width_X/2.0;
|
const double deco_xoffset=parentMathText->getDecorationWidthReductionXFactor()*width_X/2.0;
|
||||||
const double deco_width=std::max<double>(width_x*0.5,cwidth-2.0*deco_xoffset-italic_xcorrection);
|
const double deco_width=std::max<double>(width_x*0.5,cs.width-2.0*deco_xoffset-italic_xcorrection);
|
||||||
const double deco_vecwidth=width_x*0.18;
|
const double deco_vecwidth=width_x*0.18;
|
||||||
const double deco_vecheight=deco_height*0.25;
|
const double deco_vecheight=deco_height*0.25;
|
||||||
const double deco_accentwidth=deco_height/4.0;
|
const double deco_accentwidth=deco_height/4.0;
|
||||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("j").width():fm.boundingRect("^").width())-italic_xcorrection;
|
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("j").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||||
const double decotop_xcenter=x+italic_xcorrection+(cwidth-italic_xcorrection)/2.0;
|
const double decotop_xcenter=x+italic_xcorrection+(cs.width-italic_xcorrection)/2.0;
|
||||||
const double decotop_xstart=decotop_xcenter-deco_width/2.0+linewidth/2.0;
|
const double decotop_xstart=decotop_xcenter-deco_width/2.0+linewidth/2.0;
|
||||||
const double decotop_xend=decotop_xcenter+deco_width/2.0-linewidth/2.0;
|
const double decotop_xend=decotop_xcenter+deco_width/2.0-linewidth/2.0;
|
||||||
const double decobot_xstart=x+linewidth/2.0;
|
const double decobot_xstart=x+linewidth/2.0;
|
||||||
const double decobot_xend=x+cwidth-italic_xcorrection-linewidth/2.0;
|
const double decobot_xend=x+cs.width-italic_xcorrection-linewidth/2.0;
|
||||||
//const double decobot_xcenter=(decobot_xstart+decobot_xend)/2.0;
|
//const double decobot_xcenter=(decobot_xstart+decobot_xend)/2.0;
|
||||||
const double deco_ytopbot=y-cbaselineHeight-decoSeparation-linewidth/2.0;
|
const double deco_ytopbot=y-cs.baselineHeight-decoSeparation-linewidth/2.0;
|
||||||
const double deco_ytoptop=y-cbaselineHeight-decoSeparation-deco_height+linewidth/2.0;
|
const double deco_ytoptop=y-cs.baselineHeight-decoSeparation-deco_height+linewidth/2.0;
|
||||||
const double deco_ytopcenter=y-cbaselineHeight-decoSeparation-deco_height/2.0;
|
const double deco_ytopcenter=y-cs.baselineHeight-decoSeparation-deco_height/2.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -529,7 +529,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
|||||||
return xnew;
|
return xnew;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextDecoratedNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) {
|
bool JKQTMathTextDecoratedNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) const {
|
||||||
//QString f;
|
//QString f;
|
||||||
//JKQTMathTextEnvironment ev=currentEv;
|
//JKQTMathTextEnvironment ev=currentEv;
|
||||||
|
|
||||||
|
@ -91,16 +91,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing
|
|||||||
JKQTMathTextDecoratedNode(JKQTMathText* parent, DecorationType decoration, JKQTMathTextNode* child);
|
JKQTMathTextDecoratedNode(JKQTMathText* parent, DecorationType decoration, JKQTMathTextNode* child);
|
||||||
virtual ~JKQTMathTextDecoratedNode() override;
|
virtual ~JKQTMathTextDecoratedNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override ;
|
virtual QString getTypeName() const override ;
|
||||||
/** \copydoc decoration */
|
/** \copydoc decoration */
|
||||||
DecorationType getDecoration() const;
|
DecorationType getDecoration() const;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief type of decoration that is added to the child node */
|
/** \brief type of decoration that is added to the child node */
|
||||||
DecorationType decoration;
|
DecorationType decoration;
|
||||||
/** \brief lists all supported instructions */
|
/** \brief lists all supported instructions */
|
||||||
|
@ -123,7 +123,7 @@ QString JKQTMathTextFracNode::getTypeName() const
|
|||||||
return "MTfracNode";
|
return "MTfracNode";
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
const QFont f=currentEv.getFont(parentMathText);
|
const QFont f=currentEv.getFont(parentMathText);
|
||||||
const QFontMetricsF fm(f, painter.device());
|
const QFontMetricsF fm(f, painter.device());
|
||||||
JKQTMathTextEnvironment ev1=currentEv;
|
JKQTMathTextEnvironment ev1=currentEv;
|
||||||
@ -156,69 +156,68 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
|||||||
const QRectF AeTBR2=fmev2.tightBoundingRect("A");
|
const QRectF AeTBR2=fmev2.tightBoundingRect("A");
|
||||||
const double asc2=AeTBR2.height();
|
const double asc2=AeTBR2.height();
|
||||||
|
|
||||||
double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0;
|
JKQTMathTextNodeSize size1=child1->getSize(painter, ev1);
|
||||||
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos2=0;
|
JKQTMathTextNodeSize size2=child2->getSize(painter, ev2);
|
||||||
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1);
|
if (asc1>size1.baselineHeight) {
|
||||||
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos2);
|
const double oldDescent=size1.overallHeight-size1.baselineHeight;
|
||||||
if (asc1>baselineHeight1) {
|
size1.baselineHeight=asc1;
|
||||||
const double oldDescent=overallHeight1-baselineHeight1;
|
size1.overallHeight=size1.baselineHeight+oldDescent;
|
||||||
baselineHeight1=asc1;
|
|
||||||
overallHeight1=baselineHeight1+oldDescent;
|
|
||||||
}
|
}
|
||||||
if (asc2>baselineHeight2) {
|
if (asc2>size2.baselineHeight) {
|
||||||
const double oldDescent=overallHeight2-baselineHeight2;
|
const double oldDescent=size2.overallHeight-size2.baselineHeight;
|
||||||
baselineHeight2=asc2;
|
size2.baselineHeight=asc2;
|
||||||
overallHeight2=baselineHeight2+oldDescent;
|
size2.overallHeight=size2.baselineHeight+oldDescent;
|
||||||
}
|
}
|
||||||
const double descent1=overallHeight1-baselineHeight1;
|
const double descent1=size1.overallHeight-size1.baselineHeight;
|
||||||
|
|
||||||
|
JKQTMathTextNodeSize size;
|
||||||
overallHeight=0;
|
size.overallHeight=0;
|
||||||
baselineHeight=0;
|
size.baselineHeight=0;
|
||||||
width=0;
|
size.width=0;
|
||||||
if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMdfrac || mode==JKQTMathTextFracNode::MTFMtfrac || mode==JKQTMathTextFracNode::MTFMstackrel) {
|
if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMdfrac || mode==JKQTMathTextFracNode::MTFMtfrac || mode==JKQTMathTextFracNode::MTFMstackrel) {
|
||||||
const double top_ascent=line_ascent+xheight*parentMathText->getFracShiftFactor();
|
const double top_ascent=line_ascent+xheight*parentMathText->getFracShiftFactor();
|
||||||
const double bot_ascent=line_ascent-xheight*parentMathText->getFracShiftFactor();
|
const double bot_ascent=line_ascent-xheight*parentMathText->getFracShiftFactor();
|
||||||
const double newascent=overallHeight1+top_ascent;
|
const double newascent=size1.overallHeight+top_ascent;
|
||||||
const double newdescent=overallHeight2-bot_ascent;
|
const double newdescent=size2.overallHeight-bot_ascent;
|
||||||
width=qMax(width1, width2);
|
size.width=qMax(size1.width, size2.width);
|
||||||
if (mode!=JKQTMathTextFracNode::MTFMstackrel) width+=xwidth/2.0;
|
if (mode!=JKQTMathTextFracNode::MTFMstackrel) size.width+=xwidth/2.0;
|
||||||
strikeoutPos=line_ascent;
|
size.strikeoutPos=line_ascent;
|
||||||
|
|
||||||
overallHeight=newascent+newdescent;
|
size.overallHeight=newascent+newdescent;
|
||||||
baselineHeight=newascent;
|
size.baselineHeight=newascent;
|
||||||
|
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
const double top_ascent=line_ascent;
|
const double top_ascent=line_ascent;
|
||||||
const double newascent=overallHeight1+top_ascent;
|
const double newascent=size1.overallHeight+top_ascent;
|
||||||
const double newdescent=qMax(overallHeight2-baselineHeight2, qheight-xheight);
|
const double newdescent=qMax(size2.overallHeight-size2.baselineHeight, qheight-xheight);
|
||||||
width=width1+width2+xwidth*0.666;
|
size.width=size1.width+size2.width+xwidth*0.666;
|
||||||
strikeoutPos=line_ascent;
|
size.strikeoutPos=line_ascent;
|
||||||
|
|
||||||
overallHeight=newascent+newdescent;
|
size.overallHeight=newascent+newdescent;
|
||||||
baselineHeight=newascent;
|
size.baselineHeight=newascent;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMunderbrace || mode==JKQTMathTextFracNode::MTFMunderbracket) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderbrace || mode==JKQTMathTextFracNode::MTFMunderbracket) {
|
||||||
const double newdescent=descent1+overallHeight2+braceheight+2.0*braceseparation;
|
const double newdescent=descent1+size2.overallHeight+braceheight+2.0*braceseparation;
|
||||||
overallHeight=newdescent+baselineHeight1;
|
size.overallHeight=newdescent+size1.baselineHeight;
|
||||||
baselineHeight=baselineHeight1;
|
size.baselineHeight=size1.baselineHeight;
|
||||||
width=qMax(width1, width2)+xwidth;
|
size.width=qMax(size1.width, size2.width)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
size.strikeoutPos=line_ascent;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMoverbrace || mode==JKQTMathTextFracNode::MTFMoverbracket) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverbrace || mode==JKQTMathTextFracNode::MTFMoverbracket) {
|
||||||
overallHeight=overallHeight1+overallHeight2+braceheight+2.0*braceseparation;
|
size.overallHeight=size1.overallHeight+size2.overallHeight+braceheight+2.0*braceseparation;
|
||||||
baselineHeight=baselineHeight1+overallHeight2+braceheight+2.0*braceseparation;
|
size.baselineHeight=size1.baselineHeight+size2.overallHeight+braceheight+2.0*braceseparation;
|
||||||
width=qMax(width1, width2)+xwidth;
|
size.width=qMax(size1.width, size2.width)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
size.strikeoutPos=line_ascent;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMunderset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderset) {
|
||||||
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
size.overallHeight=size1.overallHeight+size2.overallHeight+xheight/6.0;
|
||||||
baselineHeight=baselineHeight1;
|
size.baselineHeight=size1.baselineHeight;
|
||||||
width=qMax(width1, width2)+xwidth;
|
size.width=qMax(size1.width, size2.width)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
size.strikeoutPos=line_ascent;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMoverset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverset) {
|
||||||
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
size.overallHeight=size1.overallHeight+size1.overallHeight+xheight/6.0;
|
||||||
baselineHeight=baselineHeight1+overallHeight2+xheight/6.0;
|
size.baselineHeight=size1.baselineHeight+size2.overallHeight+xheight/6.0;
|
||||||
width=qMax(width1, width2)+xwidth;
|
size.width=qMax(size1.width, size2.width)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
size.strikeoutPos=line_ascent;
|
||||||
}
|
}
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int JKQTMathTextFracNode::getNestingLevel(bool /*sameType*/) const
|
int JKQTMathTextFracNode::getNestingLevel(bool /*sameType*/) const
|
||||||
@ -240,7 +239,7 @@ double JKQTMathTextFracNode::getFracScalingFactor() const
|
|||||||
return parentMathText->getFracFactor();
|
return parentMathText->getFracFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
const QFont f=currentEv.getFont(parentMathText);
|
const QFont f=currentEv.getFont(parentMathText);
|
||||||
const QFontMetricsF fm(f, painter.device());
|
const QFontMetricsF fm(f, painter.device());
|
||||||
@ -276,31 +275,29 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
const QRectF AeTBR2=fmev2.tightBoundingRect("A");
|
const QRectF AeTBR2=fmev2.tightBoundingRect("A");
|
||||||
const double asc2=AeTBR2.height();
|
const double asc2=AeTBR2.height();
|
||||||
|
|
||||||
double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0;
|
JKQTMathTextNodeSize size1=child1->getSize(painter, ev1);
|
||||||
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0;
|
JKQTMathTextNodeSize size2=child2->getSize(painter, ev2);
|
||||||
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos);
|
if (asc1>size1.baselineHeight) {
|
||||||
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos);
|
const double oldDescent=size1.overallHeight-size1.baselineHeight;
|
||||||
if (asc1>baselineHeight1) {
|
size1.baselineHeight=asc1;
|
||||||
const double oldDescent=overallHeight1-baselineHeight1;
|
size1.overallHeight=size1.baselineHeight+oldDescent;
|
||||||
baselineHeight1=asc1;
|
|
||||||
overallHeight1=baselineHeight1+oldDescent;
|
|
||||||
}
|
}
|
||||||
if (asc2>baselineHeight2) {
|
if (asc2>size2.baselineHeight) {
|
||||||
const double oldDescent=overallHeight2-baselineHeight2;
|
const double oldDescent=size2.overallHeight-size2.baselineHeight;
|
||||||
baselineHeight2=asc2;
|
size2.baselineHeight=asc2;
|
||||||
overallHeight2=baselineHeight2+oldDescent;
|
size2.overallHeight=size2.baselineHeight+oldDescent;
|
||||||
}
|
}
|
||||||
const double ascent1=baselineHeight1;
|
const double ascent1=size1.baselineHeight;
|
||||||
const double descent1=overallHeight1-baselineHeight1;
|
const double descent1=size1.overallHeight-size1.baselineHeight;
|
||||||
const double ascent2=baselineHeight2;
|
const double ascent2=size2.baselineHeight;
|
||||||
const double descent2=overallHeight2-baselineHeight2;
|
const double descent2=size2.overallHeight-size2.baselineHeight;
|
||||||
|
|
||||||
const double yline=y-xheight*0.5;
|
const double yline=y-xheight*0.5;
|
||||||
|
|
||||||
|
|
||||||
//double overallHeight=overallHeight1+overallHeight2+xh;
|
//double overallHeight=size1.overallHeight+size2.overallHeight+xh;
|
||||||
//double baselineHeight=3.0*xh/2.0+overallHeight1;
|
//double baselineHeight=3.0*xh/2.0+size1.overallHeight;
|
||||||
const double maxWidth=qMax(width1, width2);
|
const double maxWidth=qMax(size1.width, size2.width);
|
||||||
double deltaWidth=0;
|
double deltaWidth=0;
|
||||||
|
|
||||||
QPen p=painter.pen();
|
QPen p=painter.pen();
|
||||||
@ -313,32 +310,32 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
deltaWidth=xwidth/2.0;
|
deltaWidth=xwidth/2.0;
|
||||||
const QLineF l(x+p.widthF()*2.0, yline, x+maxWidth+deltaWidth-p.widthF()*2.0, yline);
|
const QLineF l(x+p.widthF()*2.0, yline, x+maxWidth+deltaWidth-p.widthF()*2.0, yline);
|
||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
child1->draw(painter, x+deltaWidth/2.0+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+deltaWidth/2.0+(maxWidth-size1.width)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+deltaWidth/2.0+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+deltaWidth/2.0+(maxWidth-size2.width)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMstackrel) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstackrel) {
|
||||||
child1->draw(painter, x+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+(maxWidth-size1.width)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+(maxWidth-size2.width)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
deltaWidth=xwidth*0.666;
|
deltaWidth=xwidth*0.666;
|
||||||
child1->draw(painter, x, yline, ev1);
|
child1->draw(painter, x, yline, ev1);
|
||||||
child2->draw(painter, x+width1+deltaWidth, y, ev2);
|
child2->draw(painter, x+size1.width+deltaWidth, y, ev2);
|
||||||
const QLineF l(x+width1+deltaWidth, y-Mheight, x+width1, y+(qheight-xheight));
|
const QLineF l(x+size1.width+deltaWidth, y-Mheight, x+size1.width, y+(qheight-xheight));
|
||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMunderset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderset) {
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-size1.width)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y+descent1+xheight/6.0+ascent2, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-size2.width)/2.0, y+descent1+xheight/6.0+ascent2, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMunderbrace) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderbrace) {
|
||||||
const double ybrace=y+descent1+braceseparation+braceheight/2.0;
|
const double ybrace=y+descent1+braceseparation+braceheight/2.0;
|
||||||
const double ybot=y+descent1+2.0*braceseparation+braceheight+ascent2;
|
const double ybot=y+descent1+2.0*braceseparation+braceheight+ascent2;
|
||||||
{
|
{
|
||||||
const QPainterPath path=JKQTMathTextMakeHBracePath(x+xwidth/2.0+(width1)/2.0, ybrace, maxWidth, braceheight, p.width());
|
const QPainterPath path=JKQTMathTextMakeHBracePath(x+xwidth/2.0+(size1.width)/2.0, ybrace, maxWidth, braceheight, p.width());
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
plocal.setWidthF(0.0001);
|
plocal.setWidthF(0.0001);
|
||||||
painter.fillPath(path, QBrush(ev1.color));
|
painter.fillPath(path, QBrush(ev1.color));
|
||||||
}
|
}
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-size1.width)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, ybot, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-size2.width)/2.0, ybot, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMunderbracket) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderbracket) {
|
||||||
const double ybrace=y+descent1+braceseparation+braceheight/2.0;
|
const double ybrace=y+descent1+braceseparation+braceheight/2.0;
|
||||||
@ -355,19 +352,19 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
path.lineTo(x2, y1);
|
path.lineTo(x2, y1);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
}
|
}
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-size1.width)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, ybot, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-size2.width)/2.0, ybot, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMoverset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverset) {
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-size1.width)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y-ascent1-xheight/6.0-descent2, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-size2.width)/2.0, y-ascent1-xheight/6.0-descent2, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMoverbrace) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverbrace) {
|
||||||
const double ybrace=y-ascent1-braceheight/2.0-braceseparation;
|
const double ybrace=y-ascent1-braceheight/2.0-braceseparation;
|
||||||
const double ytop=y-ascent1-2.0*braceseparation-braceheight-descent2;
|
const double ytop=y-ascent1-2.0*braceseparation-braceheight-descent2;
|
||||||
{
|
{
|
||||||
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.translate(x+xwidth/2.0+(width1)/2.0, ybrace);
|
painter.translate(x+xwidth/2.0+(size1.width)/2.0, ybrace);
|
||||||
painter.rotate(180);
|
painter.rotate(180);
|
||||||
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0, maxWidth, braceheight, p.widthF());
|
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0, maxWidth, braceheight, p.widthF());
|
||||||
QPen plocal=p;
|
QPen plocal=p;
|
||||||
@ -375,8 +372,8 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
painter.fillPath(path, QBrush(ev1.color));
|
painter.fillPath(path, QBrush(ev1.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-size1.width)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, ytop, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-size2.width)/2.0, ytop, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMoverbracket) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverbracket) {
|
||||||
const double ybrace=y-ascent1-braceheight/2.0-braceseparation;
|
const double ybrace=y-ascent1-braceheight/2.0-braceseparation;
|
||||||
@ -393,22 +390,21 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
path.lineTo(x2, y1);
|
path.lineTo(x2, y1);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
}
|
}
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-size1.width)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, ytop, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-size2.width)/2.0, ytop, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) return x+width1+width2+deltaWidth;
|
if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) return x+size1.width+size2.width+deltaWidth;
|
||||||
else return x+maxWidth+deltaWidth;
|
else return x+maxWidth+deltaWidth;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextFracNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) {
|
bool JKQTMathTextFracNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) const {
|
||||||
bool ok=false;
|
bool ok=false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChild
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc mode */
|
/** \copydoc mode */
|
||||||
JKQTMathTextFracNode::FracType getMode() const;
|
JKQTMathTextFracNode::FracType getMode() const;
|
||||||
protected:
|
protected:
|
||||||
@ -94,7 +94,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChild
|
|||||||
/** \brief fills instructions */
|
/** \brief fills instructions */
|
||||||
static void fillInstructions();
|
static void fillInstructions();
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief actual display type of fraction object */
|
/** \brief actual display type of fraction object */
|
||||||
JKQTMathTextFracNode::FracType mode;
|
JKQTMathTextFracNode::FracType mode;
|
||||||
/** \brief returns the nesting level of the node (of same type of \a sameType \c ==true) */
|
/** \brief returns the nesting level of the node (of same type of \a sameType \c ==true) */
|
||||||
|
@ -78,7 +78,7 @@ QString JKQTMathTextSimpleInstructionNode::getTypeName() const
|
|||||||
return QLatin1String("JKQTMathTextSimpleInstructionNode(")+instructionName+")";
|
return QLatin1String("JKQTMathTextSimpleInstructionNode(")+instructionName+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
@ -93,7 +93,7 @@ double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, doub
|
|||||||
return x+bb.width();
|
return x+bb.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextSimpleInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv)
|
bool JKQTMathTextSimpleInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const
|
||||||
{
|
{
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
const QString txt=executeInstruction();
|
const QString txt=executeInstruction();
|
||||||
@ -124,7 +124,7 @@ size_t JKQTMathTextSimpleInstructionNode::countParametersOfInstruction(const QSt
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
QFont f=currentEv.getFont(parentMathText);
|
QFont f=currentEv.getFont(parentMathText);
|
||||||
@ -132,10 +132,12 @@ void JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTM
|
|||||||
const QFontMetricsF fm(f);
|
const QFontMetricsF fm(f);
|
||||||
const QString txt=executeInstruction();
|
const QString txt=executeInstruction();
|
||||||
const QRectF bb=fm.boundingRect(txt);
|
const QRectF bb=fm.boundingRect(txt);
|
||||||
width=bb.width();
|
JKQTMathTextNodeSize s;
|
||||||
baselineHeight=-bb.y();
|
s.width=bb.width();
|
||||||
overallHeight=bb.height();
|
s.baselineHeight=-bb.y();
|
||||||
strikeoutPos=fm.strikeOutPos();
|
s.overallHeight=bb.height();
|
||||||
|
s.strikeoutPos=fm.strikeOutPos();
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, JKQTMathTextSimpleInstructionNode::InstructionProperties> JKQTMathTextSimpleInstructionNode::instructions;
|
QHash<QString, JKQTMathTextSimpleInstructionNode::InstructionProperties> JKQTMathTextSimpleInstructionNode::instructions;
|
||||||
@ -215,16 +217,16 @@ QString JKQTMathTextModifiedTextPropsInstructionNode::getTypeName() const
|
|||||||
return QLatin1String("JKQTMathTextModifiedTextPropsInstructionNode(")+instructionName+")";
|
return QLatin1String("JKQTMathTextModifiedTextPropsInstructionNode(")+instructionName+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextModifiedTextPropsInstructionNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextModifiedTextPropsInstructionNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
|
|
||||||
executeInstruction(ev);
|
executeInstruction(ev);
|
||||||
|
|
||||||
getChild()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
return getChild()->getSize(painter, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextModifiedTextPropsInstructionNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextModifiedTextPropsInstructionNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
@ -234,7 +236,7 @@ double JKQTMathTextModifiedTextPropsInstructionNode::draw(QPainter& painter, dou
|
|||||||
return getChild()->draw(painter, x, y, ev);
|
return getChild()->draw(painter, x, y, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextModifiedTextPropsInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextModifiedTextPropsInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
executeInstruction(ev);
|
executeInstruction(ev);
|
||||||
@ -665,7 +667,7 @@ QString JKQTMathTextBoxInstructionNode::getTypeName() const
|
|||||||
return QLatin1String("JKQTMathTextBoxInstructionNode(")+instructionName+")";
|
return QLatin1String("JKQTMathTextBoxInstructionNode(")+instructionName+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextBoxInstructionNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextBoxInstructionNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
|
|
||||||
const auto& inst=instructions.value(getInstructionName());
|
const auto& inst=instructions.value(getInstructionName());
|
||||||
@ -676,13 +678,16 @@ void JKQTMathTextBoxInstructionNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
const double lw=p.widthF();
|
const double lw=p.widthF();
|
||||||
const double padding=inst.paddingFactor*fmNonItalic.tightBoundingRect("x").width();
|
const double padding=inst.paddingFactor*fmNonItalic.tightBoundingRect("x").width();
|
||||||
|
|
||||||
getChild()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
width=width+2.0*(padding+lw/2.0);
|
JKQTMathTextNodeSize s;
|
||||||
baselineHeight=baselineHeight+padding+lw/2.0;
|
s.width=cs.width+2.0*(padding+lw/2.0);
|
||||||
overallHeight=overallHeight+2.0*(padding+lw/2.0);
|
s.baselineHeight=cs.baselineHeight+padding+lw/2.0;
|
||||||
|
s.overallHeight=cs.overallHeight+2.0*(padding+lw/2.0);
|
||||||
|
s.strikeoutPos=cs.strikeoutPos;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextBoxInstructionNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextBoxInstructionNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
|
|
||||||
@ -694,21 +699,20 @@ double JKQTMathTextBoxInstructionNode::draw(QPainter& painter, double x, double
|
|||||||
const double lw=p.widthF();
|
const double lw=p.widthF();
|
||||||
const double padding=inst.paddingFactor*fmNonItalic.tightBoundingRect("x").width();
|
const double padding=inst.paddingFactor*fmNonItalic.tightBoundingRect("x").width();
|
||||||
const double rr=inst.roundingFactor*fmNonItalic.tightBoundingRect("x").width();
|
const double rr=inst.roundingFactor*fmNonItalic.tightBoundingRect("x").width();
|
||||||
double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0;
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.setBrush(b);
|
painter.setBrush(b);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
const QRectF rect(x+lw/2.0, y-baselineHeight-padding-lw/2.0, width+2.0*padding, overallHeight+2.0*padding);
|
const QRectF rect(x+lw/2.0, y-cs.baselineHeight-padding-lw/2.0, cs.width+2.0*padding, cs.overallHeight+2.0*padding);
|
||||||
if (rr>0) painter.drawRoundedRect(rect, rr, rr, Qt::AbsoluteSize);
|
if (rr>0) painter.drawRoundedRect(rect, rr, rr, Qt::AbsoluteSize);
|
||||||
else painter.drawRect(rect);
|
else painter.drawRect(rect);
|
||||||
if (inst.doubleLine) {
|
if (inst.doubleLine) {
|
||||||
painter.setBrush(Qt::NoBrush);
|
painter.setBrush(Qt::NoBrush);
|
||||||
QPen p2=p;
|
QPen p2=p;
|
||||||
p2.setWidthF(p.widthF()*0.6);
|
p2.setWidthF(p.widthF()*0.6);
|
||||||
const QRectF recti(x+lw*2.5, y-baselineHeight-lw/2.0-padding+2.0*lw, width+2.0*padding-4.0*lw, overallHeight+2.0*padding-4.0*lw);
|
const QRectF recti(x+lw*2.5, y-cs.baselineHeight-lw/2.0-padding+2.0*lw, cs.width+2.0*padding-4.0*lw, cs.overallHeight+2.0*padding-4.0*lw);
|
||||||
if (rr>0) painter.drawRoundedRect(recti, rr, rr, Qt::AbsoluteSize);
|
if (rr>0) painter.drawRoundedRect(recti, rr, rr, Qt::AbsoluteSize);
|
||||||
else painter.drawRect(recti);
|
else painter.drawRect(recti);
|
||||||
}
|
}
|
||||||
@ -719,7 +723,7 @@ double JKQTMathTextBoxInstructionNode::draw(QPainter& painter, double x, double
|
|||||||
return xnew+padding+lw/2.0;
|
return xnew+padding+lw/2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextBoxInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextBoxInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
const auto& inst=instructions.value(getInstructionName());
|
const auto& inst=instructions.value(getInstructionName());
|
||||||
|
@ -70,9 +70,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSimpleInstructionNode: public JKQTMath
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc instructionName */
|
/** \copydoc instructionName */
|
||||||
const QString& getInstructionName() const;
|
const QString& getInstructionName() const;
|
||||||
/** \copydoc parameters */
|
/** \copydoc parameters */
|
||||||
@ -89,7 +89,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSimpleInstructionNode: public JKQTMath
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief defines the implementation of an instruction represented by JKQTMathTextModifiedTextPropsInstructionNode */
|
/** \brief defines the implementation of an instruction represented by JKQTMathTextModifiedTextPropsInstructionNode */
|
||||||
struct InstructionProperties {
|
struct InstructionProperties {
|
||||||
/** \brief this functor implements the instruction */
|
/** \brief this functor implements the instruction */
|
||||||
@ -131,9 +131,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedTextPropsInstructionNode: publ
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
|
|
||||||
/** \brief returns true, if the given \a instructionName can be represented by this node
|
/** \brief returns true, if the given \a instructionName can be represented by this node
|
||||||
* \see instructions
|
* \see instructions
|
||||||
@ -150,7 +150,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedTextPropsInstructionNode: publ
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief defines the implementation of an instruction represented by JKQTMathTextModifiedTextPropsInstructionNode */
|
/** \brief defines the implementation of an instruction represented by JKQTMathTextModifiedTextPropsInstructionNode */
|
||||||
struct InstructionProperties {
|
struct InstructionProperties {
|
||||||
/** \brief this functor implements the instruction */
|
/** \brief this functor implements the instruction */
|
||||||
@ -188,9 +188,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBoxInstructionNode: public JKQTMathTex
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
|
|
||||||
/** \brief returns true, if the given \a instructionName can be represented by this node
|
/** \brief returns true, if the given \a instructionName can be represented by this node
|
||||||
* \see instructions
|
* \see instructions
|
||||||
@ -210,7 +210,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBoxInstructionNode: public JKQTMathTex
|
|||||||
static void modifyInMathEnvironment(const QString& instructionName, bool& insideMath, const QStringList ¶ms=QStringList());
|
static void modifyInMathEnvironment(const QString& instructionName, bool& insideMath, const QStringList ¶ms=QStringList());
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief set all properties in \a ev, as appropriate for the represented instruction */
|
/** \brief set all properties in \a ev, as appropriate for the represented instruction */
|
||||||
bool setupMTenvironment(JKQTMathTextEnvironment &ev) const;
|
bool setupMTenvironment(JKQTMathTextEnvironment &ev) const;
|
||||||
|
|
||||||
|
@ -52,11 +52,8 @@ QString JKQTMathTextHorizontalListNode::getTypeName() const
|
|||||||
return "MTHorizontalListNode";
|
return "MTHorizontalListNode";
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
width=0;
|
JKQTMathTextNodeSize outSize;
|
||||||
overallHeight=0;
|
|
||||||
baselineHeight=0;
|
|
||||||
strikeoutPos=0;
|
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText));
|
const QFontMetricsF fm(currentEv.getFont(parentMathText));
|
||||||
const double subsupershift=fm.xHeight()*parentMathText->getOperatorsubsuperDistanceFactor();
|
const double subsupershift=fm.xHeight()*parentMathText->getOperatorsubsuperDistanceFactor();
|
||||||
const double subsuperextrawidth=fm.boundingRect('x').width()*parentMathText->getOperatorsubsuperExtraSpaceFactor();
|
const double subsuperextrawidth=fm.boundingRect('x').width()*parentMathText->getOperatorsubsuperExtraSpaceFactor();
|
||||||
@ -95,32 +92,31 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
if (i+1<nodes.size()) { // is there one mor node behind?
|
if (i+1<nodes.size()) { // is there one mor node behind?
|
||||||
JKQTMathTextSubscriptNode* nodeISucc_SubScript=dynamic_cast<JKQTMathTextSubscriptNode*>(nodes[i+1]);
|
JKQTMathTextSubscriptNode* nodeISucc_SubScript=dynamic_cast<JKQTMathTextSubscriptNode*>(nodes[i+1]);
|
||||||
if (nodeISucc_SubScript) { // is this subscript?
|
if (nodeISucc_SubScript) { // is this subscript?
|
||||||
double w1=0, w2=0, oh=0, bh=0, sp=0;
|
const JKQTMathTextNodeSize ns=nodeI_SuperScript->getSizeWithSpecialPlacement(painter, currentEv, prevNodeSizePtrForSuperscript);
|
||||||
nodeI_SuperScript->getSizeWithSpecialPlacement(painter, currentEv, w1, bh, oh, sp, prevNodeSizePtrForSuperscript);
|
|
||||||
|
|
||||||
if (bh>baselineHeight) {
|
if (ns.baselineHeight>outSize.baselineHeight) {
|
||||||
overallHeight=overallHeight+bh-baselineHeight;
|
outSize.overallHeight=outSize.overallHeight+ns.baselineHeight-outSize.baselineHeight;
|
||||||
baselineHeight=bh;
|
outSize.baselineHeight=ns.baselineHeight;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
}
|
}
|
||||||
if (baselineHeight+oh-bh>overallHeight) {
|
if (outSize.baselineHeight+ns.getDescent()>outSize.overallHeight) {
|
||||||
overallHeight=baselineHeight+oh-bh;
|
outSize.overallHeight=outSize.baselineHeight+ns.getDescent();
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
nodeISucc_SubScript->getSizeWithSpecialPlacement(painter, currentEv, w2, bh, oh, sp, prevNodeSizePtrForSubscript);
|
const JKQTMathTextNodeSize ns2=nodeISucc_SubScript->getSizeWithSpecialPlacement(painter, currentEv, prevNodeSizePtrForSubscript);
|
||||||
//qDebug()<<"super_sub: sub: "<<nodes[i]->getTypeName()<<" w2="<<w2<<" bh"<<bh<<" oh="<<oh<<" sp="<<sp;
|
//qDebug()<<"super_sub: sub: "<<nodes[i]->getTypeName()<<" w2="<<w2<<" bh"<<bh<<" oh="<<oh<<" sp="<<sp;
|
||||||
if (bh>baselineHeight) {
|
if (ns2.baselineHeight>outSize.baselineHeight) {
|
||||||
overallHeight=overallHeight+bh-baselineHeight;
|
outSize.overallHeight=outSize.overallHeight+ns2.baselineHeight-outSize.baselineHeight;
|
||||||
baselineHeight=bh;
|
outSize.baselineHeight=ns2.baselineHeight;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns2.strikeoutPos;
|
||||||
}
|
}
|
||||||
if (baselineHeight+oh-bh>overallHeight) {
|
if (outSize.baselineHeight+ns2.getDescent()>outSize.overallHeight) {
|
||||||
overallHeight=baselineHeight+oh-bh;
|
outSize.overallHeight=outSize.baselineHeight+ns2.getDescent();
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns2.strikeoutPos;
|
||||||
}
|
}
|
||||||
xnew+=qMax(w1+spaceWidth, w2+prevNodeSize.subBesidesXCorrection);
|
xnew+=qMax(ns.width+spaceWidth, ns2.width+prevNodeSize.subBesidesXCorrection);
|
||||||
|
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
//qDebug()<<"### super+sub";
|
//qDebug()<<"### super+sub";
|
||||||
@ -131,30 +127,29 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
if (i+1<nodes.size()) { // is there one mor node behind?
|
if (i+1<nodes.size()) { // is there one mor node behind?
|
||||||
JKQTMathTextSuperscriptNode* nodeISucc_SuperScript=dynamic_cast<JKQTMathTextSuperscriptNode*>(nodes[i+1]);
|
JKQTMathTextSuperscriptNode* nodeISucc_SuperScript=dynamic_cast<JKQTMathTextSuperscriptNode*>(nodes[i+1]);
|
||||||
if (nodeISucc_SuperScript) { // is this subscript?
|
if (nodeISucc_SuperScript) { // is this subscript?
|
||||||
double w1=0, w2=0, oh=0, bh=0, sp=0;
|
const JKQTMathTextNodeSize ns=nodeI_SubScript->getSizeWithSpecialPlacement(painter, currentEv, prevNodeSizePtrForSubscript);
|
||||||
nodeI_SubScript->getSizeWithSpecialPlacement(painter, currentEv, w1, bh, oh, sp, prevNodeSizePtrForSubscript);
|
if (ns.baselineHeight>outSize.baselineHeight) {
|
||||||
if (bh>baselineHeight) {
|
outSize.overallHeight=outSize.overallHeight+ns.baselineHeight-outSize.baselineHeight;
|
||||||
overallHeight=overallHeight+bh-baselineHeight;
|
outSize.baselineHeight=ns.baselineHeight;
|
||||||
baselineHeight=bh;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
strikeoutPos=sp;
|
|
||||||
}
|
}
|
||||||
if (baselineHeight+oh-bh>overallHeight) {
|
if (outSize.baselineHeight+ns.overallHeight-ns.baselineHeight>outSize.overallHeight) {
|
||||||
overallHeight=baselineHeight+oh-bh;
|
outSize.overallHeight=outSize.baselineHeight+ns.overallHeight-ns.baselineHeight;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
nodeISucc_SuperScript->getSizeWithSpecialPlacement(painter, currentEv, w2, bh, oh, sp, prevNodeSizePtrForSuperscript);
|
const JKQTMathTextNodeSize ns2=nodeISucc_SuperScript->getSizeWithSpecialPlacement(painter, currentEv, prevNodeSizePtrForSuperscript);
|
||||||
if (bh>baselineHeight) {
|
if (ns2.baselineHeight>outSize.baselineHeight) {
|
||||||
overallHeight=overallHeight+bh-baselineHeight;
|
outSize.overallHeight=outSize.overallHeight+ns2.baselineHeight-outSize.baselineHeight;
|
||||||
baselineHeight=bh;
|
outSize.baselineHeight=ns2.baselineHeight;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns2.strikeoutPos;
|
||||||
}
|
}
|
||||||
if (baselineHeight+oh-bh>overallHeight) {
|
if (outSize.baselineHeight+ns2.overallHeight-ns2.baselineHeight>outSize.overallHeight) {
|
||||||
overallHeight=baselineHeight+oh-bh;
|
outSize.overallHeight=outSize.baselineHeight+ns2.overallHeight-ns2.baselineHeight;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns2.strikeoutPos;
|
||||||
}
|
}
|
||||||
xnew+=qMax(w1+prevNodeSize.subBesidesXCorrection, w2+spaceWidth);
|
xnew+=qMax(ns.width+prevNodeSize.subBesidesXCorrection, ns2.width+spaceWidth);
|
||||||
|
|
||||||
|
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
@ -162,18 +157,17 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
//qDebug()<<"### subsupop: sub+super1 overallHeight="<<overallHeight<<" baselineHeight="<<baselineHeight;
|
//qDebug()<<"### subsupop: sub+super1 overallHeight="<<overallHeight<<" baselineHeight="<<baselineHeight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
double w1=0, oh=0, bh=0, sp=0;
|
const JKQTMathTextNodeSize ns=nodes[i]->getSize(painter, currentEv);
|
||||||
nodes[i]->getSize(painter, currentEv, w1, bh, oh, sp);
|
if (ns.baselineHeight>outSize.baselineHeight) {
|
||||||
if (bh>baselineHeight) {
|
outSize.overallHeight=outSize.overallHeight+ns.baselineHeight-outSize.baselineHeight;
|
||||||
overallHeight=overallHeight+bh-baselineHeight;
|
outSize.baselineHeight=ns.baselineHeight;
|
||||||
baselineHeight=bh;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
strikeoutPos=sp;
|
|
||||||
}
|
}
|
||||||
if (baselineHeight+oh-bh>overallHeight) {
|
if (outSize.baselineHeight+ns.getDescent()>outSize.overallHeight) {
|
||||||
overallHeight=baselineHeight+oh-bh;
|
outSize.overallHeight=outSize.baselineHeight+ns.getDescent();
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
}
|
}
|
||||||
xnew+=w1-prevNodeSize.subBesidesXCorrection;
|
xnew+=ns.width-prevNodeSize.subBesidesXCorrection;
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -197,31 +191,27 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
if (!supn) supn=supn2;
|
if (!supn) supn=supn2;
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||||
double w1=0, wsub=0, wsup=0;
|
const JKQTMathTextNodeSize ns=nodes[i]->getSize(painter, currentEv);
|
||||||
double oh1=0, ohsub=0, ohsup=0;
|
//qDebug()<<"sub_super: node: "<<nodes[i]->getTypeName()<<" ns.width="<<ns.width<<" bh"<<ns.baselineHeight<<" oh="<<ns.overallHeight<<" sp="<<ns.strikeoutPos;
|
||||||
double bh1=0, bhsub=0, bhsup=0;
|
const JKQTMathTextNodeSize sub=subn->getChild()->getSize(painter, ev);
|
||||||
double sp1=0, spsub=0, spsup=0;
|
|
||||||
nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp1);
|
|
||||||
//qDebug()<<"sub_super: node: "<<nodes[i]->getTypeName()<<" w1="<<w1<<" bh"<<bh1<<" oh="<<oh1<<" sp="<<sp1;
|
|
||||||
subn->getChild()->getSize(painter, ev, wsub, bhsub, ohsub, spsub);
|
|
||||||
//qDebug()<<"sub_super: node: "<<subn->getTypeName()<<" w2="<<w2<<" bh2"<<bh2<<" oh2="<<oh2<<" sp2="<<sp2;
|
//qDebug()<<"sub_super: node: "<<subn->getTypeName()<<" w2="<<w2<<" bh2"<<bh2<<" oh2="<<oh2<<" sp2="<<sp2;
|
||||||
supn->getChild()->getSize(painter, ev, wsup, bhsup, ohsup, spsup);
|
const JKQTMathTextNodeSize sup=supn->getChild()->getSize(painter, ev);
|
||||||
//qDebug()<<"sub_super: node: "<<supn->getTypeName()<<" w3="<<w3<<" bh3"<<bh3<<" oh3="<<oh3<<" sp3="<<sp3;
|
//qDebug()<<"sub_super: node: "<<supn->getTypeName()<<" w3="<<w3<<" bh3"<<bh3<<" oh3="<<oh3<<" sp3="<<sp3;
|
||||||
const double descent1=oh1-bh1;
|
const double descent1=ns.overallHeight-ns.baselineHeight;
|
||||||
//double d1=oh1-bh1;
|
//double d1=ns.overallHeight-ns.baselineHeight;
|
||||||
//double d2=oh2-bh2;
|
//double d2=oh2-bh2;
|
||||||
//double d3=oh3-bh3;
|
//double d3=oh3-bh3;
|
||||||
const double neww=qMax(qMax(w1, wsub+prevNodeSize.subSuperXCorrection), wsup+prevNodeSize.subSuperXCorrection)+subsuperextrawidth;
|
const double neww=qMax(qMax(ns.width, sub.width+prevNodeSize.subSuperXCorrection), sup.width+prevNodeSize.subSuperXCorrection)+subsuperextrawidth;
|
||||||
const double newBaselineHeight=bh1+ohsup+subsupershift;
|
const double newBaselineHeight=ns.baselineHeight+sup.overallHeight+subsupershift;
|
||||||
if (newBaselineHeight>baselineHeight) {
|
if (newBaselineHeight>outSize.baselineHeight) {
|
||||||
const double extraBaselineHeight=newBaselineHeight-baselineHeight;
|
const double extraBaselineHeight=newBaselineHeight-outSize.baselineHeight;
|
||||||
baselineHeight=newBaselineHeight;
|
outSize.baselineHeight=newBaselineHeight;
|
||||||
overallHeight=overallHeight+extraBaselineHeight;
|
outSize.overallHeight=outSize.overallHeight+extraBaselineHeight;
|
||||||
}
|
}
|
||||||
const double newDescent=descent1+ohsub+subsupershift;
|
const double newDescent=descent1+sub.overallHeight+subsupershift;
|
||||||
if (newDescent>overallHeight-baselineHeight) {
|
if (newDescent>outSize.overallHeight-outSize.baselineHeight) {
|
||||||
const double extraDescent=newDescent-(overallHeight-baselineHeight);
|
const double extraDescent=newDescent-(outSize.overallHeight-outSize.baselineHeight);
|
||||||
overallHeight=overallHeight+extraDescent;
|
outSize.overallHeight=outSize.overallHeight+extraDescent;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
@ -233,10 +223,6 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
} else if (subn) { // is this subscript?
|
} else if (subn) { // is this subscript?
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||||
double wsub=0;
|
|
||||||
double ohsub=0;
|
|
||||||
double bhsub=0;
|
|
||||||
double spsub=0;//, sp3=0;
|
|
||||||
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
||||||
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
||||||
if (symbN) {
|
if (symbN) {
|
||||||
@ -244,21 +230,21 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
} else {
|
} else {
|
||||||
nodeSize=nodes[i]->getSize(painter, currentEv);
|
nodeSize=nodes[i]->getSize(painter, currentEv);
|
||||||
}
|
}
|
||||||
subn->getChild()->getSize(painter, ev, wsub, bhsub, ohsub, spsub);
|
const JKQTMathTextNodeSize sub=subn->getChild()->getSize(painter, ev);
|
||||||
const double descent1=nodeSize.getDescent();
|
const double descent1=nodeSize.getDescent();
|
||||||
//double d1=oh1-bh1;
|
//double d1=ns.overallHeight-ns.baselineHeight;
|
||||||
//double d2=oh2-bh2;
|
//double d2=oh2-bh2;
|
||||||
|
|
||||||
const double newDescent=descent1+ohsub+subsupershift;
|
const double newDescent=descent1+sub.overallHeight+subsupershift;
|
||||||
if (newDescent>overallHeight-baselineHeight) {
|
if (newDescent>outSize.overallHeight-outSize.baselineHeight) {
|
||||||
const double extraDescent=newDescent-(overallHeight-baselineHeight);
|
const double extraDescent=newDescent-(outSize.overallHeight-outSize.baselineHeight);
|
||||||
overallHeight=overallHeight+extraDescent;
|
outSize.overallHeight=outSize.overallHeight+extraDescent;
|
||||||
}
|
}
|
||||||
if (nodeSize.baselineHeight>baselineHeight) {
|
if (nodeSize.baselineHeight>outSize.baselineHeight) {
|
||||||
overallHeight=overallHeight+(nodeSize.baselineHeight-baselineHeight);
|
outSize.overallHeight=outSize.overallHeight+(nodeSize.baselineHeight-outSize.baselineHeight);
|
||||||
baselineHeight=nodeSize.baselineHeight;
|
outSize.baselineHeight=nodeSize.baselineHeight;
|
||||||
}
|
}
|
||||||
const double neww=qMax(nodeSize.width, wsub+nodeSize.subSuperXCorrection)+subsuperextrawidth;
|
const double neww=qMax(nodeSize.width, sub.width+nodeSize.subSuperXCorrection)+subsuperextrawidth;
|
||||||
i++;
|
i++;
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
xnew+=neww;
|
xnew+=neww;
|
||||||
@ -266,10 +252,6 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
} else if (supn) { // is this superscript?
|
} else if (supn) { // is this superscript?
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||||
double wsup=0;
|
|
||||||
double ohsup=0;
|
|
||||||
double bhsup=0;
|
|
||||||
double spsup=0;//, sp3=0;
|
|
||||||
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
||||||
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
||||||
if (symbN) {
|
if (symbN) {
|
||||||
@ -278,21 +260,21 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
nodeSize=nodes[i]->getSize(painter, currentEv);
|
nodeSize=nodes[i]->getSize(painter, currentEv);
|
||||||
}
|
}
|
||||||
const double descent1=nodeSize.getDescent();
|
const double descent1=nodeSize.getDescent();
|
||||||
supn->getChild()->getSize(painter, ev, wsup, bhsup, ohsup, spsup);
|
const JKQTMathTextNodeSize sup=supn->getChild()->getSize(painter, ev);
|
||||||
//double d1=oh1-bh1;
|
//double d1=ns.overallHeight-ns.baselineHeight;
|
||||||
//double d2=oh2-bh2;
|
//double d2=oh2-bh2;
|
||||||
|
|
||||||
const double newBaselineHeight=nodeSize.baselineHeight+ohsup+subsupershift;
|
const double newBaselineHeight=nodeSize.baselineHeight+sup.overallHeight+subsupershift;
|
||||||
if (newBaselineHeight>baselineHeight) {
|
if (newBaselineHeight>outSize.baselineHeight) {
|
||||||
const double extraBaselineHeight=newBaselineHeight-baselineHeight;
|
const double extraBaselineHeight=newBaselineHeight-outSize.baselineHeight;
|
||||||
baselineHeight=newBaselineHeight;
|
outSize.baselineHeight=newBaselineHeight;
|
||||||
overallHeight=overallHeight+extraBaselineHeight;
|
outSize.overallHeight=outSize.overallHeight+extraBaselineHeight;
|
||||||
}
|
}
|
||||||
if (descent1>overallHeight-baselineHeight) {
|
if (descent1>outSize.overallHeight-outSize.baselineHeight) {
|
||||||
overallHeight=baselineHeight+descent1;
|
outSize.overallHeight=outSize.baselineHeight+descent1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double neww=qMax(nodeSize.width, wsup+nodeSize.subSuperXCorrection)+subsuperextrawidth;
|
const double neww=qMax(nodeSize.width, sup.width+nodeSize.subSuperXCorrection)+subsuperextrawidth;
|
||||||
i++;
|
i++;
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
xnew+=neww;
|
xnew+=neww;
|
||||||
@ -302,33 +284,35 @@ void JKQTMathTextHorizontalListNode::getSizeInternal(QPainter& painter, JKQTMath
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i<nodes.size() && doDraw) {
|
if (i<nodes.size() && doDraw) {
|
||||||
double w=0, oh=0, bh=0, sp=0;
|
JKQTMathTextNodeSize ns;
|
||||||
if (nodeI_SubScript) nodeI_SubScript->getSizeWithSpecialPlacement(painter, currentEv, w, bh, oh, sp, prevNodeSizePtrForSubscript);
|
if (nodeI_SubScript) ns=nodeI_SubScript->getSizeWithSpecialPlacement(painter, currentEv, prevNodeSizePtrForSubscript);
|
||||||
else if (nodeI_SuperScript) nodeI_SuperScript->getSizeWithSpecialPlacement(painter, currentEv, w, bh, oh, sp, prevNodeSizePtrForSuperscript);
|
else if (nodeI_SuperScript) ns=nodeI_SuperScript->getSizeWithSpecialPlacement(painter, currentEv, prevNodeSizePtrForSuperscript);
|
||||||
else nodes[i]->getSize(painter, currentEv, w, bh, oh, sp);
|
else ns=nodes[i]->getSize(painter, currentEv);
|
||||||
const double cDescent=oh-bh;
|
const double cDescent=ns.getDescent();
|
||||||
|
|
||||||
//qDebug()<<"### else: bh="<<bh<<" baselineHeight="<<baselineHeight<<" oh="<<oh<<" overallHeight="<<overallHeight;
|
//qDebug()<<"### else: ns.baselineHeight="<<ns.baselineHeight<<" baselineHeight="<<baselineHeight<<" oh="<<oh<<" overallHeight="<<overallHeight;
|
||||||
if (bh>baselineHeight) {
|
if (ns.baselineHeight>outSize.baselineHeight) {
|
||||||
overallHeight=overallHeight-baselineHeight+bh;
|
outSize.overallHeight=outSize.overallHeight-outSize.baselineHeight+ns.baselineHeight;
|
||||||
baselineHeight=bh;
|
outSize.baselineHeight=ns.baselineHeight;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
}
|
}
|
||||||
if (baselineHeight+cDescent>overallHeight) {
|
if (outSize.baselineHeight+cDescent>outSize.overallHeight) {
|
||||||
overallHeight=baselineHeight+cDescent;
|
outSize.overallHeight=outSize.baselineHeight+cDescent;
|
||||||
strikeoutPos=sp;
|
outSize.strikeoutPos=ns.strikeoutPos;
|
||||||
}
|
}
|
||||||
//qDebug()<<"### subsupop: else overallHeight="<<overallHeight<<" baselineHeight="<<baselineHeight;
|
//qDebug()<<"### subsupop: else overallHeight="<<overallHeight<<" baselineHeight="<<baselineHeight;
|
||||||
|
|
||||||
xnew+=w;
|
xnew+=ns.width;
|
||||||
//qDebug()<<i<<xnew;
|
//qDebug()<<i<<xnew;
|
||||||
}
|
}
|
||||||
//wasBrace=dynamic_cast<JKQTMathTextBraceNode*>(nodes[i]);
|
//wasBrace=dynamic_cast<JKQTMathTextBraceNode*>(nodes[i]);
|
||||||
}
|
}
|
||||||
width=xnew;
|
outSize.width=xnew;
|
||||||
|
|
||||||
|
return outSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
double ynew=y;
|
double ynew=y;
|
||||||
double xnew=x;
|
double xnew=x;
|
||||||
@ -373,13 +357,13 @@ double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double
|
|||||||
|
|
||||||
//painter.setPen(QPen("red"));
|
//painter.setPen(QPen("red"));
|
||||||
//painter.drawEllipse(xnew-4,ynew+shift-(ccOverallHeight-ccBaselineHeight)-4,8,8);
|
//painter.drawEllipse(xnew-4,ynew+shift-(ccOverallHeight-ccBaselineHeight)-4,8,8);
|
||||||
double xnew1=nodeI_SuperScript->drawWithSpecialPlacement(painter, xnew, ynew, currentEv, prevNodeSizePtrForSuperscript);
|
const double xnewidth=nodeI_SuperScript->drawWithSpecialPlacement(painter, xnew, ynew, currentEv, prevNodeSizePtrForSuperscript);
|
||||||
i++;
|
i++;
|
||||||
//painter.setPen(QPen("magenta"));
|
//painter.setPen(QPen("magenta"));
|
||||||
//painter.drawEllipse(xnew-4,ynew-4,8,8);
|
//painter.drawEllipse(xnew-4,ynew-4,8,8);
|
||||||
double xnew2=nodeISucc_SubScript->drawWithSpecialPlacement(painter, xnew-prevNodeSize.subSuperXCorrection, ynew, currentEv, prevNodeSizePtrForSubscript);
|
const double xnew2=nodeISucc_SubScript->drawWithSpecialPlacement(painter, xnew-prevNodeSize.subSuperXCorrection, ynew, currentEv, prevNodeSizePtrForSubscript);
|
||||||
//i++;
|
//i++;
|
||||||
xnew=qMax(xnew1, xnew2);
|
xnew=qMax(xnewidth, xnew2);
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,13 +373,13 @@ double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double
|
|||||||
if (nodeISucc_SuperScript) { // is this subscript?
|
if (nodeISucc_SuperScript) { // is this subscript?
|
||||||
//painter.setPen(QPen("red"));
|
//painter.setPen(QPen("red"));
|
||||||
//painter.drawEllipse(xnew-4,ynew+shift-(ccOverallHeight-ccBaselineHeight)-4,8,8);
|
//painter.drawEllipse(xnew-4,ynew+shift-(ccOverallHeight-ccBaselineHeight)-4,8,8);
|
||||||
double xnew1=nodeI_SubScript->drawWithSpecialPlacement(painter, xnew-prevNodeSize.subSuperXCorrection, ynew, currentEv, prevNodeSizePtrForSubscript);
|
double xnewidth=nodeI_SubScript->drawWithSpecialPlacement(painter, xnew-prevNodeSize.subSuperXCorrection, ynew, currentEv, prevNodeSizePtrForSubscript);
|
||||||
i++;
|
i++;
|
||||||
//painter.setPen(QPen("magenta"));
|
//painter.setPen(QPen("magenta"));
|
||||||
//painter.drawEllipse(xnew-4,ynew-4,8,8);
|
//painter.drawEllipse(xnew-4,ynew-4,8,8);
|
||||||
double xnew2=nodeISucc_SuperScript->drawWithSpecialPlacement(painter, xnew, ynew, currentEv, prevNodeSizePtrForSuperscript);
|
double xnew2=nodeISucc_SuperScript->drawWithSpecialPlacement(painter, xnew, ynew, currentEv, prevNodeSizePtrForSuperscript);
|
||||||
//i++;
|
//i++;
|
||||||
xnew=qMax(xnew1, xnew2);
|
xnew=qMax(xnewidth, xnew2);
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -423,9 +407,6 @@ double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double
|
|||||||
if (!supn) supn=supn2;
|
if (!supn) supn=supn2;
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||||
double wsub=0, wsup=0;
|
|
||||||
double ohsub=0, ohsup=0;
|
|
||||||
double bhsub=0, bhsup=0, spsub, spsup, sp;
|
|
||||||
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
||||||
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
||||||
if (symbN) {
|
if (symbN) {
|
||||||
@ -435,29 +416,26 @@ double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
subn->getChild()->getSize(painter, ev, wsub, bhsub, ohsub, spsub);
|
const JKQTMathTextNodeSize sub=subn->getChild()->getSize(painter, ev);
|
||||||
supn->getChild()->getSize(painter, ev, wsup, bhsup, ohsup, spsup);
|
const JKQTMathTextNodeSize sup=supn->getChild()->getSize(painter, ev);
|
||||||
const double descent1=nodeSize.getDescent();
|
const double descent1=nodeSize.getDescent();
|
||||||
//double d2=oh2-bh2;
|
//double d2=oh2-bh2;
|
||||||
const double descent3=ohsup-bhsup;
|
const double descent3=sup.getDescent();
|
||||||
|
|
||||||
const double neww=qMax(qMax(nodeSize.width, wsub), wsup)+subsuperextrawidth;
|
const double neww=qMax(qMax(nodeSize.width, sub.width), sup.width)+subsuperextrawidth;
|
||||||
//double xnew1=
|
//double xnewidth=
|
||||||
const double xn1=nodes[i]->draw(painter, xnew+(neww-nodeSize.width)/2.0, ynew, currentEv);
|
const double xn1=nodes[i]->draw(painter, xnew+(neww-nodeSize.width)/2.0, ynew, currentEv);
|
||||||
i++;
|
i++;
|
||||||
//double xnew2=
|
//double xnew2=
|
||||||
const double xnsub=subn->getChild()->draw(painter, xnew+(neww-wsub)/2.0-nodeSize.subSuperXCorrection, ynew+bhsub+descent1+subsupershift, ev);
|
const double xnsub=subn->getChild()->draw(painter, xnew+(neww-sub.width)/2.0-nodeSize.subSuperXCorrection, ynew+sub.baselineHeight+descent1+subsupershift, ev);
|
||||||
i++;
|
i++;
|
||||||
//double xnew3=
|
//double xnew3=
|
||||||
const double xnsup=supn->getChild()->draw(painter, xnew+(neww-wsup)/2.0+nodeSize.subSuperXCorrection, ynew-nodeSize.baselineHeight-descent3-subsupershift, ev);
|
const double xnsup=supn->getChild()->draw(painter, xnew+(neww-sup.width)/2.0+nodeSize.subSuperXCorrection, ynew-nodeSize.baselineHeight-descent3-subsupershift, ev);
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
xnew=qMax(qMax(xn1, xnsub), xnsup)+subsuperextrawidth/2.0;
|
xnew=qMax(qMax(xn1, xnsub), xnsup)+subsuperextrawidth/2.0;
|
||||||
} else if (subn) { // is this subscript and no following superscript?
|
} else if (subn) { // is this subscript and no following superscript?
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||||
double wsub=0;
|
|
||||||
double ohsub=0;
|
|
||||||
double bhsub=0, sp=0, spsub=0;
|
|
||||||
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
||||||
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
||||||
if (symbN) {
|
if (symbN) {
|
||||||
@ -465,25 +443,22 @@ double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double
|
|||||||
} else {
|
} else {
|
||||||
nodeSize=nodes[i]->getSize(painter, currentEv);
|
nodeSize=nodes[i]->getSize(painter, currentEv);
|
||||||
}
|
}
|
||||||
subn->getChild()->getSize(painter, ev, wsub, bhsub, ohsub, spsub);
|
const JKQTMathTextNodeSize sub=subn->getChild()->getSize(painter, ev);
|
||||||
const double descent1=nodeSize.getDescent();
|
const double descent1=nodeSize.getDescent();
|
||||||
//double d2=oh2-bh2;
|
//double d2=oh2-bh2;
|
||||||
|
|
||||||
const double neww=qMax(nodeSize.width, wsub)+subsuperextrawidth;
|
const double neww=qMax(nodeSize.width, sub.width)+subsuperextrawidth;
|
||||||
//double xnew1=
|
//double xnewidth=
|
||||||
const double xn1=nodes[i]->draw(painter, xnew+(neww-nodeSize.width)/2.0, ynew, currentEv);
|
const double xn1=nodes[i]->draw(painter, xnew+(neww-nodeSize.width)/2.0, ynew, currentEv);
|
||||||
i++;
|
i++;
|
||||||
//double xnew2=
|
//double xnew2=
|
||||||
const double xnsub=subn->getChild()->draw(painter, xnew+(neww-wsub)/2.0-nodeSize.subSuperXCorrection, ynew+bhsub+descent1+subsupershift, ev)+subsupershift;
|
const double xnsub=subn->getChild()->draw(painter, xnew+(neww-sub.width)/2.0-nodeSize.subSuperXCorrection, ynew+sub.baselineHeight+descent1+subsupershift, ev)+subsupershift;
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
//xnew+=w;
|
//xnew+=w;
|
||||||
xnew=qMax(xnsub, xn1)+subsuperextrawidth/2.0;
|
xnew=qMax(xnsub, xn1)+subsuperextrawidth/2.0;
|
||||||
} else if (supn) { // is this superscript and no following subscript?
|
} else if (supn) { // is this superscript and no following subscript?
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||||
double wsup=0;
|
|
||||||
double ohsup=0;
|
|
||||||
double bhsup=0, sp, spsup;
|
|
||||||
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
JKQTMathTextSymbolNode::NodeSize nodeSize;
|
||||||
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
JKQTMathTextSymbolNode* symbN=dynamic_cast<JKQTMathTextSymbolNode*>(nodes[i]);
|
||||||
if (symbN) {
|
if (symbN) {
|
||||||
@ -491,17 +466,17 @@ double JKQTMathTextHorizontalListNode::draw(QPainter& painter, double x, double
|
|||||||
} else {
|
} else {
|
||||||
nodeSize=nodes[i]->getSize(painter, currentEv);
|
nodeSize=nodes[i]->getSize(painter, currentEv);
|
||||||
}
|
}
|
||||||
supn->getChild()->getSize(painter, ev, wsup, bhsup, ohsup, spsup);
|
const JKQTMathTextNodeSize sup=supn->getChild()->getSize(painter, ev);
|
||||||
//double d1=oh1-bh1;
|
//double d1=ns.overallHeight-ns.baselineHeight;
|
||||||
//double d2=oh2-bh2;
|
//double d2=oh2-bh2;
|
||||||
const double descent3=ohsup-bhsup;
|
const double descent3=sup.getDescent();
|
||||||
|
|
||||||
const double neww=qMax(nodeSize.width, wsup)+subsuperextrawidth;
|
const double neww=qMax(nodeSize.width, sup.width)+subsuperextrawidth;
|
||||||
//double xnew1=
|
//double xnewidth=
|
||||||
const double xn1=nodes[i]->draw(painter, xnew+(neww-nodeSize.width)/2.0, ynew, currentEv);
|
const double xn1=nodes[i]->draw(painter, xnew+(neww-nodeSize.width)/2.0, ynew, currentEv);
|
||||||
i++;
|
i++;
|
||||||
//double xnew3=
|
//double xnew3=
|
||||||
const double xnsup=supn->getChild()->draw(painter, xnew+(neww-wsup)/2.0+nodeSize.subSuperXCorrection, ynew-nodeSize.baselineHeight-descent3-subsupershift, ev);
|
const double xnsup=supn->getChild()->draw(painter, xnew+(neww-sup.width)/2.0+nodeSize.subSuperXCorrection, ynew-nodeSize.baselineHeight-descent3-subsupershift, ev);
|
||||||
doDraw=false;
|
doDraw=false;
|
||||||
xnew=qMax(xn1, xnsup)+subsuperextrawidth/2.0;
|
xnew=qMax(xn1, xnsup)+subsuperextrawidth/2.0;
|
||||||
}
|
}
|
||||||
@ -522,7 +497,7 @@ void JKQTMathTextHorizontalListNode::addChild(JKQTMathTextNode *n) {
|
|||||||
nodes.append(n);
|
nodes.append(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextHorizontalListNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextHorizontalListNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
bool ok=true;
|
bool ok=true;
|
||||||
for (int i=0; i<nodes.size(); i++) {
|
for (int i=0; i<nodes.size(); i++) {
|
||||||
QString h="";
|
QString h="";
|
||||||
@ -605,12 +580,8 @@ QString JKQTMathTextVerticalListNode::getTypeName() const
|
|||||||
return "MTVerticalListNode";
|
return "MTVerticalListNode";
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextVerticalListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextVerticalListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
const LayoutInfo l=calcLayout(painter, currentEv);
|
return calcLayout(painter, currentEv);
|
||||||
width=l.width;
|
|
||||||
overallHeight=l.overallHeight;
|
|
||||||
baselineHeight=l.baselineHeight;
|
|
||||||
strikeoutPos=l.strikeoutPos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTMathTextVerticalListNode::LayoutInfo JKQTMathTextVerticalListNode::calcLayout(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
JKQTMathTextVerticalListNode::LayoutInfo JKQTMathTextVerticalListNode::calcLayout(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
@ -633,27 +604,26 @@ JKQTMathTextVerticalListNode::LayoutInfo JKQTMathTextVerticalListNode::calcLayou
|
|||||||
QList<double> ysFromFirstLine; // y-position of each line, where the first line is always at y=0 (i.e. ysFromFirstLine[0]==0)
|
QList<double> ysFromFirstLine; // y-position of each line, where the first line is always at y=0 (i.e. ysFromFirstLine[0]==0)
|
||||||
double y=0;
|
double y=0;
|
||||||
for (int i=0; i<nodes.size(); i++) {
|
for (int i=0; i<nodes.size(); i++) {
|
||||||
double locWidth=0, locOverallHeight=0, locBaselineHeight=0, locStrikeoutPos=0;
|
const JKQTMathTextNodeSize loc=nodes[i]->getSize(painter, currentEv);
|
||||||
nodes[i]->getSize(painter, currentEv, locWidth, locBaselineHeight, locOverallHeight, locStrikeoutPos);
|
|
||||||
|
|
||||||
if (i==0) {
|
if (i==0) {
|
||||||
heightSum=locBaselineHeight;
|
heightSum=loc.baselineHeight;
|
||||||
} else if (i>0) {
|
} else if (i>0) {
|
||||||
double deltaLine=0;
|
double deltaLine=0;
|
||||||
if (spacingMode==MTSMMinimalSpacing) {
|
if (spacingMode==MTSMMinimalSpacing) {
|
||||||
deltaLine=descents.last()+lineLeading+locBaselineHeight;
|
deltaLine=descents.last()+lineLeading+loc.baselineHeight;
|
||||||
} else if (spacingMode==MTSMDefaultSpacing) {
|
} else if (spacingMode==MTSMDefaultSpacing) {
|
||||||
deltaLine=qMax(linespacing, descents.last()+lineLeading+locBaselineHeight);
|
deltaLine=qMax(linespacing, descents.last()+lineLeading+loc.baselineHeight);
|
||||||
}
|
}
|
||||||
heightSum=heightSum+deltaLine;
|
heightSum=heightSum+deltaLine;
|
||||||
y=y+deltaLine;
|
y=y+deltaLine;
|
||||||
}
|
}
|
||||||
widths<<locWidth;
|
widths<<loc.width;
|
||||||
l.width=qMax(l.width, locWidth);
|
l.width=qMax(l.width, loc.width);
|
||||||
heights<<locOverallHeight;
|
heights<<loc.overallHeight;
|
||||||
ascents<<locBaselineHeight;
|
ascents<<loc.baselineHeight;
|
||||||
descents<<(locOverallHeight-locBaselineHeight);
|
descents<<(loc.overallHeight-loc.baselineHeight);
|
||||||
strikeouts<<locStrikeoutPos;
|
strikeouts<<loc.strikeoutPos;
|
||||||
ysFromFirstLine<<y;
|
ysFromFirstLine<<y;
|
||||||
}
|
}
|
||||||
heightSum+=descents.last();
|
heightSum+=descents.last();
|
||||||
@ -690,7 +660,7 @@ JKQTMathTextVerticalListNode::LayoutInfo JKQTMathTextVerticalListNode::calcLayou
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextVerticalListNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextVerticalListNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
const LayoutInfo l=calcLayout(painter, currentEv);
|
const LayoutInfo l=calcLayout(painter, currentEv);
|
||||||
for (int i=0; i<nodes.size(); i++) {
|
for (int i=0; i<nodes.size(); i++) {
|
||||||
@ -704,7 +674,7 @@ void JKQTMathTextVerticalListNode::addChild(JKQTMathTextNode *n) {
|
|||||||
nodes.append(n);
|
nodes.append(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextVerticalListNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextVerticalListNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
bool ok=true;
|
bool ok=true;
|
||||||
if (alignment==MTHALeft) {
|
if (alignment==MTHALeft) {
|
||||||
html+="<div align=\"left\">";
|
html+="<div align=\"left\">";
|
||||||
@ -817,3 +787,33 @@ void JKQTMathTextVerticalListNode::setSpacingMode(JKQTMathTextLineSpacingMode va
|
|||||||
JKQTMathTextVerticalListNode::LayoutInfo::LayoutInfo():
|
JKQTMathTextVerticalListNode::LayoutInfo::LayoutInfo():
|
||||||
JKQTMathTextNodeSize(), X()
|
JKQTMathTextNodeSize(), X()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JKQTMathTextVerticalListNode::LayoutInfo::LayoutInfo(const JKQTMathTextNodeSize &other):
|
||||||
|
JKQTMathTextNodeSize(other),
|
||||||
|
X()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextVerticalListNode::LayoutInfo &JKQTMathTextVerticalListNode::LayoutInfo::operator=(const JKQTMathTextNodeSize &other)
|
||||||
|
{
|
||||||
|
JKQTMathTextNodeSize::operator=(other);
|
||||||
|
X.clear();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextVerticalListNode::LayoutInfo &JKQTMathTextVerticalListNode::LayoutInfo::operator=(const LayoutInfo &other)
|
||||||
|
{
|
||||||
|
JKQTMathTextNodeSize::operator=(dynamic_cast<const JKQTMathTextNodeSize&>(other));
|
||||||
|
X=other.X;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextVerticalListNode::LayoutInfo::LayoutInfo(const LayoutInfo &other):
|
||||||
|
JKQTMathTextNodeSize(dynamic_cast<const JKQTMathTextNodeSize&>(other)),
|
||||||
|
X(other.X)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -49,9 +49,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextHorizontalListNode: public JKQTMathTex
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \brief add a child node */
|
/** \brief add a child node */
|
||||||
void addChild(JKQTMathTextNode* n);
|
void addChild(JKQTMathTextNode* n);
|
||||||
/** \copydoc JKQTMathTextMultiChildNode::getChildren() */
|
/** \copydoc JKQTMathTextMultiChildNode::getChildren() */
|
||||||
@ -70,7 +70,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextHorizontalListNode: public JKQTMathTex
|
|||||||
virtual JKQTMathTextNode* replaceChild(int i, JKQTMathTextNode* newChild) override;
|
virtual JKQTMathTextNode* replaceChild(int i, JKQTMathTextNode* newChild) override;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
QList<JKQTMathTextNode*> nodes;
|
QList<JKQTMathTextNode*> nodes;
|
||||||
private:
|
private:
|
||||||
/** \brief internal implementation of clearChildren() that is non-virtual, so can be used in the destructor */
|
/** \brief internal implementation of clearChildren() that is non-virtual, so can be used in the destructor */
|
||||||
@ -101,9 +101,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextVerticalListNode: public JKQTMathTextM
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \brief add a child node */
|
/** \brief add a child node */
|
||||||
void addChild(JKQTMathTextNode* n);
|
void addChild(JKQTMathTextNode* n);
|
||||||
/** \copydoc JKQTMathTextMultiChildNode::getChildren() */
|
/** \copydoc JKQTMathTextMultiChildNode::getChildren() */
|
||||||
@ -138,11 +138,15 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextVerticalListNode: public JKQTMathTextM
|
|||||||
void setSpacingMode(JKQTMathTextLineSpacingMode value) ;
|
void setSpacingMode(JKQTMathTextLineSpacingMode value) ;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
|
|
||||||
/** \brief describes the layout of the whole node */
|
/** \brief describes the layout of the whole node */
|
||||||
struct LayoutInfo: public JKQTMathTextNodeSize {
|
struct LayoutInfo: public JKQTMathTextNodeSize {
|
||||||
LayoutInfo();
|
LayoutInfo();
|
||||||
|
LayoutInfo(const LayoutInfo& other);
|
||||||
|
LayoutInfo(const JKQTMathTextNodeSize& other);
|
||||||
|
LayoutInfo& operator=(const LayoutInfo& other);
|
||||||
|
LayoutInfo& operator=(const JKQTMathTextNodeSize& other);
|
||||||
/** \brief drawing position for each line */
|
/** \brief drawing position for each line */
|
||||||
QList<QPointF> X;
|
QList<QPointF> X;
|
||||||
};
|
};
|
||||||
|
@ -98,7 +98,7 @@ QString JKQTMathTextMatrixNode::getTypeName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JKQTMathTextMatrixNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/)
|
bool JKQTMathTextMatrixNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -362,21 +362,17 @@ JKQTMathTextMatrixNode::LayoutInfo JKQTMathTextMatrixNode::calcLayout(QPainter &
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextMatrixNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextMatrixNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
const LayoutInfo l=calcLayout(painter, currentEv);
|
return calcLayout(painter, currentEv);
|
||||||
width=l.width;
|
|
||||||
overallHeight=l.overallHeight;
|
|
||||||
baselineHeight=l.baselineHeight;
|
|
||||||
strikeoutPos=l.strikeoutPos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextMatrixNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextMatrixNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
|
||||||
|
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
JKQTMathTextEnvironment ev1=currentEv;
|
JKQTMathTextEnvironment ev1=currentEv;
|
||||||
|
|
||||||
const LayoutInfo l=calcLayout(painter, currentEv);
|
const LayoutInfo l=calcLayout(painter, currentEv);
|
||||||
|
doDrawBoxes(painter, x, y, l);
|
||||||
|
|
||||||
const double xwidth=fm.boundingRect("x").width();
|
const double xwidth=fm.boundingRect("x").width();
|
||||||
const double XSeparation=parentMathText->getMatrixXSeparationFactor()*xwidth;
|
const double XSeparation=parentMathText->getMatrixXSeparationFactor()*xwidth;
|
||||||
|
@ -68,9 +68,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextMatrixNode: public JKQTMathTextMultiCh
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \brief returns the child nodes */
|
/** \brief returns the child nodes */
|
||||||
QVector<QVector<JKQTMathTextNode*> > getChildrenMatrix() const;
|
QVector<QVector<JKQTMathTextNode*> > getChildrenMatrix() const;
|
||||||
/** \copydoc columns */
|
/** \copydoc columns */
|
||||||
@ -122,7 +122,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextMatrixNode: public JKQTMathTextMultiCh
|
|||||||
*/
|
*/
|
||||||
LayoutInfo calcLayout(QPainter& painter, const JKQTMathTextEnvironment& currentEv) const;
|
LayoutInfo calcLayout(QPainter& painter, const JKQTMathTextEnvironment& currentEv) const;
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||||
virtual void setDrawBoxes(bool draw) override;
|
virtual void setDrawBoxes(bool draw) override;
|
||||||
/** \brief child nodes making up the matrix, vector of rows */
|
/** \brief child nodes making up the matrix, vector of rows */
|
||||||
|
@ -50,33 +50,26 @@ JKQTMathTextNode::JKQTMathTextNode(JKQTMathText *_parent):
|
|||||||
JKQTMathTextNode::~JKQTMathTextNode()
|
JKQTMathTextNode::~JKQTMathTextNode()
|
||||||
= default;
|
= default;
|
||||||
|
|
||||||
void JKQTMathTextNode::getSize(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextNode::getSize(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
double w=width, b=baselineHeight, o=overallHeight, s=strikeoutPos;
|
return getSizeInternal(painter, currentEv);
|
||||||
getSizeInternal(painter, currentEv, w, b, o, s);
|
|
||||||
|
|
||||||
if (w<1e5) width=w;
|
|
||||||
if (b<1e5) baselineHeight=b;
|
|
||||||
if (o<1e5) overallHeight=o;
|
|
||||||
if (s<1e5) strikeoutPos=s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double JKQTMathTextNode::getNonItalicXCorretion(QPainter &painter, double width_potentiallyitalic, const JKQTMathTextEnvironment &ev_potentiallyitalic, JKQTMathTextNode* child) const
|
double JKQTMathTextNode::getNonItalicXCorretion(QPainter &painter, double width_potentiallyitalic, const JKQTMathTextEnvironment &ev_potentiallyitalic, const JKQTMathTextNode* child)
|
||||||
{
|
{
|
||||||
double italic_xcorrection=0.0;
|
double italic_xcorrection=0.0;
|
||||||
if (ev_potentiallyitalic.italic) {
|
if (ev_potentiallyitalic.italic) {
|
||||||
JKQTMathTextEnvironment ev_nonitalic=ev_potentiallyitalic;
|
JKQTMathTextEnvironment ev_nonitalic=ev_potentiallyitalic;
|
||||||
ev_nonitalic.italic=false;
|
ev_nonitalic.italic=false;
|
||||||
double width_nonitalic=0, baselineHeight_nonitalic=0, overallHeight_nonitalic=0, strikeoutPos_nonitalic=0;
|
JKQTMathTextNodeSize s_nonitalic=child->getSize(painter, ev_nonitalic);
|
||||||
child->getSize(painter, ev_nonitalic, width_nonitalic, baselineHeight_nonitalic, overallHeight_nonitalic, strikeoutPos_nonitalic);
|
italic_xcorrection=width_potentiallyitalic-s_nonitalic.width;
|
||||||
italic_xcorrection=width_potentiallyitalic-width_nonitalic;
|
|
||||||
}
|
}
|
||||||
return italic_xcorrection;
|
return italic_xcorrection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JKQTMathTextNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) {
|
bool JKQTMathTextNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,24 +78,23 @@ bool JKQTMathTextNode::getDrawBoxes() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JKQTMathTextNode::doDrawBoxes(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
void JKQTMathTextNode::doDrawBoxes(QPainter &painter, double x, double y, const JKQTMathTextNodeSize &size) const
|
||||||
|
{
|
||||||
if (drawBoxes) {
|
if (drawBoxes) {
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
double w, oh, bh, sp;
|
|
||||||
getSize(painter, currentEv, w, bh, oh, sp);
|
|
||||||
QPen p=painter.pen();
|
QPen p=painter.pen();
|
||||||
p.setColor("lightcoral");
|
p.setColor("lightcoral");
|
||||||
p.setWidthF(0.5);
|
p.setWidthF(0.5);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
QRectF r(x, y-bh, w, oh);
|
QRectF r(x, y-size.baselineHeight, size.width, size.overallHeight );
|
||||||
painter.drawRect(r);
|
painter.drawRect(r);
|
||||||
p.setColor("lightblue");
|
p.setColor("lightblue");
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
if (w>0) painter.drawLine(QLineF(x, y, x+w, y));
|
if (size.width>0) painter.drawLine(QLineF(x, y, x+size.width, y));
|
||||||
p.setColor("pink");
|
p.setColor("pink");
|
||||||
p.setStyle(Qt::DashLine);
|
p.setStyle(Qt::DashLine);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
if (w>0) painter.drawLine(QLineF(x, y-sp, x+w, y-sp));
|
if (size.width>0) painter.drawLine(QLineF(x, y-size.strikeoutPos, x+size.width, y-size.strikeoutPos));
|
||||||
p.setColor("green");
|
p.setColor("green");
|
||||||
p.setStyle(Qt::SolidLine);
|
p.setStyle(Qt::SolidLine);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
@ -113,6 +105,13 @@ void JKQTMathTextNode::doDrawBoxes(QPainter& painter, double x, double y, JKQTMa
|
|||||||
painter.drawLine(QLineF(x, y-2, x, y+2.0));
|
painter.drawLine(QLineF(x, y-2, x, y+2.0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void JKQTMathTextNode::doDrawBoxes(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
|
if (drawBoxes) {
|
||||||
|
doDrawBoxes(painter, x, y, getSize(painter, currentEv));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextNode::setDrawBoxes(bool draw)
|
void JKQTMathTextNode::setDrawBoxes(bool draw)
|
||||||
@ -151,6 +150,7 @@ void JKQTMathTextNode::setSubSuperscriptAboveBelowNode(bool __value)
|
|||||||
subSuperscriptAboveBelowNode=__value;
|
subSuperscriptAboveBelowNode=__value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JKQTMathTextSingleChildNode::JKQTMathTextSingleChildNode(JKQTMathTextNode *_child, JKQTMathText *parentMathText):
|
JKQTMathTextSingleChildNode::JKQTMathTextSingleChildNode(JKQTMathTextNode *_child, JKQTMathText *parentMathText):
|
||||||
JKQTMathTextNode(parentMathText),
|
JKQTMathTextNode(parentMathText),
|
||||||
child(_child)
|
child(_child)
|
||||||
@ -374,13 +374,6 @@ void JKQTMathTextMultiChildNode::setDrawBoxes(bool draw)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTMathTextNodeSize JKQTMathTextNode::getSize(QPainter &painter, JKQTMathTextEnvironment currentEv)
|
|
||||||
{
|
|
||||||
JKQTMathTextNodeSize s;
|
|
||||||
getSize(painter, currentEv, s.width, s.baselineHeight, s.overallHeight, s.strikeoutPos);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
JKQTMathTextNoopNode::JKQTMathTextNoopNode(JKQTMathText *parent):
|
JKQTMathTextNoopNode::JKQTMathTextNoopNode(JKQTMathText *parent):
|
||||||
JKQTMathTextNode(parent)
|
JKQTMathTextNode(parent)
|
||||||
{
|
{
|
||||||
@ -397,20 +390,17 @@ QString JKQTMathTextNoopNode::getTypeName() const
|
|||||||
return "MTNoopNode";
|
return "MTNoopNode";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextNoopNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv)
|
bool JKQTMathTextNoopNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextNoopNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextNoopNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextNoopNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextNoopNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
width=0;
|
return JKQTMathTextNodeSize();
|
||||||
baselineHeight=0;
|
|
||||||
overallHeight=0;
|
|
||||||
strikeoutPos=0;
|
|
||||||
}
|
}
|
||||||
|
@ -40,17 +40,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
|||||||
JKQTMathTextNode(const JKQTMathTextNode&)=delete;
|
JKQTMathTextNode(const JKQTMathTextNode&)=delete;
|
||||||
JKQTMathTextNode& operator=(const JKQTMathTextNode&)=delete;
|
JKQTMathTextNode& operator=(const JKQTMathTextNode&)=delete;
|
||||||
virtual ~JKQTMathTextNode();
|
virtual ~JKQTMathTextNode();
|
||||||
/** \brief determine the size of the node, calls getSizeInternal() implementation of the actual type \see getSizeInternal()
|
|
||||||
*
|
|
||||||
* \param painter painter to use for determining the size
|
|
||||||
* \param currentEv current environment object
|
|
||||||
* \param[out] width width of the block/node
|
|
||||||
* \param[out] baselineHeight distance from the bottom of the block/node-box to the baseline
|
|
||||||
* \param[out] overallHeight overall height (bottom to top) of the node, the ascent is \c overallHeight-baselineHeight
|
|
||||||
* \param[out] strikeoutPos position of the strikeout-line
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void getSize(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos);
|
|
||||||
/** \brief determine the size of the node, calls getSizeInternal() implementation of the actual type \see getSizeInternal()
|
/** \brief determine the size of the node, calls getSizeInternal() implementation of the actual type \see getSizeInternal()
|
||||||
*
|
*
|
||||||
* \param painter painter to use for determining the size
|
* \param painter painter to use for determining the size
|
||||||
@ -59,9 +48,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
|||||||
* \return all important box size parameters packed as JKQTMathTextNodeSize
|
* \return all important box size parameters packed as JKQTMathTextNodeSize
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
JKQTMathTextNodeSize getSize(QPainter& painter, JKQTMathTextEnvironment currentEv);
|
JKQTMathTextNodeSize getSize(QPainter& painter, JKQTMathTextEnvironment currentEv) const;
|
||||||
/** \brief calculates the x-size-difference between the given (probably) italic (width externally calculated: \a width_potentiallyitalic, \a ev_potentiallyitalic) and the non-italic version of \a child */
|
/** \brief calculates the x-size-difference between the given (probably) italic (width externally calculated: \a width_potentiallyitalic, \a ev_potentiallyitalic) and the non-italic version of \a child */
|
||||||
double getNonItalicXCorretion(QPainter &painter, double width_potentiallyitalic, const JKQTMathTextEnvironment &ev_potentiallyitalic, JKQTMathTextNode* child) const;
|
static double getNonItalicXCorretion(QPainter &painter, double width_potentiallyitalic, const JKQTMathTextEnvironment &ev_potentiallyitalic, const JKQTMathTextNode* child) ;
|
||||||
/** \brief draw the contents at the designated position
|
/** \brief draw the contents at the designated position
|
||||||
*
|
*
|
||||||
* \param painter QPainter to use
|
* \param painter QPainter to use
|
||||||
@ -71,14 +60,14 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
|||||||
*
|
*
|
||||||
* \return the x position which to use for the next part of the text
|
* \return the x position which to use for the next part of the text
|
||||||
*/
|
*/
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv)=0;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const=0;
|
||||||
/** \brief convert node to HTML and returns \c true on success
|
/** \brief convert node to HTML and returns \c true on success
|
||||||
* \param[out] html new HTML code is APPENDED to this string
|
* \param[out] html new HTML code is APPENDED to this string
|
||||||
* \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
|
* \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
|
||||||
* \param defaultEv JKQTMathTextEnvironment object describing the default drawing environment/settings when starting to interpret a node tree
|
* \param defaultEv JKQTMathTextEnvironment object describing the default drawing environment/settings when starting to interpret a node tree
|
||||||
* \return \c true on success
|
* \return \c true on success
|
||||||
*/
|
*/
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv);
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const;
|
||||||
|
|
||||||
/** \brief returns the drawing of colored boxes (for DEBUGGING) around the actual output of the node is enabled */
|
/** \brief returns the drawing of colored boxes (for DEBUGGING) around the actual output of the node is enabled */
|
||||||
bool getDrawBoxes() const;
|
bool getDrawBoxes() const;
|
||||||
@ -108,7 +97,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
|||||||
* \param[out] strikeoutPos position of the strikeout-line
|
* \param[out] strikeoutPos position of the strikeout-line
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos)=0;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const =0;
|
||||||
|
|
||||||
/** \brief parent JKQTMathText object (required for several drawing operations */
|
/** \brief parent JKQTMathText object (required for several drawing operations */
|
||||||
JKQTMathText* parentMathText;
|
JKQTMathText* parentMathText;
|
||||||
@ -127,9 +116,21 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
|||||||
* \param painter QPainter to use
|
* \param painter QPainter to use
|
||||||
* \param x x-position, where the drawing starts [Pixel]
|
* \param x x-position, where the drawing starts [Pixel]
|
||||||
* \param y Y-position of the baseline, where the drawing starts [Pixel]
|
* \param y Y-position of the baseline, where the drawing starts [Pixel]
|
||||||
* \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
|
* \param size size of the node, result of getSize(), see JKQTMathTextNodeSize
|
||||||
*/
|
*/
|
||||||
void doDrawBoxes(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv);
|
void doDrawBoxes(QPainter& painter, double x, double y, const JKQTMathTextNodeSize& size) const;
|
||||||
|
/** \brief draws colored boxes (for DEBUGGING) around the actual output of the node
|
||||||
|
*
|
||||||
|
* \param painter QPainter to use
|
||||||
|
* \param x x-position, where the drawing starts [Pixel]
|
||||||
|
* \param y Y-position of the baseline, where the drawing starts [Pixel]
|
||||||
|
* \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
|
||||||
|
*
|
||||||
|
* \note This version of the function calls getSize() internally. There is a second variant that
|
||||||
|
* skips this call and expects the node size info as parameter. This can be used in
|
||||||
|
* draw() implementations that call getSize() themselves to speed up drawing.
|
||||||
|
*/
|
||||||
|
void doDrawBoxes(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const;
|
||||||
|
|
||||||
|
|
||||||
/** \brief returns the list of parent, parent-of-parent, ... that can be cast to type \a T */
|
/** \brief returns the list of parent, parent-of-parent, ... that can be cast to type \a T */
|
||||||
@ -292,12 +293,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNoopNode: public JKQTMathTextNode {
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // JKQTMATHTEXTNODE_H
|
#endif // JKQTMATHTEXTNODE_H
|
||||||
|
@ -50,30 +50,32 @@ JKQTMathTextSqrtNode::~JKQTMathTextSqrtNode() {
|
|||||||
childDegree=nullptr;
|
childDegree=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextSqrtNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextSqrtNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
|
JKQTMathTextNodeSize s;
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
JKQTMathTextEnvironment evSmall=currentEv;
|
JKQTMathTextEnvironment evSmall=currentEv;
|
||||||
evSmall.fontSize=currentEv.fontSize*parentMathText->getSqrtSmallFontFactor();
|
evSmall.fontSize=currentEv.fontSize*parentMathText->getSqrtSmallFontFactor();
|
||||||
evSmall.italic=false;
|
evSmall.italic=false;
|
||||||
|
|
||||||
getChild()->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, currentEv);
|
||||||
const double descent=overallHeight-baselineHeight;
|
const double descent=cs.getDescent();
|
||||||
const double sqrtwidth=fm.boundingRect("X").width()*parentMathText->getSqrtWidthXFactor();
|
const double sqrtwidth=fm.boundingRect("X").width()*parentMathText->getSqrtWidthXFactor();
|
||||||
const double newAscent=qMax(baselineHeight*parentMathText->getSqrtHeightFactor(), fm.ascent());
|
const double newAscent=qMax(cs.baselineHeight*parentMathText->getSqrtHeightFactor(), fm.ascent());
|
||||||
const double newDescent=qMax(descent*parentMathText->getSqrtHeightFactor(), fm.descent());
|
const double newDescent=qMax(descent*parentMathText->getSqrtHeightFactor(), fm.descent());
|
||||||
|
|
||||||
overallHeight=newAscent+newDescent;;
|
s.overallHeight=newAscent+newDescent;
|
||||||
baselineHeight=newAscent;
|
s.baselineHeight=newAscent;
|
||||||
width=width+sqrtwidth;
|
s.width=cs.width+sqrtwidth;
|
||||||
|
s.strikeoutPos=cs.strikeoutPos;
|
||||||
if (childDegree) {
|
if (childDegree) {
|
||||||
double degwidth=0, degBH=0, degOH=0, degSP=0;
|
const JKQTMathTextNodeSize ds=childDegree->getSize(painter, evSmall);
|
||||||
childDegree->getSize(painter, evSmall, degwidth, degBH, degOH, degSP);
|
|
||||||
const double smalltextIndent=0.6*sqrtwidth;
|
const double smalltextIndent=0.6*sqrtwidth;
|
||||||
if (degwidth>smalltextIndent) width=width+(degwidth-smalltextIndent);
|
if (ds.width>smalltextIndent) s.width=s.width+(ds.width-smalltextIndent);
|
||||||
}
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
|
|
||||||
const QFont f=currentEv.getFont(parentMathText);
|
const QFont f=currentEv.getFont(parentMathText);
|
||||||
@ -82,20 +84,19 @@ double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
evSmall.fontSize=currentEv.fontSize*parentMathText->getSqrtSmallFontFactor();
|
evSmall.fontSize=currentEv.fontSize*parentMathText->getSqrtSmallFontFactor();
|
||||||
evSmall.italic=false;
|
evSmall.italic=false;
|
||||||
|
|
||||||
double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0;
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, currentEv);
|
||||||
getChild()->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
const double descent=cs.overallHeight-cs.baselineHeight;
|
||||||
const double descent=overallHeight-baselineHeight;
|
|
||||||
const double sqrtwidth=fm.boundingRect("X").width()*parentMathText->getSqrtWidthXFactor();
|
const double sqrtwidth=fm.boundingRect("X").width()*parentMathText->getSqrtWidthXFactor();
|
||||||
const double newAscent=qMax(baselineHeight*parentMathText->getSqrtHeightFactor(), fm.ascent());
|
const double newAscent=qMax(cs.baselineHeight*parentMathText->getSqrtHeightFactor(), fm.ascent());
|
||||||
const double newDescent=qMax(descent*parentMathText->getSqrtHeightFactor(), fm.descent());
|
const double newDescent=qMax(descent*parentMathText->getSqrtHeightFactor(), fm.descent());
|
||||||
const double linewidth=fm.lineWidth();
|
const double linewidth=fm.lineWidth();
|
||||||
const double tinyhookSize=sqrtwidth*0.1;
|
const double tinyhookSize=sqrtwidth*0.1;
|
||||||
const double smalltextIndent=0.6*sqrtwidth;
|
const double smalltextIndent=0.6*sqrtwidth;
|
||||||
|
|
||||||
double degwidth=0, degBH=0, degOH=0, degSP=0;
|
JKQTMathTextNodeSize ds;
|
||||||
if (childDegree) childDegree->getSize(painter, evSmall, degwidth, degBH, degOH, degSP);
|
if (childDegree) ds=childDegree->getSize(painter, evSmall);
|
||||||
const double degheight=degOH;
|
const double degheight=ds.overallHeight;
|
||||||
const double degree_overwidth=(degwidth>smalltextIndent)?(degwidth-smalltextIndent):0.0;
|
const double degree_overwidth=(ds.width>smalltextIndent)?(ds.width-smalltextIndent):0.0;
|
||||||
|
|
||||||
//painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
//painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
QPen p=painter.pen();
|
QPen p=painter.pen();
|
||||||
@ -107,8 +108,8 @@ double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
|
|
||||||
double xnew=getChild()->draw(painter, x+sqrtwidth+degree_overwidth, y, currentEv);
|
double xnew=getChild()->draw(painter, x+sqrtwidth+degree_overwidth, y, currentEv);
|
||||||
|
|
||||||
const bool useAltForm=overallHeight>4.0*sqrtwidth;
|
const bool useAltForm=cs.overallHeight>4.0*sqrtwidth;
|
||||||
const double y_tinyhooktop=y-strikeoutPos;
|
const double y_tinyhooktop=y-cs.strikeoutPos;
|
||||||
const double y_bottom=y+newDescent-linewidth/2.0;
|
const double y_bottom=y+newDescent-linewidth/2.0;
|
||||||
const double y_top=y-newAscent+linewidth/2.0;
|
const double y_top=y-newAscent+linewidth/2.0;
|
||||||
const double x_start=x+degree_overwidth+linewidth/2.0;
|
const double x_start=x+degree_overwidth+linewidth/2.0;
|
||||||
@ -116,7 +117,7 @@ double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
const double x_hookbottom=(!useAltForm)?(x_start+0.33*sqrtwidth):(x_start+0.66*sqrtwidth);
|
const double x_hookbottom=(!useAltForm)?(x_start+0.33*sqrtwidth):(x_start+0.66*sqrtwidth);
|
||||||
const double x_hooktop=(!useAltForm)?(x_start+sqrtwidth):x_hookbottom;
|
const double x_hooktop=(!useAltForm)?(x_start+sqrtwidth):x_hookbottom;
|
||||||
const double x_smalltextend=x_start+smalltextIndent;
|
const double x_smalltextend=x_start+smalltextIndent;
|
||||||
const double y_smalltext=y_top+degBH+(fabs(y_top-(y_tinyhooktop-linewidth))-degheight)/2.0;
|
const double y_smalltext=y_top+ds.baselineHeight+(fabs(y_top-(y_tinyhooktop-linewidth))-degheight)/2.0;
|
||||||
if (sqrtwidth>0) {
|
if (sqrtwidth>0) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.moveTo(x_start, y_tinyhooktop+tinyhookSize);
|
path.moveTo(x_start, y_tinyhooktop+tinyhookSize);
|
||||||
@ -131,13 +132,13 @@ double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
}
|
}
|
||||||
if (childDegree) {
|
if (childDegree) {
|
||||||
childDegree->draw(painter, x_smalltextend-degwidth, y_smalltext, evSmall);
|
childDegree->draw(painter, x_smalltextend-ds.width, y_smalltext, evSmall);
|
||||||
}
|
}
|
||||||
|
|
||||||
return xnew;
|
return xnew;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextSqrtNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextSqrtNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
bool ok=true;
|
bool ok=true;
|
||||||
if (childDegree) {
|
if (childDegree) {
|
||||||
JKQTMathTextEnvironment evSmall=currentEv;
|
JKQTMathTextEnvironment evSmall=currentEv;
|
||||||
|
@ -45,9 +45,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSqrtNode: public JKQTMathTextMultiChil
|
|||||||
JKQTMathTextSqrtNode(JKQTMathText* parent, JKQTMathTextNode* child__, JKQTMathTextNode* childDegree__=nullptr);
|
JKQTMathTextSqrtNode(JKQTMathText* parent, JKQTMathTextNode* child__, JKQTMathTextNode* childDegree__=nullptr);
|
||||||
virtual ~JKQTMathTextSqrtNode() override;
|
virtual ~JKQTMathTextSqrtNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override ;
|
virtual QString getTypeName() const override ;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSqrtNode: public JKQTMathTextMultiChil
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief child node for the part under the root */
|
/** \brief child node for the part under the root */
|
||||||
JKQTMathTextNode* child;
|
JKQTMathTextNode* child;
|
||||||
/** \brief second child node for the degree of the root (or nullptr if nothing) */
|
/** \brief second child node for the degree of the root (or nullptr if nothing) */
|
||||||
|
@ -45,48 +45,48 @@ JKQTMathTextSuperscriptNode::JKQTMathTextSuperscriptNode(JKQTMathText* _parent,
|
|||||||
JKQTMathTextSuperscriptNode::~JKQTMathTextSuperscriptNode() {
|
JKQTMathTextSuperscriptNode::~JKQTMathTextSuperscriptNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextSuperscriptNode::getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) {
|
JKQTMathTextNodeSize JKQTMathTextSuperscriptNode::getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const{
|
||||||
|
JKQTMathTextNodeSize s;
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||||
double cStrikeoutPos=0, cWidth=0, cBaselineHeight=0, cOverallHeight=0;
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
const double childDescent=cs.getDescent();
|
||||||
const double childDescent=cOverallHeight-cBaselineHeight;
|
|
||||||
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
||||||
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cBaselineHeight-childDescent;
|
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cs.baselineHeight-childDescent;
|
||||||
if (modifiedShift>shiftToChildBottom) shiftToChildBottom=modifiedShift;
|
if (modifiedShift>shiftToChildBottom) shiftToChildBottom=modifiedShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
baselineHeight=overallHeight=cOverallHeight+shiftToChildBottom;
|
s.baselineHeight=s.overallHeight=cs.overallHeight+shiftToChildBottom;
|
||||||
width=cWidth;
|
s.width=cs.width;
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) strikeoutPos=prevNodeSizeForSpecialPlacement->strikeoutPos;
|
if (prevNodeSizeForSpecialPlacement!=nullptr) s.strikeoutPos=prevNodeSizeForSpecialPlacement->strikeoutPos;
|
||||||
else strikeoutPos=fm.strikeOutPos();
|
else s.strikeoutPos=fm.strikeOutPos();
|
||||||
if (currentEv.italic && prevNodeSizeForSpecialPlacement==nullptr) width=width+double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
if (currentEv.italic && prevNodeSizeForSpecialPlacement==nullptr) s.width=s.width+double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextSuperscriptNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextSuperscriptNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
getSizeWithSpecialPlacement(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos, nullptr);
|
return getSizeWithSpecialPlacement(painter, currentEv, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextSuperscriptNode::drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) {
|
double JKQTMathTextSuperscriptNode::drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||||
|
|
||||||
double cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos;
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
|
||||||
|
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
//QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||||
const double childDescent=cOverallHeight-cBaselineHeight;
|
const double childDescent=cs.overallHeight-cs.baselineHeight;
|
||||||
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
||||||
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cBaselineHeight-childDescent;
|
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cs.baselineHeight-childDescent;
|
||||||
if (modifiedShift>shiftToChildBottom) shiftToChildBottom=modifiedShift;
|
if (modifiedShift>shiftToChildBottom) shiftToChildBottom=modifiedShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ double JKQTMathTextSuperscriptNode::drawWithSpecialPlacement(QPainter& painter,
|
|||||||
return getChild()->draw(painter, xx, y-(shiftToChildBottom+childDescent), ev);//+0.5*fm.boundingRect("A").width();
|
return getChild()->draw(painter, xx, y-(shiftToChildBottom+childDescent), ev);//+0.5*fm.boundingRect("A").width();
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextSuperscriptNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextSuperscriptNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
return drawWithSpecialPlacement(painter, x, y, currentEv, nullptr);
|
return drawWithSpecialPlacement(painter, x, y, currentEv, nullptr);
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ QString JKQTMathTextSuperscriptNode::getTypeName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JKQTMathTextSuperscriptNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv)
|
bool JKQTMathTextSuperscriptNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const
|
||||||
{
|
{
|
||||||
html=html+"<sup>";
|
html=html+"<sup>";
|
||||||
bool ok=getChild()->toHtml(html, currentEv, defaultEv);
|
bool ok=getChild()->toHtml(html, currentEv, defaultEv);
|
||||||
@ -131,55 +131,55 @@ JKQTMathTextSubscriptNode::~JKQTMathTextSubscriptNode() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextSubscriptNode::getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) {
|
JKQTMathTextNodeSize JKQTMathTextSubscriptNode::getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const {
|
||||||
|
JKQTMathTextNodeSize s;
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||||
const QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
||||||
//const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
//const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||||
const double italic_xshift=qMax(0.0,-fm.rightBearing('x'));// double(fm.boundingRect('x').width())*parentMathText->getItalicCorrectionFactor();
|
const double italic_xshift=qMax(0.0,-fm.rightBearing('x'));// double(fm.boundingRect('x').width())*parentMathText->getItalicCorrectionFactor();
|
||||||
|
|
||||||
double cWidth=0, cBaselineHeight=0, cOverallHeight=0, cStrikeoutPos=0;
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
//const double childDescent=cs.overallHeight-cs.baselineHeight;
|
||||||
//const double childDescent=cOverallHeight-cBaselineHeight;
|
double shift_to_childBaseline=cs.baselineHeight-parentMathText->getSubShiftFactor()*fm.xHeight();
|
||||||
double shift_to_childBaseline=cBaselineHeight-parentMathText->getSubShiftFactor()*fm.xHeight();
|
|
||||||
|
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
||||||
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
||||||
const double parentDescent=prevNodeSizeForSpecialPlacement->overallHeight-prevNodeSizeForSpecialPlacement->baselineHeight;
|
const double parentDescent=prevNodeSizeForSpecialPlacement->overallHeight-prevNodeSizeForSpecialPlacement->baselineHeight;
|
||||||
const double newShift=parentDescent+parentMathText->getSpecialSubShiftFactor()*cBaselineHeight;
|
const double newShift=parentDescent+parentMathText->getSpecialSubShiftFactor()*cs.baselineHeight;
|
||||||
if (newShift>shift_to_childBaseline) shift_to_childBaseline=newShift;
|
if (newShift>shift_to_childBaseline) shift_to_childBaseline=newShift;
|
||||||
//qDebug()<<"newshift="<<shift;
|
//qDebug()<<"newshift="<<shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
baselineHeight=cBaselineHeight-shift_to_childBaseline;
|
s.baselineHeight=cs.baselineHeight-shift_to_childBaseline;
|
||||||
overallHeight=cOverallHeight;
|
s.overallHeight=cs.overallHeight;
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) strikeoutPos=prevNodeSizeForSpecialPlacement->strikeoutPos;
|
if (prevNodeSizeForSpecialPlacement!=nullptr) s.strikeoutPos=prevNodeSizeForSpecialPlacement->strikeoutPos;
|
||||||
else strikeoutPos=fm.strikeOutPos();
|
else s.strikeoutPos=fm.strikeOutPos();
|
||||||
width=cWidth;
|
s.width=cs.width;
|
||||||
if (currentEv.italic && prevNodeSizeForSpecialPlacement==nullptr) width=width-italic_xshift;
|
if (currentEv.italic && prevNodeSizeForSpecialPlacement==nullptr) s.width=s.width-italic_xshift;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextSubscriptNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextSubscriptNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
getSizeWithSpecialPlacement(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos, nullptr);
|
return getSizeWithSpecialPlacement(painter, currentEv, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextSubscriptNode::drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) {
|
double JKQTMathTextSubscriptNode::drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||||
const QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
||||||
//const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
//const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||||
|
|
||||||
double cWidth=0, cBaselineHeight=0, cOverallHeight=0, cStrikeoutPos=0;
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
double shift_to_childBaseline=cs.baselineHeight-parentMathText->getSubShiftFactor()*fm.xHeight();
|
||||||
double shift_to_childBaseline=cBaselineHeight-parentMathText->getSubShiftFactor()*fm.xHeight();
|
|
||||||
const double italic_xshift=qMax(0.0,-fm.rightBearing('x'));// double(fm.boundingRect('x').width())*parentMathText->getItalicCorrectionFactor();
|
const double italic_xshift=qMax(0.0,-fm.rightBearing('x'));// double(fm.boundingRect('x').width())*parentMathText->getItalicCorrectionFactor();
|
||||||
|
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
||||||
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
||||||
const double parentDescent=prevNodeSizeForSpecialPlacement->overallHeight-prevNodeSizeForSpecialPlacement->baselineHeight;
|
const double parentDescent=prevNodeSizeForSpecialPlacement->overallHeight-prevNodeSizeForSpecialPlacement->baselineHeight;
|
||||||
const double newShift=parentDescent+parentMathText->getSpecialSubShiftFactor()*cBaselineHeight;
|
const double newShift=parentDescent+parentMathText->getSpecialSubShiftFactor()*cs.baselineHeight;
|
||||||
if (newShift>shift_to_childBaseline) shift_to_childBaseline=newShift;
|
if (newShift>shift_to_childBaseline) shift_to_childBaseline=newShift;
|
||||||
//qDebug()<<"newshift="<<shift;
|
//qDebug()<<"newshift="<<shift;
|
||||||
}
|
}
|
||||||
@ -188,13 +188,13 @@ double JKQTMathTextSubscriptNode::drawWithSpecialPlacement(QPainter& painter, do
|
|||||||
//qDebug()<<"shift="<<shift<<", yshift="<<yshift;
|
//qDebug()<<"shift="<<shift<<", yshift="<<yshift;
|
||||||
double xx=x;
|
double xx=x;
|
||||||
if (currentEv.italic && prevNodeSizeForSpecialPlacement==nullptr) {
|
if (currentEv.italic && prevNodeSizeForSpecialPlacement==nullptr) {
|
||||||
std::cout<<"italic_xshift="<<italic_xshift<<"\n";
|
//std::cout<<"italic_xshift="<<italic_xshift<<"\n";
|
||||||
xx=xx-italic_xshift;
|
xx=xx-italic_xshift;
|
||||||
}
|
}
|
||||||
return getChild()->draw(painter, xx, y+shift_to_childBaseline, ev);//+0.5*fm.boundingRect("A").width();
|
return getChild()->draw(painter, xx, y+shift_to_childBaseline, ev);//+0.5*fm.boundingRect("A").width();
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextSubscriptNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextSubscriptNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
return drawWithSpecialPlacement(painter, x, y, currentEv, nullptr);
|
return drawWithSpecialPlacement(painter, x, y, currentEv, nullptr);
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ QString JKQTMathTextSubscriptNode::getTypeName() const
|
|||||||
return "MTsubscriptNode";
|
return "MTsubscriptNode";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextSubscriptNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextSubscriptNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
html=html+"<sub>";
|
html=html+"<sub>";
|
||||||
bool ok=getChild()->toHtml(html, currentEv, defaultEv);
|
bool ok=getChild()->toHtml(html, currentEv, defaultEv);
|
||||||
html=html+"</sub>";
|
html=html+"</sub>";
|
||||||
|
@ -51,30 +51,30 @@ public:
|
|||||||
*
|
*
|
||||||
* \return the x position which to use for the next part of the text
|
* \return the x position which to use for the next part of the text
|
||||||
*/
|
*/
|
||||||
double drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement);
|
double drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override; /** \brief returns the child node */
|
virtual QString getTypeName() const override; /** \brief returns the child node */
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \brief like getSize(), i.e. determine the size of the node, but cares for subscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
|
/** \brief like getSize(), i.e. determine the size of the node, but cares for subscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
|
||||||
*
|
*
|
||||||
* \param painter painter to use for determining the size
|
* \param painter painter to use for determining the size
|
||||||
* \param currentEv current environment object
|
* \param currentEv current environment object
|
||||||
* \param[out] width width of the block/node
|
|
||||||
* \param[out] baselineHeight distance from the bottom of the block/node-box to the baseline
|
|
||||||
* \param[out] overallHeight overall height (bottom to top) of the node, the ascent is \c overallHeight-baselineHeight
|
|
||||||
* \param[out] strikeoutPos position of the strikeout-line
|
|
||||||
* \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
|
* \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement);
|
JKQTMathTextNodeSize getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief subclass representing an superscript node with exactly one argument in the syntax tree
|
/** \brief subclass representing an superscript node with exactly one argument in the syntax tree
|
||||||
* \ingroup jkqtmathtext_items
|
* \ingroup jkqtmathtext_items
|
||||||
*
|
*
|
||||||
@ -96,28 +96,24 @@ public:
|
|||||||
*
|
*
|
||||||
* \return the x position which to use for the next part of the text
|
* \return the x position which to use for the next part of the text
|
||||||
*/
|
*/
|
||||||
double drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement);
|
double drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \brief like getSize(), i.e. determine the size of the node, but cares for superscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
|
/** \brief like getSize(), i.e. determine the size of the node, but cares for superscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
|
||||||
*
|
*
|
||||||
* \param painter painter to use for determining the size
|
* \param painter painter to use for determining the size
|
||||||
* \param currentEv current environment object
|
* \param currentEv current environment object
|
||||||
* \param[out] width width of the block/node
|
|
||||||
* \param[out] baselineHeight distance from the bottom of the block/node-box to the baseline
|
|
||||||
* \param[out] overallHeight overall height (bottom to top) of the node, the ascent is \c overallHeight-baselineHeight
|
|
||||||
* \param[out] strikeoutPos position of the strikeout-line
|
|
||||||
* \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
|
* \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) ;
|
JKQTMathTextNodeSize getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JKQTMATHTEXTSUBSUPERSCRIPTNODE_H
|
#endif // JKQTMATHTEXTSUBSUPERSCRIPTNODE_H
|
||||||
|
@ -51,63 +51,8 @@ QString JKQTMathTextSymbolNode::getTypeName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JKQTMathTextSymbolNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextSymbolNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
double dummy1, dummy2;
|
return getSymbolSize(painter, currentEv);
|
||||||
getSymbolSizeInternal(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos, dummy1, dummy2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JKQTMathTextSymbolNode::getSymbolSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos, double &subSuperXCorrection, double &subBesidesXCorrection)
|
|
||||||
{
|
|
||||||
const auto fullProps=symbols.value(symbolName, SymbolFullProps());
|
|
||||||
const GlobalSymbolFlags globalFlags=fullProps.globalFlags;
|
|
||||||
const auto drawProps=fullProps.getDrawingData(currentEv, parentMathText);
|
|
||||||
const QFont f=drawProps.first;
|
|
||||||
const QFontMetricsF fm(f);
|
|
||||||
const JKQTMathTextSymbolNode::SymbolProps symprops=drawProps.second;
|
|
||||||
const SymbolFlags symflags=symprops.flags;
|
|
||||||
const QString sym=symprops.symbol;
|
|
||||||
const QRectF tbr=getTightBoundingRect(fm, sym, globalFlags);
|
|
||||||
const QRectF br=getBoundingRect(fm, sym, globalFlags);
|
|
||||||
const QRectF tbrNoSymbol=JKQTMathTextGetTightBoundingRect(f, "X", painter.device());
|
|
||||||
const QRectF mintbr=JKQTMathTextGetTightBoundingRect(f, "(", painter.device());
|
|
||||||
//const double yShift=symprops.yShiftFactor*tbr.height();
|
|
||||||
|
|
||||||
|
|
||||||
if (currentEv.insideMath) {
|
|
||||||
width=qMax(br.width(), mintbr.width());
|
|
||||||
if (has(globalFlags, SmallExtendWidthInMathmode)) {
|
|
||||||
if (!symprops.getSymbolSingleChar().isNull()) width=width*(1.0+(parentMathText->getMathoperatorWidthFactor()-1.0)/5.0);
|
|
||||||
else width=width+mintbr.width()*0.15;
|
|
||||||
} else if (has(globalFlags, ExtendWidthInMathmode)) {
|
|
||||||
if (!symprops.getSymbolSingleChar().isNull()) width=width*parentMathText->getMathoperatorWidthFactor();
|
|
||||||
else width=width+mintbr.width()*0.5;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
width=br.width();
|
|
||||||
}
|
|
||||||
if (!sym.isEmpty()) {
|
|
||||||
overallHeight=tbr.height();
|
|
||||||
baselineHeight=tbr.height()-tbr.bottom();
|
|
||||||
} else {
|
|
||||||
overallHeight=tbrNoSymbol.height();
|
|
||||||
baselineHeight=tbrNoSymbol.height()-tbrNoSymbol.bottom();
|
|
||||||
width=tbrNoSymbol.width();
|
|
||||||
}
|
|
||||||
const double oldDescent=overallHeight-baselineHeight;
|
|
||||||
|
|
||||||
if (has(symflags, HeightIsAscent)) {
|
|
||||||
baselineHeight=fm.ascent();
|
|
||||||
overallHeight=baselineHeight+oldDescent;
|
|
||||||
}
|
|
||||||
if (has(symflags, RotateSymbol90)) {
|
|
||||||
width=qMax(overallHeight, width);
|
|
||||||
}
|
|
||||||
strikeoutPos=fm.strikeOutPos();
|
|
||||||
|
|
||||||
if (has(globalFlags, IntLikeSymbolCorrection)) {
|
|
||||||
subSuperXCorrection=parentMathText->getIntSubSuperXCorrectionFactor()*tbr.width();
|
|
||||||
subBesidesXCorrection=parentMathText->getIntSubBesidesXCorrectionXFactor()*JKQTMathTextGetTightBoundingRect(f, "X", painter.device()).width();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF JKQTMathTextSymbolNode::getBoundingRect(const QFontMetricsF &fm, const QString &text, GlobalSymbolFlags globalFlags)
|
QRectF JKQTMathTextSymbolNode::getBoundingRect(const QFontMetricsF &fm, const QString &text, GlobalSymbolFlags globalFlags)
|
||||||
@ -193,12 +138,9 @@ void JKQTMathTextSymbolNode::drawText(QPainter &p, const QString &text, GlobalSy
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
const NodeSize s=getSymbolSize(painter, currentEv);
|
||||||
double width=0;
|
doDrawBoxes(painter, x, y, s);
|
||||||
double baselineHeight=0;
|
|
||||||
double overallHeight=0, strikeoutPos=0;
|
|
||||||
getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
|
||||||
|
|
||||||
const auto fullProps=symbols.value(symbolName, SymbolFullProps());
|
const auto fullProps=symbols.value(symbolName, SymbolFullProps());
|
||||||
const GlobalSymbolFlags globalFlags=fullProps.globalFlags;
|
const GlobalSymbolFlags globalFlags=fullProps.globalFlags;
|
||||||
@ -215,7 +157,7 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
|
|||||||
//const QRectF br=getBoundingRect(fm, sym, globalFlags);
|
//const QRectF br=getBoundingRect(fm, sym, globalFlags);
|
||||||
const QRectF tbrNoSymbol=JKQTMathTextGetTightBoundingRect(f, "X", painter.device());
|
const QRectF tbrNoSymbol=JKQTMathTextGetTightBoundingRect(f, "X", painter.device());
|
||||||
const double yShift=symprops.yShiftFactor*tbr.height();
|
const double yShift=symprops.yShiftFactor*tbr.height();
|
||||||
const double xShift=(width-tbr.width())/2.0;
|
const double xShift=(s.width-tbr.width())/2.0;
|
||||||
const QPointF x0(x+xShift-tbr.x(), y+yShift);
|
const QPointF x0(x+xShift-tbr.x(), y+yShift);
|
||||||
double italic_xcorrection=fabs(tbr.width()-tbrNonItalic.width());
|
double italic_xcorrection=fabs(tbr.width()-tbrNonItalic.width());
|
||||||
if (fabs(italic_xcorrection)<1e-6) italic_xcorrection=double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
if (fabs(italic_xcorrection)<1e-6) italic_xcorrection=double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
||||||
@ -250,11 +192,11 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
|
|||||||
}
|
}
|
||||||
if (has(symflags, DrawSlash)) {
|
if (has(symflags, DrawSlash)) {
|
||||||
//qDebug()<<" -> DrawSlash";
|
//qDebug()<<" -> DrawSlash";
|
||||||
painter.drawText(QPointF((width-fm.boundingRect('/').width())/2.0,0),"/");
|
painter.drawText(QPointF((s.width-fm.boundingRect('/').width())/2.0,0),"/");
|
||||||
}
|
}
|
||||||
if (has(symflags, DrawBackSlash)) {
|
if (has(symflags, DrawBackSlash)) {
|
||||||
//qDebug()<<" -> DrawBackSlash";
|
//qDebug()<<" -> DrawBackSlash";
|
||||||
painter.drawText(QPointF((width-fm.boundingRect('\\').width())/2.0,0),"\\");
|
painter.drawText(QPointF((s.width-fm.boundingRect('\\').width())/2.0,0),"\\");
|
||||||
}
|
}
|
||||||
/*painter.save();
|
/*painter.save();
|
||||||
painter.setPen(QPen(QColor("red"), 0.5, Qt::DotLine));
|
painter.setPen(QPen(QColor("red"), 0.5, Qt::DotLine));
|
||||||
@ -269,10 +211,10 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
|
|||||||
painter.drawRect(QRectF(x0.x(), x0.y()-tbrNoSymbol.height(), tbrNoSymbol.width(), tbrNoSymbol.height()));
|
painter.drawRect(QRectF(x0.x(), x0.y()-tbrNoSymbol.height(), tbrNoSymbol.width(), tbrNoSymbol.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return x+width;
|
return x+s.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextSymbolNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextSymbolNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
bool ok=true;
|
bool ok=true;
|
||||||
const auto props=symbols.value(symbolName, SymbolFullProps());
|
const auto props=symbols.value(symbolName, SymbolFullProps());
|
||||||
QString s=props.html.symbol;
|
QString s=props.html.symbol;
|
||||||
@ -288,10 +230,60 @@ QString JKQTMathTextSymbolNode::getSymbolName() const {
|
|||||||
return this->symbolName;
|
return this->symbolName;
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTMathTextSymbolNode::NodeSize JKQTMathTextSymbolNode::getSymbolSize(QPainter &painter, JKQTMathTextEnvironment currentEv)
|
JKQTMathTextSymbolNode::NodeSize JKQTMathTextSymbolNode::getSymbolSize(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
NodeSize s;
|
NodeSize s;
|
||||||
getSymbolSizeInternal(painter, currentEv, s.width, s.baselineHeight, s.overallHeight, s.strikeoutPos, s.subSuperXCorrection, s.subBesidesXCorrection);
|
|
||||||
|
const auto fullProps=symbols.value(symbolName, SymbolFullProps());
|
||||||
|
const GlobalSymbolFlags globalFlags=fullProps.globalFlags;
|
||||||
|
const auto drawProps=fullProps.getDrawingData(currentEv, parentMathText);
|
||||||
|
const QFont f=drawProps.first;
|
||||||
|
const QFontMetricsF fm(f);
|
||||||
|
const JKQTMathTextSymbolNode::SymbolProps symprops=drawProps.second;
|
||||||
|
const SymbolFlags symflags=symprops.flags;
|
||||||
|
const QString sym=symprops.symbol;
|
||||||
|
const QRectF tbr=getTightBoundingRect(fm, sym, globalFlags);
|
||||||
|
const QRectF br=getBoundingRect(fm, sym, globalFlags);
|
||||||
|
const QRectF tbrNoSymbol=JKQTMathTextGetTightBoundingRect(f, "X", painter.device());
|
||||||
|
const QRectF mintbr=JKQTMathTextGetTightBoundingRect(f, "(", painter.device());
|
||||||
|
//const double yShift=symprops.yShiftFactor*tbr.height();
|
||||||
|
|
||||||
|
if (currentEv.insideMath) {
|
||||||
|
s.width=qMax(br.width(), mintbr.width());
|
||||||
|
if (has(globalFlags, SmallExtendWidthInMathmode)) {
|
||||||
|
if (!symprops.getSymbolSingleChar().isNull()) s.width=s.width*(1.0+(parentMathText->getMathoperatorWidthFactor()-1.0)/5.0);
|
||||||
|
else s.width=s.width+mintbr.width()*0.15;
|
||||||
|
} else if (has(globalFlags, ExtendWidthInMathmode)) {
|
||||||
|
if (!symprops.getSymbolSingleChar().isNull()) s.width=s.width*parentMathText->getMathoperatorWidthFactor();
|
||||||
|
else s.width=s.width+mintbr.width()*0.5;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s.width=br.width();
|
||||||
|
}
|
||||||
|
if (!sym.isEmpty()) {
|
||||||
|
s.overallHeight=tbr.height();
|
||||||
|
s.baselineHeight=tbr.height()-tbr.bottom();
|
||||||
|
} else {
|
||||||
|
s.overallHeight=tbrNoSymbol.height();
|
||||||
|
s.baselineHeight=tbrNoSymbol.height()-tbrNoSymbol.bottom();
|
||||||
|
s.width=tbrNoSymbol.width();
|
||||||
|
}
|
||||||
|
const double oldDescent=s.overallHeight-s.baselineHeight;
|
||||||
|
|
||||||
|
if (has(symflags, HeightIsAscent)) {
|
||||||
|
s.baselineHeight=fm.ascent();
|
||||||
|
s.overallHeight=s.baselineHeight+oldDescent;
|
||||||
|
}
|
||||||
|
if (has(symflags, RotateSymbol90)) {
|
||||||
|
s.width=qMax(s.overallHeight, s.width);
|
||||||
|
}
|
||||||
|
s.strikeoutPos=fm.strikeOutPos();
|
||||||
|
|
||||||
|
if (has(globalFlags, IntLikeSymbolCorrection)) {
|
||||||
|
s.subSuperXCorrection=parentMathText->getIntSubSuperXCorrectionFactor()*tbr.width();
|
||||||
|
s.subBesidesXCorrection=parentMathText->getIntSubBesidesXCorrectionXFactor()*JKQTMathTextGetTightBoundingRect(f, "X", painter.device()).width();
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,9 +62,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc symbolName */
|
/** \copydoc symbolName */
|
||||||
QString getSymbolName() const;
|
QString getSymbolName() const;
|
||||||
/** \brief return type for getSymbolSize(), extends JKQTMathTextNodeSize with information about x-correction for sub- and superscript */
|
/** \brief return type for getSymbolSize(), extends JKQTMathTextNodeSize with information about x-correction for sub- and superscript */
|
||||||
@ -88,7 +88,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
|
|||||||
*
|
*
|
||||||
* \return all important size properties, packed into a NodeSize struct
|
* \return all important size properties, packed into a NodeSize struct
|
||||||
*/
|
*/
|
||||||
NodeSize getSymbolSize(QPainter& painter, JKQTMathTextEnvironment currentEv);
|
NodeSize getSymbolSize(QPainter& painter, JKQTMathTextEnvironment currentEv) const;
|
||||||
/** \brief checks whether the given symbol name can be prepresented by this type of node */
|
/** \brief checks whether the given symbol name can be prepresented by this type of node */
|
||||||
static bool hasSymbol(const QString& symbolName);
|
static bool hasSymbol(const QString& symbolName);
|
||||||
/** \brief return a list of all defined symbols */
|
/** \brief return a list of all defined symbols */
|
||||||
@ -101,9 +101,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
|
|||||||
static int getSymbolLength(const QString& symbolName);
|
static int getSymbolLength(const QString& symbolName);
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextSymbolNode::getSymbolSize() */
|
|
||||||
virtual void getSymbolSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, double& subSuperXCorrection, double& subBesidesXCorrection) ;
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief this string will be sent to the drawText method with properly set fonts */
|
/** \brief this string will be sent to the drawText method with properly set fonts */
|
||||||
|
@ -63,7 +63,7 @@ QString JKQTMathTextTextBaseNode::textTransform(const QString &text, const JKQTM
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JKQTMathTextTextBaseNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextTextBaseNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
html=html
|
html=html
|
||||||
+currentEv.toHtmlStart(defaultEv, parentMathText)
|
+currentEv.toHtmlStart(defaultEv, parentMathText)
|
||||||
+textTransform(text, currentEv).toHtmlEscaped()
|
+textTransform(text, currentEv).toHtmlEscaped()
|
||||||
@ -121,19 +121,16 @@ JKQTMathTextTextNode::JKQTMathTextTextNode(JKQTMathText* _parent, const QString&
|
|||||||
|
|
||||||
JKQTMathTextTextNode::~JKQTMathTextTextNode() = default;
|
JKQTMathTextTextNode::~JKQTMathTextTextNode() = default;
|
||||||
|
|
||||||
void JKQTMathTextTextNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextTextNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
QStringList textpart;
|
return calcLayout(painter, currentEv);
|
||||||
QList<FontMode> fontMode;
|
|
||||||
QList<double> textpartXPos;
|
|
||||||
getSizeInternalAndData(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos,textpart, fontMode, textpartXPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextTextNode::getSizeInternalAndData(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos, QStringList &textpart, QList<FontMode> &fontMode, QList<double> &textpartXPos)
|
JKQTMathTextTextNode::LayoutInfo JKQTMathTextTextNode::calcLayout(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
textpart.clear();
|
LayoutInfo l;
|
||||||
fontMode.clear();
|
|
||||||
const QString txt=textTransform(text, currentEv);
|
const QString txt=textTransform(text, currentEv);
|
||||||
splitTextForLayout(painter, currentEv, txt, textpart, fontMode);
|
splitTextForLayout(painter, currentEv, txt, l.textpart, l.fontMode);
|
||||||
|
|
||||||
const QFont f=currentEv.getFont(parentMathText);
|
const QFont f=currentEv.getFont(parentMathText);
|
||||||
const QFont fUpright=JKQTMathTextGetNonItalic(f);
|
const QFont fUpright=JKQTMathTextGetNonItalic(f);
|
||||||
@ -148,44 +145,45 @@ void JKQTMathTextTextNode::getSizeInternalAndData(QPainter &painter, JKQTMathTex
|
|||||||
#else
|
#else
|
||||||
const double sp=fm.width(' ');
|
const double sp=fm.width(' ');
|
||||||
#endif
|
#endif
|
||||||
width=0;
|
l.width=0;
|
||||||
double ascent=0;
|
double ascent=0;
|
||||||
double descent=0;
|
double descent=0;
|
||||||
for (int i=0; i<textpart.size(); i++) {
|
for (int i=0; i<l.textpart.size(); i++) {
|
||||||
QRectF br, tbr;
|
QRectF br, tbr;
|
||||||
switch(fontMode[i]) {
|
switch(l.fontMode[i]) {
|
||||||
case FMasDefined:
|
case FMasDefined:
|
||||||
case FMasDefinedOutline:
|
case FMasDefinedOutline:
|
||||||
br=fm.boundingRect(textpart[i]);
|
br=fm.boundingRect(l.textpart[i]);
|
||||||
tbr=JKQTMathTextGetTightBoundingRect(f, textpart[i], painter.device());
|
tbr=JKQTMathTextGetTightBoundingRect(f, l.textpart[i], painter.device());
|
||||||
break;
|
break;
|
||||||
case FMasDefinedForceUpright:
|
case FMasDefinedForceUpright:
|
||||||
br=fmUpright.boundingRect(textpart[i]);
|
br=fmUpright.boundingRect(l.textpart[i]);
|
||||||
tbr=JKQTMathTextGetTightBoundingRect(fUpright, textpart[i], painter.device());
|
tbr=JKQTMathTextGetTightBoundingRect(fUpright, l.textpart[i], painter.device());
|
||||||
break;
|
break;
|
||||||
case FMroman:
|
case FMroman:
|
||||||
br=fmRoman.boundingRect(textpart[i]);
|
br=fmRoman.boundingRect(l.textpart[i]);
|
||||||
tbr=JKQTMathTextGetTightBoundingRect(fRoman, textpart[i], painter.device());
|
tbr=JKQTMathTextGetTightBoundingRect(fRoman, l.textpart[i], painter.device());
|
||||||
break;
|
break;
|
||||||
case FMfallbackSymbol:
|
case FMfallbackSymbol:
|
||||||
br=fmFallbackSym.boundingRect(textpart[i]);
|
br=fmFallbackSym.boundingRect(l.textpart[i]);
|
||||||
tbr=JKQTMathTextGetTightBoundingRect(fFallbackSym, textpart[i], painter.device());
|
tbr=JKQTMathTextGetTightBoundingRect(fFallbackSym, l.textpart[i], painter.device());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
textpartXPos.append(width);
|
l.textpartXPos.append(l.width);
|
||||||
width+=br.width();
|
l.width+=br.width();
|
||||||
if (textpart[i].size()>0 && textpart[i].at(textpart[i].size()-1).isSpace()) {
|
if (l.textpart[i].size()>0 && l.textpart[i].at(l.textpart[i].size()-1).isSpace()) {
|
||||||
// this correction is necessary, because it seems that QFontMetricsF::boundingRect() ignores trailing spaces
|
// this correction is necessary, because it seems that QFontMetricsF::boundingRect() ignores trailing spaces
|
||||||
width+=sp;
|
l.width+=sp;
|
||||||
}
|
}
|
||||||
const double thisAscent=-tbr.top();
|
const double thisAscent=-tbr.top();
|
||||||
const double thisDescent=tbr.bottom();
|
const double thisDescent=tbr.bottom();
|
||||||
ascent=qMax(ascent, thisAscent);
|
ascent=qMax(ascent, thisAscent);
|
||||||
descent=qMax(descent, thisDescent);
|
descent=qMax(descent, thisDescent);
|
||||||
}
|
}
|
||||||
overallHeight=(ascent+descent); //fm.height();
|
l.overallHeight=(ascent+descent); //fm.height();
|
||||||
baselineHeight=ascent;
|
l.baselineHeight=ascent;
|
||||||
strikeoutPos=fm.strikeOutPos();
|
l.strikeoutPos=fm.strikeOutPos();
|
||||||
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextTextNode::splitTextForLayout(QPainter &painter, JKQTMathTextEnvironment currentEv, const QString &txt, QStringList &textpart, QList<FontMode> &fontMode) const
|
void JKQTMathTextTextNode::splitTextForLayout(QPainter &painter, JKQTMathTextEnvironment currentEv, const QString &txt, QStringList &textpart, QList<FontMode> &fontMode) const
|
||||||
@ -275,16 +273,9 @@ void JKQTMathTextTextNode::splitTextForLayout(QPainter &painter, JKQTMathTextEnv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
const LayoutInfo l=calcLayout(painter, currentEv);
|
||||||
double width=0;
|
doDrawBoxes(painter, x, y, l);
|
||||||
double baselineHeight=0;
|
|
||||||
double overallHeight=0;
|
|
||||||
double sp=0;
|
|
||||||
QStringList textpart;
|
|
||||||
QList<double> textpartXPos;
|
|
||||||
QList<FontMode> fontMode;
|
|
||||||
getSizeInternalAndData(painter, currentEv, width, baselineHeight, overallHeight, sp, textpart, fontMode, textpartXPos);
|
|
||||||
|
|
||||||
|
|
||||||
const QFont f=currentEv.getFont(parentMathText);
|
const QFont f=currentEv.getFont(parentMathText);
|
||||||
@ -303,32 +294,32 @@ double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
//qDebug()<<"JKQTMathTextTextNode: text="<<text<<" font="<<f;
|
//qDebug()<<"JKQTMathTextTextNode: text="<<text<<" font="<<f;
|
||||||
|
|
||||||
//std::cout<<" TEXT: currentEv.mathMode="<<currentEv.insideMath<<", currentEv.forceUpright="<<currentEv.insideMathForceDigitsUpright<<"\n";
|
//std::cout<<" TEXT: currentEv.mathMode="<<currentEv.insideMath<<", currentEv.forceUpright="<<currentEv.insideMathForceDigitsUpright<<"\n";
|
||||||
for (int i=0; i<textpart.size(); i++) {
|
for (int i=0; i<l.textpart.size(); i++) {
|
||||||
//std::cout<<" TEXT: mode="<<fontMode[i]<<", text='"<<textpart[i].toStdString()<<"'\n";
|
//std::cout<<" TEXT: mode="<<fontMode[i]<<", text='"<<textpart[i].toStdString()<<"'\n";
|
||||||
switch(fontMode[i]) {
|
switch(l.fontMode[i]) {
|
||||||
case FMasDefined:
|
case FMasDefined:
|
||||||
painter.setFont(f);
|
painter.setFont(f);
|
||||||
painter.drawText(QPointF(x+textpartXPos[i], y), textpart[i]);
|
painter.drawText(QPointF(x+l.textpartXPos[i], y), l.textpart[i]);
|
||||||
break;
|
break;
|
||||||
case FMasDefinedOutline:
|
case FMasDefinedOutline:
|
||||||
JKQTMathTextDrawStringSimBlackboard(painter, f, currentEv.color, x+textpartXPos[i], y, textpart[i]);
|
JKQTMathTextDrawStringSimBlackboard(painter, f, currentEv.color, x+l.textpartXPos[i], y, l.textpart[i]);
|
||||||
break;
|
break;
|
||||||
case FMasDefinedForceUpright:
|
case FMasDefinedForceUpright:
|
||||||
painter.setFont(fUpright);
|
painter.setFont(fUpright);
|
||||||
painter.drawText(QPointF(x+textpartXPos[i], y), textpart[i]);
|
painter.drawText(QPointF(x+l.textpartXPos[i], y), l.textpart[i]);
|
||||||
break;
|
break;
|
||||||
case FMroman:
|
case FMroman:
|
||||||
painter.setFont(fRoman);
|
painter.setFont(fRoman);
|
||||||
painter.drawText(QPointF(x+textpartXPos[i], y), textpart[i]);
|
painter.drawText(QPointF(x+l.textpartXPos[i], y), l.textpart[i]);
|
||||||
break;
|
break;
|
||||||
case FMfallbackSymbol:
|
case FMfallbackSymbol:
|
||||||
painter.setFont(fFallbackSym);
|
painter.setFont(fFallbackSym);
|
||||||
painter.drawText(QPointF(x+textpartXPos[i], y), textpart[i]);
|
painter.drawText(QPointF(x+l.textpartXPos[i], y), l.textpart[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return x+width;
|
return x+l.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -430,11 +421,11 @@ size_t JKQTMathTextVerbatimNode::getTabSize() const
|
|||||||
return tabSize;
|
return tabSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextVerbatimNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextVerbatimNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
|
||||||
transformEnvironment(currentEv);
|
transformEnvironment(currentEv);
|
||||||
const LayoutInfo l=calcLayout(painter, currentEv);
|
const LayoutInfo l=calcLayout(painter, currentEv);
|
||||||
|
doDrawBoxes(painter, x, y, l);
|
||||||
QFont f=currentEv.getFont(parentMathText);
|
QFont f=currentEv.getFont(parentMathText);
|
||||||
f.setStyleStrategy(QFont::PreferDefault);
|
f.setStyleStrategy(QFont::PreferDefault);
|
||||||
f.setFixedPitch(true);
|
f.setFixedPitch(true);
|
||||||
@ -446,7 +437,7 @@ double JKQTMathTextVerbatimNode::draw(QPainter &painter, double x, double y, JKQ
|
|||||||
return x+l.width;
|
return x+l.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextVerbatimNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv)
|
bool JKQTMathTextVerbatimNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const
|
||||||
{
|
{
|
||||||
transformEnvironment(currentEv);
|
transformEnvironment(currentEv);
|
||||||
const bool isMultiLine=text.count('\n')>0;
|
const bool isMultiLine=text.count('\n')>0;
|
||||||
@ -468,14 +459,10 @@ bool JKQTMathTextVerbatimNode::toHtml(QString &html, JKQTMathTextEnvironment cur
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextVerbatimNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextVerbatimNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
transformEnvironment(currentEv);
|
transformEnvironment(currentEv);
|
||||||
const LayoutInfo l=calcLayout(painter, currentEv);
|
return calcLayout(painter, currentEv);
|
||||||
width=l.width;
|
|
||||||
overallHeight=l.overallHeight;
|
|
||||||
baselineHeight=l.baselineHeight;
|
|
||||||
strikeoutPos=l.strikeoutPos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextVerbatimNode::transformEnvironment(JKQTMathTextEnvironment ¤tEv) const
|
void JKQTMathTextVerbatimNode::transformEnvironment(JKQTMathTextEnvironment ¤tEv) const
|
||||||
@ -592,3 +579,38 @@ JKQTMathTextVerbatimNode::LayoutInfo::LayoutInfo():
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JKQTMathTextTextNode::LayoutInfo::LayoutInfo():
|
||||||
|
JKQTMathTextNodeSize(),
|
||||||
|
textpart(), fontMode(), textpartXPos()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextTextNode::LayoutInfo::LayoutInfo(const LayoutInfo &other):
|
||||||
|
LayoutInfo()
|
||||||
|
{
|
||||||
|
operator=(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextTextNode::LayoutInfo::LayoutInfo(const JKQTMathTextNodeSize &other):
|
||||||
|
LayoutInfo()
|
||||||
|
{
|
||||||
|
operator=(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextTextNode::LayoutInfo &JKQTMathTextTextNode::LayoutInfo::operator=(const LayoutInfo &other) {
|
||||||
|
JKQTMathTextNodeSize::operator=(other);
|
||||||
|
textpart=other.textpart;
|
||||||
|
fontMode=other.fontMode;
|
||||||
|
textpartXPos=other.textpartXPos;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextTextNode::LayoutInfo &JKQTMathTextTextNode::LayoutInfo::operator=(const JKQTMathTextNodeSize &other) {
|
||||||
|
JKQTMathTextNodeSize::operator=(other);
|
||||||
|
textpart.clear();
|
||||||
|
fontMode.clear();
|
||||||
|
textpartXPos.clear();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
@ -46,7 +46,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextTextBaseNode: public JKQTMathTextNode
|
|||||||
explicit JKQTMathTextTextBaseNode(JKQTMathText* parent, const QString& text);
|
explicit JKQTMathTextTextBaseNode(JKQTMathText* parent, const QString& text);
|
||||||
virtual ~JKQTMathTextTextBaseNode() override;
|
virtual ~JKQTMathTextTextBaseNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc text */
|
/** \copydoc text */
|
||||||
QString getText() const;
|
QString getText() const;
|
||||||
protected:
|
protected:
|
||||||
@ -65,7 +65,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextTextNode: public JKQTMathTextTextBaseN
|
|||||||
explicit JKQTMathTextTextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false);
|
explicit JKQTMathTextTextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false);
|
||||||
virtual ~JKQTMathTextTextNode() override;
|
virtual ~JKQTMathTextTextNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override ;
|
virtual QString getTypeName() const override ;
|
||||||
/** \brief remove trailing whitespace, is used by simplifyJKQTMathTextNode() */
|
/** \brief remove trailing whitespace, is used by simplifyJKQTMathTextNode() */
|
||||||
@ -82,9 +82,24 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextTextNode: public JKQTMathTextTextBaseN
|
|||||||
FMfallbackSymbol, /*!< \brief use JKQTMathText::getFallbackFontSymbols() */
|
FMfallbackSymbol, /*!< \brief use JKQTMathText::getFallbackFontSymbols() */
|
||||||
};
|
};
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
|
|
||||||
|
/** \brief describes the layout of the whole node */
|
||||||
|
struct LayoutInfo: public JKQTMathTextNodeSize {
|
||||||
|
LayoutInfo();
|
||||||
|
LayoutInfo(const LayoutInfo& other);
|
||||||
|
LayoutInfo(const JKQTMathTextNodeSize& other);
|
||||||
|
LayoutInfo& operator=(const JKQTMathTextNodeSize& other);
|
||||||
|
LayoutInfo& operator=(const LayoutInfo& other);
|
||||||
|
/** \brief the text that shall be printed is split up into different parts (with different formatting each) */
|
||||||
|
QStringList textpart;
|
||||||
|
/** \brief formatting for each entry in textpart */
|
||||||
|
QList<FontMode> fontMode;
|
||||||
|
/** \brief drawing x-position for each entry in textpart */
|
||||||
|
QList<double> textpartXPos;
|
||||||
|
};
|
||||||
/** \brief calculates the size of the node, much like JKQTMathTextNode::getSizeInternal(), but returns additional properties that can be reused for drawing */
|
/** \brief calculates the size of the node, much like JKQTMathTextNode::getSizeInternal(), but returns additional properties that can be reused for drawing */
|
||||||
void getSizeInternalAndData(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, QStringList& textpart, QList<FontMode>& fontMode, QList<double>& textpartXPos) ;
|
LayoutInfo calcLayout(QPainter& painter, JKQTMathTextEnvironment currentEv) const ;
|
||||||
/** \brief split text for Math-Modelayout into sections, where each section has a defined way of output
|
/** \brief split text for Math-Modelayout into sections, where each section has a defined way of output
|
||||||
*
|
*
|
||||||
* \param painter the QPainter to use for sizing/drawing
|
* \param painter the QPainter to use for sizing/drawing
|
||||||
@ -130,9 +145,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextVerbatimNode: public JKQTMathTextTextB
|
|||||||
/** \copydoc tabSize */
|
/** \copydoc tabSize */
|
||||||
size_t getTabSize() const;
|
size_t getTabSize() const;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
protected:
|
protected:
|
||||||
/** \brief alignment scheme used to lay out all lines
|
/** \brief alignment scheme used to lay out all lines
|
||||||
*
|
*
|
||||||
@ -157,7 +172,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextVerbatimNode: public JKQTMathTextTextB
|
|||||||
size_t tabSize;
|
size_t tabSize;
|
||||||
|
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief sets all necessary settings in \a currentEv for drawing this node */
|
/** \brief sets all necessary settings in \a currentEv for drawing this node */
|
||||||
virtual void transformEnvironment(JKQTMathTextEnvironment& currentEv) const;
|
virtual void transformEnvironment(JKQTMathTextEnvironment& currentEv) const;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ QString JKQTMathTextWhitespaceNode::getTypeName() const
|
|||||||
return QLatin1String("JKQTMathTextWhitespaceNode(")+Type2String(whitespace.type)+", count="+QString::number(whitespace.count)+")";
|
return QLatin1String("JKQTMathTextWhitespaceNode(")+Type2String(whitespace.type)+", count="+QString::number(whitespace.count)+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextWhitespaceNode::toHtml(QString &html, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) {
|
bool JKQTMathTextWhitespaceNode::toHtml(QString &html, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) const {
|
||||||
for (size_t i=0; i<whitespace.count; i++) {
|
for (size_t i=0; i<whitespace.count; i++) {
|
||||||
html=html+Type2HTML(whitespace.type);
|
html=html+Type2HTML(whitespace.type);
|
||||||
}
|
}
|
||||||
@ -115,22 +115,23 @@ size_t JKQTMathTextWhitespaceNode::getWhitespaceCount() const
|
|||||||
return whitespace.count;
|
return whitespace.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextWhitespaceNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextWhitespaceNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
doDrawBoxes(painter, x,y,currentEv);
|
const JKQTMathTextNodeSize s=getSize(painter, currentEv);
|
||||||
double width=0, bh=0, oh=0, sp=0;
|
doDrawBoxes(painter, x,y,s);
|
||||||
getSize(painter, currentEv, width, bh, oh, sp);
|
return x+s.width;
|
||||||
return x+width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextWhitespaceNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextWhitespaceNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
|
JKQTMathTextNodeSize s;
|
||||||
const double singelWidthPIX=Type2PixelWidth(whitespace.type, currentEv, painter.device());
|
const double singelWidthPIX=Type2PixelWidth(whitespace.type, currentEv, painter.device());
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText));
|
const QFontMetricsF fm(currentEv.getFont(parentMathText));
|
||||||
width=singelWidthPIX*static_cast<double>(whitespace.count);
|
s.width=singelWidthPIX*static_cast<double>(whitespace.count);
|
||||||
baselineHeight=0;
|
s.baselineHeight=0;
|
||||||
overallHeight=0;
|
s.overallHeight=0;
|
||||||
strikeoutPos=fm.strikeOutPos();
|
s.strikeoutPos=fm.strikeOutPos();
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, JKQTMathTextWhitespaceNode::WhitespaceProps> JKQTMathTextWhitespaceNode::supportedInstructions;
|
QHash<QString, JKQTMathTextWhitespaceNode::WhitespaceProps> JKQTMathTextWhitespaceNode::supportedInstructions;
|
||||||
@ -294,9 +295,9 @@ QString JKQTMathTextEmptyBoxNode::getTypeName() const
|
|||||||
return QString("JKQTMathTextEmptyBoxNode(%1%2 x %3%4)").arg(getWidth()).arg(JKQTMathTextEmptyBoxNode::Units2String(getWidthUnit())).arg(getHeight()).arg(JKQTMathTextEmptyBoxNode::Units2String(getHeightUnit()));
|
return QString("JKQTMathTextEmptyBoxNode(%1%2 x %3%4)").arg(getWidth()).arg(JKQTMathTextEmptyBoxNode::Units2String(getWidthUnit())).arg(getHeight()).arg(JKQTMathTextEmptyBoxNode::Units2String(getHeightUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextEmptyBoxNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv)
|
bool JKQTMathTextEmptyBoxNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTMathTextEmptyBoxNode::Units JKQTMathTextEmptyBoxNode::getWidthUnit() const
|
JKQTMathTextEmptyBoxNode::Units JKQTMathTextEmptyBoxNode::getWidthUnit() const
|
||||||
@ -319,24 +320,26 @@ double JKQTMathTextEmptyBoxNode::getHeight() const
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextEmptyBoxNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv)
|
double JKQTMathTextEmptyBoxNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
doDrawBoxes(painter, x,y,currentEv);
|
|
||||||
const auto s=getSize(painter, currentEv);
|
const auto s=getSize(painter, currentEv);
|
||||||
|
doDrawBoxes(painter, x,y,s);
|
||||||
return x+s.width;
|
return x+s.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextEmptyBoxNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos)
|
JKQTMathTextNodeSize JKQTMathTextEmptyBoxNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
|
||||||
{
|
{
|
||||||
|
JKQTMathTextNodeSize s;
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
width=Units2PixelWidth(this->width, widthUnit, currentEv, painter.device());
|
s.width=Units2PixelWidth(width, widthUnit, currentEv, painter.device());
|
||||||
overallHeight=Units2PixelWidth(height, heightUnit, currentEv, painter.device());
|
s.overallHeight=Units2PixelWidth(height, heightUnit, currentEv, painter.device());
|
||||||
if (height>0) {
|
if (height>0) {
|
||||||
baselineHeight=overallHeight;
|
s.baselineHeight=s.overallHeight;
|
||||||
} else {
|
} else {
|
||||||
baselineHeight=0;
|
s.baselineHeight=0;
|
||||||
}
|
}
|
||||||
strikeoutPos=fm.strikeOutPos();
|
s.strikeoutPos=fm.strikeOutPos();
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -383,35 +386,32 @@ QString JKQTMathTextPhantomNode::getTypeName() const
|
|||||||
return QLatin1String("JKQTMathTextPhantomNode(")+instructionName+")";
|
return QLatin1String("JKQTMathTextPhantomNode(")+instructionName+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathTextPhantomNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) {
|
JKQTMathTextNodeSize JKQTMathTextPhantomNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextNodeSize s=getChild()->getSize(painter, currentEv);
|
||||||
|
|
||||||
getChild()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
|
||||||
|
|
||||||
switch(instructions[getInstructionName()]) {
|
switch(instructions[getInstructionName()]) {
|
||||||
case FMwidth:
|
case FMwidth:
|
||||||
overallHeight=0;
|
s.overallHeight=0;
|
||||||
baselineHeight=0;
|
s.baselineHeight=0;
|
||||||
strikeoutPos=0;
|
s.strikeoutPos=0;
|
||||||
break;
|
break;
|
||||||
case FMwidthAndHeight:
|
case FMwidthAndHeight:
|
||||||
break;
|
break;
|
||||||
case FMheight:
|
case FMheight:
|
||||||
width=0;
|
s.width=0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathTextPhantomNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) {
|
double JKQTMathTextPhantomNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
||||||
doDrawBoxes(painter, x, y, currentEv);
|
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
|
||||||
|
|
||||||
const JKQTMathTextNodeSize s=getSize(painter, currentEv);
|
const JKQTMathTextNodeSize s=getSize(painter, currentEv);
|
||||||
|
doDrawBoxes(painter, x, y, s);
|
||||||
return x+s.width;
|
return x+s.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JKQTMathTextPhantomNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
bool JKQTMathTextPhantomNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const {
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
fillInstructions();
|
fillInstructions();
|
||||||
return " ";
|
return " ";
|
||||||
|
@ -76,16 +76,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextWhitespaceNode: public JKQTMathTextNod
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc WhitespaceProps::type */
|
/** \copydoc WhitespaceProps::type */
|
||||||
Types getWhitespaceType() const;
|
Types getWhitespaceType() const;
|
||||||
/** \copydoc WhitespaceProps::count */
|
/** \copydoc WhitespaceProps::count */
|
||||||
size_t getWhitespaceCount() const;
|
size_t getWhitespaceCount() const;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief describes a whitespace */
|
/** \brief describes a whitespace */
|
||||||
struct WhitespaceProps {
|
struct WhitespaceProps {
|
||||||
WhitespaceProps(Types type=WSTNormal, size_t count=1);
|
WhitespaceProps(Types type=WSTNormal, size_t count=1);
|
||||||
@ -129,7 +129,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextEmptyBoxNode: public JKQTMathTextNode
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
/** \copydoc widthUnit */
|
/** \copydoc widthUnit */
|
||||||
Units getWidthUnit() const;
|
Units getWidthUnit() const;
|
||||||
/** \copydoc width */
|
/** \copydoc width */
|
||||||
@ -139,10 +139,10 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextEmptyBoxNode: public JKQTMathTextNode
|
|||||||
/** \copydoc height */
|
/** \copydoc height */
|
||||||
double getHeight() const;
|
double getHeight() const;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief width of the (empty) box, units of this value defined in widthUnit */
|
/** \brief width of the (empty) box, units of this value defined in widthUnit */
|
||||||
double width;
|
double width;
|
||||||
/** \brief units to interpret width */
|
/** \brief units to interpret width */
|
||||||
@ -175,9 +175,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextPhantomNode: public JKQTMathTextInstru
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
|
||||||
|
|
||||||
/** \brief returns true, if the given \a instructionName can be represented by this node
|
/** \brief returns true, if the given \a instructionName can be represented by this node
|
||||||
* \see instructions
|
* \see instructions
|
||||||
@ -186,7 +186,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextPhantomNode: public JKQTMathTextInstru
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) override;
|
virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
|
||||||
/** \brief fills instructions
|
/** \brief fills instructions
|
||||||
*
|
*
|
||||||
* \note this is the customization point for new instructions!
|
* \note this is the customization point for new instructions!
|
||||||
|