]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binaryopinset.C
bug + spped fixes + small stuff
[lyx.git] / src / mathed / math_binaryopinset.C
1 /**
2  * \file math_binaryopinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "math_binaryopinset.h"
15 #include "PainterInfo.h"
16 #include "support/std_ostream.h"
17 #include "math_support.h"
18 #include "math_mathmlstream.h"
19
20
21 using std::max;
22
23
24 MathBinaryOpInset::MathBinaryOpInset(char op)
25         : MathNestInset(2), op_(op)
26 {}
27
28
29 auto_ptr<InsetBase> MathBinaryOpInset::clone() const
30 {
31         return auto_ptr<InsetBase>(new MathBinaryOpInset(*this));
32 }
33
34
35 int MathBinaryOpInset::opwidth() const
36 {
37         return mathed_char_width(LM_TC_CONST, mi_, op_);
38 }
39
40
41 #warning Andre, have a look here. (Lgb)
42 #if 0
43 // That this is not declared in class MathBinaryOpInset makes
44 // Doxygen give warnings. (Lgb)
45 void MathBinaryOpInset::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         mi_ = mi;
48         cell(0).metrics(mi);
49         cell(1).metrics(mi);
50         width_   = cell(0).width() + cell(1).width() + opwidth();
51         ascent_  = max(cell(0).ascent(),  cell(1).ascent());
52         descent_ = max(cell(0).descent(), cell(1).descent());
53 }
54 #endif
55
56 void MathBinaryOpInset::draw(PainterInfo & pain, int x, int y) const
57 {
58         cell(0).draw(pain, x, y);
59         drawChar(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
60         cell(1).draw(pain, x + width() - cell(1).width(), y);
61 }
62
63
64 void MathBinaryOpInset::write(WriteStream & os) const
65 {
66         os << '{' << cell(0) << op_ << cell(1) << '}';
67 }
68
69
70 void MathBinaryOpInset::normalize(NormalStream & os) const
71 {
72         os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
73 }