]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathMBox.C
make it compile again (hopefully)
[lyx.git] / src / mathed / InsetMathMBox.C
1 /**
2  * \file InsetMathMBox.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 "InsetMathMBox.h"
14 #include "MathData.h"
15 #include "MathMLStream.h"
16
17 #include "BufferView.h"
18 #include "buffer.h"
19 #include "bufferparams.h"
20 #include "cursor.h"
21 #include "debug.h"
22 #include "metricsinfo.h"
23 #include "output_latex.h"
24 #include "outputparams.h"
25 #include "paragraph.h"
26 #include "texrow.h"
27
28 using lyx::odocstream;
29
30 using std::auto_ptr;
31 using std::endl;
32
33
34 InsetMathMBox::InsetMathMBox(BufferView & bv)
35         : text_(&bv), bv_(&bv)
36 {
37         text_.paragraphs().clear();
38         text_.paragraphs().push_back(Paragraph());
39         text_.paragraphs().back().
40                 layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
41         text_.redoParagraph(0);
42 }
43
44
45 auto_ptr<InsetBase> InsetMathMBox::doClone() const
46 {
47         return auto_ptr<InsetBase>(new InsetMathMBox(*this));
48 }
49
50
51 void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
52 {
53         text_.metrics(mi, dim);
54         metricsMarkers2(dim);
55         dim_ = dim;
56 }
57
58
59 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
60 {
61         text_.draw(pi, x + 1, y);
62         drawMarkers(pi, x, y);
63 }
64
65
66 void InsetMathMBox::write(WriteStream & ws) const
67 {
68         if (ws.latex()) {
69                 ws << "\\mbox{\n";
70                 TexRow texrow;
71                 OutputParams runparams;
72                 latexParagraphs(*bv_->buffer(), text_.paragraphs(),
73                         ws.os(), texrow, runparams);
74                 ws.addlines(texrow.rows());
75                 ws << "}";
76         } else {
77                 ws << "\\mbox{\n";
78                 std::ostringstream os;
79                 text_.write(*bv_->buffer(), os);
80                 ws.os() << lyx::from_utf8(os.str());
81                 ws << "}";
82         }
83 }
84
85
86 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
87                         OutputParams const & runparams) const
88 {
89         os << "\\mbox{\n";
90         TexRow texrow;
91         latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
92         os << "}";
93         return texrow.rows();
94 }
95
96
97 void InsetMathMBox::doDispatch(LCursor & cur, FuncRequest & cmd)
98 {
99         text_.dispatch(cur, cmd);
100 }
101
102
103 LyXText * InsetMathMBox::getText(int) const
104 {
105         return &text_;
106 }
107
108
109 void InsetMathMBox::cursorPos(BufferView const & bv,
110                 CursorSlice const & sl, bool boundary, int & x, int & y) const
111 {
112         x = text_.cursorX(sl, boundary);
113         y = text_.cursorY(sl, boundary);
114 }
115
116
117 void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
118 {
119         text_.drawSelection(pi, x, y);
120 }