1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
1 |
/*
|
2 |
||
1686
by Adam Reichold
Merge page-numbers branch improving calculation of current page in continuous layouts. |
3 |
Copyright 2014 S. Razi Alavizadeh
|
4 |
Copyright 2013-2014 Adam Reichold
|
|
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
5 |
|
6 |
This file is part of qpdfview.
|
|
7 |
||
8 |
qpdfview is free software: you can redistribute it and/or modify
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
10 |
the Free Software Foundation, either version 2 of the License, or
|
|
11 |
(at your option) any later version.
|
|
12 |
||
13 |
qpdfview is distributed in the hope that it will be useful,
|
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
GNU General Public License for more details.
|
|
17 |
||
18 |
You should have received a copy of the GNU General Public License
|
|
19 |
along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
|
|
20 |
||
21 |
*/
|
|
22 |
||
23 |
#ifndef DOCUMENTLAYOUT_H
|
|
24 |
#define DOCUMENTLAYOUT_H
|
|
25 |
||
26 |
#include <QMap> |
|
1663
by Adam Reichold
Try to contain the proliferation of ad-hoc types for the extended bookmark implementation. |
27 |
#include <QPair> |
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
28 |
|
29 |
#include "global.h" |
|
30 |
||
1685.1.1
by Razi Alavizadeh
Fix computing current page. |
31 |
class QRectF; |
32 |
||
1518
by Adam Reichold
Make proper use of application and anonymous namespaces and fix a few header guards. |
33 |
namespace qpdfview |
34 |
{
|
|
35 |
||
1348.1.5
by Adam Reichold
Reduce settings singleton overhead in document layout class. |
36 |
class Settings; |
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
37 |
class PageItem; |
38 |
||
39 |
struct DocumentLayout |
|
40 |
{
|
|
1348.1.5
by Adam Reichold
Reduce settings singleton overhead in document layout class. |
41 |
DocumentLayout(); |
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
42 |
virtual ~DocumentLayout() {} |
43 |
||
1410
by Adam Reichold
Move handling of document view settings back into document view itself since embeddability is not a concern anymore. |
44 |
static DocumentLayout* fromLayoutMode(LayoutMode layoutMode); |
45 |
||
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
46 |
virtual LayoutMode layoutMode() const = 0; |
47 |
||
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
48 |
virtual int currentPage(int page) const = 0; |
49 |
virtual int previousPage(int page) const = 0; |
|
50 |
virtual int nextPage(int page, int count) const = 0; |
|
51 |
||
1686
by Adam Reichold
Merge page-numbers branch improving calculation of current page in continuous layouts. |
52 |
bool isCurrentPage(const QRectF& visibleRect, const QRectF& pageRect) const; |
1685.1.1
by Razi Alavizadeh
Fix computing current page. |
53 |
|
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
54 |
virtual QPair< int, int > prefetchRange(int page, int count) const = 0; |
55 |
||
56 |
virtual int leftIndex(int index) const = 0; |
|
57 |
virtual int rightIndex(int index, int count) const = 0; |
|
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
58 |
|
1348.1.2
by Adam Reichold
refine layout strategy interface and add preliminary implementation of multiple pages layout |
59 |
virtual qreal visibleWidth(int viewportWidth) const = 0; |
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
60 |
qreal visibleHeight(int viewportHeight) const; |
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
61 |
|
1464.1.2
by Adam Reichold
Make multiple-page layout RTL-aware and add corresponding setting. |
62 |
virtual void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
1685.1.1
by Razi Alavizadeh
Fix computing current page. |
63 |
qreal& left, qreal& right, qreal& height) = 0; |
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
64 |
|
1348.1.5
by Adam Reichold
Reduce settings singleton overhead in document layout class. |
65 |
protected: |
66 |
static Settings* s_settings; |
|
67 |
||
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
68 |
};
|
69 |
||
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
70 |
struct SinglePageLayout : public DocumentLayout |
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
71 |
{
|
72 |
LayoutMode layoutMode() const { return SinglePageMode; } |
|
73 |
||
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
74 |
int currentPage(int page) const; |
75 |
int previousPage(int page) const; |
|
76 |
int nextPage(int page, int count) const; |
|
77 |
||
78 |
QPair< int, int > prefetchRange(int page, int count) const; |
|
79 |
||
80 |
int leftIndex(int index) const; |
|
81 |
int rightIndex(int index, int count) const; |
|
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
82 |
|
83 |
qreal visibleWidth(int viewportWidth) const; |
|
84 |
||
1686
by Adam Reichold
Merge page-numbers branch improving calculation of current page in continuous layouts. |
85 |
void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
86 |
qreal& left, qreal& right, qreal& height); |
|
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
87 |
|
88 |
};
|
|
89 |
||
90 |
struct TwoPagesLayout : public DocumentLayout |
|
91 |
{
|
|
92 |
LayoutMode layoutMode() const { return TwoPagesMode; } |
|
93 |
||
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
94 |
int currentPage(int page) const; |
95 |
int previousPage(int page) const; |
|
96 |
int nextPage(int page, int count) const; |
|
97 |
||
98 |
QPair< int, int > prefetchRange(int page, int count) const; |
|
99 |
||
100 |
int leftIndex(int index) const; |
|
101 |
int rightIndex(int index, int count) const; |
|
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
102 |
|
103 |
qreal visibleWidth(int viewportWidth) const; |
|
104 |
||
1686
by Adam Reichold
Merge page-numbers branch improving calculation of current page in continuous layouts. |
105 |
void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
106 |
qreal& left, qreal& right, qreal& height); |
|
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
107 |
|
108 |
};
|
|
109 |
||
110 |
struct TwoPagesWithCoverPageLayout : public TwoPagesLayout |
|
111 |
{
|
|
112 |
LayoutMode layoutMode() const { return TwoPagesWithCoverPageMode; } |
|
113 |
||
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
114 |
int currentPage(int page) const; |
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
115 |
|
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
116 |
int leftIndex(int index) const; |
117 |
int rightIndex(int index, int count) const; |
|
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
118 |
|
119 |
};
|
|
120 |
||
121 |
struct MultiplePagesLayout : public DocumentLayout |
|
1348.1.2
by Adam Reichold
refine layout strategy interface and add preliminary implementation of multiple pages layout |
122 |
{
|
123 |
LayoutMode layoutMode() const { return MultiplePagesMode; } |
|
124 |
||
1348.1.4
by Adam Reichold
actually remove layout implementation from document view and adjust document layout interface accordingly |
125 |
int currentPage(int page) const; |
126 |
int previousPage(int page) const; |
|
127 |
int nextPage(int page, int count) const; |
|
128 |
||
129 |
QPair< int, int > prefetchRange(int page, int count) const; |
|
130 |
||
131 |
int leftIndex(int index) const; |
|
132 |
int rightIndex(int index, int count) const; |
|
1348.1.2
by Adam Reichold
refine layout strategy interface and add preliminary implementation of multiple pages layout |
133 |
|
134 |
qreal visibleWidth(int viewportWidth) const; |
|
135 |
||
1686
by Adam Reichold
Merge page-numbers branch improving calculation of current page in continuous layouts. |
136 |
void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
137 |
qreal& left, qreal& right, qreal& height); |
|
1348.1.3
by Adam Reichold
add last two missing layout strategies and actually create inheritance hierarchy |
138 |
|
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
139 |
};
|
140 |
||
1518
by Adam Reichold
Make proper use of application and anonymous namespaces and fix a few header guards. |
141 |
} // qpdfview |
142 |
||
1348.1.1
by Adam Reichold
add document layout class following strategy pattern |
143 |
#endif // DOCUMENTLAYOUT_H |