From 2535ea14bd8eadc5035e1cf23e6347983a8b280f Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Wed, 22 Feb 2006 12:26:06 +0000 Subject: [PATCH] readd xymatrix inset (bug 2238) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13265 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 7 +++ src/mathed/Makefile.am | 2 + src/mathed/math_factory.C | 3 ++ src/mathed/math_parser.C | 5 +++ src/mathed/math_xymatrixinset.C | 80 +++++++++++++++++++++++++++++++++ src/mathed/math_xymatrixinset.h | 47 +++++++++++++++++++ 6 files changed, 144 insertions(+) create mode 100644 src/mathed/math_xymatrixinset.C create mode 100644 src/mathed/math_xymatrixinset.h diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index ac4b0002f4..b6431c8cab 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,10 @@ +2006-02-17 Georg Baum + + * math_xymatrixinset.[Ch]: Readd + * Makefile.am: Readd math_xymatrixinset.[Ch] + * math_factory.C (createMathInset): Readd xymatrix + * math_parser.C (parse1): Readd xymatrix + 2006-02-13 Georg Baum * math_macro.C (editXY): Prevent crash (fix by Andrew Beck) diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 62cca54f10..1ae4404260 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -147,6 +147,8 @@ libmathed_la_SOURCES = \ math_undersetinset.h \ math_xarrowinset.C \ math_xarrowinset.h \ + math_xymatrixinset.C \ + math_xymatrixinset.h \ command_inset.h \ command_inset.C \ ref_inset.h \ diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index e0529ad5e4..9faf0e8090 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -50,6 +50,7 @@ #include "math_undersetinset.h" #include "math_unknowninset.h" #include "math_xarrowinset.h" +#include "math_xymatrixinset.h" //#include "insets/insetref.h" #include "ref_inset.h" @@ -292,6 +293,8 @@ MathAtom createMathInset(string const & s) return MathAtom(new MathMakeboxInset); if (s == "kern") return MathAtom(new MathKernInset); + if (s == "xymatrix") + return MathAtom(new MathXYMatrixInset); if (s == "xrightarrow" || s == "xleftarrow") return MathAtom(new MathXArrowInset(s)); if (s == "split" || s == "gathered" || s == "aligned" || s == "alignedat") diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index a050a512cc..be12a451e5 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -1248,6 +1248,11 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, parse2(cell->back(), FLAG_ITEM, mode, false); } + else if (t.cs() == "xymatrix") { + cell->push_back(createMathInset(t.cs())); + parse2(cell->back(), FLAG_ITEM, mode, false); + } + 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); diff --git a/src/mathed/math_xymatrixinset.C b/src/mathed/math_xymatrixinset.C new file mode 100644 index 0000000000..581dab36ee --- /dev/null +++ b/src/mathed/math_xymatrixinset.C @@ -0,0 +1,80 @@ +/** + * \file math_xymatrixinset.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 + +#include "math_xymatrixinset.h" +#include "math_mathmlstream.h" +#include "math_streamstr.h" + +#include "LaTeXFeatures.h" +#include "support/std_ostream.h" + + +MathXYMatrixInset::MathXYMatrixInset() + : MathGridInset(1, 1) +{} + + +std::auto_ptr MathXYMatrixInset::doClone() const +{ + return std::auto_ptr(new MathXYMatrixInset(*this)); +} + + +int MathXYMatrixInset::colsep() const +{ + return 40; +} + + +int MathXYMatrixInset::rowsep() const +{ + return 40; +} + + +void MathXYMatrixInset::metrics(MetricsInfo & mi, Dimension & dim) const +{ + if (mi.base.style == LM_ST_DISPLAY) + mi.base.style = LM_ST_TEXT; + MathGridInset::metrics(mi, dim); +} + + +void MathXYMatrixInset::write(WriteStream & os) const +{ + os << "\\xymatrix{"; + MathGridInset::write(os); + os << "}\n"; +} + + +void MathXYMatrixInset::infoize(std::ostream & os) const +{ + os << "xymatrix "; + MathGridInset::infoize(os); +} + + +void MathXYMatrixInset::normalize(NormalStream & os) const +{ + os << "[xymatrix "; + MathGridInset::normalize(os); + os << ']'; +} + + +void MathXYMatrixInset::maple(MapleStream & os) const +{ + os << "xymatrix("; + MathGridInset::maple(os); + os << ')'; +} diff --git a/src/mathed/math_xymatrixinset.h b/src/mathed/math_xymatrixinset.h new file mode 100644 index 0000000000..d27e3e3832 --- /dev/null +++ b/src/mathed/math_xymatrixinset.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +/** + * \file math_xymatrixinset.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_XYMATRIX_H +#define MATH_XYMATRIX_H + +#include "lyxlength.h" +#include "math_gridinset.h" + + +class MathXYMatrixInset : public MathGridInset { +public: + /// + MathXYMatrixInset(); + /// + void metrics(MetricsInfo &, Dimension &) const; + /// + MathXYMatrixInset const * asXYMatrixInset() const { return this; } + /// + virtual int colsep() const; + /// + virtual int rowsep() const; + + /// + void normalize(); + /// + void write(WriteStream & os) const; + /// + void infoize(std::ostream & os) const; + /// + void normalize(NormalStream &) const; + /// + void maple(MapleStream &) const; +private: + /// + virtual std::auto_ptr doClone() const; +}; + +#endif -- 2.39.2