62 files changed:
{
arrays_.clear();
insets_.clear();
{
arrays_.clear();
insets_.clear();
- slices0_.clear();
- slices1_.clear();
lyxerr << "InsetCache contains:" << std::endl;
for (CoordCacheBase<Inset>::cache_type::const_iterator it = getInsets().getData().begin(); it != getInsets().getData().end(); ++it) {
Inset const * inset = it->first;
lyxerr << "InsetCache contains:" << std::endl;
for (CoordCacheBase<Inset>::cache_type::const_iterator it = getInsets().getData().begin(); it != getInsets().getData().end(); ++it) {
Inset const * inset = it->first;
- Point const p = it->second;
+ Point const p = it->second.pos;
lyxerr << "Inset " << inset << "(" << to_utf8(inset->name())
<< ") has point " << p.x_ << "," << p.y_ << std::endl;
}
lyxerr << "Inset " << inset << "(" << to_utf8(inset->name())
<< ") has point " << p.x_ << "," << p.y_ << std::endl;
}
// It seems that MacOSX define the check macro.
#undef check
// It seems that MacOSX define the check macro.
#undef check
+#include "Dimension.h"
+
#include "support/types.h"
#include <map>
#include "support/types.h"
#include <map>
+
+struct Geometry {
+ Point pos;
+ Dimension dim;
+};
+
+
template <class T> class CoordCacheBase {
public:
void clear()
template <class T> class CoordCacheBase {
public:
void clear()
void add(T const * thing, int x, int y)
{
void add(T const * thing, int x, int y)
{
- data_[thing] = Point(x, y);
+ data_[thing].pos = Point(x, y);
+ }
+
+ void add(T const * thing, Dimension const & dim)
+ {
+ data_[thing].dim = dim;
+ }
+
+ Dimension const & dim(T const * thing) const
+ {
+ //check(thing, "dim");
+ return data_.find(thing)->second.dim;
}
int x(T const * thing) const
{
check(thing, "x");
}
int x(T const * thing) const
{
check(thing, "x");
- return data_.find(thing)->second.x_;
+ return data_.find(thing)->second.pos.x_;
}
int y(T const * thing) const
{
check(thing, "y");
}
int y(T const * thing) const
{
check(thing, "y");
- return data_.find(thing)->second.y_;
+ return data_.find(thing)->second.pos.y_;
}
Point xy(T const * thing) const
{
check(thing, "xy");
}
Point xy(T const * thing) const
{
check(thing, "xy");
- return data_.find(thing)->second;
+ return data_.find(thing)->second.pos;
}
bool has(T const * thing) const
}
bool has(T const * thing) const
lyxbreaker(thing, hint, data_.size());
}
lyxbreaker(thing, hint, data_.size());
}
- typedef std::map<T const *, Point> cache_type;
+ typedef std::map<T const *, Geometry> cache_type;
cache_type data_;
public:
cache_type data_;
public:
- /// A map from paragraph index number to screen point
- typedef std::map<pit_type, Point> InnerParPosCache;
- /// A map from a CursorSlice to screen points
- typedef std::map<Text const *, InnerParPosCache> SliceCache;
-
/// A map from MathData to position on the screen
CoordCacheBase<MathData> & arrays() { return arrays_; }
CoordCacheBase<MathData> const & getArrays() const { return arrays_; }
/// A map from insets to positions on the screen
CoordCacheBase<Inset> & insets() { return insets_; }
CoordCacheBase<Inset> const & getInsets() const { return insets_; }
/// A map from MathData to position on the screen
CoordCacheBase<MathData> & arrays() { return arrays_; }
CoordCacheBase<MathData> const & getArrays() const { return arrays_; }
/// A map from insets to positions on the screen
CoordCacheBase<Inset> & insets() { return insets_; }
CoordCacheBase<Inset> const & getInsets() const { return insets_; }
- ///
- SliceCache & slice(bool boundary)
- {
- return boundary ? slices1_ : slices0_;
- }
- SliceCache const & getSlice(bool boundary) const
- {
- return boundary ? slices1_ : slices0_;
- }
/// Dump the contents of the cache to lyxerr in debugging form
void dump() const;
/// Dump the contents of the cache to lyxerr in debugging form
void dump() const;
CoordCacheBase<MathData> arrays_;
// All insets
CoordCacheBase<Inset> insets_;
CoordCacheBase<MathData> arrays_;
// All insets
CoordCacheBase<Inset> insets_;
- /// Used with boundary == 0
- SliceCache slices0_;
- /// Used with boundary == 1
- SliceCache slices1_;
int xo;
int yo;
Inset const * inset = &it.inset();
int xo;
int yo;
Inset const * inset = &it.inset();
- std::map<Inset const *, Point> const & data =
+ std::map<Inset const *, Geometry> const & data =
c.bv().coordCache().getInsets().getData();
c.bv().coordCache().getInsets().getData();
- std::map<Inset const *, Point>::const_iterator I = data.find(inset);
+ std::map<Inset const *, Geometry>::const_iterator I = data.find(inset);
// FIXME: in the case where the inset is not in the cache, this
// means that no part of it is visible on screen. In this case
// FIXME: in the case where the inset is not in the cache, this
// means that no part of it is visible on screen. In this case
+ Point o = I->second.pos;
inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
// Convert to absolute
xo += o.x_;
inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
// Convert to absolute
xo += o.x_;
#include "frontends/Painter.h"
#include "support/convert.h"
#include "frontends/Painter.h"
#include "support/convert.h"
-#include "support/ExceptionMessage.h"
#include <boost/current_function.hpp>
#include <boost/current_function.hpp>
-Dimension const Inset::dimension(BufferView const &) const
+Dimension const Inset::dimension(BufferView const & bv) const
- docstring const id = convert<docstring>(int(lyxCode())) + " " + name();
- throw support::ExceptionMessage(support::ErrorException,
- _("Inset::dimension(): unimplemented method"), id);
+ return bv.coordCache().getInsets().dim(this);
+void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
+{
+ mi.base.bv->coordCache().insets().add(this, dim);
+}
+
+
+
/////////////////////////////////////////
bool isEditableInset(Inset const * inset)
/////////////////////////////////////////
bool isEditableInset(Inset const * inset)
int yo(BufferView const & bv) const;
/// set x/y drawing position cache if available
virtual void setPosCache(PainterInfo const &, int, int) const;
int yo(BufferView const & bv) const;
/// set x/y drawing position cache if available
virtual void setPosCache(PainterInfo const &, int, int) const;
+ ///
+ void setDimCache(MetricsInfo const &, Dimension const &) const;
/// do we cover screen position x/y?
virtual bool covers(BufferView const & bv, int x, int y) const;
/// get the screen positions of the cursor (see note in Cursor.cpp)
/// do we cover screen position x/y?
virtual bool covers(BufferView const & bv, int x, int y) const;
/// get the screen positions of the cursor (see note in Cursor.cpp)
dim.wid = fm.width(ds);
if (kind_ == HYPHENATION && dim.wid > 5)
dim.wid -= 2; // to make it look shorter
dim.wid = fm.width(ds);
if (kind_ == HYPHENATION && dim.wid > 5)
dim.wid -= 2; // to make it look shorter
+
+ setDimCache(mi, dim);
button_.update(screenLabel(), true);
}
button_.metrics(mi, dim);
button_.update(screenLabel(), true);
}
button_.metrics(mi, dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
ArrayChanger dummy(mi.base);
InsetMathGrid::metrics(mi, dim);
dim.wid += 14;
ArrayChanger dummy(mi.base);
InsetMathGrid::metrics(mi, dim);
dim.wid += 14;
+}
+
+
+Dimension const InsetMathAMSArray::dimension(BufferView const & bv) const
+{
+ Dimension dim = InsetMathGrid::dimension(bv);
+ dim.wid += 14;
+ return dim;
}
void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const
{
- int const yy = y - dim_.ascent();
+ Dimension const dim = dimension(*pi.base.bv);
+ int const yy = y - dim.ascent();
// Drawing the deco after an ArrayChanger does not work
// Drawing the deco after an ArrayChanger does not work
- mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), from_ascii(name_left()));
- mathed_draw_deco(pi, x + dim_.width() - 8, yy, 5, dim_.height(), from_ascii(name_right()));
+ mathed_draw_deco(pi, x + 1, yy, 5, dim.height(), from_ascii(name_left()));
+ mathed_draw_deco(pi, x + dim.width() - 8, yy, 5, dim.height(), from_ascii(name_right()));
ArrayChanger dummy(pi.base);
InsetMathGrid::drawWithMargin(pi, x, y, 6, 8);
}
ArrayChanger dummy(pi.base);
InsetMathGrid::drawWithMargin(pi, x, y, 6, 8);
}
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
+ Dimension const dimension(BufferView const &) const;
+ ///
void draw(PainterInfo & pain, int x, int y) const;
///
InsetMathAMSArray * asAMSArrayInset() { return this; }
void draw(PainterInfo & pain, int x, int y) const;
///
InsetMathAMSArray * asAMSArrayInset() { return this; }
ArrayChanger dummy(mi.base);
InsetMathGrid::metrics(mi, dim);
dim.wid += 6;
ArrayChanger dummy(mi.base);
InsetMathGrid::metrics(mi, dim);
dim.wid += 6;
+}
+
+
+Dimension const InsetMathArray::dimension(BufferView const & bv) const
+{
+ Dimension dim = InsetMathGrid::dimension(bv);
+ dim.wid += 6;
+ return dim;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
+ Dimension const dimension(BufferView const &) const;
+ ///
void draw(PainterInfo & pi, int x, int y) const;
///
InsetMathArray * asArrayInset() { return this; }
void draw(PainterInfo & pi, int x, int y) const;
///
InsetMathArray * asArrayInset() { return this; }
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- Dimension const dimension(BufferView const &) const { return dim_; };
- ///
void draw(PainterInfo & pi, int x, int y) const;
///
void write(WriteStream & os) const;
void draw(PainterInfo & pi, int x, int y) const;
///
void write(WriteStream & os) const;
-int InsetMathBinom::dw() const
+int InsetMathBinom::dw(int height) const
- int w = dim_.height() / 5;
if (w > 15)
w = 15;
if (w < 6)
if (w > 15)
w = 15;
if (w < 6)
cell(1).metrics(mi);
dim.asc = cell(0).height() + 4 + 5;
dim.des = cell(1).height() + 4 - 5;
cell(1).metrics(mi);
dim.asc = cell(0).height() + 4 + 5;
dim.des = cell(1).height() + 4 - 5;
- dim.wid = std::max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
+ dim.wid = std::max(cell(0).width(), cell(1).width()) + 2 * dw(dim.height()) + 4;
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
{
- int m = x + dim_.width() / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.width() / 2;
ScriptChanger dummy(pi.base);
cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5);
ScriptChanger dummy(pi.base);
cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5);
- mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), from_ascii("("));
- mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(),
- dw(), dim_.height(), from_ascii(")"));
+ mathed_draw_deco(pi, x, y - dim.ascent(), dw(dim.height()), dim.height(), from_ascii("("));
+ mathed_draw_deco(pi, x + dim.width() - dw(dim.height()), y - dim.ascent(),
+ dw(dim.height()), dim.height(), from_ascii(")"));
drawMarkers2(pi, x, y);
}
drawMarkers2(pi, x, y);
}
private:
virtual Inset * clone() const;
///
private:
virtual Inset * clone() const;
///
+ int dw(int height) const;
cell(0).metrics(mi, dim);
metricsMarkers(dim);
++dim.wid; // for 'double stroke'
cell(0).metrics(mi, dim);
metricsMarkers(dim);
++dim.wid; // for 'double stroke'
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
void InsetMathBoldSymbol::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
{
void InsetMathBoldSymbol::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
{
- cell(0).metricsT(mi, dim_);
+ // FIXME: BROKEN!
+ Dimension dim;
+ cell(0).metricsT(mi, dim);
FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi, dim);
metricsMarkers(dim);
FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
{
cell(0).metrics(mi, dim);
metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space
{
cell(0).metrics(mi, dim);
metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) const
{
- pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
- dim_.width() - 2, dim_.height() - 2, Color::foreground);
+ Dimension const dim = dimension(*pi.base.bv);
+ pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
+ dim.width() - 2, dim.height() - 2, Color::foreground);
cell(0).draw(pi, x + 3, y);
setPosCache(pi, x, y);
}
cell(0).draw(pi, x + 3, y);
setPosCache(pi, x, y);
}
dim.des = std::max(cell(0).descent(), t.des);
dim.wid = cell(0).width() + 2 * t.wid;
metricsMarkers(dim);
dim.des = std::max(cell(0).descent(), t.des);
dim.wid = cell(0).width() + 2 * t.wid;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
{
void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
{
- InsetMathGrid::metrics(mi);
- dim_.wid += 8;
- dim = dim_;
+ InsetMathGrid::metrics(mi, dim);
+ dim.wid += 8;
+}
+
+
+Dimension const InsetMathCases::dimension(BufferView const & bv) const
+{
+ Dimension dim = InsetMathGrid::dimension(bv);
+ dim.wid += 8;
+ return dim;
}
void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
{
- mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 6, dim_.height(), from_ascii("{"));
+ Dimension const dim = dimension(*pi.base.bv);
+ mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), from_ascii("{"));
InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
setPosCache(pi, x, y);
}
InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
setPosCache(pi, x, y);
}
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
+ Dimension const dimension(BufferView const &) const;
+ ///
void draw(PainterInfo & pi, int x, int y) const;
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
void draw(PainterInfo & pi, int x, int y) const;
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
lyxerr << "InsetMathChar::metrics: " << dim << endl;
#endif
// Cache the inset dimension.
lyxerr << "InsetMathChar::metrics: " << dim << endl;
#endif
// Cache the inset dimension.
- // FIXME: put the resulting dim in BufferView.
- dim_ = dim;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- Dimension const dimension(BufferView const &) const { return dim_; }
- ///
void draw(PainterInfo & pi, int x, int y) const;
///
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
void draw(PainterInfo & pi, int x, int y) const;
///
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2;
dim.asc = cell(0).height() + 2 + 5;
dim.des = cell(1).height() + 2 - 5;
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2;
dim.asc = cell(0).height() + 2 + 5;
dim.des = cell(1).height() + 2 - 5;
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathDFrac::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathDFrac::draw(PainterInfo & pi, int x, int y) const
{
- int m = x + dim_.wid / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.wid / 2;
cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5);
cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5);
- pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, Color::math);
+ pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color::math);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
dim.wid = cell(0).width() + 2 * dw_ + 8;
dim.asc = max(a0, d0) + h0;
dim.des = max(a0, d0) - h0;
dim.wid = cell(0).width() + 2 * dw_ + 8;
dim.asc = max(a0, d0) + h0;
dim.des = max(a0, d0) - h0;
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathDelim::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathDelim::draw(PainterInfo & pi, int x, int y) const
{
- int const b = y - dim_.asc;
+ Dimension const dim = dimension(*pi.base.bv);
+ int const b = y - dim.asc;
cell(0).draw(pi, x + dw_ + 4, y);
cell(0).draw(pi, x + dw_ + 4, y);
- mathed_draw_deco(pi, x + 4, b, dw_, dim_.height(), left_);
- mathed_draw_deco(pi, x + dim_.width() - dw_ - 4,
- b, dw_, dim_.height(), right_);
+ mathed_draw_deco(pi, x + 4, b, dw_, dim.height(), left_);
+ mathed_draw_deco(pi, x + dim.width() - dw_ - 4,
+ b, dw_, dim.height(), right_);
}
else if (key_->name == "ddots")
dh_ = dim.asc;
}
else if (key_->name == "ddots")
dh_ = dim.asc;
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathDots::draw(PainterInfo & pain, int x, int y) const
{
}
void InsetMathDots::draw(PainterInfo & pain, int x, int y) const
{
- mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
+ Dimension const dim = dimension(*pain.base.bv);
+ mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
key_->name);
if (key_->name == "vdots" || key_->name == "ddots")
++x;
if (key_->name != "vdots")
--y;
key_->name);
if (key_->name == "vdots" || key_->name == "ddots")
++x;
if (key_->name != "vdots")
--y;
- mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
+ mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
key_->name);
setPosCache(pain, x, y);
}
key_->name);
setPosCache(pain, x, y);
}
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- Dimension const dimension(BufferView const &) const { return dim_; };
- ///
void draw(PainterInfo & pi, int x, int y) const;
///
docstring name() const;
void draw(PainterInfo & pi, int x, int y) const;
///
docstring name() const;
latexkeys const * key_;
private:
virtual Inset * clone() const;
latexkeys const * key_;
private:
virtual Inset * clone() const;
- ///
- mutable Dimension dim_;
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
{
mathed_string_dim(mi.base.font, name_, dim);
void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
{
mathed_string_dim(mi.base.font, name_, dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi, dim);
metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space
FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi, dim);
metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathFBox::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathFBox::draw(PainterInfo & pi, int x, int y) const
{
- pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
- dim_.width() - 2, dim_.height() - 2, Color::foreground);
+ Dimension const dim = dimension(*pi.base.bv);
+ pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
+ dim.width() - 2, dim.height() - 2, Color::foreground);
FontSetChanger dummy(pi.base, "textnormal");
cell(0).draw(pi, x + 3, y);
setPosCache(pi, x, y);
FontSetChanger dummy(pi.base, "textnormal");
cell(0).draw(pi, x + 3, y);
setPosCache(pi, x, y);
FontSetChanger dummy(mi.base, key_->name);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
FontSetChanger dummy(mi.base, key_->name);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
{
void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
{
- cell(0).metricsT(mi, dim_);
+ // FIXME: BROKEN!
+ Dimension dim;
+ cell(0).metricsT(mi, dim);
FontSetChanger dummy(mi.base, key_->name.c_str());
cell(0).metrics(mi, dim);
metricsMarkers(dim);
FontSetChanger dummy(mi.base, key_->name.c_str());
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
{
setPosCache(pi, x, y);
}
void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
{
setPosCache(pi, x, y);
- int m = x + dim_.wid / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.wid / 2;
if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
if (nargs() == 1) {
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
if (nargs() == 1) {
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
if (nargs() == 3)
xx += cell(2).width() + 5;
pi.pain.line(xx + cell(0).width(),
if (nargs() == 3)
xx += cell(2).width() + 5;
pi.pain.line(xx + cell(0).width(),
xx + cell(0).width() + 5,
xx + cell(0).width() + 5,
- y - dim_.asc + 2, Color::math);
+ y - dim.asc + 2, Color::math);
}
if (kind_ == FRAC || kind_ == OVER)
pi.pain.line(x + 1, y - 5,
}
if (kind_ == FRAC || kind_ == OVER)
pi.pain.line(x + 1, y - 5,
- x + dim_.wid - 2, y - 5, Color::math);
+ x + dim.wid - 2, y - 5, Color::math);
dim.wid = std::max(cell(0).width(), cell(1).width());
dim.asc = cell(0).height() + 1;
dim.des = cell(1).height();
dim.wid = std::max(cell(0).width(), cell(1).width());
dim.asc = cell(0).height() + 1;
dim.des = cell(1).height();
}
void InsetMathFrac::drawT(TextPainter & pain, int x, int y) const
{
}
void InsetMathFrac::drawT(TextPainter & pain, int x, int y) const
{
- int m = x + dim_.width() / 2;
+ // FIXME: BROKEN!
+ Dimension dim;
+ int m = x + dim.width() / 2;
cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1);
cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent());
// ASCII art: ignore niceties
if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC || kind_ == UNITFRAC)
cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1);
cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent());
// ASCII art: ignore niceties
if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC || kind_ == UNITFRAC)
- pain.horizontalLine(x, y, dim_.width());
+ pain.horizontalLine(x, y, dim.width());
dim += cell(1).dim();
dim += cell(2).dim();
metricsMarkers(dim);
dim += cell(1).dim();
dim += cell(2).dim();
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
{
FontSetChanger dummy(pi.base, "textnormal");
}
void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
{
FontSetChanger dummy(pi.base, "textnormal");
- pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
- dim_.width() - 2, dim_.height() - 2, Color::foreground);
+ Dimension const dim = dimension(*pi.base.bv);
+ pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
+ dim.width() - 2, dim.height() - 2, Color::foreground);
x += 5;
drawStrBlack(pi, x, y, from_ascii("["));
x += 5;
drawStrBlack(pi, x, y, from_ascii("["));
-void InsetMathGrid::metrics(MetricsInfo & mi) const
+void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
{
// let the cells adjust themselves
InsetMathNest::metrics(mi);
{
// let the cells adjust themselves
InsetMathNest::metrics(mi);
- dim_.wid = colinfo_[ncols() - 1].offset_
+ dim.wid = colinfo_[ncols() - 1].offset_
+ colinfo_[ncols() - 1].width_
+ vlinesep() * colinfo_[ncols()].lines_
+ border();
+ colinfo_[ncols() - 1].width_
+ vlinesep() * colinfo_[ncols()].lines_
+ border();
- dim_.asc = - rowinfo_[0].offset_
+ dim.asc = - rowinfo_[0].offset_
+ rowinfo_[0].ascent_
+ hlinesep() * rowinfo_[0].lines_
+ border();
+ rowinfo_[0].ascent_
+ hlinesep() * rowinfo_[0].lines_
+ border();
- dim_.des = rowinfo_[nrows() - 1].offset_
+ dim.des = rowinfo_[nrows() - 1].offset_
+ rowinfo_[nrows() - 1].descent_
+ hlinesep() * rowinfo_[nrows()].lines_
+ border();
+ rowinfo_[nrows() - 1].descent_
+ hlinesep() * rowinfo_[nrows()].lines_
+ border();
cxrow->setBaseline(cxrow->getBaseline() - ascent);
}
*/
cxrow->setBaseline(cxrow->getBaseline() - ascent);
}
*/
- metricsMarkers2(dim_);
-}
-
-
-void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- metrics(mi);
- dim = dim_;
+ metricsMarkers2(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
drawWithMargin(pi, x, y, 0, 0);
}
drawWithMargin(pi, x, y, 0, 0);
}
void InsetMathGrid::drawWithMargin(PainterInfo & pi, int x, int y,
int lmargin, int rmargin) const
{
void InsetMathGrid::drawWithMargin(PainterInfo & pi, int x, int y,
int lmargin, int rmargin) const
{
+ Dimension const dim = dimension(*pi.base.bv);
+
for (idx_type idx = 0; idx < nargs(); ++idx)
cell(idx).draw(pi, x + lmargin + cellXOffset(idx),
y + cellYOffset(idx));
for (idx_type idx = 0; idx < nargs(); ++idx)
cell(idx).draw(pi, x + lmargin + cellXOffset(idx),
y + cellYOffset(idx));
int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
- i * hlinesep() - hlinesep()/2 - rowsep()/2;
pi.pain.line(x + lmargin + 1, yy,
int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
- i * hlinesep() - hlinesep()/2 - rowsep()/2;
pi.pain.line(x + lmargin + 1, yy,
- x + dim_.width() - rmargin - 1, yy,
+ x + dim.width() - rmargin - 1, yy,
for (unsigned int i = 0; i < colinfo_[col].lines_; ++i) {
int xx = x + lmargin + colinfo_[col].offset_
- i * vlinesep() - vlinesep()/2 - colsep()/2;
for (unsigned int i = 0; i < colinfo_[col].lines_; ++i) {
int xx = x + lmargin + colinfo_[col].offset_
- i * vlinesep() - vlinesep()/2 - colsep()/2;
- pi.pain.line(xx, y - dim_.ascent() + 1,
- xx, y + dim_.descent() - 1,
+ pi.pain.line(xx, y - dim.ascent() + 1,
+ xx, y + dim.descent() - 1,
Color::foreground);
}
drawMarkers2(pi, x, y);
Color::foreground);
}
drawMarkers2(pi, x, y);
///
InsetMathGrid(col_type m, row_type n, char valign, docstring const & halign);
///
///
InsetMathGrid(col_type m, row_type n, char valign, docstring const & halign);
///
- void metrics(MetricsInfo & mi) const;
- ///
void metrics(MetricsInfo & mi, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
void metrics(MetricsInfo & mi, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
dim.wid += 1;
if (display())
dim.des += displayMargin();
dim.wid += 1;
if (display())
dim.des += displayMargin();
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
math_font_max_dim(mi.base.font, asc, des);
dim.asc = max(dim.asc, asc);
dim.des = max(dim.des, des);
math_font_max_dim(mi.base.font, asc, des);
dim.asc = max(dim.asc, asc);
dim.des = max(dim.des, des);
+ // Cache the inset dimension.
+ // FIXME: This will overwrite InsetMathGrid dimension, is that OK?
+ setDimCache(mi, dim);
}
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
{
use_preview_ = previewState(pi.base.bv);
}
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
{
use_preview_ = previewState(pi.base.bv);
+ Dimension const dim = dimension(*pi.base.bv);
// background of mathed under focus is not painted because
// selection at the top level of nested inset is difficult to handle.
if (!editing(pi.base.bv))
// background of mathed under focus is not painted because
// selection at the top level of nested inset is difficult to handle.
if (!editing(pi.base.bv))
- pi.pain.fillRectangle(x + 1, y - dim_.asc + 1, dim_.wid - 2,
- dim_.asc + dim_.des - 1, Color::mathbg);
+ pi.pain.fillRectangle(x + 1, y - dim.asc + 1, dim.wid - 2,
+ dim.asc + dim.des - 1, Color::mathbg);
if (use_preview_) {
// one pixel gap in front
if (use_preview_) {
// one pixel gap in front
dim.des += 2;
dim.wid = 4;
metricsMarkers(dim);
dim.des += 2;
dim.wid = 4;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
dim += cell(2).dim();
dim.wid += 4 * w_ + 4;
metricsMarkers(dim);
dim += cell(2).dim();
dim.wid += 4 * w_ + 4;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
/// the size is usually some sort of convex hull of the cells
/// hides inset::metrics() intentionally!
void metrics(MetricsInfo const & mi) const;
/// the size is usually some sort of convex hull of the cells
/// hides inset::metrics() intentionally!
void metrics(MetricsInfo const & mi) const;
- ///
- Dimension const dimension(BufferView const &) const { return dim_; };
/// draw background if locked
void draw(PainterInfo & pi, int x, int y) const;
/// draw selection background
/// draw background if locked
void draw(PainterInfo & pi, int x, int y) const;
/// draw selection background
bool lock_;
///
bool mouse_hover_;
bool lock_;
///
bool mouse_hover_;
- /// Cached dimensions of the inset.
- mutable Dimension dim_;
dim.asc = cell(1).ascent() + cell(0).height() + 4;
dim.des = cell(1).descent();
metricsMarkers(dim);
dim.asc = cell(1).ascent() + cell(0).height() + 4;
dim.des = cell(1).descent();
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathOverset::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathOverset::draw(PainterInfo & pi, int x, int y) const
{
- int m = x + dim_.wid / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.wid / 2;
int yo = y - cell(1).ascent() - cell(0).descent() - 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
int yo = y - cell(1).ascent() - cell(0).descent() - 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
void InsetMathPar::metrics(MetricsInfo & mi, Dimension & dim) const
{
FontSetChanger dummy1(mi.base, "textnormal");
void InsetMathPar::metrics(MetricsInfo & mi, Dimension & dim) const
{
FontSetChanger dummy1(mi.base, "textnormal");
- InsetMathGrid::metrics(mi);
- dim = dim_;
+ InsetMathGrid::metrics(mi, dim);
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
pi.base.font.setColor(Color::special);
cell(0).draw(pi, x + 1, y);
pi.base.font.setColor(origcol);
pi.base.font.setColor(Color::special);
cell(0).draw(pi, x + 1, y);
pi.base.font.setColor(origcol);
+ Dimension const dim = dimension(*pi.base.bv);
if (kind_ == phantom || kind_ == vphantom) {
// y1---------
if (kind_ == phantom || kind_ == vphantom) {
// y1---------
- int const x2 = x + dim_.wid / 2;
+ int const x2 = x + dim.wid / 2;
int const x1 = x2 - arrow_size;
int const x3 = x2 + arrow_size;
int const x1 = x2 - arrow_size;
int const x3 = x2 + arrow_size;
- int const y1 = y - dim_.asc;
+ int const y1 = y - dim.asc;
int const y2 = y1 + arrow_size;
int const y2 = y1 + arrow_size;
- int const y4 = y + dim_.des;
+ int const y4 = y + dim.des;
int const y3 = y4 - arrow_size;
// top arrow
int const y3 = y4 - arrow_size;
// top arrow
int const x1 = x;
int const x2 = x + arrow_size;
int const x1 = x;
int const x2 = x + arrow_size;
- int const x4 = x + dim_.wid;
+ int const x4 = x + dim.wid;
int const x3 = x4 - arrow_size;
int const x3 = x4 - arrow_size;
- int const y2 = y + (dim_.des - dim_.asc) / 2;
+ int const y2 = y + (dim.des - dim.asc) / 2;
int const y1 = y2 - arrow_size;
int const y3 = y2 + arrow_size;
int const y1 = y2 - arrow_size;
int const y3 = y2 + arrow_size;
dim.des = max(cell(0).descent() - 5, cell(1).descent()) + 2;
dim.wid = cell(0).width() + cell(1).width() + 10;
metricsMarkers(dim);
dim.des = max(cell(0).descent() - 5, cell(1).descent()) + 2;
dim.wid = cell(0).width() + cell(1).width() + 10;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
cell(0).draw(pi, x, y - 5 - cell(0).descent());
// the "base"
cell(1).draw(pi, x + w + 8, y);
cell(0).draw(pi, x, y - 5 - cell(0).descent());
// the "base"
cell(1).draw(pi, x + w + 8, y);
- int const a = dim_.ascent();
- int const d = dim_.descent();
+ Dimension const dim = dimension(*pi.base.bv);
+ int const a = dim.ascent();
+ int const d = dim.descent();
- pi.pain.line(x + dim_.width(), y - a + 1,
+ pi.pain.line(x + dim.width(), y - a + 1,
x + w + 4, y - a + 1, Color::math);
xp[0] = x + w + 4; yp[0] = y - a + 1;
xp[1] = x + w; yp[1] = y + d;
x + w + 4, y - a + 1, Color::math);
xp[0] = x + w + 4; yp[0] = y - a + 1;
xp[1] = x + w; yp[1] = y + d;
-int InsetMathScript::dx0() const
+int InsetMathScript::dx0(BufferView const & bv) const
{
BOOST_ASSERT(hasDown());
{
BOOST_ASSERT(hasDown());
- return hasLimits() ? (dim_.wid - down().width()) / 2 : nwid();
+ Dimension const dim = dimension(bv);
+ return hasLimits() ? (dim.wid - down().width()) / 2 : nwid();
-int InsetMathScript::dx1() const
+int InsetMathScript::dx1(BufferView const & bv) const
- return hasLimits() ? (dim_.wid - up().width()) / 2 : nwid() + nker();
+ Dimension const dim = dimension(bv);
+ return hasLimits() ? (dim.wid - up().width()) / 2 : nwid() + nker();
-int InsetMathScript::dxx() const
+int InsetMathScript::dxx(BufferView const & bv) const
- return hasLimits() ? (dim_.wid - nwid()) / 2 : 0;
+ Dimension const dim = dimension(bv);
+ return hasLimits() ? (dim.wid - nwid()) / 2 : 0;
} else
dim.des = nd;
metricsMarkers(dim);
} else
dim.des = nd;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathScript::draw(PainterInfo & pi, int x, int y) const
{
if (nuc().size())
}
void InsetMathScript::draw(PainterInfo & pi, int x, int y) const
{
if (nuc().size())
- nuc().draw(pi, x + dxx(), y);
+ nuc().draw(pi, x + dxx(*pi.base.bv), y);
- nuc().setXY(*pi.base.bv, x + dxx(), y);
+ nuc().setXY(*pi.base.bv, x + dxx(*pi.base.bv), y);
- pi.draw(x + dxx(), y, char_type('.'));
+ pi.draw(x + dxx(*pi.base.bv), y, char_type('.'));
}
ScriptChanger dummy(pi.base);
if (hasUp())
}
ScriptChanger dummy(pi.base);
if (hasUp())
- up().draw(pi, x + dx1(), y - dy1());
+ up().draw(pi, x + dx1(*pi.base.bv), y - dy1());
- down().draw(pi, x + dx0(), y + dy0());
+ down().draw(pi, x + dx0(*pi.base.bv), y + dy0());
void InsetMathScript::drawT(TextPainter & pain, int x, int y) const
{
if (nuc().size())
void InsetMathScript::drawT(TextPainter & pain, int x, int y) const
{
if (nuc().size())
- nuc().drawT(pain, x + dxx(), y);
+ nuc().drawT(pain, x + 1, y);
- up().drawT(pain, x + dx1(), y - dy1());
+ up().drawT(pain, x + 1, y - dy1());
- down().drawT(pain, x + dx0(), y + dy0());
+ down().drawT(pain, x + 1, y + dy0());
private:
virtual Inset * clone() const;
/// returns x offset for main part
private:
virtual Inset * clone() const;
/// returns x offset for main part
+ int dxx(BufferView const & bv) const;
/// returns width of nucleus if any
int nwid() const;
/// returns y offset for either superscript or subscript
/// returns width of nucleus if any
int nwid() const;
/// returns y offset for either superscript or subscript
/// returns y offset for subscript
int dy1() const;
/// returns x offset for superscript
/// returns y offset for subscript
int dy1() const;
/// returns x offset for superscript
+ int dx0(BufferView const & bv) const;
/// returns x offset for subscript
/// returns x offset for subscript
+ int dx1(BufferView const & bv) const;
/// returns ascent of nucleus if any
int nasc() const;
/// returns descent of nucleus if any
/// returns ascent of nucleus if any
int nasc() const;
/// returns descent of nucleus if any
StyleChanger dummy(mi.base, style_);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
StyleChanger dummy(mi.base, style_);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
dim.des += 2;
dim.wid += 12;
metricsMarkers(dim);
dim.des += 2;
dim.wid += 12;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
{
cell(0).draw(pi, x + 10, y);
}
void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
{
cell(0).draw(pi, x + 10, y);
- int const a = dim_.ascent();
- int const d = dim_.descent();
+ Dimension const dim = dimension(*pi.base.bv);
+ int const a = dim.ascent();
+ int const d = dim.descent();
- pi.pain.line(x + dim_.width(), y - a + 1,
- x + 8, y - a + 1, Color::math);
+ pi.pain.line(x + dim.width(), y - a + 1,
+ x + 8, y - a + 1, Color::math);
xp[0] = x + 8; yp[0] = y - a + 1;
xp[1] = x + 5; yp[1] = y + d - 1;
xp[2] = x; yp[2] = y + (d - a)/2;
xp[0] = x + 8; yp[0] = y - a + 1;
xp[1] = x + 5; yp[1] = y + d - 1;
xp[2] = x; yp[2] = y + (d - a)/2;
dim.asc = cell(1).ascent() + cell(0).height() + 4;
dim.des = cell(1).descent();
metricsMarkers(dim);
dim.asc = cell(1).ascent() + cell(0).height() + 4;
dim.des = cell(1).descent();
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathStackrel::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathStackrel::draw(PainterInfo & pi, int x, int y) const
{
- int m = x + dim_.width() / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.width() / 2;
int yo = y - cell(1).ascent() - cell(0).descent() - 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
int yo = y - cell(1).ascent() - cell(0).descent() - 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
} else {
InsetMathGrid::metrics(mi, dim);
}
} else {
InsetMathGrid::metrics(mi, dim);
}
scriptable_ = true;
// Cache the inset dimension.
scriptable_ = true;
// Cache the inset dimension.
- // FIXME: put the resulting dim in BufferView.
- dim_ = dim;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- Dimension const dimension(BufferView const &) const { return dim_; }
- ///
void draw(PainterInfo &, int x, int y) const;
///
int kerning() const { return kerning_; }
void draw(PainterInfo &, int x, int y) const;
///
int kerning() const { return kerning_; }
mutable int kerning_;
///
mutable bool scriptable_;
mutable int kerning_;
///
mutable bool scriptable_;
- /// FIXME: move this out to BufferView
- mutable Dimension dim_;
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2;
dim.asc = cell(0).height() + 2 + 5;
dim.des = cell(1).height() + 2 - 5;
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2;
dim.asc = cell(0).height() + 2 + 5;
dim.des = cell(1).height() + 2 - 5;
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathTFrac::draw(PainterInfo & pi, int x, int y) const
{
StyleChanger dummy(pi.base, LM_ST_SCRIPT);
}
void InsetMathTFrac::draw(PainterInfo & pi, int x, int y) const
{
StyleChanger dummy(pi.base, LM_ST_SCRIPT);
- int m = x + dim_.wid / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.wid / 2;
cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5);
cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5);
- pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, Color::math);
+ pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color::math);
FontSetChanger dummy(mi.base, "textnormal");
InsetMathGrid::metrics(mi, dim);
dim.wid += 6;
FontSetChanger dummy(mi.base, "textnormal");
InsetMathGrid::metrics(mi, dim);
dim.wid += 6;
+}
+
+
+Dimension const InsetMathTabular::dimension(BufferView const & bv) const
+{
+ Dimension dim = InsetMathGrid::dimension(bv);
+ dim.wid += 6;
+ return dim;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
+ Dimension const dimension(BufferView const &) const;
+ ///
void draw(PainterInfo & pi, int x, int y) const;
///
InsetMathTabular * asTabularInset() { return this; }
void draw(PainterInfo & pi, int x, int y) const;
///
InsetMathTabular * asTabularInset() { return this; }
dim.asc = cell(1).ascent();
dim.des = cell(1).descent() + cell(0).height() + 4;
metricsMarkers(dim);
dim.asc = cell(1).ascent();
dim.des = cell(1).descent() + cell(0).height() + 4;
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
}
void InsetMathUnderset::draw(PainterInfo & pi, int x, int y) const
{
}
void InsetMathUnderset::draw(PainterInfo & pi, int x, int y) const
{
- int m = x + dim_.wid / 2;
+ Dimension const dim = dimension(*pi.base.bv);
+ int m = x + dim.wid / 2;
int yo = y + cell(1).descent() + cell(0).ascent() + 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
int yo = y + cell(1).descent() + cell(0).ascent() + 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
dim.asc = cell(0).height() + 10;
dim.des = cell(1).height();
metricsMarkers(dim);
dim.asc = cell(0).height() + 10;
dim.des = cell(1).height();
metricsMarkers(dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
ScriptChanger dummy(pi.base);
cell(0).draw(pi, x + 5, y - 10);
cell(1).draw(pi, x + 5, y + cell(1).height());
ScriptChanger dummy(pi.base);
cell(0).draw(pi, x + 5, y - 10);
cell(1).draw(pi, x + 5, y + cell(1).height());
- mathed_draw_deco(pi, x + 1, y - 7, dim_.wid - 2, 5, name_);
+ Dimension const dim = dimension(*pi.base.bv);
+ mathed_draw_deco(pi, x + 1, y - 7, dim.wid - 2, 5, name_);
if (mi.base.style == LM_ST_DISPLAY)
mi.base.style = LM_ST_TEXT;
InsetMathGrid::metrics(mi, dim);
if (mi.base.style == LM_ST_DISPLAY)
mi.base.style = LM_ST_TEXT;
InsetMathGrid::metrics(mi, dim);
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
} else if (editing_) {
Font font = pi.base.font;
augmentFont(font, from_ascii("lyxtex"));
} else if (editing_) {
Font font = pi.base.font;
augmentFont(font, from_ascii("lyxtex"));
- int h = y - dim_.ascent() + 2 + tmpl_.ascent();
+ Dimension const dim = dimension(*pi.base.bv);
+ int h = y - dim.ascent() + 2 + tmpl_.ascent();
pi.pain.text(x + 3, h, name(), font);
int const w = mathed_string_width(font, name());
tmpl_.draw(pi, x + w + 12, h);
pi.pain.text(x + 3, h, name(), font);
int const w = mathed_string_width(font, name());
tmpl_.draw(pi, x + w + 12, h);
if (lockMacro)
MacroTable::globalMacros().get(name_).unlock();
if (lockMacro)
MacroTable::globalMacros().get(name_).unlock();
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
+ Dimension const dim = dimension(*p.base.bv);
+
// label
Font font = p.base.font;
font.setColor(Color::math);
// label
Font font = p.base.font;
font.setColor(Color::math);
pi.base.style = LM_ST_TEXT;
pi.base.font = font;
pi.base.style = LM_ST_TEXT;
pi.base.font = font;
- int const a = y - dim_.asc + 1;
- int const w = dim_.wid - 2;
- int const h = dim_.height() - 2;
+ int const a = y - dim.asc + 1;
+ int const w = dim.wid - 2;
+ int const h = dim.height() - 2;
// Color::mathbg used to be "AntiqueWhite" but is "linen" now, too
// the next line would overwrite the selection!
// Color::mathbg used to be "AntiqueWhite" but is "linen" now, too
// the next line would overwrite the selection!
int const w0 = cell(0).width();
int const w1 = cell(1).width();
cell(0).draw(pi, x + 2, y + 1);
int const w0 = cell(0).width();
int const w1 = cell(1).width();
cell(0).draw(pi, x + 2, y + 1);
- pi.pain.rectangle(x, y - dim_.ascent() + 3,
- w0 + 4, dim_.height() - 6, Color::mathline);
+ pi.pain.rectangle(x, y - dim.ascent() + 3,
+ w0 + 4, dim.height() - 6, Color::mathline);
cell(1).draw(pi, x + 8 + w0, y + 1);
cell(1).draw(pi, x + 8 + w0, y + 1);
- pi.pain.rectangle(x + w0 + 6, y - dim_.ascent() + 3,
- w1 + 4, dim_.height() - 6, Color::mathline);
+ pi.pain.rectangle(x + w0 + 6, y - dim.ascent() + 3,
+ w1 + 4, dim.height() - 6, Color::mathline);
if (lockMacro)
MacroTable::globalMacros().get(name_).unlock();
if (lockMacro)
MacroTable::globalMacros().get(name_).unlock();