2 book.cc -- implement Book
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "ly-smobs.icc"
15 #include "global-context.hh"
16 #include "ly-module.hh"
18 #include "music-iterator.hh"
19 #include "output-def.hh"
20 #include "music-output.hh"
23 #include "paper-book.hh"
24 #include "output-def.hh"
33 assert (!scores_.size ());
41 IMPLEMENT_SMOBS (Book);
42 IMPLEMENT_DEFAULT_EQUAL_P (Book);
45 Book::mark_smob (SCM s)
47 Book *book = (Book*) SCM_CELL_WORD_1 (s);
48 int score_count = book->scores_.size ();
49 for (int i = 0; i < score_count; i++)
50 scm_gc_mark (book->scores_[i]->self_scm ());
53 scm_gc_mark (book->bookpaper_->self_scm ());
58 Book::print_smob (SCM, SCM p, scm_print_state*)
60 scm_puts ("#<Book>", p);
65 Book::process (String outname, Output_def *default_def, SCM header)
67 Paper_book *paper_book = new Paper_book ();
70 Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
72 Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
74 paper_book->bookpaper_ = scaled_bookdef;
75 int score_count = scores_.size ();
76 for (int i = 0; i < score_count; i++)
78 SCM systems = scores_[i]->book_rendering (outname,
79 paper_book->bookpaper_,
81 if (systems != SCM_UNDEFINED)
87 paper_book->score_lines_.push (sc);
91 paper_book->output (outname);
93 scm_gc_unprotect_object (paper_book->bookpaper_->self_scm ());
94 scm_gc_unprotect_object (paper_book->self_scm ());
97 /* FIXME: WIP, this is a hack. Return first page as stencil. */
99 Book::to_stencil (Output_def *default_def, SCM header)
101 Paper_book *paper_book = new Paper_book ();
102 Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
104 Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
106 paper_book->bookpaper_ = scaled_bookdef;
108 int score_count = scores_.size ();
109 for (int i = 0; i < score_count; i++)
111 SCM systems = scores_[i]->book_rendering ("<markup>",
115 if (systems != SCM_UNDEFINED)
121 paper_book->score_lines_.push (sc);
127 SCM pages = paper_book->pages ();
129 if (pages != SCM_EOL)
131 progress_indication (_f ("paper output to `%s'...", "<markup>"));
132 return (unsmob_page (ly_car (pages)))->to_stencil ().smobbed_copy ();
135 scm_gc_unprotect_object (paper_book->bookpaper_->self_scm ());