]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
Update.
[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 /**
18    for administration of what was done already
19 */
20 enum Grob_status
21   {
22     ORPHAN = 0, // not yet added to Paper_score
23     PRECALCING,
24     PRECALCED, // calcs before spacing done
25     POSTCALCING, // busy calculating. This is used to trap cyclic deps.
26     POSTCALCED, // after spacing calcs done
27   };
28
29 typedef void (Grob:: *Grob_method_pointer) (void);
30
31 // looking at gtk+/pango docstrings .. WIP
32
33 /**
34  * Grob:
35  * @internal_get_property: get property #NAME.
36  *
37  * Class structure for #Grob.
38  **/
39 class Grob
40 {
41 private:
42   DECLARE_SMOBS (Grob, foo);
43   void init ();
44 protected:
45   Object_key const *key_;
46   SCM immutable_property_alist_;
47   SCM mutable_property_alist_;
48
49   /* BARF */
50   friend class Spanner;
51   friend SCM ly_grob_properties (SCM);
52   friend SCM ly_grob_basic_properties (SCM);
53
54   void substitute_mutable_properties (SCM, SCM);
55   char status_;
56
57 public:
58   Object_key const *get_key () const;
59
60   Grob *original_;
61
62   /* TODO: junk this member. */
63   Paper_score *pscore_;
64
65   Dimension_cache dim_cache_[NO_AXES];
66
67   Grob (SCM basic_props, Object_key const *);
68   Grob (Grob const &, int copy_count);
69
70   virtual Grob *clone (int count) const;
71   DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
72
73   String name () const;
74   /*
75     Properties
76   */
77   SCM internal_get_property (SCM) const;
78   void internal_set_property (SCM, SCM val);
79   void add_to_list_property (SCM, SCM);
80
81   SCM get_property_alist_chain (SCM) const;
82   static SCM ly_grob_set_property (SCM, SCM, SCM);
83   static SCM ly_grob_property (SCM, SCM);
84
85   void warning (String) const;
86   void programming_error (String) const;
87
88   Output_def *get_layout () const;
89   void add_dependency (Grob *);
90   virtual System *get_system () const;
91
92   void calculate_dependencies (int final, int busy, SCM funcname);
93
94   virtual void do_break_processing ();
95   virtual Grob *find_broken_piece (System *) const;
96   virtual void discretionary_processing ();
97   virtual SCM do_derived_mark () const;
98
99   Stencil *get_stencil () const;
100   SCM get_uncached_stencil () const;
101
102   void suicide ();
103   bool is_live () const;
104   bool is_empty (Axis a) const;
105
106   bool internal_has_interface (SCM intf);
107   static bool has_interface (Grob *me);
108
109   virtual void handle_broken_dependencies ();
110   virtual void handle_prebroken_dependencies ();
111
112   Interval extent (Grob *refpoint, Axis) const;
113
114   void translate_axis (Real, Axis);
115   Real relative_coordinate (Grob const *refp, Axis) const;
116   Grob *common_refpoint (Grob const *s, Axis a) const;
117
118   // duh. slim down interface here. (todo)
119   bool has_offset_callback (SCM callback, Axis) const;
120   void add_offset_callback (SCM callback, Axis);
121   bool has_extent_callback (SCM, Axis) const;
122   void flush_extent_cache (Axis);
123   void set_extent (SCM, Axis);
124   void set_extent_callback (SCM, Axis);
125   Real get_offset (Axis a) const;
126
127   void set_parent (Grob *e, Axis);
128
129   // URG
130   Grob *get_parent (Axis a) const;
131   DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM));
132 };
133
134 DECLARE_UNSMOB (Grob, grob);
135 Spanner *unsmob_spanner (SCM);
136 Item *unsmob_item (SCM);
137
138 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
139 Grob *common_refpoint_of_array (Link_array<Grob> const &, Grob *, Axis a);
140
141 void set_break_subsititution (SCM criterion);
142 SCM substitute_mutable_property_alist (SCM alist);
143
144 Link_array<Grob> ly_scm2grobs (SCM ell);
145 SCM ly_grobs2scm (Link_array<Grob> a);
146
147 Interval robust_relative_extent (Grob *, Grob *, Axis);
148
149 #endif /* GROB_HH */