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