]> git.donarmstrong.com Git - lilypond.git/blob - lily/book.cc
* lily/paper-score.cc (process): Do not show progress newline.
[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 #include "book.hh"
12 #include "global-context.hh"
13 #include "ly-module.hh"
14 #include "main.hh"
15 #include "music-iterator.hh"
16 #include "music-output.hh"
17 #include "music.hh"
18 #include "output-def.hh"
19 #include "paper-book.hh"
20 #include "score.hh"
21 #include "stencil.hh"
22 #include "warn.hh"
23
24 Book::Book ()
25   : Input ()
26 {
27   bookpaper_ = 0;
28   header_ = SCM_EOL;
29   assert (!scores_.size ());
30   smobify_self ();
31 }
32
33 Book::~Book ()
34 {
35 }
36
37 #include "ly-smobs.icc"
38 IMPLEMENT_SMOBS (Book);
39 IMPLEMENT_DEFAULT_EQUAL_P (Book);
40
41 SCM
42 Book::mark_smob (SCM s)
43 {
44   Book *book = (Book*) SCM_CELL_WORD_1 (s);
45   int score_count = book->scores_.size ();
46   for (int i = 0; i < score_count; i++)
47     scm_gc_mark (book->scores_[i]->self_scm ());
48
49   if (book->bookpaper_)
50     scm_gc_mark (book->bookpaper_->self_scm ());
51   return book->header_;
52 }
53
54 int
55 Book::print_smob (SCM, SCM p, scm_print_state*)
56 {
57   scm_puts ("#<Book>", p);
58   return 1;
59 }
60
61 /* This function does not dump the output; outname is required eg. for
62    dumping header fields.  */
63 Paper_book *
64 Book::process (String outname, Output_def *default_def)
65 {
66   Paper_book *paper_book = new Paper_book ();
67   Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
68   
69   Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
70
71   paper_book->bookpaper_ = scaled_bookdef;
72   scm_gc_unprotect_object (scaled_bookdef->self_scm());
73   
74   paper_book->header_ = header_;
75   
76   int score_count = scores_.size ();
77   for (int i = 0; i < score_count; i++)
78     {
79       SCM systems = scores_[i]->book_rendering (outname,
80                                                 paper_book->bookpaper_,
81                                                 default_def);
82       
83       /* If the score is empty, generate no output.  Should we
84          do titling?  */
85       if (systems != SCM_EOL
86           /* FIXME: can systems be SCM_UNDEFINED at all?
87              it seesm to be initialise with SCM_EOL and only gets assigned
88              non-SCM_UNDEFINED values -- jcn  */
89           && systems != SCM_UNDEFINED)
90         {
91           Score_lines sc;
92           sc.lines_ = systems;
93           sc.header_ = header_;
94           paper_book->score_lines_.push (sc);
95         }
96     }
97
98   return paper_book;
99 }
100
101 #if 0
102 /* FIXME: WIP, this is a hack.  Return first page as stencil.  */
103 SCM
104 Book::to_stencil (Output_def *default_def)
105 {
106   Paper_book *paper_book = process ("<markup>", default_def);
107
108   SCM pages = paper_book->pages ();
109   scm_gc_unprotect_object (paper_book->self_scm ());
110
111   if (ly_c_pair_p (pages))
112     {
113       progress_indication (_f ("paper output to `%s'...", "<markup>"));
114       return ly_car (pages);
115     }
116
117   scm_gc_unprotect_object (paper_book->bookpaper_->self_scm ());
118   
119   return SCM_EOL;
120 }
121 #endif