]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
* lily/staff-symbol-engraver.cc (acknowledge_grob): remove item ->
[lilypond.git] / lily / include / grob.hh
1 /*
2   grob.hh -- declare Grob
3
4   source file of the LilyPond music typesetter
5   
6   (c) 1996--2004 Han-Wen Nienhuys
7 */
8
9 #ifndef GROB_HH
10 #define GROB_HH
11
12 #include "parray.hh"
13 #include "virtual-methods.hh"
14 #include "lily-guile.hh"
15 #include "lily-proto.hh"
16 #include "smobs.hh"
17 #include "dimension-cache.hh"
18 #include "grob-interface.hh"
19
20 /**
21     for administration of what was done already
22     */
23 enum Grob_status {
24   ORPHAN=0,                     // not yet added to Paper_score
25   PRECALCING,
26   PRECALCED,            // calcs before spacing done
27   POSTCALCING,          // busy calculating. This is used to trap cyclic deps.
28   POSTCALCED,           // after spacing calcs done
29 };
30
31 typedef void (Grob::*Grob_method_pointer) (void);
32
33
34 /* Basic G[raphical output] O[bject].  */
35 class Grob
36 {
37 protected:
38   SCM immutable_property_alist_;
39   SCM mutable_property_alist_;
40   friend class Spanner;
41   
42   void substitute_mutable_properties(SCM,SCM);
43
44 public:
45   Grob *original_;
46
47   /**
48     Administration: Where are we?. This is mainly used by Super_element and
49     Grob::calcalute_dependencies ()
50
51     0 means ORPHAN,
52    */
53   char status_;
54   Paper_score *pscore_;
55   Dimension_cache dim_cache_[NO_AXES];
56
57   Grob (SCM basic_props);
58   Grob (Grob const&);
59   VIRTUAL_COPY_CONSTRUCTOR(Grob,Grob);
60  
61   String name () const;
62   
63   /*
64     properties
65    */
66   SCM internal_get_property (SCM) const;
67   void internal_set_property (SCM, SCM val);
68   void add_to_list_property (SCM, SCM);
69   void warning (String)const;
70   void programming_error (String)const;
71   
72   /*
73     related classes.
74    */
75   Output_def *get_paper () const;
76
77   /**
78     add a dependency. It may be the 0 pointer, in which case, it is ignored.
79     */
80   void add_dependency (Grob*);    
81   virtual System * get_system () const;
82
83   /**
84      Recursively track all dependencies of this Grob.  The
85      status_ field is used as a mark-field.  It is marked with
86      #busy# during execution of this function, and marked with #final#
87      when finished.
88
89      #funcptr# is the function to call to update this element.
90    */
91   void calculate_dependencies (int final, int busy, SCM funcname);
92
93
94   virtual void do_break_processing ();
95   virtual Grob *find_broken_piece (System*) const;
96   virtual void discretionary_processing ();
97   virtual SCM do_derived_mark () const;
98
99   Stencil * get_stencil () const;
100   SCM get_uncached_stencil () const;
101
102   SCM get_property_alist_chain (SCM) const;
103   void suicide ();
104   bool is_live () const;
105   
106   DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
107
108   static SCM ly_grob_set_property (SCM, SCM,SCM);
109   static SCM ly_grob_property (SCM, SCM);  
110
111   bool internal_has_interface (SCM intf);
112   static bool has_interface (Grob*me);  
113
114   virtual void handle_broken_dependencies ();
115   virtual void handle_prebroken_dependencies ();
116
117   DECLARE_SMOBS (Grob,foo);
118
119   void init ();
120 public:
121   bool is_empty (Axis a) const;
122
123   Interval extent (Grob * refpoint, Axis) const;
124  
125   void translate_axis (Real, Axis);
126   Real relative_coordinate (Grob const* refp, Axis) const;
127   Grob*common_refpoint (Grob const* s, Axis a) const;
128
129   // duh. slim down interface here. (todo)
130   bool has_offset_callback (SCM callback, Axis)const;
131   void add_offset_callback (SCM callback, Axis);
132   bool has_extent_callback (SCM, Axis)const;  
133   void set_extent (SCM , Axis);
134   Real get_offset (Axis a) const;
135   
136   void set_parent (Grob* e, Axis);
137   Grob *get_parent (Axis a) const {   return  dim_cache_[a].parent_; }
138
139   DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM));
140 };
141
142 DECLARE_UNSMOB(Grob,grob);
143 Spanner* unsmob_spanner (SCM );
144 Item* unsmob_item (SCM );
145
146 Grob*common_refpoint_of_list (SCM elt_list, Grob * , Axis a);
147 Grob*common_refpoint_of_array (Link_array<Grob> const&, Grob * , Axis a);
148
149 void set_break_subsititution (SCM criterion);
150 SCM substitute_mutable_property_alist (SCM alist);
151
152 Link_array<Grob> ly_scm2grobs (SCM l);
153 SCM ly_grobs2scm (Link_array<Grob> a);
154
155 #endif /* GROB_HH */
156