]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mboxinset.C
soem more IU for \mbox
[lyx.git] / src / mathed / math_mboxinset.C
1 /**
2  * \file math_mboxinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_mboxinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16
17 #include "BufferView.h"
18 #include "buffer.h"
19 #include "bufferparams.h"
20 #include "debug.h"
21 #include "metricsinfo.h"
22 #include "output_latex.h"
23 #include "paragraph.h"
24 #include "texrow.h"
25
26 using std::auto_ptr;
27 using std::endl;
28
29
30 MathMBoxInset::MathMBoxInset(BufferView & bv)
31         : text_(&bv), bv_(&bv)
32 {
33         text_.paragraphs().clear();
34         text_.paragraphs().push_back(Paragraph());
35         text_.paragraphs().back().
36                 layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
37         text_.redoParagraph(0);
38 }
39
40
41 auto_ptr<InsetBase> MathMBoxInset::clone() const
42 {
43         return auto_ptr<InsetBase>(new MathMBoxInset(*this));
44 }
45
46
47 void MathMBoxInset::metrics(MetricsInfo & mi, Dimension & dim) const
48 {
49         text_.metrics(mi, dim);
50         metricsMarkers2(dim);
51         dim_ = dim;
52 }
53
54
55 void MathMBoxInset::draw(PainterInfo & pi, int x, int y) const
56 {
57         text_.draw(pi, x + 1, y - text_.ascent());
58         drawMarkers(pi, x, y);
59 }
60
61
62 void MathMBoxInset::write(WriteStream & os) const
63 {
64         os << "\\mbox{\n";
65         text_.write(*bv_->buffer(), os.os());
66         os << "}";
67 }
68
69
70 int MathMBoxInset::latex(Buffer const & buf, std::ostream & os,
71                         OutputParams const & runparams) const
72 {
73         os << "\\mbox{\n";
74         TexRow texrow;
75         latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
76         os << "}";
77         return texrow.rows();
78 }
79
80
81 void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
82 {
83         text_.dispatch(cur, cmd);
84 }
85
86
87 LyXText * MathMBoxInset::getText(int) const
88 {
89         return &text_;
90 }
91
92
93 void MathMBoxInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const
94 {
95         x = text_.cursorX(cur);
96         y = text_.cursorY(cur);
97 }