vector<string> const InsetFormula::getLabelList() const
{
- return par()->getLabelList();
+ vector<string> res;
+ par()->getLabelList(res);
+ return res;
}
}
-vector<MathInset::idx_type>
- MathGridInset::idxBetween(idx_type from, idx_type to) const
-{
- row_type r1 = min(row(from), row(to));
- row_type r2 = max(row(from), row(to));
- col_type c1 = min(col(from), col(to));
- col_type c2 = max(col(from), col(to));
- 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;
+bool MathGridInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
+{
+ row_type const ri = row(idx);
+ row_type const r1 = min(row(from), row(to));
+ row_type const r2 = max(row(from), row(to));
+ col_type const ci = col(idx);
+ col_type const c1 = min(col(from), col(to));
+ col_type const c2 = max(col(from), col(to));
+ return r1 <= ri && ri <= r2 && c1 <= ci && ci <= c2;
}
///
idx_type index(row_type r, col_type c) const;
///
- std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
+ bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
///
virtual int defaultColSpace(col_type) { return 0; }
///
}
-vector<string> MathHullInset::getLabelList() const
+void MathHullInset::getLabelList(std::vector<string> & labels) const
{
- vector<string> res;
for (row_type row = 0; row < nrows(); ++row)
if (!label_[row].empty() && nonum_[row] != 1)
- res.push_back(label_[row]);
- return res;
+ labels.push_back(label_[row]);
}
///
bool ams() const;
///
- std::vector<string> getLabelList() const;
+ void getLabelList(std::vector<string> &) const;
///
void validate(LaTeXFeatures & features) const;
/// identifies MatrixInsets
}
-void MathInset::validate(LaTeXFeatures &) const
-{}
-
-
-vector<MathInset::idx_type>
- MathInset::idxBetween(idx_type from, idx_type to) const
+bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
{
- vector<idx_type> res;
- for (idx_type i = from; i <= to; ++i)
- res.push_back(i);
- return res;
+ return from <= idx && idx <= to;
}
}
-std::vector<string> MathInset::getLabelList() const
-{
- return std::vector<string>();
-}
-
-
string const & MathInset::getType() const
{
static string t("none");
virtual void idxGlue(idx_type) {}
// returns list of cell indices that are "between" from and to for
// selection purposes
- virtual std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
+ virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
/// the number of nested cells this inset owns
virtual idx_type nargs() const;
virtual void edit(BufferView *, int, int, mouse_button::state) {}
/// request "external features"
- virtual void validate(LaTeXFeatures & features) const;
+ virtual void validate(LaTeXFeatures &) const {}
/// char char code if possible
virtual void handleFont(string const &) {}
/// is this inset equal to a given other inset?
virtual int dispatch(string const & cmd, idx_type idx, pos_type pos);
/// LyXInset stuff
- virtual std::vector<string> getLabelList() const;
+ /// write labels into a list
+ virtual void getLabelList(std::vector<string> &) const {}
/// LyXInset stuff
virtual bool numberedType() const { return false; }
/// hull type
int y2 = c.yo() + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
- vector<MathInset::idx_type> indices = idxBetween(idx1, idx2);
- for (unsigned i = 0; i < indices.size(); ++i) {
- MathXArray const & c = xcell(indices[i]);
- int x1 = c.xo();
- int y1 = c.yo() - c.ascent();
- int x2 = c.xo() + c.width();
- int y2 = c.yo() + c.descent();
- pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
+ for (idx_type i = 0; i < nargs(); ++i) {
+ if (idxBetween(i, idx1, idx2)) {
+ MathXArray const & c = xcell(i);
+ int x1 = c.xo();
+ int y1 = c.yo() - c.ascent();
+ int x2 = c.xo() + c.width();
+ int y2 = c.yo() + c.descent();
+ pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
+ }
}
}
}