]> git.lyx.org Git - lyx.git/blob - src/mathed/math_funcinset.C
remove unneeded #includes, cosmetics
[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, MathInsetTypes ot)
18         : MathInset(0, nm, ot)
19 {
20         lims_ = (GetType() == LM_OT_FUNCLIM);
21 }
22
23
24 MathInset * MathFuncInset::clone() const
25 {
26         return new MathFuncInset(*this);
27 }
28
29
30 void MathFuncInset::draw(Painter & pain, int x, int y)
31
32         if (!name_.empty() && name_[0] > ' ') {
33                 LyXFont font = WhichFont(LM_TC_TEXTRM, size());
34 #ifndef NO_LATEX
35                 font.setLatex(LyXFont::ON);
36 #endif
37                 x += (lyxfont::width('I', font) + 3) / 4;
38                 pain.text(x, y, name_, font);
39         }
40 }
41
42
43 void MathFuncInset::Write(std::ostream & os, bool /* fragile */) const
44 {
45         os << "\\" << name_ << ' ';
46 }
47
48
49 void MathFuncInset::WriteNormal(std::ostream & os) const
50 {
51         os << "[" << name_ << "] ";
52 }
53
54
55 void MathFuncInset::Metrics(MathStyles st, int, int) 
56 {
57         LyXFont font = WhichFont(LM_TC_TEXTRM, size());
58 #ifndef NO_LATEX
59         font.setLatex(LyXFont::ON);
60 #endif
61         size_ = st;
62         if (name_.empty()) {
63                 width_   = lyxfont::width('M', font);
64                 ascent_  = lyxfont::ascent('M', font);
65                 descent_ = 0;
66         } else {
67                 width_ = lyxfont::width(name_, font) + lyxfont::width('I', font) / 2;
68                 mathed_string_height(LM_TC_TEXTRM, size_, name_, ascent_, descent_);
69         }
70 }