2 paper-system.cc -- implement Paper_system
4 source file of the GNU LilyPond music typesetter
6 (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "paper-system.hh"
11 #include "virtual-methods.hh"
13 #include "ly-smobs.icc"
15 IMPLEMENT_SMOBS (Paper_system);
16 IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
17 IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
21 Paper_system::Paper_system (Stencil s, bool is_title)
28 staff_refpoints_ = Interval(0,0);
31 Paper_system::~Paper_system ()
36 Paper_system::mark_smob (SCM smob)
38 Paper_system *system = (Paper_system*) SCM_CELL_WORD_1 (smob);
39 return system-> stencil_.expr ();
43 Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
45 Paper_system *p = (Paper_system*) SCM_CELL_WORD_1 (smob);
46 scm_puts ("#<", port);
47 scm_puts (classname (p), port);
49 scm_puts (to_string (p->number_).to_str0 (), port);
50 scm_puts ("p ", port);
51 scm_puts (to_string (p->penalty_).to_str0 (), port);
53 scm_puts (" t", port);
54 scm_puts (" >", port);
59 Paper_system::is_title () const
65 Paper_system::penalty () const
71 Paper_system::to_stencil () const
76 LY_DEFINE (ly_paper_system_height, "ly:paper-system-extent",
77 2, 0, 0, (SCM system, SCM axis),
78 "Return the extent of @var{system}.")
80 Paper_system *ps = unsmob_paper_system (system);
81 SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
82 SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
83 Axis ax = (Axis)scm_to_int (axis);
84 return ly_interval2scm (ps->to_stencil().extent (ax));
89 LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?",
90 1, 0, 0, (SCM system),
91 "Is @var{system} a title system?")
93 Paper_system *ps = unsmob_paper_system (system);
94 SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
95 return SCM_BOOL (ps->is_title ());
98 LY_DEFINE (ly_paper_system_number, "ly:paper-system-number",
99 1, 0, 0, (SCM system),
100 "Return the number of @var{system}.")
102 Paper_system *ps = unsmob_paper_system (system);
103 SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
104 return scm_int2num (ps->number_);
107 LY_DEFINE (ly_paper_system_break_score, "ly:paper-system-break-penalty",
108 1, 0, 0, (SCM system),
109 "Return the score for page break after @var{system}.")
111 Paper_system *ps = unsmob_paper_system (system);
112 SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
113 return scm_int2num (int (ps->penalty ()));
116 LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil",
117 1, 0, 0, (SCM system),
118 "Return the height of @var{system}.")
120 Paper_system *ps = unsmob_paper_system (system);
121 SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
122 return ps->to_stencil ().smobbed_copy ();
127 LY_DEFINE (ly_paper_system_staff_extent, "ly:paper-system-staff-extents",
128 1, 0, 0, (SCM system),
129 "Return the top and bottom staff refpoint.")
131 Paper_system *ps = unsmob_paper_system (system);
132 SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
133 return ly_interval2scm (ps->staff_refpoints_);