lilypond-0.1.33
[lilypond.git] / hdr / staffelem.hh
blob3928c994e919bc2806a11e52253f62d95ca8991c
1 /*
2 staffelem.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"
14 /** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend
15 on other Staff_elem's, eg, Beam needs to know and set direction of
16 Stem. So the Beam has to be calculated *before* Stem. This is
17 accomplished with the dependencies field of struct Staff_elem.
20 struct Staff_elem {
21 enum Status {
22 ORPHAN, // not yet added to pstaff
23 VIRGIN, // added to pstaff
24 PRECALCING,
25 PRECALCED, // calcs before spacing done
26 POSTCALCING,
27 POSTCALCED, // after spacing calcs done
28 OUTPUT, // molecule has been output
29 } status;
31 /// the pstaff it is in
32 PStaff *pstaff_l_;
34 /* *************** */
35 Staff_elem(Staff_elem const&);
36 String TeXstring () const ;
37 virtual void print() const;
38 virtual Interval width() const;
39 virtual Interval height() const;
40 Paperdef *paper() const;
41 virtual ~Staff_elem();
42 Staff_elem();
44 void translate(Offset);
45 void add_processing();
46 void pre_processing();
47 void post_processing();
48 void molecule_processing();
49 virtual const char *name() const; // to find out derived classes.
50 virtual Spanner* spanner() { return 0; }
51 virtual Item * item() { return 0; }
52 void add_depedency(Staff_elem* );
53 void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
54 protected:
56 /// do printing of derived info.
57 virtual void do_print() const=0;
58 /// generate the molecule
59 virtual Molecule* brew_molecule_p()const=0;
60 ///executed directly after the item is added to the PScore
61 virtual void do_add_processing();
62 /// do calculations before determining horizontal spacing
63 virtual void do_pre_processing();
65 /// do calculations after determining horizontal spacing
66 virtual void do_post_processing();
68 Array<Staff_elem*> dependants;
70 private:
71 /// member: the symbols
72 Molecule *output; // should scrap, and use temp var?
75 /**
76 This is needed, because #output# may still be
77 NULL.
79 Offset offset_;
80 Array<Staff_elem*> dependencies;
82 #define NAME_METHOD(c) const char *c::name()const{ return #c; } struct c
83 #endif // STAFFELEM_HH