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