Warning, file /office/calligra/libs/pageapp/KoPACanvasBase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002    Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KOPACANVASBASE_H
0021 #define KOPACANVASBASE_H
0022 
0023 #include <KoCanvasBase.h>
0024 
0025 #include "kopageapp_export.h"
0026 
0027 class KoPAViewBase;
0028 class KoPADocument;
0029 
0030 class QRect;
0031 class QPainter;
0032 
0033 /// Widget that shows a KoPAPage
0034 class KOPAGEAPP_EXPORT KoPACanvasBase : public KoCanvasBase
0035 {
0036 
0037 public:
0038     explicit KoPACanvasBase( KoPADocument * doc );
0039     ~KoPACanvasBase() override;
0040 
0041     /// set the viewbase on the canvas; this needs to be called before the canvas can be used.
0042     void setView(KoPAViewBase *view);
0043 
0044     /// Update the canvas
0045     virtual void repaint() = 0;
0046 
0047     /// Returns pointer to the KoPADocument
0048     KoPADocument* document() const;
0049 
0050     /// reimplemented method
0051     void gridSize( qreal *horizontal, qreal *vertical ) const override;
0052     /// reimplemented method
0053     bool snapToGrid() const override;
0054     /// reimplemented method
0055     void addCommand( KUndo2Command *command ) override;
0056     /// reimplemented method
0057     KoShapeManager * shapeManager() const override;
0058     KoShapeManager * masterShapeManager() const;
0059     /// reimplemented from KoCanvasBase
0060     KoGuidesData * guidesData() override;
0061 
0062     KoToolProxy * toolProxy() const override;
0063     KoViewConverter *viewConverter() const override;
0064     KoUnit unit() const override;
0065 
0066     /// XXX
0067     void setDocumentOffset(const QPoint &offset);
0068 
0069     /// XXX
0070     const QPoint & documentOffset() const;
0071 
0072     /// reimplemented in view coordinates
0073     QPoint documentOrigin() const override;
0074     /// Set the origin of the page inside the canvas in document coordinates
0075     void setDocumentOrigin(const QPointF & origin);
0076 
0077     KoPAViewBase* koPAView () const;
0078 
0079     /// translate widget coordinates to view coordinates
0080     QPoint widgetToView(const QPoint& p) const;
0081     QRect widgetToView(const QRect& r) const;
0082     QPoint viewToWidget(const QPoint& p) const;
0083     QRect viewToWidget(const QRect& r) const;
0084 
0085     /// Recalculates the size of the canvas (needed when zooming or changing pagelayout)
0086     virtual void updateSize() = 0;
0087 
0088     /// Show/hide page margins
0089     void setShowPageMargins(bool state);
0090     /// Returns true if page margins shall be shown
0091     bool showPageMargins() const;
0092 
0093 protected:
0094 
0095     void paint(QPainter &painter, const QRectF &paintRect);
0096 
0097 private:
0098     class Private;
0099     Private * const d;
0100 };
0101 
0102 #endif /* KOPACANVASBASE_H */