]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef.cc
* flower/include/std-string.hh:
[lilypond.git] / lily / clef.cc
1 /*
2   clef.cc -- implement Clef_item
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "clef.hh"
10
11 #include "font-interface.hh"
12 #include "international.hh"
13 #include "item.hh"
14 #include "std-string.hh"
15 #include "stencil.hh"
16
17 MAKE_SCHEME_CALLBACK (Clef, calc_glyph_name, 1);
18 SCM
19 Clef::calc_glyph_name (SCM smob)
20 {
21   Item *s = unsmob_item (smob);
22   SCM glyph = s->get_property ("glyph");
23
24   if (scm_is_string (glyph))
25     {
26       string str = ly_scm2string (glyph);
27
28       if (to_boolean (s->get_property ("non-default"))
29           && s->break_status_dir () != RIGHT
30           && !to_boolean (s->get_property ("full-size-change")))
31         {
32           str += "_change";
33         }
34
35       return scm_makfrom0str (str.c_str ());
36     }
37
38   s->suicide ();
39   return SCM_UNSPECIFIED;
40 }
41
42 MAKE_SCHEME_CALLBACK (Clef, print, 1)
43 SCM
44 Clef::print (SCM smob)
45 {
46   Grob *me = unsmob_grob (smob);
47   SCM glyph_scm = me->get_property ("glyph-name");
48   if (!scm_is_string (glyph_scm))
49     return SCM_EOL;
50
51   string glyph = string (ly_scm2string (glyph_scm));
52   Font_metric *fm = Font_interface::get_default_font (me);
53   Stencil out = fm->find_by_name (glyph);
54   if (out.is_empty ())
55     me->warning (_f ("clef `%s' not found", glyph.c_str ()));
56   return out.smobbed_copy ();
57 }
58
59 ADD_INTERFACE (Clef, "clef-interface",
60                "A clef sign",
61
62                /* properties */
63                "full-size-change "
64                "glyph "
65                "glyph-name "
66                "non-default "
67                );
68