lilypond-0.0.32
[lilypond.git] / src / request.cc
blob72b8a3544aa3fed86ba3ae8d4c1c20da00a27272
1 /*
2 request.cc -- implement all musical requests.
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "musicalrequest.hh"
10 #include "misc.hh"
11 #include "debug.hh"
12 #include "scriptdef.hh"
13 #include "textdef.hh"
15 void
16 Stem_req::do_print() const
18 Rhythmic_req::do_print();
19 mtor << "dir : " << dir_i_;
22 Stem_req::Stem_req(int s, int d)
23 : Rhythmic_req(s,d)
25 dir_i_ = 0;
28 /* ************** */
29 void Musical_req::do_print()const{}
30 void Request::do_print() const{}
32 /* *************** */
34 void
35 Request::print() const
37 mtor << name() << " {";
38 do_print();
39 mtor << "}\n";
44 void
45 Span_req::do_print() const
47 #ifndef NPRINT
48 mtor << spantype ;
49 #endif
52 Request::Request()
54 elt_l_ = 0;
55 defined_ch_c_l_ = 0;
57 Request::Request(Request const&src)
59 elt_l_ = 0;
60 defined_ch_c_l_ = src.defined_ch_c_l_;
62 /* *************** */
63 Spacing_req::Spacing_req()
65 next = 0;
66 distance = 0;
67 strength = 0;
69 void
70 Spacing_req::do_print()const
72 mtor << "next " << next << "dist " << distance << "strength\n";
74 void
75 Blank_req::do_print()const
77 Spacing_req::do_print();
79 /* *************** */
80 Melodic_req::Melodic_req()
82 notename_i_ = 0;
83 octave_i_ = 0;
84 accidental_i_ = 0;
85 forceacc_b_ = false;
88 void
89 Melodic_req::do_print() const
91 mtor << "notename: " << notename_i_ << " oct: "<< octave_i_;
94 int
95 Melodic_req::height() const
97 return notename_i_ + octave_i_*7;
100 /* *************** */
102 Rhythmic_req::compare(const Rhythmic_req &r1, const Rhythmic_req &r2)
104 return sign(r1.duration() - r2.duration());
106 Rhythmic_req::Rhythmic_req(int b, int d)
108 plet_factor = 1;
109 balltype = b;
110 dots = d;
113 Rhythmic_req::Rhythmic_req()
115 plet_factor = 1;
116 balltype = 1;
117 dots = 0;
120 void
121 Rhythmic_req::do_print() const
123 mtor << "ball: " << balltype ;
124 int d =dots;
125 while (d--)
126 mtor << '.';
128 mtor<<", plet factor"<<plet_factor<<"\n";
132 Moment
133 Rhythmic_req::duration() const {
134 return wholes(balltype,dots)*plet_factor;
136 /* *************** */
138 Lyric_req::Lyric_req(Text_def* def_p)
139 :Text_req(0, def_p)
141 def_p->align_i_ = 1; // raggedright
142 dir_i_ = -1; // lyrics below (invisible) staff
145 void
146 Lyric_req::do_print() const
148 Rhythmic_req::do_print();
149 Text_req::do_print();
151 /* *************** */
152 void
153 Note_req::do_print() const
155 Melodic_req::do_print();
156 Rhythmic_req::do_print();
158 /* *************** */
159 void
160 Rest_req::do_print() const
162 Rhythmic_req::do_print();
165 /* *************** */
166 Beam_req::Beam_req()
168 nplet = 0;
171 void Beam_req::do_print()const{}
172 /* *************** */
173 void Slur_req::do_print()const{}
174 /* *************** */
176 Span_req:: compare(const Span_req &r1, const Span_req &r2)
178 return r1.spantype - r2.spantype;
181 Span_req::Span_req()
183 spantype = NOSPAN;
186 /* *************** */
187 Script_req::Script_req(int d , Script_def*def)
189 dir_i_ = d;
190 scriptdef_p_ = def;
194 Script_req::compare(const Script_req &d1, const Script_req &d2)
196 return d1.dir_i_ == d2.dir_i_ &&
197 d1.scriptdef_p_->compare(*d2.scriptdef_p_);
200 Script_req::Script_req(Script_req const &s)
201 : Request( s )
203 dir_i_ = s.dir_i_;
204 scriptdef_p_ = new Script_def(*s.scriptdef_p_);
207 void
208 Script_req::do_print() const
210 mtor << " dir " << dir_i_ ;
211 scriptdef_p_->print();
215 Script_req::~Script_req()
217 delete scriptdef_p_;
219 /* *************** */
221 Text_req:: compare(const Text_req &r1, const Text_req &r2)
223 bool b1 = (r1.dir_i_ == r2.dir_i_);
224 bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
225 return b1 && b2;
227 Text_req::~Text_req()
229 delete tdef_p_;
230 tdef_p_ = 0;
233 Text_req::Text_req(Text_req const& src)
235 tdef_p_ = new Text_def(*src.tdef_p_);
236 dir_i_ = src.dir_i_;
239 Text_req::Text_req(int dir_i, Text_def* tdef_p)
241 dir_i_ = dir_i;
242 tdef_p_ = tdef_p;
245 void
246 Text_req::do_print() const
248 mtor << " dir " << dir_i_ ;
249 tdef_p_->print();
252 /* *************** */
254 Moment
255 Skip_req::duration() const
257 return duration_;
260 void
261 Skip_req::do_print() const
263 mtor << "duration: " << duration();