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