]> git.donarmstrong.com Git - lilypond.git/blob - lily/box.cc
Run `make grand-replace'.
[lilypond.git] / lily / box.cc
1 /*
2   box.cc -- implement Box
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "box.hh"
10
11 void
12 Box::translate (Offset o)
13 {
14   for (Axis i = X_AXIS; i < NO_AXES; incr (i))
15     interval_a_[i] += o[i];
16 }
17
18 void
19 Box::unite (Box b)
20 {
21   for (Axis i = X_AXIS; i < NO_AXES; incr (i))
22     interval_a_[i].unite (b[i]);
23 }
24
25 Box::Box ()
26 {
27 }
28
29 void
30 Box::set_empty ()
31 {
32   interval_a_[X_AXIS].set_empty ();
33   interval_a_[Y_AXIS].set_empty ();
34 }
35
36 Box::Box (Interval ix, Interval iy)
37 {
38   x () = ix;
39   y () = iy;
40 }
41
42 Interval &
43 Box::operator [] (Axis a)
44 {
45   return interval_a_[a];
46 }
47
48 Interval
49 Box::operator [] (Axis a) const
50 {
51   return interval_a_[a];
52 }
53
54 void
55 Box::scale (Real s)
56 {
57   interval_a_[X_AXIS] *= s;
58   interval_a_[Y_AXIS] *= s;
59 }
60
61 void
62 Box::add_point (Offset o)
63 {
64   interval_a_[X_AXIS].add_point (o[X_AXIS]);
65   interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
66 }
67
68 Offset
69 Box::center () const
70 {
71   return Offset (interval_a_[X_AXIS].center (),
72                  interval_a_[Y_AXIS].center ());
73 }
74
75 void
76 Box::widen (Real x, Real y)
77 {
78   interval_a_[X_AXIS].widen (x);
79   interval_a_[Y_AXIS].widen (y);
80 }
81
82 /****************************************************************/
83
84 #include "ly-smobs.icc"
85
86 IMPLEMENT_SIMPLE_SMOBS (Box);
87 IMPLEMENT_TYPE_P (Box, "ly:box?");
88 IMPLEMENT_DEFAULT_EQUAL_P (Box);
89
90 SCM
91 Box::mark_smob (SCM x)
92 {
93   (void)x;
94   return SCM_EOL;
95 }
96
97 int
98 Box::print_smob (SCM x, SCM p, scm_print_state*)
99 {
100   (void)x;
101   scm_puts ("#<Box>", p);
102   return 1;
103 }