]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/command-request.hh
3e187487f3895eee0d4dd0c9dc4fadac1b2fa07f
[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. */
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 };
36
37
38 class Break_req : public Command_req {
39 public:
40   enum { DISALLOW = -10000, FORCE = 10000 };
41   int penalty_i_;
42   Break_req ();
43   REQUESTMETHODS (Break_req);
44 };
45
46 class Mark_req : public Command_req {
47 public:
48   Mark_req (String);
49   String str_;
50   REQUESTMETHODS (Mark_req);
51 };
52
53 class Command_script_req : public Command_req,  public Script_req {
54 public:
55   // huh? 
56   Command_script_req();
57   ~Command_script_req();
58   REQUESTMETHODS(Command_script_req);
59 };
60
61 /** Baseclass for time_signature/partial req. It has to be handled by
62   Staff_{walker,column} baseclass.  */
63 class Timing_req  : public Command_req  {
64 public:
65   REQUESTMETHODS(Timing_req);
66   DEFAULTACCESSOR(Tempo_req)
67 };
68
69
70 class Tempo_req : public Timing_req
71 {
72 public:
73   Duration dur_;
74   int metronome_i_;
75
76   Tempo_req();
77   REQUESTMETHODS(Tempo_req);
78   bool do_equal_b (Request *) const;
79 };
80
81 class Partial_measure_req  : public Timing_req  {
82 public:
83   Moment duration_;
84
85   Partial_measure_req (Moment);
86   REQUESTMETHODS(Partial_measure_req);
87   bool do_equal_b (Request*) const;
88 };
89
90 /**
91   todo: allow C time_signature
92  */
93 class Time_signature_change_req  : public Timing_req  {
94 public:
95   int beats_i_, one_beat_i_;
96
97   Time_signature_change_req();
98   bool do_equal_b (Request*) const;
99   REQUESTMETHODS(Time_signature_change_req);
100 };
101
102 /// toggle Cadenza mode
103 class Cadenza_req  : public Timing_req  {
104 public:
105   /// turn on?
106   bool on_b_;
107   bool do_equal_b (Request*) const;
108   Cadenza_req (bool);
109   REQUESTMETHODS(Cadenza_req);
110 };
111
112 /// check if we're at start of a  measure.
113 class Barcheck_req  : public Timing_req  {
114 public:
115   bool do_equal_b (Request *) const;
116   REQUESTMETHODS(Barcheck_req);
117 };
118
119 class Measure_grouping_req : public Timing_req  {
120 public:
121   Array<int> beat_i_arr_;
122   Array<Moment> elt_length_arr_;
123   bool do_equal_b (Request *) const;
124   REQUESTMETHODS(Measure_grouping_req);
125 };
126
127 /** draw a (repeat)-bar. This something different than #Barcheck_req#,
128   the latter should only happen at the start of a measure.  */
129 class Bar_req  : public Command_req  {
130 public:
131   String type_str_;
132   Bar_req (String);
133   bool do_equal_b (Request*) const;
134
135   REQUESTMETHODS(Bar_req);
136 };
137
138
139 /**
140     Handle key changes.
141     Routines for sharps and flats are separated, 
142     so that caller may identify non-conventional keys.
143 */
144 class Key_change_req  : public Command_req  {
145 public:
146   Array<Musical_pitch> pitch_arr_;
147   bool minor_b_;
148   bool ordinary_key_b_;
149
150   Key_change_req();
151   REQUESTMETHODS(Key_change_req);
152
153   /// squash the octaves to 1
154   void squash_octaves();
155   /// return number of flats in key
156   int flats_i();
157
158   /// return number of sharps in key
159   int sharps_i();
160
161   void transpose (Musical_pitch  d);
162   /// is minor key?
163   bool minor_b() const;
164 };
165
166 class Clef_change_req  : public Command_req  {
167 public:
168   String clef_str_;
169   Clef_change_req (String);
170   REQUESTMETHODS(Clef_change_req);
171 };
172
173 #endif // COMMANDREQUEST_HH