#include "InsetMathChar.h"
#include "InsetMathColor.h"
#include "InsetMathFrac.h"
-#include "InsetMathGrid.h"
#include "InsetMathNest.h"
#include "InsetMathScript.h"
#include "MathExtern.h"
size_t firstRelOp(MathData const & ar)
{
for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
- if ((*it)->isMathRel())
+ if ((*it)->mathClass() == MC_REL)
return it - ar.begin();
return ar.size();
}
}
+ // writes a preamble for underlined or struck out math display
+ void writeMathdisplayPreamble(WriteStream & os)
+ {
+ if (os.strikeoutMath()) {
+ if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "\\raisebox{-\\belowdisplayshortskip}{"
+ "\\lyxmathsout{\\parbox[b]{\\columnwidth}{";
+ else
+ os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
+ } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "\\raisebox{-\\belowdisplayshortskip}{"
+ "\\parbox[b]{\\columnwidth}{";
+ else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+ os << "\\parbox{\\columnwidth}{";
+ }
+
+
+ // writes a postamble for underlined or struck out math display
+ void writeMathdisplayPostamble(WriteStream & os)
+ {
+ if (os.strikeoutMath()) {
+ if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "}";
+ os << "}}\\\\\n";
+ } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "}}\\\\\n";
+ else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+ os << "}\\\\\n";
+ }
+
+
} // end anon namespace
return;
}
- // FIXME: Changing the same object repeatedly is inefficient.
Changer dummy1 = mi.base.changeFontSet(standardFont());
- Changer dummy2 = mi.base.changeStyle(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+ Changer dummy2 = mi.base.font.changeStyle(display() ? LM_ST_DISPLAY
+ : LM_ST_TEXT);
// let the cells adjust themselves
InsetMathGrid::metrics(mi, dim);
if (previewState(bv)) {
// Do not draw change tracking cue if taken care of by RowPainter
// already.
- Changer dummy = make_change(pi.change_, Change(), !canPaintChange(*bv));
+ Changer dummy = !canPaintChange(*bv) ? make_change(pi.change_, Change())
+ : Changer();
if (previewTooSmall(dim)) {
// we have an extra frame
preview_->draw(pi, x + ERROR_FRAME_WIDTH, y);
ColorCode color = pi.selected && lyxrc.use_system_colors
? Color_selectiontext : standardColor();
bool const really_change_color = pi.base.font.color() == Color_none;
- Changer dummy0 = pi.base.font.changeColor(color, really_change_color);
+ Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
+ : Changer();
Changer dummy1 = pi.base.changeFontSet(standardFont());
- Changer dummy2 = pi.base.changeStyle(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+ Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY
+ : LM_ST_TEXT);
InsetMathGrid::draw(pi, x + 1, y);
break;
case hullEquation:
- if (os.strikeoutMath()) {
- if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "\\raisebox{1ex}{";
- os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
- } else if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
- else if (os.ulemCmd() == WriteStream::STRIKEOUT)
- os << "\\parbox{\\columnwidth}{";
+ writeMathdisplayPreamble(os);
os << "\n";
os.startOuterRow();
if (n)
case hullFlAlign:
case hullGather:
case hullMultline:
- if (os.strikeoutMath()) {
- if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "\\raisebox{1ex}{";
- os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
- } else if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
- else if (os.ulemCmd() == WriteStream::STRIKEOUT)
- os << "\\parbox{\\columnwidth}{";
+ writeMathdisplayPreamble(os);
os << "\n";
os.startOuterRow();
os << "\\begin{" << hullName(type_) << star(n) << "}\n";
os << "\\end{equation" << star(n) << "}\n";
else
os << "\\]\n";
- if (os.strikeoutMath()) {
- if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "}";
- os << "}}\\\\\n";
- } else if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "}}\\\\\n";
- else if (os.ulemCmd() == WriteStream::STRIKEOUT)
- os << "}\\\\\n";
+ writeMathdisplayPostamble(os);
break;
case hullEqnArray:
os << "\n";
os.startOuterRow();
os << "\\end{" << hullName(type_) << star(n) << "}\n";
- if (os.strikeoutMath()) {
- if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "}";
- os << "}}\\\\\n";
- } else if (os.ulemCmd() == WriteStream::UNDERLINE)
- os << "}}\\\\\n";
- else if (os.ulemCmd() == WriteStream::STRIKEOUT)
- os << "}\\\\\n";
+ writeMathdisplayPostamble(os);
break;
case hullAlignAt: