]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/score-element.hh
e9ea8aff9910f52a9bfd76e7365ac934474d6e9d
[lilypond.git] / lily / include / score-element.hh
1 /*
2   score-element.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 "virtual-methods.hh"
12 #include "directed-graph.hh"
13 #include "graphical-element.hh"
14
15 #define SCORE_ELEMENT_CLONE(T) VIRTUAL_COPY_CONS (T, Score_element)
16
17
18 typedef void (Score_element::*Score_element_method_pointer) (void);
19
20 /** Both Spanner and Item are Score_element's. Most Score_element's depend
21   on other Score_element'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_element,
24   which are implemented in the Directed_graph_node class: all elements
25   form an acyclic graph.
26
27   (elem) */
28 class Score_element : private Directed_graph_node, public virtual Graphical_element {
29 public:
30   Paper_score *pscore_l_;    
31
32   Score_element ();
33   Score_element (Score_element const&);
34   virtual void print () const;
35     
36   Paper_def *paper () const;
37   Lookup const *lookup_l () const;
38
39   virtual ~Score_element ();
40   DECLARE_MY_RUNTIME_TYPEINFO;    
41
42   void add_processing ();
43
44   /**
45     Remove all  links (dependencies, dependents, Axis_group_elements.
46     */
47   void unlink ();
48   void substitute_dependency (Score_element*,Score_element*);
49   void remove_dependency (Score_element*);
50   /**
51     add a dependency. It may be the 0 pointer, in which case, it is ignored.
52     */
53   void add_dependency (Score_element*);    
54
55   /*
56     virtual accessors
57     */
58
59   virtual Spanner* access_Spanner ()  { return 0; }
60   virtual Span_bar* access_Span_bar ()  { return 0; }
61   virtual Axis_group_element * access_Axis_group_element () { return 0; }
62   virtual Score_element* access_Score_element () { return this; }
63   
64   virtual Item * access_Item () { return 0; }
65   virtual Line_of_score * line_l () const;
66   virtual bool linked_b () const;
67   SCORE_ELEMENT_CLONE (Score_element);
68  
69   /// do not print anything black
70   bool transparent_b_;
71
72   int size_i_;
73   
74   // ugh: no protection. Denk na, Vrij Veilig
75   void calculate_dependencies (int final, int busy, Score_element_method_pointer funcptr);
76
77 protected:
78   /**
79     Administration: Where are we?. This is mainly used by Super_element and
80     Score_element::calcalute_dependencies ()
81
82     0 means ORPHAN,
83     -1 means deleted
84     
85    */
86 public:
87   int status_i_;
88 protected:
89   Score_element* dependency (int) const;
90   Score_element* dependent (int) const;
91   int dependent_size () const;
92   int dependency_size () const;
93   
94   virtual void do_brew_molecule ();
95   void junk_links ();
96   virtual Interval do_height () const;
97   virtual Interval do_width () const;
98     
99   /// do printing of derived info.
100   virtual void do_print () const {}
101   /// generate the molecule    
102   virtual Molecule* brew_molecule_p () const;
103   ///executed directly after the item is added to the Paper_score
104   virtual void do_add_processing ();
105   /// do calculations before determining horizontal spacing
106   virtual void do_pre_processing ();
107
108   /// generate rods & springs
109   virtual void do_space_processing ();
110
111   virtual void do_breakable_col_processing ();
112   /// do calculations after determining horizontal spacing
113   virtual void do_post_processing ();
114     
115   virtual void do_substitute_dependency (Score_element * , Score_element *);
116   virtual void do_substitute_dependent (Score_element *, Score_element *);
117   virtual void do_break_processing ();
118   virtual void handle_broken_dependencies ();
119   virtual void handle_prebroken_dependencies ();
120   virtual Link_array<Score_element> get_extra_dependencies () const;
121   virtual void do_unlink ();
122   virtual void do_junk_links ();
123   
124 };
125
126
127 #endif // STAFFELEM_HH
128