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"
12 #include "virtual-methods.hh"
14 #include "ly-smobs.icc"
16 IMPLEMENT_SMOBS (Paper_system);
17 IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
18 IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
22 Paper_system::Paper_system (Stencil s, bool is_title)
31 Paper_system::~Paper_system ()
36 Paper_system::mark_smob (SCM smob)
38 Paper_system *line = (Paper_system*) ly_cdr (smob);
39 return line-> stencil_.expr ();
43 Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
45 Paper_system *p = (Paper_system*) ly_cdr (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::dim () const
73 return Offset (stencil_.extent (X_AXIS).length (),
74 stencil_.extent (Y_AXIS).length ());
78 Paper_system::to_stencil () const
83 LY_DEFINE (ly_paper_line_height, "ly:paper-system-extent",
84 2, 0, 0, (SCM line, SCM axis),
85 "Return the extent of @var{line}.")
87 Paper_system *pl = unsmob_paper_line (line);
88 SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
89 SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
90 Axis ax = (Axis)ly_scm2int (axis);
91 return scm_make_real (pl->dim ()[ax]);
96 LY_DEFINE (ly_paper_line_title_p, "ly:paper-system-title?",
98 "Is @var{line} a title line?")
100 Paper_system *pl = unsmob_paper_line (line);
101 SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
102 return SCM_BOOL (pl->is_title ());
105 LY_DEFINE (ly_paper_line_number, "ly:paper-system-number",
107 "Return the number of @var{line}.")
109 Paper_system *pl = unsmob_paper_line (line);
110 SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
111 return scm_int2num (pl->number_);
114 LY_DEFINE (ly_paper_line_break_score, "ly:paper-system-break-penalty",
116 "Return the score for page break after @var{line}.")
118 Paper_system *pl = unsmob_paper_line (line);
119 SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
120 return scm_int2num (int (pl->penalty ()));
123 LY_DEFINE (ly_paper_line_stencil, "ly:paper-system-stencil",
125 "Return the height of @var{line}.")
127 Paper_system *pl = unsmob_paper_line (line);
128 SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
129 return pl->to_stencil ().smobbed_copy ();