]> git.donarmstrong.com Git - lilypond.git/blob - lily/book.cc
* lily/paper-book.cc: remove copyright & tagline. Remove
[lilypond.git] / lily / book.cc
1 /*
2   book.cc -- implement Book
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include <stdio.h>
10
11
12 #include "ly-smobs.icc"
13 #include "stencil.hh"
14 #include "book.hh"
15 #include "global-context.hh"
16 #include "ly-module.hh"
17 #include "main.hh"
18 #include "music-iterator.hh"
19 #include "output-def.hh"
20 #include "music-output.hh"
21 #include "music.hh"
22 #include "paper-book.hh"
23 #include "output-def.hh"
24 #include "score.hh"
25 #include "warn.hh"
26
27 Book::Book ()
28   : Input ()
29 {
30   bookpaper_ = 0;
31   header_ = SCM_EOL;
32   assert (!scores_.size ());
33   smobify_self ();
34 }
35
36 Book::~Book ()
37 {
38 }
39
40 IMPLEMENT_SMOBS (Book);
41 IMPLEMENT_DEFAULT_EQUAL_P (Book);
42
43 SCM
44 Book::mark_smob (SCM s)
45 {
46   Book *book = (Book*) SCM_CELL_WORD_1 (s);
47   int score_count = book->scores_.size ();
48   for (int i = 0; i < score_count; i++)
49     scm_gc_mark (book->scores_[i]->self_scm ());
50
51   if (book->bookpaper_)
52     scm_gc_mark (book->bookpaper_->self_scm ());
53   return book->header_;
54 }
55
56 int
57 Book::print_smob (SCM, SCM p, scm_print_state*)
58 {
59   scm_puts ("#<Book>", p);
60   return 1;
61 }
62
63 /*
64   This function does not dump the output; outname is required eg. for
65   dumping header fields.
66  */
67 Paper_book *
68 Book::process (String outname, Output_def *default_def)
69 {
70   Paper_book *paper_book = new Paper_book ();
71   Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
72   
73   Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
74
75   paper_book->bookpaper_ = scaled_bookdef;
76   scm_gc_unprotect_object (scaled_bookdef->self_scm());
77   
78   paper_book->header_ = header_;
79   
80   int score_count = scores_.size ();
81   for (int i = 0; i < score_count; i++)
82     {
83       SCM systems = scores_[i]->book_rendering (outname,
84                                                 paper_book->bookpaper_,
85                                                 default_def);
86       if (systems != SCM_UNDEFINED)
87         {
88           Score_lines sc;
89           sc.lines_ = systems;
90           sc.header_ = header_;
91
92           paper_book->score_lines_.push (sc);
93         }
94     }
95
96   return paper_book;
97 }
98
99 #if 0
100 /* FIXME: WIP, this is a hack.  Return first page as stencil.  */
101 SCM
102 Book::to_stencil (Output_def *default_def)
103 {
104   Paper_book *paper_book = process ("<markup>", default_def);
105
106   SCM pages = paper_book->pages ();
107   scm_gc_unprotect_object (paper_book->self_scm ());
108
109   if (ly_c_pair_p (pages))
110     {
111       progress_indication (_f ("paper output to `%s'...", "<markup>"));
112       return ly_car (pages);
113     }
114
115   scm_gc_unprotect_object (paper_book->bookpaper_->self_scm ());
116   
117   return SCM_EOL;
118 }
119 #endif