]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-def.cc
release: 1.1.33
[lilypond.git] / lily / text-def.cc
1 /*
2   text-def.cc -- implement Text_def
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include <ctype.h>
10 #include "debug.hh"
11 #include "lookup.hh"
12 #include "paper-def.hh"
13 #include "molecule.hh"
14 #include "text-def.hh"
15
16 Direction
17 Text_def::staff_dir () const
18 {
19   if (style_str_ == "finger")
20     return UP;
21   return DOWN;
22 }
23
24
25 void
26 Text_def::do_print() const
27 {
28 #ifndef NPRINT
29   DOUT << "align " << align_dir_ << " `" << text_str_ << "'";
30 #endif
31 }
32
33 Text_def::Text_def()
34 {   
35   align_dir_ = RIGHT;
36   style_str_ = "roman";
37 }
38
39 bool
40 Text_def::do_equal_b (General_script_def const *gdef) const
41 {
42   Text_def const *def= dynamic_cast<Text_def const*>(gdef);
43   return def&& align_dir_ == def->align_dir_ && text_str_ == def->text_str_
44         && style_str_ == def->style_str_;
45 }
46
47 Molecule
48 Text_def::get_molecule (Paper_def *p, Direction) const
49 {
50   Molecule a= p->lookup_l(0)->text (style_str_, text_str_);
51
52   a.translate_axis (-(align_dir_ + 1)* a.dim_[X_AXIS].center (), X_AXIS);
53   
54   return a;
55 }
56
57 void
58 Text_def::print() const
59 {
60   DOUT << "Text `" << text_str_ << "\', style " <<
61         style_str_ << "align " << align_dir_ << '\n';
62 }
63
64
65