]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/stencil.hh
* lily/paper-outputter.cc (output_stencil): dump font definitions
[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             | origin (ORIGIN) Expr
26             | no-origin Expr
27             | (SCHEME)
28             ;
29
30     SCHEME is a Scheme expression that --when eval'd-- produces the
31     desired output.  
32
33     Notes:
34     
35     * Because of the way that Stencil is implemented, it is the most
36     efficient to add "fresh" stencils to what you're going to build.
37
38     * Do not create Stencil objects on the heap. That includes passing
39     around Stencil* which are produced by unsmob_stencil(). Either
40     copy Stencil objects, or use SCM references.
41     
42     * Empty stencils have empty dimensions.  If add_at_edge is used to
43     init the stencil, we assume that
44
45       DIMENSIONS = (Interval (0,0),Interval (0,0)
46 */
47 class Stencil
48 {
49   friend SCM ly_stencil_set_extent_x (SCM, SCM, SCM);
50
51   /*
52     This provides the reference point of the symbol, for example with
53     characters, it is on the base line of the character. Usually,
54     ORIGIN is inside DIM_
55    */
56   Offset origin_;
57   Box dim_;
58   SCM expr_;
59   
60   DECLARE_SIMPLE_SMOBS (Stencil,);  
61 public:
62   Stencil (Box, SCM s);
63   Stencil ();
64   
65   Offset origin () const;
66   SCM expr () const;
67
68   /**
69      Set dimensions to empty, or to (Interval (0,0),Interval (0,0) */
70   void set_empty (bool);
71   Stencil moved_to_edge (Axis a, Direction d, const Stencil &m, Real padding,
72                          Real minimum) const;
73
74   void add_at_edge (Axis a, Direction d, const Stencil &m, Real padding,
75                     Real minimum);
76   void add_stencil (Stencil const &m);
77   void translate (Offset);
78   void align_to (Axis a, Real x);
79   void translate_axis (Real,Axis);
80   
81   Interval extent (Axis) const;
82   Box extent_box () const;
83   bool is_empty () const;
84
85   static SCM ly_get_stencil_extent (SCM mol, SCM axis);
86   static SCM ly_set_stencil_extent_x (SCM,SCM,SCM);
87   static SCM ly_stencil_combined_at_edge (SCM,SCM,SCM,SCM,SCM);
88 };
89
90
91 DECLARE_UNSMOB(Stencil,stencil);
92 SCM fontify_atom (Font_metric const*, SCM atom);
93
94 void interpret_stencil_expression (SCM expr,
95                         void (*func) (void*, SCM),
96                         void *func_arg,
97                         Offset o);
98
99 Stencil create_stencil (SCM print);
100 SCM find_expression_fonts (SCM expr);
101
102 #endif