2004-01-30 11:41:12 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMathMBox.C
|
2004-01-30 11:41:12 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathMBox.h"
|
|
|
|
|
#include "MathData.h"
|
2004-01-30 11:41:12 +00:00
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using odocstream;
|
2006-10-19 19:16:33 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathMBox::InsetMathMBox(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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetMathMBox::doClone() const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetMathMBox(*this));
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
text_.metrics(mi, dim);
|
|
|
|
|
metricsMarkers2(dim);
|
2006-11-28 15:15:49 +00:00
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2004-11-30 01:59:49 +00:00
|
|
|
|
text_.draw(pi, x + 1, y);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
drawMarkers(pi, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathMBox::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";
|
2006-10-19 19:16:33 +00:00
|
|
|
|
std::ostringstream os;
|
|
|
|
|
text_.write(*bv_->buffer(), os);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
ws.os() << from_utf8(os.str());
|
2004-04-08 15:03:33 +00:00
|
|
|
|
ws << "}";
|
|
|
|
|
}
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
|
2004-04-07 18:15:29 +00:00
|
|
|
|
OutputParams const & runparams) const
|
|
|
|
|
{
|
|
|
|
|
os << "\\mbox{\n";
|
|
|
|
|
TexRow texrow;
|
|
|
|
|
latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
|
|
|
|
|
os << "}";
|
|
|
|
|
return texrow.rows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathMBox::doDispatch(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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
LyXText * InsetMathMBox::getText(int) const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
return &text_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-17 16:23:27 +00:00
|
|
|
|
void InsetMathMBox::cursorPos(BufferView const & bv,
|
|
|
|
|
CursorSlice const & sl, bool boundary, int & x, int & y) const
|
2004-01-30 11:41:12 +00:00
|
|
|
|
{
|
2005-07-15 15:49:40 +00:00
|
|
|
|
x = text_.cursorX(sl, boundary);
|
|
|
|
|
y = text_.cursorY(sl, boundary);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
}
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
|
2004-11-30 01:59:49 +00:00
|
|
|
|
{
|
|
|
|
|
text_.drawSelection(pi, x, y);
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|