]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-def.cc
* lily/music-output-def.cc (Music_output_def): remove separate
[lilypond.git] / lily / paper-def.cc
1 /*
2   paper-def.cc -- implement Paper_def
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
10 #include <math.h>
11
12 #include "book-paper-def.hh"
13 #include "virtual-font-metric.hh"
14 #include "all-font-metrics.hh"
15 #include "string.hh"
16 #include "misc.hh"
17 #include "paper-def.hh"
18 #include "warn.hh"
19 #include "scaled-font-metric.hh"
20 #include "main.hh"
21 #include "scm-hash.hh"
22 #include "paper-outputter.hh"
23 #include "ly-module.hh"
24
25 /*
26   This is an almost empty thing. The only substantial thing this class
27   handles is scaling up and down to real-world dimensions (internally
28   dimensions are against global staff-space.)
29  */
30
31 Paper_def::Paper_def ()
32 {
33   bookpaper_ = 0;
34 }
35
36 Paper_def::Paper_def (Paper_def const&src)
37   : Music_output_def (src)
38 {
39   /* Do not remove this statement, scm_make_hash_table may trigger GC.  */
40   bookpaper_ = 0;
41 }
42
43 Paper_def::~Paper_def ()
44 {
45 }
46
47 Real
48 Paper_def::get_dimension (SCM s) const
49 {
50   SCM val = lookup_variable (s);
51   return ly_scm2double (val);
52 }
53
54 /* FIXME.  This is broken until we have a generic way of
55    putting lists inside the \paper block.  */
56 Interval
57 Paper_def::line_dimensions_int (int n) const
58 {
59   Real lw =  get_dimension (ly_symbol2scm ("linewidth"));
60   Real ind = n? 0.0:get_dimension (ly_symbol2scm ("indent"));
61
62   return Interval (ind, lw);
63 }
64
65 Paper_outputter*
66 Paper_def::get_paper_outputter (String outname) const
67 {
68   progress_indication (_f ("paper output to `%s'...",
69                            outname == "-" ? String ("<stdout>") : outname));
70   return new Paper_outputter (outname);
71
72 }
73
74 Paper_def* 
75 unsmob_paper (SCM x)
76 {
77   return dynamic_cast<Paper_def*> (unsmob_music_output_def (x));
78 }
79   
80
81 LY_DEFINE (ly_paper_def_p, "ly:paper-def?",
82            1, 0, 0, (SCM def),
83            "Is @var{def} a paper definition?")
84 {
85   Paper_def *op = dynamic_cast<Paper_def*> (unsmob_music_output_def (def));
86
87   bool pap = op;
88   return ly_bool2scm (pap);
89 }