]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-item.cc
release: 0.1.30
[lilypond.git] / lily / text-item.cc
1 /*
2   text-item.cc -- implement Text_item
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #include "musical-request.hh"
11 #include "paper-def.hh"
12 #include "text-item.hh"
13 #include "stem.hh"
14 #include "molecule.hh"
15 #include "lookup.hh"
16
17 Text_item::Text_item (General_script_def*tdef_l, Direction d) 
18 {
19   dir_ = d;
20   fat_b_ = false;
21   tdef_p_ = tdef_l->clone();
22 }
23
24 Text_item::~Text_item()
25 {
26   delete tdef_p_;
27 }
28
29 void
30 Text_item::do_pre_processing()
31 {
32   if (!dir_)
33     dir_ = DOWN;
34 }
35
36 Interval
37 Text_item::symbol_height() const
38 {
39   return tdef_p_->get_atom (paper(), dir_).dim_.y ();
40 }
41   
42 Molecule*
43 Text_item::brew_molecule_p() const
44 {
45   Atom a (tdef_p_->get_atom (paper(), dir_));
46
47   /*
48     if (fat_b_)
49     a.sym.dim.x = tdef_p_->width (paper());
50     */
51   Molecule* mol_p = new Molecule (a);
52
53   if (dir_<0)           // should do something better anyway.
54     mol_p->translate_axis (-mol_p->extent().y ().left , Y_AXIS);
55   mol_p->translate_axis (y_, Y_AXIS);
56   
57   return mol_p;
58 }
59
60
61 IMPLEMENT_IS_TYPE_B1(Text_item,Item);