]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/molecule.hh
release: 1.3.33
[lilypond.git] / lily / include / molecule.hh
1 /*
2   molecule.hh -- declare Molecule
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #ifndef MOLECULE_HH
9 #define MOLECULE_HH
10
11 #include <stdlib.h>             // size_t
12 #include "lily-proto.hh"
13 #include "box.hh"
14 #include "axes.hh"
15 #include "direction.hh"
16 #include "lily-guile.hh"
17
18 /** a group of individually translated symbols. You can add molecules
19     to the top, to the right, etc.
20
21     It is implemented as a "tree" of scheme expressions, as in
22
23      Expr = combine Expr Expr
24               | translate Offset Expr
25               | SCHEME
26               ;
27
28     SCHEME is a Scheme expression that --when eval'd-- produces the
29     desired output.  
30
31
32     Because of the way that Molecule is implemented, it is the most
33     efficient to add "fresh" molecules to what you're going to build.
34     
35     Dimension behavior:
36
37     Empty molecules have empty dimensions.  If add_at_edge is used to
38     init the molecule, we assume that
39     DIMENSIONS = (Interval(0,0),Interval(0,0)
40     
41 */
42 class Molecule {
43   /// can't alloc on heap.
44   void * operator new (size_t s); 
45 public:
46   Box dim_;
47   SCM expr_;
48   
49   Molecule (Box, SCM s);
50   Molecule();
51
52   /**
53      Set dimensions to empty, or to (Interval(0,0),Interval(0,0) */
54   void set_empty (bool);
55   void add_at_edge (Axis a, Direction d, const Molecule &m, Real padding);
56   void add_molecule (Molecule const &m);
57   void translate (Offset);
58   
59   /**
60      align D direction in axis A.
61
62      If D == CENTER, then move the dimension(A).center() to (0,0)
63
64      Else, move so dimension(A)[D] == 0.0
65      
66    */
67   void align_to (Axis a, Direction d);
68   void translate_axis (Real,Axis);
69
70   
71   
72   /// how big is #this#? 
73   Box extent() const;
74   Interval extent (Axis) const;
75   bool empty_b() const;
76
77
78   /*******/
79 };
80
81 SCM fontify_atom (Font_metric*, SCM atom);
82
83
84
85
86 #endif