]> git.lyx.org Git - lyx.git/blob - src/mathed/math_funcinset.C
move width_/ascent_/descent_ cache into seperate ABC.
[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 {
19         name_ = nm;
20 }
21
22
23 MathInset * MathFuncInset::clone() const
24 {
25         return new MathFuncInset(*this);
26 }
27
28
29 void MathFuncInset::write(std::ostream & os, bool /* fragile */) const
30 {
31         os << "\\" << name_ << ' ';
32 }
33
34
35 void MathFuncInset::writeNormal(std::ostream & os) const
36 {
37         os << "[" << name_ << "] ";
38 }
39
40
41 void MathFuncInset::metrics(MathStyles st) 
42 {
43         size_ = st;
44         if (name_.empty()) 
45                 mathed_char_dim(LM_TC_TEXTRM, size_, 'I', ascent_, descent_, width_);
46         else 
47                 mathed_string_dim(LM_TC_TEXTRM, size_, name_, ascent_, descent_, width_);
48 }
49
50
51 void MathFuncInset::draw(Painter & pain, int x, int y)
52
53         xo(x);
54         yo(y);
55         if (name_.empty()) 
56                 drawChar(pain, LM_TC_TEXTRM, size_, x, y, ' ');
57         else
58                 drawStr(pain, LM_TC_TEXTRM, size_, x, y, name_);
59 }