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