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