2 lookup.cc -- implement simple Lookup methods.
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "symtable.hh"
18 texsetting
= "\\unknowntexsetting";
19 symtables_
= new Symtables
;
22 Lookup::Lookup(Lookup
const &s
)
24 texsetting
= s
.texsetting
;
25 symtables_
= new Symtables(*s
.symtables_
);
33 Lookup::add(String s
, Symtable
*p
)
35 symtables_
->add(s
, p
);
41 mtor
<< "Lookup: " << texsetting
<< " {\n";
47 Lookup::text(String style
, String text
, int dir
) const
52 Symbol tsym
= (*symtables_
)("style")->lookup(style
);
53 a
[0] = substitute_args(tsym
.tex
,a
);
55 Symbol s
= (*symtables_
)("align")->lookup(dir
);
56 s
.tex
= substitute_args(s
.tex
,a
);
63 Lookup::internote() const
65 return ball(4).dim
.y
.length()/2;
69 Lookup::ball(int j
) const
74 Symtable
* st
= (*symtables_
)("balls");
75 return st
->lookup(String(j
));
79 Lookup::rest(int j
) const
81 return (*symtables_
)("rests")->lookup(String(j
));
85 Lookup::fill(Box b
) const
87 Symbol
s( (*symtables_
)("param")->lookup("fill"));
93 Lookup::accidental(int j
) const
95 return (*symtables_
)("accidentals")->lookup(String(j
));
100 Lookup::bar(String s
) const
102 return (*symtables_
)("bars")->lookup(s
);
106 Lookup::script(String s
) const
108 return (*symtables_
)("scripts")->lookup(s
);
112 Lookup::dynamic(String s
) const
114 return (*symtables_
)("dynamics")->lookup(s
);
118 Lookup::clef(String s
) const
120 return (*symtables_
)("clefs")->lookup(s
);
124 Lookup::dots(int j
) const
127 error("max 3 dots"); // todo
128 return (*symtables_
)("dots")->lookup(j
);
132 Lookup::flag(int j
) const
134 return (*symtables_
)("flags")->lookup(j
);
138 Lookup::streepjes(int i
) const
152 Symbol ret
= (*symtables_
)("streepjes")->lookup(idx
);
156 ret
.tex
= substitute_args(ret
.tex
, a
);
162 Lookup::hairpin(Real
&wid
, bool decresc
) const
164 int idx
= int(rint(wid
/ 6 PT
));
167 String idxstr
= (decresc
)? "decrescendosym" : "crescendosym";
168 Symbol ret
=(*symtables_
)("param")->lookup(idxstr
);
172 ret
.tex
= substitute_args(ret
.tex
, a
);
173 ret
.dim
.x
= Interval(0,wid
);
178 Lookup::linestaff(int lines
, Real wid
) const
181 s
.dim
.x
= Interval(0,wid
);
182 Real dy
= (lines
>0) ? (lines
-1)*internote()*2 : 0;
183 s
.dim
.y
= Interval(0,dy
);
187 a
.push(print_dimen(wid
));
189 s
.tex
= (*symtables_
)("param")->lookup("linestaf").tex
;
190 s
.tex
= substitute_args(s
.tex
, a
);
197 Lookup::meter(Array
<Scalar
> a
) const
200 s
.dim
.x
= Interval( 0 PT
, 10 PT
);
201 s
.dim
.y
= Interval(0, 20 PT
); // todo
202 String src
= (*symtables_
)("param")->lookup("meter").tex
;
203 s
.tex
= substitute_args(src
,a
);
209 Lookup::stem(Real y1
,Real y2
) const
218 s
.dim
.x
= Interval(0,0);
219 s
.dim
.y
= Interval(y1
,y2
);
222 a
.push(print_dimen(y1
));
223 a
.push(print_dimen(y2
));
225 String src
= (*symtables_
)("param")->lookup("stem").tex
;
226 s
.tex
= substitute_args(src
,a
);