* lily/music-iterator.cc (quit, do_quit): new function: break link
[lilypond.git] / lily / note-name-engraver.cc
blob1e7806e676b9bd05c48d773df02fd97192bf5b00
1 /*
2 note-name-engraver.cc -- implement Note_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "musical-request.hh"
12 #include "item.hh"
14 class Note_name_engraver : public Engraver
16 public:
17 TRANSLATOR_DECLARATIONS(Note_name_engraver);
19 Link_array<Note_req> reqs_;
20 Link_array<Item> texts_;
21 virtual bool try_music (Music*m);
22 virtual void process_acknowledged_grobs ();
23 virtual void stop_translation_timestep ();
26 bool
27 Note_name_engraver::try_music (Music *m)
29 if (Note_req *r = dynamic_cast<Note_req* > (m))
31 reqs_.push (r);
32 return true;
34 return false;
37 void
38 Note_name_engraver::process_acknowledged_grobs ()
40 if (texts_.size ())
41 return;
42 String s ;
43 for (int i=0; i < reqs_.size (); i++)
45 if (i)
46 s += " ";
47 s += unsmob_pitch (reqs_[i]->get_mus_property ("pitch"))->string ();
49 if (s.length ())
51 Item * t = new Item (get_property ("NoteName"));
52 t->set_grob_property ("text", scm_makfrom0str (s.to_str0 ()));
53 announce_grob(t, reqs_[0]->self_scm());
54 texts_.push (t);
58 void
59 Note_name_engraver::stop_translation_timestep ()
61 for (int i=0; i < texts_.size (); i++)
63 typeset_grob (texts_[i]);
65 texts_.clear () ;
66 reqs_.clear ();
70 Note_name_engraver::Note_name_engraver()
74 ENTER_DESCRIPTION(Note_name_engraver,
75 /* descr */ "",
76 /* creats*/ "NoteName",
77 /* acks */ "",
78 /* reads */ "",
79 /* write */ "");