]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/command-request.hh
a0afdc8f5e996765fa9bc54dce9d2fee455e8ea3
[lilypond.git] / lily / include / command-request.hh
1 /*
2   command-request.hh -- declare non-musical requests
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef COMMANDREQUEST_HH
11 #define COMMANDREQUEST_HH
12
13 #include "request.hh"
14 #include "array.hh"
15 #include "duration.hh"
16 #include "musical-pitch.hh"
17
18 /** Request which are  assumed to be "happening" before the
19   musical requests.  Not coupled to a note or rest. */
20 class Command_req  : public virtual Request  {
21 public:
22   REQUESTMETHODS(Command_req);
23
24     DEFAULTACCESSOR(Measure_grouping_req)
25     DEFAULTACCESSOR(Clef_change_req)
26     DEFAULTACCESSOR(Key_change_req)
27     DEFAULTACCESSOR(Partial_measure_req)
28     DEFAULTACCESSOR(Time_signature_change_req)
29     DEFAULTACCESSOR(Bar_req)
30     DEFAULTACCESSOR(Cadenza_req)
31     DEFAULTACCESSOR(Timing_req)
32     DEFAULTACCESSOR(Command_script_req)
33     DEFAULTACCESSOR(Break_req)
34     DEFAULTACCESSOR(Mark_req)
35   DEFAULTACCESSOR(Bracket_req)
36 };
37
38
39 class Break_req : public Command_req {
40 public:
41   enum { DISALLOW = -10000, FORCE = 10000 };
42   int penalty_i_;
43   Break_req ();
44   REQUESTMETHODS (Break_req);
45 };
46
47 class Mark_req : public Command_req {
48 public:
49   Mark_req (String);
50   String str_;
51   REQUESTMETHODS (Mark_req);
52 };
53
54 class Command_script_req : public Command_req,  public Script_req {
55 public:
56   // huh? 
57   Command_script_req();
58   ~Command_script_req();
59   REQUESTMETHODS(Command_script_req);
60 };
61
62 /** Baseclass for time_signature/partial req. It has to be handled by
63   Staff_{walker,column} baseclass.  */
64 class Timing_req  : public Command_req  {
65 public:
66   REQUESTMETHODS(Timing_req);
67   DEFAULTACCESSOR(Tempo_req)
68 };
69
70
71 class Tempo_req : public Timing_req
72 {
73 public:
74   Duration dur_;
75   int metronome_i_;
76
77   Tempo_req();
78   REQUESTMETHODS(Tempo_req);
79   bool do_equal_b (Request *) const;
80 };
81
82 class Partial_measure_req  : public Timing_req  {
83 public:
84   Moment duration_;
85
86   Partial_measure_req (Moment);
87   REQUESTMETHODS(Partial_measure_req);
88   bool do_equal_b (Request*) const;
89 };
90
91 /**
92   todo: allow C time_signature
93  */
94 class Time_signature_change_req  : public Timing_req  {
95 public:
96   int beats_i_, one_beat_i_;
97
98   Time_signature_change_req();
99   bool do_equal_b (Request*) const;
100   REQUESTMETHODS(Time_signature_change_req);
101 };
102
103 /// toggle Cadenza mode
104 class Cadenza_req  : public Timing_req  {
105 public:
106   /// turn on?
107   bool on_b_;
108   bool do_equal_b (Request*) const;
109   Cadenza_req (bool);
110   REQUESTMETHODS(Cadenza_req);
111 };
112
113 /// check if we're at start of a  measure.
114 class Barcheck_req  : public Timing_req  {
115 public:
116   bool do_equal_b (Request *) const;
117   REQUESTMETHODS(Barcheck_req);
118 };
119
120 class Measure_grouping_req : public Timing_req  {
121 public:
122   Array<int> beat_i_arr_;
123   Array<Moment> elt_length_arr_;
124   bool do_equal_b (Request *) const;
125   REQUESTMETHODS(Measure_grouping_req);
126 };
127
128 /** draw a (repeat)-bar. This something different than #Barcheck_req#,
129   the latter should only happen at the start of a measure.  */
130 class Bar_req  : public Command_req  {
131 public:
132   String type_str_;
133   Bar_req (String);
134   bool do_equal_b (Request*) const;
135
136   REQUESTMETHODS(Bar_req);
137 };
138
139
140 /**
141     Handle key changes.
142     Routines for sharps and flats are separated, 
143     so that caller may identify non-conventional keys.
144 */
145 class Key_change_req  : public Command_req  {
146 public:
147   Array<Musical_pitch> pitch_arr_;
148   bool minor_b_;
149   bool ordinary_key_b_;
150
151   Key_change_req();
152   REQUESTMETHODS(Key_change_req);
153
154   /// squash the octaves to 1
155   void squash_octaves();
156   /// return number of flats in key
157   int flats_i();
158
159   /// return number of sharps in key
160   int sharps_i();
161
162   void transpose (Musical_pitch  d);
163   /// is minor key?
164   bool minor_b() const;
165 };
166
167 class Clef_change_req  : public Command_req  {
168 public:
169   String clef_str_;
170   Clef_change_req (String);
171   REQUESTMETHODS(Clef_change_req);
172 };
173
174 class Bracket_req :  public Span_req, public Command_req {
175
176 public:
177   REQUESTMETHODS(Bracket_req);
178 };
179
180 #endif // COMMANDREQUEST_HH