]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-line.cc
(find_create_context): assign to lvalue.
[lilypond.git] / lily / paper-line.cc
1 /*
2   paper-line.cc -- implement Paper_line
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "paper-line.hh"
10 #include "ly-smobs.icc"
11 #include "string.hh" // to_string
12
13 #define TITLE_PENALTY -1
14
15 Paper_line::Paper_line (Offset o, SCM stencils, int penalty, bool is_title)
16 {
17   dim_ = o;
18   stencils_ = stencils;
19   is_title_ = is_title;
20   penalty_ = penalty;
21   smobify_self ();
22 }
23
24 Paper_line::~Paper_line ()
25 {
26 }
27
28 IMPLEMENT_SMOBS (Paper_line);
29 IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?");
30 IMPLEMENT_DEFAULT_EQUAL_P (Paper_line);
31
32 SCM
33 Paper_line::mark_smob (SCM s)
34 {
35   Paper_line *line = (Paper_line*) ly_cdr (s);
36   return line->stencils_;
37 }
38
39 int
40 Paper_line::print_smob (SCM s, SCM port, scm_print_state*)
41 {
42   scm_puts ("#<Paper_line ", port);
43   Paper_line *line = (Paper_line*) ly_cdr (s);
44   scm_puts (to_string (line->number_).to_str0 (), port);
45   if (line->is_title ())
46     scm_puts (" t", port);
47   scm_puts (" >", port);
48   return 1;
49 }
50
51 Offset
52 Paper_line::dim () const
53 {
54   return dim_;
55 }
56
57 bool
58 Paper_line::is_title () const
59 {
60   return is_title_;
61 }
62
63 int
64 Paper_line::penalty () const
65 {
66   return penalty_;
67 }
68
69 SCM
70 Paper_line::stencils () const
71 {
72   return stencils_;
73 }
74
75 LY_DEFINE (ly_paper_line_height, "ly:paper-line-height",
76            1, 0, 0, (SCM line),
77            "Return the height of @var{line}.")
78 {
79   Paper_line *pl = unsmob_paper_line (line);
80   SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
81   return scm_make_real (pl->dim ()[Y_AXIS]);
82 }
83
84 LY_DEFINE (ly_paper_line_number, "ly:paper-line-number",
85            1, 0, 0, (SCM line),
86            "Return the number of @var{line}.")
87 {
88   Paper_line *pl = unsmob_paper_line (line);
89   SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
90   return scm_int2num (pl->number_);
91 }
92
93 LY_DEFINE (ly_paper_line_break_score, "ly:paper-line-break-score",
94            1, 0, 0, (SCM line),
95            "Return the score for page break after @var{line}.")
96 {
97   Paper_line *pl = unsmob_paper_line (line);
98   SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
99   return scm_int2num (int (pl->penalty ()));
100 }