]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-system.cc
* lily/include/paper-system.hh (class Paper_system): remove
[lilypond.git] / lily / paper-system.cc
1 /*
2   paper-system.cc -- implement Paper_system
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "paper-system.hh"
10 #include "item.hh"
11
12 #include "ly-smobs.icc"
13
14 IMPLEMENT_SMOBS (Paper_system);
15 IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
16 IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
17
18 Paper_system::Paper_system (Stencil s, SCM immutable_init)
19 {
20   mutable_property_alist_ = SCM_EOL;
21   immutable_property_alist_ = immutable_init;
22   smobify_self ();
23   stencil_ = s;
24   staff_refpoints_ = Interval (0, 0);
25   init_vars ();
26 }
27
28
29 Paper_system::~Paper_system ()
30 {
31 }
32
33 SCM
34 Paper_system::mark_smob (SCM smob)
35 {
36   Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob);
37   scm_gc_mark (system->mutable_property_alist_);
38   return system->stencil_.expr ();
39 }
40
41 int
42 Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
43 {
44   Paper_system *p = (Paper_system *) SCM_CELL_WORD_1 (smob);
45   scm_puts ("#<", port);
46   scm_puts (classname (p), port);
47   scm_display (p->mutable_property_alist_, port);
48   
49   scm_puts (" >", port);
50   return 1;
51 }
52
53
54 Stencil
55 Paper_system::to_stencil () const
56 {
57   return stencil_;
58 }
59
60 void
61 Paper_system::init_vars ()
62 {
63   SCM yext = get_property ("Y-extent");
64   SCM staff_ext = get_property ("refpoint-Y-extent");
65
66   if (scm_is_pair (yext)
67       && is_number_pair (scm_cdr (yext)))
68     {
69       Box b = stencil_.extent_box();
70       b[Y_AXIS] = ly_scm2interval (scm_cdr (yext));
71       
72       stencil_ = Stencil (b, stencil_.expr ());
73     }
74
75   if (scm_is_pair (staff_ext)
76       && is_number_pair (scm_cdr (staff_ext)))
77     {
78       staff_refpoints_ = ly_scm2interval (scm_cdr (staff_ext));
79     }
80 }
81
82 SCM
83 Paper_system::internal_get_property (SCM sym) const
84 {
85   /*
86     TODO: type checking
87    */
88   SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
89   if (s != SCM_BOOL_F)
90     return scm_cdr (s);
91
92   s = scm_sloppy_assq (sym, immutable_property_alist_);
93
94      
95   return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
96 }
97
98 void
99 Paper_system::internal_set_property (SCM sym, SCM val) 
100 {
101   mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, val);
102 }
103
104 /*
105   todo: move to Paper_system property.
106  */
107 Interval
108 Paper_system::staff_refpoints () const
109 {
110   return staff_refpoints_;
111 }