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
This commit is contained in:
André Pönitz 2001-09-05 12:57:13 +00:00
parent 971f1755d0
commit 3b2f6decf2
8 changed files with 76 additions and 15 deletions

View File

@ -80,6 +80,8 @@ libmathed_la_SOURCES = \
math_spaceinset.h \ math_spaceinset.h \
math_specialcharinset.C \ math_specialcharinset.C \
math_specialcharinset.h \ math_specialcharinset.h \
math_splitinset.C \
math_splitinset.h \
math_sqrtinset.C \ math_sqrtinset.C \
math_sqrtinset.h \ math_sqrtinset.h \
math_stackrelinset.C \ math_stackrelinset.C \

View File

@ -24,6 +24,7 @@ MathGridInset::RowInfo::RowInfo()
{} {}
int MathGridInset::RowInfo::skipPixels() const int MathGridInset::RowInfo::skipPixels() const
{ {
#ifdef WITH_WARNINGS #ifdef WITH_WARNINGS
@ -46,10 +47,7 @@ MathGridInset::MathGridInset(int m, int n)
lyxerr << "positve number of columns expected\n"; lyxerr << "positve number of columns expected\n";
if (n <= 0) if (n <= 0)
lyxerr << "positve number of rows expected\n"; lyxerr << "positve number of rows expected\n";
for (int col = 0; col < m; ++col) { setDefaults();
colinfo_[col].skip_ = defaultColSpace(col);
colinfo_[col].align_ = defaultColAlign(col);
}
} }
@ -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) void MathGridInset::halign(string const & hh)
{ {

View File

@ -138,6 +138,8 @@ public:
virtual int defaultColSpace(int) { return 10; } virtual int defaultColSpace(int) { return 10; }
/// ///
virtual char defaultColAlign(int) { return 'c'; } virtual char defaultColAlign(int) { return 'c'; }
///
void setDefaults();
protected: protected:
/// returns proper 'end of line' code for LaTeX /// returns proper 'end of line' code for LaTeX

View File

@ -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 void MathMatrixInset::metrics(MathStyles) const
{ {
size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY; size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;

View File

@ -76,8 +76,6 @@ public:
MathInsetTypes getType() const; MathInsetTypes getType() const;
private: private:
///
void setDefaults();
/// ///
void setType(MathInsetTypes t); void setType(MathInsetTypes t);
/// ///

View File

@ -40,6 +40,7 @@
#include "math_sqrtinset.h" #include "math_sqrtinset.h"
#include "math_scriptinset.h" #include "math_scriptinset.h"
#include "math_specialcharinset.h" #include "math_specialcharinset.h"
#include "math_splitinset.h"
#include "math_sqrtinset.h" #include "math_sqrtinset.h"
#include "debug.h" #include "debug.h"
#include "support.h" #include "support.h"
@ -825,6 +826,10 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
m->halign(halign); m->halign(halign);
parse_lines(m, false, false); parse_lines(m, false, false);
array.push_back(m); array.push_back(m);
} else if (name == "split") {
MathSplitInset * m = new MathSplitInset(1);
parse_lines(m, false, false);
array.push_back(m);
} else } else
lyxerr[Debug::MATHED] << "unknow math inset begin '" << name << "'\n"; lyxerr[Debug::MATHED] << "unknow math inset begin '" << name << "'\n";
} }

View File

@ -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";
}

View File

@ -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