00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef INC_MGUI_APPMAIN_H
00046 #define INC_MGUI_APPMAIN_H
00047
00048 #ifndef INC_MI32_STDDEFNS_H
00049 #include <mi32/stddefns.h>
00050 #endif
00051
00052 #ifndef _XtIntrinsic_h
00053 #include <X11/Intrinsic.h>
00054 #endif
00055
00056 struct McbAnyCallbackStruct;
00057
00058 namespace MGUI {
00059
00060 class APP_MAIN;
00061
00062
00063
00064
00065
00066
00067 class APP_BASE {
00068 public:
00069
00070 #ifdef X_NATIVE
00071 enum LEGACYINIT {
00072 LEGACYINIT_Default = 0x00,
00073 LEGACYINIT_NoSetPosition = 0x01,
00074 LEGACYINIT_NoSetTitle = 0x02,
00075 LEGACYINIT_NoRealize = 0x04,
00076 LEGACYINIT_NoAutoSetExit = 0x08,
00077 LEGACYINIT_LockShellSize = 0x10,
00078 LEGACYINIT_NoDestroyTopOnExit = 0x20
00079 };
00080 #endif
00081
00082
00083 inline int GetCmdParmCount () const;
00084
00085
00086 inline const char* GetCmdParm (
00087 int idx
00088 ) const;
00089
00090 protected:
00091
00092
00093 APP_BASE (
00094 UINT32 AllowedProduct1 = 0,
00095 UINT32 AllowedProduct2 = 0,
00096 UINT32 AllowedProduct3 = 0,
00097 UINT32 AllowedProduct4 = 0
00098 );
00099
00100
00101 virtual ~APP_BASE ();
00102
00103 #ifdef X_NATIVE
00104
00105
00106
00107 Widget MxInitLegacy (LEGACYINIT flags = LEGACYINIT_Default);
00108 #endif
00109
00110 #ifdef X_NATIVE
00111
00112
00113
00114 void SetLegacyAllowShellResize (
00115 ) { m_LegacyAllowShellResize = true; }
00116 #endif
00117
00118 private:
00119
00120 #ifndef GENERATING_DOXYGEN_OUTPUT
00121
00122 #ifdef X_NATIVE
00123 LEGACYINIT m_LegacyInitFlags;
00124 bool m_LegacyAllowShellResize;
00125 #endif
00126 UINT32 m_ProductCode;
00127 UINT32 m_AllowedProducts[4];
00128
00129 UINT32 DetermineProductCode ()
00130 { return (v_DetermineProductCode()); }
00131 void ExitInstance ();
00132 const char* GetProcessName () const
00133 { return (v_GetProcessName()); }
00134 bool InitInstance ();
00135 bool IsProductAllowed (UINT32) const;
00136
00137 friend class MGUI::APP_MAIN;
00138
00139 APP_BASE (const APP_BASE&);
00140 APP_BASE& operator= (const APP_BASE&);
00141
00142 #endif
00143
00144
00145
00146
00147
00148
00149 virtual UINT32 v_DetermineProductCode () const;
00150
00151
00152 virtual void v_ExitInstance ();
00153
00154
00155
00156 virtual const char* v_GetProcessName () const = 0;
00157
00158
00159
00160
00161
00162 virtual bool v_InitInstance () = 0;
00163 };
00164 #ifdef X_NATIVE
00165 DEFINE_ENUM_OP_BITWISE(APP_BASE::LEGACYINIT);
00166 #endif
00167
00168
00169
00170
00171
00172
00173
00174 class APP_MAIN {
00175 public:
00176
00177
00178 static void Exit () { s_pMainInstance->DoExit(); }
00179
00180
00181 static APP_BASE* GetBaseInstance ()
00182 { return (s_pBaseInstance); }
00183
00184
00185 static APP_MAIN* GetMainInstance ()
00186 { return (s_pMainInstance); }
00187
00188
00189 APP_MAIN ();
00190
00191
00192 virtual ~APP_MAIN () = 0;
00193
00194
00195 int GetCmdParmCount () const
00196 { return (m_CmdParmCount); }
00197
00198
00199 const char* GetCmdParm (
00200 int idx
00201 ) const { return ((idx < 0 || idx >= m_CmdParmCount) ? NULL : m_CmdParmArray[idx]); }
00202
00203 #ifdef WIN32
00204
00205 void *GetInstanceHandle () const
00206 { return (m_hInstance); }
00207 #endif
00208
00209
00210
00211 void RemoveCmdParm (
00212 int idx
00213 );
00214
00215 #ifndef GENERATING_DOXYGEN_OUTPUT
00216 #if defined(WIN32) && !defined(WIN32_NATIVE)
00217 void DoWinMain (void *hInstance, const char *cmdline);
00218 #else
00219
00220
00221 void Run();
00222 void SetCmdParms (const char**, int);
00223 #endif
00224 #endif // GENERATING_DOXYGEN_OUTPUT
00225
00226 private:
00227
00228 #ifndef GENERATING_DOXYGEN_OUTPUT
00229
00230 static APP_MAIN *s_pMainInstance;
00231 static APP_BASE *s_pBaseInstance;
00232 #ifdef WIN32
00233 void *m_hInstance;
00234 char *m_ModNameStr;
00235 char *m_CmdLineStr;
00236 #endif
00237 char **m_CmdParmArray;
00238 int m_CmdParmCount;
00239
00240 void DoExit ();
00241 void ExitInstance ();
00242 bool InitInstance ();
00243 static void OnExitXServer (McbAnyCallbackStruct*, void*);
00244 static void OnTerminate ();
00245 #if defined(WIN32) && !defined(WIN32_NATIVE)
00246 void Run ();
00247 void SetCmdLine (const char*);
00248 #endif
00249
00250 friend class MGUI::APP_BASE;
00251
00252 APP_MAIN (const APP_MAIN&);
00253 APP_MAIN& operator= (const APP_MAIN&);
00254
00255 #endif // GENERATING_DOXYGEN_OUTPUT
00256
00257
00258
00259
00260
00261 virtual void v_ExitInstance ();
00262
00263
00264
00265
00266
00267
00268 virtual bool v_InitInstance ();
00269 };
00270
00271
00272 #ifndef GENERATING_DOXYGEN_OUTPUT
00273
00274
00275 inline int APP_BASE::GetCmdParmCount (
00276 ) const {
00277 APP_MAIN *pMain = APP_MAIN::GetMainInstance();
00278 return ((pMain == 0) ? 0 : pMain->GetCmdParmCount());
00279 }
00280
00281
00282 inline const char* APP_BASE::GetCmdParm (
00283 int idx
00284 ) const {
00285 APP_MAIN *pMain = APP_MAIN::GetMainInstance();
00286 return ((pMain == 0) ? 0 : pMain->GetCmdParm(idx));
00287 }
00288
00289 #endif // GENERATING_DOXYGEN_OUTPUT
00290
00291 }
00292
00293 #endif // INC_MGUI_APPMAIN_H