class library: PriorityQueue - implement removeValue, hide array
[supercollider.git] / QtCollider / QWidgetProxy.h
blob02e0fb2c0150ddff1aaad0221854f4352c3cde6c
1 /************************************************************************
3 * Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef QC_WIDGET_PROXY_H
23 #define QC_WIDGET_PROXY_H
25 #include "QObjectProxy.h"
27 #include <QWidget>
28 #include <QAtomicInt>
29 #include <QMimeData>
31 namespace QtCollider {
32 struct SetFocusEvent;
33 struct SetAlwaysOnTopEvent;
34 struct StartDragEvent;
37 class QWidgetProxy : public QObjectProxy
39 Q_OBJECT
41 public:
43 enum GlobalEvent {
44 KeyPress = 0x001,
45 KeyRelease = 0x002
48 public:
50 static void setGlobalEventEnabled ( GlobalEvent ev, bool b ) {
51 int mask = _globalEventMask;
52 if(b)
53 mask |= ev;
54 else
55 mask &= ~ev;
56 _globalEventMask = mask;
59 public:
61 QWidgetProxy( QWidget *w, PyrObject *po );
63 void setKeyEventWidget( QWidget * );
65 void setMouseEventWidget( QWidget * );
67 bool alwaysOnTop();
69 void refresh();
71 void setLayout ( QObjectProxy *layoutProxy );
73 virtual bool setParent( QObjectProxy *parent );
75 inline QWidget *widget() { return static_cast<QWidget*>( object() ); }
77 protected:
79 virtual void customEvent( QEvent * );
81 virtual bool filterEvent( QObject *, QEvent *, EventHandlerData &, QList<QVariant> & args );
83 private Q_SLOTS:
85 void customPaint( QPainter * );
87 private:
88 bool interpretMouseEvent( QObject *, QEvent *, QList<QVariant> &args );
89 bool interpretMouseWheelEvent( QObject *, QEvent *, QList<QVariant> &args );
90 bool interpretKeyEvent( QObject *, QEvent *, QList<QVariant> &args );
91 bool interpretDragEvent( QObject *, QEvent *, QList<QVariant> &args );
93 void bringFrontEvent();
94 void setFocusEvent( QtCollider::SetFocusEvent * );
95 void setAlwaysOnTopEvent( QtCollider::SetAlwaysOnTopEvent * );
96 void startDragEvent( QtCollider::StartDragEvent * );
98 static void sendRefreshEventRecursive( QWidget *w );
100 QWidget *_keyEventWidget;
101 QWidget *_mouseEventWidget;
102 static QAtomicInt _globalEventMask;
105 namespace QtCollider {
107 struct SetFocusEvent : public QEvent
109 SetFocusEvent( bool b )
110 : QEvent( (QEvent::Type) QtCollider::Event_Proxy_SetFocus ),
111 focus(b)
113 bool focus;
116 struct SetAlwaysOnTopEvent : public QEvent
118 SetAlwaysOnTopEvent( bool b )
119 : QEvent( (QEvent::Type) QtCollider::Event_Proxy_SetAlwaysOnTop ),
120 alwaysOnTop(b)
122 bool alwaysOnTop;
125 struct StartDragEvent : public QEvent
127 StartDragEvent( const QString &label_, QMimeData *data_ )
128 : QEvent( (QEvent::Type) QtCollider::Event_Proxy_StartDrag ),
129 label( label_ ), data( data_ )
131 ~StartDragEvent() { delete data; }
132 QString label;
133 QMimeData *data;
138 #endif //QC_WIDGET_PROXY_H