]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_braceinset.C
Andreas' patch to prevent crash on click on previewd inset
[lyx.git] / src / mathed / math_braceinset.C
index 88fd33a5bd541bcf904648d12033e2e0486af202..7e8a70234969bf181baddd470e7044a3dcdf87e5 100644 (file)
@@ -1,13 +1,25 @@
-#include <config.h>
+/**
+ * \file math_braceinset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "math_braceinset.h"
-#include "math_parser.h"
-#include "support.h"
+#include "math_data.h"
 #include "math_mathmlstream.h"
+#include "math_support.h"
+#include "LColor.h"
+#include "support/std_ostream.h"
+#include "frontends/Painter.h"
+
+using std::max;
+using std::auto_ptr;
 
 
 MathBraceInset::MathBraceInset()
@@ -15,40 +27,82 @@ MathBraceInset::MathBraceInset()
 {}
 
 
-MathInset * MathBraceInset::clone() const
-{   
-       return new MathBraceInset(*this);
+MathBraceInset::MathBraceInset(MathArray const & ar)
+       : MathNestInset(1)
+{
+       cell(0) = ar;
+}
+
+
+auto_ptr<InsetBase> MathBraceInset::doClone() const
+{
+       return auto_ptr<InsetBase>(new MathBraceInset(*this));
+}
+
+
+void MathBraceInset::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       cell(0).metrics(mi);
+       Dimension t;
+       mathed_char_dim(mi.base.font, '{', t);
+       dim.asc = max(cell(0).ascent(), t.asc);
+       dim.des = max(cell(0).descent(), t.des);
+       dim.wid = cell(0).width() + 2 * t.wid;
+       metricsMarkers(dim);
+       dim_ = dim;
+}
+
+
+void MathBraceInset::draw(PainterInfo & pi, int x, int y) const
+{
+       LyXFont font = pi.base.font;
+       font.setColor(LColor::latex);
+       Dimension t;
+       mathed_char_dim(font, '{', t);
+       pi.pain.text(x, y, '{', font);
+       cell(0).draw(pi, x + t.wid, y);
+       pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
+       drawMarkers(pi, x, y);
 }
 
 
-void MathBraceInset::write(MathWriteInfo & os) const
+void MathBraceInset::write(WriteStream & os) const
 {
        os << '{' << cell(0) << '}';
 }
 
 
-void MathBraceInset::writeNormal(NormalStream & os) const
+void MathBraceInset::normalize(NormalStream & os) const
+{
+       os << "[block " << cell(0) << ']';
+}
+
+
+void MathBraceInset::maple(MapleStream & os) const
 {
-       os << "[block ";
-       cell(0).writeNormal(os);
-       os << "]";
+       os << cell(0);
 }
 
 
-void MathBraceInset::metrics(MathMetricsInfo const & mi) const
+void MathBraceInset::octave(OctaveStream & os) const
 {
-       xcell(0).metrics(mi);
-       int a, d;
-       mathed_char_dim(LM_TC_TEX, mi, '{', a, d, wid_);
-       ascent_  = std::max(xcell(0).ascent(), a);
-       descent_ = std::max(xcell(0).descent(), a);
-       width_   = xcell(0).width() + 2 * wid_;
+       os << cell(0);
 }
 
 
-void MathBraceInset::draw(Painter & pain, int x, int y) const
-{ 
-       drawChar(pain, LM_TC_TEX, mi_, x, y, '{');
-       xcell(0).draw(pain, x + wid_, y);
-       drawChar(pain, LM_TC_TEX, mi_, x + width_ - wid_, y, '}');
+void MathBraceInset::mathmlize(MathMLStream & os) const
+{
+       os << MTag("mrow") << cell(0) << ETag("mrow");
+}
+
+
+void MathBraceInset::mathematica(MathematicaStream & os) const
+{
+       os << cell(0);
+}
+
+
+void MathBraceInset::infoize(std::ostream & os) const
+{
+       os << "Nested Block: ";
 }