lilypond-1.5.37
[lilypond.git] / lily / clef.cc
blobcbae1801597b5a6350f64f5196ffb1b74d40402a
2 /*
3 clef.cc -- implement Clef_item
5 source file of the GNU LilyPond music typesetter
7 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
11 #include "clef.hh"
12 #include "string.hh"
13 #include "molecule.hh"
14 #include "item.hh"
15 #include "font-interface.hh"
18 FIXME: should use symbol for #'style.
20 MAKE_SCHEME_CALLBACK (Clef,before_line_breaking,1);
21 SCM
22 Clef::before_line_breaking (SCM smob)
24 Item * s = unsmob_item (smob);
26 SCM glyph = s->get_grob_property ("glyph-name");
28 if (gh_string_p (glyph))
30 String str = ly_scm2string (glyph);
32 if (to_boolean (s->get_grob_property ("non-default"))
33 && s->break_status_dir () != RIGHT
34 && !to_boolean (s->get_grob_property ("full-size-change")))
36 str += "_change";
37 s->set_grob_property ("glyph-name", ly_str02scm (str.ch_C ()));
40 else
42 s->suicide ();
43 return SCM_UNSPECIFIED;
46 return SCM_UNSPECIFIED;
49 bool
50 Clef::has_interface (Grob* me)
52 return me->has_interface (ly_symbol2scm ("clef-interface"));
56 void
57 Clef::set_interface (Grob* me)
59 me->set_interface (ly_symbol2scm ("clef-interface"));
62 MAKE_SCHEME_CALLBACK (Clef,brew_molecule,1)
63 SCM
64 Clef::brew_molecule (SCM smob)
66 Grob * sc = unsmob_grob (smob);
67 SCM glyph = sc->get_grob_property ("glyph-name");
68 if (gh_string_p (glyph))
70 return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).smobbed_copy ();
72 else
74 return SCM_EOL;