5 #include "paper-def.hh"
7 LY_DEFINE(ly_set_grob_property,"ly-set-grob-property!", 3, 0, 0,
8 (SCM grob, SCM sym, SCM val),
9 "Set @var{sym} in grob @var{grob} to value @var{val}")
11 Grob * sc = unsmob_grob (grob);
12 SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
13 SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
15 if (!type_check_assignment (sym, val, ly_symbol2scm ("backend-type?")))
16 error ("typecheck failed");
18 sc->internal_set_grob_property (sym, val);
19 return SCM_UNSPECIFIED;
22 LY_DEFINE(ly_get_grob_property,
23 "ly-get-grob-property", 2, 0, 0, (SCM grob, SCM sym),
24 "Get the value of a value in grob @var{g} of property @var{sym}. It
25 will return @code{'()} (end-of-list) if @var{g} doesn't have @var{sym} set.
27 Grob properties are stored as GUILE association lists, with symbols as
28 keys. All lookup functions identify undefined properties with
29 end-of-list (i.e. @code{'()} in Scheme or @code{SCM_EOL} in C)
31 Properties are stored in two ways:
33 @item mutable properties.
34 Grob properties that change from object to object. The storage of
35 these are private to a grob. For example pointers to other grobs are
36 always stored in the mutable properties.
38 @item immutable properties.
39 Grob properties that are shared across different grobs of the same
40 type. The storage is shared, and hence it is read-only. Typically, this
41 is used to store function callbacks, and default settings. They are
42 initially read from @file{scm/grob-description.scm}.
47 Grob * sc = unsmob_grob (grob);
48 SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
49 SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
51 return sc->internal_get_grob_property (sym);
54 LY_DEFINE(spanner_get_bound, "ly-get-spanner-bound", 2 , 0, 0,
56 "Get one of the bounds of @var{spanner}. @var{dir} may be @code{-1} for
57 left, and @code{1} for right.
60 Spanner * sl = dynamic_cast<Spanner*> (unsmob_grob (slur));
61 SCM_ASSERT_TYPE(sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob");
62 SCM_ASSERT_TYPE(ly_dir_p (dir), slur, SCM_ARG2, __FUNCTION__, "dir");
63 return sl->get_bound (to_dir (dir))->self_scm ();
66 LY_DEFINE(ly_get_paper_var,"ly-get-paper-variable", 2, 0, 0,
68 "Get a variable from the \\paper block.")
70 Grob * sc = unsmob_grob (grob);
71 SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
72 SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
74 return sc->get_paper () ->get_scmvar_scm (sym);
79 LY_DEFINE(ly_get_extent, "ly-get-extent", 3, 0, 0,
80 (SCM grob, SCM refp, SCM axis),
81 "Get the extent in @var{axis} direction of @var{grob} relative to the
84 Grob * sc = unsmob_grob (grob);
85 Grob * ref = unsmob_grob (refp);
86 SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
87 SCM_ASSERT_TYPE(ref, refp, SCM_ARG2, __FUNCTION__, "grob");
89 SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
91 return ly_interval2scm ( sc->extent (ref, Axis (gh_scm2int (axis))));
94 LY_DEFINE (ly_get_parent, "ly-get-parent", 2, 0, 0, (SCM grob, SCM axis),
95 "Get the parent of @var{grob}. @var{axis} can be 0 for the X-axis, 1
98 Grob * sc = unsmob_grob (grob);
99 SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
100 SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
102 Grob * par = sc->get_parent (Axis (gh_scm2int (axis)));
103 return par ? par->self_scm() : SCM_EOL;
107 LY_DEFINE (get_system,
111 Return the System Grob of @var{grob}.
114 Grob *me = unsmob_grob (grob);
115 SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob");
117 if (Grob *g = me->get_system ())
118 return g->self_scm ();
124 LY_DEFINE (get_original,
128 Return the original Grob of @var{grob}
131 Grob *me = unsmob_grob (grob);
132 SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob");
133 return me->original_ ? me->original_->self_scm () : me->self_scm ();
137 /* ly prefix? spanner in name? */
138 LY_DEFINE (get_broken_into,
139 "get-broken-into", 1, 0, 0, (SCM spanner),
141 Return broken-into list for @var{spanner}.
145 /// Spanner *me = unsmob_spanner (spanner);
146 Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (spanner));
147 SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner");
150 for (int i = me->broken_intos_.size (); i; i--)
151 s = gh_cons (me->broken_intos_[i-1]->self_scm (), s);