]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-reg.cc
release: 0.0.61
[lilypond.git] / lily / text-reg.cc
1 /*
2   text-reg.cc -- implement Text_register
3
4   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6 #include "note-column.hh"
7 #include "musical-request.hh"
8 #include "text-reg.hh"
9 #include "text-item.hh"
10
11 Text_register::Text_register()
12 {
13     text_p_ = 0;
14     dir_i_ =0;
15     post_move_processing();
16 }
17
18 bool
19 Text_register::try_request(Request*req_l)
20 {
21     if (!req_l->text())
22         return false;
23     if (text_req_l_ &&
24         Text_req::compare(*req_l->text(), *text_req_l_))
25
26         return false;
27
28     text_req_l_ = req_l->text();
29     return true;
30 }
31 void
32 Text_register::acknowledge_element(Staff_elem_info i)
33 {
34     if (text_p_ && i.elem_l_->name() == Note_column::static_name()) {
35         text_p_->add_support(i.elem_l_);
36     }
37 }
38 void
39 Text_register::process_requests()
40 {
41     if (text_req_l_) {
42         text_p_ = new Text_item(text_req_l_->tdef_p_, text_req_l_->dir_i_); // ugh
43         announce_element(Staff_elem_info(text_p_, text_req_l_));
44     }
45 }
46 void
47 Text_register::pre_move_processing()
48 {
49     if (text_p_) {
50         if (dir_i_ && !text_p_->dir_i_)
51             text_p_->dir_i_ = dir_i_;
52         Staff_symbol* s_l = get_staff_info().staff_sym_l_;
53         text_p_->set_staffsym(s_l);
54         typeset_element(text_p_);
55             
56         text_p_ = 0;
57     }
58 }
59 void
60 Text_register::set_feature(Feature i)
61 {
62     if (i.type_ == "vdir")      
63         dir_i_ = i.value_;
64 }
65 void
66 Text_register::post_move_processing()
67 {
68     text_req_l_ = 0;
69 }
70 IMPLEMENT_STATIC_NAME(Text_register);
71 ADD_THIS_REGISTER(Text_register);