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);
51 mtor << "Lookup: " << texsetting << " {\n";
58 Lookup::text(String style, String text, int dir) const
63 Symbol tsym = (*symtables_)("style")->lookup(style);
64 a[0] = substitute_args(tsym.tex,a);
66 Symbol s = (*symtables_)("align")->lookup(dir);
67 s.tex = substitute_args(s.tex,a);
75 Lookup::ball(int j) const
80 Symtable * st = (*symtables_)("balls");
81 return st->lookup(String(j));
85 Lookup::rest(int j, bool o) const
87 return (*symtables_)("rests")->lookup(String(j) + (o ? "o" : "") );
91 Lookup::fill(Box b) const
93 Symbol s( (*symtables_)("param")->lookup("fill"));
99 Lookup::accidental(int j) const
101 return (*symtables_)("accidentals")->lookup(String(j));
106 Lookup::bar(String s, Real h) const
109 a.push(print_dimen( h));
110 Symbol ret=(*symtables_)("bars")->lookup(s);;
111 ret.tex = substitute_args(ret.tex, a);
112 ret.dim.y = Interval( 0, h);
117 Lookup::script(String s) const
119 return (*symtables_)("scripts")->lookup(s);
123 Lookup::dynamic(String s) const
125 return (*symtables_)("dynamics")->lookup(s);
129 Lookup::clef(String s) const
131 return (*symtables_)("clefs")->lookup(s);
135 Lookup::dots(int j) const
139 warning("max 3 dots"); // todo
141 return (*symtables_)("dots")->lookup(j);
145 Lookup::flag(int j) const
147 return (*symtables_)("flags")->lookup(j);
151 Lookup::streepjes(int i) const
165 Symbol ret = (*symtables_)("streepjes")->lookup(idx);
169 ret.tex = substitute_args(ret.tex, a);
175 Lookup::hairpin(Real &wid, bool decresc) const
177 int idx = int(rint(wid / 6 PT));
180 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
181 Symbol ret=(*symtables_)("param")->lookup(idxstr);
185 ret.tex = substitute_args(ret.tex, a);
186 ret.dim.x = Interval(0,wid);
191 Lookup::linestaff(int lines, Real wid) const
193 Real internote_f = paper_l_ ->internote_f();
195 s.dim.x = Interval(0,wid);
196 Real dy = (lines >0) ? (lines-1)*internote_f : 0;
197 s.dim.y = Interval(0,dy);
201 a.push(print_dimen(wid));
203 s.tex = (*symtables_)("param")->lookup("linestaf").tex;
204 s.tex = substitute_args(s.tex, a);
211 Lookup::meter(Array<Scalar> a) const
214 s.dim.x = Interval( 0 PT, 10 PT);
215 s.dim.y = Interval(0, 20 PT); // todo
216 String src = (*symtables_)("param")->lookup("meter").tex;
217 s.tex = substitute_args(src,a);
223 Lookup::stem(Real y1,Real y2) const
232 s.dim.x = Interval(0,0);
233 s.dim.y = Interval(y1,y2);
236 a.push(print_dimen(y1));
237 a.push(print_dimen(y2));
239 String src = (*symtables_)("param")->lookup("stem").tex;
240 s.tex = substitute_args(src,a);
245 should be handled via TeX code and Lookup::bar()
248 Lookup::vbrace(Real &y) const
251 warning ( "piano brace too small (" + print_dimen(y)+ ")");
255 warning ( "piano brace too big (" + print_dimen(y)+ ")");
259 int idx = int(rint((y/2.0 - 20 ) + 148));
261 Symbol s = (*symtables_)("param")->lookup("brace");
265 s.tex = substitute_args(s.tex,a);
266 s.dim.y = Interval(0,y);
270 a.push(print_dimen( y/2 ));
271 a.push(print_dimen(0));
273 s.tex = substitute_args("\\placebox{%}{%}{%}", a);