]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/staff-elem.hh
release: 0.0.46.jcn1
[lilypond.git] / lily / include / staff-elem.hh
1 /*
2   staff-elem.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 #include "class-name.hh"
14
15
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.
20
21   (elem)
22   */
23 class Staff_elem {
24
25     /// member: the symbols
26     Molecule *output;           // should scrap, and use temp var?
27
28
29     /**
30       This is  needed, because #output# may still be
31       NULL.
32       */
33     Offset offset_;
34     Array<Staff_elem*> dependancy_l_arr_;
35 public:
36     enum Status {
37         ORPHAN,                 // not yet added to pstaff
38         VIRGIN,                 // added to pstaff
39         PRECALCING,
40         PRECALCED,              // calcs before spacing done
41         POSTCALCING,            // busy calculating. This is used to trap cyclic deps.
42         POSTCALCED,             // after spacing calcs done
43         OUTPUT,                 // molecule has been output
44     } status;
45     
46     ///  the pstaff it is in
47     PStaff *pstaff_l_;
48
49     /* *************** */
50     Staff_elem(Staff_elem const&);
51     String TeXstring () const ;
52     virtual void print() const;
53     virtual Interval width() const;
54     virtual Interval height() const;
55     Paper_def *paper() const;
56     virtual ~Staff_elem();
57     Staff_elem();
58     NAME_MEMBERS(Staff_elem);    
59     void translate(Offset);
60     void add_processing();
61     void pre_processing();
62     void post_processing();
63     void molecule_processing();
64     
65     virtual Spanner* spanner()  { return 0; }
66     virtual Item * item() { return 0; }
67     void add_dependency(Staff_elem* );    
68     void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
69     
70 protected:
71     
72     /// do printing of derived info.
73     virtual void do_print() const=0;
74     /// generate the molecule    
75     virtual Molecule* brew_molecule_p()const=0;
76     ///executed directly after the item is added to the PScore
77     virtual void do_add_processing();
78     /// do calculations before determining horizontal spacing
79     virtual void do_pre_processing();
80
81     /// do calculations after determining horizontal spacing
82     virtual void do_post_processing();
83
84     Array<Staff_elem*> dependant_l_arr_;
85
86 };
87
88
89 #endif // STAFFELEM_HH
90