1 /*
2  * Copyright (C) 2007 Boudewijn Rempt <boud@valdyas.org>, (C)
3  * Copyright (C) 2010 Adrian Page <adrian@pagenet.plus.com>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 #ifndef _KIS_CANVAS_WIDGET_BASE_
20 #define _KIS_CANVAS_WIDGET_BASE_
21 
22 #include <QList>
23 #include <Qt>
24 
25 #include "kis_abstract_canvas_widget.h"
26 
27 class QColor;
28 class QImage;
29 class QInputMethodEvent;
30 class QVariant;
31 
32 class KisCoordinatesConverter;
33 class KisDisplayFilter;
34 class KisCanvas2;
35 
36 #include "kritaui_export.h"
37 
38 class KRITAUI_EXPORT KisCanvasWidgetBase : public KisAbstractCanvasWidget
39 {
40 public:
41     KisCanvasWidgetBase(KisCanvas2 * canvas, KisCoordinatesConverter *coordinatesConverter);
42 
43     ~KisCanvasWidgetBase() override;
44 
45 public: // KisAbstractCanvasWidget
46 
47     KoToolProxy *toolProxy() const override;
48 
49     /**
50      * Draw the specified decorations on the view.
51      */
52     void drawDecorations(QPainter & gc, const QRect &updateWidgetRect) const override;
53 
54     void addDecoration(KisCanvasDecorationSP deco) override;
55     void removeDecoration(const QString& id) override;
56     KisCanvasDecorationSP decoration(const QString& id) const override;
57 
58     void setDecorations(const QList<KisCanvasDecorationSP > &) override;
59     QList<KisCanvasDecorationSP > decorations() const override;
60 
61     void setWrapAroundViewingMode(bool value) override;
62 
63     /**
64      * Returns the color of the border, i.e. the part of the canvas
65      * outside the image contents.
66      *
67      */
68     QColor borderColor() const;
69 
70     /**
71      * Returns one check of the background checkerboard pattern.
72      */
73     static QImage createCheckersImage(qint32 checkSize = -1);
74 
75 
76     KisCoordinatesConverter* coordinatesConverter() const;
77 
78     QVector<QRect> updateCanvasProjection(const QVector<KisUpdateInfoSP> &infoObjects) override;
79     using KisAbstractCanvasWidget::updateCanvasProjection;
80 
81 protected:
82     KisCanvas2 *canvas() const;
83 
84     /**
85      * Event handlers to be called by derived canvas event handlers.
86      * All common event processing is carried out by these
87      * functions.
88      */
89     QVariant processInputMethodQuery(Qt::InputMethodQuery query) const;
90     void processInputMethodEvent(QInputMethodEvent *event);
91     void notifyConfigChanged();
92 
93     /// To be implemented by the derived canvas
94     virtual bool callFocusNextPrevChild(bool next) = 0;
95 
96 private:
97     struct Private;
98     Private * const m_d;
99 
100 };
101 
102 #endif // _KIS_CANVAS_WIDGET_BASE_
103