]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/score-elem.hh
release: 0.1.11
[lilypond.git] / lily / include / score-elem.hh
1 /*
2   score-elem.hh -- part of GNU LilyPond
3
4   (c) 1996,97 Han-Wen Nienhuys
5 */
6
7 #ifndef STAFFELEM_HH
8 #define STAFFELEM_HH
9
10 #include "parray.hh"
11 #include "lily-proto.hh"
12 #include "offset.hh"
13 #include "virtual-methods.hh"
14 #include "directed-graph.hh"
15
16 #define SCORE_ELEM_CLONE(T) VIRTUAL_COPY_CONS(T, Score_elem)
17
18
19
20 /** Both Spanner and Item are Score_elem's. Most Score_elem's depend
21   on other Score_elem's, eg, Beam needs to know and set direction of
22   Stem. So the Beam has to be calculated *before* Stem. This is
23   accomplished with the dependencies fields of struct Score_elem,
24   which are implemented in the Directed_graph_node class: all elements
25   form an acyclic graph.
26
27   (elem) */
28 class Score_elem : private Directed_graph_node {
29
30   /// member: the symbols
31   Molecule *output;             // should scrap, and use temp var?
32
33
34
35   /**
36     for administration of what was done already
37     */
38   enum Status {
39     ORPHAN,                     // not yet added to pstaff
40     VIRGIN,                     // added to pstaff
41     PREBREAKING,
42     PREBROKEN,
43     PRECALCING,
44     PRECALCED,          // calcs before spacing done
45     BREAKING,
46     BROKEN,
47     POSTCALCING,                // busy calculating. This is used to trap cyclic deps.
48     POSTCALCED,         // after spacing calcs done
49     BREWED,
50     TEXOUTPUT,                  // molecule has been output
51     DELETED,            // to catch malloc mistakes.
52   };
53     
54   Status status_;
55
56   Score_elem* dependency (int) const;
57   Score_elem* dependent (int) const;
58   int dependent_size() const;
59   int dependency_size() const;
60 public:
61   /**
62     This is  needed, because #output# may still be
63     NULL.
64     */
65   Offset offset_;
66
67
68
69
70   Paper_score *pscore_l_;    
71   Axis_group_element * axis_group_l_a_[NO_AXES];
72
73   Score_elem (Score_elem const&);
74   virtual String TeX_output_str () const ;
75     virtual void print() const;
76     
77   Paper_def *paper() const;
78
79   virtual ~Score_elem();
80   Score_elem();
81   DECLARE_MY_RUNTIME_TYPEINFO;    
82     
83   Interval extent (Axis) const;
84   Interval width() const;
85   Interval height() const;
86   Status status() const;
87     
88   /**
89     translate the symbol. The symbol does not have to be created yet. 
90     */
91   void translate (Offset);
92   /**
93     translate in one direction
94     */
95     
96   void translate (Real, Axis);
97   Real relative_coordinate (Axis_group_element*, Axis) const;
98   Offset absolute_offset() const;
99   Real absolute_coordinate (Axis) const;
100   Axis_group_element*common_group (Score_elem const* s, Axis a) const;
101
102   void add_processing();
103   void OK() const;
104   void pre_processing();
105   void breakable_col_processing();
106   void break_processing();
107     
108   void post_processing();
109   void molecule_processing();
110
111   /**
112     Remove all  links (dependencies, dependents, Axis_group_elements.
113     */
114   void unlink();
115   void unlink_all();
116   void substitute_dependency (Score_elem*,Score_elem*);
117   void remove_dependency (Score_elem*);
118   /**
119     add a dependency. It may be the 0 pointer, in which case, it is ignored.
120     */
121   void add_dependency (Score_elem*);    
122
123   /*
124     virtual accessors
125     */
126
127   virtual Spanner* spanner()  { return 0; }
128   virtual Item * item() { return 0; }
129   virtual Line_of_score * line_l() const;
130   virtual bool linked_b() const;
131   SCORE_ELEM_CLONE(Score_elem);
132  
133   /// no dimension, translation is noop
134   bool empty_b_;
135   /// do not print anything black
136   bool transparent_b_;
137 protected:
138
139   virtual Interval do_height() const;
140   virtual Interval do_width() const;
141     
142   /// do printing of derived info.
143   virtual void do_print() const {}
144   /// generate the molecule    
145   virtual Molecule* brew_molecule_p() const;
146   ///executed directly after the item is added to the Paper_score
147   virtual void do_add_processing();
148   /// do calculations before determining horizontal spacing
149   virtual void do_pre_processing();
150
151   virtual void do_breakable_col_processing();
152   /// do calculations after determining horizontal spacing
153   virtual void do_post_processing();
154   virtual String do_TeX_output_str () const;
155     
156   virtual void do_substitute_dependency (Score_elem * , Score_elem *);
157   virtual void do_substitute_dependent (Score_elem *, Score_elem *);
158   virtual void do_break_processing();
159   virtual void handle_broken_dependencies();
160   virtual void handle_prebroken_dependencies();
161   virtual Link_array<Score_elem> get_extra_dependencies() const;
162   virtual void do_unlink();
163   virtual void do_junk_links();
164   String make_TeX_string (Offset) const;
165 };
166
167
168 #endif // STAFFELEM_HH
169