2022-06-08 21:38:26 +08:00
|
|
|
/*
|
|
|
|
Copyright (c) 2008-2022 Jan W. Krieger (<jan@jkrieger.de>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This software is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License (LGPL) as published by
|
|
|
|
the Free Software Foundation, either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License (LGPL) for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License (LGPL)
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "jkqtmathtext/nodes/jkqtmathtextmatrixnode.h"
|
2022-08-19 18:16:00 +08:00
|
|
|
#include "jkqtmathtext/nodes/jkqtmathtextnoopnode.h"
|
2022-06-08 21:38:26 +08:00
|
|
|
#include "jkqtmathtext/jkqtmathtexttools.h"
|
|
|
|
#include "jkqtmathtext/jkqtmathtext.h"
|
|
|
|
#include "jkqtcommon/jkqtpcodestructuring.h"
|
|
|
|
#include "jkqtcommon/jkqtpstringtools.h"
|
2024-01-09 00:16:31 +08:00
|
|
|
#include "jkqtcommon/jkqtpdebuggingtools.h"
|
2022-06-08 21:38:26 +08:00
|
|
|
#include <cmath>
|
|
|
|
#include <QFontMetricsF>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QFontDatabase>
|
|
|
|
#include <QFontInfo>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QFont>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
JKQTMathTextMatrixNode::JKQTMathTextMatrixNode(JKQTMathText* _parent, const QVector<QVector<JKQTMathTextNode *> > &children, const QString &columnSpec):
|
2022-08-13 21:32:31 +08:00
|
|
|
JKQTMathTextMultiChildNode(_parent),
|
2022-08-12 18:54:10 +08:00
|
|
|
verticalLineRHSColumn(),
|
|
|
|
verticalLineLeft(LTnone),
|
|
|
|
horizontalLineBottomRow(),
|
|
|
|
horizontalLineTop(LTnone),
|
|
|
|
columns(0),
|
|
|
|
lines(0)
|
|
|
|
{
|
|
|
|
setChildren(children);
|
|
|
|
parseColumnSpec(columnSpec);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTMathTextMatrixNode::JKQTMathTextMatrixNode(JKQTMathText *_parent, const QString &columnSpec):
|
2022-08-13 21:32:31 +08:00
|
|
|
JKQTMathTextMultiChildNode(_parent),
|
2022-08-12 18:54:10 +08:00
|
|
|
verticalLineRHSColumn(),
|
|
|
|
verticalLineLeft(LTnone),
|
|
|
|
horizontalLineBottomRow(),
|
|
|
|
horizontalLineTop(LTnone),
|
|
|
|
columns(0),
|
|
|
|
lines(0)
|
|
|
|
{
|
|
|
|
parseColumnSpec(columnSpec);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTMathTextMatrixNode::~JKQTMathTextMatrixNode() {
|
2022-08-13 21:32:31 +08:00
|
|
|
clearChildrenImpl(true);
|
2022-08-12 18:54:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTMathTextMatrixNode::setChildren(const QVector<QVector<JKQTMathTextNode *> > &children)
|
2022-06-08 21:38:26 +08:00
|
|
|
{
|
|
|
|
this->lines=children.size();
|
|
|
|
this->columns=0;
|
2022-08-12 18:54:10 +08:00
|
|
|
for (int i=0; i<children.size(); i++) {
|
2022-06-08 21:38:26 +08:00
|
|
|
if (children[i].size()>this->columns) this->columns=children[i].size();
|
|
|
|
}
|
|
|
|
this->children=children;
|
2022-06-09 05:52:22 +08:00
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
children[i].operator[](j)->setParentNode(this);
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
void JKQTMathTextMatrixNode::setRowBottomLine(int col, LineType line)
|
|
|
|
{
|
|
|
|
horizontalLineBottomRow[col]=line;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTMathTextMatrixNode::setTopLine(LineType line)
|
|
|
|
{
|
|
|
|
horizontalLineTop=line;
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QString JKQTMathTextMatrixNode::getTypeName() const
|
|
|
|
{
|
|
|
|
return "MTmatrixNode";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-17 05:05:04 +08:00
|
|
|
bool JKQTMathTextMatrixNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*currentEv*/, JKQTMathTextEnvironment /*defaultEv*/) const
|
2022-08-12 18:54:10 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-08-13 21:32:31 +08:00
|
|
|
QVector<QVector<JKQTMathTextNode *> > JKQTMathTextMatrixNode::getChildrenMatrix() const {
|
2022-08-12 18:54:10 +08:00
|
|
|
return this->children;
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
int JKQTMathTextMatrixNode::getColumns() const {
|
|
|
|
return this->columns;
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
int JKQTMathTextMatrixNode::getLines() const {
|
|
|
|
return this->lines;
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-13 21:32:31 +08:00
|
|
|
QList<JKQTMathTextNode *> JKQTMathTextMatrixNode::getChildren()
|
|
|
|
{
|
|
|
|
QList<JKQTMathTextNode *> l;
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
l<<children[i].at(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
int JKQTMathTextMatrixNode::childCount() const
|
|
|
|
{
|
|
|
|
int s=0;
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
s+=children[i].size();
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTMathTextMatrixNode::clearChildren(bool deleteChildren)
|
|
|
|
{
|
|
|
|
clearChildrenImpl(deleteChildren);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void JKQTMathTextMatrixNode::clearChildrenImpl(bool deleteChildren)
|
|
|
|
{
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
if (deleteChildren) delete children[i].at(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
children.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void JKQTMathTextMatrixNode::deleteChild(int nn)
|
|
|
|
{
|
|
|
|
int n=0;
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
if (n==nn) {
|
|
|
|
delete children[i].operator[](j);
|
|
|
|
children[i].operator[](j)=new JKQTMathTextNoopNode(parentMathText);
|
|
|
|
children[i].operator[](j)->setParentNode(this);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTMathTextNode *JKQTMathTextMatrixNode::getChild(int nn)
|
|
|
|
{
|
|
|
|
int n=0;
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
if (n==nn) {
|
|
|
|
return children[i].at(j);
|
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const JKQTMathTextNode *JKQTMathTextMatrixNode::getChild(int nn) const
|
|
|
|
{
|
|
|
|
int n=0;
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
if (n==nn) {
|
|
|
|
return children[i].at(j);
|
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTMathTextNode *JKQTMathTextMatrixNode::replaceChild(int nn, JKQTMathTextNode *newChild)
|
|
|
|
{
|
|
|
|
int n=0;
|
|
|
|
for (int i=0; i<children.size(); i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
|
|
|
if (n==nn) {
|
|
|
|
JKQTMathTextNode* old= children[i].at(j);
|
|
|
|
children[i].operator[](j)=newChild;
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
void JKQTMathTextMatrixNode::setDrawBoxes(bool draw)
|
|
|
|
{
|
|
|
|
this->drawBoxes=draw;
|
2022-06-08 21:38:26 +08:00
|
|
|
for (int i=0; i<lines; i++) {
|
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
2022-08-12 18:54:10 +08:00
|
|
|
children[i].at(j)->setDrawBoxes(draw);
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTMathTextMatrixNode::drawVLine(QPainter &painter, double x, double y, double height, LineType lt, double linewidth, double linewidthHeavy, QColor color, double doublelineseparation)
|
|
|
|
{
|
|
|
|
if (lt==LTnone) return;
|
|
|
|
QPen p(color, linewidth, Qt::SolidLine);
|
|
|
|
if (lt==LTdashed || lt==LTdoubleDashed) p.setStyle(Qt::DashLine);
|
|
|
|
if (lt==LTheavyline) p.setWidth(linewidthHeavy);
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
painter.setPen(p);
|
|
|
|
if (lt==LTline || lt==LTdashed || lt==LTheavyline) {
|
|
|
|
painter.drawLine(QPointF(x,y), QPointF(x,y+height));
|
|
|
|
} else if (lt==LTdoubleline || lt==LTdoubleDashed) {
|
|
|
|
painter.drawLine(QPointF(x-doublelineseparation/2.0,y), QPointF(x-doublelineseparation/2.0,y+height));
|
|
|
|
painter.drawLine(QPointF(x+doublelineseparation/2.0,y), QPointF(x+doublelineseparation/2.0,y+height));
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
void JKQTMathTextMatrixNode::drawHLine(QPainter &painter, double x, double y, double width, LineType lt, double linewidth, double linewidthHeavy, QColor color, double doublelineseparation)
|
|
|
|
{
|
|
|
|
if (lt==LTnone) return;
|
|
|
|
QPen p(color, linewidth, Qt::SolidLine);
|
|
|
|
if (lt==LTdashed || lt==LTdoubleDashed) p.setStyle(Qt::DashLine);
|
|
|
|
if (lt==LTheavyline) p.setWidth(linewidthHeavy);
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
painter.setPen(p);
|
|
|
|
if (lt==LTline || lt==LTdashed || lt==LTheavyline) {
|
|
|
|
painter.drawLine(QPointF(x,y), QPointF(x+width,y));
|
|
|
|
} else if (lt==LTdoubleline || lt==LTdoubleDashed) {
|
|
|
|
painter.drawLine(QPointF(x,y-doublelineseparation/2.0), QPointF(x+width,y-doublelineseparation/2.0));
|
|
|
|
painter.drawLine(QPointF(x,y+doublelineseparation/2.0), QPointF(x+width,y+doublelineseparation/2.0));
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
void JKQTMathTextMatrixNode::parseColumnSpec(const QString &columnSpec)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
while (i<columnSpec.size()) {
|
|
|
|
if (columnSpec[i]=='l') {
|
|
|
|
columnAlignment<<MTHALeft;
|
|
|
|
} else if (columnSpec[i]=='c') {
|
|
|
|
columnAlignment<<MTHACentered;
|
|
|
|
} else if (columnSpec[i]=='r') {
|
|
|
|
columnAlignment<<MTHARight;
|
|
|
|
} else if (columnSpec.mid(i,2)=="||") {
|
|
|
|
if (columnAlignment.size()==0) {
|
|
|
|
verticalLineLeft=LTdoubleline;
|
|
|
|
} else {
|
|
|
|
verticalLineRHSColumn[columnAlignment.size()-1]=LTdoubleline;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else if (columnSpec.mid(i,2)=="::") {
|
|
|
|
if (columnAlignment.size()==0) {
|
|
|
|
verticalLineLeft=LTdoubleDashed;
|
|
|
|
} else {
|
|
|
|
verticalLineRHSColumn[columnAlignment.size()-1]=LTdoubleDashed;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else if (columnSpec.mid(i,1)=="|") {
|
|
|
|
if (columnAlignment.size()==0) {
|
|
|
|
verticalLineLeft=LTline;
|
|
|
|
} else {
|
|
|
|
verticalLineRHSColumn[columnAlignment.size()-1]=LTline;
|
|
|
|
}
|
|
|
|
} else if (columnSpec.mid(i,1)==":") {
|
|
|
|
if (columnAlignment.size()==0) {
|
|
|
|
verticalLineLeft=LTdashed;
|
|
|
|
} else {
|
|
|
|
verticalLineRHSColumn[columnAlignment.size()-1]=LTdashed;
|
|
|
|
}
|
|
|
|
} else if (!columnSpec[i].isSpace()){
|
2022-08-20 22:19:40 +08:00
|
|
|
addToErrorList(QString("array spec has unknown character '%1' (full spec was '%2')").arg(columnSpec[i]).arg(columnSpec));
|
2022-08-12 18:54:10 +08:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
JKQTMathTextMatrixNode::LayoutInfo::LayoutInfo():
|
|
|
|
JKQTMathTextNodeSize(), colwidth(), rowheight()
|
|
|
|
{
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
JKQTMathTextMatrixNode::LayoutInfo JKQTMathTextMatrixNode::calcLayout(QPainter &painter, const JKQTMathTextEnvironment ¤tEv) const
|
|
|
|
{
|
|
|
|
LayoutInfo l;
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
JKQTMathTextEnvironment ev1=currentEv;
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2024-01-09 00:16:31 +08:00
|
|
|
const QFont font=ev1.getFont(parentMathText);
|
|
|
|
const double strikepos=JKQTMathTextGetFontStrikoutPos(font, painter.device());
|
|
|
|
const double xwidth=JKQTMathTextGetBoundingRect(font,"f",painter.device()).width();
|
|
|
|
const double lw=JKQTMathTextGetFontLineWidth(font, painter.device())*1.5;
|
2022-08-12 18:54:10 +08:00
|
|
|
const double XPadding=parentMathText->getMatrixXPaddingFactor()*xwidth;
|
|
|
|
const double YPadding=parentMathText->getMatrixYPaddingFactor()*xwidth;
|
|
|
|
const double XSeparation=parentMathText->getMatrixXSeparationFactor()*xwidth;
|
|
|
|
const double YSeparation=parentMathText->getMatrixYSeparationFactor()*xwidth;
|
|
|
|
|
|
|
|
l.colwidth.resize(columns); for (int i=0; i<columns; i++) l.colwidth[i]=0;
|
|
|
|
l.rowheight.resize(lines);
|
|
|
|
l.rowascent.resize(lines);
|
|
|
|
l.cellwidth.resize(lines);
|
2022-08-14 03:56:09 +08:00
|
|
|
l.leftPadding=(verticalLineLeft==LTnone)?lw:XPadding;
|
|
|
|
l.rightPadding=(verticalLineRHSColumn.value(columns-1,LTnone)==LTnone)?lw:XPadding;
|
|
|
|
l.topPadding=(horizontalLineTop==LTnone)?lw:YPadding;
|
|
|
|
l.bottomPadding=(horizontalLineBottomRow.value(lines-1,LTnone)==LTnone)?lw:YPadding;
|
2022-08-12 18:54:10 +08:00
|
|
|
for (int ll=0; ll<lines; ll++) l.cellwidth[ll]=QVector<double>(columns, 0.0);
|
|
|
|
QVector<double> rowdescent;
|
|
|
|
rowdescent.resize(lines);
|
2022-06-08 21:38:26 +08:00
|
|
|
for (int i=0; i<lines; i++) {
|
2022-08-12 18:54:10 +08:00
|
|
|
l.rowheight[i]=0;
|
|
|
|
l.rowascent[i]=0;
|
|
|
|
rowdescent[i]=0;
|
2022-06-08 21:38:26 +08:00
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
2022-08-12 18:54:10 +08:00
|
|
|
const JKQTMathTextNodeSize cs=children[i].at(j)->getSize(painter, ev1);
|
|
|
|
l.cellwidth[i].operator[](j)=cs.width;
|
|
|
|
l.colwidth[j]=qMax(l.colwidth[j], cs.width);
|
|
|
|
l.rowascent[i]=qMax(l.rowascent[i], cs.baselineHeight);
|
|
|
|
rowdescent[i]=qMax(rowdescent[i], cs.getDescent());
|
2022-08-19 18:16:00 +08:00
|
|
|
JKQTMathTextModifyEnvironmentNodeMixIn* modEnvNode=dynamic_cast<JKQTMathTextModifyEnvironmentNodeMixIn*>(children[i].at(j));
|
|
|
|
if (modEnvNode) {
|
|
|
|
modEnvNode->modifyEnvironment(ev1);
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
2022-08-12 18:54:10 +08:00
|
|
|
l.rowheight[i]=l.rowascent[i]+rowdescent[i];
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-19 18:16:00 +08:00
|
|
|
l.overallHeight=static_cast<double>(lines-1)*YSeparation+l.topPadding+l.bottomPadding;
|
|
|
|
l.width=static_cast<double>(columns-1)*XSeparation+l.leftPadding+l.rightPadding;
|
2022-08-12 18:54:10 +08:00
|
|
|
for (int i=0; i<columns; i++) l.width=l.width+l.colwidth[i];
|
|
|
|
for (int i=0; i<lines; i++) l.overallHeight=l.overallHeight+l.rowheight[i];
|
2022-08-14 03:56:09 +08:00
|
|
|
l.baselineHeight=l.overallHeight/2.0+strikepos;
|
|
|
|
l.strikeoutPos=strikepos;
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
return l;
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
2022-08-17 05:05:04 +08:00
|
|
|
JKQTMathTextNodeSize JKQTMathTextMatrixNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
|
|
|
|
return calcLayout(painter, currentEv);
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
2022-08-17 05:05:04 +08:00
|
|
|
double JKQTMathTextMatrixNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {
|
2024-01-09 00:16:31 +08:00
|
|
|
#ifdef JKQTBP_AUTOTIMER
|
|
|
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathTextMatrixNode[]::draw()"));
|
|
|
|
#endif
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2024-01-09 00:16:31 +08:00
|
|
|
const QFont font=currentEv.getFont(parentMathText);
|
2022-08-12 18:54:10 +08:00
|
|
|
JKQTMathTextEnvironment ev1=currentEv;
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
const LayoutInfo l=calcLayout(painter, currentEv);
|
2022-08-17 05:05:04 +08:00
|
|
|
doDrawBoxes(painter, x, y, l);
|
2022-08-12 18:54:10 +08:00
|
|
|
|
2024-01-09 00:16:31 +08:00
|
|
|
const double xwidth=JKQTMathTextGetBoundingRect(font,"f",painter.device()).width();
|
|
|
|
const double fontlw=JKQTMathTextGetFontLineWidth(font, painter.device());
|
2022-08-12 18:54:10 +08:00
|
|
|
const double XSeparation=parentMathText->getMatrixXSeparationFactor()*xwidth;
|
|
|
|
const double YSeparation=parentMathText->getMatrixYSeparationFactor()*xwidth;
|
|
|
|
const double yTop=y-l.baselineHeight+l.topPadding;
|
|
|
|
const double xLeft=x+l.leftPadding;
|
2024-01-09 00:16:31 +08:00
|
|
|
const double linewidth=parentMathText->getMatrixLinewidthThinFactor()*fontlw;
|
|
|
|
const double linewidthThick=parentMathText->getMatrixLinewidthHeavyFactor()*fontlw;
|
|
|
|
const double lineSeparation=parentMathText->getMatrixLineSeparationFactor()*fontlw;
|
2022-08-12 18:54:10 +08:00
|
|
|
double leftlineX=xLeft-l.leftPadding/2.0;
|
|
|
|
double rightlineX=x+l.width-l.rightPadding/2.0;
|
|
|
|
double toplineY=yTop-l.topPadding/2.0;
|
|
|
|
double bottomlineY=y+l.getDescent()-l.bottomPadding/2;
|
|
|
|
if (verticalLineLeft==LTdoubleline || verticalLineLeft==LTdoubleDashed) leftlineX-=linewidth;
|
|
|
|
if (horizontalLineTop==LTdoubleline || horizontalLineTop==LTdoubleDashed) toplineY-=linewidth;
|
|
|
|
if (verticalLineRHSColumn.value(lines-1, LTnone)==LTdoubleline || verticalLineRHSColumn.value(lines-1, LTnone)==LTdoubleDashed) rightlineX+=linewidth;
|
|
|
|
if (horizontalLineBottomRow.value(columns-1, LTnone)==LTdoubleline || horizontalLineBottomRow.value(columns-1, LTnone)==LTdoubleDashed) bottomlineY+=linewidth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double xx;
|
|
|
|
double yy=yTop;
|
|
|
|
if (lines>0) yy=yy+l.rowascent[0];
|
2022-06-08 21:38:26 +08:00
|
|
|
for (int i=0; i<lines; i++) {
|
2022-08-12 18:54:10 +08:00
|
|
|
xx=xLeft;
|
2022-06-08 21:38:26 +08:00
|
|
|
for (int j=0; j<children[i].size(); j++) {
|
2022-08-12 18:54:10 +08:00
|
|
|
const double cw=l.getCellwidth(i, j);
|
|
|
|
double xoffset=0;
|
|
|
|
if (columnAlignment.value(j, MTHALeft)==MTHACentered) xoffset=(l.colwidth[j]-cw)/2.0;
|
|
|
|
else if (columnAlignment.value(j, MTHALeft)==MTHARight) xoffset=(l.colwidth[j]-cw);
|
|
|
|
children[i].at(j)->draw(painter, xx+xoffset, yy, ev1);
|
|
|
|
xx=xx+l.colwidth[j]+XSeparation;
|
|
|
|
if (i==0 && j<columns-1) drawVLine(painter, xx-XSeparation/2.0, toplineY, bottomlineY-toplineY, verticalLineRHSColumn.value(j, LTnone), linewidth, linewidthThick, currentEv.color, lineSeparation);
|
2022-08-19 18:16:00 +08:00
|
|
|
JKQTMathTextModifyEnvironmentNodeMixIn* modEnvNode=dynamic_cast<JKQTMathTextModifyEnvironmentNodeMixIn*>(children[i].at(j));
|
|
|
|
if (modEnvNode) {
|
|
|
|
modEnvNode->modifyEnvironment(ev1);
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:38:26 +08:00
|
|
|
}
|
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
if (i<lines-1) {
|
|
|
|
double yline=yy+(l.rowheight[i]-l.rowascent[i])+YSeparation/2.0;
|
|
|
|
yy=yline+YSeparation/2.0+l.rowascent[i+1];
|
|
|
|
drawHLine(painter, leftlineX, yline, rightlineX-leftlineX, horizontalLineBottomRow.value(i, LTnone), linewidth, linewidthThick, currentEv.color, lineSeparation);
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
drawVLine(painter, leftlineX, toplineY, bottomlineY-toplineY, verticalLineLeft, linewidth, linewidthThick, currentEv.color, lineSeparation);
|
|
|
|
drawVLine(painter, rightlineX, toplineY, bottomlineY-toplineY, verticalLineRHSColumn.value(columns-1, LTnone), linewidth, linewidthThick, currentEv.color, lineSeparation);
|
|
|
|
drawHLine(painter, leftlineX, toplineY, rightlineX-leftlineX, verticalLineLeft, linewidth, linewidthThick, currentEv.color, lineSeparation);
|
|
|
|
drawHLine(painter, leftlineX, bottomlineY, rightlineX-leftlineX, horizontalLineBottomRow.value(lines-1, LTnone), linewidth, linewidthThick, currentEv.color, lineSeparation);
|
2022-06-08 21:38:26 +08:00
|
|
|
|
2022-08-12 18:54:10 +08:00
|
|
|
return x+l.width;
|
|
|
|
}
|