lilypond-0.1.57
[lilypond.git] / hdr / staff-elem.hh
blobe2fce84582df8b177cb54f81739419c2c78ba9ae
1 /*
2 staff-elem.hh -- part of LilyPond
4 (c) 1996,97 Han-Wen Nienhuys
5 */
7 #ifndef STAFFELEM_HH
8 #define STAFFELEM_HH
9 #include "varray.hh"
10 #include "proto.hh"
11 #include "offset.hh"
12 #include "molecule.hh"
13 #include "class-name.hh"
16 /** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend
17 on other Staff_elem's, eg, Beam needs to know and set direction of
18 Stem. So the Beam has to be calculated *before* Stem. This is
19 accomplished with the dependencies field of struct Staff_elem.
22 struct Staff_elem {
23 enum Status {
24 ORPHAN, // not yet added to pstaff
25 VIRGIN, // added to pstaff
26 PRECALCING,
27 PRECALCED, // calcs before spacing done
28 POSTCALCING,
29 POSTCALCED, // after spacing calcs done
30 OUTPUT, // molecule has been output
31 } status;
33 /// the pstaff it is in
34 PStaff *pstaff_l_;
36 /* *************** */
37 Staff_elem(Staff_elem const&);
38 String TeXstring () const ;
39 virtual void print() const;
40 virtual Interval width() const;
41 virtual Interval height() const;
42 Paper_def *paper() const;
43 virtual ~Staff_elem();
44 Staff_elem();
45 NAME_MEMBERS(Staff_elem);
46 void translate(Offset);
47 void add_processing();
48 void pre_processing();
49 void post_processing();
50 void molecule_processing();
52 virtual Spanner* spanner() { return 0; }
53 virtual Item * item() { return 0; }
54 void add_dependency(Staff_elem* );
55 void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
57 protected:
59 /// do printing of derived info.
60 virtual void do_print() const=0;
61 /// generate the molecule
62 virtual Molecule* brew_molecule_p()const=0;
63 ///executed directly after the item is added to the PScore
64 virtual void do_add_processing();
65 /// do calculations before determining horizontal spacing
66 virtual void do_pre_processing();
68 /// do calculations after determining horizontal spacing
69 virtual void do_post_processing();
71 Array<Staff_elem*> dependants;
73 private:
74 /// member: the symbols
75 Molecule *output; // should scrap, and use temp var?
78 /**
79 This is needed, because #output# may still be
80 NULL.
82 Offset offset_;
83 Array<Staff_elem*> dependencies;
87 #endif // STAFFELEM_HH