]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond into new...
[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--2007 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
17 class Grob
18 {
19 private:
20   DECLARE_SMOBS (Grob);
21   DECLARE_CLASSNAME(Grob);
22   
23   void init ();
24
25 protected:
26   /* data */
27   Dimension_cache dim_cache_[NO_AXES];
28   Output_def *layout_;
29   Grob *original_;
30
31   /* SCM data */
32   SCM immutable_property_alist_;
33   SCM mutable_property_alist_;
34   SCM object_alist_;
35   
36   /*
37     If this is a property, it accounts for 25% of the property
38     lookups.
39   */
40   SCM interfaces_;
41   
42   void substitute_object_links (SCM, SCM);
43   Real get_offset (Axis a) const;
44   SCM try_callback (SCM, SCM);
45   SCM try_callback_on_alist (SCM *, SCM, SCM);
46   void internal_set_value_on_alist (SCM *alist, SCM sym, SCM val);
47
48 public:
49   
50   /* friends */
51   friend class Spanner;
52   friend class System;
53   friend SCM ly_grob_properties (SCM);
54   friend SCM ly_grob_basic_properties (SCM);
55
56   /* standard callbacks */
57   DECLARE_SCHEME_CALLBACK(x_parent_positioning, (SCM));
58   DECLARE_SCHEME_CALLBACK(y_parent_positioning, (SCM));
59   DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
60   DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
61
62   /* R/O access */
63   Output_def *layout () const { return layout_; }
64   Grob *original () const { return original_; }
65   SCM interfaces () const { return interfaces_; }
66
67   /* life & death */ 
68   Grob (SCM basic_props);
69   Grob (Grob const &);
70   virtual Grob *clone () 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   void internal_set_property (SCM sym, SCM val);
87
88   /* messages */  
89   void warning (string) const;
90   void programming_error (string) const;
91
92
93   /* class hierarchy */
94   virtual System *get_system () const;
95   virtual void do_break_processing ();
96   virtual Grob *find_broken_piece (System *) const;
97   virtual void discretionary_processing ();
98   virtual void derived_mark () const;
99   virtual void handle_broken_dependencies ();
100   virtual void handle_prebroken_dependencies ();
101
102   /* printing */
103   Stencil *get_stencil () const;
104   Stencil get_print_stencil () const;
105
106   /* interfaces */
107   bool internal_has_interface (SCM intf);
108   DECLARE_GROB_INTERFACE();
109
110   /* offsets */
111   void translate_axis (Real, Axis);
112   Real relative_coordinate (Grob const *refp, Axis) const;
113   Real pure_relative_y_coordinate (Grob const *refp, int start, int end);
114   Real maybe_pure_coordinate (Grob const *refp, Axis a, bool pure, int start, int end);
115
116   /* extents */
117   Interval extent (Grob *refpoint, Axis) const;
118   void flush_extent_cache (Axis);
119   Interval pure_height (Grob *refpoint, int start_col, int end_col);
120   Interval maybe_pure_extent (Grob *refpoint, Axis, bool pure, int start, int end);
121
122   /* refpoints */
123   Grob *common_refpoint (Grob const *s, Axis a) const;
124   void set_parent (Grob *e, Axis);
125   Grob *get_parent (Axis a) const;
126   void fixup_refpoint ();
127
128   virtual Interval_t<int> spanned_rank_iv () const;
129 };
130
131 /* smob utilities */
132 DECLARE_UNSMOB (Grob, grob);
133 Spanner *unsmob_spanner (SCM);
134 Item *unsmob_item (SCM);
135
136 /* refpoints */
137 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
138 Grob *common_refpoint_of_array (vector<Grob*> const &, Grob *, Axis a);
139 System *get_root_system (Grob *me);
140
141 /* extents */ 
142 Interval robust_relative_extent (Grob *, Grob *, Axis);
143
144 /* offset/extent callbacks. */
145 void add_offset_callback (Grob *g, SCM proc, Axis a);
146 void chain_offset_callback (Grob *g, SCM proc, Axis a);
147 SCM axis_offset_symbol (Axis a);
148 SCM axis_parent_positioning (Axis a);
149
150 SCM call_pure_function (SCM unpure, SCM args, int start, int end);
151
152 #endif /* GROB_HH */