math_cursor.C:
math_hash.C: simplifications
+ * math_binom.[Ch]: new files for "native" \binom/\choose inset
+
* math_parser.C:
- math_cursor.C: reading support for TeX style \over
+ math_cursor.C: reading support for TeX style \over and \choose
2001-08-10 André Pönitz <poenitz@gmx.net>
math_arrayinset.h \
math_bigopinset.C \
math_bigopinset.h \
+ math_binominset.C \
+ math_binominset.h \
math_charinset.C \
math_charinset.h \
math_cursor.C \
--- /dev/null
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_binominset.h"
+#include "math_parser.h"
+#include "support.h"
+#include "support/LOstream.h"
+
+
+MathBinomInset::MathBinomInset()
+{}
+
+
+MathInset * MathBinomInset::clone() const
+{
+ return new MathBinomInset(*this);
+}
+
+
+int MathBinomInset::dw() const
+{
+ int w = height()/5;
+ if (w > 15)
+ w = 15;
+ if (w < 6)
+ w = 6;
+ return w;
+}
+
+
+void MathBinomInset::metrics(MathStyles st) const
+{
+ size_ = smallerStyleFrac(st);
+ xcell(0).metrics(size_);
+ xcell(1).metrics(size_);
+ ascent_ = xcell(0).height() + 4 + 5;
+ descent_ = xcell(1).height() + 4 - 5;
+ width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
+}
+
+
+void MathBinomInset::draw(Painter & pain, int x, int y) const
+{
+ xo(x);
+ yo(y);
+ int m = x + width() / 2;
+ xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
+ xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
+ mathed_draw_deco(pain, x, y - ascent_,
+ dw(), height(), in_word_set("("));
+ mathed_draw_deco(pain, x + width() - dw(), y - ascent_,
+ dw(), height(), in_word_set(")"));
+}
+
+
+void MathBinomInset::write(std::ostream & os, bool fragile) const
+{
+ os << '{';
+ cell(0).write(os, fragile);
+ os << " \\choose ";
+ cell(1).write(os, fragile);
+ os << '}';
+}
+
+
+void MathBinomInset::writeNormal(std::ostream & os) const
+{
+ os << "[binom ";
+ cell(0).writeNormal(os);
+ os << " ";
+ cell(1).writeNormal(os);
+ os << "] ";
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_BINOMINSET_H
+#define MATH_DINOMINSET_H
+
+#include "math_fracbase.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Binom like objects
+ \author André Pönitz
+ */
+class MathBinomInset : public MathFracbaseInset {
+public:
+ ///
+ MathBinomInset();
+ ///
+ MathInset * clone() const;
+ ///
+ void write(std::ostream &, bool fragile) const;
+ ///
+ void writeNormal(std::ostream &) const;
+ ///
+ void metrics(MathStyles st) const;
+ ///
+ void draw(Painter &, int x, int y) const;
+private:
+ ///
+ int dw() const;
+};
+
+#endif
#include "math_charinset.h"
#include "math_decorationinset.h"
#include "math_deliminset.h"
-#include "math_fracinset.h"
#include "math_funcinset.h"
#include "math_macro.h"
#include "math_macrotable.h"
return;
}
- if (s == "\\over") {
+ if (s == "\\over" || s == "\\choose") {
MathArray ar = array();
- MathFracInset * p = new MathFracInset;
+ MathInset * p = createMathInset(in_word_set(s.substr(1)));
p->cell(0).swap(array());
pos() = 0;
niceInsert(p);
return;
}
- if (s.size() > 1)
- return niceInsert(new MathFuncInset(s.substr(1)));
+ if (s.size() > 1) {
+ niceInsert(new MathFuncInset(s.substr(1)));
+ return;
+ }
// we got just a single char now
#include "math_parser.h"
#include "math_bigopinset.h"
+#include "math_binominset.h"
#include "math_decorationinset.h"
#include "math_dotsinset.h"
#include "math_funcinset.h"
return new MathSymbolInset(l);
case LM_TK_STACK:
return new MathStackrelInset;
+ case LM_TK_BINOM:
+ case LM_TK_CHOOSE:
+ return new MathBinomInset;
+ case LM_TK_OVER:
case LM_TK_FRAC:
return new MathFracInset;
case LM_TK_SQRT:
{"biguplus", LM_TK_NOGLYPHB, 0, LMB_NONE},
{"bigvee", LM_TK_NOGLYPHB, 0, LMB_NONE},
{"bigwedge", LM_TK_NOGLYPHB, 0, LMB_NONE},
+ {"binom", LM_TK_BINOM, 0, LMB_NONE},
{"bmod", LM_TK_FUNC, 0, LMB_NONE},
{"bot", LM_TK_SYM, LM_bot, LMB_NONE},
{"bowtie", LM_TK_NOGLYPH, 0, LMB_RELATION},
{"cdots", LM_TK_DOTS, LM_cdots, LMB_NONE},
{"check", LM_TK_DECORATION, LM_check, LMB_NONE},
{"chi", LM_TK_SYM, LM_chi, LMB_NONE},
+ {"choose", LM_TK_CHOOSE, 0, LMB_NONE},
{"circ", LM_TK_NOGLYPH, 0, LMB_OPERATOR},
{"clubsuit", LM_TK_SYM, LM_clubsuit, LMB_NONE},
{"cong", LM_TK_SYM, LM_cong, LMB_RELATION},
createTemplate("to", 0, "\\rightarrow");
//createTemplate("lint", 4, "\\int_#1^#2#3 d#4");
//createTemplate("silentmult", 0, "\\cdot");
- createTemplate("binom", 2, "\\left(\\frac#1#2\\right)");
+ //createTemplate("binom", 2, "\\left(\\frac#1#2\\right)");
}
#include "math_charinset.h"
#include "math_deliminset.h"
#include "math_factory.h"
-#include "math_fracinset.h"
#include "math_funcinset.h"
#include "math_macro.h"
#include "math_macrotable.h"
curr_label_ = lexArg('{', true);
break;
+ case LM_TK_CHOOSE:
case LM_TK_OVER:
{
- MathFracInset * p = new MathFracInset;
+ limits = 0;
+ MathInset * p = createMathInset(lval_);
p->cell(0).swap(array);
array.push_back(p);
parse_into(p->cell(1), FLAG_BLOCK);
///
LM_TK_SYM,
///
- LM_TK_OVER,
- ///
LM_TK_CHOOSE,
///
+ LM_TK_BINOM,
+ ///
+ LM_TK_OVER,
+ ///
LM_TK_FRAC,
///
LM_TK_SQRT,