]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
* lily/grob.cc: remove X-extent-callback / Y-extent-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   
31   /*
32     If this is a property, it accounts for 25% of the property
33     lookups.
34   */
35   SCM interfaces_;
36
37   /* BARF */
38   friend class Spanner;
39   friend SCM ly_grob_properties (SCM);
40   friend SCM ly_grob_basic_properties (SCM);
41   friend void check_interfaces_for_property (Grob const *, SCM);
42   void substitute_object_links (SCM, SCM);
43
44   DECLARE_CLASSNAME(Grob);
45 public:
46   DECLARE_SCHEME_CALLBACK(same_axis_parent_positioning, (SCM, SCM));
47   DECLARE_SCHEME_CALLBACK(other_axis_parent_positioning, (SCM, SCM));
48
49   Object_key const *get_key () const;
50
51   Grob *original_;
52
53   /* TODO: junk this member. */
54   Paper_score *pscore_;
55
56   Dimension_cache dim_cache_[NO_AXES];
57
58   Grob (SCM basic_props, Object_key const *);
59   Grob (Grob const &, int copy_count);
60
61   virtual Grob *clone (int count) const;
62   static SCM stencil_extent (Grob*, Axis);
63   DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
64   DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
65     
66   
67   String name () const;
68   /*
69     Properties
70   */
71   SCM internal_get_property (SCM symbol) const;
72   SCM get_property_data (SCM symbol) const;
73   SCM internal_get_object (SCM symbol) const;
74
75   void del_property (SCM symbol); 
76   void internal_set_property (SCM sym, SCM val);
77   void internal_set_object (SCM sym, SCM val);
78
79   SCM try_callback (SCM, SCM);
80   /*
81     JUNKME.
82   */
83   void add_to_list_property (SCM, SCM);
84   void add_to_object_list (SCM sym, SCM thing);
85
86   SCM get_property_alist_chain (SCM) const;
87   static SCM ly_grob_set_property (SCM, SCM, SCM);
88   static SCM ly_grob_property (SCM, SCM);
89
90   void warning (String) const;
91   void programming_error (String) const;
92
93   Output_def *get_layout () const;
94   void add_dependency (Grob *);
95   virtual System *get_system () const;
96
97   void calculate_dependencies (int final, int busy, SCM funcname);
98
99   virtual void do_break_processing ();
100   virtual Grob *find_broken_piece (System *) const;
101   virtual void discretionary_processing ();
102   virtual void derived_mark () const;
103
104   Stencil *get_stencil () const;
105   Stencil get_print_stencil () const;
106
107   void suicide ();
108   bool is_live () const;
109
110   bool internal_has_interface (SCM intf);
111   static bool has_interface (Grob *me);
112   SCM get_interfaces () const;
113   
114   virtual void handle_broken_dependencies ();
115   virtual void handle_prebroken_dependencies ();
116
117   Interval extent (Grob *refpoint, Axis) const;
118
119   void translate_axis (Real, Axis);
120   Real relative_coordinate (Grob const *refp, Axis) const;
121   Grob *common_refpoint (Grob const *s, Axis a) const;
122
123   // duh. slim down interface here. (todo)
124   bool has_offset_callback (SCM callback, Axis) const;
125   void add_offset_callback (SCM callback, Axis);
126   void flush_extent_cache (Axis);
127   Real get_offset (Axis a) const;
128
129   void set_parent (Grob *e, Axis);
130
131   // URG
132   Grob *get_parent (Axis a) const;
133   void fixup_refpoint ();
134 };
135
136 DECLARE_UNSMOB (Grob, grob);
137 Spanner *unsmob_spanner (SCM);
138 Item *unsmob_item (SCM);
139
140 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
141 Grob *common_refpoint_of_array (Link_array<Grob> const &, Grob *, Axis a);
142
143 void set_break_subsititution (SCM criterion);
144 SCM substitute_object_alist (SCM alist, SCM dest);
145
146 Link_array<Grob> ly_scm2grobs (SCM ell);
147 SCM ly_grobs2scm (Link_array<Grob> a);
148
149 Interval robust_relative_extent (Grob *, Grob *, Axis);
150
151 #endif /* GROB_HH */