]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/molecule.hh
78aace7bd3f72cd26a2bc876ec24641a6605a3f6
[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--2004 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 #include "smobs.hh"
18
19 /** a group of individually translated symbols. You can add molecules
20     to the top, to the right, etc.
21
22     It is implemented as a "tree" of scheme expressions, as in
23
24      Expr = combine Expr Expr
25               | translate Offset Expr
26               | SCHEME
27               ;
28
29     SCHEME is a Scheme expression that --when eval'd-- produces the
30     desired output.  
31
32
33     Because of the way that Molecule is implemented, it is the most
34     efficient to add "fresh" molecules to what you're going to build.
35     
36     Dimension behavior:
37
38     Empty molecules have empty dimensions.  If add_at_edge is used to
39     init the molecule, we assume that
40     DIMENSIONS = (Interval (0,0),Interval (0,0)
41 */
42 class Molecule
43 {
44   friend SCM ly_molecule_set_extent_x (SCM, SCM, SCM);
45   
46   Box dim_;
47   SCM expr_;
48   
49   DECLARE_SIMPLE_SMOBS (Molecule,);  
50 public:
51   Molecule (Box, SCM s);
52   Molecule ();
53
54
55   SCM smobbed_copy () const;
56   SCM get_expr () const;
57
58   /**
59      Set dimensions to empty, or to (Interval (0,0),Interval (0,0) */
60   void set_empty (bool);
61   void add_at_edge (Axis a, Direction d, const Molecule &m, Real padding,
62                     Real minimum);
63   void add_molecule (Molecule const &m);
64   void translate (Offset);
65   void align_to (Axis a, Real x);
66   void translate_axis (Real,Axis);
67   
68   Interval extent (Axis) const;
69   Box extent_box () const;
70   /**
71      codify THIS into a Scheme expression.
72    */
73   SCM create_scheme () const;
74   bool is_empty () const;
75
76
77   static SCM ly_get_molecule_extent (SCM mol, SCM axis);
78   static SCM ly_set_molecule_extent_x (SCM,SCM,SCM);
79   static SCM ly_molecule_combined_at_edge (SCM,SCM,SCM,SCM,SCM);
80 };
81
82
83 DECLARE_UNSMOB(Molecule,molecule);
84 SCM fontify_atom (Font_metric const*, SCM atom);
85
86 Molecule create_molecule (SCM print);
87
88
89
90 #endif