]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
* buildscripts/guile-gnome.sh: Build without gcc libtool version
[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 // looking at gtk+/pango docstrings .. WIP
34
35 /**
36  * Grob:
37  * @internal_get_property: get property #NAME.
38  *
39  * Class structure for #Grob.
40  **/
41 class Grob
42 {
43 private:  
44   DECLARE_SMOBS (Grob, foo);
45   void init ();
46
47 protected:
48   SCM immutable_property_alist_;
49   SCM mutable_property_alist_;
50   
51   /* BARF */
52   friend class Spanner;
53   friend SCM ly_grob_properties (SCM);
54   friend SCM ly_grob_basic_properties (SCM);
55   
56   void substitute_mutable_properties (SCM, SCM);
57   char status_;
58   
59 public:
60   Grob *original_;
61
62   /* TODO: junk this member. */
63   Paper_score *pscore_;
64
65   Dimension_cache dim_cache_[NO_AXES];
66
67   Grob (SCM basic_props);
68   Grob (Grob const&);
69   VIRTUAL_COPY_CONSTRUCTOR (Grob, Grob);
70   DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
71  
72   String name () const;
73
74
75   /*
76     Properties
77    */
78   SCM internal_get_property (SCM) const;
79   void internal_set_property (SCM, SCM val);
80   void add_to_list_property (SCM, SCM);
81
82   SCM get_property_alist_chain (SCM) const;
83   static SCM ly_grob_set_property (SCM, SCM,SCM);
84   static SCM ly_grob_property (SCM, SCM);  
85
86   void warning (String) const;
87   void programming_error (String) const;
88   
89   Output_def *get_paper () const;
90   void add_dependency (Grob*);    
91   virtual System *get_system () const;
92
93   void calculate_dependencies (int final, int busy, SCM funcname);
94
95
96   virtual void do_break_processing ();
97   virtual Grob *find_broken_piece (System*) const;
98   virtual void discretionary_processing ();
99   virtual SCM do_derived_mark () const;
100
101   Stencil *get_stencil () const;
102   SCM get_uncached_stencil () const;
103
104   void suicide ();
105   bool is_live () const;
106   bool is_empty (Axis a) const;
107   
108   bool internal_has_interface (SCM intf);
109   static bool has_interface (Grob *me);
110
111   virtual void handle_broken_dependencies ();
112   virtual void handle_prebroken_dependencies ();
113
114   Interval extent (Grob * refpoint, Axis) const;
115  
116   void translate_axis (Real, Axis);
117   Real relative_coordinate (Grob const *refp, Axis) const;
118   Grob *common_refpoint (Grob const *s, Axis a) const;
119
120   // duh. slim down interface here. (todo)
121   bool has_offset_callback (SCM callback, Axis) const;
122   void add_offset_callback (SCM callback, Axis);
123   bool has_extent_callback (SCM, Axis) const;
124   void set_extent (SCM, Axis);
125   Real get_offset (Axis a) const;
126   
127   void set_parent (Grob* e, Axis);
128
129   // URG
130   Grob *get_parent (Axis a) const
131   {
132     return  dim_cache_[a].parent_;
133   }
134
135   DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM));
136 };
137
138 DECLARE_UNSMOB (Grob, grob);
139 Spanner *unsmob_spanner (SCM);
140 Item *unsmob_item (SCM);
141
142 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
143 Grob *common_refpoint_of_array (Link_array<Grob> const&, Grob *, Axis a);
144
145 void set_break_subsititution (SCM criterion);
146 SCM substitute_mutable_property_alist (SCM alist);
147
148 Link_array<Grob> ly_scm2grobs (SCM ell);
149 SCM ly_grobs2scm (Link_array<Grob> a);
150
151 #endif /* GROB_HH */
152