Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #ifndef MU_ENGRAVING_READPAGEFORMAT_H
23 : #define MU_ENGRAVING_READPAGEFORMAT_H
24 :
25 : #include "draw/types/geometry.h"
26 :
27 : namespace mu::engraving {
28 : class MStyle;
29 : class XmlReader;
30 : }
31 :
32 : namespace mu::engraving::compat {
33 : //---------------------------------------------------------
34 : // @@ PageFormat
35 : //---------------------------------------------------------
36 :
37 : class PageFormat
38 : {
39 : muse::SizeF _size;
40 : double _printableWidth; // _width - left margin - right margin
41 : double _evenLeftMargin; // values in inch
42 : double _oddLeftMargin;
43 : double _evenTopMargin;
44 : double _evenBottomMargin;
45 : double _oddTopMargin;
46 : double _oddBottomMargin;
47 : bool _twosided;
48 :
49 : public:
50 53 : PageFormat() {}
51 :
52 158 : const muse::SizeF& size() const { return _size; } // size in inch
53 : double width() const { return _size.width(); }
54 : double height() const { return _size.height(); }
55 79 : void setSize(const muse::SizeF& s) { _size = s; }
56 :
57 : void read206(XmlReader&);
58 :
59 79 : double evenLeftMargin() const { return _evenLeftMargin; }
60 79 : double oddLeftMargin() const { return _oddLeftMargin; }
61 53 : double evenTopMargin() const { return _evenTopMargin; }
62 53 : double evenBottomMargin() const { return _evenBottomMargin; }
63 53 : double oddTopMargin() const { return _oddTopMargin; }
64 53 : double oddBottomMargin() const { return _oddBottomMargin; }
65 53 : double printableWidth() const { return _printableWidth; }
66 :
67 79 : void setEvenLeftMargin(double val) { _evenLeftMargin = val; }
68 79 : void setOddLeftMargin(double val) { _oddLeftMargin = val; }
69 79 : void setEvenTopMargin(double val) { _evenTopMargin = val; }
70 79 : void setEvenBottomMargin(double val) { _evenBottomMargin = val; }
71 79 : void setOddTopMargin(double val) { _oddTopMargin = val; }
72 79 : void setOddBottomMargin(double val) { _oddBottomMargin = val; }
73 79 : void setPrintableWidth(double val) { _printableWidth = val; }
74 :
75 53 : bool twosided() const { return _twosided; }
76 103 : void setTwosided(bool val) { _twosided = val; }
77 :
78 : // convenience functions
79 : double evenRightMargin() const { return _size.width() - _printableWidth - _evenLeftMargin; }
80 : double oddRightMargin() const { return _size.width() - _printableWidth - _oddLeftMargin; }
81 : };
82 :
83 : void initPageFormat(MStyle* style, PageFormat* pf);
84 : void setPageFormat(MStyle* style, const PageFormat& pf);
85 : void readPageFormat206(MStyle* style, XmlReader& e);
86 : }
87 : #endif // MU_ENGRAVING_READPAGEFORMAT_H
|