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"
21 #include "paper-def.hh"
26 texsetting = "\\unknowntexsetting";
27 symtables_ = new Symtables;
30 Lookup::Lookup(Lookup const &s)
32 paper_l_ = s.paper_l_;
33 texsetting = s.texsetting;
34 symtables_ = new Symtables(*s.symtables_);
42 Lookup::add(String s, Symtable*p)
44 symtables_->add(s, p);
50 mtor << "Lookup: " << texsetting << " {\n";
56 Lookup::text(String style, String text, int dir) const
61 Symbol tsym = (*symtables_)("style")->lookup(style);
62 a[0] = substitute_args(tsym.tex,a);
64 Symbol s = (*symtables_)("align")->lookup(dir);
65 s.tex = substitute_args(s.tex,a);
73 Lookup::ball(int j) const
78 Symtable * st = (*symtables_)("balls");
79 return st->lookup(String(j));
83 Lookup::rest(int j, bool o) const
85 return (*symtables_)("rests")->lookup(String(j) + (o ? "o" : "") );
89 Lookup::fill(Box b) const
91 Symbol s( (*symtables_)("param")->lookup("fill"));
97 Lookup::accidental(int j) const
99 return (*symtables_)("accidentals")->lookup(String(j));
104 Lookup::bar(String s, Real h) const
107 a.push(print_dimen( h));
108 Symbol ret=(*symtables_)("bars")->lookup(s);;
109 ret.tex = substitute_args(ret.tex, a);
110 ret.dim.y = Interval( 0, h);
115 Lookup::script(String s) const
117 return (*symtables_)("scripts")->lookup(s);
121 Lookup::dynamic(String s) const
123 return (*symtables_)("dynamics")->lookup(s);
127 Lookup::clef(String s) const
129 return (*symtables_)("clefs")->lookup(s);
133 Lookup::dots(int j) const
137 warning("max 3 dots"); // todo
139 return (*symtables_)("dots")->lookup(j);
143 Lookup::flag(int j) const
145 return (*symtables_)("flags")->lookup(j);
149 Lookup::streepjes(int i) const
163 Symbol ret = (*symtables_)("streepjes")->lookup(idx);
167 ret.tex = substitute_args(ret.tex, a);
173 Lookup::hairpin(Real &wid, bool decresc) const
175 int idx = int(rint(wid / 6 PT));
178 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
179 Symbol ret=(*symtables_)("param")->lookup(idxstr);
183 ret.tex = substitute_args(ret.tex, a);
184 ret.dim.x = Interval(0,wid);
189 Lookup::linestaff(int lines, Real wid) const
191 Real internote_f = paper_l_ ->internote_f();
193 s.dim.x = Interval(0,wid);
194 Real dy = (lines >0) ? (lines-1)*internote_f : 0;
195 s.dim.y = Interval(0,dy);
199 a.push(print_dimen(wid));
201 s.tex = (*symtables_)("param")->lookup("linestaf").tex;
202 s.tex = substitute_args(s.tex, a);
209 Lookup::meter(Array<Scalar> a) const
212 s.dim.x = Interval( 0 PT, 10 PT);
213 s.dim.y = Interval(0, 20 PT); // todo
214 String src = (*symtables_)("param")->lookup("meter").tex;
215 s.tex = substitute_args(src,a);
221 Lookup::stem(Real y1,Real y2) const
230 s.dim.x = Interval(0,0);
231 s.dim.y = Interval(y1,y2);
234 a.push(print_dimen(y1));
235 a.push(print_dimen(y2));
237 String src = (*symtables_)("param")->lookup("stem").tex;
238 s.tex = substitute_args(src,a);
243 should be handled via TeX code and Lookup::bar()
246 Lookup::vbrace(Real &y) const
249 warning ( "piano brace too small (" + print_dimen(y)+ ")");
253 warning ( "piano brace too big (" + print_dimen(y)+ ")");
257 int idx = int(rint((y/2.0 - 20 ) + 148));
259 Symbol s = (*symtables_)("param")->lookup("brace");
263 s.tex = substitute_args(s.tex,a);
264 s.dim.y = Interval(0,y);
268 a.push(print_dimen( y/2 ));
269 a.push(print_dimen(0));
271 s.tex = substitute_args("\\placebox{%}{%}{%}", a);