2 staff-elem.cc -- implement Staff_elem
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "paper-def.hh"
14 #include "molecule.hh"
15 #include "staff-elem.hh"
19 Staff_elem::TeXstring() const
22 m.translate(offset_); // ugh?
26 Staff_elem::Staff_elem(Staff_elem const&s)
27 :dependancy_l_arr_(s.dependancy_l_arr_),
28 dependant_l_arr_(s.dependant_l_arr_)
33 pstaff_l_ = s.pstaff_l_;
34 offset_ = Offset(0,0);
39 If deleted, then remove dependant_l_arr_ depency!
41 Staff_elem::~Staff_elem()
47 Staff_elem::translate(Offset O)
53 Staff_elem::do_width() const return r;
57 Molecule*m = brew_molecule_p();
61 r = output->extent().x;
64 Staff_elem::width() const
66 Interval r=do_width();
68 if (!r.empty_b()) // float exception on DEC Alpha
74 Staff_elem::do_height() const return r
77 Molecule*m = brew_molecule_p();
81 r = output->extent().y;
85 Staff_elem::height() const
87 Interval r=do_height();
97 Staff_elem::print()const
100 mtor << name() << "{\n";
111 Staff_elem::Staff_elem()
114 offset_ = Offset(0,0);
121 Staff_elem::paper() const
124 return pstaff_l_->pscore_l_->paper_l_;
128 Staff_elem::add_processing()
130 if (status >= VIRGIN)
137 Staff_elem::pre_processing()
139 if (status >= PRECALCED )
141 assert(status != PRECALCING); // cyclic dependency
144 for (int i=0; i < dependancy_l_arr_.size(); i++)
145 if (dependancy_l_arr_[i])
146 dependancy_l_arr_[i]->pre_processing();
153 Staff_elem::post_processing()
155 if (status >= POSTCALCED)
157 assert(status != POSTCALCING);// cyclic dependency
160 for (int i=0; i < dependancy_l_arr_.size(); i++)
161 if (dependancy_l_arr_[i])
162 dependancy_l_arr_[i]->post_processing();
163 do_post_processing();
168 Staff_elem::molecule_processing()
170 if (status >= OUTPUT)
172 status = OUTPUT; // do it only once.
173 for (int i=0; i < dependancy_l_arr_.size(); i++)
174 if (dependancy_l_arr_[i])
175 dependancy_l_arr_[i]->molecule_processing();
177 output= brew_molecule_p();
181 Staff_elem::do_post_processing()
186 Staff_elem::do_pre_processing()
191 Staff_elem::do_add_processing()
196 Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep)
199 for (int i=0; i < dependancy_l_arr_.size(); i++) {
200 if (dependancy_l_arr_[i] == old){
201 dependancy_l_arr_[i] = newdep;
203 } else if (dependancy_l_arr_[i] == newdep) {
208 dependancy_l_arr_.push(newdep);
212 Staff_elem::add_dependency(Staff_elem * p)
214 for (int i=0; i < dependancy_l_arr_.size(); i ++)
215 if (dependancy_l_arr_[i] == p)
218 dependancy_l_arr_.push(p);
219 p->dependant_l_arr_.push(p);
221 IMPLEMENT_STATIC_NAME(Staff_elem);
224 Staff_elem::brew_molecule_p()const
226 Atom a(paper()->lookup_l()->fill(Box(Interval(0,0), Interval(0,0))));
227 return new Molecule (a);