lilypond-1.1.31
[lilypond.git] / src / simpleprint.cc
blob7ded4a9c90b8d49dd5e67eb824169e933ae01e4c
1 #include "clefitem.hh"
2 #include "request.hh"
3 #include "pscore.hh"
4 #include "paper.hh"
5 #include "simplestaff.hh"
6 #include "sccol.hh"
7 #include "rest.hh"
8 #include "debug.hh"
9 #include "bar.hh"
10 #include "meter.hh"
12 Item *
13 Simple_staff::get_TYPESET_item(Command *com)
15 Item *s=0;
16 Array<Scalar> arg( com->args);
17 String type =arg[0];
18 arg.del(0);
19 if (type == "BAR" ) {
20 s = new Bar(com->args[1]);
21 } else if (type == "METER") {
22 s = new Meter(arg);
23 } else if (type == "CLEF" || type == "CURRENTCLEF") {
24 Clef_item * c = new Clef_item;
25 s = c;
26 c->change = (type == "CLEF");
27 }else{
28 WARN << "ignoring TYPESET command for " << type << '\n';
30 return s;
34 Interval
35 itemlist_width(const Array<Item*> &its)
37 Interval iv ;
38 iv.set_empty();
40 for (int j =0; j < its.size(); j++){
41 iv.unite (its[j]->width());
44 return iv;
47 void
48 Simple_column::typeset_item(Item *i, int breakst)
50 assert(i);
52 staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
53 staff_l_->theline_l_,breakst);
55 if (breakst == BREAK_PRE - BREAK_PRE) {
57 Array<Item*> to_move(
58 staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
59 score_column_l_->pcol_l_->prebreak_p_));
60 Interval column_wid = itemlist_width(to_move);
61 assert(!column_wid.empty());
63 for (int j=0; j < to_move.size(); j++) {
64 to_move[j]->translate(Offset(-column_wid.right, 0));
69 void
70 Simple_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH!
72 assert(i);
73 PCol * c=score_column_l_->pcol_l_;
74 if (breakst == 0)
75 c = c->prebreak_p_;
76 else if (breakst == 2)
77 c = c->postbreak_p_;
79 Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
80 c));
81 typeset_item(i, breakst);
83 Interval column_wid = itemlist_width(to_move);
84 if (column_wid.empty())
85 column_wid = Interval(0,0);
86 i->translate(Offset(column_wid[dir] - i->width()[-dir], 0));
89 void
90 Simple_staff::set_output(PScore* ps )
92 pscore_l_ = ps;
93 pscore_l_->add(theline_l_);
97 Rest*
98 Simple_staff::get_rest(Rest_req*rq)
100 int b = rq->rhythmic()->balltype;
101 int d = rq->rhythmic()->dots;
102 return new Rest(b, d);
105 Local_key_item*
106 Simple_staff::get_local_key_item()
108 return 0;