2 text-def.cc -- implement Text_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "paper-def.hh"
13 #include "molecule.hh"
14 #include "text-def.hh"
17 Text_def::staff_dir () const
19 if (style_str_ == "finger")
25 Text_def::guess_width_f(Atom& a) const
27 return a.dim_.x ().length ();
31 Text_def::width (Paper_def * p) const
33 Atom a = get_atom (p,CENTER);
35 Interval i (0, guess_width_f (a));
36 i += - (align_dir_ + 1)* i.center ();
41 Text_def::do_print() const
44 DOUT << "align " << align_dir_ << " `" << text_str_ << "'";
55 Text_def::do_equal_b (General_script_def const *gdef) const
57 Text_def const *def= dynamic_cast<Text_def const*>(gdef);
58 return def&& align_dir_ == def->align_dir_ && text_str_ == def->text_str_
59 && style_str_ == def->style_str_;
63 Text_def::get_atom (Paper_def *p, Direction) const
65 Atom a= p->lookup_l(0)->text (style_str_, text_str_);
67 a.translate_axis (-(align_dir_ + 1)* guess_width_f (a) / 2, X_AXIS);
68 // urg 1/1 is too much; see input/test/vertical-text.ly
69 a.translate_axis (a.dim_.y ().length () * 9 / 10, Y_AXIS);
75 Text_def::print() const
77 DOUT << "Text `" << text_str_ << "\', style " <<
78 style_str_ << "align " << align_dir_ << '\n';
82 IMPLEMENT_IS_TYPE_B1(Text_def,General_script_def);