]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binaryopinset.C
float2string #4 (Spacing)
[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 #ifdef WITH_WARNINGS
42 #warning Andre, have a look here. (Lgb)
43 #endif
44 #if 0
45 // That this is not declared in class MathBinaryOpInset makes
46 // Doxygen give warnings. (Lgb)
47 void MathBinaryOpInset::metrics(MetricsInfo & mi, Dimension & dim) const
48 {
49         mi_ = mi;
50         cell(0).metrics(mi);
51         cell(1).metrics(mi);
52         width_   = cell(0).width() + cell(1).width() + opwidth();
53         ascent_  = max(cell(0).ascent(),  cell(1).ascent());
54         descent_ = max(cell(0).descent(), cell(1).descent());
55 }
56 #endif
57
58
59 void MathBinaryOpInset::draw(PainterInfo & pain, int x, int y) const
60 {
61         cell(0).draw(pain, x, y);
62         drawChar(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
63         cell(1).draw(pain, x + width() - cell(1).width(), y);
64 }
65
66
67 void MathBinaryOpInset::write(WriteStream & os) const
68 {
69         os << '{' << cell(0) << op_ << cell(1) << '}';
70 }
71
72
73 void MathBinaryOpInset::normalize(NormalStream & os) const
74 {
75         os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
76 }