]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
(class Grob): move pscore, dim_cache_,
[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   void substitute_object_links (SCM, SCM);
42
43   DECLARE_CLASSNAME(Grob);
44   Real get_offset (Axis a) const;
45
46   Output_def *layout_;
47   Dimension_cache dim_cache_[NO_AXES];
48   Grob *original_;
49
50   SCM try_callback (SCM, SCM);
51 public:
52   DECLARE_SCHEME_CALLBACK(x_parent_positioning, (SCM));
53   DECLARE_SCHEME_CALLBACK(y_parent_positioning, (SCM));
54   DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
55   DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
56
57   /* R/O access */
58   Output_def *layout () const { return layout_; }
59   Grob *original () const { return original_; }
60   SCM interfaces () const { return interfaces_; }
61   Object_key const *key () const { return key_; }
62
63   /* life & death */ 
64   Grob (SCM basic_props, Object_key const *);
65   Grob (Grob const &, int copy_count);
66   virtual Grob *clone (int count) const;
67
68   /* forced death */
69   void suicide ();
70   bool is_live () const;
71
72   /* naming. */
73   String name () const;
74
75   /* Properties */
76   SCM get_property_alist_chain (SCM) const;
77   SCM internal_get_property (SCM symbol) const;
78   SCM get_property_data (SCM symbol) const;
79   SCM internal_get_object (SCM symbol) const;
80   void del_property (SCM symbol); 
81   void internal_set_property (SCM sym, SCM val);
82   void internal_set_object (SCM sym, SCM val);
83
84   /* messages */  
85   void warning (String) const;
86   void programming_error (String) const;
87
88
89   /* class hierarchy */
90   virtual System *get_system () const;
91   virtual void do_break_processing ();
92   virtual Grob *find_broken_piece (System *) const;
93   virtual void discretionary_processing ();
94   virtual void derived_mark () const;
95   virtual void handle_broken_dependencies ();
96   virtual void handle_prebroken_dependencies ();
97
98   /* printing */
99   Stencil *get_stencil () const;
100   Stencil get_print_stencil () const;
101
102   /* interfaces */
103   bool internal_has_interface (SCM intf);
104   static bool has_interface (Grob *me);
105
106   /* offsets */
107   void translate_axis (Real, Axis);
108   Real relative_coordinate (Grob const *refp, Axis) const;
109
110   /* extents */
111   Interval extent (Grob *refpoint, Axis) const;
112   void flush_extent_cache (Axis);
113
114   /* refpoints */
115   Grob *common_refpoint (Grob const *s, Axis a) const;
116   void set_parent (Grob *e, Axis);
117   Grob *get_parent (Axis a) const;
118   void fixup_refpoint ();
119 };
120
121 DECLARE_UNSMOB (Grob, grob);
122 Spanner *unsmob_spanner (SCM);
123 Item *unsmob_item (SCM);
124
125 /* refpoints */
126 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
127 Grob *common_refpoint_of_array (Link_array<Grob> const &, Grob *, Axis a);
128 System *get_root_system (Grob *me);
129
130 /* extents */ 
131 Interval robust_relative_extent (Grob *, Grob *, Axis);
132
133 /* offset/extent callbacks. */
134 void add_offset_callback (Grob *g, SCM proc, Axis a);
135 void chain_offset_callback (Grob *g, SCM proc, Axis a);
136 SCM axis_offset_symbol (Axis a);
137 SCM axis_parent_positioning (Axis a);
138
139
140 #endif /* GROB_HH */