1 /************************************************************************
2  *
3  * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
4  *
5  * This file is part of SuperCollider Qt GUI.
6  *
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 2 of the License, or
10  * (at your option) any later version.
11  *
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.
16  *
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/>.
19  *
20  ************************************************************************/
21 
22 #pragma once
23 
24 #include "debug.h"
25 
26 #include <QList>
27 #include <QVariant>
28 #include <QEvent>
29 #include <QMutex>
30 #include <QWaitCondition>
31 #include <QVector>
32 
33 #include <SCBase.h>
34 #include <PyrSymbol.h>
35 #include <PyrObject.h>
36 #include <PyrSched.h>
37 
38 Q_DECLARE_METATYPE(PyrObject*);
39 Q_DECLARE_METATYPE(QVector<double>);
40 Q_DECLARE_METATYPE(QVector<int>);
41 
42 namespace QtCollider {
43 
44 enum EventType {
45     Event_SCRequest_Work = QEvent::User,
46     Event_SCRequest_Tick,
47     Event_SCRequest_Quit,
48     Event_ScMethodCall,
49     Event_Refresh,
50     Event_Proxy_SetProperty,
51     Event_Proxy_Destroy,
52     Event_Proxy_BringFront,
53     Event_Proxy_SetFocus,
54     Event_Proxy_SetAlwaysOnTop,
55     Event_Proxy_Release
56 };
57 
58 enum Synchronicity { Synchronous, Asynchronous };
59 
60 inline void lockLang() {
61     qcDebugMsg(2, "locking lang!");
62     gLangMutex.lock();
63     qcDebugMsg(2, "locked");
64 }
65 
66 inline void unlockLang() {
67     gLangMutex.unlock();
68     qcDebugMsg(2, "unlocked");
69 }
70 
71 void runLang(PyrObjectHdr* receiver, PyrSymbol* method, const QList<QVariant>& args = QList<QVariant>(),
72              PyrSlot* result = 0);
73 
74 int wrongThreadError();
75 
76 QPalette systemPalette();
77 
78 #define QC_DO_SYMBOLS                                                                                                  \
79     QC_DO_SYMBOL(interpretCmdLine);                                                                                    \
80     QC_DO_SYMBOL(interpretPrintCmdLine);                                                                               \
81     QC_DO_SYMBOL(doFunction);                                                                                          \
82     QC_DO_SYMBOL(doDrawFunc);                                                                                          \
83     QC_DO_SYMBOL(prRelease);                                                                                           \
84     QC_DO_SYMBOL(Rect);                                                                                                \
85     QC_DO_SYMBOL(Point);                                                                                               \
86     QC_DO_SYMBOL(Color);                                                                                               \
87     QC_DO_SYMBOL(Size);                                                                                                \
88     QC_DO_SYMBOL(QPalette);                                                                                            \
89     QC_DO_SYMBOL(Font);                                                                                                \
90     QC_DO_SYMBOL(QCallback);                                                                                           \
91     QC_DO_SYMBOL(WebPage);                                                                                             \
92     QC_DO_SYMBOL(QObject);                                                                                             \
93     QC_DO_SYMBOL(Layout);                                                                                              \
94     QC_DO_SYMBOL(ScrollCanvas);                                                                                        \
95     QC_DO_SYMBOL(TreeViewItem);                                                                                        \
96     QC_DO_SYMBOL(Gradient);                                                                                            \
97     QC_DO_SYMBOL(HiliteGradient);                                                                                      \
98     QC_DO_SYMBOL(AbstractMenuAction);                                                                                  \
99     QC_DO_SYMBOL(Menu);                                                                                                \
100     QC_DO_SYMBOL(View);                                                                                                \
101     QC_DO_SYMBOL(Image);
102 
103 #define QC_DO_SYMBOL(SYM) extern PyrSymbol* sym_##SYM
104 QC_DO_SYMBOLS
105 #undef QC_DO_SYMBOL
106 
107 #define SC_SYM(SYM) QtCollider::sym_##SYM
108 #define SC_CLASS(SYM) SC_SYM(SYM)->u.classobj
109 
110 }
111