lilypond-1.3.31
[lilypond.git] / lily / note-name-engraver.cc
bloba87cea19ff94e366aba658f3f023a221f8c3cbf6
1 /*
2 note-name-engraver.cc -- implement Note_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "musical-request.hh"
12 #include "text-item.hh"
14 class Note_name_engraver : public Engraver
16 public:
17 VIRTUAL_COPY_CONS(Translator);
18 Link_array<Note_req> req_l_arr_;
19 Link_array<Text_item> texts_;
20 virtual bool do_try_music (Music*m);
21 virtual void do_process_requests ();
22 virtual void do_pre_move_processing ();
25 bool
26 Note_name_engraver::do_try_music (Music *m)
28 if (Note_req *r = dynamic_cast<Note_req* > (m))
30 req_l_arr_.push (r);
31 return true;
33 return false;
37 void
38 Note_name_engraver::do_process_requests ()
40 String s ;
41 for (int i=0; i < req_l_arr_.size (); i++)
43 if (i)
44 s += " ";
45 s += req_l_arr_[i]->pitch_.str ();
47 if (s.length_i())
49 Text_item * t = new Text_item;
50 t->set_elt_property ("text", ly_str02scm ( s.ch_C()));
51 announce_element (Score_element_info (t, req_l_arr_[0]));
52 texts_.push (t);
56 void
57 Note_name_engraver::do_pre_move_processing ()
59 for (int i=0; i < texts_.size (); i++)
61 typeset_element (texts_[i]);
63 texts_.clear() ;
64 req_l_arr_.clear ();
67 ADD_THIS_TRANSLATOR(Note_name_engraver);