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