]> git.lyx.org Git - features.git/commitdiff
Ling Li's makebox support
authorAndré Pönitz <poenitz@gmx.net>
Wed, 7 May 2003 07:46:04 +0000 (07:46 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 7 May 2003 07:46:04 +0000 (07:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6943 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/Makefile.am
src/mathed/math_boxinset.C
src/mathed/math_factory.C
src/mathed/math_makeboxinset.C [new file with mode: 0644]
src/mathed/math_makeboxinset.h [new file with mode: 0644]
src/mathed/math_nestinset.C
src/mathed/math_parser.C

index 491dc3111e458657b55b13204a9458508657f956..2123e7680de120cbef1a68c4ee24783dac656e72 100644 (file)
@@ -1,3 +1,13 @@
+2003-05-06  Ling Li  <ling@caltech.edu>
+       * Makefile, math_makeboxinset.[Ch]:
+       * math_factory.C (createMathInset):
+       * math_parser.C (parse1): New support for \makebox.
+       * math_nestinset.C (drawMarkers, drawMarkers2):
+       * math_boxinset.C, math_frameboxinset.C (draw):
+       Fix spacing and marker length.
 2003-05-03  John Levon  <levon@movementarian.org>
 
        * formula.C:
index 423995cbb83828ffcf68365c1107bae1fe92da76..b5bf583d506ef51f904b14df1109d469a0b573f1 100644 (file)
@@ -100,6 +100,8 @@ libmathed_la_SOURCES = \
        math_macrotemplate.h \
        math_macrotable.C \
        math_macrotable.h \
+       math_makeboxinset.C \
+       math_makeboxinset.h \
        math_mathmlstream.C \
        math_mathmlstream.h \
        math_matrixinset.C \
index 29c5e2c72739bab01cf724fbc550ff3a49546633..f479ae2470080764e3ecf4a7fa80c2d97cca7d60 100644 (file)
@@ -46,7 +46,7 @@ void MathBoxInset::draw(PainterInfo & pi, int x, int y) const
 {
        FontSetChanger dummy(pi.base, "textnormal");
        cell(0).draw(pi, x, y);
-       drawMarkers2(pi, x + 1, y);
+       drawMarkers2(pi, x, y);
 }
 
 
index b0fa5e7dffbf88135b5591bf498b9e2c1f37d5c8..1ccb5829dc4f4277df3a0b72ede146a055e09960 100644 (file)
@@ -22,6 +22,7 @@
 #include "math_macrotable.h"
 #include "math_macrotemplate.h"
 #include "math_macroarg.h"
+#include "math_makeboxinset.h"
 #include "math_parboxinset.h"
 #include "math_rootinset.h"
 #include "math_sizeinset.h"
@@ -259,6 +260,8 @@ MathAtom createMathInset(string const & s)
                return MathAtom(new MathMacroArgument(s[2] - '0'));
        if (s == "framebox")
                return MathAtom(new MathFrameboxInset);
+       if (s == "makebox")
+               return MathAtom(new MathMakeboxInset);
        if (s == "kern")
                return MathAtom(new MathKernInset);
        if (s == "xymatrix")
diff --git a/src/mathed/math_makeboxinset.C b/src/mathed/math_makeboxinset.C
new file mode 100644 (file)
index 0000000..730604a
--- /dev/null
@@ -0,0 +1,75 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_makeboxinset.h"
+#include "math_support.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "frontends/Painter.h"
+
+
+
+MathMakeboxInset::MathMakeboxInset()
+       : MathNestInset(3)
+{}
+
+
+MathInset * MathMakeboxInset::clone() const
+{
+       return new MathMakeboxInset(*this);
+}
+
+
+void MathMakeboxInset::metrics(MetricsInfo & mi) const
+{
+       FontSetChanger dummy(mi.base, "textnormal");
+       w_ = mathed_char_width(mi.base.font, '[');
+       MathNestInset::metrics(mi);
+       dim_    = cell(0).dim();
+       dim_   += cell(1).dim();
+       dim_   += cell(2).dim();
+       dim_.w += 4 * w_ + 4;
+       metricsMarkers2();
+}
+
+
+void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
+{
+       FontSetChanger dummy(pi.base, "textnormal");
+       drawMarkers2(pi, x, y);
+
+       drawStrBlack(pi, x, y, "[");
+       x += w_;
+       cell(0).draw(pi, x, y);
+       x += cell(0).width();
+       drawStrBlack(pi, x, y, "]");
+       x += w_ + 2;
+
+       drawStrBlack(pi, x, y, "[");
+       x += w_;
+       cell(1).draw(pi, x, y);
+       x += cell(1).width();
+       drawStrBlack(pi, x, y, "]");
+       x += w_ + 2;
+
+       cell(2).draw(pi, x, y);
+}
+
+
+void MathMakeboxInset::write(WriteStream & os) const
+{
+       os << "\\makebox";
+       os << '[' << cell(0) << ']';
+       if (cell(1).size())
+               os << '[' << cell(1) << ']';
+       os << '{' << cell(2) << '}';
+}
+
+
+void MathMakeboxInset::normalize(NormalStream & os) const
+{
+       os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
+}
diff --git a/src/mathed/math_makeboxinset.h b/src/mathed/math_makeboxinset.h
new file mode 100644 (file)
index 0000000..f93de06
--- /dev/null
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+#ifndef MATH_MAKEBOXINSET_H
+#define MATH_MAKEBOXINSET_H
+
+#include "math_nestinset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Extra nesting: \\makebox.
+ *  \author Ling Li
+ *
+ *  Full author contact details are available in file CREDITS
+ */
+
+// consolidate with MathFrameboxInset?
+
+class MathMakeboxInset : public MathNestInset {
+public:
+       ///
+       MathMakeboxInset();
+       ///
+       MathInset * clone() const;
+       ///
+       void metrics(MetricsInfo & mi) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
+       void write(WriteStream & os) const;
+       /// write normalized content
+       void normalize(NormalStream & ns) const;
+       ///
+       mode_type currentMode() const { return TEXT_MODE; }
+private:
+       /// width of '[' in current font
+       mutable int w_;
+};
+
+#endif
index 44649e2cdcb29defba2526ed0afea3d0e1345744..b4163ca3e797083504246af7aeb5e86762b917aa 100644 (file)
@@ -201,7 +201,7 @@ void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const
        pi.pain.line(x, d - 3, x, d, LColor::mathframe);
        pi.pain.line(t, d - 3, t, d, LColor::mathframe);
        pi.pain.line(x, d, x + 3, d, LColor::mathframe);
-       pi.pain.line(t - 2, d, t, d, LColor::mathframe);
+       pi.pain.line(t - 3, d, t, d, LColor::mathframe);
 }
 
 
@@ -215,7 +215,7 @@ void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const
        pi.pain.line(x, a + 3, x, a, LColor::mathframe);
        pi.pain.line(t, a + 3, t, a, LColor::mathframe);
        pi.pain.line(x, a, x + 3, a, LColor::mathframe);
-       pi.pain.line(t - 2, a, t, a, LColor::mathframe);
+       pi.pain.line(t - 3, a, t, a, LColor::mathframe);
 }
 
 
index 947655d85b7a532bed4a8d059b152e3d34cb031c..2d150149b8fe12753e22c24592e5b2da5dbffa28 100644 (file)
@@ -1138,7 +1138,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
                        parse2(cell->back(), FLAG_ITEM, mode, false);
                }
 
-               else if (t.cs() == "framebox") {
+               else if (t.cs() == "framebox" || t.cs() == "makebox") {
                        cell->push_back(createMathInset(t.cs()));
                        parse(cell->back().nucleus()->cell(0), FLAG_OPTION, MathInset::TEXT_MODE);
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, MathInset::TEXT_MODE);