]> git.donarmstrong.com Git - lilypond.git/blob - molecule.hh
c98cfe5f49421b26c11e01193f4b6ae5bb71eb95
[lilypond.git] / molecule.hh
1 #ifndef MOLECULE_HH
2 #define MOLECULE_HH
3
4 #include "list.hh"
5 #include "boxes.hh"
6 #include "item.hh"
7
8 /// a symbol which can be translated, and freely copied
9 struct Atom {
10     Offset off;
11     const Symbol * sym;
12
13     void translate(Offset o) {
14         off += o;
15     }
16     
17     /// how big is #this#?
18     Box extent() const {
19         Box b( sym->dim);
20         b.translate(off);
21         return b;
22     }
23     Atom(const Symbol*s) {
24         sym=s;
25     }
26     String TeXstring() const;
27 };
28
29 /// a group of #Atom#s
30 struct Molecule : Output {
31     List<Atom> ats;
32
33     Molecule() { }
34     Molecule(Atom a) { ats.bottom().add(a); }
35     //    Molecule(Molecule const&src);
36     void add_right(const Molecule &m);
37     void add_left(const Molecule &m);
38     void add_top(const Molecule &m);
39     void add_bot(const Molecule &m);
40     void add(Molecule const &m);
41     void translate(Offset);
42
43     /// how big is #this#? 
44     Box extent() const;
45
46     String TeXstring() const;
47 };
48 /** a group of individually translated symbols. You can add molecules
49     to the top, to the right, etc.  */
50 #endif