]> git.lyx.org Git - lyx.git/blob - src/mathed/math_symbolinset.C
ea1efff9b069556d46081cf2c86c4ef3d1a52c76
[lyx.git] / src / mathed / math_symbolinset.C
1 #include "math_symbolinset.h"
2 #include "mathed/math_parser.h"
3 #include "support/LOstream.h"
4
5
6 using std::ostream;
7
8 MathSymbolInset::MathSymbolInset(const latexkeys * l)
9         : sym_(l)
10 {}
11
12
13 MathInset * MathSymbolInset::clone() const
14 {
15         return new MathSymbolInset(*this);
16 }
17
18
19 void MathSymbolInset::write(ostream & os, bool /* fragile */) const
20 {
21         os << '\\' << sym_->name << ' ';
22 }
23
24
25 void MathSymbolInset::writeNormal(ostream & os) const
26 {
27         os << "[bigop " << sym_->name << "] ";
28 }
29
30
31 void MathSymbolInset::metrics(MathStyles st) const
32 {
33         size(st);
34         
35         if (sym_->id > 0 && sym_->id < 256) {
36                 ssym_ = string();
37                 ssym_ += sym_->id;
38                 code_ = (sym_->token == LM_TK_BIGSYM) ? LM_TC_BSYM : LM_TC_SYMB;
39         } else {
40                 ssym_ = sym_->name;
41                 code_ = LM_TC_TEX;
42         }
43
44         mathed_string_dim(code_, size(), ssym_, ascent_, descent_, width_);
45 }
46
47
48 void MathSymbolInset::draw(Painter & pain, int x, int y) const
49 {  
50         xo(x);
51         yo(y);
52
53         drawStr(pain, code_, size_, x, y, ssym_);
54 }
55
56
57 bool MathSymbolInset::isRelOp() const
58 {
59         return sym_->id == LM_leq || sym_->id == LM_geq;
60 }