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"
27 texsetting = "\\unknowntexsetting";
28 symtables_p_ = new Symtables;
31 Lookup::Lookup (Lookup const &s)
33 paper_l_ = s.paper_l_;
34 texsetting = s.texsetting;
35 symtables_p_ = new Symtables (*s.symtables_p_);
43 Lookup::add (String s, Symtable*p)
45 symtables_p_->add (s, p);
52 DOUT << "Lookup: " << texsetting << " {\n";
53 symtables_p_->print();
59 Lookup::text (String style, String text, int dir) const
64 Atom tsym = (*symtables_p_)("style")->lookup (style);
65 a[0] = substitute_args (tsym.tex_,a);
67 Atom s = (*symtables_p_)("align")->lookup (dir);
68 s.tex_ = substitute_args (s.tex_,a);
76 Lookup::ball (int j) const
81 Symtable * st = (*symtables_p_)("balls");
82 return st->lookup (String (j));
86 Lookup::rest (int j, bool o) const
88 return (*symtables_p_)("rests")->lookup (String (j) + (o ? "o" : ""));
92 Lookup::fill (Box b) const
94 Atom s ((*symtables_p_)("param")->lookup ("fill"));
100 Lookup::accidental (int j) const
102 return (*symtables_p_)("accidentals")->lookup (String (j));
107 Lookup::bar (String s, Real h) const
110 a.push (print_dimen (h));
111 Atom ret=(*symtables_p_)("bars")->lookup (s);
112 ret.tex_ = substitute_args (ret.tex_, a);
113 ret.dim_.y() = Interval (-h/2, h/2);
118 Lookup::script (String s) const
120 return (*symtables_p_)("scripts")->lookup (s);
124 Lookup::dynamic (String s) const
126 return (*symtables_p_)("dynamics")->lookup (s);
130 Lookup::clef (String s) const
132 return (*symtables_p_)("clefs")->lookup (s);
136 Lookup::dots () const
138 return (*symtables_p_)("dots")->lookup ("dot");
142 Lookup::flag (int j, Direction d) const
144 char c = (d == UP) ? 'u' : 'd';
145 return (*symtables_p_)("flags")->lookup (c + String (j));
149 Lookup::streepje (int type) const
154 Symtable * st = (*symtables_p_)("balls");
156 return st->lookup (String (type) + 'l');
160 Lookup::hairpin (Real &wid, bool decresc, bool continued) const
162 bool embedded_b = postscript_global_b;
168 embed = "\\embeddedps{\n" ;
169 embed += String (wid) + " "
170 + String (height) + " "
171 + String (continued ? height/2 : 0) +
172 + " draw_" + String(decresc ? "de" : "") + "cresc}\n";
179 warning (_("Crescendo too long (") + print_dimen (wid)
180 +_( ") shrinking (ugh)"));
183 int idx = int (rint (wid / 6 PT));
186 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
187 ret=(*symtables_p_)("param")->lookup (idxstr);
191 ret.tex_ = substitute_args (ret.tex_, a);
194 ret.dim_.x() = Interval (0,wid);
195 // ret.translate_axis (-ret.dim_[Y_AXIS][DOWN], Y_AXIS);
200 Lookup::meter (Array<Scalar> a) const
202 Atom s((*symtables_p_)("param")->lookup ("meter"));
203 s.tex_ = substitute_args (s.tex_,a);
209 Lookup::stem (Real y1,Real y2) const
219 s.dim_.x() = Interval (0,0);
220 s.dim_.y() = Interval (y1,y2);
223 a.push (print_dimen (y1));
224 a.push (print_dimen (y2));
226 String src = (*symtables_p_)("param")->lookup ("stem").tex_;
227 s.tex_ = substitute_args (src,a);
232 should be handled via Tex_ code and Lookup::bar()
235 Lookup::vbrace (Real &y) const
237 Atom brace = (*symtables_p_)("param")->lookup ("brace");
238 Interval ydims = brace.dim_[Y_AXIS];
239 Real min_y = ydims[LEFT];
240 Real max_y = ydims[RIGHT];
245 warning (_("piano brace too small (") + print_dimen (y)+ ")");
250 warning (_("piano brace too big (") + print_dimen (y)+ ")");
255 int idx = int (rint ((y- min_y)/step)) + 1;
260 brace.tex_ = substitute_args (brace.tex_,a);
261 brace.dim_[Y_AXIS] = Interval (-y/2,y/2);