Svg with woff fonts: document as new feature in changes.
[lilypond/patrick.git] / lily / change-iterator.cc
blob7f298ac444aa31283f18a2194c9d6ef0428e2794
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "change-iterator.hh"
22 #include "context.hh"
23 #include "input.hh"
24 #include "international.hh"
25 #include "music.hh"
26 #include "warn.hh"
28 void
29 Change_iterator::error (string reason)
31 string to_type = ly_symbol2string (get_music ()->get_property ("change-to-type"));
32 string to_id = ly_scm2string (get_music ()->get_property ("change-to-id"));
34 string warn1 = _f ("cannot change `%s' to `%s'", to_type, to_id)
35 + ": " + reason;
38 GUHG!
40 string warn2= "Change_iterator::process (): "
41 + get_outlet ()->context_name () + " = `"
42 + get_outlet ()->id_string () + "': ";
43 warning (warn2);
44 get_music ()->origin ()->warning (warn1);
48 move to construct_children ?
50 void
51 Change_iterator::process (Moment m)
53 Context *current = get_outlet ();
54 Context *last = 0;
56 SCM to_type = get_music ()->get_property ("change-to-type");
57 string to_id = ly_scm2string (get_music ()->get_property ("change-to-id"));
59 /* find the type of translator that we're changing.
61 If \translator Staff = bass, then look for Staff = *
63 while (current && !current->is_alias (to_type))
65 last = current;
66 current = current->get_parent_context ();
69 if (current && current->id_string () == to_id)
71 string msg;
72 msg += _f ("cannot change, already in translator: %s", to_id);
75 if (current)
76 if (last)
78 Context *dest = 0;
79 Context *where = get_outlet ();
80 while (!dest && where)
82 dest = find_context_below (where, to_type, to_id);
83 where = where->get_parent_context ();
86 if (dest)
88 send_stream_event (last, "ChangeParent", get_music ()->origin (),
89 ly_symbol2scm ("context"), dest->self_scm ());
91 else
92 /* FIXME: constant error message. */
93 get_music ()->origin ()->warning (_ ("cannot find context to switch to"));
95 else
97 /* We could change the current translator's id, but that would make
98 errors hard to catch.
100 last->translator_id_string () = get_change
101 ()->change_to_id_string (); */
102 error (_f ("not changing to same context type: %s", ly_symbol2string (to_type).c_str ()));
104 else
105 /* FIXME: uncomprehensable message */
106 error (_ ("none of these in my family"));
108 Simple_music_iterator::process (m);
111 IMPLEMENT_CTOR_CALLBACK (Change_iterator);