Warning, file /office/calligra/libs/pageapp/KoPAViewMode.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 ) 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 KOPAVIEWMODE_H
0021 #define KOPAVIEWMODE_H
0022 
0023 #include "kopageapp_export.h"
0024 
0025 #include <QObject>
0026 #include <QPointF>
0027 
0028 struct KoPageLayout;
0029 class KoPAViewBase;
0030 class KoPACanvas;
0031 class KoPACanvasBase;
0032 class KoPAPageBase;
0033 class KoToolProxy;
0034 class KoShape;
0035 class KoViewConverter;
0036 class QPainter;
0037 class QPaintEvent;
0038 class QTabletEvent;
0039 class QMouseEvent;
0040 class QKeyEvent;
0041 class QWheelEvent;
0042 class QCloseEvent;
0043 class QRectF;
0044 class KUndo2Command;
0045 
0046 class KOPAGEAPP_EXPORT KoPAViewMode : public QObject
0047 {
0048 
0049     Q_OBJECT
0050 public:
0051     KoPAViewMode(KoPAViewBase * view, KoPACanvasBase * canvas, const QString& name = QString());
0052     ~KoPAViewMode() override;
0053 
0054     virtual void paint(KoPACanvasBase* canvas, QPainter& painter, const QRectF &paintRect) = 0;
0055     //virtual void paintEvent( KoPACanvas * canvas, QPaintEvent* event ) = 0;
0056     virtual void tabletEvent( QTabletEvent *event, const QPointF &point ) = 0;
0057     virtual void mousePressEvent( QMouseEvent *event, const QPointF &point ) = 0;
0058     virtual void mouseDoubleClickEvent( QMouseEvent *event, const QPointF &point ) = 0;
0059     virtual void mouseMoveEvent( QMouseEvent *event, const QPointF &point ) = 0;
0060     virtual void mouseReleaseEvent( QMouseEvent *event, const QPointF &point ) = 0;
0061     virtual void shortcutOverrideEvent( QKeyEvent *event ) = 0;
0062     virtual void keyPressEvent( QKeyEvent *event ) = 0;
0063     virtual void keyReleaseEvent( QKeyEvent *event ) = 0;
0064     virtual void wheelEvent( QWheelEvent * event, const QPointF &point ) = 0;
0065     /**
0066      * The default implementation ignores this event
0067      */
0068     virtual void closeEvent( QCloseEvent * event );
0069 
0070     /**
0071      * @brief Switch the active view mode to work on master/normal pages
0072      *
0073      * The default implementation does not change anything. If it is needed in the
0074      * view mode you have to implement it.
0075      *
0076      * @param master if true work on master pages, if false work on normal pages
0077      */
0078     virtual void setMasterMode( bool master );
0079 
0080     /**
0081      * @brief Check if the active view mode works on master/normal pages
0082      *
0083      * The default implementation always returns false
0084      *
0085      * @return false
0086      */
0087     virtual bool masterMode();
0088 
0089     /**
0090      * @brief This method is called when the view mode is activated
0091      *
0092      * The default implementation does nothing.
0093      *
0094      * @param previousViewMode the view mode which was active before the
0095      *        activation of this view mode;
0096      */
0097     virtual void activate( KoPAViewMode * previousViewMode );
0098 
0099     /**
0100      * @brief This method is called when the view mode is deactivated
0101      *
0102      * The default implementation does nothing.
0103      */
0104     virtual void deactivate();
0105 
0106     /**
0107      * @brief Get the canvas
0108      *
0109      * @return canvas canvas used by the view mode
0110      */
0111     KoPACanvasBase * canvas() const;
0112 
0113     /**
0114      * @brief Get the view
0115      *
0116      * @return view view used by the view mode
0117      */
0118     KoPAViewBase * view() const;
0119 
0120     /**
0121      * @brief Get the view mode's implementation of view converter
0122      *
0123      * The default implementation returns the KoPAView's view converter
0124      *
0125      * @return the view converter used in the view mode
0126      */
0127     virtual KoViewConverter * viewConverter( KoPACanvasBase * canvas );
0128 
0129 
0130     virtual const KoPageLayout &activePageLayout() const;
0131 
0132     virtual void changePageLayout( const KoPageLayout &pageLayout, bool applyToDocument, KUndo2Command *parent = 0 );
0133 
0134     QPointF origin();
0135 
0136     void setOrigin(const QPointF &origin);
0137     void setName(const QString &name);
0138     QString name() const;
0139 
0140 public Q_SLOTS:
0141 
0142     /**
0143      * @brief Update the view when a new shape is added to the document
0144      *
0145      * The default implementation does nothing. The derived class' implementation
0146      * should check whether the new shape is added to currently active page.
0147      *
0148      * @param shape the new shape added to the document
0149      */
0150     virtual void addShape( KoShape *shape );
0151 
0152     /**
0153      * @brief Update the view when a shape is removed from the document
0154      *
0155      * The default implementation does nothing. The derived class' implementation
0156      * should check whether the shape is removed from currently active page.
0157      *
0158      * @param shape the shape removed from the document
0159      */
0160     virtual void removeShape( KoShape *shape );
0161 
0162     /**
0163      * @brief Update the view based on the active page
0164      *
0165      * The default implementation calls the KoPAView's updateActivePage(). If
0166      * other behavior is intended when updating active page, the derived class
0167      * should reimplement this function.
0168      *
0169      * @see KoPAView::updateActivePage()
0170      *
0171      * @param page the new page to be updated on the view mode
0172      */
0173     virtual void updateActivePage(KoPAPageBase * page);
0174 
0175 protected:
0176     KoPACanvasBase * m_canvas;
0177     KoToolProxy * m_toolProxy;
0178     KoPAViewBase * m_view;
0179     QPointF m_origin;
0180     QString m_name;
0181 };
0182 
0183 #endif /* KOPAVIEWMODE_H */