2 lookup.cc -- implement simple Lookup methods.
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "symtable.hh"
18 texsetting = "\\unknowntexsetting";
19 symtables_ = new Symtables;
22 Lookup::Lookup(Lookup const &s)
24 texsetting = s.texsetting;
25 symtables_ = new Symtables(*s.symtables_);
33 Lookup::add(String s, Symtable*p)
35 symtables_->add(s, p);
41 mtor << "Lookup: " << texsetting << " {\n";
47 Lookup::text(String style, String text, int dir)
52 Symbol tsym = (*symtables_)("style")->lookup(style);
53 a[0] = substitute_args(tsym.tex,a);
55 Symbol s = (*symtables_)("align")->lookup(dir);
56 s.tex = substitute_args(s.tex,a);
65 return ball(4).dim.y.length()/2;
74 Symtable * st = (*symtables_)("balls");
75 return st->lookup(String(j));
81 return (*symtables_)("rests")->lookup(String(j));
87 Symbol s( (*symtables_)("param")->lookup("fill"));
93 Lookup::accidental(int j)
95 return (*symtables_)("accidentals")->lookup(String(j));
100 Lookup::bar(String s)
102 return (*symtables_)("bars")->lookup(s);
106 Lookup::script(String s)
108 return (*symtables_)("scripts")->lookup(s);
112 Lookup::clef(String s)
114 return (*symtables_)("clefs")->lookup(s);
121 error("max 3 dots"); // todo
122 return (*symtables_)("dots")->lookup(j);
128 return (*symtables_)("flags")->lookup(j);
132 Lookup::streepjes(int i)
146 Symbol ret = (*symtables_)("streepjes")->lookup(idx);
150 ret.tex = substitute_args(ret.tex, a);
156 Lookup::hairpin(Real &wid, bool decresc)
158 int idx = int(rint(wid / 6 PT));
161 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
162 Symbol ret=(*symtables_)("param")->lookup(idxstr);
166 ret.tex = substitute_args(ret.tex, a);
167 ret.dim.x = Interval(0,wid);
172 Lookup::linestaff(int lines, Real wid)
175 s.dim.x = Interval(0,wid);
176 Real dy = (lines >0) ? (lines-1)*internote()*2 : 0;
177 s.dim.y = Interval(0,dy);
181 a.push(print_dimen(wid));
183 s.tex = (*symtables_)("param")->lookup("linestaf").tex;
184 s.tex = substitute_args(s.tex, a);
191 Lookup::meter(Array<Scalar> a)
194 s.dim.x = Interval( 0 PT, 10 PT);
195 s.dim.y = Interval(0, 20 PT); // todo
196 String src = (*symtables_)("param")->lookup("meter").tex;
197 s.tex = substitute_args(src,a);
203 Lookup::stem(Real y1,Real y2)
212 s.dim.x = Interval(0,0);
213 s.dim.y = Interval(y1,y2);
216 a.push(print_dimen(y1));
217 a.push(print_dimen(y2));
219 String src = (*symtables_)("param")->lookup("stem").tex;
220 s.tex = substitute_args(src,a);