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