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_p_ = new Symtables;
30 Lookup::Lookup (Lookup const &s)
32 paper_l_ = s.paper_l_;
33 texsetting = s.texsetting;
34 symtables_p_ = new Symtables (*s.symtables_p_);
42 Lookup::add (String s, Symtable*p)
44 symtables_p_->add (s, p);
51 DOUT << "Lookup: " << texsetting << " {\n";
52 symtables_p_->print();
58 Lookup::text (String style, String text, int dir) const
63 Atom tsym = (*symtables_p_)("style")->lookup (style);
64 a[0] = substitute_args (tsym.tex_,a);
66 Atom s = (*symtables_p_)("align")->lookup (dir);
67 s.tex_ = substitute_args (s.tex_,a);
75 Lookup::ball (int j) const
80 Symtable * st = (*symtables_p_)("balls");
81 return st->lookup (String (j));
85 Lookup::rest (int j, bool o) const
87 return (*symtables_p_)("rests")->lookup (String (j) + (o ? "o" : ""));
91 Lookup::fill (Box b) const
93 Atom s ((*symtables_p_)("param")->lookup ("fill"));
99 Lookup::accidental (int j) const
101 return (*symtables_p_)("accidentals")->lookup (String (j));
106 Lookup::bar (String s, Real h) const
109 a.push (print_dimen (h));
110 Atom ret=(*symtables_p_)("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_p_)("scripts")->lookup (s);
123 Lookup::dynamic (String s) const
125 return (*symtables_p_)("dynamics")->lookup (s);
129 Lookup::clef (String s) const
131 return (*symtables_p_)("clefs")->lookup (s);
135 Lookup::dots () const
137 return (*symtables_p_)("dots")->lookup ("dot");
141 Lookup::flag (int j, Direction d) const
143 char c = (d == UP) ? 'u' : 'd';
144 return (*symtables_p_)("flags")->lookup (c + String (j));
148 Lookup::streepje (int type) const
153 Symtable * st = (*symtables_p_)("balls");
155 return st->lookup (String (type) + 'l');
159 Lookup::hairpin (Real &wid, bool decresc) const
161 int idx = int (rint (wid / 6 PT));
164 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
165 Atom ret=(*symtables_p_)("param")->lookup (idxstr);
169 ret.tex_ = substitute_args (ret.tex_, a);
170 ret.dim_.x() = Interval (0,wid);
175 Lookup::meter (Array<Scalar> a) const
177 Atom s((*symtables_p_)("param")->lookup ("meter"));
178 s.tex_ = substitute_args (s.tex_,a);
184 Lookup::stem (Real y1,Real y2) const
194 s.dim_.x() = Interval (0,0);
195 s.dim_.y() = Interval (y1,y2);
198 a.push (print_dimen (y1));
199 a.push (print_dimen (y2));
201 String src = (*symtables_p_)("param")->lookup ("stem").tex_;
202 s.tex_ = substitute_args (src,a);
207 should be handled via Tex_ code and Lookup::bar()
210 Lookup::vbrace (Real &y) const
214 warning (_("piano brace too small (") + print_dimen (y)+ ")");
219 warning (_("piano brace too big (") + print_dimen (y)+ ")");
223 int idx = int (rint ((y/2.0 - 20) + 148));
225 Atom s = (*symtables_p_)("param")->lookup ("brace");
229 s.tex_ = substitute_args (s.tex_,a);
230 s.dim_.y() = Interval (0,y);
234 a.push (print_dimen (y/2));
235 a.push (print_dimen (0));
237 s.tex_ = substitute_args ("\\placebox{%}{%}{%}", a);