source: terepaima/terepaima-0.4.16/sources/documentlayout.h

desarrollostretch
Last change on this file was 1f4adec, checked in by aosorio <aosorio@…>, 8 years ago

Agregado proyecto base, esto luego del dh_make -f

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2
3Copyright 2014 S. Razi Alavizadeh
4Copyright 2013-2014 Adam Reichold
5
6This file is part of qpdfview.
7
8qpdfview is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13qpdfview is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along 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
31class QRectF;
32
33namespace qpdfview
34{
35
36class Settings;
37class PageItem;
38
39struct 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
65protected:
66    static Settings* s_settings;
67
68};
69
70struct 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
90struct 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
110struct 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
121struct 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
Note: See TracBrowser for help on using the repository browser.