]> git.donarmstrong.com Git - lilypond.git/blob - lily/atom.cc
release: 1.3.25
[lilypond.git] / lily / atom.cc
1 /*
2   atom.cc -- implement Atom
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 #include <math.h>
10 #include "ly-smobs.icc"
11
12 #include "atom.hh"
13 #include "interval.hh"
14 #include "string.hh"
15 #include "array.hh"
16 #include "debug.hh"
17 #include "dimensions.hh"
18 #include "lookup.hh"
19 #include "main.hh"
20 #include "global-ctor.hh"
21 #include "font-metric.hh"
22
23 Atom::Atom(SCM s)
24 {
25   SCM onstack = s;              // protection. just to be sure.
26   func_ = s;
27   self_scm_ = SCM_EOL;
28   smobify_self ();
29 }
30
31 SCM
32 Atom::mark_smob (SCM s)
33 {
34   Atom*  a = SMOB_TO_TYPE(Atom, s);
35   assert (s == a->self_scm_);
36   return a->func_;
37 }
38
39 void
40 Atom::fontify (Font_metric * met)
41 {
42   SCM desc = ly_quote_scm (met->description ());
43   SCM font_switch = gh_list (ly_symbol2scm ("select-font"),
44                              desc,
45                              SCM_UNDEFINED);
46
47   SCM f =func_;
48   func_ = gh_list (ly_symbol2scm ("string-append"),
49                    font_switch , f,
50                    SCM_UNDEFINED);
51 }
52
53 void
54 Atom::do_smobify_self ()
55 {
56 }
57
58 Atom::Atom (Atom const &s)
59 {
60   off_ = s.off_;
61   func_ = s.func_;
62   self_scm_= SCM_EOL;
63   smobify_self ();
64 }
65 int
66 Atom::print_smob (SCM s, SCM p, scm_print_state*)
67 {
68   Atom * a = unsmob_atom (s);
69
70   scm_puts ("#<Atom off ",p);
71   String str(a->off_.str ());
72   scm_puts ((char *)str.ch_C(), p);
73   scm_display (a->func_, p);
74   scm_puts ("> ",p);  
75   return 1;
76 }
77   
78 IMPLEMENT_UNSMOB(Atom, atom)
79 IMPLEMENT_SMOBS(Atom)
80