1 /* This file is part of the KDE project
2    Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org>
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8 
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13 
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KOPACANVAS_H
21 #define KOPACANVAS_H
22 
23 #include <QWidget>
24 #include <QList>
25 #include <KoPACanvasBase.h>
26 
27 #include "kopageapp_export.h"
28 
29 /// Widget that shows a KoPAPage
30 class KOPAGEAPP_EXPORT KoPACanvas : public QWidget, public KoPACanvasBase
31 {
32     Q_OBJECT
33 public:
34     explicit KoPACanvas( KoPAViewBase * view, KoPADocument * doc, QWidget *parent = 0, Qt::WindowFlags f = 0);
35 
36     void repaint() override;
37 
38     QWidget* canvasWidget() override;
39     const QWidget* canvasWidget() const override;
40 
41     /// reimplemented method
42     void updateCanvas( const QRectF& rc ) override;
43 
44     /// reimplemented method
45     void updateInputMethodInfo() override;
46 
47     /// Recalculates the size of the canvas (needed when zooming or changing pagelayout)
48     void updateSize() override;
49 
50     void setCursor(const QCursor &cursor) override;
51 
52 public Q_SLOTS:
53 
slotSetDocumentOffset(const QPoint & offset)54     void slotSetDocumentOffset(const QPoint &offset) { setDocumentOffset(offset); }
55 
56 Q_SIGNALS:
57     void documentSize(const QSize &size);
58 
59     /**
60      * Emitted when the entire controller size changes
61      * @param size the size in widget pixels.
62      */
63     void sizeChanged( const QSize & size );
64 
65     /// Emitted when updateCanvas has been called.
66     void canvasUpdated();
67 
68 protected:
69     /// reimplemented method from superclass
70     bool event(QEvent *) override;
71     /// reimplemented method from superclass
72     void paintEvent( QPaintEvent* event ) override;
73     /// reimplemented method from superclass
74     void tabletEvent( QTabletEvent *event ) override;
75     /// reimplemented method from superclass
76     void mousePressEvent( QMouseEvent *event ) override;
77     /// reimplemented method from superclass
78     void mouseDoubleClickEvent( QMouseEvent *event ) override;
79     /// reimplemented method from superclass
80     void mouseMoveEvent( QMouseEvent *event ) override;
81     /// reimplemented method from superclass
82     void mouseReleaseEvent( QMouseEvent *event ) override;
83     /// reimplemented method from superclass
84     void keyPressEvent( QKeyEvent *event ) override;
85     /// reimplemented method from superclass
86     void keyReleaseEvent( QKeyEvent *event ) override;
87     /// reimplemented method from superclass
88     void wheelEvent ( QWheelEvent * event ) override;
89     /// reimplemented method from superclass
90     void closeEvent( QCloseEvent * event ) override;
91     /// reimplemented method from superclass
92     QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
93     /// reimplemented method from superclass
94     void inputMethodEvent(QInputMethodEvent *event) override;
95 
96     /// reimplemented method from superclass
97     void resizeEvent( QResizeEvent * event ) override;
98 
99     /**
100      * Shows the default context menu
101      * @param globalPos global position to show the menu at.
102      * @param actionList action list to be inserted into the menu
103      */
104     void showContextMenu( const QPoint& globalPos, const QList<QAction*>& actionList );
105 };
106 
107 #endif /* KOPACANVAS_H */
108