]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef.cc
cbae1801597b5a6350f64f5196ffb1b74d40402a
[lilypond.git] / lily / clef.cc
1
2 /*
3   clef.cc -- implement Clef_item
4
5   source file of the GNU LilyPond music typesetter
6
7   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9
10
11 #include "clef.hh"
12 #include "string.hh"
13 #include "molecule.hh"
14 #include "item.hh"
15 #include "font-interface.hh"
16
17 /*
18  FIXME: should use symbol for #'style.
19 */
20 MAKE_SCHEME_CALLBACK (Clef,before_line_breaking,1);
21 SCM
22 Clef::before_line_breaking (SCM smob)
23 {
24   Item * s = unsmob_item (smob);
25
26   SCM glyph = s->get_grob_property ("glyph-name");
27   
28   if (gh_string_p (glyph))
29     {
30       String str = ly_scm2string (glyph);
31
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")))
35         {
36           str += "_change";
37           s->set_grob_property ("glyph-name", ly_str02scm (str.ch_C ()));         
38         }
39     }
40   else
41     {
42       s->suicide ();
43       return SCM_UNSPECIFIED;
44     }
45
46   return SCM_UNSPECIFIED;
47 }
48
49 bool
50 Clef::has_interface (Grob* me)
51 {
52   return me->has_interface (ly_symbol2scm ("clef-interface"));
53 }
54
55
56 void
57 Clef::set_interface (Grob* me)
58 {
59   me->set_interface (ly_symbol2scm ("clef-interface"));
60 }
61
62 MAKE_SCHEME_CALLBACK (Clef,brew_molecule,1)
63 SCM
64 Clef::brew_molecule (SCM smob) 
65 {
66   Grob * sc = unsmob_grob (smob);
67   SCM glyph = sc->get_grob_property ("glyph-name");
68   if (gh_string_p (glyph))
69     {
70       return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).smobbed_copy ();
71     }
72   else
73     {
74       return SCM_EOL;
75     }
76 }