1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/***************************************************************************
kmagselrect.h - description
-------------------
begin : Mon Feb 12 23:45:41 EST 2001
copyright : (C) 2001-2003 by Sarang Lakare
email : sarang#users.sf.net
copyright : (C) 2003-2004 by Olaf Schmidt
email : ojschmidt@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KMAGSELRECT_H
#define KMAGSELRECT_H
// Qt
#include <QWidget>
#include <QLabel>
class QMouseEvent;
class KMagSelWinCorner : public QLabel
{
Q_OBJECT
public:
explicit KMagSelWinCorner ( QWidget * parent = nullptr );
virtual ~KMagSelWinCorner();
Q_SIGNALS:
void startResizing ();
void resized ( QPoint offset );
protected:
QPoint oldPos;
void mousePressEvent ( QMouseEvent * e ) override;
void mouseReleaseEvent ( QMouseEvent * e ) override;
void mouseMoveEvent ( QMouseEvent * e ) override;
};
class KMagSelWin : public QWidget
{
Q_OBJECT
public:
explicit KMagSelWin ( QWidget * parent = nullptr );
virtual ~KMagSelWin();
void setSelRect ( const QRect & selRect );
QRect getSelRect ();
public Q_SLOTS:
void startResizing ();
void titleMoved ( const QPoint & offset );
void topLeftResized ( const QPoint & offset );
void topRightResized ( const QPoint & offset );
void bottomLeftResized ( const QPoint & offset );
void bottomRightResized ( const QPoint & offset );
Q_SIGNALS:
void resized();
protected:
QRect oldSelRect;
KMagSelWinCorner *titleBar;
KMagSelWinCorner *topLeftCorner;
KMagSelWinCorner *topRightCorner;
KMagSelWinCorner *bottomLeftCorner;
KMagSelWinCorner *bottomRightCorner;
};
/**
* This class stores the selected rectangular area for grabbing. It also displays the
* rectangular area on demand.
*
* @author Original : Michael Forster
* @author Current : Sarang Lakare
*/
class KMagSelRect : public QObject, public QRect
{
Q_OBJECT
public:
explicit KMagSelRect(QWidget *parent=nullptr);
KMagSelRect(const QPoint &topLeft, const QPoint &bottomRight,
QWidget *parent=nullptr);
KMagSelRect(const QPoint &topLeft, const QSize &size,
QWidget *parent=nullptr);
KMagSelRect(int left, int top, int width, int height,
QWidget *selWindowParent=nullptr);
virtual ~KMagSelRect();
bool visible();
/// Makes the rectangle always visible
void alwaysVisible(bool visible=true);
/// Returns true if always visible is set
bool getAlwaysVisible() const {
return (m_alwaysVisible);
}
public Q_SLOTS:
void show();
void hide();
void update();
void selWinResized();
protected:
void init(QWidget *);
QWidget *selWindowParent;
KMagSelWin *selectionwindow;
bool m_alwaysVisible;
};
void setTitleColors (const QColor & title, const QColor & text, const QColor & titleBtn);
void setFrameSize (int size);
#endif // KMAGSELRECT_H
|