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