2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_biginset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-02-14 12:38:02 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "math_biginset.h"
|
|
|
|
|
#include "math_support.h"
|
|
|
|
|
#include "math_mathmlstream.h"
|
|
|
|
|
#include "math_streamstr.h"
|
|
|
|
|
|
2006-04-20 09:55:45 +00:00
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
2002-02-14 12:38:02 +00:00
|
|
|
|
|
|
|
|
|
MathBigInset::MathBigInset(string const & name, string const & delim)
|
|
|
|
|
: name_(name), delim_(delim)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-04-20 09:55:45 +00:00
|
|
|
|
string MathBigInset::name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> MathBigInset::doClone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathBigInset(*this));
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-18 16:32:52 +00:00
|
|
|
|
MathBigInset::size_type MathBigInset::size() const
|
2002-02-14 12:38:02 +00:00
|
|
|
|
{
|
2006-04-20 09:55:45 +00:00
|
|
|
|
// order: big Big bigg Bigg biggg Biggg
|
|
|
|
|
// 0 1 2 3 4 5
|
|
|
|
|
return name_[0] == 'B' ?
|
|
|
|
|
2 * (name_.size() - 4) + 1:
|
|
|
|
|
2 * (name_.size() - 4);
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double MathBigInset::increase() const
|
|
|
|
|
{
|
2006-04-20 09:55:45 +00:00
|
|
|
|
// The formula used in amsmath.sty is
|
|
|
|
|
// 1.2 * (1.0 + size() * 0.5) - 1.0.
|
|
|
|
|
// We use a smaller step and a bigger offset because our base size
|
|
|
|
|
// is different.
|
|
|
|
|
return (size() + 1) * 0.3;
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathBigInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-02-14 12:38:02 +00:00
|
|
|
|
{
|
2002-07-11 11:27:24 +00:00
|
|
|
|
double const h = mathed_char_ascent(mi.base.font, 'I');
|
|
|
|
|
double const f = increase();
|
2003-05-27 13:55:03 +00:00
|
|
|
|
dim_.wid = 6;
|
|
|
|
|
dim_.asc = int(h + f * h);
|
|
|
|
|
dim_.des = int(f * h);
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathBigInset::draw(PainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2006-04-20 09:55:45 +00:00
|
|
|
|
// mathed_draw_deco does not use the leading backslash, so remove it.
|
|
|
|
|
// Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco
|
|
|
|
|
// would treat it as |.
|
|
|
|
|
string const delim = (delim_ == "\\|") ?
|
|
|
|
|
"Vert" :
|
|
|
|
|
lyx::support::ltrim(delim_, "\\");
|
|
|
|
|
mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(),
|
|
|
|
|
delim);
|
|
|
|
|
setPosCache(pi, x, y);
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigInset::write(WriteStream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << '\\' << name_ << ' ' << delim_;
|
2006-04-20 09:55:45 +00:00
|
|
|
|
if (delim_[0] == '\\')
|
|
|
|
|
os.pendingSpace(true);
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigInset::normalize(NormalStream & os) const
|
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '[' << name_ << ' ' << delim_ << ']';
|
2002-02-14 12:38:02 +00:00
|
|
|
|
}
|
2006-04-20 09:55:45 +00:00
|
|
|
|
|
|
|
|
|
|
2006-04-27 07:55:25 +00:00
|
|
|
|
void MathBigInset::infoize2(std::ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-04-20 09:55:45 +00:00
|
|
|
|
bool MathBigInset::isBigInsetDelim(string const & delim)
|
|
|
|
|
{
|
|
|
|
|
// mathed_draw_deco must handle these
|
|
|
|
|
static char const * const delimiters[] = {
|
|
|
|
|
"(", ")", "\\{", "\\}", "\\lbrace", "\\rbrace", "[", "]",
|
|
|
|
|
"|", "/", "\\|", "\\vert", "\\Vert", "'", "\\backslash",
|
|
|
|
|
"\\langle", "\\lceil", "\\lfloor",
|
|
|
|
|
"\\rangle", "\\rceil", "\\rfloor",
|
|
|
|
|
"\\downarrow", "\\Downarrow",
|
|
|
|
|
"\\uparrow", "\\Uparrow",
|
|
|
|
|
"\\updownarrow", "\\Updownarrow", ""
|
|
|
|
|
};
|
|
|
|
|
return (lyx::support::findToken(delimiters, delim) >= 0);
|
|
|
|
|
}
|