File indexing completed on 2024-04-28 04:32:23

0001 /*
0002  * SPDX-FileCopyrightText: 2008 Kare Sars <kare dot sars at iki dot fi>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 #ifndef SELECTIONITEM_H
0007 #define SELECTIONITEM_H
0008 
0009 #include <QGraphicsPixmapItem>
0010 #include <QPainter>
0011 
0012 namespace KSaneIface
0013 {
0014 
0015 /**
0016  * Selection QGraphicsItem for the image viewer.
0017  */
0018 class SelectionItem : public QGraphicsItem
0019 {
0020 public:
0021     typedef enum {
0022         None,
0023         Top,
0024         TopRight,
0025         Right,
0026         BottomRight,
0027         Bottom,
0028         BottomLeft,
0029         Left,
0030         TopLeft,
0031         Move,
0032         AddRemove
0033     } Intersects;
0034 
0035     explicit SelectionItem(const QRectF &rect);
0036     ~SelectionItem() override;
0037 
0038     void setMaxRight(qreal maxRight);
0039     void setMaxBottom(qreal maxBottom);
0040     void setSaved(bool isSaved);
0041 
0042     Intersects intersects(const QPointF &point);
0043 
0044     void saveZoom(qreal zoom);
0045 
0046     void setRect(const QRectF &rect);
0047     QPointF fixTranslation( QPointF dp);
0048     QRectF rect();
0049 
0050     qreal devicePixelRatio() const;
0051     void setDevicePixelRatio(qreal dpr);
0052 
0053     void setAddButtonEnabled(bool enabled);
0054 
0055 public:
0056     // Graphics Item methods
0057     QRectF boundingRect() const override;
0058     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
0059 
0060 private:
0061     struct Private;
0062     Private *const d;
0063 };
0064 
0065 }  // NameSpace KSaneIface
0066 
0067 #endif
0068