-
Notifications
You must be signed in to change notification settings - Fork 0
/
DQRubberBand.h
96 lines (76 loc) · 2.33 KB
/
DQRubberBand.h
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
/*
* DQRubberBand.h
*
* Created on: Apr 28, 2014
* Author: Tim
*/
#ifndef DQRUBBERBAND_H_
#define DQRUBBERBAND_H_
/*****************************************************************************
****************************** I N C L U D E *******************************
*****************************************************************************/
#include <QRubberBand>
/*****************************************************************************
*
*** class DQRubberBand
*
* This class extends QRubberBand by handling the mouse events in a
* consistent way.
*
* In the containing widget, call the Begin() method in the mousePressEvent.
* Call the Move() method in the mouseMoveEvent. Finally, call the End()
* method in the mouseReleaseEvent.
*
*****************************************************************************/
class DQRubberBand : public QRubberBand
{
Q_OBJECT
public:
DQRubberBand(QRubberBand::Shape Shape = QRubberBand::Rectangle, QWidget* pParent = nullptr) :
QRubberBand(Shape, pParent)
{
m_bEnabled = true;
m_bBanding = false;
// Geometry isn't nulled by the base class
setGeometry(QRect());
return;
}
DQRubberBand(const DQRubberBand& src) = delete;
~DQRubberBand() = default;
DQRubberBand& operator=(const DQRubberBand& rhs) = delete;
virtual void Begin(const QPoint& pt);
virtual void Move(const QPoint& pt);
virtual void End(const QPoint& pt);
bool IsBanding() const
{
return (m_bBanding);
}
void Clear()
{
setGeometry(QRect());
m_bBanding = false;
return;
}
bool IsEnabled() const
{
return (m_bEnabled);
}
void Enable(bool bEnable = true)
{
m_bEnabled = bEnable;
// m_bEnabled ? show() : hide();
return;
}
void Disable(bool bDisable = true)
{
m_bEnabled = !bDisable;
// m_bEnabled ? show() : hide();
return;
}
protected:
bool m_bEnabled;
bool m_bBanding;
QPoint m_Origin;
private:
}; // end of class QRubberBand
#endif /* DQRUBBERBAND_H_ */