math_biginset.h \
math_binominset.C \
math_binominset.h \
- math_braceinset.C \
- math_braceinset.h \
math_boxinset.C \
math_boxinset.h \
- math_binaryopinset.C \
- math_binaryopinset.h \
+ math_braceinset.C \
+ math_braceinset.h \
math_casesinset.C \
math_casesinset.h \
math_charinset.C \
void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const
{
- int x = int(xx);
-
- Painter & pain = bv->painter();
-
metrics(bv, font);
+
+ int x = int(xx);
int w = par_->width();
int h = par_->height();
int a = par_->ascent();
+ Painter & pain = bv->painter();
if (lcolor.getX11Name(LColor::mathbg)!=lcolor.getX11Name(LColor::background))
pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
hideInsetCursor(bv);
mathcursor->normalize();
+ mathcursor->touch();
+
switch (action) {
// --- Cursor Movements ---------------------------------------------
}
mathcursor->normalize();
+ mathcursor->touch();
lyx::Assert(mathcursor);
#include "math_atom.h"
#include "math_inset.h"
-#include "support/LAssert.h"
#include <utility>
-using std::swap;
-
-
MathAtom::MathAtom()
: nucleus_(0)
{}
if (&p == this)
return;
MathAtom tmp(p);
- swap(tmp.nucleus_, nucleus_);
+ std::swap(tmp.nucleus_, nucleus_);
}
delete nucleus_;
nucleus_ = p;
}
-
-
-MathInset * MathAtom::nucleus() const
-{
- lyx::Assert(nucleus_);
- return nucleus_;
-}
-
-
-MathInset * MathAtom::operator->() const
-{
- return nucleus();
-}
void operator=(MathAtom const &);
/// change inset under the hood
void reset(MathInset * p);
+ /// access to the inset (checked with gprof)
+ MathInset * nucleus() const { return nucleus_; }
/// access to the inset
- MathInset * nucleus() const;
- /// access to the inset
- MathInset * operator->() const;
+ MathInset * operator->() const { return nucleus_; }
private:
///
}
+void MathCursor::touch()
+{
+ cursor_type::const_iterator it = Cursor_.begin();
+ cursor_type::const_iterator et = Cursor_.end();
+ for ( ; it != et; ++it)
+ it->xcell().touch();
+}
+
+
void MathCursor::normalize()
{
// rebreak
/// make sure cursor position is valid
void normalize();
+ /// mark current cursor trace for redraw
+ void touch();
///
UpdatableInset * asHyperActiveInset() const;
/// returns the normalized anchor of the selection
MathCursorPos normalAnchor() const;
- /// path of positions the cursor had to go if it were leving each inset
- cursor_type Cursor_;
- /// path of positions the anchor had to go if it were leving each inset
- mutable cursor_type Anchor_;
-
/// reference to the last item of the path, i.e. "The Cursor"
MathCursorPos & cursor();
/// reference to the last item of the path, i.e. "The Cursor"
/// write access to cursor cell index
idx_type & idx();
- ///
+ /// path of positions the cursor had to go if it were leving each inset
+ cursor_type Cursor_;
+ /// path of positions the anchor had to go if it were leving each inset
+ mutable cursor_type Anchor_;
+ /// pointer to enclsing LyX inset
InsetFormulaBase * formula_;
- ///
+ /// text code of last char entered
MathTextCodes lastcode_;
// Selection stuff
/// do we currently select
//{}
-MathCursorPos const & MathIterator::position() const
-{
- lyx::Assert(cursor_.size());
- return cursor_.back();
-}
-
-
-MathCursorPos & MathIterator::position()
-{
- lyx::Assert(cursor_.size());
- return cursor_.back();
-}
-
-
MathCursor::cursor_type const & MathIterator::cursor() const
{
return cursor_;
{
// move into the current inset if possible
// it is impossible for pos() == size()!
- if (nextInset() && nextInset()->isActive()) {
- push(nextInset());
+ MathInset * n = nextInset();
+ if (n && n->isActive()) {
+ push(n);
return;
}
// otherwise move on one cell position if possible
- if (position().pos_ < xcell().data_.size()) {
+ MathCursorPos & top = position();
+ if (top.pos_ < top.par_->cell(top.idx_).size()) {
// pos() == size() is valid!
- ++position().pos_;
+ ++top.pos_;
return;
}
// otherwise move on one cell if possible
- if (position().idx_ + 1 < par()->nargs()) {
+ if (top.idx_ + 1 < top.par_->nargs()) {
// idx() == nargs() is _not_ valid!
- ++position().idx_;
- position().pos_ = 0;
+ ++top.idx_;
+ top.pos_ = 0;
return;
}
// otherwise leave array, move on one position
// this might yield pos() == size(), but that's a ok.
- pop();
+ // it certainly invalidates top
+ pop();
++position().pos_;
}
void operator++();
/// move on several steps
void jump(MathInset::difference_type);
- /// read access to top most item
- MathCursorPos const & position() const;
+ /// read access to top most item (inline after running gprof!)
+ MathCursorPos const & position() const { return cursor_.back(); }
/// write access to top most item
- MathCursorPos & position();
+ MathCursorPos & position() { return cursor_.back(); }
/// read access to full path
MathCursor::cursor_type const & cursor() const;
/// read access to top most inset
whichFont(font, type, size);
if (isBinaryOp(c, type))
return lyxfont::width(c, font) + 2 * lyxfont::width(' ', font);
- else
- return lyxfont::width(c, font);
+ return lyxfont::width(c, font);
}
MathXArray::MathXArray()
- : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
+ : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_(),
+ clean_(false), drawn_(false)
{}
+void MathXArray::touch() const
+{
+ clean_ = false;
+ drawn_ = false;
+}
+
+
void MathXArray::metrics(MathMetricsInfo const & mi) const
{
- size_ = mi;
+ if (clean_)
+ return;
+
+ size_ = mi;
+ clean_ = true;
+ drawn_ = false;
if (data_.empty()) {
mathed_char_dim(LM_TC_VAR, mi, 'I', ascent_, descent_, width_);
void MathXArray::draw(Painter & pain, int x, int y) const
{
- xo_ = x;
- yo_ = y;
+ //if (drawn_ && x == xo_ && y == yo_)
+ // return;
+
+ xo_ = x;
+ yo_ = y;
+ drawn_ = true;
if (data_.empty()) {
pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
void metrics(MathMetricsInfo const & st) const;
/// redraw cell using cache metrics information
void draw(Painter & pain, int x, int y) const;
+ /// mark cell for re-drawing
+ void touch() const;
/// access to cached x coordinate of last drawing
int xo() const { return xo_; }
mutable int yo_;
/// cache size information of last drawing
mutable MathMetricsInfo size_;
+ /// cached cleaness of cell
+ mutable bool clean_;
+ /// cached draw status of cell
+ mutable bool drawn_;
};
/// output cell on a stream