]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-item.cc
release: 0.0.57
[lilypond.git] / lily / text-item.cc
1 /*
2   text-item.cc -- implement Text_item
3
4   source file of the 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(Text_def *tdef_l, int d)
18     : Staff_side(this)
19 {
20     dir_i_ = d;
21     fat_b_ = false;
22     tdef_p_ = new Text_def(*tdef_l);
23     pos_i_ =0;
24 }
25
26 Text_def*
27 Text_item::tdef_l()
28 {
29     return tdef_p_;
30 }
31
32 Text_item::~Text_item()
33 {
34     delete tdef_p_;
35 }
36
37 void
38 Text_item::set_default_index()
39 {
40     pos_i_  = get_position_i(tdef_p_->create_atom().extent().y );
41 }
42
43 void
44 Text_item::do_pre_processing()
45 {
46     if (!dir_i_)
47         dir_i_ = -1;
48     tdef_p_->pdef_l_ = paper();
49 }
50
51 void
52 Text_item::do_post_processing()
53 {
54         set_default_index();
55 }
56
57     
58 Molecule*
59 Text_item::brew_molecule_p() const
60 {
61     Atom a(tdef_p_->create_atom());
62
63     if ( fat_b_)
64         a.sym.dim.x = tdef_p_->width();
65
66     Molecule* mol_p = new Molecule(a);
67
68     if(dir_i_<0 )               // should do something better anyway.
69         mol_p->translate(Offset(0, -mol_p->extent().y.left ));
70     mol_p->translate(Offset(0, pos_i_ * paper()->internote()));
71     
72     return mol_p;
73 }
74
75 IMPLEMENT_STATIC_NAME(Text_item);