]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
Merge with git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond.git
[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--2006 Han-Wen Nienhuys
7 */
8
9 #ifndef GROB_HH
10 #define GROB_HH
11
12 #include "box.hh"
13 #include "virtual-methods.hh"
14 #include "dimension-cache.hh"
15 #include "grob-interface.hh"
16 #include "object-key.hh"
17
18 class Grob
19 {
20 private:
21   DECLARE_SMOBS (Grob);
22   DECLARE_CLASSNAME(Grob);
23   
24   void init ();
25
26 protected:
27   /* data */
28   Dimension_cache dim_cache_[NO_AXES];
29   Output_def *layout_;
30   Grob *original_;
31   Object_key const *key_;
32
33   /* SCM data */
34   SCM immutable_property_alist_;
35   SCM mutable_property_alist_;
36   SCM object_alist_;
37   
38   /*
39     If this is a property, it accounts for 25% of the property
40     lookups.
41   */
42   SCM interfaces_;
43   
44   void substitute_object_links (SCM, SCM);
45   Real get_offset (Axis a) const;
46   SCM try_callback (SCM, SCM);
47 public:
48   
49   /* friends */
50   friend class Spanner;
51   friend class System;
52   friend SCM ly_grob_properties (SCM);
53   friend SCM ly_grob_basic_properties (SCM);
54
55   /* standard callbacks */
56   DECLARE_SCHEME_CALLBACK(x_parent_positioning, (SCM));
57   DECLARE_SCHEME_CALLBACK(y_parent_positioning, (SCM));
58   DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
59   DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
60
61   /* R/O access */
62   Output_def *layout () const { return layout_; }
63   Grob *original () const { return original_; }
64   SCM interfaces () const { return interfaces_; }
65   Object_key const *key () const { return key_; }
66
67   /* life & death */ 
68   Grob (SCM basic_props, Object_key const *);
69   Grob (Grob const &, int copy_count);
70   virtual Grob *clone (int count) const;
71
72   /* forced death */
73   void suicide ();
74   bool is_live () const;
75
76   /* naming. */
77   string name () const;
78
79   /* Properties */
80   SCM get_property_alist_chain (SCM) const;
81   SCM internal_get_property (SCM symbol) const;
82   SCM internal_get_property_data (SCM symbol) const;
83   SCM internal_get_object (SCM symbol) const;
84   void internal_set_object (SCM sym, SCM val);
85   void internal_del_property (SCM symbol);
86
87 #ifndef NDEBUG
88   void internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun);
89 #else
90   void internal_set_property (SCM sym, SCM val);
91 #endif
92
93   /* messages */  
94   void warning (string) const;
95   void programming_error (string) const;
96
97
98   /* class hierarchy */
99   virtual System *get_system () const;
100   virtual void do_break_processing ();
101   virtual Grob *find_broken_piece (System *) const;
102   virtual void discretionary_processing ();
103   virtual void derived_mark () const;
104   virtual void handle_broken_dependencies ();
105   virtual void handle_prebroken_dependencies ();
106
107   /* printing */
108   Stencil *get_stencil () const;
109   Stencil get_print_stencil () const;
110
111   /* interfaces */
112   bool internal_has_interface (SCM intf);
113   static bool has_interface (Grob *me);
114
115   /* offsets */
116   void translate_axis (Real, Axis);
117   Real relative_coordinate (Grob const *refp, Axis) const;
118   Real pure_relative_y_coordinate (Grob const *refp, int start, int end);
119   Real maybe_pure_coordinate (Grob const *refp, Axis a, bool pure, int start, int end);
120
121   /* extents */
122   Interval extent (Grob *refpoint, Axis) const;
123   void flush_extent_cache (Axis);
124   Interval pure_height (Grob *refpoint, int start_col, int end_col);
125   Interval maybe_pure_extent (Grob *refpoint, Axis, bool pure, int start, int end);
126
127   /* refpoints */
128   Grob *common_refpoint (Grob const *s, Axis a) const;
129   void set_parent (Grob *e, Axis);
130   Grob *get_parent (Axis a) const;
131   void fixup_refpoint ();
132
133   virtual Interval_t<int> spanned_rank_iv ();
134 };
135
136 /* smob utilities */
137 DECLARE_UNSMOB (Grob, grob);
138 Spanner *unsmob_spanner (SCM);
139 Item *unsmob_item (SCM);
140
141 /* refpoints */
142 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
143 Grob *common_refpoint_of_array (vector<Grob*> const &, Grob *, Axis a);
144 System *get_root_system (Grob *me);
145
146 /* extents */ 
147 Interval robust_relative_extent (Grob *, Grob *, Axis);
148
149 /* offset/extent callbacks. */
150 void add_offset_callback (Grob *g, SCM proc, Axis a);
151 void chain_offset_callback (Grob *g, SCM proc, Axis a);
152 SCM axis_offset_symbol (Axis a);
153 SCM axis_parent_positioning (Axis a);
154
155 SCM call_pure_function (SCM unpure, SCM args, int start, int end);
156
157 #endif /* GROB_HH */