More error vs Error().throw cleanups
[supercollider.git] / QtCollider / Common.h
blobcad4b8a936ef1312dc78573f3ed3d3f8d20f95b0
1 /************************************************************************
3 * Copyright 2010 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 _SC_QT_COMMON_H
23 #define _SC_QT_COMMON_H
25 #include "debug.h"
27 #include <QList>
28 #include <QVariant>
29 #include <QEvent>
30 #include <QMutex>
31 #include <QWaitCondition>
32 #include <QVector>
34 #include <SCBase.h>
35 #include <PyrSymbol.h>
36 #include <PyrObject.h>
38 #include <pthread.h>
40 extern pthread_mutex_t gLangMutex;
42 struct VariantList {
43 QList<QVariant> data;
46 Q_DECLARE_METATYPE( VariantList );
47 Q_DECLARE_METATYPE( PyrObject * );
48 Q_DECLARE_METATYPE( QVector<double> );
49 Q_DECLARE_METATYPE( QVector<int> );
51 namespace QtCollider {
53 enum MetaType {
54 Type_VariantList,
55 Type_Count
58 enum EventType {
59 Event_SCRequest_Input = QEvent::User,
60 Event_SCRequest_Sched,
61 Event_SCRequest_Quit,
62 Event_SCRequest_Recompile,
63 Event_SCRequest_Stop,
64 Event_ScMethodCall,
65 Event_Refresh,
66 Event_Proxy_SetProperty,
67 Event_Proxy_Destroy,
68 Event_Proxy_BringFront,
69 Event_Proxy_SetFocus,
70 Event_Proxy_SetAlwaysOnTop,
71 Event_Proxy_StartDrag
74 enum Synchronicity {
75 Synchronous,
76 Asynchronous
79 inline void lockLang()
81 qcDebugMsg(2,"locking lang!");
82 pthread_mutex_lock (&gLangMutex);
83 qcDebugMsg(2,"locked");
86 inline void unlockLang()
88 pthread_mutex_unlock(&gLangMutex);
89 qcDebugMsg(2,"unlocked");
92 void runLang (
93 PyrObjectHdr *receiver,
94 PyrSymbol *method,
95 const QList<QVariant> & args = QList<QVariant>(),
96 PyrSlot *result = 0 );
98 int wrongThreadError ();
100 QPalette systemPalette();
102 extern PyrSymbol *s_interpretCmdLine;
103 extern PyrSymbol *s_interpretPrintCmdLine;
104 extern PyrSymbol *s_doFunction;
105 extern PyrSymbol *s_doDrawFunc;
106 extern PyrSymbol *s_Rect;
107 extern PyrSymbol *s_Point;
108 extern PyrSymbol *s_Color;
109 extern PyrSymbol *s_Size;
110 extern PyrSymbol *s_Array;
111 extern PyrSymbol *s_FloatArray;
112 extern PyrSymbol *s_SymbolArray;
113 extern PyrSymbol *s_String;
114 extern PyrSymbol *s_QPalette;
115 extern PyrSymbol *s_QFont;
116 extern PyrSymbol *s_QObject;
117 extern PyrSymbol *s_QLayout;
118 extern PyrSymbol *s_QTreeViewItem;
120 #define class_Rect s_Rect->u.classobj
121 #define class_Point s_Point->u.classobj
122 #define class_Color s_Color->u.classobj
123 #define class_Size s_Size->u.classobj
124 #define class_Array s_Array->u.classobj
125 #define class_FloatArray s_FloatArray->u.classobj
126 #define class_SymbolArray s_SymbolArray->u.classobj
127 #define class_String s_String->u.classobj
128 #define class_QPalette s_QPalette->u.classobj
129 #define class_QFont s_QFont->u.classobj
130 #define class_QObject s_QObject->u.classobj
131 #define class_QLayout s_QLayout->u.classobj
132 #define class_QTreeViewItem s_QTreeViewItem->u.classobj
134 #define DECLARE_SYMBOL( SYM ) \
135 struct symbol_##SYM { \
136 static PyrSymbol * get() { static PyrSymbol *sym = getsym(#SYM); return sym; } \
139 #define SC_SYM( SYM ) symbol_##SYM::get()
141 #define SC_CLASS( SYM ) SC_SYM(SYM)->u.classobj
143 DECLARE_SYMBOL(Gradient);
144 DECLARE_SYMBOL(HiliteGradient);
147 #endif //_SC_QT_COMMON_H