00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GZ_APPLICATION_H__
00023 #define __GZ_APPLICATION_H__
00024
00030 #include "gzBase.h"
00031 #include "gzThread.h"
00032 #include "gzNotify.h"
00033 #include "gzGraphicsAbstractionLayer.h"
00034
00035 #ifdef GZ_WIN32
00036
00037
00038 class gzAppContext
00039 {
00040 public:
00041 HINSTANCE instance;
00042 gzDeviceContext display;
00043 };
00044
00045 #elif defined GZ_GLX
00046
00047
00048 #include "X11/Intrinsic.h"
00049 #include "X11/Xlib.h"
00050
00051 class gzAppContext
00052 {
00053 public:
00054 gzDeviceContext display;
00055 XtAppContext context;
00056 };
00057
00058 #elif defined GZ_MAC
00059
00060
00061 class gzAppContext
00062 {
00063 public:
00064 gzDeviceContext display;
00065 gzULong context;
00066 };
00067
00068 #endif // ------------------------ COMMON ---------------------------------
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 class gzApplication : public gzNotifyManager , public gzReference , public gzProgramExecution
00086 {
00087 public:
00088
00089 GZ_SYSTEM_EXPORT gzApplication(const gzString & name="GIZMO APPLICATION" , int argc=0 , char **argv=NULL ,gzDeviceContext dc=NULL);
00090
00091 GZ_SYSTEM_EXPORT virtual ~gzApplication();
00092
00094 GZ_SYSTEM_EXPORT gzVoid run();
00095
00097 GZ_SYSTEM_EXPORT gzVoid stop();
00098
00100
00101 GZ_SYSTEM_EXPORT gzInt poll(gzBool forceExecNotifications=TRUE);
00102
00103
00104 GZ_SYSTEM_EXPORT virtual gzVoid onIdle();
00105
00106 GZ_SYSTEM_EXPORT virtual gzVoid onTick();
00107
00108 GZ_SYSTEM_EXPORT gzVoid setTickInterval( gzDouble seconds );
00109
00110 GZ_SYSTEM_EXPORT gzAppContext getAppContext();
00111
00112 GZ_SYSTEM_EXPORT static gzApplication *getGizmoApplication();
00113
00114 #if defined GZ_GLX
00115
00116
00117 gzInt getWMProtocolLength() { return 1; }
00118 Atom * getWMProtocol() { return &m_wm_delete_window; }
00119
00120 #endif // ------------------------ COMMON ---------------------------------
00121
00122
00123 private:
00124
00125 GZ_SYSTEM_EXPORT virtual gzVoid onProgramExecution();
00126
00127 friend class gzWindow;
00128
00129 gzString m_appName;
00130
00131 gzDouble m_tickIntervalTime;
00132
00133 gzDouble m_nextTickTime;
00134
00135 gzBool m_isRunning;
00136
00137 gzAppContext m_appContext;
00138
00139 #if defined GZ_GLX
00140
00141
00142 static Boolean workproc( XtPointer clientData);
00143
00144 Atom m_wm_protocols;
00145 Atom m_wm_delete_window;
00146
00147 #elif defined GZ_MAC
00148
00149 EventLoopTimerUPP m_timerUPP;
00150
00151 static void AppTimer(EventLoopTimerRef theTimer,void *userData);
00152
00153 #endif // ------------------------ COMMON ---------------------------------
00154
00155 static gzRefPointer<gzApplication> s_gizmoApplication;
00156
00157 };
00158
00159
00160
00161 #endif // __GZ_APPLICATION_H__