lilypond-0.0.9
[lilypond.git] / molecule.cc
blob96a21b9025dc590292eee53ef7a85b9f010025e5
1 #include "glob.hh"
2 #include "string.hh"
3 #include "molecule.hh"
5 String
6 Atom::TeXstring() const
8 // whugh.. Hard coded...
9 String s("\\raise");
10 s+= String(off.y * VERT_TO_PT)+"pt\\hbox to 0pt{\\kern ";
11 s+=String(off.x * HOR_TO_PT) + "pt" + sym->tex + "\\hss}";
12 return s;
15 /****************************************************************/
17 String
18 Molecule::TeXstring() const
20 String s;
21 for(Cursor<Atom> c(ats); c.ok(); c++)
22 s+=(*c).TeXstring();
23 return s;
26 Box
27 Molecule::extent() const
29 Box b;
30 for(Cursor<Atom> c(ats); c.ok(); c++)
31 b.unite((*c).extent());
32 return b;
35 void
36 Molecule::translate(Offset o)
38 for(Cursor<Atom> c(ats); c.ok(); c++)
39 (*c).translate(o);
42 void
43 Molecule::add(const Molecule &m)
45 for (Cursor<Atom> c(m.ats); c.ok(); c++) {
46 Atom a(c);
47 ats.bottom().add(a);
51 void
52 Molecule::add_right(const Molecule &m)
54 Real xof=extent().x.max - m.extent().x.min;
55 Molecule toadd(m);
56 toadd.translate(Offset(xof, 0.0));
57 add(toadd);
60 void
61 Molecule::add_left(const Molecule &m)
63 Real xof=extent().x.min - m.extent().x.max;
64 Molecule toadd(m);
65 toadd.translate(Offset(xof, 0.0));
66 add(toadd);
70 void
71 Molecule::add_top(const Molecule &m)
73 Real yof=extent().y.max - m.extent().y.min;
74 Molecule toadd(m);
75 toadd.translate(Offset(0,yof));
76 add(toadd);
79 void
80 Molecule::add_bot(const Molecule &m)
82 Real yof=extent().y.min- m.extent().y.max;
83 Molecule toadd(m);
84 toadd.translate(Offset(0,yof));
85 add(toadd);