]> git.lyx.org Git - features.git/commitdiff
support for \overset
authorAndré Pönitz <poenitz@gmx.net>
Fri, 22 Aug 2003 16:01:13 +0000 (16:01 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 22 Aug 2003 16:01:13 +0000 (16:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7594 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/Makefile.am
src/mathed/math_factory.C
src/mathed/math_oversetinset.C [new file with mode: 0644]
src/mathed/math_oversetinset.h [new file with mode: 0644]
src/rowpainter.C
src/text.C
src/text2.C

index 0f0efffca6ac6a2ac770610c1602c9f3fb0e8d12..b39f933fe5a5836d18b6e19b86cd2ab61cdbb7dc 100644 (file)
@@ -106,6 +106,8 @@ libmathed_la_SOURCES = \
        math_nestinset.h \
        math_numberinset.C \
        math_numberinset.h \
+       math_oversetinset.C \
+       math_oversetinset.h \
        math_parboxinset.C \
        math_parboxinset.h \
        math_parinset.C \
index b4e6418d604eef624250611870881b9b8bb672d0..eaa9be204be406e011e9fe3397624ce52b26e5fa 100644 (file)
@@ -31,6 +31,7 @@
 #include "math_macrotemplate.h"
 #include "math_macroarg.h"
 #include "math_makeboxinset.h"
+#include "math_oversetinset.h"
 #include "math_parboxinset.h"
 #include "math_rootinset.h"
 #include "math_sizeinset.h"
@@ -237,6 +238,8 @@ MathAtom createMathInset(string const & s)
                        inset << '\'' << endl;
                if (inset == "ref")
                        return MathAtom(new RefInset(l->name));
+               if (inset == "overset")
+                       return MathAtom(new MathOversetInset);
                if (inset == "underset")
                        return MathAtom(new MathUndersetInset);
                if (inset == "decoration")
diff --git a/src/mathed/math_oversetinset.C b/src/mathed/math_oversetinset.C
new file mode 100644 (file)
index 0000000..a3beef8
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+ * \file math_oversetinset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "math_oversetinset.h"
+#include "math_mathmlstream.h"
+#include "math_support.h"
+
+
+using std::max;
+using std::auto_ptr;
+
+
+MathOversetInset::MathOversetInset()
+{}
+
+
+auto_ptr<InsetBase> MathOversetInset::clone() const
+{
+       return auto_ptr<InsetBase>(new MathOversetInset(*this));
+}
+
+
+void MathOversetInset::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       cell(1).metrics(mi);
+       FracChanger dummy(mi.base);
+       cell(0).metrics(mi);
+       dim_.wid = max(cell(0).width(), cell(1).width()) + 4;
+       dim_.asc = cell(1).ascent() + cell(0).height() + 4;
+       dim_.des = cell(1).descent();
+       dim = dim_;
+}
+
+
+void MathOversetInset::draw(PainterInfo & pi, int x, int y) const
+{
+       int m  = x + pi.width / 2;
+       int yo = y - cell(1).ascent() + cell(0).descent() + 1;
+       cell(1).draw(pi, m - cell(1).width() / 2, y);
+       FracChanger dummy(pi.base);
+       cell(0).draw(pi, m - cell(0).width() / 2, yo);
+}
+
+
+void MathOversetInset::write(WriteStream & os) const
+{
+       os << "\\overset{" << cell(0) << "}{" << cell(1) << '}';
+}
+
+
+void MathOversetInset::normalize(NormalStream & os) const
+{
+       os << "[overset " << cell(0) << ' ' << cell(1) << ']';
+}
diff --git a/src/mathed/math_oversetinset.h b/src/mathed/math_oversetinset.h
new file mode 100644 (file)
index 0000000..5327339
--- /dev/null
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+/**
+ * \file math_oversetinset.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef MATH_OVERSETINSET_H
+#define MATH_OVERSETINSET_H
+
+
+#include "math_fracbase.h"
+
+/// Inset for overset
+class MathOversetInset : public MathFracbaseInset {
+public:
+       ///
+       MathOversetInset();
+       ///
+       virtual std::auto_ptr<InsetBase> clone() const;
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+};
+
+#endif
index 199ffd05aad402fb9df2898dc6c2c5c766d567bd..ca819fb2e6f497b4f8ea32572f465171cf116ed7 100644 (file)
@@ -1047,7 +1047,7 @@ int paintRows(BufferView const & bv, LyXText const & text,
        int xo, int y, int yf, int yo)
 {
        lyxerr << "  paintRows: rit: " << &*rit << endl;
-       const_cast<LyXText&>(text).updateRowPositions();
+       //const_cast<LyXText&>(text).updateRowPositions();
        int const yy = yf - y;
        int const y2 = bv.painter().paperHeight();
        
index 95526633e32b1bf2d085933f930c099fd5dd0ce6..ea7c612912404787bb4f249dcffc7aa8dfaed262 100644 (file)
@@ -84,12 +84,12 @@ void LyXText::updateRowPositions()
 {
        ParagraphList::iterator pit = ownerParagraphs().begin();
        ParagraphList::iterator end = ownerParagraphs().end();
-       for (int y = 0; pit != end; ++pit) {
+       for (height = 0; pit != end; ++pit) {
                RowList::iterator rit = pit->rows.begin();
                RowList::iterator rend = pit->rows.end();
                for ( ; rit != rend ; rit = ++rit) {
-                       rit->y(y);
-                       y += rit->height();
+                       rit->y(height);
+                       height += rit->height();
                }
        }
 }
index aa00774ce1084da9a6c515eace02071b9d487214..ff18daf87afa463bcedfd6927e99b0aacc41461d 100644 (file)
@@ -604,6 +604,7 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
 
        //anchor_y_ = 0;
        redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
+       updateRowPositions();
 
        // final dimension
        dim.asc = firstRow()->ascent_of_text();