]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/staff-elem.hh
release: 0.0.64
[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 Score_elem's. Most Score_elem's depend
17   on other Score_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 Score_elem.
20
21   (elem)
22   */
23 class Score_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<Score_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         VERTICALCING,           // height determined
44         VERTICALCED,
45         OUTPUT,                 // molecule has been output
46         DELETED,                // to catch malloc mistakes.
47     } status;
48     
49     ///  the pstaff it is in
50     PStaff *pstaff_l_;
51
52     /* *************** */
53     Score_elem(Score_elem const&);
54     String TeXstring () const ;
55     virtual void print() const;
56     virtual Interval width() const;
57     virtual Interval height() const;
58     Paper_def *paper() const;
59     virtual ~Score_elem();
60     Score_elem();
61     NAME_MEMBERS(Score_elem);    
62
63     /**
64       translate the symbol. The symbol does not have to be created yet. 
65       Overridable, since this staff-elem might act as a pseudo-list.
66      */
67     virtual void translate(Offset);
68     Offset offset()const;
69     void add_processing();
70     void pre_processing();
71     void post_processing();
72     void molecule_processing();
73     
74     virtual Spanner* spanner()  { return 0; }
75     virtual Item * item() { return 0; }
76     /**
77       add a dependency. It may be the 0 pointer, in which case, it is ignored.
78      */
79     void add_dependency(Score_elem* );    
80     void substitute_dependency(Score_elem* old, Score_elem * newdep);
81     
82 protected:
83     virtual  Interval do_height()const;
84     virtual Interval do_width()const;
85     /// do printing of derived info.
86     virtual void do_print() const {}
87     /// generate the molecule    
88     virtual Molecule* brew_molecule_p()const;
89     ///executed directly after the item is added to the PScore
90     virtual void do_add_processing();
91     /// do calculations before determining horizontal spacing
92     virtual void do_pre_processing();
93
94     /// do calculations after determining horizontal spacing
95     virtual void do_post_processing();
96
97     /// do calculations after height of spanners/items is determined.
98     virtual void do_verticalcing();
99     Array<Score_elem*> dependant_l_arr_;
100
101 };
102
103
104 #endif // STAFFELEM_HH
105