]> git.donarmstrong.com Git - lilypond.git/blob - lookupsyms.cc
66cbd6db084623fd5647d087d513c422a5b5155c
[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
7 Symtables the_sym_tables("symbol.ini");
8
9 Symbol
10 Lookup::ball(int j)
11 {
12     if (j > 4) j = 4;
13     Symtable * st = the_sym_tables("balls");
14     return st->lookup(String(j));
15 }
16
17 Symbol
18 Lookup::rest(int j)
19 {
20     return the_sym_tables("rests")->lookup(String(j));
21 }
22
23
24  Symbol
25 Lookup::bar(String s)
26 {
27     return the_sym_tables("bars")->lookup(s);
28 }
29  Symbol
30 Lookup::dots(int j)
31 {
32     if (j>3)
33         error("max 3 dots");
34     return the_sym_tables("dots")->lookup(j);
35 }
36
37 /****************************************************************/
38 // bare bones.
39
40 struct Linestaf_symbol : Parametric_symbol {
41     int lines;
42     Linestaf_symbol(int n) { lines = n;}
43     Symbol eval(svec<String>)const;
44 };
45
46
47 Symbol
48 Linestaf_symbol::eval(svec<String> w)const
49 {
50     Real wid = w[0].fvalue();
51
52     Symbol s;
53     s.dim.x = Interval(0,wid);
54     s.dim.y = Interval(0, lines*convert_dimen(5,"pt"));
55     svec<String> a;
56     a.add(lines);
57     a.add(w[0]);
58     s.tex = the_sym_tables("param")->lookup("linestaf").tex;
59     s.tex = substitute_args(s.tex, a);
60     return s;
61 }
62
63 /****************************************************************
64  */
65
66
67 struct Meter_sym:Parametric_symbol {
68
69     Symbol eval(svec<String> a) const{
70         Symbol s;
71         s.dim.x = Interval(0, convert_dimen(10,"pt"));
72         s.dim.y = Interval(0, convert_dimen(10,"pt") ); 
73         String src = the_sym_tables("param")->lookup("meter").tex;
74         s.tex = substitute_args(src,a);
75         return s;
76     }
77 };
78 /****************************************************************/
79
80 Parametric_symbol *
81 Lookup::meter(String )
82 {
83     return new Meter_sym;
84 }
85
86 Parametric_symbol *
87 Lookup::linestaff(int n)
88 {
89     return new Linestaf_symbol(n);
90 }
91