File indexing completed on 2024-05-19 16:10:01

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001 David Faure <faure@kde.org>
0003  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KWVIEWMODENORMAL_H
0022 #define KWVIEWMODENORMAL_H
0023 
0024 #include "KWViewMode.h"
0025 
0026 #include <QString>
0027 #include <QList>
0028 
0029 /**
0030  * This is one viewmode strategy used by the canvas to map the internal page layout to
0031  * one that users want to see.
0032  * The document-internal structure places one page below another, with page-padding in
0033  * in between. This strategy is mirrored
0034  * in this viewmode.  Only when there is at least one PageSpread kind of page will the
0035  * behavior change slightly.  A pagespread type page is what the user will perceive as
0036  * 2 pages, but Words internally sees as one big page with a special type.  Since it is
0037  * about twice as wide as normal pages this viewmode will try to layout the rest of
0038  * the pages side by side.
0039  * @see KWViewMode
0040  */
0041 class WORDS_EXPORT KWViewModeNormal : public KWViewMode
0042 {
0043     Q_OBJECT
0044 public:
0045     /**
0046      * Constructor; please use KWViewMode::create()
0047      */
0048     KWViewModeNormal();
0049     ~KWViewModeNormal() override {}
0050 
0051     using KWViewMode::documentToView;
0052 
0053     QPointF documentToView(const QPointF &point, KoViewConverter *viewConverter) const override;
0054     QPointF viewToDocument(const QPointF &point, KoViewConverter *viewConverter) const override;
0055     QSizeF contentsSize() const override {
0056         return m_contents;
0057     }
0058 
0059     /// return a string identification of this viewMode
0060     static const QString viewMode() {
0061         return "ModeNormal";
0062     }
0063     const QString type() const override {
0064         return KWViewModeNormal::viewMode();
0065     }
0066     QVector<ViewMap> mapExposedRects(const QRectF &clipRect, KoViewConverter *viewConverter) const override;
0067 
0068 protected:
0069     void updatePageCache() override;
0070 
0071     // a list with the top of the page location in view-coordinates, in unzoomed-pt.
0072     QList<qreal> m_pageTops;
0073     bool m_pageSpreadMode;
0074     QSizeF m_contents;
0075 };
0076 
0077 #endif