]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-info.cc
* ly/engraver-init.ly (AncientRemoveEmptyStaffContext): remove
[lilypond.git] / lily / grob-info.cc
1 /*
2   grob-info.cc -- implement Grob_info
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "grob-info.hh"
10 #include "grob.hh"
11 #include "music.hh"
12 #include "translator-group.hh"
13 #include "context.hh"
14 #include "spanner.hh"
15 #include "item.hh"
16
17 Grob_info::Grob_info (Translator *t, Grob *g)
18 {
19   origin_trans_ = t;
20   grob_ = g;
21 }
22
23 Grob_info::Grob_info ()
24 {
25   grob_ = 0;
26   origin_trans_ = 0;
27 }
28
29 Music *
30 Grob_info::music_cause () const
31 {
32   SCM cause = grob_->get_property ("cause");
33   return unsmob_music (cause);
34 }
35
36 Link_array<Context>
37 Grob_info::origin_contexts (Translator *end) const
38 {
39   Context *t = origin_trans_->context ();
40   Link_array<Context> r;
41   do
42     {
43       r.push (t);
44       t = t->get_parent_context ();
45     }
46   while (t && t != end->context ());
47
48   return r;
49 }
50
51 Context *
52 Grob_info::context () const
53 {
54   return origin_trans_->context ();
55 }
56
57 Spanner *
58 Grob_info::spanner () const
59 {
60   return dynamic_cast<Spanner *> (grob_);
61 }
62
63 Item *
64 Grob_info::item () const
65 {
66   return dynamic_cast<Item *> (grob_);
67 }
68
69 Music *
70 Grob_info::ultimate_music_cause () const
71 {
72   SCM cause = grob_->self_scm ();
73   while (unsmob_grob (cause))
74     {
75       cause = unsmob_grob (cause)->get_property ("cause");
76     }
77
78   return unsmob_music (cause);
79 }
80