mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
- fix nasty bug due to missing InsetFormula copy c'tor
- make all cache variables mutable, remove const_casts git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2426 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
26b1fa7be8
commit
8b7b3a5895
@ -1,3 +1,14 @@
|
||||
|
||||
2001-08-06 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* formulamacro.C: fix nasty bug due to missing copy constructor
|
||||
|
||||
* math_bigopinset.[Ch]: revival for things like \int, \sum
|
||||
|
||||
* math_funcliminset.[Ch]: dedicated new inset for \lim, \max, \min...
|
||||
|
||||
* math_diminset.h: make cahce variables mutable
|
||||
|
||||
2001-08-01 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* math_cursor.C:
|
||||
|
@ -20,6 +20,8 @@ libmathed_la_SOURCES = \
|
||||
formulamacro.h \
|
||||
math_arrayinset.C \
|
||||
math_arrayinset.h \
|
||||
math_bigopinset.C \
|
||||
math_bigopinset.h \
|
||||
math_charinset.C \
|
||||
math_charinset.h \
|
||||
math_cursor.C \
|
||||
@ -37,6 +39,8 @@ libmathed_la_SOURCES = \
|
||||
math_fracinset.h \
|
||||
math_funcinset.C \
|
||||
math_funcinset.h \
|
||||
math_funcliminset.C \
|
||||
math_funcliminset.h \
|
||||
math_gridinset.C \
|
||||
math_gridinset.h \
|
||||
math_hash.C \
|
||||
|
@ -38,8 +38,11 @@ MathArray::MathArray(MathArray const & array, int from, int to)
|
||||
|
||||
void MathArray::deep_copy(int pos1, int pos2)
|
||||
{
|
||||
for (int pos = pos1; pos < pos2; ++pos)
|
||||
bf_[pos] = bf_[pos]->clone();
|
||||
for (int pos = pos1; pos < pos2; ++pos) {
|
||||
MathInset * p = bf_[pos]->clone();
|
||||
//lyxerr << "cloning: '" << bf_[pos] << " to " << p << "'\n";
|
||||
bf_[pos] = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,20 +56,9 @@ bool MathArray::next(int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathArray::prev(int & pos) const
|
||||
int MathArray::last() const
|
||||
{
|
||||
if (pos == 0)
|
||||
return false;
|
||||
|
||||
--pos;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MathArray::last(int & pos) const
|
||||
{
|
||||
pos = bf_.size();
|
||||
return prev(pos);
|
||||
return size() - 1;
|
||||
}
|
||||
|
||||
|
||||
@ -87,15 +79,15 @@ MathArray & MathArray::operator=(MathArray const & array)
|
||||
}
|
||||
|
||||
|
||||
MathInset * MathArray::nextInset(int pos) const
|
||||
MathInset * MathArray::nextInset(int pos)
|
||||
{
|
||||
return (pos == size()) ? 0 : bf_[pos];
|
||||
}
|
||||
|
||||
|
||||
MathInset * MathArray::prevInset(int pos) const
|
||||
MathInset const * MathArray::nextInset(int pos) const
|
||||
{
|
||||
return (pos == 0) ? 0 : bf_[pos - 1];
|
||||
return (pos == size()) ? 0 : bf_[pos];
|
||||
}
|
||||
|
||||
|
||||
@ -220,15 +212,14 @@ void MathArray::erase(int pos1, int pos2)
|
||||
|
||||
MathInset * MathArray::back() const
|
||||
{
|
||||
return prevInset(size());
|
||||
return size() ? bf_.back() : 0;
|
||||
}
|
||||
|
||||
|
||||
void MathArray::dump2(ostream & os) const
|
||||
{
|
||||
for (buffer_type::const_iterator it = bf_.begin(); it != bf_.end(); ++it)
|
||||
os << int(*it) << ' ';
|
||||
os << endl;
|
||||
os << *it << ' ';
|
||||
}
|
||||
|
||||
|
||||
@ -273,8 +264,11 @@ void MathArray::validate(LaTeXFeatures & features) const
|
||||
|
||||
void MathArray::pop_back()
|
||||
{
|
||||
int pos = size();
|
||||
prev(pos);
|
||||
erase(pos, size());
|
||||
if (!size()) {
|
||||
lyxerr << "pop_back from empty array!\n";
|
||||
return;
|
||||
}
|
||||
delete back();
|
||||
bf_.pop_back();
|
||||
}
|
||||
|
||||
|
@ -76,11 +76,9 @@ public:
|
||||
///
|
||||
void erase();
|
||||
///
|
||||
bool prev(int & pos) const;
|
||||
///
|
||||
bool next(int & pos) const;
|
||||
///
|
||||
bool last(int & pos) const;
|
||||
int last() const;
|
||||
|
||||
|
||||
///
|
||||
@ -103,9 +101,9 @@ public:
|
||||
///
|
||||
|
||||
///
|
||||
MathInset * nextInset(int pos) const;
|
||||
MathInset * nextInset(int pos);
|
||||
///
|
||||
MathInset * prevInset(int pos) const;
|
||||
MathInset const * nextInset(int pos) const;
|
||||
///
|
||||
unsigned char getChar(int pos) const;
|
||||
/// read subsequent chars of the same kind.
|
||||
|
@ -55,6 +55,11 @@ InsetFormula::InsetFormula()
|
||||
{}
|
||||
|
||||
|
||||
InsetFormula::InsetFormula(const InsetFormula & f)
|
||||
: InsetFormulaBase(f), par_(static_cast<MathMatrixInset *>(f.par_->clone()))
|
||||
{}
|
||||
|
||||
|
||||
InsetFormula::InsetFormula(MathInsetTypes t)
|
||||
: par_(new MathMatrixInset(t))
|
||||
{}
|
||||
@ -148,8 +153,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
|
||||
|
||||
void InsetFormula::metrics() const
|
||||
{
|
||||
const_cast<MathMatrixInset *>(par_)
|
||||
-> metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
|
||||
par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
|
||||
}
|
||||
|
||||
vector<string> const InsetFormula::getLabelList() const
|
||||
@ -314,7 +318,7 @@ bool InsetFormula::display() const
|
||||
}
|
||||
|
||||
|
||||
MathInset * InsetFormula::par() const
|
||||
MathInset const * InsetFormula::par() const
|
||||
{
|
||||
return par_;
|
||||
}
|
||||
|
@ -32,12 +32,16 @@ public:
|
||||
///
|
||||
InsetFormula();
|
||||
///
|
||||
InsetFormula(InsetFormula const &);
|
||||
///
|
||||
explicit InsetFormula(MathInsetTypes);
|
||||
///
|
||||
explicit InsetFormula(string const &);
|
||||
///
|
||||
~InsetFormula();
|
||||
///
|
||||
void operator=(InsetFormula const &);
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
@ -77,7 +81,7 @@ public:
|
||||
///
|
||||
void handleExtern(string const & arg, BufferView * bv);
|
||||
///
|
||||
MathInset * par() const;
|
||||
MathInset const * par() const;
|
||||
///
|
||||
bool display() const;
|
||||
///
|
||||
|
@ -191,8 +191,6 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
|
||||
|
||||
void InsetFormulaBase::edit(BufferView * bv, bool front)
|
||||
{
|
||||
#warning Please have a look if this is right (Jug)
|
||||
#warning Does not look wrong... although I do not know what it is supposed to do (Andre)
|
||||
edit(bv, front ? 0 : 1, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
///
|
||||
virtual std::vector<string> const getLabelList() const;
|
||||
///
|
||||
virtual MathInset * par() const = 0;
|
||||
virtual MathInset const * par() const = 0;
|
||||
///
|
||||
virtual void metrics() const = 0;
|
||||
protected:
|
||||
|
@ -47,6 +47,12 @@ InsetFormulaMacro::InsetFormulaMacro()
|
||||
{}
|
||||
|
||||
|
||||
InsetFormulaMacro::InsetFormulaMacro(InsetFormulaMacro const & m)
|
||||
: InsetFormulaBase(m),
|
||||
tmacro_(static_cast<MathMacroTemplate *>(m.tmacro_->clone()))
|
||||
{}
|
||||
|
||||
|
||||
InsetFormulaMacro::InsetFormulaMacro(string nm, int na)
|
||||
: tmacro_(new MathMacroTemplate(nm, na))
|
||||
{
|
||||
@ -185,15 +191,15 @@ MathInsetTypes InsetFormulaMacro::getType() const
|
||||
}
|
||||
|
||||
|
||||
MathInset * InsetFormulaMacro::par() const
|
||||
MathInset const * InsetFormulaMacro::par() const
|
||||
{
|
||||
return const_cast<MathMacroTemplate *>(tmacro_);
|
||||
return tmacro_;
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaMacro::metrics() const
|
||||
{
|
||||
par()->metrics(LM_ST_TEXT);
|
||||
tmacro_->metrics(LM_ST_TEXT);
|
||||
}
|
||||
|
||||
|
||||
@ -223,7 +229,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
|
||||
// formula
|
||||
float t = tmacro().width() + 5;
|
||||
x -= t;
|
||||
par()->draw(pain, int(x), baseline);
|
||||
tmacro_->draw(pain, int(x), baseline);
|
||||
x += t;
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,16 @@ class MathMacroTemplate;
|
||||
class InsetFormulaMacro: public InsetFormulaBase {
|
||||
public:
|
||||
///
|
||||
explicit InsetFormulaMacro();
|
||||
InsetFormulaMacro();
|
||||
///
|
||||
InsetFormulaMacro(InsetFormulaMacro const &);
|
||||
///
|
||||
explicit InsetFormulaMacro(string name, int na);
|
||||
///
|
||||
~InsetFormulaMacro();
|
||||
///
|
||||
void operator=(InsetFormulaMacro const &);
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
@ -69,7 +73,7 @@ public:
|
||||
///
|
||||
MathInsetTypes getType() const;
|
||||
///
|
||||
MathInset * par() const;
|
||||
MathInset const * par() const;
|
||||
///
|
||||
void metrics() const;
|
||||
private:
|
||||
|
@ -14,7 +14,7 @@ public:
|
||||
///
|
||||
MathArrayInset(int m, int n);
|
||||
///
|
||||
virtual MathInset * clone() const;
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
|
@ -42,7 +42,13 @@ int MathCharInset::width() const
|
||||
}
|
||||
|
||||
|
||||
void MathCharInset::draw(Painter & pain, int x, int y)
|
||||
void MathCharInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
}
|
||||
|
||||
|
||||
void MathCharInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -19,7 +19,9 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
|
@ -30,12 +30,14 @@
|
||||
#include "formulabase.h"
|
||||
#include "math_cursor.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_bigopinset.h"
|
||||
#include "math_symbolinset.h"
|
||||
#include "math_decorationinset.h"
|
||||
#include "math_deliminset.h"
|
||||
#include "math_dotsinset.h"
|
||||
#include "math_fracinset.h"
|
||||
#include "math_funcinset.h"
|
||||
#include "math_funcliminset.h"
|
||||
#include "math_gridinset.h"
|
||||
#include "math_macro.h"
|
||||
#include "math_macroarg.h"
|
||||
@ -195,7 +197,7 @@ void MathCursor::seldump(char const *) const
|
||||
}
|
||||
|
||||
|
||||
bool MathCursor::isInside(MathInset * p) const
|
||||
bool MathCursor::isInside(MathInset const * p) const
|
||||
{
|
||||
for (unsigned i = 0; i < Cursor_.size(); ++i)
|
||||
if (parInset(i) == p)
|
||||
@ -222,9 +224,9 @@ bool MathCursor::openable(MathInset * p, bool sel, bool useupdown) const
|
||||
}
|
||||
|
||||
|
||||
bool MathCursor::plainLeft()
|
||||
void MathCursor::plainLeft()
|
||||
{
|
||||
return array().prev(cursor().pos_);
|
||||
--cursor().pos_;
|
||||
}
|
||||
|
||||
|
||||
@ -249,8 +251,10 @@ bool MathCursor::left(bool sel)
|
||||
push(p, false);
|
||||
return true;
|
||||
}
|
||||
if (plainLeft())
|
||||
if (cursor().pos_) {
|
||||
plainLeft();
|
||||
return true;
|
||||
}
|
||||
if (cursor().par_->idxLeft(cursor().idx_, cursor().pos_))
|
||||
return true;
|
||||
if (pop())
|
||||
@ -294,14 +298,14 @@ bool MathCursor::right(bool sel)
|
||||
void MathCursor::first()
|
||||
{
|
||||
Cursor_.clear();
|
||||
push(formula_->par(), true);
|
||||
push(outerPar(), true);
|
||||
}
|
||||
|
||||
|
||||
void MathCursor::last()
|
||||
{
|
||||
Cursor_.clear();
|
||||
push(formula_->par(), false);
|
||||
push(outerPar(), false);
|
||||
}
|
||||
|
||||
|
||||
@ -314,7 +318,7 @@ void MathCursor::setPos(int x, int y)
|
||||
lastcode_ = LM_TC_MIN;
|
||||
first();
|
||||
|
||||
cursor().par_ = formula()->par();
|
||||
cursor().par_ = outerPar();
|
||||
|
||||
while (1) {
|
||||
cursor().idx_ = -1;
|
||||
@ -370,7 +374,7 @@ void MathCursor::end()
|
||||
clearLastCode();
|
||||
if (!cursor().par_->idxEnd(cursor().idx_, cursor().pos_)) {
|
||||
pop();
|
||||
array().next(cursor().pos_);
|
||||
++cursor().pos_;
|
||||
}
|
||||
dump("end 2");
|
||||
}
|
||||
@ -403,7 +407,7 @@ void MathCursor::insert(char c, MathTextCodes t)
|
||||
}
|
||||
|
||||
array().insert(cursor().pos_, c, t);
|
||||
array().next(cursor().pos_);
|
||||
++cursor().pos_;
|
||||
}
|
||||
|
||||
|
||||
@ -586,9 +590,9 @@ bool MathCursor::down(bool sel)
|
||||
|
||||
bool MathCursor::toggleLimits()
|
||||
{
|
||||
if (!prevIsInset())
|
||||
return false;
|
||||
MathScriptInset * p = prevScriptInset();
|
||||
if (!p)
|
||||
return false;
|
||||
int old = p->limits();
|
||||
p->limits(old < 0 ? 1 : -1);
|
||||
return old != p->limits();
|
||||
@ -670,9 +674,15 @@ void MathCursor::interpret(string const & s)
|
||||
p = new MathFuncInset(s);
|
||||
} else {
|
||||
switch (l->token) {
|
||||
case LM_TK_SYM:
|
||||
case LM_TK_BIGSYM:
|
||||
p = new MathBigopInset(l);
|
||||
break;
|
||||
|
||||
case LM_TK_FUNCLIM:
|
||||
p = new MathFuncLimInset(l);
|
||||
break;
|
||||
|
||||
case LM_TK_SYM:
|
||||
p = new MathSymbolInset(l);
|
||||
break;
|
||||
|
||||
@ -1049,7 +1059,7 @@ MathInset * MathCursor::prevInset() const
|
||||
{
|
||||
normalize();
|
||||
int c = cursor().pos_;
|
||||
if (!array().prev(c))
|
||||
if (!c)
|
||||
return 0;
|
||||
return array().nextInset(c);
|
||||
}
|
||||
@ -1065,7 +1075,7 @@ MathInset * MathCursor::nextInset() const
|
||||
MathScriptInset * MathCursor::prevScriptInset() const
|
||||
{
|
||||
normalize();
|
||||
MathInset * p = array().prevInset(cursor().pos_);
|
||||
MathInset * p = prevInset();
|
||||
return (p && p->isScriptInset()) ? static_cast<MathScriptInset *>(p) : 0;
|
||||
}
|
||||
|
||||
@ -1073,7 +1083,7 @@ MathScriptInset * MathCursor::prevScriptInset() const
|
||||
MathSpaceInset * MathCursor::prevSpaceInset() const
|
||||
{
|
||||
normalize();
|
||||
MathInset * p = array().prevInset(cursor().pos_);
|
||||
MathInset * p = prevInset();
|
||||
return (p && p->isSpaceInset()) ? static_cast<MathSpaceInset *>(p) : 0;
|
||||
}
|
||||
|
||||
@ -1101,18 +1111,6 @@ MathXArray & MathCursor::xarray() const
|
||||
}
|
||||
|
||||
|
||||
bool MathCursor::nextIsInset() const
|
||||
{
|
||||
return cursor().pos_ < array().size() && MathIsInset(nextCode());
|
||||
}
|
||||
|
||||
|
||||
bool MathCursor::prevIsInset() const
|
||||
{
|
||||
return cursor().pos_ > 0 && MathIsInset(prevCode());
|
||||
}
|
||||
|
||||
|
||||
int MathCursor::xpos() const
|
||||
{
|
||||
normalize();
|
||||
@ -1153,7 +1151,7 @@ void MathCursor::splitCell()
|
||||
|
||||
void MathCursor::breakLine()
|
||||
{
|
||||
MathMatrixInset * p = static_cast<MathMatrixInset *>(formula()->par());
|
||||
MathMatrixInset * p = outerPar();
|
||||
if (p->getType() == LM_OT_SIMPLE || p->getType() == LM_OT_EQUATION) {
|
||||
p->mutate(LM_OT_EQNARRAY);
|
||||
p->addRow(0);
|
||||
@ -1314,3 +1312,10 @@ bool MathCursorPos::idxRight()
|
||||
{
|
||||
return par_->idxRight(idx_, pos_);
|
||||
}
|
||||
|
||||
|
||||
MathMatrixInset * MathCursor::outerPar() const
|
||||
{
|
||||
return
|
||||
static_cast<MathMatrixInset *>(const_cast<MathInset *>(formula_->par()));
|
||||
}
|
||||
|
@ -24,10 +24,11 @@
|
||||
#include "math_defs.h"
|
||||
|
||||
class MathInset;
|
||||
class MathArrayInset;
|
||||
class MathFuncInset;
|
||||
class MathMatrixInset;
|
||||
class MathScriptInset;
|
||||
class MathSpaceInset;
|
||||
class MathArrayInset;
|
||||
class InsetFormulaBase;
|
||||
class MathArray;
|
||||
class MathXArray;
|
||||
@ -97,7 +98,7 @@ public:
|
||||
/// Put the cursor in the last position
|
||||
void last();
|
||||
///
|
||||
bool plainLeft();
|
||||
void plainLeft();
|
||||
///
|
||||
void plainRight();
|
||||
///
|
||||
@ -176,7 +177,7 @@ public:
|
||||
///
|
||||
void pullArg(bool goright);
|
||||
///
|
||||
bool isInside(MathInset *) const;
|
||||
bool isInside(MathInset const *) const;
|
||||
///
|
||||
MathTextCodes nextCode() const;
|
||||
///
|
||||
@ -243,6 +244,8 @@ public:
|
||||
///
|
||||
MathInset * parInset(int i) const;
|
||||
///
|
||||
MathMatrixInset * outerPar() const;
|
||||
///
|
||||
void seldump(char const * str) const;
|
||||
///
|
||||
void dump(char const * str) const;
|
||||
@ -252,10 +255,6 @@ public:
|
||||
///
|
||||
void gotoX(int x);
|
||||
|
||||
///
|
||||
bool nextIsInset() const;
|
||||
///
|
||||
bool prevIsInset() const;
|
||||
///
|
||||
void merge(MathArray const & arr);
|
||||
///
|
||||
|
@ -25,7 +25,7 @@ MathInset * MathDecorationInset::clone() const
|
||||
|
||||
|
||||
|
||||
void MathDecorationInset::metrics(MathStyles st)
|
||||
void MathDecorationInset::metrics(MathStyles st) const
|
||||
{
|
||||
xcell(0).metrics(st);
|
||||
size_ = st;
|
||||
@ -51,7 +51,7 @@ void MathDecorationInset::metrics(MathStyles st)
|
||||
}
|
||||
}
|
||||
|
||||
void MathDecorationInset::draw(Painter & pain, int x, int y)
|
||||
void MathDecorationInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(x);
|
||||
|
@ -21,11 +21,11 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void writeNormal(std::ostream & os) const;
|
||||
private:
|
||||
@ -33,9 +33,9 @@ private:
|
||||
latexkeys const * key_;
|
||||
///
|
||||
bool upper_;
|
||||
/// height of deco
|
||||
int dh_;
|
||||
/// vertical offset of deco
|
||||
int dy_;
|
||||
/// height cache of deco
|
||||
mutable int dh_;
|
||||
/// vertical offset cache of deco
|
||||
mutable int dy_;
|
||||
};
|
||||
#endif
|
||||
|
@ -51,7 +51,7 @@ void MathDelimInset::write(std::ostream & os, bool fragile) const
|
||||
}
|
||||
|
||||
|
||||
void MathDelimInset::draw(Painter & pain, int x, int y)
|
||||
void MathDelimInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
@ -86,7 +86,7 @@ int MathDelimInset::dw() const
|
||||
}
|
||||
|
||||
|
||||
void MathDelimInset::metrics(MathStyles st)
|
||||
void MathDelimInset::metrics(MathStyles st) const
|
||||
{
|
||||
xcell(0).metrics(st);
|
||||
size_ = st;
|
||||
|
@ -18,11 +18,11 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
private:
|
||||
int dw() const;
|
||||
///
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
#include "math_inset.h"
|
||||
|
||||
/// thing that need the dimension cache
|
||||
/// things that need the dimension cache
|
||||
|
||||
class MathDimInset : public MathInset {
|
||||
public:
|
||||
MathDimInset();
|
||||
@ -17,10 +18,10 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
int width_;
|
||||
mutable int width_;
|
||||
///
|
||||
int ascent_;
|
||||
mutable int ascent_;
|
||||
///
|
||||
int descent_;
|
||||
mutable int descent_;
|
||||
};
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@ MathInset * MathDotsInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathDotsInset::draw(Painter & pain, int x, int y)
|
||||
void MathDotsInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, key_->id);
|
||||
if (key_->id == LM_vdots || key_->id == LM_ddots)
|
||||
@ -32,7 +32,7 @@ void MathDotsInset::draw(Painter & pain, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
void MathDotsInset::metrics(MathStyles st)
|
||||
void MathDotsInset::metrics(MathStyles st) const
|
||||
{
|
||||
size(st);
|
||||
mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
|
||||
|
@ -19,16 +19,16 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
protected:
|
||||
///
|
||||
int dh_;
|
||||
/// cache for the thing's heigth
|
||||
mutable int dh_;
|
||||
///
|
||||
latexkeys const * key_;
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ MathInset * MathFracInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathFracInset::metrics(MathStyles st)
|
||||
void MathFracInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = smallerStyleFrac(st);
|
||||
xcell(0).metrics(size_);
|
||||
@ -30,7 +30,7 @@ void MathFracInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathFracInset::draw(Painter & pain, int x, int y)
|
||||
void MathFracInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -16,31 +16,31 @@ public:
|
||||
///
|
||||
explicit MathFracInset(const string & name);
|
||||
///
|
||||
virtual MathInset * clone() const;
|
||||
MathInset * clone() const;
|
||||
///
|
||||
virtual void write(std::ostream &, bool fragile) const;
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
virtual void writeNormal(std::ostream &) const;
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
virtual void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
virtual void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
virtual bool idxUp(int &, int &) const;
|
||||
bool idxUp(int &, int &) const;
|
||||
///
|
||||
virtual bool idxDown(int &, int &) const;
|
||||
bool idxDown(int &, int &) const;
|
||||
///
|
||||
virtual bool idxLeft(int &, int &) const;
|
||||
bool idxLeft(int &, int &) const;
|
||||
///
|
||||
virtual bool idxRight(int &, int &) const;
|
||||
bool idxRight(int &, int &) const;
|
||||
///
|
||||
virtual bool idxFirstUp(int & idx, int & pos) const;
|
||||
bool idxFirstUp(int & idx, int & pos) const;
|
||||
///
|
||||
virtual bool idxFirstDown(int & idx, int & pos) const;
|
||||
bool idxFirstDown(int & idx, int & pos) const;
|
||||
///
|
||||
virtual bool idxLastUp(int & idx, int & pos) const;
|
||||
bool idxLastUp(int & idx, int & pos) const;
|
||||
///
|
||||
virtual bool idxLastDown(int & idx, int & pos) const;
|
||||
bool idxLastDown(int & idx, int & pos) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ void MathFuncInset::writeNormal(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::metrics(MathStyles st)
|
||||
void MathFuncInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
if (name_.empty())
|
||||
@ -48,7 +48,7 @@ void MathFuncInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::draw(Painter & pain, int x, int y)
|
||||
void MathFuncInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -19,9 +19,9 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void MathFuncInset::metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
|
@ -74,7 +74,7 @@ char MathGridInset::valign() const
|
||||
return v_align_;
|
||||
}
|
||||
|
||||
void MathGridInset::metrics(MathStyles st)
|
||||
void MathGridInset::metrics(MathStyles st) const
|
||||
{
|
||||
// let the cells adjust themselves
|
||||
MathNestInset::metrics(st);
|
||||
@ -193,7 +193,7 @@ void MathGridInset::metrics(MathStyles st)
|
||||
*/
|
||||
}
|
||||
|
||||
void MathGridInset::draw(Painter & pain, int x, int y)
|
||||
void MathGridInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -20,15 +20,15 @@ class MathGridInset : public MathNestInset {
|
||||
struct RowInfo {
|
||||
///
|
||||
RowInfo();
|
||||
///
|
||||
int descent_;
|
||||
///
|
||||
int ascent_;
|
||||
///
|
||||
int offset_;
|
||||
///
|
||||
/// cached descent
|
||||
mutable int descent_;
|
||||
/// cached ascent
|
||||
mutable int ascent_;
|
||||
/// cached offset
|
||||
mutable int offset_;
|
||||
/// hline abow this row?
|
||||
bool upperline_;
|
||||
///
|
||||
/// hline below this row?
|
||||
bool lowerline_;
|
||||
};
|
||||
|
||||
@ -40,11 +40,11 @@ class MathGridInset : public MathNestInset {
|
||||
char h_align_;
|
||||
/// cache for drawing
|
||||
int h_offset;
|
||||
///
|
||||
int width_;
|
||||
///
|
||||
int offset_;
|
||||
///
|
||||
/// cached width
|
||||
mutable int width_;
|
||||
/// cached offset
|
||||
mutable int offset_;
|
||||
///
|
||||
bool leftline_;
|
||||
///
|
||||
bool rightline_;
|
||||
@ -54,13 +54,11 @@ public:
|
||||
///
|
||||
MathGridInset(int m, int n, string const & nm);
|
||||
///
|
||||
virtual MathInset * clone() const = 0;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void halign(string const &);
|
||||
///
|
||||
|
@ -55,7 +55,7 @@ MathStyles MathInset::size() const
|
||||
}
|
||||
|
||||
|
||||
void MathInset::size(MathStyles s)
|
||||
void MathInset::size(MathStyles s) const
|
||||
{
|
||||
size_ = s;
|
||||
}
|
||||
@ -80,13 +80,13 @@ int MathInset::yo() const
|
||||
}
|
||||
|
||||
|
||||
void MathInset::xo(int x)
|
||||
void MathInset::xo(int x) const
|
||||
{
|
||||
xo_ = x;
|
||||
}
|
||||
|
||||
|
||||
void MathInset::yo(int y)
|
||||
void MathInset::yo(int y) const
|
||||
{
|
||||
yo_ = y;
|
||||
}
|
||||
@ -307,7 +307,20 @@ void MathInset::code(MathTextCodes t)
|
||||
}
|
||||
|
||||
|
||||
void MathInset::metrics(MathStyles st)
|
||||
void MathInset::metrics(MathStyles st) const
|
||||
{
|
||||
lyxerr[Debug::MATHED] << "MathInset::metrics() called directly!\n";
|
||||
size_ = st;
|
||||
}
|
||||
|
||||
|
||||
void MathInset::draw(Painter &, int, int) const
|
||||
{
|
||||
lyxerr << "MathInset::draw() called directly!\n";
|
||||
}
|
||||
|
||||
|
||||
void MathInset::write(std::ostream &, bool) const
|
||||
{
|
||||
lyxerr << "MathInset::write() called directly!\n";
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ public:
|
||||
virtual ~MathInset() {}
|
||||
|
||||
/// draw the object, sets xo_ and yo_ cached values
|
||||
virtual void draw(Painter &, int x, int baseline) = 0;
|
||||
virtual void draw(Painter &, int x, int y) const;
|
||||
/// write LaTeX and Lyx code
|
||||
virtual void write(std::ostream &, bool fragile) const = 0;
|
||||
virtual void write(std::ostream &, bool fragile) const;
|
||||
/// write normalized content
|
||||
virtual void writeNormal(std::ostream &) const;
|
||||
/// reproduce itself
|
||||
@ -60,17 +60,17 @@ public:
|
||||
/// appends itself with macro arguments substituted
|
||||
virtual void substitute(MathArray & array, MathMacro const & macro) const;
|
||||
/// compute the size of the object, sets ascend_, descend_ and width_
|
||||
virtual void metrics(MathStyles st);
|
||||
virtual void metrics(MathStyles st) const;
|
||||
///
|
||||
virtual int ascent() const = 0;
|
||||
virtual int ascent() const { return 1; }
|
||||
///
|
||||
virtual int descent() const = 0;
|
||||
virtual int descent() const { return 1; }
|
||||
///
|
||||
virtual int width() const = 0;
|
||||
virtual int width() const { return 2; }
|
||||
///
|
||||
virtual int height() const;
|
||||
///
|
||||
string const & name() const;
|
||||
virtual string const & name() const;
|
||||
///
|
||||
virtual void setName(string const & n);
|
||||
///
|
||||
@ -136,9 +136,9 @@ public:
|
||||
///
|
||||
virtual int yo() const;
|
||||
///
|
||||
virtual void xo(int tx);
|
||||
virtual void xo(int tx) const;
|
||||
///
|
||||
virtual void yo(int ty);
|
||||
virtual void yo(int ty) const;
|
||||
///
|
||||
|
||||
///
|
||||
@ -203,19 +203,19 @@ public:
|
||||
protected:
|
||||
/// usually the LaTeX name of the thingy
|
||||
string name_;
|
||||
///
|
||||
void size(MathStyles s);
|
||||
/// _sets_ style
|
||||
void size(MathStyles s) const;
|
||||
/// the used font size
|
||||
MathStyles size_;
|
||||
mutable MathStyles size_;
|
||||
/// the inherited text style
|
||||
MathTextCodes code_;
|
||||
mutable MathTextCodes code_;
|
||||
|
||||
private:
|
||||
/// the following are used for positioning the cursor with the mouse
|
||||
/// cached cursor start position in pixels from the document left
|
||||
int xo_;
|
||||
mutable int xo_;
|
||||
/// cached cursor start position in pixels from the document top
|
||||
int yo_;
|
||||
mutable int yo_;
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream &, MathInset const &);
|
||||
|
@ -49,7 +49,7 @@ MathInset * MathMacro::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathMacro::metrics(MathStyles st)
|
||||
void MathMacro::metrics(MathStyles st) const
|
||||
{
|
||||
if (mathcursor && mathcursor->isInside(this)) {
|
||||
expanded_ = tmplate_->xcell(0);
|
||||
@ -67,7 +67,7 @@ void MathMacro::metrics(MathStyles st)
|
||||
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
|
||||
|
||||
for (int i = 0; i < nargs(); ++i) {
|
||||
MathXArray & c = xcell(i);
|
||||
MathXArray const & c = xcell(i);
|
||||
c.metrics(st);
|
||||
width_ = std::max(width_, c.width() + lwid);
|
||||
descent_ += std::max(c.ascent(), lasc) + 5;
|
||||
@ -85,7 +85,7 @@ void MathMacro::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathMacro::draw(Painter & pain, int x, int y)
|
||||
void MathMacro::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
@ -109,7 +109,7 @@ void MathMacro::draw(Painter & pain, int x, int y)
|
||||
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
|
||||
|
||||
for (int i = 0; i < nargs(); ++i) {
|
||||
MathXArray & c = xcell(i);
|
||||
MathXArray const & c = xcell(i);
|
||||
h += std::max(c.ascent(), lasc) + 5;
|
||||
c.draw(pain, x + lwid, h);
|
||||
char str[] = "#1:";
|
||||
@ -190,5 +190,5 @@ void MathMacro::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
if (name_ == "binom")
|
||||
features.binom = true;
|
||||
MathInset::validate(features);
|
||||
//MathInset::validate(features);
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ public:
|
||||
///
|
||||
MathMacro(MathMacro const &);
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
@ -69,7 +69,7 @@ private:
|
||||
///
|
||||
MathMacroTemplate const * const tmplate_;
|
||||
///
|
||||
MathXArray expanded_;
|
||||
mutable MathXArray expanded_;
|
||||
///
|
||||
void operator=(MathMacro const &);
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ MathInset * MathMacroArgument::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathMacroArgument::draw(Painter & pain, int x, int y)
|
||||
void MathMacroArgument::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
drawStr(pain, LM_TC_TEX, size(), x, y, str_);
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
//void metrics(MathStyles st);
|
||||
//void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
|
@ -49,7 +49,7 @@ void MathMacroTemplate::write(std::ostream & os, bool fragile) const
|
||||
}
|
||||
|
||||
|
||||
void MathMacroTemplate::metrics(MathStyles st)
|
||||
void MathMacroTemplate::metrics(MathStyles st) const
|
||||
{
|
||||
xcell(0).metrics(st);
|
||||
size_ = st;
|
||||
@ -59,7 +59,7 @@ void MathMacroTemplate::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathMacroTemplate::draw(Painter & pain, int x, int y)
|
||||
void MathMacroTemplate::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -30,9 +30,9 @@ public:
|
||||
///
|
||||
void numargs(int);
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
private:
|
||||
///
|
||||
int numargs_;
|
||||
|
@ -93,7 +93,7 @@ MathInset * MathMatrixInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::metrics(MathStyles /* st */)
|
||||
void MathMatrixInset::metrics(MathStyles) const
|
||||
{
|
||||
size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
|
||||
|
||||
@ -116,7 +116,7 @@ void MathMatrixInset::metrics(MathStyles /* st */)
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::draw(Painter & pain, int x, int y)
|
||||
void MathMatrixInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -27,9 +27,9 @@ public:
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
string label(int row) const;
|
||||
///
|
||||
|
@ -45,14 +45,13 @@ MathArray const & MathNestInset::cell(int i) const
|
||||
|
||||
void MathNestInset::substitute(MathArray & array, MathMacro const & m) const
|
||||
{
|
||||
MathNestInset * p = static_cast<MathNestInset *>(clone());
|
||||
array.push_back(clone());
|
||||
for (int i = 0; i < nargs(); ++i)
|
||||
p->cell(i).substitute(m);
|
||||
array.push_back(p);
|
||||
array.back()->cell(i).substitute(m);
|
||||
}
|
||||
|
||||
|
||||
void MathNestInset::metrics(MathStyles st)
|
||||
void MathNestInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
for (int i = 0; i < nargs(); ++i)
|
||||
@ -60,7 +59,7 @@ void MathNestInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathNestInset::draw(Painter & pain, int x, int y)
|
||||
void MathNestInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -18,32 +18,32 @@ public:
|
||||
///
|
||||
explicit MathNestInset(int na = 0, string const & nm = string());
|
||||
|
||||
///
|
||||
void metrics(MathStyles st) const;
|
||||
/// draw the object, sets xo_ and yo_ cached values
|
||||
virtual void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
/// appends itself with macro arguments substituted
|
||||
virtual void substitute(MathArray & array, MathMacro const & macro) const;
|
||||
/// compute the size of the object, sets ascend_, descend_ and width_
|
||||
virtual void metrics(MathStyles st) = 0;
|
||||
void substitute(MathArray & array, MathMacro const & macro) const;
|
||||
|
||||
/// The left key
|
||||
virtual bool idxLeft(int & idx, int & pos) const;
|
||||
bool idxLeft(int & idx, int & pos) const;
|
||||
/// The right key
|
||||
virtual bool idxRight(int & idx, int & pos) const;
|
||||
bool idxRight(int & idx, int & pos) const;
|
||||
|
||||
/// Move one physical cell up
|
||||
virtual bool idxNext(int & idx, int & pos) const;
|
||||
bool idxNext(int & idx, int & pos) const;
|
||||
/// Move one physical cell down
|
||||
virtual bool idxPrev(int & idx, int & pos) const;
|
||||
bool idxPrev(int & idx, int & pos) const;
|
||||
|
||||
/// Target pos when we enter the inset from the left by pressing "Right"
|
||||
virtual bool idxFirst(int & idx, int & pos) const;
|
||||
bool idxFirst(int & idx, int & pos) const;
|
||||
/// Target pos when we enter the inset from the right by pressing "Left"
|
||||
virtual bool idxLast(int & idx, int & pos) const;
|
||||
bool idxLast(int & idx, int & pos) const;
|
||||
|
||||
/// Where should we go if we press home?
|
||||
virtual bool idxHome(int & idx, int & pos) const;
|
||||
bool idxHome(int & idx, int & pos) const;
|
||||
/// Where should we go if we press end?
|
||||
virtual bool idxEnd(int & idx, int & pos) const;
|
||||
bool idxEnd(int & idx, int & pos) const;
|
||||
|
||||
///
|
||||
int nargs() const;
|
||||
|
@ -29,12 +29,13 @@
|
||||
#include "array.h"
|
||||
#include "math_inset.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_symbolinset.h"
|
||||
#include "math_bigopinset.h"
|
||||
#include "math_dotsinset.h"
|
||||
#include "math_decorationinset.h"
|
||||
#include "math_deliminset.h"
|
||||
#include "math_fracinset.h"
|
||||
#include "math_funcinset.h"
|
||||
#include "math_funcliminset.h"
|
||||
#include "math_macro.h"
|
||||
#include "math_macrotable.h"
|
||||
#include "math_macrotemplate.h"
|
||||
@ -44,6 +45,7 @@
|
||||
#include "math_sizeinset.h"
|
||||
#include "math_spaceinset.h"
|
||||
#include "math_sqrtinset.h"
|
||||
#include "math_symbolinset.h"
|
||||
#include "debug.h"
|
||||
#include "mathed/support.h"
|
||||
#include "lyxlex.h"
|
||||
@ -657,8 +659,16 @@ void mathed_parse_into(MathArray & array, unsigned flags)
|
||||
break;
|
||||
|
||||
case LM_TK_BIGSYM:
|
||||
case LM_TK_SYM:
|
||||
limits = 0;
|
||||
array.push_back(new MathBigopInset(yylval.l));
|
||||
break;
|
||||
|
||||
case LM_TK_FUNCLIM:
|
||||
limits = 0;
|
||||
array.push_back(new MathFuncLimInset(yylval.l));
|
||||
break;
|
||||
|
||||
case LM_TK_SYM:
|
||||
limits = 0;
|
||||
array.push_back(new MathSymbolInset(yylval.l));
|
||||
break;
|
||||
|
@ -30,7 +30,7 @@ MathInset * MathRootInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathRootInset::metrics(MathStyles st)
|
||||
void MathRootInset::metrics(MathStyles st) const
|
||||
{
|
||||
MathNestInset::metrics(st);
|
||||
size_ = st;
|
||||
@ -40,7 +40,7 @@ void MathRootInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathRootInset::draw(Painter & pain, int x, int y)
|
||||
void MathRootInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -33,13 +33,13 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
bool idxUp(int & idx, int & pos) const;
|
||||
///
|
||||
|
@ -211,7 +211,7 @@ void MathScriptInset::writeNormal(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathScriptInset::metrics(MathStyles st)
|
||||
void MathScriptInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
MathStyles tt = smallerStyleScript(st);
|
||||
@ -261,7 +261,7 @@ void MathScriptInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathScriptInset::draw(Painter & pain, int x, int y)
|
||||
void MathScriptInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -30,9 +30,9 @@ public:
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
|
||||
///
|
||||
bool idxUp(int & idx, int & pos) const;
|
||||
@ -82,20 +82,18 @@ private:
|
||||
bool up_;
|
||||
///
|
||||
bool down_;
|
||||
///
|
||||
string ssym_;
|
||||
/// 1: \limits, -1: \nolimits, 0: use default
|
||||
int limits_;
|
||||
/// x offset for drawing the superscript
|
||||
int dx0_;
|
||||
/// x offset for drawing the subscript
|
||||
int dx1_;
|
||||
/// x offset for drawing the inner symbol
|
||||
int dxx_;
|
||||
///
|
||||
int dy0_;
|
||||
///
|
||||
int dy1_;
|
||||
/// x offset cache for drawing the superscript
|
||||
mutable int dx0_;
|
||||
/// x offset cache for drawing the subscript
|
||||
mutable int dx1_;
|
||||
/// x offset cache for drawing the inner symbol
|
||||
mutable int dxx_;
|
||||
/// y offset cache for drawing the superscript
|
||||
mutable int dy0_;
|
||||
/// y offset cache for drawing the subscript
|
||||
mutable int dy1_;
|
||||
///
|
||||
MathInset * symbol_;
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ MathInset * MathSizeInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathSizeInset::draw(Painter & pain, int x, int y)
|
||||
void MathSizeInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
@ -43,7 +43,7 @@ void MathSizeInset::draw(Painter & pain, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
void MathSizeInset::metrics(MathStyles /* st */)
|
||||
void MathSizeInset::metrics(MathStyles /* st */) const
|
||||
{
|
||||
xcell(0).metrics(style_);
|
||||
ascent_ = xcell(0).ascent_;
|
||||
|
@ -18,11 +18,11 @@ public:
|
||||
///
|
||||
explicit MathSizeInset(MathStyles st);
|
||||
///
|
||||
virtual MathInset * clone() const;
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
|
@ -19,7 +19,7 @@ MathInset * MathSpaceInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathSpaceInset::draw(Painter & pain, int x, int y)
|
||||
void MathSpaceInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
|
||||
// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
|
||||
@ -51,7 +51,7 @@ void MathSpaceInset::writeNormal(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathSpaceInset::metrics(MathStyles st)
|
||||
void MathSpaceInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
width_ = space_ ? space_ * 2 : 2;
|
||||
|
@ -17,13 +17,13 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
bool isSpaceInset() const { return true; }
|
||||
///
|
||||
|
@ -19,7 +19,7 @@ MathInset * MathSqrtInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
void MathSqrtInset::metrics(MathStyles st)
|
||||
void MathSqrtInset::metrics(MathStyles st) const
|
||||
{
|
||||
xcell(0).metrics(st);
|
||||
size_ = st;
|
||||
@ -29,7 +29,7 @@ void MathSqrtInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathSqrtInset::draw(Painter & pain, int x, int y)
|
||||
void MathSqrtInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -18,12 +18,12 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
};
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ void MathSymbolInset::writeNormal(ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathSymbolInset::metrics(MathStyles st)
|
||||
void MathSymbolInset::metrics(MathStyles st) const
|
||||
{
|
||||
size(st);
|
||||
|
||||
@ -45,7 +45,7 @@ void MathSymbolInset::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathSymbolInset::draw(Painter & pain, int x, int y)
|
||||
void MathSymbolInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
struct latexkeys;
|
||||
|
||||
/// big operators
|
||||
// "normal" symbols that don't take limits and don't grow in displayed
|
||||
// formulae
|
||||
|
||||
class MathSymbolInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
@ -18,18 +20,14 @@ public:
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
///
|
||||
bool isScriptable() const { return true; }
|
||||
void draw(Painter &, int x, int y) const;
|
||||
|
||||
private:
|
||||
///
|
||||
latexkeys const * sym_;
|
||||
///
|
||||
string ssym_;
|
||||
///
|
||||
MathTextCodes code_;
|
||||
/// cache for the symbol's onscreen string representation
|
||||
mutable string ssym_;
|
||||
};
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mathed/support.h"
|
||||
#include "math_defs.h"
|
||||
#include "Painter.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
@ -19,7 +20,7 @@ MathXArray::MathXArray()
|
||||
{}
|
||||
|
||||
|
||||
void MathXArray::metrics(MathStyles st)
|
||||
void MathXArray::metrics(MathStyles st) const
|
||||
{
|
||||
if (data_.empty()) {
|
||||
mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
|
||||
@ -31,12 +32,13 @@ void MathXArray::metrics(MathStyles st)
|
||||
width_ = 0;
|
||||
style_ = st;
|
||||
|
||||
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
|
||||
for (int pos = 0; pos < data_.size(); ++pos) {
|
||||
MathInset * p = data_.nextInset(pos);
|
||||
MathInset const * p = data_.nextInset(pos);
|
||||
p->metrics(st);
|
||||
int asc = p->ascent();
|
||||
int des = p->descent();
|
||||
int wid = p->width();
|
||||
int asc = p->ascent();
|
||||
int des = p->descent();
|
||||
int wid = p->width();
|
||||
ascent_ = max(ascent_, asc);
|
||||
descent_ = max(descent_, des);
|
||||
width_ += wid;
|
||||
@ -44,7 +46,7 @@ void MathXArray::metrics(MathStyles st)
|
||||
}
|
||||
|
||||
|
||||
void MathXArray::draw(Painter & pain, int x, int y)
|
||||
void MathXArray::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
@ -55,7 +57,7 @@ void MathXArray::draw(Painter & pain, int x, int y)
|
||||
}
|
||||
|
||||
for (int pos = 0; pos < data_.size(); ++pos) {
|
||||
MathInset * p = data_.nextInset(pos);
|
||||
MathInset const * p = data_.nextInset(pos);
|
||||
p->draw(pain, x, y);
|
||||
x += p->width();
|
||||
}
|
||||
@ -81,8 +83,8 @@ int MathXArray::x2pos(int targetx) const
|
||||
lastx = currx;
|
||||
currx += width(pos);
|
||||
}
|
||||
if (abs(lastx - targetx) < abs(currx - targetx))
|
||||
data_.prev(pos);
|
||||
if (abs(lastx - targetx) < abs(currx - targetx) && pos > 0)
|
||||
--pos;
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ public:
|
||||
///
|
||||
MathXArray();
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter & pain, int x, int y);
|
||||
void draw(Painter & pain, int x, int y) const;
|
||||
|
||||
///
|
||||
int xo() const { return xo_; }
|
||||
@ -48,17 +48,17 @@ public:
|
||||
///
|
||||
MathArray data_;
|
||||
///
|
||||
int width_;
|
||||
mutable int width_;
|
||||
///
|
||||
int ascent_;
|
||||
mutable int ascent_;
|
||||
///
|
||||
int descent_;
|
||||
mutable int descent_;
|
||||
///
|
||||
int xo_;
|
||||
mutable int xo_;
|
||||
///
|
||||
int yo_;
|
||||
mutable int yo_;
|
||||
///
|
||||
MathStyles style_;
|
||||
mutable MathStyles style_;
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, MathXArray const & ar);
|
||||
|
Loading…
x
Reference in New Issue
Block a user