]> git.donarmstrong.com Git - lilypond.git/blob - src/simpleprint.cc
release: 0.0.20
[lilypond.git] / src / simpleprint.cc
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"
11
12 Item *
13 Simple_staff::get_TYPESET_item(Command *com)
14 {
15     Item *s=0;
16     svec<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';
29     }
30     return s;
31 }
32
33
34 Interval
35 itemlist_width(const svec<Item*> &its)
36 {
37     Interval iv ;
38     iv.set_empty();
39      
40     for (int j =0; j < its.sz(); j++){
41         iv.unite (its[j]->width());
42
43     }
44     return iv;
45 }
46
47 void
48 Simple_column::typeset_item(Item *i, int breakst)
49 {
50     assert(i);
51     
52     staff_->pscore_->typeset_item(i, score_column->pcol_,
53                                   staff_->theline,breakst);
54     
55     if (breakst == BREAK_PRE - BREAK_PRE) {
56         
57         svec<Item*> to_move(
58             staff_->pscore_->select_items(staff_->theline,
59                                           score_column->pcol_->prebreak));
60         Interval column_wid = itemlist_width(to_move);
61         assert(!column_wid.empty());
62
63         for (int j=0; j < to_move.sz(); j++) {
64             to_move[j]->translate(Offset(-column_wid.right, 0));
65         }
66     }
67 }    
68
69 void
70 Simple_column::typeset_item_directional(Item *i, int dir, int breakst)
71 {
72     assert(i);
73     PCol * c=score_column->pcol_;
74     if (breakst == 0)
75         c = c->prebreak;
76     else if (breakst == 2)
77         c = c->postbreak;
78     
79     svec<Item*> to_move(staff_->pscore_->select_items(staff_->theline,
80                                                       c));    
81     typeset_item(i, breakst);
82
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));
87 }
88
89 void
90 Simple_staff::set_output(PScore* ps )
91 {
92     pscore_ = ps;
93     pscore_->add(theline);
94 }
95
96
97 Rest*
98 Simple_staff::get_rest(Rest_req*rq)
99 {
100     int b = rq->rhythmic()->balltype;
101     int d = rq->rhythmic()->dots;
102     return new Rest(b, d);  
103 }
104
105 Local_key_item*
106 Simple_staff::get_local_key_item()
107 {
108     return 0;
109 }
110