mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
replace (ascent, descent, width) triples by a structure 'dimension'
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4601 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d359dd8fca
commit
9b2be91bed
@ -19,14 +19,12 @@ void ButtonInset::metrics(MathMetricsInfo & mi) const
|
|||||||
MathFontSetChanger dummy(mi.base, "textnormal");
|
MathFontSetChanger dummy(mi.base, "textnormal");
|
||||||
if (editing()) {
|
if (editing()) {
|
||||||
MathNestInset::metrics(mi);
|
MathNestInset::metrics(mi);
|
||||||
width_ = xcell(0).width() + xcell(1).width() + 4;
|
dim_.w = xcell(0).width() + xcell(1).width() + 4;
|
||||||
ascent_ = max(xcell(0).ascent(), xcell(1).ascent());
|
dim_.a = max(xcell(0).ascent(), xcell(1).ascent());
|
||||||
descent_ = max(xcell(0).descent(), xcell(1).descent());
|
dim_.d = max(xcell(0).descent(), xcell(1).descent());
|
||||||
} else {
|
} else {
|
||||||
string s = screenLabel();
|
mathed_string_dim(mi.base.font, screenLabel(), dim_);
|
||||||
mathed_string_dim(mi.base.font,
|
dim_.w += 10;
|
||||||
s, ascent_, descent_, width_);
|
|
||||||
width_ += 10;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ public:
|
|||||||
int height() const { return a + d; }
|
int height() const { return a + d; }
|
||||||
/// get ascent
|
/// get ascent
|
||||||
int ascent() const { return a; }
|
int ascent() const { return a; }
|
||||||
|
/// get descent
|
||||||
|
int descent() const { return d; }
|
||||||
/// get width
|
/// get width
|
||||||
int width() const { return w; }
|
int width() const { return w; }
|
||||||
|
|
||||||
|
@ -62,16 +62,16 @@ void MathAMSArrayInset::metrics(MathMetricsInfo & mi) const
|
|||||||
if (m.base.style == LM_ST_DISPLAY)
|
if (m.base.style == LM_ST_DISPLAY)
|
||||||
m.base.style = LM_ST_TEXT;
|
m.base.style = LM_ST_TEXT;
|
||||||
MathGridInset::metrics(m);
|
MathGridInset::metrics(m);
|
||||||
width_ += 12;
|
dim_.w += 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathAMSArrayInset::draw(MathPainterInfo & pi, int x, int y) const
|
void MathAMSArrayInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
MathGridInset::draw(pi, x + 6, y);
|
MathGridInset::draw(pi, x + 6, y);
|
||||||
int yy = y - ascent_;
|
int const yy = y - ascent();
|
||||||
mathed_draw_deco(pi, x + 1, yy, 5, height(), name_left());
|
mathed_draw_deco(pi, x + 1, yy, 5, height(), name_left());
|
||||||
mathed_draw_deco(pi, x + width_ - 6, yy, 5, height(), name_right());
|
mathed_draw_deco(pi, x + width() - 6, yy, 5, height(), name_right());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,17 +42,17 @@ double MathBigInset::increase() const
|
|||||||
|
|
||||||
void MathBigInset::metrics(MathMetricsInfo & mi) const
|
void MathBigInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
double h = mathed_char_ascent(mi.base.font, 'I');
|
double const h = mathed_char_ascent(mi.base.font, 'I');
|
||||||
double f = increase();
|
double const f = increase();
|
||||||
width_ = 6;
|
dim_.w = 6;
|
||||||
ascent_ = int(h + f * h);
|
dim_.a = int(h + f * h);
|
||||||
descent_ = int(f * h);
|
dim_.d = int(f * h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathBigInset::draw(MathPainterInfo & pi, int x, int y) const
|
void MathBigInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
mathed_draw_deco(pi, x + 1, y - ascent_, 4, height(), delim_);
|
mathed_draw_deco(pi, x + 1, y - ascent(), 4, height(), delim_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ void MathBinomInset::metrics(MathMetricsInfo & mi) const
|
|||||||
MathScriptChanger(mi.base);
|
MathScriptChanger(mi.base);
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
xcell(1).metrics(mi);
|
xcell(1).metrics(mi);
|
||||||
ascent_ = xcell(0).height() + 4 + 5;
|
dim_.a = xcell(0).height() + 4 + 5;
|
||||||
descent_ = xcell(1).height() + 4 - 5;
|
dim_.d = xcell(1).height() + 4 - 5;
|
||||||
width_ = max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
dim_.w = max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ void MathBinomInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
MathScriptChanger(pi.base);
|
MathScriptChanger(pi.base);
|
||||||
xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
|
xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
|
||||||
xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
|
xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
|
||||||
mathed_draw_deco(pi, x, y - ascent_, dw(), height(), "(");
|
mathed_draw_deco(pi, x, y - ascent(), dw(), height(), "(");
|
||||||
mathed_draw_deco(pi, x + width() - dw(), y - ascent_, dw(), height(), ")");
|
mathed_draw_deco(pi, x + width() - dw(), y - ascent(), dw(), height(), ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,9 +46,8 @@ void MathBoxInset::metrics(MathMetricsInfo & mi) const
|
|||||||
{
|
{
|
||||||
MathFontSetChanger dummy(mi.base, "textnormal");
|
MathFontSetChanger dummy(mi.base, "textnormal");
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent() + 1;
|
dim_ = xcell(0).dim();
|
||||||
descent_ = xcell(0).descent() + 1;
|
metricsMarkers2();
|
||||||
width_ = xcell(0).width() + 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,11 +34,12 @@ MathInset * MathBraceInset::clone() const
|
|||||||
void MathBraceInset::metrics(MathMetricsInfo & mi) const
|
void MathBraceInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
int a, d;
|
Dimension t;
|
||||||
mathed_char_dim(mi.base.font, '{', a, d, wid_);
|
mathed_char_dim(mi.base.font, '{', t);
|
||||||
ascent_ = max(xcell(0).ascent(), a);
|
wid_ = t.w;
|
||||||
descent_ = max(xcell(0).descent(), a);
|
dim_.a = max(xcell(0).ascent(), t.a);
|
||||||
width_ = xcell(0).width() + 2 * wid_;
|
dim_.d = max(xcell(0).descent(), t.a);
|
||||||
|
dim_.w = xcell(0).width() + 2 * wid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ void MathBraceInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
font.setColor(LColor::latex);
|
font.setColor(LColor::latex);
|
||||||
drawChar(pi, font, x, y, '{');
|
drawChar(pi, font, x, y, '{');
|
||||||
xcell(0).draw(pi, x + wid_, y);
|
xcell(0).draw(pi, x + wid_, y);
|
||||||
drawChar(pi, font, x + width_ - wid_, y, '}');
|
drawChar(pi, font, x + width() - wid_, y, '}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ MathInset * MathCasesInset::clone() const
|
|||||||
void MathCasesInset::metrics(MathMetricsInfo & mi) const
|
void MathCasesInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
MathGridInset::metrics(mi);
|
MathGridInset::metrics(mi);
|
||||||
width_ += 8;
|
dim_.w += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,15 +62,15 @@ void MathCharInset::metrics(MathMetricsInfo & mi) const
|
|||||||
#if 1
|
#if 1
|
||||||
if (slanted(char_) && mi.base.fontname == "mathnormal") {
|
if (slanted(char_) && mi.base.fontname == "mathnormal") {
|
||||||
MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
|
MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
|
||||||
mathed_char_dim(mi.base.font, char_, ascent_, descent_, width_);
|
mathed_char_dim(mi.base.font, char_, dim_);
|
||||||
} else {
|
} else {
|
||||||
mathed_char_dim(mi.base.font, char_, ascent_, descent_, width_);
|
mathed_char_dim(mi.base.font, char_, dim_);
|
||||||
}
|
}
|
||||||
if (isBinaryOp(char_))
|
if (isBinaryOp(char_))
|
||||||
width_ += 2 * font_metrics::width(' ', mi.base.font);
|
dim_.w += 2 * font_metrics::width(' ', mi.base.font);
|
||||||
#else
|
#else
|
||||||
whichFont(font_, code_, mi);
|
whichFont(font_, code_, mi);
|
||||||
mathed_char_dim(font_, char_, ascent_, descent_, width_);
|
mathed_char_dim(font_, char_, dim_);
|
||||||
if (isBinaryOp(char_, code_))
|
if (isBinaryOp(char_, code_))
|
||||||
width_ += 2 * font_metrics::width(' ', font_);
|
width_ += 2 * font_metrics::width(' ', font_);
|
||||||
#endif
|
#endif
|
||||||
@ -97,9 +97,9 @@ void MathCharInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
|
|
||||||
void MathCharInset::metricsT(TextMetricsInfo const &) const
|
void MathCharInset::metricsT(TextMetricsInfo const &) const
|
||||||
{
|
{
|
||||||
width_ = 1;
|
dim_.w = 1;
|
||||||
ascent_ = 1;
|
dim_.a = 1;
|
||||||
descent_ = 0;
|
dim_.d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,24 +78,19 @@ bool MathDecorationInset::wide() const
|
|||||||
void MathDecorationInset::metrics(MathMetricsInfo & mi) const
|
void MathDecorationInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
width_ = xcell(0).width();
|
dim_ = xcell(0).dim();
|
||||||
ascent_ = xcell(0).ascent();
|
dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
|
||||||
descent_ = xcell(0).descent();
|
dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
|
||||||
|
|
||||||
dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
|
|
||||||
dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
|
|
||||||
|
|
||||||
if (upper()) {
|
if (upper()) {
|
||||||
dy_ = -ascent_ - dh_;
|
dy_ = -dim_.a - dh_;
|
||||||
ascent_ += dh_ + 1;
|
dim_.a += dh_ + 1;
|
||||||
} else {
|
} else {
|
||||||
dy_ = descent_ + 1;
|
dy_ = dim_.d + 1;
|
||||||
descent_ += dh_ + 2;
|
dim_.d += dh_ + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for the angular markers
|
metricsMarkers();
|
||||||
descent_ += 2;
|
|
||||||
width_ += 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,9 +98,9 @@ void MathDecorationInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
{
|
{
|
||||||
xcell(0).draw(pi, x + 1, y);
|
xcell(0).draw(pi, x + 1, y);
|
||||||
if (wide())
|
if (wide())
|
||||||
mathed_draw_deco(pi, x + 1, y + dy_, width_, dh_, name_);
|
mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, name_);
|
||||||
else
|
else
|
||||||
mathed_draw_deco(pi, x + 1 + (width_ - dw_) / 2, y + dy_, dw_, dh_, name_);
|
mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, name_);
|
||||||
drawMarkers(pi, x, y);
|
drawMarkers(pi, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,21 +90,21 @@ int MathDelimInset::dw() const
|
|||||||
void MathDelimInset::metrics(MathMetricsInfo & mi) const
|
void MathDelimInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
int a, d, w;
|
Dimension t;
|
||||||
mathed_char_dim(mi.base.font, 'I', a, d, w);
|
mathed_char_dim(mi.base.font, 'I', t);
|
||||||
int h0 = (a + d) / 2;
|
int h0 = (t.a + t.d) / 2;
|
||||||
int a0 = max(xcell(0).ascent(), a) - h0;
|
int a0 = max(xcell(0).ascent(), t.a) - h0;
|
||||||
int d0 = max(xcell(0).descent(), d) + h0;
|
int d0 = max(xcell(0).descent(), t.d) + h0;
|
||||||
ascent_ = max(a0, d0) + h0;
|
dim_.a = max(a0, d0) + h0;
|
||||||
descent_ = max(a0, d0) - h0;
|
dim_.d = max(a0, d0) - h0;
|
||||||
width_ = xcell(0).width() + 2 * dw() + 8;
|
dim_.w = xcell(0).width() + 2 * dw() + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDelimInset::draw(MathPainterInfo & pi, int x, int y) const
|
void MathDelimInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
int const w = dw();
|
int const w = dw();
|
||||||
int const b = y - ascent_;
|
int const b = y - ascent();
|
||||||
xcell(0).draw(pi, x + w + 4, y);
|
xcell(0).draw(pi, x + w + 4, y);
|
||||||
mathed_draw_deco(pi, x + 4, b, w, height(), left_);
|
mathed_draw_deco(pi, x + 4, b, w, height(), left_);
|
||||||
mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_);
|
mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_);
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
#include "textpainter.h"
|
#include "textpainter.h"
|
||||||
|
|
||||||
|
|
||||||
void MathDimInset::dimensions(int & w, int & a, int & d) const
|
void MathDimInset::dimensions(Dimension & dim) const
|
||||||
{
|
{
|
||||||
w = width_;
|
dim = dim_;
|
||||||
a = ascent_;
|
|
||||||
d = descent_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -15,9 +13,9 @@ void MathDimInset::metricsT(TextMetricsInfo const &) const
|
|||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << *this;
|
os << *this;
|
||||||
width_ = int(os.str().size());
|
dim_.w = int(os.str().size());
|
||||||
ascent_ = 1;
|
dim_.a = 1;
|
||||||
descent_ = 0;
|
dim_.d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,21 +3,22 @@
|
|||||||
#define MATH_DIMINSET_H
|
#define MATH_DIMINSET_H
|
||||||
|
|
||||||
#include "math_inset.h"
|
#include "math_inset.h"
|
||||||
|
#include "dimension.h"
|
||||||
|
|
||||||
/// things that need the dimension cache
|
/// things that need the dimension cache
|
||||||
|
|
||||||
class MathDimInset : public MathInset {
|
class MathDimInset : public MathInset {
|
||||||
public:
|
public:
|
||||||
/// not sure whether the initialization is really necessary
|
/// not sure whether the initialization is really necessary
|
||||||
MathDimInset() : width_(0), ascent_(0), descent_(0) {}
|
MathDimInset() {}
|
||||||
/// read ascent value (should be inline according to gprof)
|
/// read ascent value (should be inline according to gprof)
|
||||||
int ascent() const { return ascent_; }
|
int ascent() const { return dim_.ascent(); }
|
||||||
/// read descent
|
/// read descent
|
||||||
int descent() const { return descent_; }
|
int descent() const { return dim_.descent(); }
|
||||||
/// read width
|
/// read width
|
||||||
int width() const { return width_; }
|
int width() const { return dim_.width(); }
|
||||||
///
|
///
|
||||||
void dimensions(int & w, int & a, int & d) const;
|
void dimensions(Dimension & dim) const;
|
||||||
///
|
///
|
||||||
void metricsT(TextMetricsInfo const &) const;
|
void metricsT(TextMetricsInfo const &) const;
|
||||||
///
|
///
|
||||||
@ -25,10 +26,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
mutable int width_;
|
mutable Dimension dim_;
|
||||||
///
|
|
||||||
mutable int ascent_;
|
|
||||||
///
|
|
||||||
mutable int descent_;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,29 +23,29 @@ MathInset * MathDotsInset::clone() const
|
|||||||
|
|
||||||
void MathDotsInset::metrics(MathMetricsInfo & mi) const
|
void MathDotsInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
mathed_char_dim(mi.base.font, 'M', ascent_, descent_, width_);
|
mathed_char_dim(mi.base.font, 'M', dim_);
|
||||||
if (name_ == "ldots" || name_ == "dotsm")
|
if (name_ == "ldots" || name_ == "dotsm")
|
||||||
dh_ = 0;
|
dh_ = 0;
|
||||||
else if (name_ == "cdots" || name_ == "dotsb"
|
else if (name_ == "cdots" || name_ == "dotsb"
|
||||||
|| name_ == "dotsm" || name_ == "dotsi")
|
|| name_ == "dotsm" || name_ == "dotsi")
|
||||||
dh_ = ascent_ / 2;
|
dh_ = ascent() / 2;
|
||||||
else if (name_ == "dotsc")
|
else if (name_ == "dotsc")
|
||||||
dh_ = ascent_ / 4;
|
dh_ = ascent() / 4;
|
||||||
else if (name_ == "vdots")
|
else if (name_ == "vdots")
|
||||||
width_ /= 2;
|
dim_.w /= 2;
|
||||||
else if (name_ == "ddots")
|
else if (name_ == "ddots")
|
||||||
dh_ = ascent_;
|
dh_ = ascent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
|
void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
|
||||||
{
|
{
|
||||||
mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
|
mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), name_);
|
||||||
if (name_ == "vdots" || name_ == "ddots")
|
if (name_ == "vdots" || name_ == "ddots")
|
||||||
++x;
|
++x;
|
||||||
if (name_ != "vdots")
|
if (name_ != "vdots")
|
||||||
--y;
|
--y;
|
||||||
mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
|
mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,10 +23,8 @@ MathInset * MathEnvInset::clone() const
|
|||||||
|
|
||||||
void MathEnvInset::metrics(MathMetricsInfo & mi) const
|
void MathEnvInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(mi);
|
dim_ = xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent() + 1;
|
metricsMarkers2();
|
||||||
descent_ = xcell(0).descent() + 1;
|
|
||||||
width_ = xcell(0).width() + 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ MathInset * MathExFuncInset::clone() const
|
|||||||
|
|
||||||
void MathExFuncInset::metrics(MathMetricsInfo & mi) const
|
void MathExFuncInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
mathed_string_dim(mi.base.font, name_, ascent_, descent_, width_);
|
mathed_string_dim(mi.base.font, name_, dim_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,10 +25,8 @@ MathInset * MathFboxInset::clone() const
|
|||||||
void MathFboxInset::metrics(MathMetricsInfo & mi) const
|
void MathFboxInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
MathFontSetChanger dummy(mi.base, "textnormal");
|
MathFontSetChanger dummy(mi.base, "textnormal");
|
||||||
xcell(0).metrics(mi);
|
dim_ = xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent() + 5;
|
metricsMarkers2(5); // 5 pixels margin
|
||||||
descent_ = xcell(0).descent() + 5;
|
|
||||||
width_ = xcell(0).width() + 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,10 +31,8 @@ MathInset * MathFontInset::clone() const
|
|||||||
void MathFontInset::metrics(MathMetricsInfo & mi) const
|
void MathFontInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
MathFontSetChanger dummy(mi.base, name_.c_str());
|
MathFontSetChanger dummy(mi.base, name_.c_str());
|
||||||
xcell(0).metrics(mi);
|
dim_ = xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent();
|
metricsMarkers();
|
||||||
descent_ = xcell(0).descent() + 1;
|
|
||||||
width_ = xcell(0).width() + 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,10 +48,7 @@ void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
|
|
||||||
void MathFontInset::metricsT(TextMetricsInfo const & mi) const
|
void MathFontInset::metricsT(TextMetricsInfo const & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metricsT(mi);
|
dim_ = xcell(0).metricsT(mi);
|
||||||
width_ = xcell(0).width();
|
|
||||||
ascent_ = xcell(0).ascent();
|
|
||||||
descent_ = xcell(0).descent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ void MathFracInset::metrics(MathMetricsInfo & mi) const
|
|||||||
MathFracChanger dummy(mi.base);
|
MathFracChanger dummy(mi.base);
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
xcell(1).metrics(mi);
|
xcell(1).metrics(mi);
|
||||||
width_ = max(xcell(0).width(), xcell(1).width()) + 2;
|
dim_.w = max(xcell(0).width(), xcell(1).width()) + 2;
|
||||||
ascent_ = xcell(0).height() + 2 + 5;
|
dim_.a = xcell(0).height() + 2 + 5;
|
||||||
descent_ = xcell(1).height() + 2 - 5;
|
dim_.d = xcell(1).height() + 2 - 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ void MathFracInset::metricsT(TextMetricsInfo const & mi) const
|
|||||||
{
|
{
|
||||||
xcell(0).metricsT(mi);
|
xcell(0).metricsT(mi);
|
||||||
xcell(1).metricsT(mi);
|
xcell(1).metricsT(mi);
|
||||||
width_ = max(xcell(0).width(), xcell(1).width());
|
dim_.w = max(xcell(0).width(), xcell(1).width());
|
||||||
ascent_ = xcell(0).height() + 1;
|
dim_.a = xcell(0).height() + 1;
|
||||||
descent_ = xcell(1).height();
|
dim_.d = xcell(1).height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -314,17 +314,17 @@ void MathGridInset::metrics(MathMetricsInfo & mi) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
width_ = colinfo_[ncols() - 1].offset_
|
dim_.w = colinfo_[ncols() - 1].offset_
|
||||||
+ colinfo_[ncols() - 1].width_
|
+ colinfo_[ncols() - 1].width_
|
||||||
+ vlinesep() * colinfo_[ncols()].lines_
|
+ vlinesep() * colinfo_[ncols()].lines_
|
||||||
+ border();
|
+ border();
|
||||||
|
|
||||||
ascent_ = - rowinfo_[0].offset_
|
dim_.a = - rowinfo_[0].offset_
|
||||||
+ rowinfo_[0].ascent_
|
+ rowinfo_[0].ascent_
|
||||||
+ hlinesep() * rowinfo_[0].lines_
|
+ hlinesep() * rowinfo_[0].lines_
|
||||||
+ border();
|
+ border();
|
||||||
|
|
||||||
descent_ = rowinfo_[nrows() - 1].offset_
|
dim_.d = rowinfo_[nrows() - 1].offset_
|
||||||
+ rowinfo_[nrows() - 1].descent_
|
+ rowinfo_[nrows() - 1].descent_
|
||||||
+ hlinesep() * rowinfo_[nrows()].lines_
|
+ hlinesep() * rowinfo_[nrows()].lines_
|
||||||
+ border();
|
+ border();
|
||||||
@ -392,14 +392,14 @@ void MathGridInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
for (int i = 0; i < rowinfo_[row].lines_; ++i) {
|
for (int i = 0; i < rowinfo_[row].lines_; ++i) {
|
||||||
int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
|
int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
|
||||||
- i * hlinesep() - hlinesep()/2 - rowsep()/2;
|
- i * hlinesep() - hlinesep()/2 - rowsep()/2;
|
||||||
pi.pain.line(x + 1, yy, x + width_ - 1, yy);
|
pi.pain.line(x + 1, yy, x + width() - 1, yy);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (col_type col = 0; col <= ncols(); ++col)
|
for (col_type col = 0; col <= ncols(); ++col)
|
||||||
for (int i = 0; i < colinfo_[col].lines_; ++i) {
|
for (int i = 0; i < colinfo_[col].lines_; ++i) {
|
||||||
int xx = x + colinfo_[col].offset_
|
int xx = x + colinfo_[col].offset_
|
||||||
- i * vlinesep() - vlinesep()/2 - colsep()/2;
|
- i * vlinesep() - vlinesep()/2 - colsep()/2;
|
||||||
pi.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
|
pi.pain.line(xx, y - ascent() + 1, xx, y + descent() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,17 +476,17 @@ void MathGridInset::metricsT(TextMetricsInfo const & mi) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
width_ = colinfo_[ncols() - 1].offset_
|
dim_.w = colinfo_[ncols() - 1].offset_
|
||||||
+ colinfo_[ncols() - 1].width_
|
+ colinfo_[ncols() - 1].width_
|
||||||
//+ vlinesep() * colinfo_[ncols()].lines_
|
//+ vlinesep() * colinfo_[ncols()].lines_
|
||||||
+ 2;
|
+ 2;
|
||||||
|
|
||||||
ascent_ = - rowinfo_[0].offset_
|
dim_.a = -rowinfo_[0].offset_
|
||||||
+ rowinfo_[0].ascent_
|
+ rowinfo_[0].ascent_
|
||||||
//+ hlinesep() * rowinfo_[0].lines_
|
//+ hlinesep() * rowinfo_[0].lines_
|
||||||
+ 1;
|
+ 1;
|
||||||
|
|
||||||
descent_ = rowinfo_[nrows() - 1].offset_
|
dim_.d = rowinfo_[nrows() - 1].offset_
|
||||||
+ rowinfo_[nrows() - 1].descent_
|
+ rowinfo_[nrows() - 1].descent_
|
||||||
//+ hlinesep() * rowinfo_[nrows()].lines_
|
//+ hlinesep() * rowinfo_[nrows()].lines_
|
||||||
+ 1;
|
+ 1;
|
||||||
|
@ -169,8 +169,8 @@ void MathHullInset::metrics(MathMetricsInfo & mi) const
|
|||||||
MathGridInset::metrics(mi);
|
MathGridInset::metrics(mi);
|
||||||
|
|
||||||
if (display()) {
|
if (display()) {
|
||||||
ascent_ += 12;
|
dim_.a += 12;
|
||||||
descent_ += 12;
|
dim_.d += 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numberedType()) {
|
if (numberedType()) {
|
||||||
@ -180,20 +180,18 @@ void MathHullInset::metrics(MathMetricsInfo & mi) const
|
|||||||
l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
|
l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
|
||||||
|
|
||||||
if (l)
|
if (l)
|
||||||
width_ += 30 + l;
|
dim_.w += 30 + l;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make it at least as high as the current font
|
// make it at least as high as the current font
|
||||||
int asc = 0;
|
int asc = 0;
|
||||||
int des = 0;
|
int des = 0;
|
||||||
math_font_max_dim(mi.base.font, asc, des);
|
math_font_max_dim(mi.base.font, asc, des);
|
||||||
ascent_ = max(ascent_, asc);
|
dim_.a = max(dim_.a, asc);
|
||||||
descent_ = max(descent_, des);
|
dim_.d = max(dim_.d, des);
|
||||||
|
|
||||||
// for markers
|
// for markers
|
||||||
width_ += 2;
|
metricsMarkers2();
|
||||||
descent_ += 1;
|
|
||||||
ascent_ += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,9 +224,9 @@ void MathHullInset::metricsT(TextMetricsInfo const &) const
|
|||||||
ostringstream os;
|
ostringstream os;
|
||||||
WriteStream wi(os, false, true);
|
WriteStream wi(os, false, true);
|
||||||
write(wi);
|
write(wi);
|
||||||
width_ = os.str().size();
|
dim_.w = os.str().size();
|
||||||
ascent_ = 1;
|
dim_.a = 1;
|
||||||
descent_ = 0;
|
dim_.d = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ MathInset::size_type MathInset::nargs() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathInset::dimensions(int & w, int & a, int & d) const
|
void MathInset::dimensions(Dimension & dim) const
|
||||||
{
|
{
|
||||||
w = width();
|
dim.w = width();
|
||||||
a = ascent();
|
dim.a = ascent();
|
||||||
d = descent();
|
dim.d = descent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ class BufferView;
|
|||||||
class UpdatableInset;
|
class UpdatableInset;
|
||||||
class MathMacroTemplate;
|
class MathMacroTemplate;
|
||||||
class MathPosFinder;
|
class MathPosFinder;
|
||||||
|
class Dimension;
|
||||||
|
|
||||||
|
|
||||||
class MathInset {
|
class MathInset {
|
||||||
@ -128,7 +129,7 @@ public:
|
|||||||
/// total width
|
/// total width
|
||||||
virtual int width() const { return 2; }
|
virtual int width() const { return 2; }
|
||||||
/// all in one batch
|
/// all in one batch
|
||||||
virtual void dimensions(int & w, int & a, int & d) const;
|
virtual void dimensions(Dimension & dim) const;
|
||||||
/// total height (== ascent + descent)
|
/// total height (== ascent + descent)
|
||||||
virtual int height() const;
|
virtual int height() const;
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ MathInset * MathKernInset::clone() const
|
|||||||
|
|
||||||
void MathKernInset::metrics(MathMetricsInfo & /*mi*/) const
|
void MathKernInset::metrics(MathMetricsInfo & /*mi*/) const
|
||||||
{
|
{
|
||||||
width_ = wid_.inBP();
|
dim_.w = wid_.inBP();
|
||||||
ascent_ = 0;
|
dim_.a = 0;
|
||||||
descent_ = 0;
|
dim_.d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ MathInset * MathLefteqnInset::clone() const
|
|||||||
|
|
||||||
void MathLefteqnInset::metrics(MathMetricsInfo & mi) const
|
void MathLefteqnInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
MathNestInset::metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent() + 2;
|
dim_.a = xcell(0).ascent() + 2;
|
||||||
descent_ = xcell(0).descent() + 2;
|
dim_.d = xcell(0).descent() + 2;
|
||||||
width_ = 4;
|
dim_.w = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,30 +78,26 @@ void MathMacro::metrics(MathMetricsInfo & mi) const
|
|||||||
mi_ = mi;
|
mi_ = mi;
|
||||||
|
|
||||||
if (defining()) {
|
if (defining()) {
|
||||||
mathed_string_dim(font_, name(), ascent_, descent_, width_);
|
mathed_string_dim(font_, name(), dim_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editing()) {
|
if (editing()) {
|
||||||
expand();
|
expand();
|
||||||
expanded_.metrics(mi_);
|
dim_ = expanded_.metrics(mi_);
|
||||||
width_ = expanded_.width() + 4;
|
metricsMarkers2(2);
|
||||||
ascent_ = expanded_.ascent() + 2;
|
|
||||||
descent_ = expanded_.descent() + 2;
|
|
||||||
|
|
||||||
width_ += mathed_string_width(font_, name()) + 10;
|
dim_.w += mathed_string_width(font_, name()) + 10;
|
||||||
|
|
||||||
int lasc;
|
Dimension ldim;
|
||||||
int ldes;
|
mathed_string_dim(font_, "#1: ", ldim);
|
||||||
int lwid;
|
|
||||||
mathed_string_dim(font_, "#1: ", lasc, ldes, lwid);
|
|
||||||
|
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
MathXArray const & c = xcell(i);
|
MathXArray const & c = xcell(i);
|
||||||
c.metrics(mi_);
|
c.metrics(mi_);
|
||||||
width_ = max(width_, c.width() + lwid);
|
dim_.w = max(dim_.w, c.width() + ldim.w);
|
||||||
descent_ += max(c.ascent(), lasc) + 5;
|
dim_.d += max(c.ascent(), ldim.a) + 5;
|
||||||
descent_ += max(c.descent(), ldes) + 5;
|
dim_.d += max(c.descent(), ldim.d) + 5;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,9 +105,7 @@ void MathMacro::metrics(MathMetricsInfo & mi) const
|
|||||||
expand();
|
expand();
|
||||||
expanded_.data().substitute(*this);
|
expanded_.data().substitute(*this);
|
||||||
expanded_.metrics(mi_);
|
expanded_.metrics(mi_);
|
||||||
width_ = expanded_.width();
|
dim_ = expanded_.dim();
|
||||||
ascent_ = expanded_.ascent();
|
|
||||||
descent_ = expanded_.descent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -135,19 +129,17 @@ void MathMacro::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
expanded_.draw(pi, x + w + 12, h);
|
expanded_.draw(pi, x + w + 12, h);
|
||||||
h += expanded_.descent();
|
h += expanded_.descent();
|
||||||
|
|
||||||
int lasc;
|
Dimension ldim;
|
||||||
int ldes;
|
mathed_string_dim(font_, "#1: ", ldim);
|
||||||
int lwid;
|
|
||||||
mathed_string_dim(font_, "#1: ", lasc, ldes, lwid);
|
|
||||||
|
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
MathXArray const & c = xcell(i);
|
MathXArray const & c = xcell(i);
|
||||||
h += max(c.ascent(), lasc) + 5;
|
h += max(c.ascent(), ldim.a) + 5;
|
||||||
c.draw(pi, x + lwid, h);
|
c.draw(pi, x + ldim.w, h);
|
||||||
char str[] = "#1:";
|
char str[] = "#1:";
|
||||||
str[1] += static_cast<char>(i);
|
str[1] += static_cast<char>(i);
|
||||||
drawStr(pi, texfont, x + 3, h, str);
|
drawStr(pi, texfont, x + 3, h, str);
|
||||||
h += max(c.descent(), ldes) + 5;
|
h += max(c.descent(), ldim.d) + 5;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,10 @@ void MathMacroArgument::write(WriteStream & os) const
|
|||||||
|
|
||||||
void MathMacroArgument::metrics(MathMetricsInfo & mi) const
|
void MathMacroArgument::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
if (expanded_) {
|
if (expanded_)
|
||||||
xcell(0).metrics(mi);
|
dim_ = xcell(0).metrics(mi);
|
||||||
width_ = xcell(0).width();
|
else
|
||||||
ascent_ = xcell(0).ascent();
|
mathed_string_dim(mi.base.font, str_, dim_);
|
||||||
descent_ = xcell(0).descent();
|
|
||||||
} else {
|
|
||||||
mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ void MathMacroTemplate::metrics(MathMetricsInfo & mi) const
|
|||||||
{
|
{
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
xcell(1).metrics(mi);
|
xcell(1).metrics(mi);
|
||||||
width_ = xcell(0).width() + xcell(1).width() + 10;
|
dim_.w = xcell(0).width() + xcell(1).width() + 10;
|
||||||
ascent_ = std::max(xcell(0).ascent(), xcell(1).ascent()) + 2;
|
dim_.a = std::max(xcell(0).ascent(), xcell(1).ascent()) + 2;
|
||||||
descent_ = std::max(xcell(0).descent(), xcell(1).descent()) + 2;
|
dim_.d = std::max(xcell(0).descent(), xcell(1).descent()) + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,18 +63,18 @@ void MathNestInset::metrics(MathMetricsInfo const & mi) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathNestInset::metricsMarkers() const
|
void MathNestInset::metricsMarkers(int frame) const
|
||||||
{
|
{
|
||||||
descent_ += 1;
|
dim_.d += frame;
|
||||||
width_ += 2;
|
dim_.w += 2 * frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathNestInset::metricsMarkers2() const
|
void MathNestInset::metricsMarkers2(int frame) const
|
||||||
{
|
{
|
||||||
ascent_ += 1;
|
dim_.a += frame;
|
||||||
descent_ += 1;
|
dim_.d += frame;
|
||||||
width_ += 2;
|
dim_.w += 2 * frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ public:
|
|||||||
/// the size is usuall some sort of convex hull of the cells
|
/// the size is usuall some sort of convex hull of the cells
|
||||||
void metrics(MathMetricsInfo const & mi) const;
|
void metrics(MathMetricsInfo const & mi) const;
|
||||||
/// add space for markers
|
/// add space for markers
|
||||||
void metricsMarkers() const;
|
void metricsMarkers(int frame = 1) const;
|
||||||
/// add space for markers
|
/// add space for markers
|
||||||
void metricsMarkers2() const;
|
void metricsMarkers2(int frame = 1) const;
|
||||||
/// draw background if locked
|
/// draw background if locked
|
||||||
void draw(MathPainterInfo & pi, int x, int y) const;
|
void draw(MathPainterInfo & pi, int x, int y) const;
|
||||||
/// draw two angular markers
|
/// draw two angular markers
|
||||||
|
@ -36,8 +36,8 @@ void MathNotInset::metrics(MathMetricsInfo & mi) const
|
|||||||
augmentFont(font_, "mathnormal");
|
augmentFont(font_, "mathnormal");
|
||||||
char_ = '/';
|
char_ = '/';
|
||||||
// }
|
// }
|
||||||
mathed_char_dim(font_, char_, ascent_, descent_, width_);
|
mathed_char_dim(font_, char_, dim_);
|
||||||
width_ = 0;
|
dim_.w = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ MathInset * MathNumberInset::clone() const
|
|||||||
|
|
||||||
void MathNumberInset::metrics(MathMetricsInfo & mi) const
|
void MathNumberInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
|
mathed_string_dim(mi.base.font, str_, dim_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,10 +44,7 @@ void MathParboxInset::metrics(MathMetricsInfo & mi) const
|
|||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
xcell(0).metrics(mi);
|
dim_ = xcell(0).metrics(mi);
|
||||||
width_ = xcell(0).width();
|
|
||||||
ascent_ = xcell(0).ascent();
|
|
||||||
descent_ = xcell(0).descent();
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -106,9 +103,8 @@ void MathParboxInset::metrics(MathMetricsInfo & mi) const
|
|||||||
rows_.push_back(row);
|
rows_.push_back(row);
|
||||||
|
|
||||||
// what to report?
|
// what to report?
|
||||||
ascent_ = xcell(0).ascent();
|
dim_ = xcell(0).dim();
|
||||||
descent_ = xcell(0).descent() + 1;
|
metricsMarkers();
|
||||||
width_ = xcell(0).width() + 2;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ MathInset * MathRootInset::clone() const
|
|||||||
void MathRootInset::metrics(MathMetricsInfo & mi) const
|
void MathRootInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
MathNestInset::metrics(mi);
|
MathNestInset::metrics(mi);
|
||||||
ascent_ = max(xcell(0).ascent() + 5, xcell(1).ascent()) + 2;
|
dim_.a = max(xcell(0).ascent() + 5, xcell(1).ascent()) + 2;
|
||||||
descent_ = max(xcell(1).descent() + 5, xcell(0).descent()) + 2;
|
dim_.d = max(xcell(1).descent() + 5, xcell(0).descent()) + 2;
|
||||||
width_ = xcell(0).width() + xcell(1).width() + 10;
|
dim_.w = xcell(0).width() + xcell(1).width() + 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ void MathRootInset::draw(MathPainterInfo & pain, int x, int y) const
|
|||||||
int const d = descent();
|
int const d = descent();
|
||||||
int xp[5];
|
int xp[5];
|
||||||
int yp[5];
|
int yp[5];
|
||||||
xp[0] = x + width_; yp[0] = y - a + 1;
|
xp[0] = x + width(); yp[0] = y - a + 1;
|
||||||
xp[1] = x + w + 4; yp[1] = y - a + 1;
|
xp[1] = x + w + 4; yp[1] = y - a + 1;
|
||||||
xp[2] = x + w; yp[2] = y + d;
|
xp[2] = x + w; yp[2] = y + d;
|
||||||
xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2;
|
xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2;
|
||||||
|
@ -127,12 +127,11 @@ int MathScriptInset::dxx(MathInset const * nuc) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathScriptInset::dimensions2
|
void MathScriptInset::dimensions2(MathInset const * nuc, Dimension & dim) const
|
||||||
(MathInset const * nuc, int & w, int & a, int & d) const
|
|
||||||
{
|
{
|
||||||
a = dy1(nuc) + (hasUp() ? up().ascent() : 0);
|
dim.a = dy1(nuc) + (hasUp() ? up().ascent() : 0);
|
||||||
d = dy0(nuc) + (hasDown() ? down().descent() : 0);
|
dim.d = dy0(nuc) + (hasDown() ? down().descent() : 0);
|
||||||
w = width2(nuc);
|
dim.w = width2(nuc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -186,7 +185,7 @@ void MathScriptInset::metrics(MathInset const * nuc, MathMetricsInfo & mi) const
|
|||||||
nuc->metrics(mi);
|
nuc->metrics(mi);
|
||||||
MathNestInset::metrics(mi);
|
MathNestInset::metrics(mi);
|
||||||
MathScriptChanger dummy(mi.base);
|
MathScriptChanger dummy(mi.base);
|
||||||
dimensions2(nuc, width_, ascent_, descent_);
|
dimensions2(nuc, dim_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
///
|
///
|
||||||
void drawT(MathInset const * nuc, TextPainter &, int x, int y) const;
|
void drawT(MathInset const * nuc, TextPainter &, int x, int y) const;
|
||||||
/// helper
|
/// helper
|
||||||
void dimensions2(MathInset const * nuc, int & w, int & a, int & d) const;
|
void dimensions2(MathInset const * nuc, Dimension & dim) const;
|
||||||
/// only the width
|
/// only the width
|
||||||
int width2(MathInset const * nuc) const;
|
int width2(MathInset const * nuc) const;
|
||||||
|
|
||||||
|
@ -26,10 +26,8 @@ MathInset * MathSizeInset::clone() const
|
|||||||
void MathSizeInset::metrics(MathMetricsInfo & mi) const
|
void MathSizeInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
//MathStyleChanger dummy(mi.base, MathStyles(key_->id));
|
//MathStyleChanger dummy(mi.base, MathStyles(key_->id));
|
||||||
xcell(0).metrics(mi);
|
dim_ = xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent() + 1;
|
metricsMarkers2();
|
||||||
descent_ = xcell(0).descent() + 1;
|
|
||||||
width_ = xcell(0).width() + 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,18 +41,18 @@ MathInset * MathSpaceInset::clone() const
|
|||||||
void MathSpaceInset::metrics(MathMetricsInfo &) const
|
void MathSpaceInset::metrics(MathMetricsInfo &) const
|
||||||
{
|
{
|
||||||
switch (space_) {
|
switch (space_) {
|
||||||
case 0: width_ = 6; break;
|
case 0: dim_.w = 6; break;
|
||||||
case 1: width_ = 6; break;
|
case 1: dim_.w = 6; break;
|
||||||
case 2: width_ = 8; break;
|
case 2: dim_.w = 8; break;
|
||||||
case 3: width_ = 10; break;
|
case 3: dim_.w = 10; break;
|
||||||
case 4: width_ = 20; break;
|
case 4: dim_.w = 20; break;
|
||||||
case 5: width_ = 40; break;
|
case 5: dim_.w = 40; break;
|
||||||
case 6: width_ = -2; break;
|
case 6: dim_.w = -2; break;
|
||||||
case 7: width_ = 2; break;
|
case 7: dim_.w = 2; break;
|
||||||
default: width_ = 6; break;
|
default: dim_.w = 6; break;
|
||||||
}
|
}
|
||||||
ascent_ = 4;
|
dim_.a = 4;
|
||||||
descent_ = 0;
|
dim_.d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,10 +67,10 @@ void MathSpaceInset::draw(MathPainterInfo & pain, int x, int y) const
|
|||||||
int xp[4];
|
int xp[4];
|
||||||
int yp[4];
|
int yp[4];
|
||||||
|
|
||||||
xp[0] = ++x; yp[0] = y - 3;
|
xp[0] = ++x; yp[0] = y - 3;
|
||||||
xp[1] = x; yp[1] = y;
|
xp[1] = x; yp[1] = y;
|
||||||
xp[2] = x + width_ - 2; yp[2] = y;
|
xp[2] = x + width() - 2; yp[2] = y;
|
||||||
xp[3] = x + width_ - 2; yp[3] = y - 3;
|
xp[3] = x + width() - 2; yp[3] = y - 3;
|
||||||
|
|
||||||
pain.pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
|
pain.pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
|
||||||
}
|
}
|
||||||
|
@ -23,23 +23,23 @@ MathInset * MathSqrtInset::clone() const
|
|||||||
void MathSqrtInset::metrics(MathMetricsInfo & mi) const
|
void MathSqrtInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
ascent_ = xcell(0).ascent() + 4;
|
dim_.a = xcell(0).ascent() + 4;
|
||||||
descent_ = xcell(0).descent() + 2;
|
dim_.d = xcell(0).descent() + 2;
|
||||||
width_ = xcell(0).width() + 12;
|
dim_.w = xcell(0).width() + 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathSqrtInset::draw(MathPainterInfo & pain, int x, int y) const
|
void MathSqrtInset::draw(MathPainterInfo & pain, int x, int y) const
|
||||||
{
|
{
|
||||||
xcell(0).draw(pain, x + 10, y);
|
xcell(0).draw(pain, x + 10, y);
|
||||||
int const a = ascent_;
|
int const a = ascent();
|
||||||
int const d = descent_;
|
int const d = descent();
|
||||||
int xp[4];
|
int xp[4];
|
||||||
int yp[4];
|
int yp[4];
|
||||||
xp[0] = x + width_; yp[0] = y - a + 1;
|
xp[0] = x + width(); yp[0] = y - a + 1;
|
||||||
xp[1] = x + 8; yp[1] = y - a + 1;
|
xp[1] = x + 8; yp[1] = y - a + 1;
|
||||||
xp[2] = x + 5; yp[2] = y + d - 1;
|
xp[2] = x + 5; yp[2] = y + d - 1;
|
||||||
xp[3] = x; yp[3] = y + (d - a)/2;
|
xp[3] = x; yp[3] = y + (d - a)/2;
|
||||||
pain.pain.lines(xp, yp, 4, LColor::math);
|
pain.pain.lines(xp, yp, 4, LColor::math);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ void MathSqrtInset::draw(MathPainterInfo & pain, int x, int y) const
|
|||||||
void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
|
void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
|
||||||
{
|
{
|
||||||
xcell(0).metricsT(mi);
|
xcell(0).metricsT(mi);
|
||||||
ascent_ = xcell(0).ascent() + 1;
|
dim_.a = xcell(0).ascent() + 1;
|
||||||
descent_ = xcell(0).descent();
|
dim_.d = xcell(0).descent();
|
||||||
width_ = xcell(0).width() + 2;
|
dim_.w = xcell(0).width() + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ void MathStackrelInset::metrics(MathMetricsInfo & mi) const
|
|||||||
xcell(1).metrics(mi);
|
xcell(1).metrics(mi);
|
||||||
MathFracChanger dummy(mi.base);
|
MathFracChanger dummy(mi.base);
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
width_ = max(xcell(0).width(), xcell(1).width()) + 4;
|
dim_.w = max(xcell(0).width(), xcell(1).width()) + 4;
|
||||||
ascent_ = xcell(1).ascent() + xcell(0).height() + 4;
|
dim_.a = xcell(1).ascent() + xcell(0).height() + 4;
|
||||||
descent_ = xcell(1).descent();
|
dim_.d = xcell(1).descent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,10 +7,7 @@
|
|||||||
#include "math_stringinset.h"
|
#include "math_stringinset.h"
|
||||||
#include "math_mathmlstream.h"
|
#include "math_mathmlstream.h"
|
||||||
#include "math_streamstr.h"
|
#include "math_streamstr.h"
|
||||||
#include "LColor.h"
|
|
||||||
#include "math_support.h"
|
#include "math_support.h"
|
||||||
#include "math_parser.h"
|
|
||||||
#include "LaTeXFeatures.h"
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +24,7 @@ MathInset * MathStringInset::clone() const
|
|||||||
|
|
||||||
void MathStringInset::metrics(MathMetricsInfo & mi) const
|
void MathStringInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
|
mathed_string_dim(mi.base.font, str_, dim_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "frontends/font_loader.h"
|
#include "frontends/font_loader.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "commandtags.h"
|
#include "commandtags.h"
|
||||||
|
#include "dimension.h"
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -345,12 +346,11 @@ deco_struct const * search_deco(string const & name)
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
void mathed_char_dim(LyXFont const & font,
|
void mathed_char_dim(LyXFont const & font, unsigned char c, Dimension & dim)
|
||||||
unsigned char c, int & asc, int & des, int & wid)
|
|
||||||
{
|
{
|
||||||
des = font_metrics::descent(c, font);
|
dim.d = font_metrics::descent(c, font);
|
||||||
asc = font_metrics::ascent(c, font);
|
dim.a = font_metrics::ascent(c, font);
|
||||||
wid = mathed_char_width(font, c);
|
dim.w = mathed_char_width(font, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -375,12 +375,18 @@ int mathed_char_width(LyXFont const & font, unsigned char c)
|
|||||||
void mathed_string_dim(LyXFont const & font,
|
void mathed_string_dim(LyXFont const & font,
|
||||||
string const & s, int & asc, int & des, int & wid)
|
string const & s, int & asc, int & des, int & wid)
|
||||||
{
|
{
|
||||||
asc = des = 0;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mathed_string_dim(LyXFont const & font, string const & s, Dimension & dim)
|
||||||
|
{
|
||||||
|
dim.a = 0;
|
||||||
|
dim.d = 0;
|
||||||
for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
des = max(des, font_metrics::descent(*it, font));
|
dim.a = max(dim.a, font_metrics::ascent(*it, font));
|
||||||
asc = max(asc, font_metrics::ascent(*it, font));
|
dim.d = max(dim.d, font_metrics::descent(*it, font));
|
||||||
}
|
}
|
||||||
wid = font_metrics::width(s, font);
|
dim.w = font_metrics::width(s, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ class latexkeys;
|
|||||||
class MathMetricsInfo;
|
class MathMetricsInfo;
|
||||||
class MathInset;
|
class MathInset;
|
||||||
class LyXFont;
|
class LyXFont;
|
||||||
|
class Dimension;
|
||||||
|
|
||||||
void mathed_char_dim(LyXFont const &, unsigned char c,
|
void mathed_char_dim(LyXFont const &, unsigned char c, Dimension & dim);
|
||||||
int & asc, int & des, int & wid);
|
|
||||||
int mathed_char_width(LyXFont const &, unsigned char c);
|
int mathed_char_width(LyXFont const &, unsigned char c);
|
||||||
int mathed_char_ascent(LyXFont const &, unsigned char c);
|
int mathed_char_ascent(LyXFont const &, unsigned char c);
|
||||||
int mathed_char_descent(LyXFont const &, unsigned char c);
|
int mathed_char_descent(LyXFont const &, unsigned char c);
|
||||||
@ -23,9 +23,7 @@ void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h,
|
|||||||
|
|
||||||
void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const *);
|
void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const *);
|
||||||
|
|
||||||
void mathed_string_dim(LyXFont const &,
|
void mathed_string_dim(LyXFont const & font, string const & s, Dimension & dim);
|
||||||
string const & s, int & asc, int & des, int & wid);
|
|
||||||
|
|
||||||
int mathed_string_width(LyXFont const &, string const & s);
|
int mathed_string_width(LyXFont const &, string const & s);
|
||||||
int mathed_string_ascent(LyXFont const &, string const & s);
|
int mathed_string_ascent(LyXFont const &, string const & s);
|
||||||
int mathed_string_descent(LyXFont const &, string const & s);
|
int mathed_string_descent(LyXFont const &, string const & s);
|
||||||
|
@ -47,17 +47,17 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
|
|||||||
// << "' drawn as: '" << sym_->draw
|
// << "' drawn as: '" << sym_->draw
|
||||||
// << "'\n";
|
// << "'\n";
|
||||||
MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
|
MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
|
||||||
mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
|
mathed_string_dim(mi.base.font, sym_->draw, dim_);
|
||||||
// correct height for broken cmex font
|
// correct height for broken cmex and wasy font
|
||||||
if (sym_->inset == "cmex" || sym_->inset == "wasy") {
|
if (sym_->inset == "cmex" || sym_->inset == "wasy") {
|
||||||
h_ = 4 * descent_ / 5;
|
h_ = 4 * dim_.d / 5;
|
||||||
ascent_ += h_;
|
dim_.a += h_;
|
||||||
descent_ -= h_;
|
dim_.d -= h_;
|
||||||
}
|
}
|
||||||
if (isRelOp())
|
if (isRelOp())
|
||||||
width_ += 6;
|
dim_.w += 6;
|
||||||
// seperate things a bit
|
// seperate things a bit
|
||||||
width_ += 2;
|
dim_.w += 2;
|
||||||
|
|
||||||
scriptable_ = false;
|
scriptable_ = false;
|
||||||
if (mi.base.style == LM_ST_DISPLAY)
|
if (mi.base.style == LM_ST_DISPLAY)
|
||||||
|
@ -25,9 +25,9 @@ void MathUndersetInset::metrics(MathMetricsInfo & mi) const
|
|||||||
xcell(1).metrics(mi);
|
xcell(1).metrics(mi);
|
||||||
MathFracChanger dummy(mi.base);
|
MathFracChanger dummy(mi.base);
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
width_ = max(xcell(0).width(), xcell(1).width()) + 4;
|
dim_.w = max(xcell(0).width(), xcell(1).width()) + 4;
|
||||||
ascent_ = xcell(1).ascent();
|
dim_.a = xcell(1).ascent();
|
||||||
descent_ = xcell(1).descent() + xcell(0).height() + 4;
|
dim_.d = xcell(1).descent() + xcell(0).height() + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ void MathUnknownInset::normalize(NormalStream & os) const
|
|||||||
|
|
||||||
void MathUnknownInset::metrics(MathMetricsInfo & mi) const
|
void MathUnknownInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
mathed_string_dim(mi.base.font, name_, ascent_, descent_, width_);
|
mathed_string_dim(mi.base.font, name_, dim_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,16 +27,16 @@ void MathXArrowInset::metrics(MathMetricsInfo & mi) const
|
|||||||
//MathMetricsInfo mi = st;
|
//MathMetricsInfo mi = st;
|
||||||
//smallerStyleScript(mi);
|
//smallerStyleScript(mi);
|
||||||
xcell(0).metrics(mi);
|
xcell(0).metrics(mi);
|
||||||
width_ = xcell(0).width() + 10;
|
dim_.w = xcell(0).width() + 10;
|
||||||
ascent_ = xcell(0).height() + 10;
|
dim_.a = xcell(0).height() + 10;
|
||||||
descent_ = 0;
|
dim_.d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathXArrowInset::draw(MathPainterInfo & pain, int x, int y) const
|
void MathXArrowInset::draw(MathPainterInfo & pain, int x, int y) const
|
||||||
{
|
{
|
||||||
xcell(0).draw(pain, x + 5, y - 10);
|
xcell(0).draw(pain, x + 5, y - 10);
|
||||||
mathed_draw_deco(pain, x + 1, y - 7, width_ - 2, 5, name_);
|
mathed_draw_deco(pain, x + 1, y - 7, width() - 2, 5, name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void MathXArray::touch() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathXArray::metrics(MathMetricsInfo & mi) const
|
Dimension const & MathXArray::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
//if (clean_)
|
//if (clean_)
|
||||||
// return;
|
// return;
|
||||||
@ -41,27 +41,28 @@ void MathXArray::metrics(MathMetricsInfo & mi) const
|
|||||||
drawn_ = false;
|
drawn_ = false;
|
||||||
|
|
||||||
if (data_.empty()) {
|
if (data_.empty()) {
|
||||||
mathed_char_dim(mi.base.font, 'I', dim_.a, dim_.d, dim_.w);
|
mathed_char_dim(mi.base.font, 'I', dim_);
|
||||||
return;
|
return dim_;;
|
||||||
}
|
}
|
||||||
|
|
||||||
dim_.clear();
|
dim_.clear();
|
||||||
for (const_iterator it = begin(); it != end(); ++it) {
|
for (const_iterator it = begin(); it != end(); ++it) {
|
||||||
MathInset const * p = it->nucleus();
|
MathInset const * p = it->nucleus();
|
||||||
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
|
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
|
||||||
int ww, aa, dd;
|
Dimension d;
|
||||||
if (q) {
|
if (q) {
|
||||||
q->metrics(p, mi);
|
q->metrics(p, mi);
|
||||||
q->dimensions2(p, ww, aa, dd);
|
q->dimensions2(p, d);
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
p->metrics(mi);
|
p->metrics(mi);
|
||||||
p->dimensions(ww, aa, dd);
|
p->dimensions(d);
|
||||||
}
|
}
|
||||||
dim_ += Dimension(ww, aa, dd);
|
dim_ += d;
|
||||||
}
|
}
|
||||||
|
|
||||||
//lyxerr << "MathXArray::metrics(): '" << dim_ << "\n";
|
//lyxerr << "MathXArray::metrics(): '" << dim_ << "\n";
|
||||||
|
return dim_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ void MathXArray::metricsExternal(MathMetricsInfo & mi,
|
|||||||
drawn_ = false;
|
drawn_ = false;
|
||||||
|
|
||||||
if (data_.empty()) {
|
if (data_.empty()) {
|
||||||
mathed_char_dim(mi.base.font, 'I', dim_.a, dim_.d, dim_.w);
|
mathed_char_dim(mi.base.font, 'I', dim_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,19 +85,19 @@ void MathXArray::metricsExternal(MathMetricsInfo & mi,
|
|||||||
for (const_iterator it = begin(); it != end(); ++it) {
|
for (const_iterator it = begin(); it != end(); ++it) {
|
||||||
MathInset const * p = it->nucleus();
|
MathInset const * p = it->nucleus();
|
||||||
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
|
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
|
||||||
int ww, aa, dd;
|
Dimension d;
|
||||||
if (q) {
|
if (q) {
|
||||||
q->metrics(p, mi);
|
q->metrics(p, mi);
|
||||||
q->dimensions2(p, ww, aa, dd);
|
q->dimensions2(p, d);
|
||||||
++it;
|
++it;
|
||||||
v.push_back(Row());
|
v.push_back(Row());
|
||||||
v.back().dim = Dimension(ww, aa, dd);
|
v.back().dim = d;
|
||||||
v.push_back(Row());
|
v.push_back(Row());
|
||||||
} else {
|
} else {
|
||||||
p->metrics(mi);
|
p->metrics(mi);
|
||||||
p->dimensions(ww, aa, dd);
|
p->dimensions(d);
|
||||||
v.push_back(Row());
|
v.push_back(Row());
|
||||||
v.back().dim = Dimension(ww, aa, dd);
|
v.back().dim = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +171,7 @@ void MathXArray::drawExternal(MathPainterInfo & pi, int x, int y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathXArray::metricsT(TextMetricsInfo const & mi) const
|
Dimension const & MathXArray::metricsT(TextMetricsInfo const & mi) const
|
||||||
{
|
{
|
||||||
//if (clean_)
|
//if (clean_)
|
||||||
// return;
|
// return;
|
||||||
@ -178,17 +179,18 @@ void MathXArray::metricsT(TextMetricsInfo const & mi) const
|
|||||||
for (const_iterator it = begin(); it != end(); ++it) {
|
for (const_iterator it = begin(); it != end(); ++it) {
|
||||||
MathInset const * p = it->nucleus();
|
MathInset const * p = it->nucleus();
|
||||||
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
|
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
|
||||||
int ww, aa, dd;
|
Dimension d;
|
||||||
if (q) {
|
if (q) {
|
||||||
q->metricsT(p, mi);
|
q->metricsT(p, mi);
|
||||||
q->dimensions2(p, ww, aa, dd);
|
q->dimensions2(p, d);
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
p->metricsT(mi);
|
p->metricsT(mi);
|
||||||
p->dimensions(ww, aa, dd);
|
p->dimensions(d);
|
||||||
}
|
}
|
||||||
dim_ += Dimension(ww, aa, dd);
|
dim_ += d;
|
||||||
}
|
}
|
||||||
|
return dim_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
/// constructor
|
/// constructor
|
||||||
MathXArray();
|
MathXArray();
|
||||||
/// rebuild cached metrics information
|
/// rebuild cached metrics information
|
||||||
void metrics(MathMetricsInfo & mi) const;
|
Dimension const & metrics(MathMetricsInfo & mi) const;
|
||||||
/// rebuild cached metrics information
|
/// rebuild cached metrics information
|
||||||
void metricsExternal(MathMetricsInfo & mi,
|
void metricsExternal(MathMetricsInfo & mi,
|
||||||
std::vector<MathXArray::Row> &) const;
|
std::vector<MathXArray::Row> &) const;
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
void drawExternal(MathPainterInfo & pi, int x, int y,
|
void drawExternal(MathPainterInfo & pi, int x, int y,
|
||||||
std::vector<MathXArray::Row> const &) const;
|
std::vector<MathXArray::Row> const &) const;
|
||||||
/// rebuild cached metrics information
|
/// rebuild cached metrics information
|
||||||
void metricsT(TextMetricsInfo const & mi) const;
|
Dimension const & metricsT(TextMetricsInfo const & mi) const;
|
||||||
/// redraw cell using cache metrics information
|
/// redraw cell using cache metrics information
|
||||||
void drawT(TextPainter & pi, int x, int y) const;
|
void drawT(TextPainter & pi, int x, int y) const;
|
||||||
/// mark cell for re-drawing
|
/// mark cell for re-drawing
|
||||||
@ -86,6 +86,8 @@ public:
|
|||||||
int height() const { return dim_.a + dim_.d; }
|
int height() const { return dim_.a + dim_.d; }
|
||||||
/// width of this cell
|
/// width of this cell
|
||||||
int width() const { return dim_.w; }
|
int width() const { return dim_.w; }
|
||||||
|
/// dimensions of cell
|
||||||
|
Dimension const & dim() const { return dim_; }
|
||||||
/// bounding box of this cell
|
/// bounding box of this cell
|
||||||
void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh);
|
void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh);
|
||||||
/// find best position to do things
|
/// find best position to do things
|
||||||
|
Loading…
Reference in New Issue
Block a user