| 1 | #ifndef QORCA_H |
|---|
| 2 | #define QORCA_H |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 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 | |
|---|
| 38 | enum 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 | |
|---|
| 56 | class WIDPool |
|---|
| 57 | { |
|---|
| 58 | public: |
|---|
| 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 | |
|---|
| 86 | private: |
|---|
| 87 | |
|---|
| 88 | int _freeCount; |
|---|
| 89 | int _freeIndex; |
|---|
| 90 | QVector<REC> _records; |
|---|
| 91 | }; |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | struct 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; |
|---|
| 109 | OValue comboIndex; |
|---|
| 110 | OValue watchEvent; |
|---|
| 111 | OValue watchFile; |
|---|
| 112 | WIDPool pool; |
|---|
| 113 | |
|---|
| 114 | QEventLoop* loop; |
|---|
| 115 | }; |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | class QOrcaApp : public QApplication |
|---|
| 119 | { |
|---|
| 120 | Q_OBJECT |
|---|
| 121 | |
|---|
| 122 | public: |
|---|
| 123 | |
|---|
| 124 | QOrcaApp( int& argc, char** argv ); |
|---|
| 125 | }; |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | class ExeBlock |
|---|
| 129 | { |
|---|
| 130 | public: |
|---|
| 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 | |
|---|
| 143 | class SButton : public QPushButton |
|---|
| 144 | { |
|---|
| 145 | Q_OBJECT |
|---|
| 146 | |
|---|
| 147 | public: |
|---|
| 148 | |
|---|
| 149 | SButton(); |
|---|
| 150 | ~SButton(); |
|---|
| 151 | |
|---|
| 152 | int _wid; |
|---|
| 153 | |
|---|
| 154 | void setBlock( OValue* v ); |
|---|
| 155 | |
|---|
| 156 | public slots: |
|---|
| 157 | |
|---|
| 158 | void slotDo(); |
|---|
| 159 | |
|---|
| 160 | private: |
|---|
| 161 | |
|---|
| 162 | ExeBlock _blk; |
|---|
| 163 | }; |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | class SCombo : public QComboBox |
|---|
| 167 | { |
|---|
| 168 | Q_OBJECT |
|---|
| 169 | |
|---|
| 170 | public: |
|---|
| 171 | |
|---|
| 172 | SCombo(); |
|---|
| 173 | ~SCombo(); |
|---|
| 174 | |
|---|
| 175 | int _wid; |
|---|
| 176 | |
|---|
| 177 | void setBlock( OValue* ); |
|---|
| 178 | |
|---|
| 179 | public slots: |
|---|
| 180 | |
|---|
| 181 | void slotDo( int ); |
|---|
| 182 | |
|---|
| 183 | private: |
|---|
| 184 | |
|---|
| 185 | ExeBlock _blk; |
|---|
| 186 | }; |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | class SWidget : public QWidget |
|---|
| 190 | { |
|---|
| 191 | Q_OBJECT |
|---|
| 192 | |
|---|
| 193 | public: |
|---|
| 194 | |
|---|
| 195 | SWidget(); |
|---|
| 196 | ~SWidget(); |
|---|
| 197 | |
|---|
| 198 | int _wid; |
|---|
| 199 | |
|---|
| 200 | void setEventBlock( OValue* ); |
|---|
| 201 | |
|---|
| 202 | protected: |
|---|
| 203 | |
|---|
| 204 | void closeEvent( QCloseEvent* ); |
|---|
| 205 | |
|---|
| 206 | private: |
|---|
| 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 | |
|---|
| 216 | DEF_WIDGET(SCheck,QCheckBox); |
|---|
| 217 | DEF_WIDGET(SDialog,QDialog); |
|---|
| 218 | DEF_WIDGET(SGroup,QGroupBox); |
|---|
| 219 | DEF_WIDGET(SLabel,QLabel); |
|---|
| 220 | DEF_WIDGET(SLineEdit,QLineEdit); |
|---|
| 221 | DEF_WIDGET(STabWidget,QTabWidget); |
|---|
| 222 | DEF_WIDGET(STextEdit,QTextEdit); |
|---|
| 223 | DEF_WIDGET(SProgress,QProgressBar); |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | extern QtEnv qEnv; |
|---|
| 227 | |
|---|
| 228 | extern void qoInitEnv(); |
|---|
| 229 | extern void qoFreeEnv(); |
|---|
| 230 | extern int qoError(); |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | inline 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 |
|---|