]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_binominset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_binominset.C
index 58b1acafa22bfcdd76c9b733cb3615bee8d688e6..84a875ec8d13f597ee5eb84c027d1dcb04785213 100644 (file)
@@ -1,6 +1,5 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
+
 
 #include "math_binominset.h"
 #include "math_support.h"
@@ -8,12 +7,16 @@
 #include "math_mathmlstream.h"
 
 
-MathBinomInset::MathBinomInset()
+using std::max;
+
+
+MathBinomInset::MathBinomInset(bool choose)
+       : choose_(choose)
 {}
 
 
 MathInset * MathBinomInset::clone() const
-{   
+{
        return new MathBinomInset(*this);
 }
 
@@ -29,39 +32,38 @@ int MathBinomInset::dw() const
 }
 
 
-void MathBinomInset::metrics(MathMetricsInfo const & st) const
+void MathBinomInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo mi = st;
-       smallerStyleFrac(mi);
-       xcell(0).metrics(mi);
-       xcell(1).metrics(mi);
-       ascent_  = xcell(0).height() + 4 + 5;
-       descent_ = xcell(1).height() + 4 - 5; 
-       width_   = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4; 
+       MathScriptChanger dummy(mi.base);
+       cell(0).metrics(mi);
+       cell(1).metrics(mi);
+       dim_.a = cell(0).height() + 4 + 5;
+       dim_.d = cell(1).height() + 4 - 5;
+       dim_.w = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
 }
 
 
-void MathBinomInset::draw(Painter & pain, int x, int y) const
+void MathBinomInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        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(), "(");
-       mathed_draw_deco(pain, x + width() - dw(), y - ascent_, dw(), height(), ")");
+       MathScriptChanger dummy(pi.base);
+       cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
+       cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 3 - 5);
+       mathed_draw_deco(pi, x, y - ascent(), dw(), height(), "(");
+       mathed_draw_deco(pi, x + width() - dw(), y - ascent(),  dw(), height(), ")");
 }
 
 
-void MathBinomInset::write(MathWriteInfo & os) const
+void MathBinomInset::write(WriteStream & os) const
 {
-       os << '{' << cell(0) << " \\choose " << cell(1) << '}';
+       if (choose_)
+               os << '{' << cell(0) << " \\choose " << cell(1) << '}';
+       else
+               os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
 }
 
 
-void MathBinomInset::writeNormal(NormalStream & os) const
+void MathBinomInset::normalize(NormalStream & os) const
 {
-       os << "[binom ";
-       cell(0).writeNormal(os);
-       os << " ";
-       cell(1).writeNormal(os);
-       os << "] ";
+       os << "[binom " << cell(0) << ' ' << cell(1) << ']';
 }