]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
add 2007 to (c) year.
[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 #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   SCM try_callback_on_alist (SCM *, SCM, SCM);
48   void internal_set_value_on_alist (SCM *alist, SCM sym, SCM val);
49
50 public:
51   
52   /* friends */
53   friend class Spanner;
54   friend class System;
55   friend SCM ly_grob_properties (SCM);
56   friend SCM ly_grob_basic_properties (SCM);
57
58   /* standard callbacks */
59   DECLARE_SCHEME_CALLBACK(x_parent_positioning, (SCM));
60   DECLARE_SCHEME_CALLBACK(y_parent_positioning, (SCM));
61   DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
62   DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
63
64   /* R/O access */
65   Output_def *layout () const { return layout_; }
66   Grob *original () const { return original_; }
67   SCM interfaces () const { return interfaces_; }
68   Object_key const *key () const { return key_; }
69
70   /* life & death */ 
71   Grob (SCM basic_props, Object_key const *);
72   Grob (Grob const &, int copy_count);
73   virtual Grob *clone (int count) const;
74
75   /* forced death */
76   void suicide ();
77   bool is_live () const;
78
79   /* naming. */
80   string name () const;
81
82   /* Properties */
83   SCM get_property_alist_chain (SCM) const;
84   SCM internal_get_property (SCM symbol) const;
85   SCM internal_get_property_data (SCM symbol) const;
86   SCM internal_get_object (SCM symbol) const;
87   void internal_set_object (SCM sym, SCM val);
88   void internal_del_property (SCM symbol);
89
90 #ifndef NDEBUG
91   void internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun);
92 #else
93   void internal_set_property (SCM sym, SCM val);
94 #endif
95
96   /* messages */  
97   void warning (string) const;
98   void programming_error (string) const;
99
100
101   /* class hierarchy */
102   virtual System *get_system () const;
103   virtual void do_break_processing ();
104   virtual Grob *find_broken_piece (System *) const;
105   virtual void discretionary_processing ();
106   virtual void derived_mark () const;
107   virtual void handle_broken_dependencies ();
108   virtual void handle_prebroken_dependencies ();
109
110   /* printing */
111   Stencil *get_stencil () const;
112   Stencil get_print_stencil () const;
113
114   /* interfaces */
115   bool internal_has_interface (SCM intf);
116   DECLARE_GROB_INTERFACE();
117
118   /* offsets */
119   void translate_axis (Real, Axis);
120   Real relative_coordinate (Grob const *refp, Axis) const;
121   Real pure_relative_y_coordinate (Grob const *refp, int start, int end);
122   Real maybe_pure_coordinate (Grob const *refp, Axis a, bool pure, int start, int end);
123
124   /* extents */
125   Interval extent (Grob *refpoint, Axis) const;
126   void flush_extent_cache (Axis);
127   Interval pure_height (Grob *refpoint, int start_col, int end_col);
128   Interval maybe_pure_extent (Grob *refpoint, Axis, bool pure, int start, int end);
129
130   /* refpoints */
131   Grob *common_refpoint (Grob const *s, Axis a) const;
132   void set_parent (Grob *e, Axis);
133   Grob *get_parent (Axis a) const;
134   void fixup_refpoint ();
135
136   virtual Interval_t<int> spanned_rank_iv ();
137 };
138
139 /* smob utilities */
140 DECLARE_UNSMOB (Grob, grob);
141 Spanner *unsmob_spanner (SCM);
142 Item *unsmob_item (SCM);
143
144 /* refpoints */
145 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
146 Grob *common_refpoint_of_array (vector<Grob*> const &, Grob *, Axis a);
147 System *get_root_system (Grob *me);
148
149 /* extents */ 
150 Interval robust_relative_extent (Grob *, Grob *, Axis);
151
152 /* offset/extent callbacks. */
153 void add_offset_callback (Grob *g, SCM proc, Axis a);
154 void chain_offset_callback (Grob *g, SCM proc, Axis a);
155 SCM axis_offset_symbol (Axis a);
156 SCM axis_parent_positioning (Axis a);
157
158 SCM call_pure_function (SCM unpure, SCM args, int start, int end);
159
160 #endif /* GROB_HH */