]> git.donarmstrong.com Git - lilypond.git/blob - lookupsyms.cc
release: 0.0.6
[lilypond.git] / lookupsyms.cc
1 #include "lookupsyms.hh"
2 #include "debug.hh"
3 #include "symtable.hh"
4 #include "dimen.hh"
5 #include "tex.hh"
6 void
7 Lookup::parse(Text_db&t)
8 {
9     symtables_->read(t) ;
10 }
11
12 Lookup::Lookup()
13 {
14     symtables_ = new Symtables;
15 }
16
17 Lookup::~Lookup()
18 {
19     delete symtables_;
20 }
21
22 Symbol
23 Lookup::ball(int j)
24 {
25     if (j > 4)
26         j = 4;
27
28     Symtable * st = (*symtables_)("balls");
29     return st->lookup(String(j));
30 }
31
32 Symbol
33 Lookup::rest(int j)
34 {
35     return (*symtables_)("rests")->lookup(String(j));
36 }
37
38
39 Symbol
40 Lookup::bar(String s)
41 {
42     return (*symtables_)("bars")->lookup(s);
43 }
44  Symbol
45 Lookup::dots(int j)
46 {
47     if (j>3)
48         error("max 3 dots");
49     return (*symtables_)("dots")->lookup(j);
50 }
51
52 /****************************************************************/
53 // bare bones.
54
55 struct Linestaf_symbol : Parametric_symbol {
56     int lines;
57     Linestaf_symbol(int n, Symtables*s): Parametric_symbol(s) { lines = n;}
58     Symbol eval(svec<String>)const;
59 };
60
61
62 Symbol
63 Linestaf_symbol::eval(svec<String> w)const
64 {
65     Real wid = w[0].fvalue();
66
67     Symbol s;
68     s.dim.x = Interval(0,wid);
69     Real dy=lines*convert_dimen(5,"pt");
70     s.dim.y = Interval(0,dy);
71     svec<String> a;
72     a.add(lines);
73     a.add(w[0]);
74     s.tex = (*symtables_)("param")->lookup("linestaf").tex;
75     s.tex = substitute_args(s.tex, a);
76     return s;
77 }
78
79 /****************************************************************/
80
81
82 struct Meter_sym:Parametric_symbol {
83
84     Meter_sym(Symtables*s) : Parametric_symbol(s){  }
85     Symbol eval(svec<String> a) const{
86         Symbol s;
87         s.dim.x = Interval( convert_dimen(-5,"pt"), convert_dimen(10,"pt"));
88         s.dim.y = Interval(0, convert_dimen(10,"pt") ); // todo
89         String src = (*symtables_)("param")->lookup("meter").tex;
90         s.tex = substitute_args(src,a);
91         return s;
92     }
93 };
94 /****************************************************************/
95
96 Parametric_symbol *
97 Lookup::meter(String )
98 {
99     return new Meter_sym(symtables_);
100 }
101
102 Parametric_symbol *
103 Lookup::linestaff(int n)
104 {
105     return new Linestaf_symbol(n,symtables_);
106 }
107