lilypond-0.0.5
[lilypond.git] / pcol.cc
blob44c82a938ddf67ff316bbb82c0663638c2a4c32c
1 #include "pcol.hh"
2 #include "pstaff.hh"
3 #include "debug.hh"
5 void
6 Idealspacing::print() const
8 #ifndef NPRINT
9 mtor << "idealspacing {" ;
10 mtor << "distance "<<space<< " strength " << hooke << "}\n";
11 #endif
14 Idealspacing::Idealspacing(const PCol * l,const PCol * r)
16 space = 0.0;
17 hooke = 0.0;
18 left = l;
19 right = r;
21 void
22 Idealspacing::OK() const
24 #ifndef NDEBUG
25 assert(hooke >= 0 && left && right);
26 #endif
29 /****************************************************************/
31 Interval
32 PCol::width() const
34 Interval w;
36 for (PCursor<const Item *> ic(its); ic.ok(); ic++)
37 w.unite(ic->width());
38 if (w.empty())
39 w.unite(Interval(0,0));
40 return w;
43 void
44 PCol::print() const
46 #ifndef NPRINT
47 mtor << "PCol {";
48 mtor << "# symbols: " << its.size() ;
49 mtor << "breakable: " << breakable<<"\n";
50 mtor << "extent: " << width().min << ", " << width().max << "\n";
51 mtor << "}\n";
52 #endif
55 int
56 PCol::compare(const PCol &, const PCol &)
58 assert(false);
59 return 0 ;
62 void
63 PCol::OK () const
65 if (prebreak || postbreak ) {
66 assert(breakable);
71 void
72 PCol::set_breakable()
74 if (breakable)
75 return;
77 prebreak = new PCol(this);
78 postbreak = new PCol(this);
79 breakable = true;
80 used = true;
83 PCol::PCol(PCol *parent) {
84 daddy = parent;
85 prebreak=0;
86 postbreak=0;
87 breakable=false;
88 line=0;
89 used = false;
92 PCol::~PCol()
94 if (prebreak)
95 delete prebreak; // no recursion!
96 if (postbreak)
97 delete postbreak;
100 void
101 PCol::add(const Item *i)
103 its.bottom().add(i);
104 used = true;