]> git.lyx.org Git - features.git/commitdiff
use a single function dimension() instead of three.
authorAndré Pönitz <poenitz@gmx.net>
Mon, 8 Jul 2002 16:20:53 +0000 (16:20 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 8 Jul 2002 16:20:53 +0000 (16:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4554 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_casesinset.C
src/mathed/math_casesinset.h
src/mathed/math_diminset.C
src/mathed/math_diminset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/math_xdata.C

index 94c83c0df726af46fc3c761f7499ac11feced4dd..f21895f0634515fa75a235363d197b6a04a4ee0a 100644 (file)
@@ -61,3 +61,9 @@ void MathCasesInset::maplize(MapleStream & os) const
        MathGridInset::maplize(os);
        os << ")";
 }
+
+
+void MathCasesInset::infoize(std::ostream & os) const
+{
+       os << "Cases ";
+}
index a7a3fc50269de6f2f3db38acc5778ef6f9c9ab37..9628d8a3e404c98c334ec3f49fb3301252d9ff39 100644 (file)
@@ -20,6 +20,8 @@ public:
        ///
        void draw(MathPainterInfo & pain, int x, int y) const;
 
+       ///
+       void infoize(std::ostream & os) const;
        ///
        void normalize(NormalStream &) const;
        ///
index e9de770737d0324aab5e97d22e6419171f35df76..f02ae43dd11345a054bee6b20b1975fb860bd14a 100644 (file)
@@ -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;
index 64fe5ee58e2c4f2c36217ef854d877cefb776c30..4bc853e03844aba145d3c3df6df77ca9ca20647e 100644 (file)
@@ -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;
        ///
index 5b29fefe340256d7fb10199593153e7287e2faa7..428a5297137a7db2bf08699341339bffa682d5ed 100644 (file)
@@ -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)
index 42e925ae32e6de9b356da15c461dfa42aa2b0b8a..515e81f991c7443acd904cb763b6a506a53edbbc 100644 (file)
@@ -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;
 
index 67e0e3af805e0218efd55d1b28e56e1a95811c70..75bc596e9bf13fd92941adf2a3138289638abaf3 100644 (file)
@@ -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_);
 }
 
 
index 913756ec2f399c22948e418199a9410fcb8f744a..56826ff106c8d338d6f5fd047e23f03fe2d98e0d 100644 (file)
@@ -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;
 
        ///
index da357dc65218bf55519d7b9865264d6179381340..eaf68afc5f08d64aa18c414e3467c5b2dca14691 100644 (file)
@@ -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;
        }
 }