[1f4adec] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright 2014 S. Razi Alavizadeh |
---|
| 4 | Copyright 2013-2014 Adam Reichold |
---|
| 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> |
---|
| 27 | #include <QPair> |
---|
| 28 | |
---|
| 29 | #include "global.h" |
---|
| 30 | |
---|
| 31 | class QRectF; |
---|
| 32 | |
---|
| 33 | namespace qpdfview |
---|
| 34 | { |
---|
| 35 | |
---|
| 36 | class Settings; |
---|
| 37 | class PageItem; |
---|
| 38 | |
---|
| 39 | struct DocumentLayout |
---|
| 40 | { |
---|
| 41 | DocumentLayout(); |
---|
| 42 | virtual ~DocumentLayout() {} |
---|
| 43 | |
---|
| 44 | static DocumentLayout* fromLayoutMode(LayoutMode layoutMode); |
---|
| 45 | |
---|
| 46 | virtual LayoutMode layoutMode() const = 0; |
---|
| 47 | |
---|
| 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 | |
---|
| 52 | bool isCurrentPage(const QRectF& visibleRect, const QRectF& pageRect) const; |
---|
| 53 | |
---|
| 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; |
---|
| 58 | |
---|
| 59 | virtual qreal visibleWidth(int viewportWidth) const = 0; |
---|
| 60 | qreal visibleHeight(int viewportHeight) const; |
---|
| 61 | |
---|
| 62 | virtual void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
---|
| 63 | qreal& left, qreal& right, qreal& height) = 0; |
---|
| 64 | |
---|
| 65 | protected: |
---|
| 66 | static Settings* s_settings; |
---|
| 67 | |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | struct SinglePageLayout : public DocumentLayout |
---|
| 71 | { |
---|
| 72 | LayoutMode layoutMode() const { return SinglePageMode; } |
---|
| 73 | |
---|
| 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; |
---|
| 82 | |
---|
| 83 | qreal visibleWidth(int viewportWidth) const; |
---|
| 84 | |
---|
| 85 | void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
---|
| 86 | qreal& left, qreal& right, qreal& height); |
---|
| 87 | |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | struct TwoPagesLayout : public DocumentLayout |
---|
| 91 | { |
---|
| 92 | LayoutMode layoutMode() const { return TwoPagesMode; } |
---|
| 93 | |
---|
| 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; |
---|
| 102 | |
---|
| 103 | qreal visibleWidth(int viewportWidth) const; |
---|
| 104 | |
---|
| 105 | void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
---|
| 106 | qreal& left, qreal& right, qreal& height); |
---|
| 107 | |
---|
| 108 | }; |
---|
| 109 | |
---|
| 110 | struct TwoPagesWithCoverPageLayout : public TwoPagesLayout |
---|
| 111 | { |
---|
| 112 | LayoutMode layoutMode() const { return TwoPagesWithCoverPageMode; } |
---|
| 113 | |
---|
| 114 | int currentPage(int page) const; |
---|
| 115 | |
---|
| 116 | int leftIndex(int index) const; |
---|
| 117 | int rightIndex(int index, int count) const; |
---|
| 118 | |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | struct MultiplePagesLayout : public DocumentLayout |
---|
| 122 | { |
---|
| 123 | LayoutMode layoutMode() const { return MultiplePagesMode; } |
---|
| 124 | |
---|
| 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; |
---|
| 133 | |
---|
| 134 | qreal visibleWidth(int viewportWidth) const; |
---|
| 135 | |
---|
| 136 | void prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft, |
---|
| 137 | qreal& left, qreal& right, qreal& height); |
---|
| 138 | |
---|
| 139 | }; |
---|
| 140 | |
---|
| 141 | } // qpdfview |
---|
| 142 | |
---|
| 143 | #endif // DOCUMENTLAYOUT_H |
---|