2 lookup.cc -- implement simple Lookup methods.
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 This doth suck. We should have PS output, and read spacing info from TFMs
17 #include "symtable.hh"
25 texsetting = "\\unknowntexsetting";
26 symtables_ = new Symtables;
29 Lookup::Lookup(Lookup const &s)
31 texsetting = s.texsetting;
32 symtables_ = new Symtables(*s.symtables_);
40 Lookup::add(String s, Symtable*p)
42 symtables_->add(s, p);
48 mtor << "Lookup: " << texsetting << " {\n";
54 Lookup::text(String style, String text, int dir) const
59 Symbol tsym = (*symtables_)("style")->lookup(style);
60 a[0] = substitute_args(tsym.tex,a);
62 Symbol s = (*symtables_)("align")->lookup(dir);
63 s.tex = substitute_args(s.tex,a);
70 Lookup::internote_f() const
72 return ball(4).dim.y.length()/2;
76 Lookup::ball(int j) const
81 Symtable * st = (*symtables_)("balls");
82 return st->lookup(String(j));
86 Lookup::rest(int j) const
88 return (*symtables_)("rests")->lookup(String(j));
92 Lookup::fill(Box b) const
94 Symbol s( (*symtables_)("param")->lookup("fill"));
100 Lookup::accidental(int j) const
102 return (*symtables_)("accidentals")->lookup(String(j));
107 Lookup::bar(String s) const
109 return (*symtables_)("bars")->lookup(s);
113 Lookup::script(String s) const
115 return (*symtables_)("scripts")->lookup(s);
119 Lookup::dynamic(String s) const
121 return (*symtables_)("dynamics")->lookup(s);
125 Lookup::clef(String s) const
127 return (*symtables_)("clefs")->lookup(s);
131 Lookup::dots(int j) const
135 warning("max 3 dots"); // todo
137 return (*symtables_)("dots")->lookup(j);
141 Lookup::flag(int j) const
143 return (*symtables_)("flags")->lookup(j);
147 Lookup::streepjes(int i) const
161 Symbol ret = (*symtables_)("streepjes")->lookup(idx);
165 ret.tex = substitute_args(ret.tex, a);
171 Lookup::hairpin(Real &wid, bool decresc) const
173 int idx = int(rint(wid / 6 PT));
176 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
177 Symbol ret=(*symtables_)("param")->lookup(idxstr);
181 ret.tex = substitute_args(ret.tex, a);
182 ret.dim.x = Interval(0,wid);
187 Lookup::linestaff(int lines, Real wid) const
190 s.dim.x = Interval(0,wid);
191 Real dy = (lines >0) ? (lines-1)*internote_f()*2 : 0;
192 s.dim.y = Interval(0,dy);
196 a.push(print_dimen(wid));
198 s.tex = (*symtables_)("param")->lookup("linestaf").tex;
199 s.tex = substitute_args(s.tex, a);
206 Lookup::meter(Array<Scalar> a) const
209 s.dim.x = Interval( 0 PT, 10 PT);
210 s.dim.y = Interval(0, 20 PT); // todo
211 String src = (*symtables_)("param")->lookup("meter").tex;
212 s.tex = substitute_args(src,a);
218 Lookup::stem(Real y1,Real y2) const
227 s.dim.x = Interval(0,0);
228 s.dim.y = Interval(y1,y2);
231 a.push(print_dimen(y1));
232 a.push(print_dimen(y2));
234 String src = (*symtables_)("param")->lookup("stem").tex;
235 s.tex = substitute_args(src,a);
240 Lookup::vbrace(Real &y) const
243 warning ( "piano brace too small (" + print_dimen(y)+ ")");
247 warning ( "piano brace too big (" + print_dimen(y)+ ")");
251 int idx = (y/2.0 - 20 ) + 148;
253 Symbol s = (*symtables_)("param")->lookup("brace");
257 s.tex = substitute_args(s.tex,a);
258 s.dim.y = Interval(0,y);