/
QWidgetProxy.h
138 lines (105 loc) · 3.31 KB
/
QWidgetProxy.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
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
/************************************************************************
*
* Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com)
*
* This file is part of SuperCollider Qt GUI.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/
#ifndef QC_WIDGET_PROXY_H
#define QC_WIDGET_PROXY_H
#include "QObjectProxy.h"
#include <QWidget>
#include <QAtomicInt>
#include <QMimeData>
namespace QtCollider {
struct SetFocusEvent;
struct SetAlwaysOnTopEvent;
struct StartDragEvent;
}
class QWidgetProxy : public QObjectProxy
{
Q_OBJECT
public:
enum GlobalEvent {
KeyPress = 0x001,
KeyRelease = 0x002
};
public:
static void setGlobalEventEnabled ( GlobalEvent ev, bool b ) {
int mask = _globalEventMask;
if(b)
mask |= ev;
else
mask &= ~ev;
_globalEventMask = mask;
}
public:
QWidgetProxy( QWidget *w, PyrObject *po );
void setKeyEventWidget( QWidget * );
void setMouseEventWidget( QWidget * );
bool alwaysOnTop();
void refresh();
void setLayout ( QObjectProxy *layoutProxy );
virtual bool setParent( QObjectProxy *parent );
inline QWidget *widget() { return static_cast<QWidget*>( object() ); }
protected:
virtual void customEvent( QEvent * );
virtual bool filterEvent( QObject *, QEvent *, EventHandlerData &, QList<QVariant> & args );
private Q_SLOTS:
void customPaint( QPainter * );
private:
bool interpretMouseEvent( QObject *, QEvent *, QList<QVariant> &args );
bool interpretMouseWheelEvent( QObject *, QEvent *, QList<QVariant> &args );
bool interpretKeyEvent( QObject *, QEvent *, QList<QVariant> &args );
bool interpretDragEvent( QObject *, QEvent *, QList<QVariant> &args );
void bringFrontEvent();
void setFocusEvent( QtCollider::SetFocusEvent * );
void setAlwaysOnTopEvent( QtCollider::SetAlwaysOnTopEvent * );
void startDragEvent( QtCollider::StartDragEvent * );
static void sendRefreshEventRecursive( QWidget *w );
QWidget *_keyEventWidget;
QWidget *_mouseEventWidget;
static QAtomicInt _globalEventMask;
};
namespace QtCollider {
struct SetFocusEvent : public QEvent
{
SetFocusEvent( bool b )
: QEvent( (QEvent::Type) QtCollider::Event_Proxy_SetFocus ),
focus(b)
{}
bool focus;
};
struct SetAlwaysOnTopEvent : public QEvent
{
SetAlwaysOnTopEvent( bool b )
: QEvent( (QEvent::Type) QtCollider::Event_Proxy_SetAlwaysOnTop ),
alwaysOnTop(b)
{}
bool alwaysOnTop;
};
struct StartDragEvent : public QEvent
{
StartDragEvent( const QString &label_, QMimeData *data_ )
: QEvent( (QEvent::Type) QtCollider::Event_Proxy_StartDrag ),
label( label_ ), data( data_ )
{}
~StartDragEvent() { delete data; }
QString label;
QMimeData *data;
};
}
#endif //QC_WIDGET_PROXY_H