2 paper-system.cc -- implement Paper_system
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "paper-system.hh"
12 #include "ly-smobs.icc"
14 IMPLEMENT_SMOBS (Paper_system);
15 IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
16 IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
18 Paper_system::Paper_system (Stencil s, SCM immutable_init)
20 mutable_property_alist_ = SCM_EOL;
21 immutable_property_alist_ = immutable_init;
24 staff_refpoints_ = Interval (0, 0);
29 Paper_system::~Paper_system ()
34 Paper_system::mark_smob (SCM smob)
36 Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob);
37 scm_gc_mark (system->mutable_property_alist_);
38 return system->stencil_.expr ();
42 Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
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);
49 scm_puts (" >", port);
55 Paper_system::to_stencil () const
61 Paper_system::init_vars ()
63 SCM yext = get_property ("Y-extent");
64 SCM staff_ext = get_property ("refpoint-Y-extent");
66 if (scm_is_pair (yext)
67 && is_number_pair (scm_cdr (yext)))
69 Box b = stencil_.extent_box();
70 b[Y_AXIS] = ly_scm2interval (scm_cdr (yext));
72 stencil_ = Stencil (b, stencil_.expr ());
75 if (scm_is_pair (staff_ext)
76 && is_number_pair (scm_cdr (staff_ext)))
78 staff_refpoints_ = ly_scm2interval (scm_cdr (staff_ext));
83 Paper_system::internal_get_property (SCM sym) const
88 SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
92 s = scm_sloppy_assq (sym, immutable_property_alist_);
95 return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
99 Paper_system::internal_set_property (SCM sym, SCM val)
101 mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, val);
105 todo: move to Paper_system property.
108 Paper_system::staff_refpoints () const
110 return staff_refpoints_;