]> git.donarmstrong.com Git - lilypond.git/blob - cols.cc
release: 0.0.3
[lilypond.git] / cols.cc
1 #include "cols.hh"
2 #include "pstaff.hh"
3
4 Idealspacing::Idealspacing(const PCol * l,const PCol * r)
5 {
6     space = 0.0;
7     hooke = 0.0;
8     left = l;
9     right = r;
10 }
11 void
12 Idealspacing::OK() const
13 {
14 #ifndef NDEBUG
15     assert(hooke >= 0 && left  && right);
16 #endif    
17 }
18
19 Interval
20 PCol::width() const
21 {
22     Interval w;
23
24     for (PCursor<const Item *> ic(its); ic.ok(); ic++)
25         w.unite(ic->width());
26     if (w.empty())
27         w.unite(Interval(0,0));
28     return w;
29 }
30 /****************************************************************/
31
32 int
33 PCol::compare(const PCol &c1, const PCol &c2)
34 {
35     assert(false);
36     return 0 ;
37 }
38
39 void
40 PCol::OK () const
41 {
42     if (prebreak || postbreak ) {
43         assert(breakable);
44     }
45 }
46
47 void
48 PCol::set_breakable()
49 {
50     if (breakable)
51         return;
52
53     prebreak = new PCol(this);
54     postbreak = new PCol(this);
55     breakable = true;
56     used = true;
57 }
58
59 PCol::PCol(PCol *parent) {
60     daddy = parent;
61     prebreak=0;
62     postbreak=0;
63     breakable=false;
64     line=0;
65     used  = false;
66 }
67
68 PCol::~PCol()
69 {
70     if (prebreak)
71         delete prebreak;        // no recursion!
72     if (postbreak)
73         delete postbreak;       
74 }
75
76 void
77 PCol::add(const Item *i)
78 {
79     its.bottom().add(i);
80     used = true;
81 }
82