]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mboxinset.C
the stuff from the sneak preview:
[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 "paragraph.h"
23
24 using std::auto_ptr;
25 using std::endl;
26
27
28 MathMBoxInset::MathMBoxInset(BufferView & bv)
29         : text_(&bv), bv_(&bv)
30 {
31         text_.paragraphs().clear();
32         text_.paragraphs().push_back(Paragraph());
33         text_.paragraphs().back().
34                 layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
35         text_.redoParagraph(0);
36 }
37
38
39 auto_ptr<InsetBase> MathMBoxInset::clone() const
40 {
41         return auto_ptr<InsetBase>(new MathMBoxInset(*this));
42 }
43
44
45 void MathMBoxInset::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         text_.metrics(mi, dim);
48         metricsMarkers2(dim);
49         dim_ = dim;
50 }
51
52
53 void MathMBoxInset::draw(PainterInfo & pi, int x, int y) const
54 {
55         text_.draw(pi, x + 1, y);
56         drawMarkers(pi, x, y);
57 }
58
59
60 void MathMBoxInset::write(WriteStream & os) const
61 {
62         os << "\\mbox{\n";
63         text_.write(*bv_->buffer(), os.os());
64         os << "}";
65 }
66
67
68 void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
69 {
70         text_.dispatch(cur, cmd);
71 }
72
73
74 LyXText * MathMBoxInset::getText(int) const
75 {
76         return &text_;
77 }
78
79
80 void MathMBoxInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const
81 {
82         x = text_.cursorX(cur);
83         //y = text_.cursorY(cur);
84         y = 100;
85 }