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