math_arrayinset.h \
math_atom.C \
math_atom.h \
+ math_biginset.C \
+ math_biginset.h \
math_binominset.C \
math_binominset.h \
math_braceinset.C \
--- /dev/null
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_biginset.h"
+#include "math_support.h"
+#include "math_parser.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+
+
+MathBigInset::MathBigInset(string const & name, string const & delim)
+ : name_(name), delim_(delim)
+{}
+
+
+MathInset * MathBigInset::clone() const
+{
+ return new MathBigInset(*this);
+}
+
+
+int MathBigInset::size() const
+{
+ return name_.size() - 4;
+}
+
+
+double MathBigInset::increase() const
+{
+ switch (size()) {
+ case 1: return 0.2;
+ case 2: return 0.44;
+ case 3: return 0.7;
+ default: return 0.0;
+ }
+ return 0.0;
+}
+
+
+void MathBigInset::metrics(MathMetricsInfo const & mi) const
+{
+ double h = mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
+ double f = increase();
+ width_ = 6;
+ ascent_ = int(h + f * h);
+ descent_ = int(f * h);
+}
+
+
+void MathBigInset::draw(Painter & pain, int x, int y) const
+{
+ mathed_draw_deco(pain, x + 1, y - ascent_, 4, height(), delim_);
+}
+
+
+void MathBigInset::write(WriteStream & os) const
+{
+ os << '\\' << name_ << ' ' << delim_;
+}
+
+
+void MathBigInset::normalize(NormalStream & os) const
+{
+ os << "[" << name_ << ' ' << delim_ << ']';
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_BIGINSET_H
+#define MATH_BIGINSET_H
+
+#include "math_diminset.h"
+#include "LString.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Inset for \bigl & Co.
+ \author André Pönitz
+ */
+
+class MathBigInset : public MathDimInset {
+public:
+ ///
+ MathBigInset(string const & name, string const & delim);
+ ///
+ MathInset * clone() const;
+ ///
+ void draw(Painter &, int x, int y) const;
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void metrics(MathMetricsInfo const & st) const;
+ ///
+ void normalize(NormalStream & os) const;
+
+private:
+ ///
+ int size() const;
+ ///
+ double increase() const;
+
+ /// \bigl or what?
+ string const name_;
+ /// ( or [ or Vert...
+ string const delim_;
+};
+
+#endif
}
-string MathDelimInset::latexName(string const & name)
-{
- if (name == "(")
- return name;
- if (name == "[")
- return name;
- if (name == ".")
- return name;
- if (name == ")")
- return name;
- if (name == "]")
- return name;
- if (name == "/")
- return name;
- if (name == "|")
- return name;
- return "\\" + name + " ";
-}
-
-
void MathDelimInset::write(WriteStream & os) const
{
- os << "\\left" << latexName(left_) << cell(0)
- << "\\right" << latexName(right_);
+ os << "\\left" << convertDelimToLatexName(left_) << cell(0)
+ << "\\right" << convertDelimToLatexName(right_);
}
void MathDelimInset::normalize(NormalStream & os) const
{
- os << "[delim " << latexName(left_) << ' '
- << latexName(right_) << ' ' << cell(0) << ']';
+ os << "[delim " << convertDelimToLatexName(left_) << ' '
+ << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
}
class MathDelimInset : public MathNestInset {
public:
///
- MathDelimInset(string const &, string const &);
+ MathDelimInset(string const & left, string const & right);
///
MathInset * clone() const;
///
private:
///
int dw() const;
- ///
- static string latexName(string const & name);
};
#endif
return theFontNames[code - LM_TC_RM];
return 0;
}
+
+string convertDelimToLatexName(string const & name)
+{
+ if (name == "(")
+ return name;
+ if (name == "[")
+ return name;
+ if (name == ".")
+ return name;
+ if (name == ")")
+ return name;
+ if (name == "]")
+ return name;
+ if (name == "/")
+ return name;
+ if (name == "|")
+ return name;
+ return "\\" + name + " ";
+}
+
+
char const * math_font_name(MathTextCodes type);
+string convertDelimToLatexName(string const & name);
#endif