2 dimension-cache.cc -- implement Dimension_cache
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "dimension-cache.hh"
12 Dimension_cache::Dimension_cache (Dimension_cache const &d)
15 callback_l_ = d.callback_l_;
16 empty_b_ = d.empty_b_;
17 offset_ = d.offset_; //let's hope others will copy the refpoint appropriately.
20 Dimension_cache::Dimension_cache ()
26 Dimension_cache::init()
39 Dimension_cache::invalidate ()
42 invalidate_dependencies ();
46 Dimension_cache::invalidate_dependencies ()
48 for (int i=0; i < dependencies_l_arr_.size (); i++)
50 Dimension_cache * g = dependencies_l_arr_[i];
59 Dimension_cache::set_offset (Real x)
61 invalidate_dependencies ();
66 Dimension_cache::translate (Real x)
68 invalidate_dependencies ();
73 Dimension_cache::relative_coordinate (Dimension_cache *refp) const
79 We catch PARENT_L_ == nil case with this, but we crash if we did
80 not ask for the absolute coordinate (ie. REFP == nil.)
83 if (refp == parent_l_)
86 return offset_ + parent_l_->relative_coordinate (refp);
90 Dimension_cache::common_refpoint (Dimension_cache const* s) const
92 Link_array<Dimension_cache> my_groups;
93 for (Dimension_cache const *c = this; c ; c = c->parent_l_)
94 my_groups.push ((Dimension_cache*)c);
96 Dimension_cache const *common=0;
98 for (Dimension_cache const * d = s; !common && d; d = d->parent_l_)
99 common = (Dimension_cache const*)my_groups.find_l (d);
101 return (Dimension_cache*) common;
107 Dimension_cache::set_empty (bool b)
118 Dimension_cache::get_dim () const
129 Dimension_cache *nc = ((Dimension_cache*)this);
130 nc->dim_= (*callback_l_ ) (nc);
140 Dimension_cache::set_callback (Dim_cache_callback c)