]> git.lyx.org Git - lyx.git/blob - src/mathed/math_funcinset.C
mathed cleanup, change mask for tmpdir
[lyx.git] / src / mathed / math_funcinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_funcinset.h"
8 #include "lyxfont.h"
9 #include "font.h"
10 #include "Painter.h"
11 #include "mathed/support.h"
12 #include "support/LOstream.h"
13
14
15 using std::ostream;
16
17 extern LyXFont WhichFont(short type, int size);
18
19
20 MathFuncInset::MathFuncInset(string const & nm, short ot, short st)
21         : MathedInset(nm, ot, st)
22 {
23         lims_ = (GetType() == LM_OT_FUNCLIM);
24 }
25
26
27 MathedInset * MathFuncInset::Clone()
28 {
29         return new MathFuncInset(name, GetType(), GetStyle());
30 }
31
32
33 void
34 MathFuncInset::draw(Painter & pain, int x, int y)
35
36         if (!name.empty() && name[0] > ' ') {
37                 LyXFont font = WhichFont(LM_TC_TEXTRM, size());
38                 font.setLatex(LyXFont::ON);
39                 x += (lyxfont::width('I', font) + 3) / 4;
40                 pain.text(x, y, name, font);
41         }
42 }
43
44
45 void MathFuncInset::Write(std::ostream & os, bool /* fragile */)
46 {
47         os << "\\" << name << ' ';
48 }
49
50
51 void MathFuncInset::Metrics() 
52 {
53         LyXFont font = WhichFont(LM_TC_TEXTRM, size());
54         font.setLatex(LyXFont::ON);
55         if (name.empty()) {
56                 width = df_width;
57                 descent = df_des;
58                 ascent = df_asc;
59         } else {
60                 width = lyxfont::width(name, font)
61                         + lyxfont::width('I', font) / 2;
62                 mathed_string_height(LM_TC_TEXTRM, size(),
63                                      name, ascent, descent);
64         }
65 }
66
67
68 bool MathFuncInset::GetLimits() const 
69 {  
70         return bool(lims_ && (GetStyle() == LM_ST_DISPLAY)); 
71