2 change-iterator.cc -- implement Change_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "change-iterator.hh"
10 #include "translator-group.hh"
16 Change_iterator::error (String reason
)
18 String to_type
= ly_scm2string (music_l_
->get_mus_property ("change-to-type"));
19 String to_id
= ly_scm2string (music_l_
->get_mus_property ("change-to-id"));
21 String warn1
= _f ("can't change `%s' to `%s'", to_type
, to_id
)
26 String warn2
= "Change_iterator::process (): "
27 + report_to_l ()->type_str_
+ " = `"
28 + report_to_l ()->id_str_
+ "': ";
30 music_l_
->origin ()->warning (warn1
);
34 move to construct_children ?
37 Change_iterator::process (Moment m
)
39 Translator_group
* current
= report_to_l ();
40 Translator_group
* last
= 0;
42 String to_type
= ly_scm2string (music_l_
->get_mus_property ("change-to-type"));
43 String to_id
= ly_scm2string (music_l_
->get_mus_property ("change-to-id"));
46 /* find the type of translator that we're changing.
48 If \translator Staff = bass, then look for Staff = *
50 while (current
&& current
->type_str_
!= to_type
)
53 current
= current
->daddy_trans_l_
;
56 if (current
&& current
->id_str_
== to_id
)
59 msg
+= _ ("Can't switch translators, I'm there already");
65 Translator_group
* dest
=
66 report_to_l ()->find_create_translator_l (to_type
, to_id
);
67 current
->remove_translator_p (last
);
68 dest
->add_group_translator (last
);
73 We could change the current translator's id, but that would make
76 last->translator_id_str_ = change_l ()->change_to_id_str_;
78 error (_ ("I'm one myself"));
81 error (_ ("none of these in my family"));
82 Simple_music_iterator::process (m
);
87 IMPLEMENT_CTOR_CALLBACK (Change_iterator
);