}
-bool MathCursor::positionable(MathAtom const & t, int x, int y) const
-{
- if (selection_) {
- // we can't move into anything new during selection
- if (Cursor_.size() >= Anchor_.size())
- return false;
- if (t.nucleus() != Anchor_[Cursor_.size()].par_)
- return false;
- }
-
- //lyxerr << " positionable: 1 " << t->nargs() << "\n";
- //lyxerr << " positionable: 2 " << t->covers(x, y) << "\n";
- return t->nargs() && t->covers(x, y);
-}
-
-
bool MathCursor::posLeft()
{
if (pos() == 0)
}
-#if 0
-void MathCursor::setPos(int x, int y)
-{
- //dump("setPos 1");
- //lyxerr << "MathCursor::setPos x: " << x << " y: " << y << "\n";
-
- macroModeClose();
- lastcode_ = LM_TC_VAR;
- first();
-
- cursor().par_ = &formula_->par();
-
- while (1) {
- idx() = 0;
- cursor().pos_ = 0;
- //lyxerr << "found idx: " << idx() << " cursor: " << pos() << "\n";
- int distmin = 1 << 30; // large enough
- for (unsigned int i = 0; i < par()->nargs(); ++i) {
- MathXArray const & ar = par()->xcell(i);
- int d = ar.dist(x, y);
- if (d <= distmin) {
- distmin = d;
- idx() = i;
- pos() = ar.x2pos(x - ar.xo());
- }
- }
- //lyxerr << "found idx: " << idx() << " cursor: " << pos() << "\n";
- if (hasNextAtom() && positionable(nextAtom(), x, y))
- pushLeft(nextAtom());
- else if (hasPrevAtom() && positionable(prevAtom(), x, y))
- pushRight(prevAtom());
- else
- break;
- }
- //dump("setPos 2");
-}
-
-#else
void MathCursor::setPos(int x, int y)
{
dump("setPos 2");
}
-#endif
-
-
void MathCursor::home(bool sel)
void insert(char, MathTextCodes t);
/// can we enter the inset?
bool openable(MathAtom const &, bool selection) const;
- /// can the setPos routine enter that inset?
- bool positionable(MathAtom const &, int x, int y) const;
/// write access to cursor cell position
pos_type & pos();
/// write access to cursor cell index
}
-bool MathInset::covers(int, int) const
-{
- lyxerr << "MathInset::covers() called directly!\n";
- return false;
-}
-
-
void MathInset::validate(LaTeXFeatures &) const
{}
/// delete a given row
virtual void delCol(col_type) {}
- /// does this inset cover the pixel at (x,y)?
- virtual bool covers(int x, int y) const;
-
/// identifies certain types of insets
virtual MathArrayInset * asArrayInset() { return 0; }
virtual MathBoxInset * asBoxInset() { return 0; }
}
-bool MathNestInset::covers(int x, int y) const
-{
- if (!nargs())
- return false;
- int x0 = xcell(0).xo();
- int y0 = xcell(0).yo() - xcell(0).ascent();
- int x1 = xcell(0).xo() + xcell(0).width();
- int y1 = xcell(0).yo() + xcell(0).descent();
- for (idx_type i = 1; i < nargs(); ++i) {
- x0 = std::min(x0, xcell(i).xo());
- y0 = std::min(y0, xcell(i).yo() - xcell(i).ascent());
- x1 = std::max(x1, xcell(i).xo() + xcell(i).width());
- y1 = std::max(y1, xcell(i).yo() + xcell(i).descent());
- }
- //lyxerr << "xO: " << x0 << " x1: " << x1 << " "
- // << "yO: " << y0 << " y1: " << y1 << " "
- // << "x: " << x << " y: " << y << '\n';
- return x >= x0 && x <= x1 && y >= y0 && y <= y1;
-}
-
-
bool MathNestInset::match(MathInset * p) const
{
if (nargs() != p->nargs())
bool isActive() const { return nargs() > 0; }
/// request "external features"
void validate(LaTeXFeatures & features) const;
- /// do we cover the point (x,y)?
- bool covers(int x, int y) const;
/// match in all cells
bool match(MathInset *) const;
}
-bool MathScriptInset::covers(int x, int y) const
-{
- for (idx_type i = 0; i < 2; ++i)
- if (has(i) && xcell(i).covers(x, y))
- return true;
- return false;
-}
-
-
int MathScriptInset::dy0(MathInset const * nuc) const
{
int nd = ndes(nuc);
void removeEmptyScripts();
/// make sure a script is accessible
void ensure(bool up);
- /// only true if we are _in_ sub- or superscript, not in the convex hull
- bool covers(int x, int y) const;
// call these methods ...2 to make compaq cxx in anal mode happy...
/// suppresses empty braces if necessary
}
-bool MathXArray::covers(int x, int y) const
-{
- int const x0 = xo_;
- int const y0 = yo_ - ascent_;
- int const x1 = xo_ + width_;
- int const y1 = yo_ + descent_;
- return x >= x0 && x <= x1 && y >= y0 && y <= y1;
-}
-
-
void MathXArray::boundingBox(int & x1, int & x2, int & y1, int & y2)
{
x1 = xo_;
int height() const { return ascent_ + descent_; }
/// width of this cell
int width() const { return width_; }
- /// do we cover point(x, y)?
- bool covers(int x, int y) const;
/// bounding box of this cell
void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh);
/// find best position to do things