mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Even more ugly changes and a new file dependency to shut up Jean-Marc's
compiler *sigh* git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2804 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7435fca771
commit
0f5ff99bc1
@ -188,7 +188,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
||||
if (display()) {
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bool old = par_->numberedType();
|
||||
for (unsigned int row = 0; row < par_->nrows(); ++row)
|
||||
for (MathInset::row_type row = 0; row < par_->nrows(); ++row)
|
||||
par_->numbered(row, !old);
|
||||
bv->owner()->message(old ? _("No number") : _("Number"));
|
||||
updateLocal(bv, true);
|
||||
|
@ -91,7 +91,7 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
|
||||
|
||||
|
||||
// returns the nearest enclosing grid
|
||||
MathArrayInset * matrixpar(unsigned int & idx)
|
||||
MathArrayInset * matrixpar(MathInset::idx_type & idx)
|
||||
{
|
||||
idx = 0;
|
||||
return (mathcursor ? mathcursor->enclosingArray(idx) : 0);
|
||||
@ -555,7 +555,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
lyxerr << "handling halign '" << arg << "'\n";
|
||||
unsigned int idx;
|
||||
MathInset::idx_type idx;
|
||||
MathArrayInset * p = matrixpar(idx);
|
||||
if (!p)
|
||||
break;
|
||||
@ -568,7 +568,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
lyxerr << "handling valign '" << arg << "'\n";
|
||||
unsigned int idx;
|
||||
MathInset::idx_type idx;
|
||||
MathArrayInset * p = matrixpar(idx);
|
||||
if (!p)
|
||||
break;
|
||||
@ -580,7 +580,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_MATH_ROW_INSERT:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
unsigned int idx;
|
||||
MathInset::idx_type idx;
|
||||
MathArrayInset * p = matrixpar(idx);
|
||||
lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
|
||||
if (!p)
|
||||
@ -593,7 +593,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_MATH_ROW_DELETE:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
unsigned int idx;
|
||||
MathInset::idx_type idx;
|
||||
MathArrayInset * p = matrixpar(idx);
|
||||
lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
|
||||
if (!p)
|
||||
@ -606,7 +606,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_MATH_COLUMN_INSERT:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
unsigned int idx;
|
||||
MathInset::idx_type idx;
|
||||
MathArrayInset * p = matrixpar(idx);
|
||||
if (!p)
|
||||
break;
|
||||
@ -618,7 +618,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_MATH_COLUMN_DELETE:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
unsigned int idx;
|
||||
MathInset::idx_type idx;
|
||||
MathArrayInset * p = matrixpar(idx);
|
||||
if (!p)
|
||||
break;
|
||||
|
@ -27,7 +27,7 @@ void MathArrayInset::write(std::ostream & os, bool fragile) const
|
||||
os << '[' << char(v_align_) << ']';
|
||||
|
||||
os << '{';
|
||||
for (unsigned int col = 0; col < ncols(); ++col)
|
||||
for (col_type col = 0; col < ncols(); ++col)
|
||||
os << colinfo_[col].align_;
|
||||
os << "}\n";
|
||||
|
||||
|
@ -61,8 +61,9 @@ struct Selection
|
||||
if (i1.idx_ == i2.idx_)
|
||||
data_.push_back(MathArray(i1.cell(), i1.pos_, i2.pos_));
|
||||
else {
|
||||
std::vector<unsigned int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
|
||||
for (unsigned i = 0; i < indices.size(); ++i)
|
||||
std::vector<MathInset::idx_type> indices =
|
||||
i1.par_->idxBetween(i1.idx_, i2.idx_);
|
||||
for (MathInset::idx_type i = 0; i < indices.size(); ++i)
|
||||
data_.push_back(i1.cell(indices[i]));
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "math_defs.h"
|
||||
#include "math_inset.h"
|
||||
|
||||
class MathInset;
|
||||
class MathAtom;
|
||||
@ -41,17 +42,17 @@ struct MathCursorPos {
|
||||
/// inset
|
||||
MathInset * par_;
|
||||
/// cell index
|
||||
unsigned int idx_;
|
||||
MathInset::idx_type idx_;
|
||||
/// cell position
|
||||
unsigned int pos_;
|
||||
MathInset::pos_type pos_;
|
||||
/// returns cell corresponding to this position
|
||||
MathArray & cell() const;
|
||||
/// returns cell corresponding to this position
|
||||
MathArray & cell(unsigned int idx) const;
|
||||
MathArray & cell(MathInset::idx_type idx) const;
|
||||
/// returns xcell corresponding to this position
|
||||
MathXArray & xcell() const;
|
||||
/// returns xcell corresponding to this position
|
||||
MathXArray & xcell(unsigned int idx) const;
|
||||
MathXArray & xcell(MathInset::idx_type idx) const;
|
||||
};
|
||||
|
||||
///
|
||||
@ -63,6 +64,17 @@ bool operator<(MathCursorPos const &, MathCursorPos const &);
|
||||
/// This is the external interface of Math's subkernel
|
||||
class MathCursor {
|
||||
public:
|
||||
/// short of anything else reasonable
|
||||
typedef MathInset::size_type size_type;
|
||||
/// type for cursor positions within a cell
|
||||
typedef MathInset::pos_type pos_type;
|
||||
/// type for cell indices
|
||||
typedef MathInset::idx_type idx_type;
|
||||
/// type for row numbers
|
||||
typedef MathInset::row_type row_type;
|
||||
/// type for column numbers
|
||||
typedef MathInset::col_type col_type;
|
||||
|
||||
///
|
||||
explicit MathCursor(InsetFormulaBase *);
|
||||
///
|
||||
@ -120,15 +132,15 @@ public:
|
||||
///
|
||||
MathInset * par() const;
|
||||
/// return the next enclosing grid inset and the cursor's index in it
|
||||
MathArrayInset * enclosingArray(unsigned int &) const;
|
||||
MathArrayInset * enclosingArray(idx_type &) const;
|
||||
///
|
||||
InsetFormulaBase const * formula();
|
||||
///
|
||||
unsigned int pos() const;
|
||||
pos_type pos() const;
|
||||
///
|
||||
unsigned int idx() const;
|
||||
idx_type idx() const;
|
||||
///
|
||||
unsigned int size() const;
|
||||
size_type size() const;
|
||||
///
|
||||
void interpret(string const &);
|
||||
///
|
||||
@ -183,9 +195,9 @@ public:
|
||||
///
|
||||
char halign() const;
|
||||
///
|
||||
unsigned int col() const;
|
||||
col_type col() const;
|
||||
///
|
||||
unsigned int row() const;
|
||||
row_type row() const;
|
||||
|
||||
///
|
||||
MathStyles style() const;
|
||||
@ -231,7 +243,7 @@ public:
|
||||
|
||||
|
||||
///
|
||||
unsigned int last() const;
|
||||
pos_type last() const;
|
||||
///
|
||||
MathInset * parInset(int i) const;
|
||||
///
|
||||
@ -261,13 +273,13 @@ private:
|
||||
/// can the setPos routine enter that inset?
|
||||
MathInset * positionable(MathAtom *, int x, int y) const;
|
||||
/// write access to cursor cell position
|
||||
unsigned int & pos();
|
||||
pos_type & pos();
|
||||
/// write access to cursor cell index
|
||||
unsigned int & idx();
|
||||
idx_type & idx();
|
||||
/// x-offset of current cell relative to par xo
|
||||
unsigned int cellXOffset() const;
|
||||
idx_type cellXOffset() const;
|
||||
/// y-offset of current cell relative to par yo
|
||||
unsigned int cellYOffset() const;
|
||||
idx_type cellYOffset() const;
|
||||
/// current x position relative to par xo
|
||||
int xpos() const;
|
||||
/// current y position relative to par yo
|
||||
|
@ -40,7 +40,7 @@ MathGridInset::ColInfo::ColInfo()
|
||||
{}
|
||||
|
||||
|
||||
MathGridInset::MathGridInset(unsigned int m, unsigned int n)
|
||||
MathGridInset::MathGridInset(col_type m, row_type n)
|
||||
: MathNestInset(m * n), rowinfo_(n), colinfo_(m), v_align_('c')
|
||||
{
|
||||
if (m <= 0)
|
||||
@ -51,7 +51,7 @@ MathGridInset::MathGridInset(unsigned int m, unsigned int n)
|
||||
}
|
||||
|
||||
|
||||
unsigned int MathGridInset::index(unsigned int row, unsigned int col) const
|
||||
MathInset::idx_type MathGridInset::index(row_type row, col_type col) const
|
||||
{
|
||||
return col + ncols() * row;
|
||||
}
|
||||
@ -59,7 +59,7 @@ unsigned int MathGridInset::index(unsigned int row, unsigned int col) const
|
||||
|
||||
void MathGridInset::setDefaults()
|
||||
{
|
||||
for (unsigned int col = 0; col < ncols(); ++col) {
|
||||
for (col_type col = 0; col < ncols(); ++col) {
|
||||
colinfo_[col].align_ = defaultColAlign(col);
|
||||
colinfo_[col].skip_ = defaultColSpace(col);
|
||||
}
|
||||
@ -68,21 +68,21 @@ void MathGridInset::setDefaults()
|
||||
|
||||
void MathGridInset::halign(string const & hh)
|
||||
{
|
||||
unsigned int n = hh.size();
|
||||
col_type n = hh.size();
|
||||
if (n > ncols())
|
||||
n = ncols();
|
||||
for (unsigned int i = 0; i < n; ++i)
|
||||
colinfo_[i].align_ = hh[i];
|
||||
for (col_type col = 0; col < n; ++col)
|
||||
colinfo_[col].align_ = hh[col];
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::halign(char h, unsigned int col)
|
||||
void MathGridInset::halign(char h, col_type col)
|
||||
{
|
||||
colinfo_[col].align_ = h;
|
||||
}
|
||||
|
||||
|
||||
char MathGridInset::halign(unsigned int col) const
|
||||
char MathGridInset::halign(col_type col) const
|
||||
{
|
||||
return colinfo_[col].align_;
|
||||
}
|
||||
@ -102,13 +102,13 @@ char MathGridInset::valign() const
|
||||
|
||||
|
||||
|
||||
void MathGridInset::vskip(LyXLength const & skip, unsigned int row)
|
||||
void MathGridInset::vskip(LyXLength const & skip, row_type row)
|
||||
{
|
||||
rowinfo_[row].skip_ = skip;
|
||||
}
|
||||
|
||||
|
||||
LyXLength MathGridInset::vskip(unsigned int row) const
|
||||
LyXLength MathGridInset::vskip(row_type row) const
|
||||
{
|
||||
return rowinfo_[row].skip_;
|
||||
}
|
||||
@ -121,10 +121,10 @@ void MathGridInset::metrics(MathStyles st) const
|
||||
size_ = st;
|
||||
|
||||
// adjust vertical structure
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
int asc = 0;
|
||||
int desc = 0;
|
||||
for (unsigned int col = 0; col < ncols(); ++col) {
|
||||
for (col_type col = 0; col < ncols(); ++col) {
|
||||
MathXArray const & c = xcell(index(row, col));
|
||||
asc = std::max(asc, c.ascent());
|
||||
desc = std::max(desc, c.descent());
|
||||
@ -156,15 +156,15 @@ void MathGridInset::metrics(MathStyles st) const
|
||||
h = rowinfo_.back().offset_ / 2;
|
||||
}
|
||||
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
rowinfo_[row].offset_ -= h;
|
||||
rowinfo_[row].offset_ += MATH_BORDER;
|
||||
}
|
||||
|
||||
// adjust horizontal structure
|
||||
for (unsigned int col = 0; col < ncols(); ++col) {
|
||||
for (col_type col = 0; col < ncols(); ++col) {
|
||||
int wid = 0;
|
||||
for (unsigned int row = 0; row < nrows(); ++row)
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
wid = std::max(wid, xcell(index(row, col)).width());
|
||||
colinfo_[col].width_ = wid;
|
||||
colinfo_[col].offset_ = colinfo_[col].width_;
|
||||
@ -241,15 +241,15 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
for (unsigned int idx = 0; idx < nargs(); ++idx)
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx));
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::write(std::ostream & os, bool fragile) const
|
||||
{
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (unsigned int col = 0; col < ncols(); ++col) {
|
||||
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);
|
||||
}
|
||||
@ -258,7 +258,7 @@ void MathGridInset::write(std::ostream & os, bool fragile) const
|
||||
}
|
||||
|
||||
|
||||
string MathGridInset::eolString(unsigned int row) const
|
||||
string MathGridInset::eolString(row_type row) const
|
||||
{
|
||||
if (row + 1 == nrows())
|
||||
return "";
|
||||
@ -275,7 +275,7 @@ string MathGridInset::eolString(unsigned int row) const
|
||||
}
|
||||
|
||||
|
||||
string MathGridInset::eocString(unsigned int col) const
|
||||
string MathGridInset::eocString(col_type col) const
|
||||
{
|
||||
if (col + 1 == ncols())
|
||||
return "";
|
||||
@ -283,7 +283,7 @@ string MathGridInset::eocString(unsigned int col) const
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::addRow(unsigned int row)
|
||||
void MathGridInset::addRow(row_type row)
|
||||
{
|
||||
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
|
||||
cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
|
||||
@ -293,12 +293,12 @@ void MathGridInset::addRow(unsigned int row)
|
||||
void MathGridInset::appendRow()
|
||||
{
|
||||
rowinfo_.push_back(RowInfo());
|
||||
for (unsigned int i = 0; i < ncols(); ++i)
|
||||
for (col_type col = 0; col < ncols(); ++col)
|
||||
cells_.push_back(cells_type::value_type());
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::delRow(unsigned int row)
|
||||
void MathGridInset::delRow(row_type row)
|
||||
{
|
||||
if (nrows() == 1)
|
||||
return;
|
||||
@ -310,14 +310,14 @@ void MathGridInset::delRow(unsigned int row)
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::addCol(unsigned int newcol)
|
||||
void MathGridInset::addCol(col_type newcol)
|
||||
{
|
||||
unsigned int const nc = ncols();
|
||||
unsigned int const nr = nrows();
|
||||
const col_type nc = ncols();
|
||||
const row_type nr = nrows();
|
||||
cells_type new_cells((nc + 1) * nr);
|
||||
|
||||
for (unsigned int row = 0; row < nr; ++row)
|
||||
for (unsigned int col = 0; col < nc; ++col)
|
||||
for (row_type row = 0; row < nr; ++row)
|
||||
for (col_type col = 0; col < nc; ++col)
|
||||
new_cells[row * (nc + 1) + col + (col > newcol)]
|
||||
= cells_[row * nc + col];
|
||||
std::swap(cells_, new_cells);
|
||||
@ -329,13 +329,13 @@ void MathGridInset::addCol(unsigned int newcol)
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::delCol(unsigned int col)
|
||||
void MathGridInset::delCol(col_type col)
|
||||
{
|
||||
if (ncols() == 1)
|
||||
return;
|
||||
|
||||
cells_type tmpcells;
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (col_type i = 0; i < nargs(); ++i)
|
||||
if (i % ncols() != col)
|
||||
tmpcells.push_back(cells_[i]);
|
||||
std::swap(cells_, tmpcells);
|
||||
@ -344,9 +344,9 @@ void MathGridInset::delCol(unsigned int col)
|
||||
}
|
||||
|
||||
|
||||
int MathGridInset::cellXOffset(unsigned int idx) const
|
||||
int MathGridInset::cellXOffset(idx_type idx) const
|
||||
{
|
||||
unsigned int c = col(idx);
|
||||
col_type c = col(idx);
|
||||
int x = colinfo_[c].offset_;
|
||||
char align = colinfo_[c].align_;
|
||||
if (align == 'r' || align == 'R')
|
||||
@ -357,13 +357,13 @@ int MathGridInset::cellXOffset(unsigned int idx) const
|
||||
}
|
||||
|
||||
|
||||
int MathGridInset::cellYOffset(unsigned int idx) const
|
||||
int MathGridInset::cellYOffset(idx_type idx) const
|
||||
{
|
||||
return rowinfo_[row(idx)].offset_;
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxUp(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathGridInset::idxUp(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
if (idx < ncols())
|
||||
return false;
|
||||
@ -373,7 +373,7 @@ bool MathGridInset::idxUp(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxDown(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathGridInset::idxDown(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
if (idx >= ncols() * (nrows() - 1))
|
||||
return false;
|
||||
@ -383,7 +383,7 @@ bool MathGridInset::idxDown(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxLeft(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
// leave matrix if on the left hand edge
|
||||
if (col(idx) == 0)
|
||||
@ -394,7 +394,7 @@ bool MathGridInset::idxLeft(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxRight(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
// leave matrix if on the right hand edge
|
||||
if (col(idx) == ncols() - 1)
|
||||
@ -405,7 +405,7 @@ bool MathGridInset::idxRight(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxFirst(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
switch (v_align_) {
|
||||
case 't':
|
||||
@ -422,7 +422,7 @@ bool MathGridInset::idxFirst(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxLast(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
switch (v_align_) {
|
||||
case 't':
|
||||
@ -439,7 +439,7 @@ bool MathGridInset::idxLast(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::idxDelete(unsigned int & idx, bool & popit, bool & deleteit)
|
||||
void MathGridInset::idxDelete(idx_type & idx, bool & popit, bool & deleteit)
|
||||
{
|
||||
popit = false;
|
||||
deleteit = false;
|
||||
@ -447,7 +447,7 @@ void MathGridInset::idxDelete(unsigned int & idx, bool & popit, bool & deleteit)
|
||||
// delete entire row if in first cell of empty row
|
||||
if (col(idx) == 0 && nrows() > 1) {
|
||||
bool deleterow = true;
|
||||
for (unsigned int i = idx; i < idx + ncols(); ++i)
|
||||
for (idx_type i = idx; i < idx + ncols(); ++i)
|
||||
if (cell(i).size()) {
|
||||
deleterow = false;
|
||||
break;
|
||||
@ -466,7 +466,7 @@ void MathGridInset::idxDelete(unsigned int & idx, bool & popit, bool & deleteit)
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::idxDeleteRange(unsigned int /*from*/, unsigned int /*to*/)
|
||||
void MathGridInset::idxDeleteRange(idx_type /*from*/, idx_type /*to*/)
|
||||
{
|
||||
// leave this unimplemented unless someone wants to have it.
|
||||
/*
|
||||
@ -482,28 +482,28 @@ void MathGridInset::idxDeleteRange(unsigned int /*from*/, unsigned int /*to*/)
|
||||
}
|
||||
|
||||
|
||||
MathGridInset::RowInfo const & MathGridInset::rowinfo(unsigned int i) const
|
||||
MathGridInset::RowInfo const & MathGridInset::rowinfo(row_type row) const
|
||||
{
|
||||
return rowinfo_[i];
|
||||
return rowinfo_[row];
|
||||
}
|
||||
|
||||
|
||||
MathGridInset::RowInfo & MathGridInset::rowinfo(unsigned int i)
|
||||
MathGridInset::RowInfo & MathGridInset::rowinfo(row_type row)
|
||||
{
|
||||
return rowinfo_[i];
|
||||
return rowinfo_[row];
|
||||
}
|
||||
|
||||
|
||||
std::vector<unsigned int>
|
||||
MathGridInset::idxBetween(unsigned int from, unsigned int to) const
|
||||
std::vector<MathInset::idx_type>
|
||||
MathGridInset::idxBetween(idx_type from, idx_type to) const
|
||||
{
|
||||
unsigned int r1 = std::min(row(from), row(to));
|
||||
unsigned int r2 = std::max(row(from), row(to));
|
||||
unsigned int c1 = std::min(col(from), col(to));
|
||||
unsigned int c2 = std::max(col(from), col(to));
|
||||
std::vector<unsigned int> res;
|
||||
for (unsigned int i = r1; i <= r2; ++i)
|
||||
for (unsigned int j = c1; j <= c2; ++j)
|
||||
row_type r1 = std::min(row(from), row(to));
|
||||
row_type r2 = std::max(row(from), row(to));
|
||||
col_type c1 = std::min(col(from), col(to));
|
||||
col_type c2 = std::max(col(from), col(to));
|
||||
std::vector<idx_type> res;
|
||||
for (row_type i = r1; i <= r2; ++i)
|
||||
for (col_type j = c1; j <= c2; ++j)
|
||||
res.push_back(index(i, j));
|
||||
return res;
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ class MathGridInset : public MathNestInset {
|
||||
};
|
||||
|
||||
public:
|
||||
///
|
||||
MathGridInset(unsigned int m, unsigned int n);
|
||||
/// Note: columns first!
|
||||
MathGridInset(col_type m, row_type n);
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
@ -70,82 +70,82 @@ public:
|
||||
///
|
||||
void halign(string const &);
|
||||
///
|
||||
void halign(char c, unsigned int col);
|
||||
void halign(char c, col_type col);
|
||||
///
|
||||
char halign(unsigned int col) const;
|
||||
char halign(col_type col) const;
|
||||
///
|
||||
void valign(char c);
|
||||
///
|
||||
char valign() const;
|
||||
///
|
||||
void vskip(LyXLength const &, unsigned int row);
|
||||
void vskip(LyXLength const &, row_type row);
|
||||
///
|
||||
LyXLength vskip(unsigned int row) const;
|
||||
LyXLength vskip(row_type row) const;
|
||||
///
|
||||
void resize(short int type, unsigned int cols);
|
||||
void resize(short int type, col_type cols);
|
||||
///
|
||||
const RowInfo & rowinfo(unsigned int row) const;
|
||||
const RowInfo & rowinfo(row_type row) const;
|
||||
///
|
||||
RowInfo & rowinfo(unsigned int row);
|
||||
RowInfo & rowinfo(row_type row);
|
||||
///
|
||||
bool isGrid() const { return true; }
|
||||
|
||||
///
|
||||
unsigned int ncols() const { return colinfo_.size(); }
|
||||
col_type ncols() const { return colinfo_.size(); }
|
||||
///
|
||||
unsigned int nrows() const { return rowinfo_.size(); }
|
||||
row_type nrows() const { return rowinfo_.size(); }
|
||||
///
|
||||
unsigned int col(unsigned int idx) const { return idx % ncols(); }
|
||||
col_type col(idx_type idx) const { return idx % ncols(); }
|
||||
///
|
||||
unsigned int row(unsigned int idx) const { return idx / ncols(); }
|
||||
row_type row(idx_type idx) const { return idx / ncols(); }
|
||||
///
|
||||
int cellXOffset(unsigned int idx) const;
|
||||
int cellXOffset(idx_type idx) const;
|
||||
///
|
||||
int cellYOffset(unsigned int idx) const;
|
||||
int cellYOffset(idx_type idx) const;
|
||||
|
||||
///
|
||||
bool idxUp(unsigned int &, unsigned int &) const;
|
||||
bool idxUp(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxDown(unsigned int &, unsigned int &) const;
|
||||
bool idxDown(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxLeft(unsigned int &, unsigned int &) const;
|
||||
bool idxLeft(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxRight(unsigned int &, unsigned int &) const;
|
||||
bool idxRight(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxFirst(unsigned int &, unsigned int &) const;
|
||||
bool idxFirst(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxLast(unsigned int &, unsigned int &) const;
|
||||
bool idxLast(idx_type &, pos_type &) const;
|
||||
///
|
||||
void idxDelete(unsigned int &, bool &, bool &);
|
||||
void idxDelete(idx_type &, bool &, bool &);
|
||||
///
|
||||
void idxDeleteRange(unsigned int, unsigned int);
|
||||
void idxDeleteRange(idx_type, idx_type);
|
||||
|
||||
///
|
||||
void addRow(unsigned int);
|
||||
void addRow(row_type);
|
||||
///
|
||||
void delRow(unsigned int);
|
||||
void delRow(row_type);
|
||||
///
|
||||
void addCol(unsigned int);
|
||||
void addCol(col_type);
|
||||
///
|
||||
void delCol(unsigned int);
|
||||
void delCol(col_type);
|
||||
///
|
||||
virtual void appendRow();
|
||||
///
|
||||
unsigned int index(unsigned int row, unsigned int col) const;
|
||||
idx_type index(row_type row, col_type col) const;
|
||||
///
|
||||
std::vector<unsigned int> idxBetween(unsigned int from, unsigned int to) const;
|
||||
std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
|
||||
///
|
||||
virtual int defaultColSpace(unsigned int) { return 10; }
|
||||
virtual int defaultColSpace(col_type) { return 10; }
|
||||
///
|
||||
virtual char defaultColAlign(unsigned int) { return 'c'; }
|
||||
virtual char defaultColAlign(col_type) { return 'c'; }
|
||||
///
|
||||
void setDefaults();
|
||||
|
||||
protected:
|
||||
/// returns proper 'end of line' code for LaTeX
|
||||
string eolString(unsigned int row) const;
|
||||
string eolString(row_type row) const;
|
||||
/// returns proper 'end of column' code for LaTeX
|
||||
string eocString(unsigned int col) const;
|
||||
string eocString(col_type col) const;
|
||||
|
||||
/// row info
|
||||
std::vector<RowInfo> rowinfo_;
|
||||
|
@ -85,7 +85,7 @@ void MathInset::yo(int y) const
|
||||
}
|
||||
|
||||
|
||||
unsigned int MathInset::nargs() const
|
||||
MathInset::size_type MathInset::nargs() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -93,28 +93,28 @@ unsigned int MathInset::nargs() const
|
||||
|
||||
MathXArray dummyCell;
|
||||
|
||||
MathXArray & MathInset::xcell(unsigned int)
|
||||
MathXArray & MathInset::xcell(idx_type)
|
||||
{
|
||||
lyxerr << "I don't have a cell\n";
|
||||
return dummyCell;
|
||||
}
|
||||
|
||||
|
||||
MathXArray const & MathInset::xcell(unsigned int) const
|
||||
MathXArray const & MathInset::xcell(idx_type) const
|
||||
{
|
||||
lyxerr << "I don't have a cell\n";
|
||||
return dummyCell;
|
||||
}
|
||||
|
||||
|
||||
MathArray & MathInset::cell(unsigned int)
|
||||
MathArray & MathInset::cell(idx_type)
|
||||
{
|
||||
lyxerr << "I don't have a cell\n";
|
||||
return dummyCell.data_;
|
||||
}
|
||||
|
||||
|
||||
MathArray const & MathInset::cell(unsigned int) const
|
||||
MathArray const & MathInset::cell(idx_type) const
|
||||
{
|
||||
lyxerr << "I don't have a cell\n";
|
||||
return dummyCell.data_;
|
||||
@ -125,74 +125,74 @@ void MathInset::substitute(MathMacro const &)
|
||||
{}
|
||||
|
||||
|
||||
bool MathInset::idxNext(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxNext(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxRight(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxRight(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxPrev(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxPrev(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxLeft(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxLeft(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxUp(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxUp(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxDown(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxDown(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxFirst(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxFirst(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxLast(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxLast(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxHome(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxHome(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathInset::idxEnd(unsigned int &, unsigned int &) const
|
||||
bool MathInset::idxEnd(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MathInset::idxDelete(unsigned int &, bool & popit, bool & deleteit)
|
||||
void MathInset::idxDelete(idx_type &, bool & popit, bool & deleteit)
|
||||
{
|
||||
popit = false;
|
||||
deleteit = false;
|
||||
}
|
||||
|
||||
|
||||
void MathInset::idxDeleteRange(unsigned int, unsigned int)
|
||||
void MathInset::idxDeleteRange(idx_type, idx_type)
|
||||
{}
|
||||
|
||||
|
||||
@ -255,11 +255,11 @@ void MathInset::validate(LaTeXFeatures &) const
|
||||
{}
|
||||
|
||||
|
||||
std::vector<unsigned int>
|
||||
MathInset::idxBetween(unsigned int from, unsigned int to) const
|
||||
std::vector<MathInset::idx_type>
|
||||
MathInset::idxBetween(idx_type from, idx_type to) const
|
||||
{
|
||||
std::vector<unsigned int> res;
|
||||
for (unsigned int i = from; i <= to; ++i)
|
||||
std::vector<idx_type> res;
|
||||
for (idx_type i = from; i <= to; ++i)
|
||||
res.push_back(i);
|
||||
return res;
|
||||
}
|
||||
|
@ -43,8 +43,16 @@ class MathScriptInset;
|
||||
|
||||
class MathInset {
|
||||
public:
|
||||
///
|
||||
/// short of anything else reasonable
|
||||
typedef MathArray::size_type size_type;
|
||||
/// type for cursor positions within a cell
|
||||
typedef MathArray::size_type pos_type;
|
||||
/// type for cell indices
|
||||
typedef size_type idx_type;
|
||||
/// type for row numbers
|
||||
typedef size_type row_type;
|
||||
/// type for column numbers
|
||||
typedef size_type col_type;
|
||||
|
||||
///
|
||||
MathInset();
|
||||
@ -75,51 +83,50 @@ public:
|
||||
virtual MathStyles size() const;
|
||||
|
||||
/// Where should we go when we press the up cursor key?
|
||||
virtual bool idxUp(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxUp(idx_type & idx, pos_type & pos) const;
|
||||
/// The down key
|
||||
virtual bool idxDown(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxDown(idx_type & idx, pos_type & pos) const;
|
||||
/// The left key
|
||||
virtual bool idxLeft(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxLeft(idx_type & idx, pos_type & pos) const;
|
||||
/// The right key
|
||||
virtual bool idxRight(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxRight(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Move one physical cell up
|
||||
virtual bool idxNext(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxNext(idx_type & idx, pos_type & pos) const;
|
||||
/// Move one physical cell down
|
||||
virtual bool idxPrev(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxPrev(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Target pos when we enter the inset from the left by pressing "Right"
|
||||
virtual bool idxFirst(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxFirst(idx_type & idx, pos_type & pos) const;
|
||||
/// Target pos when we enter the inset from the right by pressing "Left"
|
||||
virtual bool idxLast(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxLast(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Where should we go if we press home?
|
||||
virtual bool idxHome(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxHome(idx_type & idx, pos_type & pos) const;
|
||||
/// Where should we go if we press end?
|
||||
virtual bool idxEnd(unsigned int & idx, unsigned int & pos) const;
|
||||
virtual bool idxEnd(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Delete a cell and move cursor
|
||||
// the return value indicates whether the cursor should leave the inset
|
||||
// and/or the whole inset should be deleted
|
||||
virtual void idxDelete(unsigned int & idx, bool & popit, bool & deleteit);
|
||||
virtual void idxDelete(idx_type & idx, bool & popit, bool & deleteit);
|
||||
// deletes a cell range and moves the cursor
|
||||
virtual void idxDeleteRange(unsigned int from, unsigned int to);
|
||||
virtual void idxDeleteRange(idx_type from, idx_type to);
|
||||
// returns list of cell indices that are "between" from and to for
|
||||
// selection purposes
|
||||
virtual std::vector<unsigned int>
|
||||
idxBetween(unsigned int from, unsigned int to) const;
|
||||
virtual std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
|
||||
|
||||
///
|
||||
virtual unsigned int nargs() const;
|
||||
virtual idx_type nargs() const;
|
||||
|
||||
///
|
||||
virtual MathArray & cell(unsigned int);
|
||||
virtual MathArray & cell(idx_type);
|
||||
///
|
||||
virtual MathArray const & cell(unsigned int) const;
|
||||
virtual MathArray const & cell(idx_type) const;
|
||||
///
|
||||
virtual MathXArray & xcell(unsigned int);
|
||||
virtual MathXArray & xcell(idx_type);
|
||||
///
|
||||
virtual MathXArray const & xcell(unsigned int) const;
|
||||
virtual MathXArray const & xcell(idx_type) const;
|
||||
|
||||
///
|
||||
virtual int xo() const;
|
||||
@ -132,25 +139,25 @@ public:
|
||||
///
|
||||
|
||||
///
|
||||
virtual unsigned int ncols() const { return 1; }
|
||||
virtual col_type ncols() const { return 1; }
|
||||
///
|
||||
virtual unsigned int nrows() const { return 1; }
|
||||
virtual row_type nrows() const { return 1; }
|
||||
///
|
||||
virtual unsigned int col(unsigned int) const { return 0; }
|
||||
virtual col_type col(row_type) const { return 0; }
|
||||
///
|
||||
virtual unsigned int row(unsigned int) const { return 0; }
|
||||
virtual row_type row(row_type) const { return 0; }
|
||||
///
|
||||
virtual int cellXOffset(unsigned int) const { return 0; }
|
||||
virtual int cellXOffset(row_type) const { return 0; }
|
||||
///
|
||||
virtual int cellYOffset(unsigned int) const { return 0; }
|
||||
virtual int cellYOffset(row_type) const { return 0; }
|
||||
///
|
||||
virtual void addRow(unsigned int) {}
|
||||
virtual void addRow(row_type) {}
|
||||
///
|
||||
virtual void delRow(unsigned int) {}
|
||||
virtual void delRow(row_type) {}
|
||||
///
|
||||
virtual void addCol(unsigned int) {}
|
||||
virtual void addCol(col_type) {}
|
||||
///
|
||||
virtual void delCol(unsigned int) {}
|
||||
virtual void delCol(col_type) {}
|
||||
|
||||
///
|
||||
virtual void userSetSize(MathStyles &) {}
|
||||
|
@ -72,7 +72,7 @@ void MathMacro::metrics(MathStyles st) const
|
||||
int lwid;
|
||||
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
|
||||
|
||||
for (unsigned int i = 0; i < nargs(); ++i) {
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
MathXArray const & c = xcell(i);
|
||||
c.metrics(st);
|
||||
width_ = std::max(width_, c.width() + lwid);
|
||||
@ -114,7 +114,7 @@ void MathMacro::draw(Painter & pain, int x, int y) const
|
||||
int lwid;
|
||||
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
|
||||
|
||||
for (unsigned int i = 0; i < nargs(); ++i) {
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
MathXArray const & c = xcell(i);
|
||||
h += std::max(c.ascent(), lasc) + 5;
|
||||
c.draw(pain, x + lwid, h);
|
||||
@ -147,7 +147,7 @@ void MathMacro::dump() const
|
||||
void MathMacro::write(std::ostream & os, bool fragile) const
|
||||
{
|
||||
os << '\\' << name();
|
||||
for (unsigned int i = 0; i < nargs(); ++i) {
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
os << '{';
|
||||
cell(i).write(os, fragile);
|
||||
os << '}';
|
||||
@ -160,7 +160,7 @@ void MathMacro::write(std::ostream & os, bool fragile) const
|
||||
void MathMacro::writeNormal(std::ostream & os) const
|
||||
{
|
||||
os << "[macro " << name() << " ";
|
||||
for (unsigned int i = 0; i < nargs(); ++i) {
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
cell(i).writeNormal(os);
|
||||
os << ' ';
|
||||
}
|
||||
@ -168,25 +168,25 @@ void MathMacro::writeNormal(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
bool MathMacro::idxUp(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathMacro::idxUp(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
return MathNestInset::idxLeft(idx, pos);
|
||||
}
|
||||
|
||||
|
||||
bool MathMacro::idxDown(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathMacro::idxDown(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
return MathNestInset::idxRight(idx, pos);
|
||||
}
|
||||
|
||||
|
||||
bool MathMacro::idxLeft(unsigned int &, unsigned int &) const
|
||||
bool MathMacro::idxLeft(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathMacro::idxRight(unsigned int &, unsigned int &) const
|
||||
bool MathMacro::idxRight(idx_type &, pos_type &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ public:
|
||||
void dump() const;
|
||||
|
||||
///
|
||||
bool idxUp(unsigned int &, unsigned int &) const;
|
||||
bool idxUp(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxDown(unsigned int &, unsigned int &) const;
|
||||
bool idxDown(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxLeft(unsigned int &, unsigned int &) const;
|
||||
bool idxLeft(idx_type &, pos_type &) const;
|
||||
///
|
||||
bool idxRight(unsigned int &, unsigned int &) const;
|
||||
bool idxRight(idx_type &, pos_type &) const;
|
||||
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
|
@ -64,7 +64,7 @@ MathMatrixInset::MathMatrixInset(MathInsetTypes t)
|
||||
}
|
||||
|
||||
|
||||
MathMatrixInset::MathMatrixInset(MathInsetTypes t, unsigned int cols)
|
||||
MathMatrixInset::MathMatrixInset(MathInsetTypes t, col_type cols)
|
||||
: MathGridInset(cols, 1), objtype_(t), nonum_(1), label_(1)
|
||||
{
|
||||
setDefaults();
|
||||
@ -77,7 +77,7 @@ MathInset * MathMatrixInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
char MathMatrixInset::defaultColAlign(unsigned int col)
|
||||
char MathMatrixInset::defaultColAlign(col_type col)
|
||||
{
|
||||
switch (getType()) {
|
||||
case LM_OT_ALIGN:
|
||||
@ -93,7 +93,7 @@ char MathMatrixInset::defaultColAlign(unsigned int col)
|
||||
}
|
||||
|
||||
|
||||
int MathMatrixInset::defaultColSpace(unsigned int col)
|
||||
int MathMatrixInset::defaultColSpace(col_type col)
|
||||
{
|
||||
switch (getType()) {
|
||||
case LM_OT_ALIGN:
|
||||
@ -123,7 +123,7 @@ void MathMatrixInset::metrics(MathStyles) const
|
||||
|
||||
if (numberedType()) {
|
||||
int l = 0;
|
||||
for (unsigned int row = 0; row < nrows(); ++row)
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
l = std::max(l, mathed_string_width(LM_TC_BF, size(), nicelabel(row)));
|
||||
|
||||
if (l)
|
||||
@ -148,7 +148,7 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const
|
||||
|
||||
if (numberedType()) {
|
||||
int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
int yy = y + rowinfo_[row].offset_;
|
||||
drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row));
|
||||
}
|
||||
@ -162,8 +162,8 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
||||
|
||||
bool n = numberedType();
|
||||
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (unsigned int col = 0; col < ncols(); ++col) {
|
||||
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);
|
||||
}
|
||||
@ -180,25 +180,25 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
||||
}
|
||||
|
||||
|
||||
string MathMatrixInset::label(unsigned int row) const
|
||||
string MathMatrixInset::label(row_type row) const
|
||||
{
|
||||
return label_[row];
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::label(unsigned int row, string const & label)
|
||||
void MathMatrixInset::label(row_type row, string const & label)
|
||||
{
|
||||
label_[row] = label;
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::numbered(unsigned int row, bool num)
|
||||
void MathMatrixInset::numbered(row_type row, bool num)
|
||||
{
|
||||
nonum_[row] = !num;
|
||||
}
|
||||
|
||||
|
||||
bool MathMatrixInset::numbered(unsigned int row) const
|
||||
bool MathMatrixInset::numbered(row_type row) const
|
||||
{
|
||||
return !nonum_[row];
|
||||
}
|
||||
@ -219,7 +219,7 @@ bool MathMatrixInset::display() const
|
||||
std::vector<string> const MathMatrixInset::getLabelList() const
|
||||
{
|
||||
std::vector<string> res;
|
||||
for (unsigned int row = 0; row < nrows(); ++row)
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
if (!label_[row].empty() && nonum_[row] != 1)
|
||||
res.push_back(label_[row]);
|
||||
return res;
|
||||
@ -230,7 +230,7 @@ bool MathMatrixInset::numberedType() const
|
||||
{
|
||||
if (getType() == LM_OT_SIMPLE || getType() == LM_OT_XXALIGNAT)
|
||||
return false;
|
||||
for (unsigned int row = 0; row < nrows(); ++row)
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
if (!nonum_[row])
|
||||
return true;
|
||||
return false;
|
||||
@ -355,7 +355,7 @@ void MathMatrixInset::footer_write(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::addRow(unsigned int row)
|
||||
void MathMatrixInset::addRow(row_type row)
|
||||
{
|
||||
nonum_.insert(nonum_.begin() + row + 1, !numberedType());
|
||||
label_.insert(label_.begin() + row + 1, string());
|
||||
@ -371,7 +371,7 @@ void MathMatrixInset::appendRow()
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::delRow(unsigned int row)
|
||||
void MathMatrixInset::delRow(row_type row)
|
||||
{
|
||||
MathGridInset::delRow(row);
|
||||
nonum_.erase(nonum_.begin() + row);
|
||||
@ -379,7 +379,7 @@ void MathMatrixInset::delRow(unsigned int row)
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::addCol(unsigned int col)
|
||||
void MathMatrixInset::addCol(col_type col)
|
||||
{
|
||||
switch (getType()) {
|
||||
case LM_OT_EQUATION:
|
||||
@ -409,7 +409,7 @@ void MathMatrixInset::addCol(unsigned int col)
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::delCol(unsigned int col)
|
||||
void MathMatrixInset::delCol(col_type col)
|
||||
{
|
||||
switch (getType()) {
|
||||
case LM_OT_ALIGNAT:
|
||||
@ -424,7 +424,7 @@ void MathMatrixInset::delCol(unsigned int col)
|
||||
}
|
||||
|
||||
|
||||
string MathMatrixInset::nicelabel(unsigned int row) const
|
||||
string MathMatrixInset::nicelabel(row_type row) const
|
||||
{
|
||||
if (nonum_[row])
|
||||
return string();
|
||||
@ -474,7 +474,7 @@ void MathMatrixInset::mutate(string const & newtype)
|
||||
void MathMatrixInset::glueall()
|
||||
{
|
||||
MathArray ar;
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
ar.push_back(cell(i));
|
||||
*this = MathMatrixInset(LM_OT_SIMPLE);
|
||||
cell(0) = ar;
|
||||
@ -523,7 +523,7 @@ void MathMatrixInset::mutate(MathInsetTypes newtype)
|
||||
MathGridInset::addCol(1);
|
||||
|
||||
// split it "nicely"
|
||||
unsigned int pos = firstRelOp(cell(0));
|
||||
pos_type pos = firstRelOp(cell(0));
|
||||
cell(1) = cell(0);
|
||||
cell(0).erase(pos, cell(0).size());
|
||||
cell(1).erase(0, pos);
|
||||
@ -538,7 +538,7 @@ void MathMatrixInset::mutate(MathInsetTypes newtype)
|
||||
MathGridInset::addCol(1);
|
||||
|
||||
// split it "nicely" on the firest relop
|
||||
unsigned int pos = firstRelOp(cell(0));
|
||||
pos_type pos = firstRelOp(cell(0));
|
||||
cell(1) = cell(0);
|
||||
cell(0).erase(pos, cell(0).size());
|
||||
cell(1).erase(0, pos);
|
||||
@ -561,14 +561,14 @@ void MathMatrixInset::mutate(MathInsetTypes newtype)
|
||||
case LM_OT_EQUATION: {
|
||||
// set correct (no)numbering
|
||||
bool allnonum = true;
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
if (!nonum_[row])
|
||||
allnonum = false;
|
||||
}
|
||||
|
||||
// set first non-empty label
|
||||
string label;
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
if (!label_[row].empty()) {
|
||||
label = label_[row];
|
||||
break;
|
||||
@ -588,8 +588,8 @@ void MathMatrixInset::mutate(MathInsetTypes newtype)
|
||||
case LM_OT_XALIGNAT:
|
||||
case LM_OT_XXALIGNAT:
|
||||
default: {
|
||||
for (unsigned int row = 0; row < nrows(); ++row) {
|
||||
unsigned int c = 3 * row + 1;
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
idx_type c = 3 * row + 1;
|
||||
cell(c).push_back(cell(c + 1));
|
||||
}
|
||||
MathGridInset::delCol(2);
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
///
|
||||
explicit MathMatrixInset(MathInsetTypes t);
|
||||
///
|
||||
MathMatrixInset(MathInsetTypes t, unsigned int cols);
|
||||
MathMatrixInset(MathInsetTypes t, col_type cols);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
@ -33,13 +33,13 @@ public:
|
||||
///
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
string label(unsigned int row) const;
|
||||
string label(row_type row) const;
|
||||
///
|
||||
void label(unsigned int row, string const & label);
|
||||
void label(row_type row, string const & label);
|
||||
///
|
||||
void numbered(unsigned int row, bool num);
|
||||
void numbered(row_type row, bool num);
|
||||
///
|
||||
bool numbered(unsigned int row) const;
|
||||
bool numbered(row_type row) const;
|
||||
///
|
||||
bool numberedType() const;
|
||||
///
|
||||
@ -52,13 +52,13 @@ public:
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
|
||||
///
|
||||
void addRow(unsigned int);
|
||||
void addRow(row_type);
|
||||
///
|
||||
void delRow(unsigned int);
|
||||
void delRow(row_type);
|
||||
///
|
||||
void addCol(unsigned int);
|
||||
void addCol(col_type);
|
||||
///
|
||||
void delCol(unsigned int);
|
||||
void delCol(col_type);
|
||||
///
|
||||
void appendRow();
|
||||
|
||||
@ -68,9 +68,9 @@ public:
|
||||
void mutate(MathInsetTypes);
|
||||
|
||||
///
|
||||
int defaultColSpace(unsigned int col);
|
||||
int defaultColSpace(col_type col);
|
||||
///
|
||||
char defaultColAlign(unsigned int col);
|
||||
char defaultColAlign(col_type col);
|
||||
|
||||
///
|
||||
MathInsetTypes getType() const;
|
||||
@ -87,7 +87,7 @@ private:
|
||||
///
|
||||
void glueall();
|
||||
///
|
||||
string nicelabel(unsigned int row) const;
|
||||
string nicelabel(row_type row) const;
|
||||
|
||||
///
|
||||
MathInsetTypes objtype_;
|
||||
|
@ -6,36 +6,36 @@
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
MathNestInset::MathNestInset(unsigned int nargs)
|
||||
MathNestInset::MathNestInset(idx_type nargs)
|
||||
: MathDimInset(), cells_(nargs)
|
||||
{}
|
||||
|
||||
|
||||
unsigned int MathNestInset::nargs() const
|
||||
MathInset::idx_type MathNestInset::nargs() const
|
||||
{
|
||||
return cells_.size();
|
||||
}
|
||||
|
||||
|
||||
MathXArray & MathNestInset::xcell(unsigned int i)
|
||||
MathXArray & MathNestInset::xcell(idx_type i)
|
||||
{
|
||||
return cells_[i];
|
||||
}
|
||||
|
||||
|
||||
MathXArray const & MathNestInset::xcell(unsigned int i) const
|
||||
MathXArray const & MathNestInset::xcell(idx_type i) const
|
||||
{
|
||||
return cells_[i];
|
||||
}
|
||||
|
||||
|
||||
MathArray & MathNestInset::cell(unsigned int i)
|
||||
MathArray & MathNestInset::cell(idx_type i)
|
||||
{
|
||||
return cells_[i].data_;
|
||||
}
|
||||
|
||||
|
||||
MathArray const & MathNestInset::cell(unsigned int i) const
|
||||
MathArray const & MathNestInset::cell(idx_type i) const
|
||||
{
|
||||
return cells_[i].data_;
|
||||
}
|
||||
@ -43,7 +43,7 @@ MathArray const & MathNestInset::cell(unsigned int i) const
|
||||
|
||||
void MathNestInset::substitute(MathMacro const & m)
|
||||
{
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
cell(i).substitute(m);
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ void MathNestInset::substitute(MathMacro const & m)
|
||||
void MathNestInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
xcell(i).metrics(st);
|
||||
}
|
||||
|
||||
@ -60,12 +60,12 @@ void MathNestInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxNext(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
if (idx + 1 >= nargs())
|
||||
return false;
|
||||
@ -75,13 +75,13 @@ bool MathNestInset::idxNext(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxRight(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
return idxNext(idx, pos);
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxPrev(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
if (idx == 0)
|
||||
return false;
|
||||
@ -91,13 +91,13 @@ bool MathNestInset::idxPrev(unsigned int & idx, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxLeft(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
return idxPrev(idx, pos);
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxFirst(unsigned int & i, unsigned int & pos) const
|
||||
bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
|
||||
{
|
||||
if (nargs() == 0)
|
||||
return false;
|
||||
@ -107,7 +107,7 @@ bool MathNestInset::idxFirst(unsigned int & i, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxLast(unsigned int & i, unsigned int & pos) const
|
||||
bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
|
||||
{
|
||||
if (nargs() == 0)
|
||||
return false;
|
||||
@ -117,7 +117,7 @@ bool MathNestInset::idxLast(unsigned int & i, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxHome(unsigned int & /* idx */, unsigned int & pos) const
|
||||
bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
|
||||
{
|
||||
if (pos == 0)
|
||||
return false;
|
||||
@ -126,9 +126,9 @@ bool MathNestInset::idxHome(unsigned int & /* idx */, unsigned int & pos) const
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::idxEnd(unsigned int & idx, unsigned int & pos) const
|
||||
bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
|
||||
{
|
||||
unsigned int n = cell(idx).size();
|
||||
pos_type n = cell(idx).size();
|
||||
if (pos == n)
|
||||
return false;
|
||||
|
||||
@ -142,7 +142,7 @@ void MathNestInset::dump() const
|
||||
lyxerr << "---------------------------------------------\n";
|
||||
write(lyxerr, false);
|
||||
lyxerr << "\n";
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
lyxerr << cell(i) << "\n";
|
||||
lyxerr << "---------------------------------------------\n";
|
||||
}
|
||||
@ -159,6 +159,6 @@ void MathNestInset::push_back(MathInset * p)
|
||||
|
||||
void MathNestInset::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
for (unsigned int i = 0; i < nargs(); ++i)
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
cell(i).validate(features);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class LaTeXFeatures;
|
||||
class MathNestInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathNestInset(unsigned int ncells);
|
||||
explicit MathNestInset(idx_type ncells);
|
||||
|
||||
///
|
||||
void metrics(MathStyles st) const;
|
||||
@ -26,36 +26,36 @@ public:
|
||||
void substitute(MathMacro const & macro);
|
||||
|
||||
/// The left key
|
||||
bool idxLeft(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxLeft(idx_type & idx, pos_type & pos) const;
|
||||
/// The right key
|
||||
bool idxRight(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxRight(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Move one physical cell up
|
||||
bool idxNext(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxNext(idx_type & idx, pos_type & pos) const;
|
||||
/// Move one physical cell down
|
||||
bool idxPrev(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxPrev(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Target pos when we enter the inset from the left by pressing "Right"
|
||||
bool idxFirst(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxFirst(idx_type & idx, pos_type & pos) const;
|
||||
/// Target pos when we enter the inset from the right by pressing "Left"
|
||||
bool idxLast(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxLast(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
/// Where should we go if we press home?
|
||||
bool idxHome(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxHome(idx_type & idx, pos_type & pos) const;
|
||||
/// Where should we go if we press end?
|
||||
bool idxEnd(unsigned int & idx, unsigned int & pos) const;
|
||||
bool idxEnd(idx_type & idx, pos_type & pos) const;
|
||||
|
||||
///
|
||||
unsigned int nargs() const;
|
||||
idx_type nargs() const;
|
||||
|
||||
///
|
||||
MathArray & cell(unsigned int);
|
||||
MathArray & cell(idx_type);
|
||||
///
|
||||
MathArray const & cell(unsigned int) const;
|
||||
MathArray const & cell(idx_type) const;
|
||||
///
|
||||
MathXArray & xcell(unsigned int);
|
||||
MathXArray & xcell(idx_type);
|
||||
///
|
||||
MathXArray const & xcell(unsigned int) const;
|
||||
MathXArray const & xcell(idx_type) const;
|
||||
|
||||
///
|
||||
bool isActive() const { return nargs() > 0; }
|
||||
|
@ -880,7 +880,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
|
||||
else {
|
||||
MathInset * p = createMathInset(t.cs());
|
||||
for (unsigned int i = 0; i < p->nargs(); ++i)
|
||||
for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
|
||||
parse_into(p->cell(i), FLAG_ITEM);
|
||||
array.push_back(p);
|
||||
}
|
||||
@ -889,7 +889,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
else {
|
||||
MathInset * p = createMathInset(t.cs());
|
||||
if (p) {
|
||||
for (unsigned int i = 0; i < p->nargs(); ++i)
|
||||
for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
|
||||
parse_into(p->cell(i), FLAG_ITEM);
|
||||
array.push_back(p);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user