]> git.donarmstrong.com Git - lilypond.git/blob - src/staffelem.cc
4be3cee0bf16f40e6a788db459f1febefdd7c64b
[lilypond.git] / src / staffelem.cc
1 #include "pscore.hh"
2 #include "symbol.hh"
3 #include "pstaff.hh"
4 #include "molecule.hh"
5 #include "staffelem.hh"
6
7 String
8 Staff_elem::TeXstring() const
9 {
10     assert(!calc_children);
11     Molecule m(*output);
12     m.translate(offset_);       // ugh?
13     return m.TeXstring();
14 }
15
16 Staff_elem::Staff_elem(Staff_elem const&s)
17     :    dependencies(s.dependencies)
18 {
19     status = s.status;
20     assert(!s.output);
21     output = 0;
22     pstaff_l_ = s.pstaff_l_;
23     calc_children = false;
24     offset_ = Offset(0,0);
25 }
26
27 Staff_elem::~Staff_elem()
28 {
29    delete output;
30 }
31 void
32 Staff_elem::translate(Offset O)
33 {
34     offset_ += O;
35 }
36 Interval
37 Staff_elem::width() const
38 {
39     Interval r;
40
41     if (!output){
42         Molecule*m      = brew_molecule_p();
43         r = m->extent().x;
44         delete m;
45     } else
46         r = output->extent().x;
47   
48     if (!r.empty()) // float exception on DEC Alpha
49         r+=offset_.x;
50
51     return r;
52 }
53 Interval
54 Staff_elem::height() const
55 {
56     Interval r;
57
58     if (!output){
59         Molecule*m      = brew_molecule_p();
60         r = m->extent().y;
61         delete m;
62     } else
63         r = output->extent().y;
64     
65     if (!r.empty())
66         r+=offset_.y;
67
68   
69     return r;
70 }
71
72 void
73 Staff_elem::print()const
74 {
75 #ifndef NPRINT
76     if (output)
77         output->print();
78 #endif
79 }
80
81 Staff_elem::Staff_elem()
82 {
83     calc_children = false;
84     pstaff_l_=0;
85     offset_ = Offset(0,0);
86     output = 0;
87     status = ORPHAN;
88 }
89
90
91 Paperdef*
92 Staff_elem::paper()  const
93 {
94     assert(pstaff_l_);
95     return pstaff_l_->pscore_l_->paper_l_;
96 }
97
98 void
99 Staff_elem::add_processing()
100 {
101     if (status >= VIRGIN)
102         return;
103
104     do_add_processing();
105     status = VIRGIN;
106 }
107
108 void
109 Staff_elem::pre_processing()
110 {
111     if (status >= PRECALCED )
112         return;
113     for (int i=0; i < dependencies.size(); i++)
114         if (dependencies[i])
115             dependencies[i]->pre_processing();
116     if (!calc_children)
117         do_pre_processing();
118     status = PRECALCED;
119 }
120 void
121 Staff_elem::post_processing()
122 {
123     if (status > POSTCALCED)
124         return;
125     for (int i=0; i < dependencies.size(); i++)
126         if (dependencies[i])
127             dependencies[i]->post_processing();
128     if (!calc_children)
129         do_post_processing();
130     status=POSTCALCED;
131 }
132
133 void 
134 Staff_elem::molecule_processing()
135 {
136     if (status >= OUTPUT)
137         return;
138     for (int i=0; i < dependencies.size(); i++)
139         if (dependencies[i])
140             dependencies[i]->molecule_processing();
141     if (!calc_children)
142         output= brew_molecule_p();
143     status = OUTPUT;    
144 }
145
146 void
147 Staff_elem::do_post_processing()
148 {
149 }
150
151 void
152 Staff_elem::do_pre_processing()
153 {
154 }
155
156 void
157 Staff_elem::do_add_processing()
158 {
159 }