LibMusicXML 3.18
msrLayouts.h
1/*
2 MusicXML Library
3 Copyright (C) Grame 2006-2013
4
5 This Source Code Form is subject to the terms of the Mozilla Public
6 License, v. 2.0. If a copy of the MPL was not distributed with this
7 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9 Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10 research@grame.fr
11*/
12
13#ifndef ___msrLayout___
14#define ___msrLayout___
15
16#include "msrElements.h"
17
18#include "msrBasicTypes.h"
19
20
21namespace MusicXML2
22{
23
24//______________________________________________________________________________
26{
27/*
28<!--
29 Page layout can be defined both in score-wide defaults
30 and in the print element. Page margins are specified either
31 for both even and odd pages, or via separate odd and even
32 page number values. The type is not needed when used as
33 part of a print element. If omitted when used in the
34 defaults element, "both" is the default.
35-->
36<!ELEMENT page-layout ((page-height, page-width)?,
37 (page-margins, page-margins?)?)>
38<!ELEMENT page-height %layout-tenths;>
39<!ELEMENT page-width %layout-tenths;>
40<!ELEMENT page-margins (left-margin, right-margin,
41 top-margin, bottom-margin)>
42<!ATTLIST page-margins
43 type (odd | even | both) #IMPLIED
44>
45*/
46
47 public:
48
49 // creation from MusicXML
50 // ------------------------------------------------------
51
52 static SMARTP<msrPageLayout> create (
53 int inputLineNumber);
54
55 protected:
56
57 // constructors/destructor
58 // ------------------------------------------------------
59
61 int inputLineNumber);
62
63 virtual ~msrPageLayout ();
64
65 public:
66
67 // set and get
68 // ------------------------------------------------------
69
70 // page size
71 void setPageHeight (S_msrLength val)
72 { fPageHeight = val; }
73 S_msrLength getPageHeight () const
74 { return fPageHeight; }
75
76 void setPageWidth (S_msrLength val)
77 { fPageWidth = val; }
78 S_msrLength getPageWidth () const
79 { return fPageWidth; }
80
81 // margins
82 void setLeftMargin (S_msrMargin val)
83 { fLeftMargin = val; }
84 S_msrMargin getLeftMargin () const
85 { return fLeftMargin; }
86
87 void setRightMargin (S_msrMargin val)
88 { fRightMargin = val; }
89 S_msrMargin getRightMargin () const
90 { return fRightMargin; }
91
92 void setTopMargin (S_msrMargin val)
93 { fTopMargin = val; }
94 S_msrMargin getTopMargin () const
95 { return fTopMargin; }
96
97 void setBottomMargin (S_msrMargin val)
98 { fBottomMargin = val; }
99 S_msrMargin getBottomMargin () const
100 { return fBottomMargin; }
101
102 public:
103
104 // services
105 // ------------------------------------------------------
106
107 public:
108
109 // visitors
110 // ------------------------------------------------------
111
112 virtual void acceptIn (basevisitor* v);
113 virtual void acceptOut (basevisitor* v);
114
115 virtual void browseData (basevisitor* v);
116
117 public:
118
119 // print
120 // ------------------------------------------------------
121
122 virtual void print (ostream& os) const;
123
124 private:
125
126 // fields
127 // ------------------------------------------------------
128
129 // page size
130 S_msrLength fPageHeight;
131 S_msrLength fPageWidth;
132
133 // margins
134 S_msrMargin fLeftMargin;
135 S_msrMargin fRightMargin;
136 S_msrMargin fTopMargin;
137 S_msrMargin fBottomMargin;
138};
140EXP ostream& operator<< (ostream& os, const S_msrPageLayout& elt);
141
142//______________________________________________________________________________
144{
145/*
146<!--
147 A system is a group of staves that are read and played
148 simultaneously. System layout includes left and right
149 margins, the vertical distance from the previous system,
150 and the presence or absence of system dividers.
151
152 Margins are relative to the page margins. Positive values
153 indent and negative values reduce the margin size. The
154 system distance is measured from the bottom line of the
155 previous system to the top line of the current system.
156 It is ignored for the first system on a page. The top
157 system distance is measured from the page's top margin to
158 the top line of the first system. It is ignored for all
159 but the first system on a page.
160
161 Sometimes the sum of measure widths in a system may not
162 equal the system width specified by the layout elements due
163 to roundoff or other errors. The behavior when reading
164 MusicXML files in these cases is application-dependent.
165 For instance, applications may find that the system layout
166 data is more reliable than the sum of the measure widths,
167 and adjust the measure widths accordingly.
168
169 When used in the layout element, the system-layout element
170 defines a default appearance for all systems in the score.
171 When used in the print element, the system layout element
172 affects the appearance of the current system only. All
173 other systems use the default values provided in the
174 defaults element. If any child elements are missing from
175 the system-layout element in a print element, the values
176 from the defaults element are used there as well.
177-->
178<!ELEMENT system-layout
179 (system-margins?, system-distance?,
180 top-system-distance?, system-dividers?)>
181<!ELEMENT system-margins (left-margin, right-margin)>
182<!ELEMENT system-distance %layout-tenths;>
183<!ELEMENT top-system-distance %layout-tenths;>
184*/
185
186 public:
187
188 // creation from MusicXML
189 // ------------------------------------------------------
190
191 static SMARTP<msrSystemLayout> create (
192 int inputLineNumber);
193
194 protected:
195
196 // constructors/destructor
197 // ------------------------------------------------------
198
200 int inputLineNumber);
201
202 virtual ~msrSystemLayout ();
203
204 public:
205
206 // set and get
207 // ------------------------------------------------------
208
209 // margins
210 void setLeftMargin (S_msrMargin val)
211 { fLeftMargin = val; }
212 S_msrMargin getLeftMargin () const
213 { return fLeftMargin; }
214
215 void setRightMargin (S_msrMargin val)
216 { fRightMargin = val; }
217 S_msrMargin getRightMargin () const
218 { return fRightMargin; }
219
220 // distances
221 void setSystemDistance (S_msrLength val)
222 { fSystemDistance = val; }
223 S_msrLength getSystemDistance () const
224 { return fSystemDistance; }
225
226 void setTopSystemDistance (S_msrLength val)
227 { fTopSystemDistance = val; }
228 S_msrLength getTopSystemDistance () const
229 { return fTopSystemDistance; }
230
231 public:
232
233 // services
234 // ------------------------------------------------------
235
236 public:
237
238 // visitors
239 // ------------------------------------------------------
240
241 virtual void acceptIn (basevisitor* v);
242 virtual void acceptOut (basevisitor* v);
243
244 virtual void browseData (basevisitor* v);
245
246 public:
247
248 // print
249 // ------------------------------------------------------
250
251 virtual void print (ostream& os) const;
252
253 private:
254
255 // fields
256 // ------------------------------------------------------
257
258 // margins
259 S_msrMargin fLeftMargin;
260 S_msrMargin fRightMargin;
261
262 // distances
263 S_msrLength fSystemDistance;
264 S_msrLength fTopSystemDistance;
265};
267EXP ostream& operator<< (ostream& os, const S_msrSystemLayout& elt);
268
269//______________________________________________________________________________
271{
272/*
273<!--
274 The system-dividers element indicates the presence or
275 absence of system dividers (also known as system separation
276 marks) between systems displayed on the same page. Dividers
277 on the left and right side of the page are controlled by
278 the left-divider and right-divider elements respectively.
279 The default vertical position is half the system-distance
280 value from the top of the system that is below the divider.
281 The default horizontal position is the left and right
282 system margin, respectively.
283
284 When used in the print element, the system-dividers element
285 affects the dividers that would appear between the current
286 system and the previous system.
287-->
288<!ELEMENT system-dividers (left-divider, right-divider)>
289<!ELEMENT left-divider EMPTY>
290<!ATTLIST left-divider
291 %print-object;
292 %print-style-align;
293>
294<!ELEMENT right-divider EMPTY>
295<!ATTLIST right-divider
296 %print-object;
297 %print-style-align;
298>
299
300 <system-layout>
301 <system-margins>
302 <left-margin>0</left-margin>
303 <right-margin>0</right-margin>
304 </system-margins>
305 <system-distance>39</system-distance>
306 <top-system-distance>39</top-system-distance>
307 <system-dividers>
308 <left-divider print-object="yes"/>
309 <right-divider print-object="no"/>
310 </system-dividers>
311 </system-layout>
312*/
313
314 public:
315
316 // creation from MusicXML
317 // ------------------------------------------------------
318
319 static SMARTP<msrSystemDividers> create (
320 int inputLineNumber);
321
322 protected:
323
324 // constructors/destructor
325 // ------------------------------------------------------
326
328 int inputLineNumber);
329
330 virtual ~msrSystemDividers ();
331
332 public:
333
334 // set and get
335 // ------------------------------------------------------
336
337 void setPrintLeftDivider (bool val)
338 { fPrintLeftDivider = val; }
339 bool getPrintLeftDivider () const
340 { return fPrintLeftDivider; }
341
342 void setPrintRightDivider (bool val)
343 { fPrintRightDivider = val; }
344 bool getPrintRightDivider () const
345 { return fPrintRightDivider; }
346
347 public:
348
349 // services
350 // ------------------------------------------------------
351
352 public:
353
354 // visitors
355 // ------------------------------------------------------
356
357 virtual void acceptIn (basevisitor* v);
358 virtual void acceptOut (basevisitor* v);
359
360 virtual void browseData (basevisitor* v);
361
362 public:
363
364 // print
365 // ------------------------------------------------------
366
367 virtual void print (ostream& os) const;
368
369 private:
370
371 // fields
372 // ------------------------------------------------------
373
374 // staff number
375 bool fPrintLeftDivider;
376 bool fPrintRightDivider;
377};
379EXP ostream& operator<< (ostream& os, const S_msrSystemDividers& elt);
380
381//______________________________________________________________________________
383{
384/*
385<!--
386 Staff layout includes the vertical distance from the bottom
387 line of the previous staff in this system to the top line
388 of the staff specified by the number attribute. The
389 optional number attribute refers to staff numbers within
390 the part, from top to bottom on the system. A value of 1
391 is assumed if not present. When used in the defaults
392 element, the values apply to all parts. This value is
393 ignored for the first staff in a system.
394-->
395<!ELEMENT staff-layout (staff-distance?)>
396<!ELEMENT staff-distance %layout-tenths;>
397<!ATTLIST staff-layout
398 number CDATA #IMPLIED
399>
400*/
401
402 public:
403
404 // creation from MusicXML
405 // ------------------------------------------------------
406
407 static SMARTP<msrStaffLayout> create (
408 int inputLineNumber);
409
410 protected:
411
412 // constructors/destructor
413 // ------------------------------------------------------
414
416 int inputLineNumber);
417
418 virtual ~msrStaffLayout ();
419
420 public:
421
422 // set and get
423 // ------------------------------------------------------
424
425 // staff number
426 void setStaffNumber (int val)
427 { fStaffNumber = val; }
428 int getStaffNumber () const
429 { return fStaffNumber; }
430
431 // staff distance
432 void setStaffDistance (S_msrLength val)
433 { fStaffDistance = val; }
434 S_msrLength getStaffDistance () const
435 { return fStaffDistance; }
436
437 public:
438
439 // services
440 // ------------------------------------------------------
441
442 public:
443
444 // visitors
445 // ------------------------------------------------------
446
447 virtual void acceptIn (basevisitor* v);
448 virtual void acceptOut (basevisitor* v);
449
450 virtual void browseData (basevisitor* v);
451
452 public:
453
454 // print
455 // ------------------------------------------------------
456
457 virtual void print (ostream& os) const;
458
459 private:
460
461 // fields
462 // ------------------------------------------------------
463
464 // staff number
465 int fStaffNumber;
466
467 // staff distance
468 S_msrLength fStaffDistance;
469};
471EXP ostream& operator<< (ostream& os, const S_msrStaffLayout& elt);
472
473//______________________________________________________________________________
475{
476/*
477<!--
478 Measure layout includes the horizontal distance from the
479 previous measure. This value is only used for systems
480 where there is horizontal whitespace in the middle of a
481 system, as in systems with codas. To specify the measure
482 width, use the width attribute of the measure element.
483-->
484<!ELEMENT measure-layout (measure-distance?)>
485<!ELEMENT measure-distance %layout-tenths;>
486*/
487
488 public:
489
490 // creation from MusicXML
491 // ------------------------------------------------------
492
493 static SMARTP<msrMeasureLayout> create (
494 int inputLineNumber);
495
496 protected:
497
498 // constructors/destructor
499 // ------------------------------------------------------
500
502 int inputLineNumber);
503
504 virtual ~msrMeasureLayout ();
505
506 public:
507
508 // set and get
509 // ------------------------------------------------------
510
511 // measure distance
512 void setMeasureDistance (S_msrLength val)
513 { fMeasureDistance = val; }
514 S_msrLength getMeasureDistance () const
515 { return fMeasureDistance; }
516
517 // services
518 // ------------------------------------------------------
519
520 public:
521
522 // visitors
523 // ------------------------------------------------------
524
525 virtual void acceptIn (basevisitor* v);
526 virtual void acceptOut (basevisitor* v);
527
528 virtual void browseData (basevisitor* v);
529
530 public:
531
532 // print
533 // ------------------------------------------------------
534
535 virtual void print (ostream& os) const;
536
537 private:
538
539 // fields
540 // ------------------------------------------------------
541
542 // measure distance
543 S_msrLength fMeasureDistance;
544};
546EXP ostream& operator<< (ostream& os, const S_msrMeasureLayout& elt);
547
548
549} // namespace MusicXML2
550
551
552#endif
Definition: basevisitor.h:25
Definition: msrElements.h:26
Definition: msrLayouts.h:475
Definition: msrLayouts.h:26
Definition: msrLayouts.h:383
Definition: msrLayouts.h:271
Definition: msrLayouts.h:144