From 3b2f6decf27da05ecb59d23ec15636bebbc3953e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 5 Sep 2001 12:57:13 +0000 Subject: [PATCH] read/write support for the AMS split environment git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2688 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/Makefile.am | 2 ++ src/mathed/math_gridinset.C | 14 ++++++++++---- src/mathed/math_gridinset.h | 2 ++ src/mathed/math_matrixinset.C | 9 --------- src/mathed/math_matrixinset.h | 2 -- src/mathed/math_parser.C | 5 +++++ src/mathed/math_splitinset.C | 31 +++++++++++++++++++++++++++++++ src/mathed/math_splitinset.h | 26 ++++++++++++++++++++++++++ 8 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 src/mathed/math_splitinset.C create mode 100644 src/mathed/math_splitinset.h diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 5ffdd9c7e5..06d0aafb91 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -80,6 +80,8 @@ libmathed_la_SOURCES = \ math_spaceinset.h \ math_specialcharinset.C \ math_specialcharinset.h \ + math_splitinset.C \ + math_splitinset.h \ math_sqrtinset.C \ math_sqrtinset.h \ math_stackrelinset.C \ diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index c5863e6811..daf70daa96 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -24,6 +24,7 @@ MathGridInset::RowInfo::RowInfo() {} + int MathGridInset::RowInfo::skipPixels() const { #ifdef WITH_WARNINGS @@ -46,10 +47,7 @@ MathGridInset::MathGridInset(int m, int n) lyxerr << "positve number of columns expected\n"; if (n <= 0) lyxerr << "positve number of rows expected\n"; - for (int col = 0; col < m; ++col) { - colinfo_[col].skip_ = defaultColSpace(col); - colinfo_[col].align_ = defaultColAlign(col); - } + setDefaults(); } @@ -59,6 +57,14 @@ int MathGridInset::index(int row, int col) const } +void MathGridInset::setDefaults() +{ + for (int col = 0; col < ncols(); ++col) { + colinfo_[col].align_ = defaultColAlign(col); + colinfo_[col].skip_ = defaultColSpace(col); + } +} + void MathGridInset::halign(string const & hh) { diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index b3af17a760..25555c1e91 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -138,6 +138,8 @@ public: virtual int defaultColSpace(int) { return 10; } /// virtual char defaultColAlign(int) { return 'c'; } + /// + void setDefaults(); protected: /// returns proper 'end of line' code for LaTeX diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 32f032b485..0401b8ba17 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -108,15 +108,6 @@ int MathMatrixInset::defaultColSpace(int col) } -void MathMatrixInset::setDefaults() -{ - for (int col = 0; col < ncols(); ++col) { - colinfo_[col].align_ = defaultColAlign(col); - colinfo_[col].skip_ = defaultColSpace(col); - } -} - - void MathMatrixInset::metrics(MathStyles) const { size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY; diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index d4e2b8ed58..0bacd40534 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -76,8 +76,6 @@ public: MathInsetTypes getType() const; private: - /// - void setDefaults(); /// void setType(MathInsetTypes t); /// diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 1ae4622524..ad0e5c0116 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -40,6 +40,7 @@ #include "math_sqrtinset.h" #include "math_scriptinset.h" #include "math_specialcharinset.h" +#include "math_splitinset.h" #include "math_sqrtinset.h" #include "debug.h" #include "support.h" @@ -825,6 +826,10 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) m->halign(halign); parse_lines(m, false, false); array.push_back(m); + } else if (name == "split") { + MathSplitInset * m = new MathSplitInset(1); + parse_lines(m, false, false); + array.push_back(m); } else lyxerr[Debug::MATHED] << "unknow math inset begin '" << name << "'\n"; } diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C new file mode 100644 index 0000000000..e7b5c18f18 --- /dev/null +++ b/src/mathed/math_splitinset.C @@ -0,0 +1,31 @@ +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "math_splitinset.h" +#include "support/LOstream.h" + + +MathSplitInset::MathSplitInset(int n) + : MathGridInset(2, n) +{ + setDefaults(); +} + + +MathInset * MathSplitInset::clone() const +{ + return new MathSplitInset(*this); +} + + +void MathSplitInset::write(std::ostream & os, bool fragile) const +{ + if (fragile) + os << "\\protect"; + os << "\\begin{split}"; + MathGridInset::write(os, fragile); + if (fragile) + os << "\\protect"; + os << "\\end{split}\n"; +} diff --git a/src/mathed/math_splitinset.h b/src/mathed/math_splitinset.h new file mode 100644 index 0000000000..2ef9348db9 --- /dev/null +++ b/src/mathed/math_splitinset.h @@ -0,0 +1,26 @@ +// -*- C++ -*- +#ifndef MATH_SPLITINSET_H +#define MATH_SPLITINSET_H + +#include "math_gridinset.h" + +#ifdef __GNUG__ +#pragma interface +#endif + + +class MathSplitInset : public MathGridInset { +public: + /// + explicit MathSplitInset(int n); + /// + MathInset * clone() const; + /// + void write(std::ostream &, bool fragile) const; + /// + int defaultColSpace(int) { return 0; } + /// + char defaultColAlign(int) { return 'l'; } +}; + +#endif