From: André Pönitz Date: Mon, 8 Jul 2002 16:20:53 +0000 (+0000) Subject: use a single function dimension() instead of three. X-Git-Tag: 1.6.10~18947 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ec274548014237a28a7b893ca3f88179c20c63a6;p=features.git use a single function dimension() instead of three. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4554 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index 94c83c0df7..f21895f063 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -61,3 +61,9 @@ void MathCasesInset::maplize(MapleStream & os) const MathGridInset::maplize(os); os << ")"; } + + +void MathCasesInset::infoize(std::ostream & os) const +{ + os << "Cases "; +} diff --git a/src/mathed/math_casesinset.h b/src/mathed/math_casesinset.h index a7a3fc5026..9628d8a3e4 100644 --- a/src/mathed/math_casesinset.h +++ b/src/mathed/math_casesinset.h @@ -20,6 +20,8 @@ public: /// void draw(MathPainterInfo & pain, int x, int y) const; + /// + void infoize(std::ostream & os) const; /// void normalize(NormalStream &) const; /// diff --git a/src/mathed/math_diminset.C b/src/mathed/math_diminset.C index e9de770737..f02ae43dd1 100644 --- a/src/mathed/math_diminset.C +++ b/src/mathed/math_diminset.C @@ -3,6 +3,14 @@ #include "textpainter.h" +void MathDimInset::dimensions(int & w, int & a, int & d) const +{ + w = width_; + a = ascent_; + d = descent_; +} + + void MathDimInset::metricsT(TextMetricsInfo const &) const { std::ostringstream os; diff --git a/src/mathed/math_diminset.h b/src/mathed/math_diminset.h index 64fe5ee58e..4bc853e038 100644 --- a/src/mathed/math_diminset.h +++ b/src/mathed/math_diminset.h @@ -16,6 +16,8 @@ public: int descent() const { return descent_; } /// read width int width() const { return width_; } + /// + void dimensions(int & w, int & a, int & d) const; /// void metricsT(TextMetricsInfo const &) const; /// diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 5b29fefe34..428a529713 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -68,6 +68,14 @@ MathInset::size_type MathInset::nargs() const } +void MathInset::dimensions(int & w, int & a, int & d) const +{ + w = width(); + a = ascent(); + d = descent(); +} + + MathXArray dummyCell; MathXArray & MathInset::xcell(idx_type) diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 42e925ae32..515e81f991 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -128,6 +128,8 @@ public: virtual int descent() const { return 1; } /// total width virtual int width() const { return 2; } + /// all in one batch + virtual void dimensions(int & w, int & a, int & d) const; /// total height (== ascent + descent) virtual int height() const; diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 67e0e3af80..75bc596e9b 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -127,35 +127,32 @@ int MathScriptInset::dxx(MathInset const * nuc) const } -int MathScriptInset::ascent2(MathInset const * nuc) const +void MathScriptInset::dimensions2 + (MathInset const * nuc, int & w, int & a, int & d) const { - return dy1(nuc) + (hasUp() ? up().ascent() : 0); -} - - -int MathScriptInset::descent2(MathInset const * nuc) const -{ - return dy0(nuc) + (hasDown() ? down().descent() : 0); + a = dy1(nuc) + (hasUp() ? up().ascent() : 0); + d = dy0(nuc) + (hasDown() ? down().descent() : 0); + w = width2(nuc); } int MathScriptInset::width2(MathInset const * nuc) const { - int wid = 0; + int w = 0; if (hasLimits(nuc)) { - wid = nwid(nuc); + w = nwid(nuc); if (hasUp()) - wid = max(wid, up().width()); + w = max(w, up().width()); if (hasDown()) - wid = max(wid, down().width()); + w = max(w, down().width()); } else { if (hasUp()) - wid = max(wid, up().width()); + w = max(w, up().width()); if (hasDown()) - wid = max(wid, down().width()); - wid += nwid(nuc); + w = max(w, down().width()); + w += nwid(nuc); } - return wid; + return w; } @@ -189,9 +186,7 @@ void MathScriptInset::metrics(MathInset const * nuc, MathMetricsInfo & mi) const nuc->metrics(mi); MathNestInset::metrics(mi); MathScriptChanger dummy(mi.base); - ascent_ = ascent2(nuc); - descent_ = descent2(nuc); - width_ = width2(nuc); + dimensions2(nuc, width_, ascent_, descent_); } diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 913756ec2f..56826ff106 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -41,11 +41,9 @@ public: void metricsT(MathInset const * nuc, TextMetricsInfo const & st) const; /// void drawT(MathInset const * nuc, TextPainter &, int x, int y) const; - /// - int ascent2(MathInset const * nuc) const; - /// - int descent2(MathInset const * nuc) const; - /// + /// helper + void dimensions2(MathInset const * nuc, int & w, int & a, int & d) const; + /// only the width int width2(MathInset const * nuc) const; /// diff --git a/src/mathed/math_xdata.C b/src/mathed/math_xdata.C index da357dc652..eaf68afc5f 100644 --- a/src/mathed/math_xdata.C +++ b/src/mathed/math_xdata.C @@ -47,32 +47,24 @@ void MathXArray::metrics(MathMetricsInfo & mi) const } width_ = 0; - - int a = 0; - int d = 0; + ascent_ = 0; + descent_ = 0; for (const_iterator it = begin(); it != end(); ++it) { MathInset const * p = it->nucleus(); MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it); - int w = 0; + int ww, aa, dd; if (q) { q->metrics(p, mi); - a = max(a, q->ascent2(p)); - d = max(d, q->descent2(p)); - w = q->width2(p); + q->dimensions2(p, ww, aa, dd); ++it; } else { p->metrics(mi); - a = max(a, p->ascent()); - d = max(d, p->descent()); - w = p->width(); } - width_ += w; + ascent_ = max(ascent_, aa); + descent_ = max(descent_, dd); + width_ += ww; } - ascent_ = a; - descent_ = d; - //width_ = 0; - //lyxerr << "MathXArray::metrics(): '" << ascent_ << " " // << descent_ << " " << width_ << "'\n"; @@ -147,18 +139,17 @@ 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; if (q) { q->metricsT(p, mi); - ascent_ = max(ascent_, q->ascent2(p)); - descent_ = max(descent_, q->descent2(p)); - width_ += q->width2(p); + q->dimensions(ww, aa, dd); ++it; } else { p->metricsT(mi); - ascent_ = max(ascent_, p->ascent()); - descent_ = max(descent_, p->descent()); - width_ += p->width(); } + ascent_ = max(ascent_, aa); + descent_ = max(descent_, dd); + width_ += ww; } }