File indexing completed on 2024-04-28 03:40:28

0001 // SPDX-FileCopyrightText: 2001-2003 Sarang Lakare <sarang@users.sourceforge.net>
0002 // SPDX-FileCopyrightText: 2003-2004 Olaf Schmidt <ojschmidt@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #ifndef KMAGSELRECT_H
0006 #define KMAGSELRECT_H
0007 
0008 // Qt
0009 #include <QWidget>
0010 #include <QLabel>
0011 
0012 class QMouseEvent;
0013 
0014 class KMagSelWinCorner : public QLabel
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019 
0020     explicit KMagSelWinCorner ( QWidget * parent = nullptr );
0021 
0022     ~KMagSelWinCorner() override;
0023 
0024 Q_SIGNALS:
0025 
0026     void startResizing ();
0027     void resized ( QPoint offset );
0028 
0029 protected:
0030 
0031     QPoint oldPos;
0032 
0033     void mousePressEvent ( QMouseEvent * e ) override;
0034     void mouseReleaseEvent ( QMouseEvent * e ) override;
0035     void mouseMoveEvent ( QMouseEvent * e ) override;
0036 };
0037 
0038 class KMagSelWin : public QWidget
0039 {
0040     Q_OBJECT
0041 
0042 public:
0043 
0044     explicit KMagSelWin ( QWidget * parent = nullptr );
0045 
0046     ~KMagSelWin() override;
0047 
0048     void setSelRect ( const QRect & selRect );
0049     QRect getSelRect ();
0050 
0051 public Q_SLOTS:
0052 
0053     void startResizing ();
0054     void titleMoved ( const QPoint & offset );
0055     void topLeftResized ( const QPoint & offset );
0056     void topRightResized ( const QPoint & offset );
0057     void bottomLeftResized ( const QPoint & offset );
0058     void bottomRightResized ( const QPoint & offset );
0059 
0060 Q_SIGNALS:
0061 
0062     void resized();
0063 
0064 protected:
0065 
0066     QRect oldSelRect;
0067 
0068     KMagSelWinCorner *titleBar;
0069     KMagSelWinCorner *topLeftCorner;
0070     KMagSelWinCorner *topRightCorner;
0071     KMagSelWinCorner *bottomLeftCorner;
0072     KMagSelWinCorner *bottomRightCorner;
0073 };
0074 
0075 /**
0076  * This class stores the selected rectangular area for grabbing. It also displays the
0077  * rectangular area on demand.
0078  *
0079  * @author Original : Michael Forster
0080  * @author Current : Sarang Lakare
0081  */
0082 class KMagSelRect : public QObject, public QRect
0083 {
0084     Q_OBJECT
0085 
0086 public:
0087     explicit KMagSelRect(QWidget *parent=nullptr);
0088     KMagSelRect(const QPoint &topLeft, const QPoint &bottomRight,
0089       QWidget *parent=nullptr);
0090     KMagSelRect(const QPoint &topLeft, const QSize &size,
0091       QWidget *parent=nullptr);
0092     KMagSelRect(int left, int top, int width, int height,
0093       QWidget *selWindowParent=nullptr);
0094 
0095     ~KMagSelRect() override;
0096 
0097     bool visible() const;
0098 
0099     /// Makes the rectangle always visible
0100     void alwaysVisible(bool visible=true);
0101 
0102     /// Returns true if always visible is set
0103     bool getAlwaysVisible() const {
0104       return (m_alwaysVisible);
0105     }
0106 
0107 public Q_SLOTS:
0108 
0109     void show();
0110     void hide();
0111     void update();
0112 
0113     void selWinResized();
0114 
0115 protected:
0116 
0117     void init(QWidget *);
0118 
0119     QWidget *selWindowParent;
0120     KMagSelWin *selectionwindow;
0121     bool m_alwaysVisible;
0122 
0123 };
0124 
0125 void setTitleColors (const QColor & title, const QColor & text, const QColor & titleBtn);
0126 void setFrameSize (int size);
0127 
0128 #endif // KMAGSELRECT_H