]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef-item.cc
release: 1.3.107
[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--2000 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 = dynamic_cast<Item*> (unsmob_element (smob));
24
25   SCM style_sym =s->get_elt_property ("style");
26   String style;
27   if (gh_string_p (style_sym))
28     style = ly_scm2string (style_sym);
29
30   SCM glyph = s->get_elt_property ("glyph");
31   
32   if (gh_string_p (glyph))
33     {
34       String str = ly_scm2string (glyph);
35
36       if (to_boolean (s->get_elt_property ("non-default")) &&
37           s->break_status_dir() != RIGHT &&
38           to_boolean (s->get_elt_property ("full-size-change")))
39         {
40           str += "_change";
41           s->set_elt_property ("glyph", ly_str02scm (str.ch_C()));        
42         }
43     }
44   else
45     {
46       s->suicide ();
47       return SCM_UNSPECIFIED;
48     }
49
50   return SCM_UNSPECIFIED;
51 }
52
53 bool
54 Clef::has_interface (Score_element* me)
55 {
56   return me->has_interface (ly_symbol2scm ("clef-interface"));
57 }
58
59
60 void
61 Clef::set_interface (Score_element* me)
62 {
63   me->set_interface (ly_symbol2scm ("clef-interface"));
64 }
65
66 MAKE_SCHEME_CALLBACK(Clef,brew_molecule,1)
67 SCM
68 Clef::brew_molecule (SCM smob) 
69 {
70   Score_element * sc = unsmob_element (smob);
71   SCM glyph = sc->get_elt_property ("glyph");
72   if (gh_string_p (glyph))
73     {
74       return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).smobbed_copy ();
75     }
76   else
77     {
78       return SCM_EOL;
79     }
80 }