00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(TNFXAPP_H) && !defined(FX_DISABLEGUI)
00023 #define TNFXAPP_H
00024
00025 #include "FXApp.h"
00026 #include "QThread.h"
00027
00028 namespace FX {
00029
00034 class TnFXAppEventLoop;
00035
00036
00148 struct TnFXAppPrivate;
00149 class FXAPI TnFXApp : public QMutex, public FXApp
00150 {
00151 FXDECLARE(TnFXApp)
00152 TnFXAppPrivate *p;
00153 TnFXApp(const TnFXApp &);
00154 TnFXApp &operator=(const TnFXApp &);
00155 public:
00157 TnFXApp(const FXString &name="Application", const FXString &vendor="FoxDefault");
00158 ~TnFXApp();
00159 virtual FXEventLoop* getEventLoop() const;
00160 public:
00161 long onCmdQuit(FXObject*,FXSelector,void*);
00162 public:
00163 static TnFXApp *instance() { return (TnFXApp *) FXApp::instance(); }
00164 virtual void create();
00165 virtual void destroy();
00166 virtual void detach();
00167 virtual void init(int& argc,char** argv,bool connect=TRUE);
00170 virtual void exit(FXint code=0);
00171 virtual void lock();
00172 virtual void unlock();
00173
00176 FXint run(TnFXAppEventLoop &primaryLoop);
00177 };
00178
00179
00188 struct TnFXAppEventLoopPrivate;
00189 class FXAPI TnFXAppEventLoop : public QMutex, public FXObject, public QThread
00190 {
00191 FXDECLARE_ABSTRACT(TnFXAppEventLoop)
00192 TnFXAppEventLoopPrivate *p;
00193 TnFXAppEventLoop(const TnFXAppEventLoop &);
00194 TnFXAppEventLoop &operator=(const TnFXAppEventLoop &);
00195 public:
00196 enum
00197 {
00198 ID_LAST=0
00199 };
00200 public:
00202 TnFXAppEventLoop(const char *threadname="Event Loop thread", TnFXApp *app=TnFXApp::instance());
00203 ~TnFXAppEventLoop();
00205 TnFXApp *getApp() const;
00207 FXEventLoop *getEventLoop() const;
00208 protected:
00210 virtual FXint execute(FXApp *app)=0;
00211 virtual void run();
00212 virtual void *cleanup();
00214 void *&executeRetCode();
00215 };
00216
00217 }
00218
00219 #endif