2 paper-def.cc -- implement Paper_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "paper-def.hh"
15 #include "font-metric.hh"
18 #include "file-results.hh" // urg? header_global_p
19 #include "paper-stream.hh"
21 Paper_def::Paper_def ()
23 style_sheet_ = SCM_EOL;
26 Paper_def::~Paper_def ()
30 Paper_def::Paper_def (Paper_def const&src)
31 : Music_output_def (src)
33 style_sheet_ = src.style_sheet_;
38 Paper_def::get_var (String s) const
40 return get_realvar (ly_symbol2scm (s.ch_C()));
44 Paper_def::get_scmvar (String s) const
46 return scope_p_->scm_elem (ly_symbol2scm (s.ch_C()));
50 Paper_def::get_realvar (SCM s) const
53 if (!scope_p_->try_retrieve (s, &val))
55 programming_error ("unknown paper variable: " + ly_symbol2string (s));
59 if (gh_number_p (val))
61 return gh_scm2double (val);
65 programming_error ("not a real variable");
71 FIXME. This is broken until we have a generic way of
72 putting lists inside the \paper block.
75 Paper_def::line_dimensions_int (int n) const
77 Real lw = get_var ("linewidth");
78 Real ind = n? 0.0:get_var ("indent");
80 return Interval (ind, lw);
85 int Paper_def::default_count_i_ = 0;
88 Paper_def::get_next_default_count () const
90 return default_count_i_ ++;
94 Paper_def::reset_default_count()
101 Paper_def::paper_stream_p () const
103 String outname = base_output_str ();
106 outname += String (".") + output_global_ch;
107 progress_indication (_f ("paper output to %s...",
108 outname == "-" ? String ("<stdout>") : outname));
110 target_str_global_array.push (outname);
111 return new Paper_stream (outname);
116 Paper_def::base_output_str () const
118 String str = get_default_output ();
122 str = default_outname_base_global;
123 int def = get_next_default_count ();
125 str += "-" + to_str (def);