]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff.cc
release: 0.0.65
[lilypond.git] / lily / staff.cc
1 /*
2   staff.cc -- implement Staff
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "proto.hh"
10 #include "plist.hh"
11 #include "input-register.hh"
12 #include "staff.hh"
13 #include "score.hh"
14 #include "voice.hh"
15 #include "staff-column.hh"
16 #include "score-column.hh"
17 #include "voice-element.hh"
18 #include "debug.hh"
19 #include "musical-request.hh"
20 #include "command-request.hh" // todo
21 #include "staffline.hh"
22 #include "complex-walker.hh"
23 #include "super-elem.hh"
24 #include "p-score.hh"
25 #include "scoreline.hh"
26
27 void
28 Staff::add(Link_list<Voice*> const &l)
29 {
30     for (iter_top(l,i); i.ok(); i++)
31         voice_list_.bottom().add(i);
32 }
33
34 Paper_def *
35 Staff::paper() const
36 {
37     return score_l_->paper_p_;
38 }
39
40 void
41 Staff::clean_cols()
42 {
43 #if 0 // TODO
44     iter_top(cols_,i);
45     for(; i.ok(); ){
46         if (!i->musical_column_l_->used_b())
47             i->musical_column_l_ = 0;
48         if (!i->command_column_l_->used_b())
49             i->command_column_l_ =0;
50         
51         if (!i->command_column_l_&& !i->musical_column_l_)
52             delete i.remove_p();
53         else
54             i++;
55     }
56 #endif
57 }
58
59
60 void
61 Staff::OK() const
62 {
63 #ifndef NDEBUG
64     cols_.OK();
65     voice_list_.OK();
66     assert(score_l_);
67 #endif    
68 }
69
70
71 Moment
72 Staff::last() const
73 {
74     Moment l = 0;
75     for (iter_top(voice_list_,i); i.ok(); i++) {
76         l = l >? i->last();
77     }
78     return l;
79 }
80
81 void
82 Staff::print() const
83 {
84 #ifndef NPRINT
85     mtor << "Staff {\n";
86     for (iter_top(voice_list_,i); i.ok(); i++) {
87         i->print();     
88     }
89     ireg_p_->print();
90     mtor <<"}\n";
91 #endif
92 }
93
94 Staff::~Staff()
95 {
96     delete ireg_p_;
97 }
98
99 Staff::Staff()
100 {    
101     ireg_p_ =0;
102     score_l_ =0;
103     pscore_l_ =0;
104 }
105
106 void
107 Staff::add_col(Staff_column*c_l)
108 {
109     cols_.bottom().add(c_l);
110     c_l->staff_l_ = this;
111 }
112
113 void
114 Staff::set_output(PScore* pscore_l )
115 {
116     pscore_l_ = pscore_l;
117     staff_line_l_ = new Line_of_staff;
118     pscore_l_->typeset_unbroken_spanner(staff_line_l_);
119     pscore_l_->super_elem_l_->line_of_score_l_->add_line(staff_line_l_);
120 }
121
122
123 Staff_walker * 
124 Staff::get_walker_p()
125 {
126     return new Complex_walker(this);
127 }