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