2004-01-30 11:41:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_mboxinset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "math_mboxinset.h"
|
|
|
|
|
#include "math_data.h"
|
|
|
|
|
#include "math_mathmlstream.h"
|
|
|
|
|
|
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "bufferparams.h"
|
2004-04-13 12:47:48 +00:00
|
|
|
|
#include "cursor.h"
|
2004-01-30 11:41:12 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "metricsinfo.h"
|
2004-04-07 18:15:29 +00:00
|
|
|
|
#include "output_latex.h"
|
2004-04-08 15:03:33 +00:00
|
|
|
|
#include "outputparams.h"
|
2004-01-30 11:41:12 +00:00
|
|
|
|
#include "paragraph.h"
|
2004-04-07 18:15:29 +00:00
|
|
|
|
#include "texrow.h"
|
2004-01-30 11:41:12 +00:00
|
|
|
|
|
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MathMBoxInset::MathMBoxInset(BufferView & bv)
|
2004-03-18 12:53:43 +00:00
|
|
|
|
: text_(&bv), bv_(&bv)
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
text_.paragraphs().clear();
|
2004-01-30 11:41:12 +00:00
|
|
|
|
text_.paragraphs().push_back(Paragraph());
|
|
|
|
|
text_.paragraphs().back().
|
|
|
|
|
layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
|
2004-03-25 09:16:36 +00:00
|
|
|
|
text_.redoParagraph(0);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto_ptr<InsetBase> MathMBoxInset::clone() const
|
|
|
|
|
{
|
|
|
|
|
return auto_ptr<InsetBase>(new MathMBoxInset(*this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathMBoxInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
|
{
|
|
|
|
|
text_.metrics(mi, dim);
|
|
|
|
|
metricsMarkers2(dim);
|
|
|
|
|
dim_ = dim;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathMBoxInset::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
2004-04-07 18:15:29 +00:00
|
|
|
|
text_.draw(pi, x + 1, y - text_.ascent());
|
2004-01-30 11:41:12 +00:00
|
|
|
|
drawMarkers(pi, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
void MathMBoxInset::write(WriteStream & ws) const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2004-04-08 15:03:33 +00:00
|
|
|
|
if (ws.latex()) {
|
|
|
|
|
ws << "\\mbox{\n";
|
|
|
|
|
TexRow texrow;
|
|
|
|
|
OutputParams runparams;
|
|
|
|
|
latexParagraphs(*bv_->buffer(), text_.paragraphs(),
|
|
|
|
|
ws.os(), texrow, runparams);
|
|
|
|
|
ws.addlines(texrow.rows());
|
|
|
|
|
ws << "}";
|
|
|
|
|
} else {
|
|
|
|
|
ws << "\\mbox{\n";
|
|
|
|
|
text_.write(*bv_->buffer(), ws.os());
|
|
|
|
|
ws << "}";
|
|
|
|
|
}
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-07 18:15:29 +00:00
|
|
|
|
int MathMBoxInset::latex(Buffer const & buf, std::ostream & os,
|
|
|
|
|
OutputParams const & runparams) const
|
|
|
|
|
{
|
|
|
|
|
os << "\\mbox{\n";
|
|
|
|
|
TexRow texrow;
|
|
|
|
|
latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
|
|
|
|
|
os << "}";
|
|
|
|
|
return texrow.rows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2004-02-16 11:58:51 +00:00
|
|
|
|
text_.dispatch(cur, cmd);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LyXText * MathMBoxInset::getText(int) const
|
|
|
|
|
{
|
|
|
|
|
return &text_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-13 12:47:48 +00:00
|
|
|
|
void MathMBoxInset::getCursorPos(LCursor const & cur, int & x, int & y) const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2004-04-13 12:47:48 +00:00
|
|
|
|
x = text_.cursorX(cur.top());
|
|
|
|
|
y = text_.cursorY(cur.top());
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|