mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 01:51:49 +08:00
JKQTMathText: added \unicode{XXXX} instruction
This commit is contained in:
parent
18b0ef61f1
commit
2ec3d12507
@ -39,7 +39,7 @@ This page lists several todos and wishes for future version of JKQTPlotter
|
|||||||
<li></li>
|
<li></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li>JKQTMathText:<ul>
|
<li>JKQTMathText:<ul>
|
||||||
<li>add instruction for unicode-characters \\charDDDD, \\char"XXXX, \\unicode{XXXX}, \\utf8{XXXX}, \\utf16{XXXX}, \\utf32{XXXX} ...</li>
|
<li>add instruction for unicode-characters \\charDDDD, \\char"XXXX ...</li>
|
||||||
<li>check sub/superscript with italic text in math mode, possibly a correction is necessary</li>
|
<li>check sub/superscript with italic text in math mode, possibly a correction is necessary</li>
|
||||||
<li>explore where QFontMetricsF::horizontalAdvance() can be used (for Qt >=5.15)</li>
|
<li>explore where QFontMetricsF::horizontalAdvance() can be used (for Qt >=5.15)</li>
|
||||||
<li>add support for \\bigl,\\bigr,\\Bigr,... commands for fixed-size but large paramtheses</li>
|
<li>add support for \\bigl,\\bigr,\\Bigr,... commands for fixed-size but large paramtheses</li>
|
||||||
|
@ -66,7 +66,8 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
|||||||
<li>NEW: added \c \\shaded{color}{...} </li>
|
<li>NEW: added \c \\shaded{color}{...} </li>
|
||||||
<li>NEW: added \c \\acute{X}, \c \\grave{X}, \c \\acute{X}</li>
|
<li>NEW: added \c \\acute{X}, \c \\grave{X}, \c \\acute{X}</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>
|
||||||
<li>NEW: added \c \\userfont{SystemFontName}{Text}</li>
|
<li>NEW: added \c \\userfont{SystemFontName}{Text} instruction</li>
|
||||||
|
<li>NEW: added \c \\unicode{HEX} instruction to draw unicide characters by code</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
BIN
doc/images/jkqtmathtext/jkqtmathtext_unicode.png
Normal file
BIN
doc/images/jkqtmathtext/jkqtmathtext_unicode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -67,6 +67,7 @@ TestForm::TestForm(QWidget *parent) :
|
|||||||
ui->cmbTestset->addItem("text (bold)", "text \\mathbf{bold}");
|
ui->cmbTestset->addItem("text (bold)", "text \\mathbf{bold}");
|
||||||
ui->cmbTestset->addItem("textcolor", "text \\mathbf{bold}\\textcolor{red}{RED}");
|
ui->cmbTestset->addItem("textcolor", "text \\mathbf{bold}\\textcolor{red}{RED}");
|
||||||
ui->cmbTestset->addItem("userfont", "text, \\userfont{Arial}{Arial}, \\userfont{Comic Sans MS}{Comic Sans MS}");
|
ui->cmbTestset->addItem("userfont", "text, \\userfont{Arial}{Arial}, \\userfont{Comic Sans MS}{Comic Sans MS}");
|
||||||
|
ui->cmbTestset->addItem("unicode", "star: \\unicode{2605}, circonflex: \\unicode{109}");
|
||||||
const auto mathDecoExample=[](const QString& deco)->QString { return "\\"+deco+"{x}\\"+deco+"{i}\\"+deco+"{X}\\"+deco+"{\\psi}\\"+deco+"{abc}"; };
|
const auto mathDecoExample=[](const QString& deco)->QString { return "\\"+deco+"{x}\\"+deco+"{i}\\"+deco+"{X}\\"+deco+"{\\psi}\\"+deco+"{abc}"; };
|
||||||
ui->cmbTestset->addItem("decoration: math", "$"+mathDecoExample("vec")+" -- "+mathDecoExample("grave")+" -- "+mathDecoExample("acute")+" -- "+mathDecoExample("dot")+" -- "+mathDecoExample("ddot")+" -- "+mathDecoExample("ocirc")+" -- "+mathDecoExample("overline")+" -- "+mathDecoExample("underline")+" -- "+mathDecoExample("hat")+" -- "+mathDecoExample("widehat")+" -- "+mathDecoExample("check")+" -- "+mathDecoExample("widecheck")+" -- "+mathDecoExample("breve")+" -- "+mathDecoExample("tilde")+" -- "+mathDecoExample("widetilde")+" -- "+mathDecoExample("uul")+" -- "+mathDecoExample("ool")+" -- "+mathDecoExample("bar")+" -- "+mathDecoExample("arrow")+" -- "+mathDecoExample("cancel")+" -- "+mathDecoExample("bcancel")+" -- "+mathDecoExample("xcancel")+" -- "+mathDecoExample("sout")+"$");
|
ui->cmbTestset->addItem("decoration: math", "$"+mathDecoExample("vec")+" -- "+mathDecoExample("grave")+" -- "+mathDecoExample("acute")+" -- "+mathDecoExample("dot")+" -- "+mathDecoExample("ddot")+" -- "+mathDecoExample("ocirc")+" -- "+mathDecoExample("overline")+" -- "+mathDecoExample("underline")+" -- "+mathDecoExample("hat")+" -- "+mathDecoExample("widehat")+" -- "+mathDecoExample("check")+" -- "+mathDecoExample("widecheck")+" -- "+mathDecoExample("breve")+" -- "+mathDecoExample("tilde")+" -- "+mathDecoExample("widetilde")+" -- "+mathDecoExample("uul")+" -- "+mathDecoExample("ool")+" -- "+mathDecoExample("bar")+" -- "+mathDecoExample("arrow")+" -- "+mathDecoExample("cancel")+" -- "+mathDecoExample("bcancel")+" -- "+mathDecoExample("xcancel")+" -- "+mathDecoExample("sout")+"$");
|
||||||
ui->cmbTestset->addItem("decoration: text", "Text \\ul{underlined Text Equator} -- \\ol{overlined Text Equator} -- \\sout{striked out Text Equator} -- \\cancel{canceled out Text Equator} -- \\bcancel{b-canceled out Text Equator} -- \\xcancel{x-canceled out Text Equator}");
|
ui->cmbTestset->addItem("decoration: text", "Text \\ul{underlined Text Equator} -- \\ol{overlined Text Equator} -- \\sout{striked out Text Equator} -- \\cancel{canceled out Text Equator} -- \\bcancel{b-canceled out Text Equator} -- \\xcancel{x-canceled out Text Equator}");
|
||||||
@ -430,6 +431,7 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathTextNode *node, QTreeWidgetItem* p
|
|||||||
JKQTMathTextListNode* lstN=dynamic_cast<JKQTMathTextListNode*>(node);
|
JKQTMathTextListNode* lstN=dynamic_cast<JKQTMathTextListNode*>(node);
|
||||||
JKQTMathTextModifiedTextPropsInstructionNode* inst1N=dynamic_cast<JKQTMathTextModifiedTextPropsInstructionNode*>(node);
|
JKQTMathTextModifiedTextPropsInstructionNode* inst1N=dynamic_cast<JKQTMathTextModifiedTextPropsInstructionNode*>(node);
|
||||||
JKQTMathTextBoxInstructionNode* inst1B=dynamic_cast<JKQTMathTextBoxInstructionNode*>(node);
|
JKQTMathTextBoxInstructionNode* inst1B=dynamic_cast<JKQTMathTextBoxInstructionNode*>(node);
|
||||||
|
JKQTMathTextSimpleInstructionNode* instS=dynamic_cast<JKQTMathTextSimpleInstructionNode*>(node);
|
||||||
JKQTMathTextSubscriptNode* subN=dynamic_cast<JKQTMathTextSubscriptNode*>(node);
|
JKQTMathTextSubscriptNode* subN=dynamic_cast<JKQTMathTextSubscriptNode*>(node);
|
||||||
JKQTMathTextSuperscriptNode* superN=dynamic_cast<JKQTMathTextSuperscriptNode*>(node);
|
JKQTMathTextSuperscriptNode* superN=dynamic_cast<JKQTMathTextSuperscriptNode*>(node);
|
||||||
JKQTMathTextBraceNode* braceN=dynamic_cast<JKQTMathTextBraceNode*>(node);
|
JKQTMathTextBraceNode* braceN=dynamic_cast<JKQTMathTextBraceNode*>(node);
|
||||||
@ -476,6 +478,8 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathTextNode *node, QTreeWidgetItem* p
|
|||||||
} else if (subN) {
|
} else if (subN) {
|
||||||
name=QString("MTsubscriptNode");
|
name=QString("MTsubscriptNode");
|
||||||
if (subN->getChild()) ti->addChild(createTree(subN->getChild(), ti));
|
if (subN->getChild()) ti->addChild(createTree(subN->getChild(), ti));
|
||||||
|
} else if (instS) {
|
||||||
|
name=QString("SimpleInstructionNode: \'%1\' (subsuper=%2, params=%3)").arg(instS->getInstructionName()).arg(instS->isSubSuperscriptAboveBelowNode()).arg(instS->getParameters().join("/"));
|
||||||
} else if (inst1N) {
|
} else if (inst1N) {
|
||||||
name=QString("ModTxtPropsInstructionNode: \'%1\' (subsuper=%2, params=%3)").arg(inst1N->getInstructionName()).arg(inst1N->isSubSuperscriptAboveBelowNode()).arg(inst1N->getParameters().join("/"));
|
name=QString("ModTxtPropsInstructionNode: \'%1\' (subsuper=%2, params=%3)").arg(inst1N->getInstructionName()).arg(inst1N->isSubSuperscriptAboveBelowNode()).arg(inst1N->getParameters().join("/"));
|
||||||
if (inst1N->getChild()) ti->addChild(createTree(inst1N->getChild(), ti));
|
if (inst1N->getChild()) ti->addChild(createTree(inst1N->getChild(), ti));
|
||||||
|
@ -1708,6 +1708,16 @@ JKQTMathTextNode* JKQTMathText::parseInstruction(bool *_foundError, bool* getNew
|
|||||||
if (foundError){
|
if (foundError){
|
||||||
error_list.append(tr("error @ ch. %1: expected %3 arguments in '{...}' braces after '%2' command").arg(currentTokenID).arg(currentInstructionName).arg(Nparams+1));
|
error_list.append(tr("error @ ch. %1: expected %3 arguments in '{...}' braces after '%2' command").arg(currentTokenID).arg(currentInstructionName).arg(Nparams+1));
|
||||||
}
|
}
|
||||||
|
} else if (JKQTMathTextSimpleInstructionNode::supportsInstructionName(currentInstructionName)) {
|
||||||
|
const size_t Nparams=JKQTMathTextSimpleInstructionNode::countParametersOfInstruction(currentInstructionName);
|
||||||
|
bool foundError=false;
|
||||||
|
const QStringList params=parseStringParams(true, Nparams, &foundError);
|
||||||
|
if (!foundError) {
|
||||||
|
child=new JKQTMathTextSimpleInstructionNode(this, currentInstructionName, params);
|
||||||
|
}
|
||||||
|
if (foundError){
|
||||||
|
error_list.append(tr("error @ ch. %1: expected %3 arguments in '{...}' braces after '%2' command").arg(currentTokenID).arg(currentInstructionName).arg(Nparams));
|
||||||
|
}
|
||||||
} else if (JKQTMathTextBoxInstructionNode::supportsInstructionName(currentInstructionName)) {
|
} else if (JKQTMathTextBoxInstructionNode::supportsInstructionName(currentInstructionName)) {
|
||||||
const size_t Nparams=JKQTMathTextBoxInstructionNode::countParametersOfInstruction(currentInstructionName);
|
const size_t Nparams=JKQTMathTextBoxInstructionNode::countParametersOfInstruction(currentInstructionName);
|
||||||
bool foundError=false;
|
bool foundError=false;
|
||||||
|
@ -133,6 +133,7 @@ class JKQTMathTextNode; // forward
|
|||||||
- \c \\fcolorbox{bordercolor}{backgroundcolor}{...} : draw a colored, filled box \image html jkqtmathtext/jkqtmathtext_fcolorbox.png
|
- \c \\fcolorbox{bordercolor}{backgroundcolor}{...} : draw a colored, filled box \image html jkqtmathtext/jkqtmathtext_fcolorbox.png
|
||||||
- \c \\colorbox{color}{...} : draw a colored box around text \image html jkqtmathtext/jkqtmathtext_colorbox.png
|
- \c \\colorbox{color}{...} : draw a colored box around text \image html jkqtmathtext/jkqtmathtext_colorbox.png
|
||||||
- \c \\alpha ... : display the according greek letter \image html jkqtmathtext/jkqtmathtext_greek.png
|
- \c \\alpha ... : display the according greek letter \image html jkqtmathtext/jkqtmathtext_greek.png
|
||||||
|
- \c \\unicode{HEX} : draws a unicode character \image html jkqtmathtext/jkqtmathtext_unicode.png (generated by <code>star: \\unicode{2605}, circonflex: \\unicode{109}</code>)
|
||||||
- \c ^{...} \c _{...} : display the contents of braces in superscript/subscript \image html jkqtmathtext/jkqtmathtext_supersub.png
|
- \c ^{...} \c _{...} : display the contents of braces in superscript/subscript \image html jkqtmathtext/jkqtmathtext_supersub.png
|
||||||
<br>Special subscript/superscript typesetting applies, when the sub/super follows \c \\sum \c \\Prod ...: \image html jkqtmathtext/jkqtmathtext_specialsubsuper.png
|
<br>Special subscript/superscript typesetting applies, when the sub/super follows \c \\sum \c \\Prod ...: \image html jkqtmathtext/jkqtmathtext_specialsubsuper.png
|
||||||
- \c \\{ / \\} : display opening/closing brace
|
- \c \\{ / \\} : display opening/closing brace
|
||||||
|
@ -58,6 +58,136 @@ const QStringList &JKQTMathTextInstruction1Node::getParameters() const {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JKQTMathTextSimpleInstructionNode::JKQTMathTextSimpleInstructionNode(JKQTMathText *_parent, const QString &_name, const QStringList &_parameters):
|
||||||
|
JKQTMathTextNode(_parent),
|
||||||
|
instructionName(_name),
|
||||||
|
parameters(_parameters)
|
||||||
|
{
|
||||||
|
fillInstructions();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextSimpleInstructionNode::~JKQTMathTextSimpleInstructionNode()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString JKQTMathTextSimpleInstructionNode::getTypeName() const
|
||||||
|
{
|
||||||
|
return QLatin1String("JKQTMathTextSimpleInstructionNode(")+instructionName+")";
|
||||||
|
}
|
||||||
|
|
||||||
|
double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize *prevNodeSize)
|
||||||
|
{
|
||||||
|
doDrawBoxes(painter, x, y, currentEv);
|
||||||
|
fillInstructions();
|
||||||
|
QFont f=currentEv.getFont(parentMathText);
|
||||||
|
f.setStyleStrategy(QFont::PreferDefault);
|
||||||
|
const QFontMetricsF fm(f);
|
||||||
|
const QString txt=executeInstruction();
|
||||||
|
const QRectF bb=fm.boundingRect(txt);
|
||||||
|
|
||||||
|
painter.setFont(f);
|
||||||
|
painter.drawText(x,y,txt);
|
||||||
|
|
||||||
|
return x+bb.width();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JKQTMathTextSimpleInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv)
|
||||||
|
{
|
||||||
|
fillInstructions();
|
||||||
|
const QString txt=executeInstruction();
|
||||||
|
html+=txt;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &JKQTMathTextSimpleInstructionNode::getInstructionName() const
|
||||||
|
{
|
||||||
|
return instructionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList &JKQTMathTextSimpleInstructionNode::getParameters() const
|
||||||
|
{
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JKQTMathTextSimpleInstructionNode::supportsInstructionName(const QString &instructionName)
|
||||||
|
{
|
||||||
|
fillInstructions();
|
||||||
|
return instructions.contains(instructionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t JKQTMathTextSimpleInstructionNode::countParametersOfInstruction(const QString &instructionName)
|
||||||
|
{
|
||||||
|
fillInstructions();
|
||||||
|
if (instructions.contains(instructionName)) return instructions[instructionName].NParams;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos, const JKQTMathTextNodeSize */*prevNodeSize*/)
|
||||||
|
{
|
||||||
|
fillInstructions();
|
||||||
|
QFont f=currentEv.getFont(parentMathText);
|
||||||
|
f.setStyleStrategy(QFont::PreferDefault);
|
||||||
|
const QFontMetricsF fm(f);
|
||||||
|
const QString txt=executeInstruction();
|
||||||
|
const QRectF bb=fm.boundingRect(txt);
|
||||||
|
width=bb.width();
|
||||||
|
baselineHeight=bb.height()+bb.y();
|
||||||
|
overallHeight=bb.height();
|
||||||
|
strikeoutPos=fm.strikeOutPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<QString, JKQTMathTextSimpleInstructionNode::InstructionProperties> JKQTMathTextSimpleInstructionNode::instructions;
|
||||||
|
|
||||||
|
void JKQTMathTextSimpleInstructionNode::fillInstructions()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
InstructionProperties i([](const QStringList& parameters) -> QString {
|
||||||
|
bool ok=false;
|
||||||
|
const int code=parameters.value(0, "0").toInt(&ok, 16);
|
||||||
|
ok=ok&&(code>=0);
|
||||||
|
if (ok&&(code<=0xFFFF)) return QChar(code);
|
||||||
|
else if (ok&&(code>0xFFFF && code<0xFFFFFFFF)) {
|
||||||
|
const char16_t unicodeSmile[] = { char16_t((code&0xFFFF0000)>>16), char16_t(code&0xFFFF), 0 };
|
||||||
|
return QString::fromUtf16(unicodeSmile);
|
||||||
|
}
|
||||||
|
return QChar(0);
|
||||||
|
}, 1);
|
||||||
|
instructions["unicode"]= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString JKQTMathTextSimpleInstructionNode::executeInstruction() const
|
||||||
|
{
|
||||||
|
fillInstructions();
|
||||||
|
return instructions.value(getInstructionName(), InstructionProperties()).evaluator(getParameters());
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextSimpleInstructionNode::InstructionProperties::InstructionProperties():
|
||||||
|
NParams(0),
|
||||||
|
evaluator([](const QStringList&) { return QString(); })
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTMathTextSimpleInstructionNode::InstructionProperties::InstructionProperties(const EvaluateInstructionFunctor &_evaluator, size_t _NParams):
|
||||||
|
NParams(_NParams),
|
||||||
|
evaluator(_evaluator)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JKQTMathTextModifiedTextPropsInstructionNode::JKQTMathTextModifiedTextPropsInstructionNode(JKQTMathText* _parent, const QString& name, JKQTMathTextNode* child, const QStringList& parameters):
|
JKQTMathTextModifiedTextPropsInstructionNode::JKQTMathTextModifiedTextPropsInstructionNode(JKQTMathText* _parent, const QString& name, JKQTMathTextNode* child, const QStringList& parameters):
|
||||||
JKQTMathTextInstruction1Node(_parent, name, child, parameters)
|
JKQTMathTextInstruction1Node(_parent, name, child, parameters)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,67 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextInstruction1Node: public JKQTMathTextS
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief subclass representing a simple instruction node which only accepts string arguments, not LaTeX arguments
|
||||||
|
* i.e. it represents instructions like \c \\unicode{...}, ...
|
||||||
|
* \ingroup jkqtmathtext_items
|
||||||
|
*/
|
||||||
|
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSimpleInstructionNode: public JKQTMathTextNode {
|
||||||
|
public:
|
||||||
|
explicit JKQTMathTextSimpleInstructionNode(JKQTMathText* parent, const QString& name, const QStringList& parameters=QStringList());
|
||||||
|
virtual ~JKQTMathTextSimpleInstructionNode() override;
|
||||||
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
|
virtual QString getTypeName() const override;
|
||||||
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||||
|
/** \copydoc instructionName */
|
||||||
|
const QString& getInstructionName() const;
|
||||||
|
/** \copydoc parameters */
|
||||||
|
const QStringList& getParameters() const;
|
||||||
|
|
||||||
|
/** \brief returns true, if the given \a instructionName can be represented by this node
|
||||||
|
* \see instructions
|
||||||
|
*/
|
||||||
|
static bool supportsInstructionName(const QString& instructionName);
|
||||||
|
/** \brief returns the number of additional string parameters, required for the given \a instructionName
|
||||||
|
* \see instructions
|
||||||
|
*/
|
||||||
|
static size_t countParametersOfInstruction(const QString& instructionName);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
|
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
|
/** \brief defines the implementation of an instruction represented by JKQTMathTextModifiedTextPropsInstructionNode */
|
||||||
|
struct InstructionProperties {
|
||||||
|
/** \brief this functor implements the instruction */
|
||||||
|
typedef std::function<QString(const QStringList& parameters)> EvaluateInstructionFunctor;
|
||||||
|
/** \brief default constructor, creates a NOP-instruction that does nothing */
|
||||||
|
InstructionProperties();
|
||||||
|
/** \brief constructor which gets a functor \a _modifier and a number of required parameters \a _NParams */
|
||||||
|
InstructionProperties(const EvaluateInstructionFunctor& _evaluator, size_t _NParams=0);
|
||||||
|
/** \brief number of parameters for this node */
|
||||||
|
size_t NParams;
|
||||||
|
/** \brief output of the instruction */
|
||||||
|
EvaluateInstructionFunctor evaluator;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief fills instructions
|
||||||
|
*
|
||||||
|
* \note this is the customization point for new instructions!
|
||||||
|
*/
|
||||||
|
static void fillInstructions();
|
||||||
|
/** \brief defines all implemented instructions in this node */
|
||||||
|
static QHash<QString, InstructionProperties> instructions;
|
||||||
|
/** \brief executes the instruction on \a ev */
|
||||||
|
QString executeInstruction() const;
|
||||||
|
/** \brief instruction name */
|
||||||
|
QString instructionName;
|
||||||
|
/** \brief additional string-parameters */
|
||||||
|
QStringList parameters;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** \brief subclass representing an instruction node which modifies the current font (as defined in JKQTMathTextEnvironment),
|
/** \brief subclass representing an instruction node which modifies the current font (as defined in JKQTMathTextEnvironment),
|
||||||
* i.e. it represents instructions like \c \\textbf{...}, \c \\ul{underlinedText}, ...
|
* i.e. it represents instructions like \c \\textbf{...}, \c \\ul{underlinedText}, ...
|
||||||
* \ingroup jkqtmathtext_items
|
* \ingroup jkqtmathtext_items
|
||||||
@ -71,7 +132,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedTextPropsInstructionNode: publ
|
|||||||
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, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
/** \brief convert node to HTML and returns \c true on success */
|
|
||||||
/** \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) override;
|
||||||
|
|
||||||
@ -129,7 +189,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBoxInstructionNode: public JKQTMathTex
|
|||||||
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, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
/** \brief convert node to HTML and returns \c true on success */
|
|
||||||
/** \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) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user