lilypond-0.1.57
[lilypond.git] / lily / script-reg.cc
blob90bf7ce5848339bae7a4d98b5d9eb0cef330f69a
1 /*
2 script-reg.cc -- implement Script_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
7 #include "script-reg.hh"
8 #include "script.hh"
9 #include "musical-request.hh"
10 #include "stem.hh"
11 #include "staff-sym.hh"
13 Script_register::Script_register()
15 do_post_move_processing();
18 bool
19 Script_register::do_try_request(Request *r_l)
21 if (!r_l->musical() || ! r_l->musical()->musicalscript())
22 return false ;
24 for (int i=0; i < script_req_l_arr_.size(); i++)
25 if ( !Script_req::compare(*script_req_l_arr_[i], *r_l->script())) {
26 return true;
29 script_req_l_arr_.push( r_l->script());
31 return true;
34 void
35 Script_register::do_process_requests()
37 for (int i=0; i < script_req_l_arr_.size(); i++){
38 Script_req* l=script_req_l_arr_[i];
39 Script *p =new Script;
40 p->dir_i_ = l->dir_i_;
41 p->specs_l_ = l->scriptdef_p_;
42 script_p_arr_.push(p);
43 announce_element(Score_elem_info(p, l));
47 bool
48 Script_register::acceptable_elem_b(Score_elem*s_l)
50 char const *nC = s_l->name();
51 return (nC == Stem::static_name());
54 void
55 Script_register::acknowledge_element(Score_elem_info info)
57 Score_elem *elem_l = info.elem_l_;
58 if (!acceptable_elem_b(elem_l))
59 return;
61 for (int i=0; i < script_p_arr_.size(); i++) {
62 Script*script_l = script_p_arr_[i];
63 if (elem_l->name() == Stem::static_name())
64 script_l->set_stem((Stem*)elem_l->item());
68 void
69 Script_register::do_pre_move_processing()
71 Staff_symbol* s_l = get_staff_info().staff_sym_l_;
72 for (int i=0; i < script_p_arr_.size(); i++) {
74 Script*script_p = script_p_arr_[i];
75 script_p->set_staffsym( s_l);
76 typeset_element(script_p);
78 script_p_arr_.set_size(0);
81 void
82 Script_register::do_post_move_processing()
84 script_req_l_arr_.set_size(0);
87 IMPLEMENT_STATIC_NAME(Script_register);
88 IMPLEMENT_IS_TYPE_B1(Script_register,Request_register);
89 ADD_THIS_REGISTER(Script_register);