]> git.lyx.org Git - lyx.git/blob - src/mathed/math_funcinset.C
new hierarchy for frac-like things
[lyx.git] / src / mathed / math_funcinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_funcinset.h"
6 #include "font.h"
7 #include "Painter.h"
8 #include "mathed/support.h"
9 #include "support/LOstream.h"
10
11
12 using std::ostream;
13
14 extern LyXFont WhichFont(short type, int size);
15
16
17 MathFuncInset::MathFuncInset(string const & nm)
18         : name_(nm)
19 {}
20
21
22 MathInset * MathFuncInset::clone() const
23 {
24         return new MathFuncInset(*this);
25 }
26
27
28 string const & MathFuncInset::name() const
29 {
30         return name_;
31 }
32
33
34 void MathFuncInset::setName(string const & n)
35 {
36         name_ = n;
37 }
38
39
40 void MathFuncInset::write(std::ostream & os, bool /* fragile */) const
41 {
42         os << "\\" << name_ << ' ';
43 }
44
45
46 void MathFuncInset::writeNormal(std::ostream & os) const
47 {
48         os << "[" << name_ << "] ";
49 }
50
51
52 void MathFuncInset::metrics(MathStyles st) const 
53 {
54         size_ = st;
55         if (name_.empty()) 
56                 mathed_char_dim(LM_TC_TEX, size_, 'I', ascent_, descent_, width_);
57         else 
58                 mathed_string_dim(LM_TC_TEX, size_, name_, ascent_, descent_, width_);
59 }
60
61
62 void MathFuncInset::draw(Painter & pain, int x, int y) const
63
64         xo(x);
65         yo(y);
66         if (name_.empty()) 
67                 drawChar(pain, LM_TC_TEX, size_, x, y, ' ');
68         else
69                 drawStr(pain, LM_TC_TEX, size_, x, y, name_);
70 }