]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sizeinset.C
move things around
[lyx.git] / src / mathed / math_sizeinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_sizeinset.h"
6 #include "support/LOstream.h"
7
8
9 MathSizeInset::MathSizeInset(MathStyles st)
10         : MathNestInset(1), style_(st)
11 {}
12
13
14 char const * MathSizeInset::name() const
15 {
16         switch (style_) {
17                 case LM_ST_DISPLAY:
18                         return "displaystyle";
19                 case LM_ST_TEXT:
20                         return "textstyle";
21                 case LM_ST_SCRIPT:
22                         return "scriptstyle";
23                 case LM_ST_SCRIPTSCRIPT:
24                         return "scriptscriptstyle";
25         }
26         return "unknownstyle";
27 }
28
29
30 MathInset * MathSizeInset::clone() const
31 {
32         return new MathSizeInset(*this);
33 }
34
35
36 void MathSizeInset::draw(Painter & pain, int x, int y) const
37 {
38         xo(x);
39         yo(y);
40         xcell(0).draw(pain, x, y);
41 }
42
43
44 void MathSizeInset::metrics(MathStyles /* st */) const
45 {
46         xcell(0).metrics(style_);
47         ascent_   = xcell(0).ascent_;
48         descent_  = xcell(0).descent_;
49         width_    = xcell(0).width_;
50 }
51
52
53 void MathSizeInset::write(std::ostream & os, bool fragile) const
54 {
55         os << "{\\" << name() << " ";
56         cell(0).write(os, fragile);
57         os << "}";
58 }
59
60
61 void MathSizeInset::writeNormal(std::ostream & os) const
62 {
63         os << "[" << name() << " ";
64         cell(0).writeNormal(os);
65         os << "]";
66 }