2 hyphen-engraver.cc -- implement Hyphen_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2004 Glen Prideaux <glenprideaux@iname.com>,
7 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
8 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "engraver.hh"
16 class Hyphen_engraver : public Engraver
20 Spanner *finished_hyphen_;
22 TRANSLATOR_DECLARATIONS (Hyphen_engraver);
25 virtual void acknowledge_grob (Grob_info);
26 virtual void finalize ();
27 virtual bool try_music (Music*);
28 virtual void stop_translation_timestep ();
29 virtual void process_music ();
37 Hyphen_engraver::Hyphen_engraver ()
45 Hyphen_engraver::acknowledge_grob (Grob_info i)
47 Item * item = dynamic_cast<Item*> (i.grob_);
49 if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
52 hyphen_->set_bound (LEFT, item);
55 finished_hyphen_->set_bound (RIGHT, item);
61 Hyphen_engraver::try_music (Music* r)
71 completize_hyphen (Spanner* sp)
73 if (!sp->get_bound (RIGHT))
75 SCM heads = sp->get_property ("heads");
76 if (scm_is_pair (heads))
78 Item* it = dynamic_cast<Item*> (unsmob_grob (scm_car (heads)));
80 sp->set_bound (RIGHT, it);
88 Hyphen_engraver::finalize ()
92 completize_hyphen (hyphen_);
94 if (!hyphen_->get_bound (RIGHT))
96 hyphen_->warning (_ ("removing unterminated hyphen"));
103 if (finished_hyphen_)
105 completize_hyphen (finished_hyphen_);
107 if (!finished_hyphen_->get_bound (RIGHT))
109 finished_hyphen_->warning (_("unterminated hyphen; removing"));
110 finished_hyphen_->suicide ();
112 finished_hyphen_ = 0;
117 Hyphen_engraver::process_music ()
121 hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ()
128 Hyphen_engraver::stop_translation_timestep ()
130 if (finished_hyphen_ && finished_hyphen_->get_bound (RIGHT))
132 finished_hyphen_ = 0;
135 if (finished_hyphen_ && hyphen_)
137 programming_error ("Haven't finished hyphen yet.");
138 finished_hyphen_ = 0;
142 finished_hyphen_ = hyphen_;
151 ENTER_DESCRIPTION (Hyphen_engraver,
152 /* descr */ "Create lyric hyphens",
153 /* creats*/ "LyricHyphen",
154 /* accepts */ "hyphen-event",
155 /* acks */ "lyric-syllable-interface",