+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>
* formula.C:
* array.C: add missing/broken writeNormal()
* math_lefteqn.[Ch]: some visual support for \lefteqn
-
+
2001-10-10 André Pönitz <poenitz@gmx.net>
math_atom.h \
math_binominset.C \
math_binominset.h \
+ math_boxinset.C \
+ math_boxinset.h \
math_charinset.C \
math_charinset.h \
math_cursor.C \
}
-void MathArray::write(ostream & os, bool fragile) const
+void MathArray::write(MathWriteInfo & wi) const
{
for (const_iterator it = begin(); it != end(); ++it) {
MathInset * p = it->nucleus();
} else
*/
if (MathScriptInset const * q = asScript(it)) {
- q->write(p, os, fragile);
+ q->write(p, wi);
++it;
} else {
- p->write(os, fragile);
+ p->write(wi);
}
}
}
class MathScriptInset;
class MathMacro;
+class MathWriteInfo;
+class MathMetricsInfo;
class LaTeXFeatures;
#ifdef __GNUG__
///
MathAtom const & at(size_type pos) const;
///
- void write(std::ostream &, bool) const;
+ void write(MathWriteInfo & os) const;
///
void writeNormal(std::ostream &) 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;
}
-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;
}
}
-void InsetFormula::draw(BufferView * bv, LyXFont const &,
+void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const
{
int x = int(xx) - 1;
MathInset::workwidth = bv->workWidth();
Painter & pain = bv->painter();
- metrics();
+ metrics(bv, &font);
int w = par_->width();
int h = par_->height();
int a = par_->ascent();
}
-void InsetFormula::metrics() const
-{
- par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
-}
-
-
vector<string> const InsetFormula::getLabelList() const
{
return mat()->getLabelList();
}
-void InsetFormula::handleExtern(const string & arg, BufferView *)
+void InsetFormula::handleExtern(const string & arg, BufferView * bv)
{
// where are we?
MathArray & ar = mathcursor->cursor().cell();
mathcursor->end();
// re-compute inset dimension
- metrics();
+ metrics(bv);
}
}
-int InsetFormula::width(BufferView *, LyXFont const &) const
+int InsetFormula::width(BufferView * bv, LyXFont const & font) const
{
- metrics();
+ metrics(bv, &font);
return par_->width();
}
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
- ///
- void metrics() const;
///
void write(Buffer const *, std::ostream &) const;
InsetFormulaBase::InsetFormulaBase()
+ : view_(0), font_(0)
{
// This is needed as long the math parser is not re-entrant
MathMacroTable::builtinMacros();
{}
+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
{
return _("Math editor mode");
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
mathcursor = new MathCursor(this, x == 0);
- metrics();
+ metrics(bv);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
bv->updateInset(this, false);
void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
{
- metrics();
+ metrics(bv);
bv->updateInset(this, dirty);
}
// sel = "";
//else
- string sel = bv->getLyXText()->selectionAsString(bv->buffer(),
- false);
+ string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
InsetFormulaBase * f;
if (sel.empty()) {
///
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);
private:
/// unimplemented
void operator=(const InsetFormulaBase &);
+ ///
+ mutable BufferView * view_;
+ ///
+ mutable LyXFont const * font_;
};
// We don't really mess want around with mathed stuff outside mathed.
{
string name = mathed_parse_macro(s);
setInsetName(name);
- metrics();
+#ifdef WITH_WARNINGS
+#warning "metrics disabled"
+#endif
+ //metrics();
}
}
-void InsetFormulaMacro::write(Buffer const *, ostream & os) const
+void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
{
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
{
- par()->write(os, fragile);
+ MathWriteInfo wi(buf, os, fragile);
+ par()->write(wi);
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;
}
{
string name = mathed_parse_macro(lex);
setInsetName(name);
+ lyxerr << "metrics disabled";
metrics();
}
}
-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();
}
}
-void InsetFormulaMacro::metrics() const
-{
- par()->metrics(LM_ST_TEXT);
-}
-
-
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool /*cleared*/) const
{
///
MathInsetTypes getType() const;
///
- void metrics() const;
- ///
MathAtom const & par() const;
///
MathAtom & par();
}
-void MathArrayInset::write(std::ostream & os, bool fragile) const
+void MathArrayInset::write(MathWriteInfo & os) const
{
- if (fragile)
+ if (os.fragile)
os << "\\protect";
os << "\\begin{array}";
os << colinfo_[col].align_;
os << "}\n";
- MathGridInset::write(os, fragile);
+ MathGridInset::write(os);
- if (fragile)
+ if (os.fragile)
os << "\\protect";
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);
}
///
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; }
};
}
-void MathBinomInset::metrics(MathStyles st) const
+void MathBinomInset::metrics(MathMetricsInfo const & st) const
{
- size_ = smallerStyleFrac(st);
- xcell(0).metrics(size_);
- xcell(1).metrics(size_);
+ MathMetricsInfo m = st;
+ m.size = smallerStyleFrac(m.size);
+ xcell(0).metrics(m);
+ xcell(1).metrics(m);
ascent_ = xcell(0).height() + 4 + 5;
descent_ = xcell(1).height() + 4 - 5;
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
}
-void MathBinomInset::write(std::ostream & os, bool fragile) const
+void MathBinomInset::write(MathWriteInfo & os) const
{
- os << '{';
- cell(0).write(os, fragile);
- os << " \\choose ";
- cell(1).write(os, fragile);
- os << '}';
+ os << '{' << cell(0) << " \\choose " << cell(1) << '}';
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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;
private:
--- /dev/null
+#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);
+}
--- /dev/null
+// -*- 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
}
-void MathCharInset::metrics(MathStyles st) const
+void MathCharInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
}
xo(x);
yo(y);
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
- drawChar(pain, code_, size_, x, y, char_);
+ drawChar(pain, code_, size_.size, x, y, char_);
}
}
-void MathCharInset::write(std::ostream & os, bool) const
+void MathCharInset::write(MathWriteInfo & os) const
{
- writeHeader(os);
- writeRaw(os);
- writeTrailer(os);
+ writeHeader(os.os);
+ writeRaw(os.os);
+ writeTrailer(os.os);
}
///
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 write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) const;
///
void writeHeader(std::ostream &) const;
///
right(); // do not push for e.g. MathSymbolInset
selPaste();
}
- p->metrics(p->size());
+#ifdef WITH_WARNINGS
+#warning "redraw disabled"
+#endif
+ //p->metrics(p->size());
}
lyxerr << "this should not really happen - 2: "
<< pos() << " " << size() << " in idx: " << it->idx()
<< " in atom: '";
- it->par()->write(lyxerr, false);
+ MathWriteInfo wi(0, lyxerr, false);
+ it->par()->write(wi);
lyxerr << "\n";
dump("error 4");
}
}
-void MathDecorationInset::metrics(MathStyles st) const
+void MathDecorationInset::metrics(MathMetricsInfo const & st) const
{
xcell(0).metrics(st);
size_ = st;
}
-void MathDecorationInset::write(ostream & os, bool fragile) const
+void MathDecorationInset::write(MathWriteInfo & os) const
{
- if (fragile && protect())
+ if (os.fragile && protect())
os << "\\protect";
- os << '\\' << name_ << '{';
- cell(0).write(os, fragile);
- os << '}';
+ os << '\\' << name_ << '{' << cell(0) << '}';
}
///
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 MathDelimInset::write(std::ostream & os, bool fragile) const
+void MathDelimInset::write(MathWriteInfo & os) const
{
- os << "\\left" << latexName(left_);
- cell(0).write(os, fragile);
- os << "\\right" << latexName(right_);
+ os << "\\left" << latexName(left_) << cell(0)
+ << "\\right" << latexName(right_);
}
}
-void MathDelimInset::metrics(MathStyles st) const
+void MathDelimInset::metrics(MathMetricsInfo const & st) const
{
xcell(0).metrics(st);
size_ = st;
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 a0 = std::max(xcell(0).ascent(), a) - h0;
int d0 = std::max(xcell(0).descent(), d) + h0;
///
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:
///
int dw() 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_);
switch (name_[0]) {
case 'l': dh_ = 0; break;
}
-void MathDotsInset::write(ostream & os, bool /* fragile */) const
+void MathDotsInset::write(MathWriteInfo & os) const
{
os << '\\' << name_ << ' ';
}
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
protected:
/// cache for the thing's heigth
mutable int dh_;
#include "math_parser.h"
#include "math_binominset.h"
+//#include "math_boxinset.h"
#include "math_decorationinset.h"
#include "math_dotsinset.h"
#include "math_funcinset.h"
return MathAtom(new MathSpaceInset(l->id));
case LM_TK_DOTS:
return MathAtom(new MathDotsInset(l->name));
+ //case LM_TK_BOX:
+ // return MathAtom(new MathBoxInset(l->name));
}
return MathAtom(new MathFuncInset(l->name));
}
}
-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(1).metrics(size_);
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
}
-void MathFracInset::write(std::ostream & os, bool fragile) const
+void MathFracInset::write(MathWriteInfo & os) const
{
- if (atop_) {
- os << "{";
- cell(0).write(os, fragile);
- os << "\\atop ";
- cell(1).write(os, fragile);
- os << '}';
- } else {
- os << "\\frac{";
- cell(0).write(os, fragile);
- os << "}{";
- cell(1).write(os, fragile);
- os << '}';
- }
+ if (atop_)
+ os << '{' << cell(0) << "\\atop " << cell(1) << '}';
+ else
+ os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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;
public:
}
-void MathFuncInset::write(std::ostream & os, bool /* fragile */) const
+void MathFuncInset::write(MathWriteInfo & os) const
{
os << "\\" << name_ << ' ';
}
}
-void MathFuncInset::metrics(MathStyles st) const
+void MathFuncInset::metrics(MathMetricsInfo const & st) const
{
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_);
}
{
xo(x);
yo(y);
- drawStr(pain, LM_TC_TEX, size_, x, y, name_);
+ drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
}
///
MathInset * clone() const;
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) 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;
///
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 << ' ';
}
}
-void MathFuncLimInset::metrics(MathStyles st) const
+void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
{
- size(st);
- mathed_string_dim(LM_TC_TEXTRM, size(), sym_->name, ascent_, descent_, width_);
+ size_ = st;
+ mathed_string_dim(LM_TC_TEXTRM, size_.size, sym_->name,
+ ascent_, descent_, width_);
}
{
xo(x);
yo(y);
- drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
+ drawStr(pain, LM_TC_TEXTRM, size_.size, x, y, sym_->name);
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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 MathGridInset::metrics(MathStyles st) const
+void MathGridInset::metrics(MathMetricsInfo const & st) const
{
// let the cells adjust themselves
MathNestInset::metrics(st);
}
-void MathGridInset::write(std::ostream & os, bool fragile) const
+void MathGridInset::write(MathWriteInfo & os) const
{
for (row_type row = 0; row < nrows(); ++row) {
- for (col_type col = 0; col < ncols(); ++col) {
- cell(index(row, col)).write(os, fragile);
- os << eocString(col);
- }
+ for (col_type col = 0; col < ncols(); ++col)
+ os << cell(index(row, col)) << eocString(col);
os << eolString(row);
}
}
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
///
{"mathsf", LM_TK_FONT, LM_TC_SF},
{"mathtt", LM_TK_FONT, LM_TC_TT},
{"max", LM_TK_FUNCLIM, 0},
+ //{"mbox", LM_TK_BOX, 0},
{"min", LM_TK_FUNCLIM, 0},
{"newcommand", LM_TK_NEWCOMMAND, 0 },
{"nolimits", LM_TK_LIMIT, static_cast<unsigned>(-1)},
return LM_TK_SYM;
}
+
MathSymbolTypes symbolType(const string & type)
{
if (type == "mathrel")
MathInset::MathInset()
- : size_(LM_ST_DISPLAY), xo_(0), yo_(0)
+ : xo_(0), yo_(0)
{}
MathStyles MathInset::size() const
{
- return size_;
-}
-
-
-void MathInset::size(MathStyles s) const
-{
- size_ = s;
+ return size_.size;
}
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
{
- inset.write(os, false);
+ MathWriteInfo wi(0, os, false);
+ inset.write(wi);
return os;
}
void MathInset::writeNormal(std::ostream & os) const
{
os << "[unknown ";
- write(os, false);
+ MathWriteInfo wi(0, os, false);
+ write(wi);
os << "] ";
}
void MathInset::dump() const
{
lyxerr << "---------------------------------------------\n";
- write(lyxerr, false);
+ MathWriteInfo wi(0, lyxerr, false);
+ write(wi);
lyxerr << "\n---------------------------------------------\n";
}
}
-void MathInset::metrics(MathStyles st) const
+void MathInset::metrics(MathMetricsInfo const & st) const
{
lyxerr << "MathInset::metrics() called directly!\n";
size_ = st;
}
-void MathInset::write(std::ostream &, bool) const
+void MathInset::write(MathWriteInfo &) const
{
lyxerr << "MathInset::write() called directly!\n";
}
*/
-class LaTeXFeatures;
class MathArrayInset;
+class MathBoxInset;
class MathCharInset;
class MathGridInset;
class MathNestInset;
-class MathScriptInset;
class MathMatrixInset;
+class MathScriptInset;
class MathSpaceInset;
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 {
public:
/// short of anything else reasonable
/// draw the object, sets xo_ and yo_ cached values
virtual void draw(Painter &, int x, int y) const;
/// write LaTeX and Lyx code
- virtual void write(std::ostream &, bool fragile) const;
+ virtual void write(MathWriteInfo & os) const;
/// write normalized content
virtual void writeNormal(std::ostream &) const;
/// reproduce itself
///substitutes macro arguments if necessary
virtual void substitute(MathMacro const & macro);
/// 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 MathGridInset * asGridInset() { return 0; }
/// identifies ArrayInsets
virtual MathArrayInset * asArrayInset() { return 0; }
+ /// identifies BoxInsets
+ virtual MathBoxInset * asBoxInset() { return 0; }
/// identifies macro templates
virtual MathMacroTemplate * asMacroTemplate() { return 0; }
static int workwidth;
protected:
- /// _sets_ style
- void size(MathStyles s) const;
/// the used font size
- mutable MathStyles size_;
+ mutable MathMetricsInfo size_;
private:
/// the following are used for positioning the cursor with the mouse
{}
-void MathKernInset::write(std::ostream & os, bool) const
+void MathKernInset::write(MathWriteInfo & os) const
{
os << "\\kern" << wid_.asLatexString() << " ";
}
}
-void MathKernInset::metrics(MathStyles) const
+void MathKernInset::metrics(MathMetricsInfo const &) const
{
ascent_ = 0;
descent_ = 0;
#ifdef WITH_WARNINGS
#warning fix this once the interface to LyXLength has improved
#endif
+ // this uses the numerical valu in pixels, even if the unit is cm or ex!
width_ = static_cast<int>(wid_.value());
+ //cerr << "handling kern of width " << wid_.value() << "\n";
}
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
private:
/// width in em
LyXLength wid_;
}
-void MathLefteqnInset::write(std::ostream & os, bool fragile) const
+void MathLefteqnInset::write(MathWriteInfo & os) const
{
- os << "\\lefteqn{";
- cell(0).write(os, fragile);
- os << "}";
+ os << "\\lefteqn{" << cell(0) << "}";
}
void MathLefteqnInset::writeNormal(std::ostream & os) const
{
os << "[lefteqn ";
- cell(0).write(os, false);
+ MathWriteInfo wi(os);
+ cell(0).write(wi);
os << "] ";
}
-void MathLefteqnInset::metrics(MathStyles st) const
+void MathLefteqnInset::metrics(MathMetricsInfo const & st) const
{
MathNestInset::metrics(st);
size_ = st;
#pragma interface
#endif
-/// The \kern primitive
+/// Support for LaTeX's \\lefteqn command
class MathLefteqnInset : public MathNestInset {
public:
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
};
#endif
}
-void MathMacro::metrics(MathStyles st) const
+void MathMacro::metrics(MathMetricsInfo const & st) const
{
if (defining()) {
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;
}
ascent_ = expanded_.ascent() + 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 ldes;
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) {
MathXArray const & c = xcell(i);
xo(x);
yo(y);
- metrics(size());
+ metrics(size_);
if (defining()) {
- drawStr(pain, LM_TC_TEX, size_, x, y, name());
+ drawStr(pain, LM_TC_TEX, size_.size, x, y, name());
return;
}
if (editing()) {
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);
h += expanded_.descent();
int lasc;
int ldes;
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) {
MathXArray const & c = xcell(i);
c.draw(pain, x + lwid, h);
char str[] = "#1:";
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;
}
return;
MathMacroTable::dump();
lyxerr << "\n macro: '" << this << "'\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();
- for (idx_type i = 0; i < nargs(); ++i) {
- os << '{';
- cell(i).write(os, fragile);
- os << '}';
- }
+ for (idx_type i = 0; i < nargs(); ++i)
+ os << '{' << cell(i) << '}';
if (nargs() == 0)
os << ' ';
}
///
void draw(Painter &, int x, int y) const;
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) const;
///
void writeNormal(std::ostream &) const;
///
}
-void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::write(MathWriteInfo & os) const
{
os << '#' << number_;
}
-void MathMacroArgument::metrics(MathStyles st) const
+void MathMacroArgument::metrics(MathMetricsInfo const & st) const
{
if (expanded_) {
xcell(0).metrics(st);
ascent_ = xcell(0).ascent();
descent_ = xcell(0).descent();
} else
- mathed_string_dim(LM_TC_TEX, size(), str_, ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
}
if (expanded_)
xcell(0).draw(pain, x, y);
else
- drawStr(pain, LM_TC_TEX, size(), x, y, str_);
+ drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
}
///
MathInset * clone() const;
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) 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 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)
- os << "[" << numargs_ << "]";
-
- os << "{";
- cell(0).write(os, fragile);
- os << "}\n";
+ os << '[' << numargs_ << ']';
+ os << '{' << cell(0) << "}\n";
}
-void MathMacroTemplate::metrics(MathStyles st) const
+void MathMacroTemplate::metrics(MathMetricsInfo const & st) const
{
xcell(0).metrics(st);
size_ = st;
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) const;
/// Number of arguments
int numargs() const;
///
///
void draw(Painter &, int x, int y) const;
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
/// identifies macro templates
MathMacroTemplate * asMacroTemplate() { return this; }
private:
}
-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
MathGridInset::metrics(size_);
}
-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();
for (row_type row = 0; row < nrows(); ++row) {
- for (col_type col = 0; col < ncols(); ++col) {
- cell(index(row, col)).write(os, fragile);
- os << eocString(col);
- }
+ for (col_type col = 0; col < ncols(); ++col)
+ os << cell(index(row, col)) << eocString(col);
if (n) {
if (!label_[row].empty())
os << "\\label{" << label_[row] << "}";
os << eolString(row);
}
- footer_write(os);
+ footer_write(os.os);
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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 MathNestInset::metrics(MathStyles st) const
+void MathNestInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
for (idx_type i = 0; i < nargs(); ++i)
void MathNestInset::dump() const
{
- lyxerr << "---------------------------------------------\n";
- write(lyxerr, false);
- lyxerr << "\n";
+ MathWriteInfo os(lyxerr);
+ os << "---------------------------------------------\n";
+ write(os);
+ os << "\n";
for (idx_type i = 0; i < nargs(); ++i)
- lyxerr << cell(i) << "\n";
- lyxerr << "---------------------------------------------\n";
+ os << cell(i) << "\n";
+ os << "---------------------------------------------\n";
}
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
void draw(Painter &, int x, int y) const;
/// appends itself with macro arguments substituted
}
-void MathNotInset::write(ostream & os, bool /* fragile */) const
+void MathNotInset::write(MathWriteInfo & os) const
{
os << "\\not ";
}
}
-void MathNotInset::metrics(MathStyles st) const
+void MathNotInset::metrics(MathMetricsInfo const & st) const
{
- size(st);
+ size_ = st;
if (math_font_available(LM_TC_CMSY))
- mathed_char_dim(LM_TC_CMSY, size_, 54,
- ascent_, descent_, width_);
- else
- mathed_char_dim(LM_TC_VAR, size_, '/',
- ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_CMSY, size(), 54, ascent_, descent_, width_);
+ else
+ mathed_char_dim(LM_TC_VAR, size(), '/', ascent_, descent_, width_);
width_ = 0;
}
yo(y);
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
- drawChar(pain, LM_TC_VAR, size_, x, y, '/');
+ drawChar(pain, LM_TC_VAR, size(), x, y, '/');
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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;
};
}
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()) {
latexkeys const * l = in_word_set(t.cs());
///
LM_TK_SYM = 256,
///
+ LM_TK_BOX,
+ ///
LM_TK_CHOOSE,
///
LM_TK_BINOM,
}
-void MathRootInset::metrics(MathStyles st) const
+void MathRootInset::metrics(MathMetricsInfo const & st) const
{
MathNestInset::metrics(st);
size_ = st;
}
-void MathRootInset::write(std::ostream & os, bool fragile) const
+void MathRootInset::write(MathWriteInfo & os) const
{
- os << "\\sqrt[";
- cell(0).write(os, fragile);
- os << "]{";
- cell(1).write(os, fragile);
- os << '}';
+ os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
}
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
///
bool idxUp(int & idx, int & pos) const;
///
}
-void MathScriptInset::metrics(MathStyles st) const
+void MathScriptInset::metrics(MathMetricsInfo const & st) const
{
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);
if (nuc)
}
-void MathScriptInset::write(std::ostream & os, bool fragile) const
+void MathScriptInset::write(MathWriteInfo & os) const
{
//lyxerr << "unexpected call to MathScriptInset::write()\n";
- write(0, os, fragile);
+ write(0, os);
}
-void MathScriptInset::write(MathInset const * nuc, std::ostream & os,
- bool fragile) const
+void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
{
if (nuc) {
- nuc->write(os, fragile);
+ nuc->write(os);
if (nuc->takesLimits()) {
if (limits_ == -1)
os << "\\nolimits ";
else
os << "{}";
- if (hasDown() && down().data_.size()) {
- os << "_{";
- down().data_.write(os, fragile);
- os << "}";
- }
+ if (hasDown() && down().data_.size())
+ os << "_{" << down().data_ << '}';
- if (hasUp() && up().data_.size()) {
- os << "^{";
- up().data_.write(os, fragile);
- os << "}";
- }
+ if (hasUp() && up().data_.size())
+ os << "^{" << up().data_ << '}';
}
///
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 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 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_;
descent_ = xcell(0).descent_;
width_ = xcell(0).width_;
}
-void MathSizeInset::write(std::ostream & os, bool fragile) const
+void MathSizeInset::write(MathWriteInfo & os) const
{
- os << "{\\" << key_->name << " ";
- cell(0).write(os, fragile);
- os << "}";
+ os << "{\\" << key_->name << ' ' << cell(0) << '}';
}
///
MathInset * clone() const;
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) 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 MathSpaceInset::write(std::ostream & os, bool /* fragile */) const
+void MathSpaceInset::write(MathWriteInfo & os) const
{
if (space_ >= 0 && space_ < 6)
os << '\\' << latex_mathspace[space_] << ' ';
}
-void MathSpaceInset::metrics(MathStyles st) const
+void MathSpaceInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
width_ = space_ ? space_ * 2 : 2;
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
///
MathSpaceInset const * asSpaceInset() const { return this; }
///
}
-void MathSpecialCharInset::metrics(MathStyles st) const
+void MathSpecialCharInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
}
{
xo(x);
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_;
}
///
MathInset * clone() const;
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) 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 MathSplitInset::write(std::ostream & os, bool fragile) const
+void MathSplitInset::write(MathWriteInfo & os) const
{
- if (fragile)
+ if (os.fragile)
os << "\\protect";
os << "\\begin{split}";
- MathGridInset::write(os, fragile);
- if (fragile)
+ MathGridInset::write(os);
+ if (os.fragile)
os << "\\protect";
os << "\\end{split}\n";
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) const;
///
int defaultColSpace(int) { return 0; }
///
}
-void MathSqrtInset::metrics(MathStyles st) const
+void MathSqrtInset::metrics(MathMetricsInfo const & st) const
{
xcell(0).metrics(st);
size_ = st;
}
-void MathSqrtInset::write(std::ostream & os, bool fragile) const
+void MathSqrtInset::write(MathWriteInfo & os) const
{
- os << "\\sqrt{";
- cell(0).write(os, fragile);
- os << '}';
+ os << "\\sqrt{" << cell(0) << '}';
}
///
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 metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
};
#endif
}
-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(1).metrics(st);
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
}
-void MathStackrelInset::write(std::ostream & os, bool fragile) const
+void MathStackrelInset::write(MathWriteInfo & os) const
{
- os << "\\stackrel{";
- cell(0).write(os, fragile);
- os << "}{";
- cell(1).write(os, fragile);
- os << '}';
+ os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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 MathSymbolInset::write(ostream & os, bool /* fragile */) const
+void MathSymbolInset::write(MathWriteInfo & os) const
{
os << '\\' << sym_->name << ' ';
}
}
-void MathSymbolInset::metrics(MathStyles st) const
+void MathSymbolInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
MathTextCodes Code = 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_);
if (Code == LM_TC_CMEX) {
h_ = 4*descent_/5;
ascent_ += h_;
descent_ -= h_;
}
- } else 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_);
+ return;
}
+
+ 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_);
}
yo(y);
MathTextCodes Code = code();
if (sym_->latex_font_id > 0 && math_font_available(Code))
- drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
- else if (sym_->id > 0 && sym_->id < 255 &&
- math_font_available(LM_TC_SYMB))
- drawChar(pain, code2(), size_, x, y, sym_->id);
+ drawChar(pain, Code, size(), x, y - h_, sym_->latex_font_id);
+ else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
+ drawChar(pain, code2(), size(), x, y, sym_->id);
else
- drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
+ drawStr(pain, LM_TC_TEX, size(), x, y, sym_->name);
}
bool MathSymbolInset::isScriptable() const
{
- return size_ == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
+ return size() == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
}
///
MathInset * clone() const;
///
- void write(std::ostream &, bool fragile) const;
+ void write(MathWriteInfo & os) 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 MathXArray::metrics(MathStyles st) const
+void MathXArray::metrics(MathMetricsInfo const & st) const
{
- style_ = st;
- mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
+ style_ = st.size;
+ mathed_char_dim(LM_TC_VAR, style_, 'I', ascent_, descent_, width_);
if (data_.empty())
return;
- math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_);
+ math_font_max_dim(LM_TC_TEXTRM, style_, ascent_, descent_);
width_ = 0;
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
///
MathXArray();
///
- void metrics(MathStyles st) const;
+ void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter & pain, int x, int y) const;