File indexing completed on 2025-02-23 04:08:58

0001 /*
0002  * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>, (C)
0003  * SPDX-FileCopyrightText: 2010 Adrian Page <adrian@pagenet.plus.com>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 #ifndef _KIS_CANVAS_WIDGET_BASE_
0008 #define _KIS_CANVAS_WIDGET_BASE_
0009 
0010 #include <QList>
0011 #include <Qt>
0012 
0013 #include "kis_abstract_canvas_widget.h"
0014 
0015 class QColor;
0016 class QImage;
0017 class QInputMethodEvent;
0018 class QFocusEvent;
0019 class QVariant;
0020 
0021 class KisCoordinatesConverter;
0022 class KisDisplayFilter;
0023 class KisCanvas2;
0024 
0025 #include "kritaui_export.h"
0026 
0027 class KRITAUI_EXPORT KisCanvasWidgetBase : public KisAbstractCanvasWidget
0028 {
0029 public:
0030     KisCanvasWidgetBase(KisCanvas2 * canvas, KisCoordinatesConverter *coordinatesConverter);
0031 
0032     ~KisCanvasWidgetBase() override;
0033 
0034 public: // KisAbstractCanvasWidget
0035 
0036     KoToolProxy *toolProxy() const override;
0037 
0038     /**
0039      * Draw the specified decorations on the view.
0040      */
0041     void drawDecorations(QPainter & gc, const QRect &updateWidgetRect) const override;
0042 
0043     void addDecoration(KisCanvasDecorationSP deco) override;
0044     void removeDecoration(const QString& id) override;
0045     KisCanvasDecorationSP decoration(const QString& id) const override;
0046 
0047     void setDecorations(const QList<KisCanvasDecorationSP > &) override;
0048     QList<KisCanvasDecorationSP > decorations() const override;
0049     void notifyDecorationsWindowMinimized(bool minimized);
0050 
0051     void setWrapAroundViewingMode(bool value) override;
0052     void setWrapAroundViewingModeAxis(WrapAroundAxis value) override;
0053 
0054     /**
0055      * Returns the color of the border, i.e. the part of the canvas
0056      * outside the image contents.
0057      *
0058      */
0059     QColor borderColor() const;
0060 
0061     /**
0062      * Returns one check of the background checkerboard pattern.
0063      */
0064     static QImage createCheckersImage(qint32 checkSize = -1);
0065 
0066 
0067     KisCoordinatesConverter* coordinatesConverter() const;
0068 
0069     QVector<QRect> updateCanvasProjection(const QVector<KisUpdateInfoSP> &infoObjects) override;
0070     using KisAbstractCanvasWidget::updateCanvasProjection;
0071 
0072 protected:
0073     KisCanvas2 *canvas() const;
0074 
0075     /**
0076      * Event handlers to be called by derived canvas event handlers.
0077      * All common event processing is carried out by these
0078      * functions.
0079      */
0080     QVariant processInputMethodQuery(Qt::InputMethodQuery query) const;
0081     void processInputMethodEvent(QInputMethodEvent *event);
0082     void processFocusInEvent(QFocusEvent *event);
0083     void processFocusOutEvent(QFocusEvent *event);
0084     void notifyConfigChanged();
0085 
0086     /// To be implemented by the derived canvas
0087     virtual bool callFocusNextPrevChild(bool next) = 0;
0088 
0089 private:
0090     struct Private;
0091     Private * const m_d;
0092 
0093 };
0094 
0095 #endif // _KIS_CANVAS_WIDGET_BASE_