]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/stencil.hh
* lily/paper-line.cc (Paper_line): don't store list of stencils,
[lilypond.git] / lily / include / stencil.hh
1 /*
2   stencil.hh -- declare Stencil
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 STENCIL_HH
9 #define STENCIL_HH
10
11 #include <stdlib.h>             // size_t
12 #include "lily-proto.hh"
13 #include "box.hh"
14 #include "direction.hh"
15 #include "lily-guile.hh"
16 #include "smobs.hh"
17
18 /** a group of individually translated symbols. You can add stencils
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     Notes:
32     
33     * Because of the way that Stencil is implemented, it is the most
34     efficient to add "fresh" stencils to what you're going to build.
35
36     * Do not create Stencil objects on the heap. That includes passing
37     around Stencil* which are produced by unsmob_stencil().
38     
39     * Empty stencils have empty dimensions.  If add_at_edge is used to
40     init the stencil, we assume that
41
42       DIMENSIONS = (Interval (0,0),Interval (0,0)
43 */
44 class Stencil
45 {
46   friend SCM ly_stencil_set_extent_x (SCM, SCM, SCM);
47
48   /*
49     This provides the reference point of the symbol, for example with
50     characters, it is on the base line of the character. Usually,
51     ORIGIN is inside DIM_
52    */
53   Offset origin_;
54   Box dim_;
55   SCM expr_;
56   
57   DECLARE_SIMPLE_SMOBS (Stencil,);  
58 public:
59   Stencil (Box, SCM s);
60   Stencil ();
61   
62   Offset origin () const;
63   SCM expr () const;
64
65   /**
66      Set dimensions to empty, or to (Interval (0,0),Interval (0,0) */
67   void set_empty (bool);
68   Stencil moved_to_edge (Axis a, Direction d, const Stencil &m, Real padding,
69                          Real minimum) const;
70
71   void add_at_edge (Axis a, Direction d, const Stencil &m, Real padding,
72                     Real minimum);
73   void add_stencil (Stencil const &m);
74   void translate (Offset);
75   void align_to (Axis a, Real x);
76   void translate_axis (Real,Axis);
77   
78   Interval extent (Axis) const;
79   Box extent_box () const;
80   bool is_empty () const;
81
82   static SCM ly_get_stencil_extent (SCM mol, SCM axis);
83   static SCM ly_set_stencil_extent_x (SCM,SCM,SCM);
84   static SCM ly_stencil_combined_at_edge (SCM,SCM,SCM,SCM,SCM);
85 };
86
87
88 DECLARE_UNSMOB(Stencil,stencil);
89 SCM fontify_atom (Font_metric const*, SCM atom);
90
91 Stencil create_stencil (SCM print);
92
93
94
95 #endif