]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
* lily/grob-scheme.cc (LY_DEFINE): new function ly:grob-set-callback!
[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 typedef void (Grob:: *Grob_method_pointer) (void);
18
19 class Grob
20 {
21 private:
22   DECLARE_SMOBS (Grob, foo);
23   void init ();
24
25 protected:
26   Object_key const *key_;
27   SCM immutable_property_alist_;
28   SCM mutable_property_alist_;
29   SCM object_alist_;
30   SCM property_callbacks_;
31   
32   /*
33     If this is a property, it accounts for 25% of the property
34     lookups.
35   */
36   SCM interfaces_;
37
38   /* BARF */
39   friend class Spanner;
40   friend SCM ly_grob_properties (SCM);
41   friend SCM ly_grob_basic_properties (SCM);
42   friend void check_interfaces_for_property (Grob const *, SCM);
43   void substitute_object_links (SCM, SCM);
44   char status_;
45
46   DECLARE_CLASSNAME(Grob);
47 public:
48   DECLARE_SCHEME_CALLBACK(same_axis_parent_positioning, (SCM, SCM));
49   DECLARE_SCHEME_CALLBACK(other_axis_parent_positioning, (SCM, SCM));
50
51   Object_key const *get_key () const;
52
53   Grob *original_;
54
55   /* TODO: junk this member. */
56   Paper_score *pscore_;
57
58   Dimension_cache dim_cache_[NO_AXES];
59
60   Grob (SCM basic_props, Object_key const *);
61   Grob (Grob const &, int copy_count);
62
63   virtual Grob *clone (int count) const;
64   DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
65   
66   String name () const;
67   /*
68     Properties
69   */
70   SCM internal_get_property (SCM symbol) const;
71   SCM get_property_data (SCM symbol) const;
72   SCM internal_get_object (SCM symbol) const;
73
74   void internal_set_property (SCM sym, SCM val);
75   void internal_set_object (SCM sym, SCM val);
76
77   SCM try_callback (SCM);
78   /*
79     JUNKME.
80   */
81   void add_to_list_property (SCM, SCM);
82   void add_to_object_list (SCM sym, SCM thing);
83
84   SCM get_property_alist_chain (SCM) const;
85   static SCM ly_grob_set_property (SCM, SCM, SCM);
86   static SCM ly_grob_property (SCM, SCM);
87
88   void warning (String) const;
89   void programming_error (String) const;
90
91   Output_def *get_layout () const;
92   void add_dependency (Grob *);
93   virtual System *get_system () const;
94
95   void calculate_dependencies (int final, int busy, SCM funcname);
96
97   virtual void do_break_processing ();
98   virtual Grob *find_broken_piece (System *) const;
99   virtual void discretionary_processing ();
100   virtual void derived_mark () const;
101
102   Stencil *get_stencil () const;
103   Stencil get_print_stencil () const;
104
105   void suicide ();
106   bool is_live () const;
107   bool is_empty (Axis a) const;
108
109   bool internal_has_interface (SCM intf);
110   static bool has_interface (Grob *me);
111
112   virtual void handle_broken_dependencies ();
113   virtual void handle_prebroken_dependencies ();
114
115   Interval extent (Grob *refpoint, Axis) const;
116
117   void translate_axis (Real, Axis);
118   Real relative_coordinate (Grob const *refp, Axis) const;
119   Grob *common_refpoint (Grob const *s, Axis a) const;
120
121   // duh. slim down interface here. (todo)
122   void set_callback (SCM sym, SCM proc);
123   bool has_offset_callback (SCM callback, Axis) const;
124   void add_offset_callback (SCM callback, Axis);
125   bool has_extent_callback (SCM, Axis) const;
126   void flush_extent_cache (Axis);
127   void set_extent (SCM, Axis);
128   void set_extent_callback (SCM, Axis);
129   Real get_offset (Axis a) const;
130
131   void set_parent (Grob *e, Axis);
132
133   // URG
134   Grob *get_parent (Axis a) const;
135   void fixup_refpoint ();
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_object_alist (SCM alist, SCM dest);
147
148 Link_array<Grob> ly_scm2grobs (SCM ell);
149 SCM ly_grobs2scm (Link_array<Grob> a);
150
151 Interval robust_relative_extent (Grob *, Grob *, Axis);
152
153 #endif /* GROB_HH */