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