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