lilypond-0.1.56
[lilypond.git] / src / voicegroup.cc
blob0674ee08c86b6c6a70340aacaf859e6b47e936c4
1 /*
2 voicegroup.cc -- implement Voice_group_registers
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "plist.hh"
10 #include "musicalrequest.hh"
11 #include "voicegroup.hh"
12 #include "register.hh"
13 #include "textreg.hh"
14 #include "stembeamreg.hh"
15 #include "scriptreg.hh"
16 #include "complexwalker.hh"
17 #include "commandrequest.hh"
19 static int temp_id_count;
21 Voice_group_registers::Voice_group_registers(Complex_walker*w_l, String id)
23 walk_l_ = w_l;
24 text_reg_=new Text_register(w_l);
25 stem_beam_reg_= new Stem_beam_register(w_l);
26 script_reg_ = new Script_register(w_l);
27 if (id=="")
28 id = __FUNCTION__ + String(temp_id_count++);
29 group_id_str_ = id;
30 dir_i_ = 0;
33 Voice_group_registers::~Voice_group_registers()
35 delete text_reg_;
36 delete stem_beam_reg_;
37 delete script_reg_;
40 void
41 Voice_group_registers::pre_move_processing()
43 stem_beam_reg_->pre_move_processing();
44 script_reg_->pre_move_processing();
45 text_reg_->pre_move_processing();
48 void
49 Voice_group_registers::post_move_processing()
51 stem_beam_reg_->post_move_processing();
52 text_reg_->post_move_processing();
53 script_reg_->post_move_processing();
56 bool
57 Voice_group_registers::try_request(Request*r_l)
59 if (r_l->groupfeature()) {
60 set_dir(r_l->groupfeature()->stemdir_i_);
61 return true;
63 bool b = stem_beam_reg_->try_request(r_l);
64 if (!b)
65 b|= script_reg_->try_request(r_l);
66 if (!b)
67 b|= text_reg_->try_request(r_l);
69 return b;
72 void
73 Voice_group_registers::acknowledge_element(Staff_elem_info i)
75 if (i.group_regs_l_!= this)
76 return;
78 stem_beam_reg_->acknowledge_element(i);
79 script_reg_->acknowledge_element(i);
80 text_reg_->acknowledge_element(i);
83 void
84 Voice_group_registers::set_dir(int i)
86 stem_beam_reg_->set_dir(i);
87 script_reg_->set_dir(i);
88 text_reg_->set_dir(i);
90 Array<Voice_registers*> vr_arr (walk_l_->get_voice_regs(this));
91 for (int j=0; j<vr_arr.size(); j++) {
92 if (vr_arr[j])
93 vr_arr[j]->set_dir(i);
96 void
97 Voice_group_registers::process_requests()
99 stem_beam_reg_->process_request();
100 script_reg_->process_request();
101 text_reg_->process_request();
105 bool
106 Voice_group_registers::acceptable_request(Request*r)
108 return (r->stem() || r->beam() || r->text() || r->script() ||
109 r->groupfeature());