]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
* scm/define-context-properties.scm
[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--2005 Han-Wen Nienhuys
7 */
8
9 #ifndef GROB_HH
10 #define GROB_HH
11
12 #include "virtual-methods.hh"
13 #include "dimension-cache.hh"
14 #include "grob-interface.hh"
15 #include "object-key.hh"
16
17 enum Grob_status
18   {
19     ORPHAN = 0, // not yet added to Paper_score
20     PRECALCING,
21     PRECALCED, // calcs before spacing done
22     POSTCALCING, // busy calculating. This is used to trap cyclic deps.
23     POSTCALCED, // after spacing calcs done
24   };
25
26 typedef void (Grob:: *Grob_method_pointer) (void);
27
28 class Grob
29 {
30 private:
31   DECLARE_SMOBS (Grob, foo);
32   void init ();
33
34
35
36 protected:
37   Object_key const *key_;
38   SCM immutable_property_alist_;
39   SCM mutable_property_alist_;
40   SCM object_alist_;
41   SCM property_callbacks_;
42   
43   /*
44     If this is a property, it accounts for 25% of the property
45     lookups.
46   */
47   SCM interfaces_;
48
49   /* BARF */
50   friend class Spanner;
51   friend SCM ly_grob_properties (SCM);
52   friend SCM ly_grob_basic_properties (SCM);
53   friend void check_interfaces_for_property (Grob const *, SCM);
54   void substitute_object_links (SCM, SCM);
55   char status_;
56
57   DECLARE_CLASSNAME(Grob);
58 public:
59   DECLARE_SCHEME_CALLBACK(same_axis_parent_positioning, (SCM, SCM));
60   DECLARE_SCHEME_CALLBACK(other_axis_parent_positioning, (SCM, SCM));
61
62   Object_key const *get_key () const;
63
64   Grob *original_;
65
66   /* TODO: junk this member. */
67   Paper_score *pscore_;
68
69   Dimension_cache dim_cache_[NO_AXES];
70
71   Grob (SCM basic_props, Object_key const *);
72   Grob (Grob const &, int copy_count);
73
74   virtual Grob *clone (int count) const;
75   DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
76   
77   String name () const;
78   /*
79     Properties
80   */
81   SCM internal_get_property (SCM symbol) const;
82   SCM get_property_data (SCM symbol) const;
83   SCM internal_get_object (SCM symbol) const;
84
85   void internal_set_property (SCM sym, SCM val);
86   void internal_set_object (SCM sym, SCM val);
87
88   SCM try_callback (SCM);
89   /*
90     JUNKME.
91   */
92   void add_to_list_property (SCM, SCM);
93   void add_to_object_list (SCM sym, SCM thing);
94
95   SCM get_property_alist_chain (SCM) const;
96   static SCM ly_grob_set_property (SCM, SCM, SCM);
97   static SCM ly_grob_property (SCM, SCM);
98
99   void warning (String) const;
100   void programming_error (String) const;
101
102   Output_def *get_layout () const;
103   void add_dependency (Grob *);
104   virtual System *get_system () const;
105
106   void calculate_dependencies (int final, int busy, SCM funcname);
107
108   virtual void do_break_processing ();
109   virtual Grob *find_broken_piece (System *) const;
110   virtual void discretionary_processing ();
111   virtual void derived_mark () const;
112
113   Stencil *get_stencil () const;
114   SCM get_uncached_stencil () const;
115
116   void suicide ();
117   bool is_live () const;
118   bool is_empty (Axis a) const;
119
120   bool internal_has_interface (SCM intf);
121   static bool has_interface (Grob *me);
122
123   virtual void handle_broken_dependencies ();
124   virtual void handle_prebroken_dependencies ();
125
126   Interval extent (Grob *refpoint, Axis) const;
127
128   void translate_axis (Real, Axis);
129   Real relative_coordinate (Grob const *refp, Axis) const;
130   Grob *common_refpoint (Grob const *s, Axis a) const;
131
132   // duh. slim down interface here. (todo)
133   bool has_offset_callback (SCM callback, Axis) const;
134   void add_offset_callback (SCM callback, Axis);
135   bool has_extent_callback (SCM, Axis) const;
136   void flush_extent_cache (Axis);
137   void set_extent (SCM, Axis);
138   void set_extent_callback (SCM, Axis);
139   Real get_offset (Axis a) const;
140
141   void set_parent (Grob *e, Axis);
142
143   // URG
144   Grob *get_parent (Axis a) const;
145   void fixup_refpoint ();
146 };
147
148 DECLARE_UNSMOB (Grob, grob);
149 Spanner *unsmob_spanner (SCM);
150 Item *unsmob_item (SCM);
151
152 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
153 Grob *common_refpoint_of_array (Link_array<Grob> const &, Grob *, Axis a);
154
155 void set_break_subsititution (SCM criterion);
156 SCM substitute_object_alist (SCM alist, SCM dest);
157
158 Link_array<Grob> ly_scm2grobs (SCM ell);
159 SCM ly_grobs2scm (Link_array<Grob> a);
160
161 Interval robust_relative_extent (Grob *, Grob *, Axis);
162
163 #endif /* GROB_HH */