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