root/trunk/orca/qt/qorca.h

Revision 416, 4.0 kB (checked in by krobillard, 18 months ago)

Orca Qt - Fixed subtle QApplication argc reference bug.

Line 
1#ifndef QORCA_H
2#define QORCA_H
3/*============================================================================
4    ORCA Qt Module
5    Copyright (C) 2005-2006  Karl Robillard
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    as published by the Free Software Foundation; either version 2
10    of the License, or (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, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20    02110-1301, USA.
21============================================================================*/
22
23
24#include <ovalue.h>
25#include <QApplication>
26#include <QCheckBox>
27#include <QComboBox>
28#include <QDialog>
29#include <QLabel>
30#include <QLineEdit>
31#include <QGroupBox>
32#include <QPushButton>
33#include <QProgressBar>
34#include <QTabWidget>
35#include <QTextEdit>
36
37
38enum eWidgetType
39{
40    WT_Null,
41    WT_Button,
42    WT_Dialog,
43    WT_Label,
44    WT_LineEdit,
45    WT_CheckBox,
46    WT_Combo,
47    WT_Tab,
48    WT_TextEdit,
49    WT_Group,
50    WT_Progress,
51    WT_Watcher,
52    WT_Widget
53};
54
55
56class WIDPool
57{
58public:
59
60    enum eRecFlags
61    {
62        DeleteObject = 0x0001
63    };
64
65    struct REC
66    {
67        short type;
68        short flags;
69        union
70        {
71            QObject* object;
72            QWidget* widget;
73        };
74    };
75
76    WIDPool() : _freeCount(0), _freeIndex(-1) {}
77
78    int  add( QObject*, int type, int flags = 0 );
79    void remove( int id );
80    REC* record( int id );
81
82    typedef QVector<REC>::iterator  iterator;
83    iterator begin() { return _records.begin(); }
84    iterator end()   { return _records.end(); }
85
86private:
87
88    int _freeCount;
89    int _freeIndex;
90    QVector<REC> _records;
91};
92
93
94struct QtEnv
95{
96    OAtom atom_close;
97    OAtom atom_exec_exit;
98
99    OAtom atom_ready;
100    OAtom atom_removed;
101    OAtom atom_created;
102    OAtom atom_changed;
103
104    OIndex layoutRulesBlkN;
105
106    QWidget* curWidget;
107    QDialog* dialog;
108    QString  filePath;     // Saves directory selected in last request-file.
109    OValue   comboIndex;
110    OValue   watchEvent;
111    OValue   watchFile;
112    WIDPool  pool;
113
114    QEventLoop* loop;
115};
116
117
118class QOrcaApp : public QApplication
119{
120    Q_OBJECT
121
122public:
123
124    QOrcaApp( int& argc, char** argv );
125};
126
127
128class ExeBlock
129{
130public:
131    ExeBlock() : n(0), hold(OR_INVALID_HOLD) {}
132    ~ExeBlock();
133
134    void setBlock( OValue* );
135    void switchWord( OAtom );
136
137    OIndex n;
138    OIndex index;
139    OIndex hold;
140};
141
142
143class SButton : public QPushButton
144{
145    Q_OBJECT
146
147public:
148
149    SButton();
150    ~SButton();
151
152    int _wid;
153
154    void setBlock( OValue* v );
155
156public slots:
157
158    void slotDo();
159
160private:
161
162    ExeBlock _blk;
163};
164
165
166class SCombo : public QComboBox
167{
168    Q_OBJECT
169
170public:
171
172    SCombo();
173    ~SCombo();
174
175    int _wid;
176
177    void setBlock( OValue* );
178
179public slots:
180
181    void slotDo( int );
182
183private:
184
185    ExeBlock _blk;
186};
187
188
189class SWidget : public QWidget
190{
191    Q_OBJECT
192
193public:
194
195    SWidget();
196    ~SWidget();
197
198    int _wid;
199
200    void setEventBlock( OValue* );
201
202protected:
203
204    void closeEvent( QCloseEvent* );
205
206private:
207
208    ExeBlock _blk;
209};
210
211
212#define DEF_WIDGET(oo,qo) \
213    class oo : public qo { public: oo(); ~oo(); int _wid; }
214
215
216DEF_WIDGET(SCheck,QCheckBox);
217DEF_WIDGET(SDialog,QDialog);
218DEF_WIDGET(SGroup,QGroupBox);
219DEF_WIDGET(SLabel,QLabel);
220DEF_WIDGET(SLineEdit,QLineEdit);
221DEF_WIDGET(STabWidget,QTabWidget);
222DEF_WIDGET(STextEdit,QTextEdit);
223DEF_WIDGET(SProgress,QProgressBar);
224
225
226extern QtEnv qEnv;
227
228extern void qoInitEnv();
229extern void qoFreeEnv();
230extern int qoError();
231
232
233inline const char* cstring( const OValue* val )
234{
235    OString* str = orSTRING( val );
236    orTermCStr( str );
237    return orStrChars( str, val );
238}
239
240
241#endif /*QORCA_H*/
Note: See TracBrowser for help on using the browser.