mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 04:17:43 +00:00
e24bf64c68
* InsetBase and all derivates: - metrics(MetricsInfo & mi, Dimension & dim) now returns a bool (true if metrics changed). * MathData and all derivates: - metrics(MetricsInfo & mi, Dimension & dim): ditto. * RenderBase and all derivates: - metrics(MetricsInfo & mi, Dimension & dim): ditto. * lyxtext.h/text.C: - LyXText::metrics(MetricsInfo & mi, Dimension & dim): ditto. - LyXText::redoParagraph(): take into account potential change in inset metrics. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16091 a592a061-630c-0410-9148-cb99ea01b6c8
129 lines
2.4 KiB
C
129 lines
2.4 KiB
C
/**
|
|
* \file InsetMathMBox.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.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "InsetMathMBox.h"
|
|
#include "MathData.h"
|
|
|
|
#include "BufferView.h"
|
|
#include "buffer.h"
|
|
#include "bufferparams.h"
|
|
#include "cursor.h"
|
|
#include "debug.h"
|
|
#include "metricsinfo.h"
|
|
#include "output_latex.h"
|
|
#include "outputparams.h"
|
|
#include "paragraph.h"
|
|
#include "texrow.h"
|
|
|
|
|
|
namespace lyx {
|
|
|
|
using odocstream;
|
|
|
|
using std::auto_ptr;
|
|
using std::endl;
|
|
|
|
|
|
InsetMathMBox::InsetMathMBox(BufferView & bv)
|
|
: text_(&bv), bv_(&bv)
|
|
{
|
|
text_.paragraphs().clear();
|
|
text_.paragraphs().push_back(Paragraph());
|
|
text_.paragraphs().back().
|
|
layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
|
|
text_.redoParagraph(0);
|
|
}
|
|
|
|
|
|
auto_ptr<InsetBase> InsetMathMBox::doClone() const
|
|
{
|
|
return auto_ptr<InsetBase>(new InsetMathMBox(*this));
|
|
}
|
|
|
|
|
|
bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
{
|
|
text_.metrics(mi, dim);
|
|
metricsMarkers2(dim);
|
|
if (dim_ == dim)
|
|
return false;
|
|
dim_ = dim;
|
|
return true;
|
|
}
|
|
|
|
|
|
void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
|
|
{
|
|
text_.draw(pi, x + 1, y);
|
|
drawMarkers(pi, x, y);
|
|
}
|
|
|
|
|
|
void InsetMathMBox::write(WriteStream & ws) const
|
|
{
|
|
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";
|
|
std::ostringstream os;
|
|
text_.write(*bv_->buffer(), os);
|
|
ws.os() << from_utf8(os.str());
|
|
ws << "}";
|
|
}
|
|
}
|
|
|
|
|
|
int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
|
|
OutputParams const & runparams) const
|
|
{
|
|
os << "\\mbox{\n";
|
|
TexRow texrow;
|
|
latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
|
|
os << "}";
|
|
return texrow.rows();
|
|
}
|
|
|
|
|
|
void InsetMathMBox::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|
{
|
|
text_.dispatch(cur, cmd);
|
|
}
|
|
|
|
|
|
LyXText * InsetMathMBox::getText(int) const
|
|
{
|
|
return &text_;
|
|
}
|
|
|
|
|
|
void InsetMathMBox::cursorPos(BufferView const & bv,
|
|
CursorSlice const & sl, bool boundary, int & x, int & y) const
|
|
{
|
|
x = text_.cursorX(sl, boundary);
|
|
y = text_.cursorY(sl, boundary);
|
|
}
|
|
|
|
|
|
void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
|
|
{
|
|
text_.drawSelection(pi, x, y);
|
|
}
|
|
|
|
|
|
} // namespace lyx
|