]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-info.cc
23ff736d9536c0ab62a7b40c1a5023662052dddf
[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--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "context.hh"
10 #include "grob-info.hh"
11 #include "grob.hh"
12 #include "item.hh"
13 #include "music.hh"
14 #include "spanner.hh"
15 #include "stream-event.hh"
16 #include "translator-group.hh"
17
18 Grob_info::Grob_info (Translator *t, Grob *g)
19 {
20   origin_trans_ = t;
21   grob_ = g;
22   start_end_ = START;
23 }
24
25 Grob_info::Grob_info ()
26 {
27   grob_ = 0;
28   start_end_ = START;
29   origin_trans_ = 0;
30 }
31
32 Stream_event *
33 Grob_info::event_cause () const
34 {
35   SCM cause = grob_->get_property ("cause");
36   return unsmob_stream_event (cause);
37 }
38
39 vector<Context*>
40 Grob_info::origin_contexts (Translator *end) const
41 {
42   Context *t = origin_trans_->context ();
43   vector<Context*> r;
44   do
45     {
46       r.push_back (t);
47       t = t->get_parent_context ();
48     }
49   while (t && t != end->context ());
50
51   return r;
52 }
53
54 Context *
55 Grob_info::context () const
56 {
57   return origin_trans_->context ();
58 }
59
60 Spanner *
61 Grob_info::spanner () const
62 {
63   return dynamic_cast<Spanner *> (grob_);
64 }
65
66 Item *
67 Grob_info::item () const
68 {
69   return dynamic_cast<Item *> (grob_);
70 }
71
72 Stream_event *
73 Grob_info::ultimate_event_cause () const
74 {
75   SCM cause = grob_->self_scm ();
76   while (unsmob_grob (cause))
77     {
78       cause = unsmob_grob (cause)->get_property ("cause");
79     }
80   return unsmob_stream_event (cause);
81 }