1 //=============================================================================
2 //  MuseScore
3 //  Music Composition & Notation
4 //
5 //  Copyright (C) 2002-2011 Werner Schweer
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License version 2
9 //  as published by the Free Software Foundation and appearing in
10 //  the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __PAGE_H__
14 #define __PAGE_H__
15 
16 #include "config.h"
17 #include "element.h"
18 #include "bsp.h"
19 
20 namespace Ms {
21 
22 class System;
23 class Text;
24 class Measure;
25 class XmlWriter;
26 class Score;
27 class MeasureBase;
28 
29 //---------------------------------------------------------
30 //   @@ Page
31 //   @P pagenumber int (read only)
32 //---------------------------------------------------------
33 
34 class Page final : public Element {
35       QList<System*> _systems;
36       int _no;                      // page number
37 #ifdef USE_BSP
38       BspTree bspTree;
39       void doRebuildBspTree();
40 #endif
41       bool bspTreeValid;
42 
43       QString replaceTextMacros(const QString&) const;
44       void drawHeaderFooter(QPainter*, int area, const QString&) const;
45 
46    public:
47       Page(Score*);
48       ~Page();
49 
clone()50       Page* clone() const override          { return new Page(*this); }
type()51       ElementType type() const override     { return ElementType::PAGE; }
systems()52       const QList<System*>& systems() const { return _systems;   }
systems()53       QList<System*>& systems()             { return _systems;   }
system(int idx)54       System* system(int idx)               { return _systems[idx];   }
55 
56       void write(XmlWriter&) const override;
57       void read(XmlReader&) override;
58 
59       void appendSystem(System* s);
60 
no()61       int no() const                     { return _no;        }
setNo(int n)62       void setNo(int n)                  { _no = n;           }
63       bool isOdd() const;
64       qreal tm() const;            // margins in pixel
65       qreal bm() const;
66       qreal lm() const;
67       qreal rm() const;
68 
69       void draw(QPainter*) const override;
70       void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
71 
72       QList<Element*> items(const QRectF& r);
73       QList<Element*> items(const QPointF& p);
rebuildBspTree()74       void rebuildBspTree()   { bspTreeValid = false; }
pagePos()75       QPointF pagePos() const override { return QPointF(); }     ///< position in page coordinates
76       QList<Element*> elements();               ///< list of visible elements
77       QRectF tbbox();                           // tight bounding box, excluding white space
78       Fraction endTick() const;
79       };
80 
81 
82 
83 }     // namespace Ms
84 #endif
85