]> git.donarmstrong.com Git - lilypond.git/blob - src/staffelem.cc
release: 0.0.23
[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     Molecule*m= brew_molecule();
40     Interval r;
41
42     if (!output){
43         Molecule*m      = brew_molecule();
44         r = m->extent().x;
45         delete m;
46     } else
47         r = output->extent().x;
48   
49     if (!r.empty()) // float exception on DEC Alpha
50         r+=offset_.x;
51
52     return r;
53 }
54 Interval
55 Staff_elem::height() const
56 {
57     Interval r;
58
59     if (!output){
60         Molecule*m      = brew_molecule();
61         r = m->extent().y;
62         delete m;
63     } else
64         r = output->extent().y;
65     
66     if (!r.empty())
67         r+=offset_.y;
68
69   
70     return r;
71 }
72
73 void
74 Staff_elem::print()const
75 {
76 #ifndef NPRINT
77     if (output)
78         output->print();
79 #endif
80 }
81
82 Staff_elem::Staff_elem()
83 {
84     calc_children = false;
85     pstaff_l_=0;
86     offset_ = Offset(0,0);
87     output = 0;
88     status = ORPHAN;
89 }
90
91
92 Paperdef*
93 Staff_elem::paper()  const
94 {
95     assert(pstaff_l_);
96     return pstaff_l_->pscore_l_->paper_l_;
97 }
98
99 void
100 Staff_elem::add_processing()
101 {
102     if (status >= VIRGIN)
103         return;
104
105     do_add_processing();
106     status = VIRGIN;
107 }
108
109 void
110 Staff_elem::pre_processing()
111 {
112     if (status >= PRECALCED )
113         return;
114     for (int i=0; i < dependencies.size(); i++)
115         if (dependencies[i])
116             dependencies[i]->pre_processing();
117     if (!calc_children)
118         do_pre_processing();
119     status = PRECALCED;
120 }
121 void
122 Staff_elem::post_processing()
123 {
124     if (status > POSTCALCED)
125         return;
126     for (int i=0; i < dependencies.size(); i++)
127         if (dependencies[i])
128             dependencies[i]->post_processing();
129     if (!calc_children)
130         do_post_processing();
131     status=POSTCALCED;
132 }
133
134 void 
135 Staff_elem::molecule_processing()
136 {
137     if (status >= OUTPUT)
138         return;
139     for (int i=0; i < dependencies.size(); i++)
140         if (dependencies[i])
141             dependencies[i]->molecule_processing();
142     if (!calc_children)
143         output= brew_molecule();
144     status = OUTPUT;    
145 }
146
147 void
148 Staff_elem::do_post_processing()
149 {
150 }
151
152 void
153 Staff_elem::do_pre_processing()
154 {
155 }
156
157 void
158 Staff_elem::do_add_processing()
159 {
160 }