]> git.donarmstrong.com Git - lilypond.git/blob - simpleprint.cc
release: 0.0.6
[lilypond.git] / simpleprint.cc
1 #include "lookupsyms.hh"
2 #include "request.hh"
3 #include "pscore.hh"
4 #include "paper.hh"
5 #include "simplestaff.hh"
6 #include "molecule.hh"
7 #include "sccol.hh"
8
9 Item *
10 Simple_column::create_req_item(Request *rq)
11 {
12     Item *i = new Item;
13     Symbol s;
14     int dots=0;
15
16     if (rq->note())
17         s = staff_->paper()->lookup_->ball(rq->note()->balltype);
18     else if (rq->rest())
19         s = staff_->paper()->lookup_->rest(rq->rest()->balltype);
20
21     if (rq->rhythmic())
22         dots=rq->rhythmic()->dots;
23
24
25     Molecule *m = new Molecule(Atom(s));
26     if (dots) {
27         Symbol d = staff_->paper()->lookup_->dots(dots);
28         Molecule dm;
29         dm.add(Atom(d));
30         m->add_right(dm);
31     }
32     i->output=m;
33     return i;
34 }
35 Item *
36 Simple_column::create_command_item(Command *com)
37 {
38     Item *i = new Item;
39     Symbol s;
40
41     if (com -> args[0] ==  "BAR" ) {
42         s = staff_->paper()->lookup_->bar(com->args[1]);        
43     } else if (com->args[0] == "METER") {
44         Parametric_symbol *p = staff_->paper()->lookup_->meter("general");
45         svec<String> arg( com->args);
46         arg.del(0);
47         s = p->eval(arg);
48     } else
49         assert(false);
50
51     Molecule * m =new Molecule(Atom(s));
52     {
53         Interval wid;
54         svec<Item*> sv(staff_->pscore_->
55                        select_items(staff_->theline, score_column->pcol));
56         for (int j=0; j<sv.sz(); j++) {
57             wid.unite(sv[j]->output->extent().x);
58         }
59         if (!wid.empty())
60             m->translate(Offset(wid.max,0));
61     }
62     i->output=m;
63     return i;
64 }
65
66 void
67 Simple_column::typeset_item(Item *i, int breakst)
68 {
69     // ugh
70     staff_->pscore_->typeset_item(i, score_column->pcol,
71                                   staff_->theline,breakst);
72 }
73
74 void
75 Simple_staff::set_output(PScore* ps )
76 {
77     pscore_ = ps;
78     pscore_->add(theline);
79 }