* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author André Pönitz
+ * \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "InsetMathBrace.h"
+
#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
-#include "Color.h"
+#include "MetricsInfo.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
-#include "support/std_ostream.h"
-
-namespace lyx {
+#include <ostream>
+#include <algorithm>
-using std::max;
-using std::auto_ptr;
+using namespace std;
+namespace lyx {
-InsetMathBrace::InsetMathBrace()
- : InsetMathNest(1)
+InsetMathBrace::InsetMathBrace(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
InsetMathBrace::InsetMathBrace(MathData const & ar)
- : InsetMathNest(1)
+ : InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1)
{
cell(0) = ar;
}
-auto_ptr<Inset> InsetMathBrace::doClone() const
+Inset * InsetMathBrace::clone() const
{
- return auto_ptr<Inset>(new InsetMathBrace(*this));
+ return new InsetMathBrace(*this);
}
-bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
{
- cell(0).metrics(mi);
- Dimension t = theFontMetrics(mi.base.font).dimension('{');
- dim.asc = max(cell(0).ascent(), t.asc);
- dim.des = max(cell(0).descent(), t.des);
- dim.wid = cell(0).width() + 2 * t.wid;
+ Dimension dim0;
+ cell(0).metrics(mi, dim0);
+ FontInfo font = mi.base.font;
+ augmentFont(font, "mathnormal");
+ Dimension t = theFontMetrics(font).dimension('{');
+ dim.asc = max(dim0.asc, t.asc);
+ dim.des = max(dim0.des, t.des);
+ dim.wid = dim0.width() + 2 * t.wid;
metricsMarkers(dim);
- if (dim_ == dim)
- return false;
- dim_ = dim;
- return true;
}
void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
{
- LyXFont font = pi.base.font;
- font.setColor(Color::latex);
+ FontInfo font = pi.base.font;
+ augmentFont(font, "mathnormal");
+ font.setShape(UP_SHAPE);
+ font.setColor(Color_latex);
Dimension t = theFontMetrics(font).dimension('{');
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);
+ Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
+ pi.pain.text(x + t.wid + dim0.width(), y, '}', font);
drawMarkers(pi, x, y);
}
}
+void InsetMathBrace::htmlize(HtmlStream & os) const
+{
+ os << cell(0);
+}
+
+
void InsetMathBrace::mathematica(MathematicaStream & os) const
{
os << cell(0);