mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 21:05:12 +00:00
use stream-like syntax for LaTeX output
(instead of inset.write(stream) functions) prepare fix for proper font sizes in chapter heading etc... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2899 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
da7583ab70
commit
5507c1ad69
@ -1,4 +1,9 @@
|
|||||||
|
|
||||||
|
2001-10-17 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* math_inset.h:
|
||||||
|
* *.[Ch]: make output more stream-like
|
||||||
|
|
||||||
2001-10-17 André Pönitz <poenitz@gmx.net>
|
2001-10-17 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* formula.C:
|
* formula.C:
|
||||||
|
@ -24,6 +24,8 @@ libmathed_la_SOURCES = \
|
|||||||
math_atom.h \
|
math_atom.h \
|
||||||
math_binominset.C \
|
math_binominset.C \
|
||||||
math_binominset.h \
|
math_binominset.h \
|
||||||
|
math_boxinset.C \
|
||||||
|
math_boxinset.h \
|
||||||
math_charinset.C \
|
math_charinset.C \
|
||||||
math_charinset.h \
|
math_charinset.h \
|
||||||
math_cursor.C \
|
math_cursor.C \
|
||||||
|
@ -171,7 +171,7 @@ string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathArray::write(ostream & os, bool fragile) const
|
void MathArray::write(MathWriteInfo & wi) const
|
||||||
{
|
{
|
||||||
for (const_iterator it = begin(); it != end(); ++it) {
|
for (const_iterator it = begin(); it != end(); ++it) {
|
||||||
MathInset * p = it->nucleus();
|
MathInset * p = it->nucleus();
|
||||||
@ -190,10 +190,10 @@ void MathArray::write(ostream & os, bool fragile) const
|
|||||||
} else
|
} else
|
||||||
*/
|
*/
|
||||||
if (MathScriptInset const * q = asScript(it)) {
|
if (MathScriptInset const * q = asScript(it)) {
|
||||||
q->write(p, os, fragile);
|
q->write(p, wi);
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
p->write(os, fragile);
|
p->write(wi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
class MathScriptInset;
|
class MathScriptInset;
|
||||||
class MathMacro;
|
class MathMacro;
|
||||||
|
class MathWriteInfo;
|
||||||
|
class MathMetricsInfo;
|
||||||
class LaTeXFeatures;
|
class LaTeXFeatures;
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@ -96,7 +98,7 @@ public:
|
|||||||
///
|
///
|
||||||
MathAtom const & at(size_type pos) const;
|
MathAtom const & at(size_type pos) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -90,16 +90,19 @@ void InsetFormula::write(Buffer const * buf, ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
|
int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool)
|
||||||
|
const
|
||||||
{
|
{
|
||||||
par_->write(os, fragile);
|
MathWriteInfo wi(buf, os, fragil);
|
||||||
|
par_->write(wi);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormula::ascii(Buffer const *, ostream & os, int) const
|
int InsetFormula::ascii(Buffer const * buf, ostream & os, int) const
|
||||||
{
|
{
|
||||||
par_->write(os, false);
|
MathWriteInfo wi(buf, os, false);
|
||||||
|
par_->write(wi);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +126,7 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::draw(BufferView * bv, LyXFont const &,
|
void InsetFormula::draw(BufferView * bv, LyXFont const & font,
|
||||||
int y, float & xx, bool) const
|
int y, float & xx, bool) const
|
||||||
{
|
{
|
||||||
int x = int(xx) - 1;
|
int x = int(xx) - 1;
|
||||||
@ -132,7 +135,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
|
|||||||
MathInset::workwidth = bv->workWidth();
|
MathInset::workwidth = bv->workWidth();
|
||||||
Painter & pain = bv->painter();
|
Painter & pain = bv->painter();
|
||||||
|
|
||||||
metrics();
|
metrics(bv, &font);
|
||||||
int w = par_->width();
|
int w = par_->width();
|
||||||
int h = par_->height();
|
int h = par_->height();
|
||||||
int a = par_->ascent();
|
int a = par_->ascent();
|
||||||
@ -150,12 +153,6 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::metrics() const
|
|
||||||
{
|
|
||||||
par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> const InsetFormula::getLabelList() const
|
vector<string> const InsetFormula::getLabelList() const
|
||||||
{
|
{
|
||||||
return mat()->getLabelList();
|
return mat()->getLabelList();
|
||||||
@ -302,7 +299,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::handleExtern(const string & arg, BufferView *)
|
void InsetFormula::handleExtern(const string & arg, BufferView * bv)
|
||||||
{
|
{
|
||||||
// where are we?
|
// where are we?
|
||||||
MathArray & ar = mathcursor->cursor().cell();
|
MathArray & ar = mathcursor->cursor().cell();
|
||||||
@ -337,7 +334,7 @@ void InsetFormula::handleExtern(const string & arg, BufferView *)
|
|||||||
mathcursor->end();
|
mathcursor->end();
|
||||||
|
|
||||||
// re-compute inset dimension
|
// re-compute inset dimension
|
||||||
metrics();
|
metrics(bv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -391,9 +388,9 @@ int InsetFormula::descent(BufferView *, LyXFont const &) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormula::width(BufferView *, LyXFont const &) const
|
int InsetFormula::width(BufferView * bv, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
metrics();
|
metrics(bv, &font);
|
||||||
return par_->width();
|
return par_->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,6 @@ public:
|
|||||||
int width(BufferView *, LyXFont const &) const;
|
int width(BufferView *, LyXFont const &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
|
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
|
||||||
///
|
|
||||||
void metrics() const;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
void write(Buffer const *, std::ostream &) const;
|
void write(Buffer const *, std::ostream &) const;
|
||||||
|
@ -104,6 +104,7 @@ MathArrayInset * matrixpar(MathInset::idx_type & idx)
|
|||||||
|
|
||||||
|
|
||||||
InsetFormulaBase::InsetFormulaBase()
|
InsetFormulaBase::InsetFormulaBase()
|
||||||
|
: view_(0), font_(0)
|
||||||
{
|
{
|
||||||
// This is needed as long the math parser is not re-entrant
|
// This is needed as long the math parser is not re-entrant
|
||||||
MathMacroTable::builtinMacros();
|
MathMacroTable::builtinMacros();
|
||||||
@ -116,6 +117,17 @@ void InsetFormulaBase::validate(LaTeXFeatures &) const
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetFormulaBase::metrics(BufferView * bv, LyXFont const * f) const
|
||||||
|
{
|
||||||
|
if (bv)
|
||||||
|
view_ = bv;
|
||||||
|
if (f)
|
||||||
|
font_ = f;
|
||||||
|
MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
|
||||||
|
par()->metrics(mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string const InsetFormulaBase::editMessage() const
|
string const InsetFormulaBase::editMessage() const
|
||||||
{
|
{
|
||||||
return _("Math editor mode");
|
return _("Math editor mode");
|
||||||
@ -128,7 +140,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
|
|||||||
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
|
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
|
||||||
|
|
||||||
mathcursor = new MathCursor(this, x == 0);
|
mathcursor = new MathCursor(this, x == 0);
|
||||||
metrics();
|
metrics(bv);
|
||||||
// if that is removed, we won't get the magenta box when entering an
|
// if that is removed, we won't get the magenta box when entering an
|
||||||
// inset for the first time
|
// inset for the first time
|
||||||
bv->updateInset(this, false);
|
bv->updateInset(this, false);
|
||||||
@ -233,7 +245,7 @@ vector<string> const InsetFormulaBase::getLabelList() const
|
|||||||
|
|
||||||
void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
|
void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
|
||||||
{
|
{
|
||||||
metrics();
|
metrics(bv);
|
||||||
bv->updateInset(this, dirty);
|
bv->updateInset(this, dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,8 +689,7 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
|
|||||||
// sel = "";
|
// sel = "";
|
||||||
//else
|
//else
|
||||||
|
|
||||||
string sel = bv->getLyXText()->selectionAsString(bv->buffer(),
|
string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
|
||||||
false);
|
|
||||||
|
|
||||||
InsetFormulaBase * f;
|
InsetFormulaBase * f;
|
||||||
if (sel.empty()) {
|
if (sel.empty()) {
|
||||||
|
@ -89,12 +89,16 @@ public:
|
|||||||
///
|
///
|
||||||
virtual MathAtom & par() = 0;
|
virtual MathAtom & par() = 0;
|
||||||
///
|
///
|
||||||
virtual void metrics() const = 0;
|
virtual void metrics(BufferView * bv = 0, LyXFont const * font = 0) const;
|
||||||
///
|
///
|
||||||
virtual void updateLocal(BufferView * bv, bool mark_dirty);
|
virtual void updateLocal(BufferView * bv, bool mark_dirty);
|
||||||
private:
|
private:
|
||||||
/// unimplemented
|
/// unimplemented
|
||||||
void operator=(const InsetFormulaBase &);
|
void operator=(const InsetFormulaBase &);
|
||||||
|
///
|
||||||
|
mutable BufferView * view_;
|
||||||
|
///
|
||||||
|
mutable LyXFont const * font_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// We don't really mess want around with mathed stuff outside mathed.
|
// We don't really mess want around with mathed stuff outside mathed.
|
||||||
|
@ -61,7 +61,10 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s)
|
|||||||
{
|
{
|
||||||
string name = mathed_parse_macro(s);
|
string name = mathed_parse_macro(s);
|
||||||
setInsetName(name);
|
setInsetName(name);
|
||||||
metrics();
|
#ifdef WITH_WARNINGS
|
||||||
|
#warning "metrics disabled"
|
||||||
|
#endif
|
||||||
|
//metrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,23 +74,27 @@ Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormulaMacro::write(Buffer const *, ostream & os) const
|
void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
|
||||||
{
|
{
|
||||||
os << "FormulaMacro ";
|
os << "FormulaMacro ";
|
||||||
par()->write(os, false);
|
MathWriteInfo wi(buf, os, false);
|
||||||
|
par()->write(wi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile,
|
int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile,
|
||||||
bool /*free_spacing*/) const
|
bool /*free_spacing*/) const
|
||||||
{
|
{
|
||||||
par()->write(os, fragile);
|
MathWriteInfo wi(buf, os, fragile);
|
||||||
|
par()->write(wi);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsetFormulaMacro::ascii(Buffer const *, ostream & os, int) const
|
|
||||||
|
int InsetFormulaMacro::ascii(Buffer const * buf, ostream & os, int) const
|
||||||
{
|
{
|
||||||
par()->write(os, false);
|
MathWriteInfo wi(buf, os, false);
|
||||||
|
par()->write(wi);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +115,7 @@ void InsetFormulaMacro::read(Buffer const *, LyXLex & lex)
|
|||||||
{
|
{
|
||||||
string name = mathed_parse_macro(lex);
|
string name = mathed_parse_macro(lex);
|
||||||
setInsetName(name);
|
setInsetName(name);
|
||||||
|
lyxerr << "metrics disabled";
|
||||||
metrics();
|
metrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +138,9 @@ int InsetFormulaMacro::descent(BufferView *, LyXFont const &) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormulaMacro::width(BufferView *, LyXFont const & f) const
|
int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
|
||||||
{
|
{
|
||||||
metrics();
|
metrics(bv, &f);
|
||||||
return 10 + lyxfont::width(prefix(), f) + par()->width();
|
return 10 + lyxfont::width(prefix(), f) + par()->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,12 +201,6 @@ MathInsetTypes InsetFormulaMacro::getType() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormulaMacro::metrics() const
|
|
||||||
{
|
|
||||||
par()->metrics(LM_ST_TEXT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
|
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
|
||||||
int baseline, float & x, bool /*cleared*/) const
|
int baseline, float & x, bool /*cleared*/) const
|
||||||
{
|
{
|
||||||
|
@ -68,8 +68,6 @@ public:
|
|||||||
///
|
///
|
||||||
MathInsetTypes getType() const;
|
MathInsetTypes getType() const;
|
||||||
///
|
///
|
||||||
void metrics() const;
|
|
||||||
///
|
|
||||||
MathAtom const & par() const;
|
MathAtom const & par() const;
|
||||||
///
|
///
|
||||||
MathAtom & par();
|
MathAtom & par();
|
||||||
|
@ -22,9 +22,9 @@ MathInset * MathArrayInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathArrayInset::write(std::ostream & os, bool fragile) const
|
void MathArrayInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
if (fragile)
|
if (os.fragile)
|
||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << "\\begin{array}";
|
os << "\\begin{array}";
|
||||||
|
|
||||||
@ -36,16 +36,19 @@ void MathArrayInset::write(std::ostream & os, bool fragile) const
|
|||||||
os << colinfo_[col].align_;
|
os << colinfo_[col].align_;
|
||||||
os << "}\n";
|
os << "}\n";
|
||||||
|
|
||||||
MathGridInset::write(os, fragile);
|
MathGridInset::write(os);
|
||||||
|
|
||||||
if (fragile)
|
if (os.fragile)
|
||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << "\\end{array}\n";
|
os << "\\end{array}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathArrayInset::metrics(MathStyles st) const
|
void MathArrayInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
MathGridInset::metrics(st == LM_ST_DISPLAY ? LM_ST_TEXT : st);
|
MathMetricsInfo m = st;
|
||||||
|
if (m.size == LM_ST_DISPLAY)
|
||||||
|
m.size = LM_ST_TEXT;
|
||||||
|
MathGridInset::metrics(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
MathArrayInset * asArrayInset() { return this; }
|
MathArrayInset * asArrayInset() { return this; }
|
||||||
};
|
};
|
||||||
|
@ -28,11 +28,12 @@ int MathBinomInset::dw() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathBinomInset::metrics(MathStyles st) const
|
void MathBinomInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = smallerStyleFrac(st);
|
MathMetricsInfo m = st;
|
||||||
xcell(0).metrics(size_);
|
m.size = smallerStyleFrac(m.size);
|
||||||
xcell(1).metrics(size_);
|
xcell(0).metrics(m);
|
||||||
|
xcell(1).metrics(m);
|
||||||
ascent_ = xcell(0).height() + 4 + 5;
|
ascent_ = xcell(0).height() + 4 + 5;
|
||||||
descent_ = xcell(1).height() + 4 - 5;
|
descent_ = xcell(1).height() + 4 - 5;
|
||||||
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
||||||
@ -51,13 +52,9 @@ void MathBinomInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathBinomInset::write(std::ostream & os, bool fragile) const
|
void MathBinomInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << '{';
|
os << '{' << cell(0) << " \\choose " << cell(1) << '}';
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << " \\choose ";
|
|
||||||
cell(1).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
private:
|
private:
|
||||||
|
81
src/mathed/math_boxinset.C
Normal file
81
src/mathed/math_boxinset.C
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "math_boxinset.h"
|
||||||
|
#include "support/LOstream.h"
|
||||||
|
#include "LColor.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "Painter.h"
|
||||||
|
#include "math_cursor.h"
|
||||||
|
#include "insets/insettext.h"
|
||||||
|
|
||||||
|
|
||||||
|
MathBoxInset::MathBoxInset(string const & name)
|
||||||
|
: MathDimInset(), name_(name), text_(new InsetText), buffer_(0)
|
||||||
|
{
|
||||||
|
lyxerr << "creating new " << name << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathBoxInset::MathBoxInset(MathBoxInset const & m)
|
||||||
|
: MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
|
||||||
|
{
|
||||||
|
if (!m.buffer_)
|
||||||
|
cerr << "no buffer\n";
|
||||||
|
else
|
||||||
|
text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathBoxInset::~MathBoxInset()
|
||||||
|
{
|
||||||
|
delete text_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathInset * MathBoxInset::clone() const
|
||||||
|
{
|
||||||
|
return new MathBoxInset(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBoxInset::write(MathWriteInfo & os) const
|
||||||
|
{
|
||||||
|
os << "\\" << name_ << "{" << cell(0) << "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBoxInset::writeNormal(std::ostream & os) const
|
||||||
|
{
|
||||||
|
os << "[mbox ";
|
||||||
|
//text_->write(buffer(), os);
|
||||||
|
os << "] ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBoxInset::metrics(MathMetricsInfo const & st) const
|
||||||
|
{
|
||||||
|
size_ = st;
|
||||||
|
if (text_ && st.view && st.font) {
|
||||||
|
ascent_ = text_->ascent(st.view, *st.font) + 2;
|
||||||
|
descent_ = text_->descent(st.view, *st.font) + 2;
|
||||||
|
width_ = text_->width(st.view, *st.font) + 4;
|
||||||
|
} else {
|
||||||
|
ascent_ = 10;
|
||||||
|
descent_ = 0;
|
||||||
|
width_ = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBoxInset::draw(Painter & pain, int x, int y) const
|
||||||
|
{
|
||||||
|
float fx = x + 2;
|
||||||
|
|
||||||
|
if (text_ && size_.view && size_.font)
|
||||||
|
text_->draw(size_.view, *(size_.font), y, fx, false);
|
||||||
|
if (mathcursor && mathcursor->isInside(this))
|
||||||
|
pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
|
||||||
|
LColor::mathframe);
|
||||||
|
}
|
51
src/mathed/math_boxinset.h
Normal file
51
src/mathed/math_boxinset.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
#ifndef MATH_BOXINSET_H
|
||||||
|
#define MATH_BOXINSET_H
|
||||||
|
|
||||||
|
#include "math_diminset.h"
|
||||||
|
#include "LString.h"
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class InsetText;
|
||||||
|
class BufferView;
|
||||||
|
class Buffer;
|
||||||
|
class LyXFont;
|
||||||
|
|
||||||
|
/// Support for \\mbox
|
||||||
|
|
||||||
|
class MathBoxInset : public MathDimInset {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
explicit MathBoxInset(string const &);
|
||||||
|
///
|
||||||
|
MathBoxInset(MathBoxInset const &);
|
||||||
|
///
|
||||||
|
~MathBoxInset();
|
||||||
|
///
|
||||||
|
MathInset * clone() const;
|
||||||
|
///
|
||||||
|
void draw(Painter &, int x, int y) const;
|
||||||
|
///
|
||||||
|
void write(MathWriteInfo & os) const;
|
||||||
|
///
|
||||||
|
void writeNormal(std::ostream &) const;
|
||||||
|
///
|
||||||
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
|
/// identifies BoxInsets
|
||||||
|
MathBoxInset * asBoxInset() { return this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// unimplemented
|
||||||
|
void operator=(MathBoxInset const &);
|
||||||
|
|
||||||
|
///
|
||||||
|
string name_;
|
||||||
|
///
|
||||||
|
InsetText * text_;
|
||||||
|
///
|
||||||
|
mutable Buffer * buffer_;
|
||||||
|
};
|
||||||
|
#endif
|
@ -76,7 +76,7 @@ int MathCharInset::width() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathCharInset::metrics(MathStyles st) const
|
void MathCharInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ void MathCharInset::draw(Painter & pain, int x, int y) const
|
|||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
|
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
|
||||||
drawChar(pain, code_, size_, x, y, char_);
|
drawChar(pain, code_, size_.size, x, y, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -111,11 +111,11 @@ void MathCharInset::writeRaw(std::ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathCharInset::write(std::ostream & os, bool) const
|
void MathCharInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
writeHeader(os);
|
writeHeader(os.os);
|
||||||
writeRaw(os);
|
writeRaw(os.os);
|
||||||
writeTrailer(os);
|
writeTrailer(os.os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathTextCodes nativeCode(char c) const;
|
MathTextCodes nativeCode(char c) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeHeader(std::ostream &) const;
|
void writeHeader(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -460,7 +460,10 @@ void MathCursor::niceInsert(MathAtom const & t)
|
|||||||
right(); // do not push for e.g. MathSymbolInset
|
right(); // do not push for e.g. MathSymbolInset
|
||||||
selPaste();
|
selPaste();
|
||||||
}
|
}
|
||||||
p->metrics(p->size());
|
#ifdef WITH_WARNINGS
|
||||||
|
#warning "redraw disabled"
|
||||||
|
#endif
|
||||||
|
//p->metrics(p->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -936,7 +939,8 @@ void MathCursor::normalize() const
|
|||||||
lyxerr << "this should not really happen - 2: "
|
lyxerr << "this should not really happen - 2: "
|
||||||
<< pos() << " " << size() << " in idx: " << it->idx()
|
<< pos() << " " << size() << " in idx: " << it->idx()
|
||||||
<< " in atom: '";
|
<< " in atom: '";
|
||||||
it->par()->write(lyxerr, false);
|
MathWriteInfo wi(0, lyxerr, false);
|
||||||
|
it->par()->write(wi);
|
||||||
lyxerr << "\n";
|
lyxerr << "\n";
|
||||||
dump("error 4");
|
dump("error 4");
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ bool MathDecorationInset::wide() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDecorationInset::metrics(MathStyles st) const
|
void MathDecorationInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(st);
|
xcell(0).metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
@ -96,13 +96,11 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDecorationInset::write(ostream & os, bool fragile) const
|
void MathDecorationInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
if (fragile && protect())
|
if (os.fragile && protect())
|
||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << '\\' << name_ << '{';
|
os << '\\' << name_ << '{' << cell(0) << '}';
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream & os) const;
|
void writeNormal(std::ostream & os) const;
|
||||||
///
|
///
|
||||||
|
@ -42,11 +42,10 @@ string MathDelimInset::latexName(string const & name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDelimInset::write(std::ostream & os, bool fragile) const
|
void MathDelimInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\left" << latexName(left_);
|
os << "\\left" << latexName(left_) << cell(0)
|
||||||
cell(0).write(os, fragile);
|
<< "\\right" << latexName(right_);
|
||||||
os << "\\right" << latexName(right_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,12 +60,12 @@ int MathDelimInset::dw() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDelimInset::metrics(MathStyles st) const
|
void MathDelimInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(st);
|
xcell(0).metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
int a, d, w;
|
int a, d, w;
|
||||||
mathed_char_dim(LM_TC_VAR, st,'I', a, d, w);
|
mathed_char_dim(LM_TC_VAR, size_.size,'I', a, d, w);
|
||||||
int h0 = (a + d) / 2;
|
int h0 = (a + d) / 2;
|
||||||
int a0 = std::max(xcell(0).ascent(), a) - h0;
|
int a0 = std::max(xcell(0).ascent(), a) - h0;
|
||||||
int d0 = std::max(xcell(0).descent(), d) + h0;
|
int d0 = std::max(xcell(0).descent(), d) + h0;
|
||||||
|
@ -22,9 +22,9 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
int dw() const;
|
int dw() const;
|
||||||
|
@ -32,9 +32,9 @@ void MathDotsInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDotsInset::metrics(MathStyles st) const
|
void MathDotsInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size(st);
|
size_ = st;
|
||||||
mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
|
mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
|
||||||
switch (name_[0]) {
|
switch (name_[0]) {
|
||||||
case 'l': dh_ = 0; break;
|
case 'l': dh_ = 0; break;
|
||||||
@ -45,7 +45,7 @@ void MathDotsInset::metrics(MathStyles st) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDotsInset::write(ostream & os, bool /* fragile */) const
|
void MathDotsInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << '\\' << name_ << ' ';
|
os << '\\' << name_ << ' ';
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
protected:
|
protected:
|
||||||
/// cache for the thing's heigth
|
/// cache for the thing's heigth
|
||||||
mutable int dh_;
|
mutable int dh_;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "math_parser.h"
|
#include "math_parser.h"
|
||||||
#include "math_binominset.h"
|
#include "math_binominset.h"
|
||||||
|
//#include "math_boxinset.h"
|
||||||
#include "math_decorationinset.h"
|
#include "math_decorationinset.h"
|
||||||
#include "math_dotsinset.h"
|
#include "math_dotsinset.h"
|
||||||
#include "math_funcinset.h"
|
#include "math_funcinset.h"
|
||||||
@ -62,6 +63,8 @@ MathAtom createMathInset(latexkeys const * l)
|
|||||||
return MathAtom(new MathSpaceInset(l->id));
|
return MathAtom(new MathSpaceInset(l->id));
|
||||||
case LM_TK_DOTS:
|
case LM_TK_DOTS:
|
||||||
return MathAtom(new MathDotsInset(l->name));
|
return MathAtom(new MathDotsInset(l->name));
|
||||||
|
//case LM_TK_BOX:
|
||||||
|
// return MathAtom(new MathBoxInset(l->name));
|
||||||
}
|
}
|
||||||
return MathAtom(new MathFuncInset(l->name));
|
return MathAtom(new MathFuncInset(l->name));
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,10 @@ MathInset * MathFracInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFracInset::metrics(MathStyles st) const
|
void MathFracInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = smallerStyleFrac(st);
|
size_ = st;
|
||||||
|
size_.size = smallerStyleFrac(size_.size);
|
||||||
xcell(0).metrics(size_);
|
xcell(0).metrics(size_);
|
||||||
xcell(1).metrics(size_);
|
xcell(1).metrics(size_);
|
||||||
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
||||||
@ -42,21 +43,12 @@ void MathFracInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFracInset::write(std::ostream & os, bool fragile) const
|
void MathFracInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
if (atop_) {
|
if (atop_)
|
||||||
os << "{";
|
os << '{' << cell(0) << "\\atop " << cell(1) << '}';
|
||||||
cell(0).write(os, fragile);
|
else
|
||||||
os << "\\atop ";
|
os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
|
||||||
cell(1).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
} else {
|
|
||||||
os << "\\frac{";
|
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << "}{";
|
|
||||||
cell(1).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
public:
|
public:
|
||||||
|
@ -37,7 +37,7 @@ void MathFuncInset::setName(string const & n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFuncInset::write(std::ostream & os, bool /* fragile */) const
|
void MathFuncInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\" << name_ << ' ';
|
os << "\\" << name_ << ' ';
|
||||||
}
|
}
|
||||||
@ -49,10 +49,10 @@ void MathFuncInset::writeNormal(std::ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFuncInset::metrics(MathStyles st) const
|
void MathFuncInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
mathed_string_dim(LM_TC_TEX, size_, name_, ascent_, descent_, width_);
|
mathed_string_dim(LM_TC_TEX, size_.size, name_, ascent_, descent_, width_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,5 +60,5 @@ void MathFuncInset::draw(Painter & pain, int x, int y) const
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
drawStr(pain, LM_TC_TEX, size_, x, y, name_);
|
drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -19,11 +19,11 @@ MathInset * MathFuncLimInset::clone() const
|
|||||||
|
|
||||||
bool MathFuncLimInset::isScriptable() const
|
bool MathFuncLimInset::isScriptable() const
|
||||||
{
|
{
|
||||||
return size_ == LM_ST_DISPLAY;
|
return size_.size == LM_ST_DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFuncLimInset::write(ostream & os, bool /* fragile */) const
|
void MathFuncLimInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << '\\' << sym_->name << ' ';
|
os << '\\' << sym_->name << ' ';
|
||||||
}
|
}
|
||||||
@ -35,10 +35,11 @@ void MathFuncLimInset::writeNormal(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFuncLimInset::metrics(MathStyles st) const
|
void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size(st);
|
size_ = st;
|
||||||
mathed_string_dim(LM_TC_TEXTRM, size(), sym_->name, ascent_, descent_, width_);
|
mathed_string_dim(LM_TC_TEXTRM, size_.size, sym_->name,
|
||||||
|
ascent_, descent_, width_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -46,5 +47,5 @@ void MathFuncLimInset::draw(Painter & pain, int x, int y) const
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
|
drawStr(pain, LM_TC_TEXTRM, size_.size, x, y, sym_->name);
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -132,7 +132,7 @@ LyXLength MathGridInset::vskip(row_type row) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathGridInset::metrics(MathStyles st) const
|
void MathGridInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
// let the cells adjust themselves
|
// let the cells adjust themselves
|
||||||
MathNestInset::metrics(st);
|
MathNestInset::metrics(st);
|
||||||
@ -264,13 +264,11 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathGridInset::write(std::ostream & os, bool fragile) const
|
void MathGridInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
for (row_type row = 0; row < nrows(); ++row) {
|
for (row_type row = 0; row < nrows(); ++row) {
|
||||||
for (col_type col = 0; col < ncols(); ++col) {
|
for (col_type col = 0; col < ncols(); ++col)
|
||||||
cell(index(row, col)).write(os, fragile);
|
os << cell(index(row, col)) << eocString(col);
|
||||||
os << eocString(col);
|
|
||||||
}
|
|
||||||
os << eolString(row);
|
os << eolString(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathGridInset(int m, int n, char valign, string const & halign);
|
MathGridInset(int m, int n, char valign, string const & halign);
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -94,6 +94,7 @@ latexkeys_a wordlist_array[] =
|
|||||||
{"mathsf", LM_TK_FONT, LM_TC_SF},
|
{"mathsf", LM_TK_FONT, LM_TC_SF},
|
||||||
{"mathtt", LM_TK_FONT, LM_TC_TT},
|
{"mathtt", LM_TK_FONT, LM_TC_TT},
|
||||||
{"max", LM_TK_FUNCLIM, 0},
|
{"max", LM_TK_FUNCLIM, 0},
|
||||||
|
//{"mbox", LM_TK_BOX, 0},
|
||||||
{"min", LM_TK_FUNCLIM, 0},
|
{"min", LM_TK_FUNCLIM, 0},
|
||||||
{"newcommand", LM_TK_NEWCOMMAND, 0 },
|
{"newcommand", LM_TK_NEWCOMMAND, 0 },
|
||||||
{"nolimits", LM_TK_LIMIT, static_cast<unsigned>(-1)},
|
{"nolimits", LM_TK_LIMIT, static_cast<unsigned>(-1)},
|
||||||
@ -154,6 +155,7 @@ MathTokenEnum tokenEnum(const string & font)
|
|||||||
return LM_TK_SYM;
|
return LM_TK_SYM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathSymbolTypes symbolType(const string & type)
|
MathSymbolTypes symbolType(const string & type)
|
||||||
{
|
{
|
||||||
if (type == "mathrel")
|
if (type == "mathrel")
|
||||||
|
@ -28,7 +28,7 @@ int MathInset::workwidth;
|
|||||||
|
|
||||||
|
|
||||||
MathInset::MathInset()
|
MathInset::MathInset()
|
||||||
: size_(LM_ST_DISPLAY), xo_(0), yo_(0)
|
: xo_(0), yo_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -44,19 +44,14 @@ int MathInset::height() const
|
|||||||
|
|
||||||
MathStyles MathInset::size() const
|
MathStyles MathInset::size() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_.size;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MathInset::size(MathStyles s) const
|
|
||||||
{
|
|
||||||
size_ = s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
|
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
|
||||||
{
|
{
|
||||||
inset.write(os, false);
|
MathWriteInfo wi(0, os, false);
|
||||||
|
inset.write(wi);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +211,8 @@ void MathInset::userSetSize(MathStyles sz)
|
|||||||
void MathInset::writeNormal(std::ostream & os) const
|
void MathInset::writeNormal(std::ostream & os) const
|
||||||
{
|
{
|
||||||
os << "[unknown ";
|
os << "[unknown ";
|
||||||
write(os, false);
|
MathWriteInfo wi(0, os, false);
|
||||||
|
write(wi);
|
||||||
os << "] ";
|
os << "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +220,8 @@ void MathInset::writeNormal(std::ostream & os) const
|
|||||||
void MathInset::dump() const
|
void MathInset::dump() const
|
||||||
{
|
{
|
||||||
lyxerr << "---------------------------------------------\n";
|
lyxerr << "---------------------------------------------\n";
|
||||||
write(lyxerr, false);
|
MathWriteInfo wi(0, lyxerr, false);
|
||||||
|
write(wi);
|
||||||
lyxerr << "\n---------------------------------------------\n";
|
lyxerr << "\n---------------------------------------------\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +264,7 @@ std::vector<MathInset::idx_type>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathInset::metrics(MathStyles st) const
|
void MathInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
lyxerr << "MathInset::metrics() called directly!\n";
|
lyxerr << "MathInset::metrics() called directly!\n";
|
||||||
size_ = st;
|
size_ = st;
|
||||||
@ -280,7 +277,7 @@ void MathInset::draw(Painter &, int, int) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathInset::write(std::ostream &, bool) const
|
void MathInset::write(MathWriteInfo &) const
|
||||||
{
|
{
|
||||||
lyxerr << "MathInset::write() called directly!\n";
|
lyxerr << "MathInset::write() called directly!\n";
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,75 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class LaTeXFeatures;
|
|
||||||
class MathArrayInset;
|
class MathArrayInset;
|
||||||
|
class MathBoxInset;
|
||||||
class MathCharInset;
|
class MathCharInset;
|
||||||
class MathGridInset;
|
class MathGridInset;
|
||||||
class MathNestInset;
|
class MathNestInset;
|
||||||
class MathScriptInset;
|
|
||||||
class MathMatrixInset;
|
class MathMatrixInset;
|
||||||
|
class MathScriptInset;
|
||||||
class MathSpaceInset;
|
class MathSpaceInset;
|
||||||
class MathMacroTemplate;
|
class MathMacroTemplate;
|
||||||
|
|
||||||
|
class LaTeXFeatures;
|
||||||
|
class Buffer;
|
||||||
|
class BufferView;
|
||||||
|
class LyXFont;
|
||||||
|
|
||||||
|
|
||||||
|
struct MathMetricsInfo {
|
||||||
|
///
|
||||||
|
MathMetricsInfo()
|
||||||
|
: view(0), font(0), size(LM_ST_TEXT)
|
||||||
|
{}
|
||||||
|
///
|
||||||
|
MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
|
||||||
|
: view(v), font(f), size(s)
|
||||||
|
{}
|
||||||
|
|
||||||
|
///
|
||||||
|
BufferView * view;
|
||||||
|
///
|
||||||
|
LyXFont const * font;
|
||||||
|
///
|
||||||
|
MathStyles size;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct MathWriteInfo {
|
||||||
|
///
|
||||||
|
MathWriteInfo(Buffer const * buffer_, std::ostream & os_, bool fragile_)
|
||||||
|
: buffer(buffer_), os(os_), fragile(fragile_)
|
||||||
|
{}
|
||||||
|
///
|
||||||
|
explicit MathWriteInfo(std::ostream & os_)
|
||||||
|
: buffer(0), os(os_), fragile(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
///
|
||||||
|
template <class T>
|
||||||
|
MathWriteInfo & operator<<(T const & T)
|
||||||
|
{
|
||||||
|
os << T;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
///
|
||||||
|
MathWriteInfo & operator<<(MathArray const & ar)
|
||||||
|
{
|
||||||
|
ar.write(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
Buffer const * buffer;
|
||||||
|
///
|
||||||
|
std::ostream & os;
|
||||||
|
///
|
||||||
|
bool fragile;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class MathInset {
|
class MathInset {
|
||||||
public:
|
public:
|
||||||
/// short of anything else reasonable
|
/// short of anything else reasonable
|
||||||
@ -68,7 +127,7 @@ public:
|
|||||||
/// draw the object, sets xo_ and yo_ cached values
|
/// draw the object, sets xo_ and yo_ cached values
|
||||||
virtual void draw(Painter &, int x, int y) const;
|
virtual void draw(Painter &, int x, int y) const;
|
||||||
/// write LaTeX and Lyx code
|
/// write LaTeX and Lyx code
|
||||||
virtual void write(std::ostream &, bool fragile) const;
|
virtual void write(MathWriteInfo & os) const;
|
||||||
/// write normalized content
|
/// write normalized content
|
||||||
virtual void writeNormal(std::ostream &) const;
|
virtual void writeNormal(std::ostream &) const;
|
||||||
/// reproduce itself
|
/// reproduce itself
|
||||||
@ -76,7 +135,7 @@ public:
|
|||||||
///substitutes macro arguments if necessary
|
///substitutes macro arguments if necessary
|
||||||
virtual void substitute(MathMacro const & macro);
|
virtual void substitute(MathMacro const & macro);
|
||||||
/// compute the size of the object, sets ascend_, descend_ and width_
|
/// compute the size of the object, sets ascend_, descend_ and width_
|
||||||
virtual void metrics(MathStyles st) const;
|
virtual void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
virtual int ascent() const { return 1; }
|
virtual int ascent() const { return 1; }
|
||||||
///
|
///
|
||||||
@ -191,6 +250,8 @@ public:
|
|||||||
virtual MathGridInset * asGridInset() { return 0; }
|
virtual MathGridInset * asGridInset() { return 0; }
|
||||||
/// identifies ArrayInsets
|
/// identifies ArrayInsets
|
||||||
virtual MathArrayInset * asArrayInset() { return 0; }
|
virtual MathArrayInset * asArrayInset() { return 0; }
|
||||||
|
/// identifies BoxInsets
|
||||||
|
virtual MathBoxInset * asBoxInset() { return 0; }
|
||||||
/// identifies macro templates
|
/// identifies macro templates
|
||||||
virtual MathMacroTemplate * asMacroTemplate() { return 0; }
|
virtual MathMacroTemplate * asMacroTemplate() { return 0; }
|
||||||
|
|
||||||
@ -226,10 +287,8 @@ public:
|
|||||||
static int workwidth;
|
static int workwidth;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// _sets_ style
|
|
||||||
void size(MathStyles s) const;
|
|
||||||
/// the used font size
|
/// the used font size
|
||||||
mutable MathStyles size_;
|
mutable MathMetricsInfo size_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// the following are used for positioning the cursor with the mouse
|
/// the following are used for positioning the cursor with the mouse
|
||||||
|
@ -31,7 +31,7 @@ void MathKernInset::draw(Painter &, int, int) const
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void MathKernInset::write(std::ostream & os, bool) const
|
void MathKernInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\kern" << wid_.asLatexString() << " ";
|
os << "\\kern" << wid_.asLatexString() << " ";
|
||||||
}
|
}
|
||||||
@ -43,12 +43,14 @@ void MathKernInset::writeNormal(std::ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathKernInset::metrics(MathStyles) const
|
void MathKernInset::metrics(MathMetricsInfo const &) const
|
||||||
{
|
{
|
||||||
ascent_ = 0;
|
ascent_ = 0;
|
||||||
descent_ = 0;
|
descent_ = 0;
|
||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
#warning fix this once the interface to LyXLength has improved
|
#warning fix this once the interface to LyXLength has improved
|
||||||
#endif
|
#endif
|
||||||
|
// this uses the numerical valu in pixels, even if the unit is cm or ex!
|
||||||
width_ = static_cast<int>(wid_.value());
|
width_ = static_cast<int>(wid_.value());
|
||||||
|
//cerr << "handling kern of width " << wid_.value() << "\n";
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
private:
|
private:
|
||||||
/// width in em
|
/// width in em
|
||||||
LyXLength wid_;
|
LyXLength wid_;
|
||||||
|
@ -30,23 +30,22 @@ void MathLefteqnInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathLefteqnInset::write(std::ostream & os, bool fragile) const
|
void MathLefteqnInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\lefteqn{";
|
os << "\\lefteqn{" << cell(0) << "}";
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << "}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathLefteqnInset::writeNormal(std::ostream & os) const
|
void MathLefteqnInset::writeNormal(std::ostream & os) const
|
||||||
{
|
{
|
||||||
os << "[lefteqn ";
|
os << "[lefteqn ";
|
||||||
cell(0).write(os, false);
|
MathWriteInfo wi(os);
|
||||||
|
cell(0).write(wi);
|
||||||
os << "] ";
|
os << "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathLefteqnInset::metrics(MathStyles st) const
|
void MathLefteqnInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
MathNestInset::metrics(st);
|
MathNestInset::metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// The \kern primitive
|
/// Support for LaTeX's \\lefteqn command
|
||||||
|
|
||||||
class MathLefteqnInset : public MathNestInset {
|
class MathLefteqnInset : public MathNestInset {
|
||||||
public:
|
public:
|
||||||
@ -19,10 +19,10 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,11 +69,11 @@ bool MathMacro::editing() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacro::metrics(MathStyles st) const
|
void MathMacro::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
if (defining()) {
|
if (defining()) {
|
||||||
size_ = st;
|
size_ = st;
|
||||||
mathed_string_dim(LM_TC_TEX, size_, name(), ascent_, descent_, width_);
|
mathed_string_dim(LM_TC_TEX, size_.size, name(), ascent_, descent_, width_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +85,12 @@ void MathMacro::metrics(MathStyles st) const
|
|||||||
ascent_ = expanded_.ascent() + 2;
|
ascent_ = expanded_.ascent() + 2;
|
||||||
descent_ = expanded_.descent() + 2;
|
descent_ = expanded_.descent() + 2;
|
||||||
|
|
||||||
width_ += mathed_string_width(LM_TC_TEXTRM, size_, name()) + 10;
|
width_ += mathed_string_width(LM_TC_TEXTRM, size_.size, name()) + 10;
|
||||||
|
|
||||||
int lasc;
|
int lasc;
|
||||||
int ldes;
|
int ldes;
|
||||||
int lwid;
|
int lwid;
|
||||||
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
|
mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
|
||||||
|
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
MathXArray const & c = xcell(i);
|
MathXArray const & c = xcell(i);
|
||||||
@ -117,25 +117,25 @@ void MathMacro::draw(Painter & pain, int x, int y) const
|
|||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
|
|
||||||
metrics(size());
|
metrics(size_);
|
||||||
|
|
||||||
if (defining()) {
|
if (defining()) {
|
||||||
drawStr(pain, LM_TC_TEX, size_, x, y, name());
|
drawStr(pain, LM_TC_TEX, size_.size, x, y, name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editing()) {
|
if (editing()) {
|
||||||
int h = y - ascent() + 2 + expanded_.ascent();
|
int h = y - ascent() + 2 + expanded_.ascent();
|
||||||
drawStr(pain, LM_TC_TEXTRM, size(), x + 3, h, name());
|
drawStr(pain, LM_TC_TEXTRM, size_.size, x + 3, h, name());
|
||||||
|
|
||||||
int const w = mathed_string_width(LM_TC_TEXTRM, size(), name());
|
int const w = mathed_string_width(LM_TC_TEXTRM, size_.size, name());
|
||||||
expanded_.draw(pain, x + w + 12, h);
|
expanded_.draw(pain, x + w + 12, h);
|
||||||
h += expanded_.descent();
|
h += expanded_.descent();
|
||||||
|
|
||||||
int lasc;
|
int lasc;
|
||||||
int ldes;
|
int ldes;
|
||||||
int lwid;
|
int lwid;
|
||||||
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
|
mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
|
||||||
|
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
MathXArray const & c = xcell(i);
|
MathXArray const & c = xcell(i);
|
||||||
@ -143,7 +143,7 @@ void MathMacro::draw(Painter & pain, int x, int y) const
|
|||||||
c.draw(pain, x + lwid, h);
|
c.draw(pain, x + lwid, h);
|
||||||
char str[] = "#1:";
|
char str[] = "#1:";
|
||||||
str[1] += static_cast<char>(i);
|
str[1] += static_cast<char>(i);
|
||||||
drawStr(pain, LM_TC_TEX, size(), x + 3, h, str);
|
drawStr(pain, LM_TC_TEX, size_.size, x + 3, h, str);
|
||||||
h += std::max(c.descent(), ldes) + 5;
|
h += std::max(c.descent(), ldes) + 5;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -158,18 +158,18 @@ void MathMacro::dump() const
|
|||||||
MathMacroTable::dump();
|
MathMacroTable::dump();
|
||||||
lyxerr << "\n macro: '" << this << "'\n";
|
lyxerr << "\n macro: '" << this << "'\n";
|
||||||
lyxerr << " name: '" << name() << "'\n";
|
lyxerr << " name: '" << name() << "'\n";
|
||||||
lyxerr << " template: '"; tmplate_->write(lyxerr, false); lyxerr << "'\n";
|
lyxerr << " template: '";
|
||||||
|
MathWriteInfo wi(lyxerr);
|
||||||
|
tmplate_->write(wi);
|
||||||
|
lyxerr << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacro::write(std::ostream & os, bool fragile) const
|
void MathMacro::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << '\\' << name();
|
os << '\\' << name();
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i)
|
||||||
os << '{';
|
os << '{' << cell(i) << '}';
|
||||||
cell(i).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
|
||||||
if (nargs() == 0)
|
if (nargs() == 0)
|
||||||
os << ' ';
|
os << ' ';
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,11 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -29,13 +29,13 @@ MathInset * MathMacroArgument::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
|
void MathMacroArgument::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << '#' << number_;
|
os << '#' << number_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacroArgument::metrics(MathStyles st) const
|
void MathMacroArgument::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
if (expanded_) {
|
if (expanded_) {
|
||||||
xcell(0).metrics(st);
|
xcell(0).metrics(st);
|
||||||
@ -43,7 +43,7 @@ void MathMacroArgument::metrics(MathStyles st) const
|
|||||||
ascent_ = xcell(0).ascent();
|
ascent_ = xcell(0).ascent();
|
||||||
descent_ = xcell(0).descent();
|
descent_ = xcell(0).descent();
|
||||||
} else
|
} else
|
||||||
mathed_string_dim(LM_TC_TEX, size(), str_, ascent_, descent_, width_);
|
mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y) const
|
|||||||
if (expanded_)
|
if (expanded_)
|
||||||
xcell(0).draw(pain, x, y);
|
xcell(0).draw(pain, x, y);
|
||||||
else
|
else
|
||||||
drawStr(pain, LM_TC_TEX, size(), x, y, str_);
|
drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -47,20 +47,16 @@ string const & MathMacroTemplate::name() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacroTemplate::write(std::ostream & os, bool fragile) const
|
void MathMacroTemplate::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\n\\newcommand{\\" << name_ << "}";
|
os << "\n\\newcommand{\\" << name_ << '}';
|
||||||
|
|
||||||
if (numargs_ > 0)
|
if (numargs_ > 0)
|
||||||
os << "[" << numargs_ << "]";
|
os << '[' << numargs_ << ']';
|
||||||
|
os << '{' << cell(0) << "}\n";
|
||||||
os << "{";
|
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << "}\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacroTemplate::metrics(MathStyles st) const
|
void MathMacroTemplate::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(st);
|
xcell(0).metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
/// Number of arguments
|
/// Number of arguments
|
||||||
int numargs() const;
|
int numargs() const;
|
||||||
///
|
///
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
/// identifies macro templates
|
/// identifies macro templates
|
||||||
MathMacroTemplate * asMacroTemplate() { return this; }
|
MathMacroTemplate * asMacroTemplate() { return this; }
|
||||||
private:
|
private:
|
||||||
|
@ -140,9 +140,10 @@ int MathMatrixInset::defaultColSpace(col_type col)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMatrixInset::metrics(MathStyles) const
|
void MathMatrixInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
|
size_ = st;
|
||||||
|
size_.size = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
|
||||||
|
|
||||||
// let the cells adjust themselves
|
// let the cells adjust themselves
|
||||||
MathGridInset::metrics(size_);
|
MathGridInset::metrics(size_);
|
||||||
@ -187,17 +188,15 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
void MathMatrixInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
header_write(os);
|
header_write(os.os);
|
||||||
|
|
||||||
bool n = numberedType();
|
bool n = numberedType();
|
||||||
|
|
||||||
for (row_type row = 0; row < nrows(); ++row) {
|
for (row_type row = 0; row < nrows(); ++row) {
|
||||||
for (col_type col = 0; col < ncols(); ++col) {
|
for (col_type col = 0; col < ncols(); ++col)
|
||||||
cell(index(row, col)).write(os, fragile);
|
os << cell(index(row, col)) << eocString(col);
|
||||||
os << eocString(col);
|
|
||||||
}
|
|
||||||
if (n) {
|
if (n) {
|
||||||
if (!label_[row].empty())
|
if (!label_[row].empty())
|
||||||
os << "\\label{" << label_[row] << "}";
|
os << "\\label{" << label_[row] << "}";
|
||||||
@ -207,7 +206,7 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
|||||||
os << eolString(row);
|
os << eolString(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
footer_write(os);
|
footer_write(os.os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -48,7 +48,7 @@ void MathNestInset::substitute(MathMacro const & m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathNestInset::metrics(MathStyles st) const
|
void MathNestInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
for (idx_type i = 0; i < nargs(); ++i)
|
for (idx_type i = 0; i < nargs(); ++i)
|
||||||
@ -139,12 +139,13 @@ bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
|
|||||||
|
|
||||||
void MathNestInset::dump() const
|
void MathNestInset::dump() const
|
||||||
{
|
{
|
||||||
lyxerr << "---------------------------------------------\n";
|
MathWriteInfo os(lyxerr);
|
||||||
write(lyxerr, false);
|
os << "---------------------------------------------\n";
|
||||||
lyxerr << "\n";
|
write(os);
|
||||||
|
os << "\n";
|
||||||
for (idx_type i = 0; i < nargs(); ++i)
|
for (idx_type i = 0; i < nargs(); ++i)
|
||||||
lyxerr << cell(i) << "\n";
|
os << cell(i) << "\n";
|
||||||
lyxerr << "---------------------------------------------\n";
|
os << "---------------------------------------------\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
explicit MathNestInset(idx_type ncells);
|
explicit MathNestInset(idx_type ncells);
|
||||||
|
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
/// draw the object, sets xo_ and yo_ cached values
|
/// draw the object, sets xo_ and yo_ cached values
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
/// appends itself with macro arguments substituted
|
/// appends itself with macro arguments substituted
|
||||||
|
@ -16,7 +16,7 @@ MathInset * MathNotInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathNotInset::write(ostream & os, bool /* fragile */) const
|
void MathNotInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\not ";
|
os << "\\not ";
|
||||||
}
|
}
|
||||||
@ -28,15 +28,13 @@ void MathNotInset::writeNormal(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathNotInset::metrics(MathStyles st) const
|
void MathNotInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size(st);
|
size_ = st;
|
||||||
if (math_font_available(LM_TC_CMSY))
|
if (math_font_available(LM_TC_CMSY))
|
||||||
mathed_char_dim(LM_TC_CMSY, size_, 54,
|
mathed_char_dim(LM_TC_CMSY, size(), 54, ascent_, descent_, width_);
|
||||||
ascent_, descent_, width_);
|
else
|
||||||
else
|
mathed_char_dim(LM_TC_VAR, size(), '/', ascent_, descent_, width_);
|
||||||
mathed_char_dim(LM_TC_VAR, size_, '/',
|
|
||||||
ascent_, descent_, width_);
|
|
||||||
width_ = 0;
|
width_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +45,7 @@ void MathNotInset::draw(Painter & pain, int x, int y) const
|
|||||||
yo(y);
|
yo(y);
|
||||||
|
|
||||||
if (math_font_available(LM_TC_CMSY))
|
if (math_font_available(LM_TC_CMSY))
|
||||||
drawChar(pain, LM_TC_CMSY, size_, x, y, 54);
|
drawChar(pain, LM_TC_CMSY, size(), x, y, 54);
|
||||||
else
|
else
|
||||||
drawChar(pain, LM_TC_VAR, size_, x, y, '/');
|
drawChar(pain, LM_TC_VAR, size(), x, y, '/');
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
};
|
};
|
||||||
|
@ -890,6 +890,17 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
array.push_back(MathAtom(p));
|
array.push_back(MathAtom(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Disabled
|
||||||
|
else if (t.cs() == "mbox") {
|
||||||
|
array.push_back(createMathInset(t.cs()));
|
||||||
|
// slurp in the argument of mbox
|
||||||
|
|
||||||
|
MathBoxInset * p = array.back()->asBoxInset();
|
||||||
|
//lyx::assert(p);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
else if (t.cs().size()) {
|
else if (t.cs().size()) {
|
||||||
latexkeys const * l = in_word_set(t.cs());
|
latexkeys const * l = in_word_set(t.cs());
|
||||||
if (l) {
|
if (l) {
|
||||||
|
@ -38,6 +38,8 @@ enum MathTokenEnum
|
|||||||
///
|
///
|
||||||
LM_TK_SYM = 256,
|
LM_TK_SYM = 256,
|
||||||
///
|
///
|
||||||
|
LM_TK_BOX,
|
||||||
|
///
|
||||||
LM_TK_CHOOSE,
|
LM_TK_CHOOSE,
|
||||||
///
|
///
|
||||||
LM_TK_BINOM,
|
LM_TK_BINOM,
|
||||||
|
@ -30,7 +30,7 @@ MathInset * MathRootInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathRootInset::metrics(MathStyles st) const
|
void MathRootInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
MathNestInset::metrics(st);
|
MathNestInset::metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
@ -60,13 +60,9 @@ void MathRootInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathRootInset::write(std::ostream & os, bool fragile) const
|
void MathRootInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\sqrt[";
|
os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << "]{";
|
|
||||||
cell(1).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
bool idxUp(int & idx, int & pos) const;
|
bool idxUp(int & idx, int & pos) const;
|
||||||
///
|
///
|
||||||
|
@ -180,13 +180,14 @@ int MathScriptInset::ndes(MathInset const * nuc) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathScriptInset::metrics(MathStyles st) const
|
void MathScriptInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
metrics(0, st);
|
metrics(0, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathScriptInset::metrics(MathInset const * nuc, MathStyles st) const
|
void MathScriptInset::metrics(MathInset const * nuc,
|
||||||
|
MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
MathNestInset::metrics(st);
|
MathNestInset::metrics(st);
|
||||||
if (nuc)
|
if (nuc)
|
||||||
@ -221,18 +222,17 @@ void MathScriptInset::draw(MathInset const * nuc, Painter & pain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathScriptInset::write(std::ostream & os, bool fragile) const
|
void MathScriptInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
//lyxerr << "unexpected call to MathScriptInset::write()\n";
|
//lyxerr << "unexpected call to MathScriptInset::write()\n";
|
||||||
write(0, os, fragile);
|
write(0, os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathScriptInset::write(MathInset const * nuc, std::ostream & os,
|
void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
|
||||||
bool fragile) const
|
|
||||||
{
|
{
|
||||||
if (nuc) {
|
if (nuc) {
|
||||||
nuc->write(os, fragile);
|
nuc->write(os);
|
||||||
if (nuc->takesLimits()) {
|
if (nuc->takesLimits()) {
|
||||||
if (limits_ == -1)
|
if (limits_ == -1)
|
||||||
os << "\\nolimits ";
|
os << "\\nolimits ";
|
||||||
@ -243,17 +243,11 @@ void MathScriptInset::write(MathInset const * nuc, std::ostream & os,
|
|||||||
else
|
else
|
||||||
os << "{}";
|
os << "{}";
|
||||||
|
|
||||||
if (hasDown() && down().data_.size()) {
|
if (hasDown() && down().data_.size())
|
||||||
os << "_{";
|
os << "_{" << down().data_ << '}';
|
||||||
down().data_.write(os, fragile);
|
|
||||||
os << "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasUp() && up().data_.size()) {
|
if (hasUp() && up().data_.size())
|
||||||
os << "^{";
|
os << "^{" << up().data_ << '}';
|
||||||
up().data_.write(os, fragile);
|
|
||||||
os << "}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,16 +21,16 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void write(MathInset const * nucleus, std::ostream &, bool fragile) const;
|
void write(MathInset const *, MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void metrics(MathInset const * nucleus, MathStyles st) const;
|
void metrics(MathInset const * nucleus, MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(MathInset const * nucleus, Painter &, int x, int y) const;
|
void draw(MathInset const * nucleus, Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -26,20 +26,20 @@ void MathSizeInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSizeInset::metrics(MathStyles /* st */) const
|
void MathSizeInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(MathStyles(key_->id));
|
size_ = st;
|
||||||
|
size_.size = MathStyles(key_->id);
|
||||||
|
xcell(0).metrics(size_);
|
||||||
ascent_ = xcell(0).ascent_;
|
ascent_ = xcell(0).ascent_;
|
||||||
descent_ = xcell(0).descent_;
|
descent_ = xcell(0).descent_;
|
||||||
width_ = xcell(0).width_;
|
width_ = xcell(0).width_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSizeInset::write(std::ostream & os, bool fragile) const
|
void MathSizeInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "{\\" << key_->name << " ";
|
os << "{\\" << key_->name << ' ' << cell(0) << '}';
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << "}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void MathSpaceInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSpaceInset::write(std::ostream & os, bool /* fragile */) const
|
void MathSpaceInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
if (space_ >= 0 && space_ < 6)
|
if (space_ >= 0 && space_ < 6)
|
||||||
os << '\\' << latex_mathspace[space_] << ' ';
|
os << '\\' << latex_mathspace[space_] << ' ';
|
||||||
@ -53,7 +53,7 @@ void MathSpaceInset::writeNormal(std::ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSpaceInset::metrics(MathStyles st) const
|
void MathSpaceInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
width_ = space_ ? space_ * 2 : 2;
|
width_ = space_ ? space_ * 2 : 2;
|
||||||
|
@ -19,11 +19,11 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
MathSpaceInset const * asSpaceInset() const { return this; }
|
MathSpaceInset const * asSpaceInset() const { return this; }
|
||||||
///
|
///
|
||||||
|
@ -36,7 +36,7 @@ int MathSpecialCharInset::width() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSpecialCharInset::metrics(MathStyles st) const
|
void MathSpecialCharInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
}
|
}
|
||||||
@ -46,11 +46,11 @@ void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
drawChar(pain, LM_TC_CONST, size_, x, y, char_);
|
drawChar(pain, LM_TC_CONST, size(), x, y, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSpecialCharInset::write(std::ostream & os, bool) const
|
void MathSpecialCharInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\" << char_;
|
os << "\\" << char_;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -19,13 +19,13 @@ MathInset * MathSplitInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSplitInset::write(std::ostream & os, bool fragile) const
|
void MathSplitInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
if (fragile)
|
if (os.fragile)
|
||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << "\\begin{split}";
|
os << "\\begin{split}";
|
||||||
MathGridInset::write(os, fragile);
|
MathGridInset::write(os);
|
||||||
if (fragile)
|
if (os.fragile)
|
||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << "\\end{split}\n";
|
os << "\\end{split}\n";
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
int defaultColSpace(int) { return 0; }
|
int defaultColSpace(int) { return 0; }
|
||||||
///
|
///
|
||||||
|
@ -19,7 +19,7 @@ MathInset * MathSqrtInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSqrtInset::metrics(MathStyles st) const
|
void MathSqrtInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(st);
|
xcell(0).metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
@ -46,11 +46,9 @@ void MathSqrtInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSqrtInset::write(std::ostream & os, bool fragile) const
|
void MathSqrtInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\sqrt{";
|
os << "\\sqrt{" << cell(0) << '}';
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ public:
|
|||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,9 +17,10 @@ MathInset * MathStackrelInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathStackrelInset::metrics(MathStyles st) const
|
void MathStackrelInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = smallerStyleFrac(st);
|
size_ = st;
|
||||||
|
size_.size = smallerStyleFrac(size_.size);
|
||||||
xcell(0).metrics(size_);
|
xcell(0).metrics(size_);
|
||||||
xcell(1).metrics(st);
|
xcell(1).metrics(st);
|
||||||
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
||||||
@ -38,13 +39,9 @@ void MathStackrelInset::draw(Painter & pain, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathStackrelInset::write(std::ostream & os, bool fragile) const
|
void MathStackrelInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << "\\stackrel{";
|
os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
|
||||||
cell(0).write(os, fragile);
|
|
||||||
os << "}{";
|
|
||||||
cell(1).write(os, fragile);
|
|
||||||
os << '}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ MathInset * MathSymbolInset::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSymbolInset::write(ostream & os, bool /* fragile */) const
|
void MathSymbolInset::write(MathWriteInfo & os) const
|
||||||
{
|
{
|
||||||
os << '\\' << sym_->name << ' ';
|
os << '\\' << sym_->name << ' ';
|
||||||
}
|
}
|
||||||
@ -58,25 +58,25 @@ MathTextCodes MathSymbolInset::code2() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSymbolInset::metrics(MathStyles st) const
|
void MathSymbolInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
MathTextCodes Code = code();
|
MathTextCodes Code = code();
|
||||||
if (sym_->latex_font_id > 0 && math_font_available(Code)) {
|
if (sym_->latex_font_id > 0 && math_font_available(Code)) {
|
||||||
mathed_char_dim(Code, size_, sym_->latex_font_id,
|
mathed_char_dim(Code, size(), sym_->latex_font_id,
|
||||||
ascent_, descent_, width_);
|
ascent_, descent_, width_);
|
||||||
if (Code == LM_TC_CMEX) {
|
if (Code == LM_TC_CMEX) {
|
||||||
h_ = 4*descent_/5;
|
h_ = 4*descent_/5;
|
||||||
ascent_ += h_;
|
ascent_ += h_;
|
||||||
descent_ -= h_;
|
descent_ -= h_;
|
||||||
}
|
}
|
||||||
} else if (sym_->id > 0 && sym_->id < 255 &&
|
return;
|
||||||
math_font_available(LM_TC_SYMB)) {
|
|
||||||
mathed_char_dim(code2(), size_, sym_->id,
|
|
||||||
ascent_, descent_, width_);
|
|
||||||
} else {
|
|
||||||
mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
|
||||||
|
mathed_char_dim(code2(), size(), sym_->id, ascent_, descent_, width_);
|
||||||
|
else
|
||||||
|
mathed_string_dim(LM_TC_TEX, size(), sym_->name, ascent_, descent_, width_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,12 +86,11 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const
|
|||||||
yo(y);
|
yo(y);
|
||||||
MathTextCodes Code = code();
|
MathTextCodes Code = code();
|
||||||
if (sym_->latex_font_id > 0 && math_font_available(Code))
|
if (sym_->latex_font_id > 0 && math_font_available(Code))
|
||||||
drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
|
drawChar(pain, Code, size(), x, y - h_, sym_->latex_font_id);
|
||||||
else if (sym_->id > 0 && sym_->id < 255 &&
|
else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
|
||||||
math_font_available(LM_TC_SYMB))
|
drawChar(pain, code2(), size(), x, y, sym_->id);
|
||||||
drawChar(pain, code2(), size_, x, y, sym_->id);
|
|
||||||
else
|
else
|
||||||
drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
|
drawStr(pain, LM_TC_TEX, size(), x, y, sym_->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ bool MathSymbolInset::isRelOp() const
|
|||||||
|
|
||||||
bool MathSymbolInset::isScriptable() const
|
bool MathSymbolInset::isScriptable() const
|
||||||
{
|
{
|
||||||
return size_ == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
|
return size() == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@ public:
|
|||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
void write(std::ostream &, bool fragile) const;
|
void write(MathWriteInfo & os) const;
|
||||||
///
|
///
|
||||||
void writeNormal(std::ostream &) const;
|
void writeNormal(std::ostream &) const;
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -18,15 +18,15 @@ MathXArray::MathXArray()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void MathXArray::metrics(MathStyles st) const
|
void MathXArray::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
style_ = st;
|
style_ = st.size;
|
||||||
mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
|
mathed_char_dim(LM_TC_VAR, style_, 'I', ascent_, descent_, width_);
|
||||||
|
|
||||||
if (data_.empty())
|
if (data_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_);
|
math_font_max_dim(LM_TC_TEXTRM, style_, ascent_, descent_);
|
||||||
width_ = 0;
|
width_ = 0;
|
||||||
|
|
||||||
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
|
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
///
|
///
|
||||||
MathXArray();
|
MathXArray();
|
||||||
///
|
///
|
||||||
void metrics(MathStyles st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
void draw(Painter & pain, int x, int y) const;
|
void draw(Painter & pain, int x, int y) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user