2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
22 #include "output-def.hh"
24 #include "paper-book.hh"
25 #include "ly-module.hh"
27 LY_DEFINE (ly_make_book
, "ly:make-book",
28 2, 0, 1, (SCM paper
, SCM header
, SCM scores
),
29 "Make a @code{\\book} of @var{paper} and @var{header}"
30 " (which may be @code{#f} as well) containing @code{\\scores}.")
32 Output_def
*odef
= unsmob_output_def (paper
);
33 LY_ASSERT_SMOB (Output_def
, paper
, 1);
35 Book
*book
= new Book
;
38 if (ly_is_module (header
))
39 book
->header_
= header
;
41 book
->scores_
= scm_append (scm_list_2 (scores
, book
->scores_
));
43 SCM x
= book
->self_scm ();
48 LY_DEFINE (ly_make_book_part
, "ly:make-book-part",
49 1, 0, 0, (SCM scores
),
50 "Make a @code{\\bookpart} containing @code{\\scores}.")
52 Book
*book
= new Book
;
53 book
->scores_
= scm_append (scm_list_2 (scores
, book
->scores_
));
55 SCM x
= book
->self_scm ();
60 LY_DEFINE (ly_book_process
, "ly:book-process",
61 4, 0, 0, (SCM book_smob
,
65 "Print book. @var{output} is passed to the backend unchanged."
66 " For example, it may be a string (for file based outputs)"
67 " or a socket (for network based output).")
69 Book
*book
= unsmob_book (book_smob
);
71 LY_ASSERT_SMOB (Book
, book_smob
, 1);
72 LY_ASSERT_SMOB (Output_def
, default_paper
, 2);
73 LY_ASSERT_SMOB (Output_def
, default_layout
, 3);
75 Paper_book
*pb
= book
->process (unsmob_output_def (default_paper
),
76 unsmob_output_def (default_layout
));
83 return SCM_UNSPECIFIED
;
87 LY_DEFINE (ly_book_process_to_systems
, "ly:book-process-to-systems",
88 4, 0, 0, (SCM book_smob
,
92 "Print book. @var{output} is passed to the backend unchanged."
93 " For example, it may be a string (for file based outputs)"
94 " or a socket (for network based output).")
96 LY_ASSERT_SMOB (Book
, book_smob
, 1);
97 LY_ASSERT_SMOB (Output_def
, default_paper
, 2);
98 LY_ASSERT_SMOB (Output_def
, default_layout
, 3);
100 Book
*book
= unsmob_book (book_smob
);
102 Paper_book
*pb
= book
->process (unsmob_output_def (default_paper
),
103 unsmob_output_def (default_layout
));
106 pb
->classic_output (output
);
110 return SCM_UNSPECIFIED
;
113 LY_DEFINE (ly_book_add_score_x
, "ly:book-add-score!",
114 2, 0, 0, (SCM book_smob
, SCM score
),
115 "Add @var{score} to @var{book-smob} score list.")
117 LY_ASSERT_SMOB (Book
, book_smob
, 1);
118 Book
*book
= unsmob_book (book_smob
);
119 book
->add_score (score
);
120 return SCM_UNSPECIFIED
;
123 LY_DEFINE (ly_book_add_bookpart_x
, "ly:book-add-bookpart!",
124 2, 0, 0, (SCM book_smob
, SCM book_part
),
125 "Add @var{book-part} to @var{book-smob} book part list.")
127 LY_ASSERT_SMOB (Book
, book_smob
, 1);
128 Book
*book
= unsmob_book (book_smob
);
129 book
->add_bookpart (book_part
);
130 return SCM_UNSPECIFIED
;
133 LY_DEFINE (ly_book_book_parts
, "ly:book-book-parts",
135 "Return book parts in @var{book}.")
137 LY_ASSERT_SMOB (Book
, book
, 1);
138 Book
*b
= unsmob_book (book
);
139 return b
->bookparts_
;
142 LY_DEFINE (ly_book_paper
, "ly:book-paper",
144 "Return paper in @var{book}.")
146 LY_ASSERT_SMOB (Book
, book
, 1);
147 Book
*b
= unsmob_book (book
);
148 return b
->paper_
? b
->paper_
->self_scm () : SCM_BOOL_F
;
151 LY_DEFINE (ly_book_header
, "ly:book-header",
153 "Return header in @var{book}.")
155 LY_ASSERT_SMOB (Book
, book
, 1);
156 Book
*b
= unsmob_book (book
);
157 return b
->header_
? b
->header_
: SCM_BOOL_F
;
160 LY_DEFINE (ly_book_scores
, "ly:book-scores",
162 "Return scores in @var{book}.")
164 LY_ASSERT_SMOB (Book
, book
, 1);
165 Book
*b
= unsmob_book (book
);