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
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef INC_MGUI_APPMAIN_H
00058 #define INC_MGUI_APPMAIN_H
00059
00060 #ifndef INC_MI32_STDDEFNS_H
00061 #include <mi32/stddefns.h>
00062 #endif
00063
00064 #if !defined(_XtIntrinsic_h) && !defined(WIN32_MFC)
00065 #include <X11/Intrinsic.h>
00066 #endif
00067
00068 #if !defined(INC_MI32_STDAFX_H) && defined(WIN32_MFC)
00069 #include <mi32/stdafx.h>
00070 #endif
00071
00072 struct McbAnyCallbackStruct;
00073
00074 namespace MGUI {
00075
00076 class APP_MAIN;
00077
00078
00079
00080
00081
00082
00083 class APP_BASE {
00084 public:
00085
00086 #ifdef X_NATIVE
00087 enum LEGACYINIT {
00088 LEGACYINIT_Default = 0x00,
00089 LEGACYINIT_NoSetPosition = 0x01,
00090 LEGACYINIT_NoSetTitle = 0x02,
00091 LEGACYINIT_NoRealize = 0x04,
00092 LEGACYINIT_NoAutoSetExit = 0x08,
00093 LEGACYINIT_LockShellSize = 0x10,
00094 LEGACYINIT_NoDestroyTopOnExit = 0x20
00095 };
00096 #endif
00097
00098
00099 inline int GetCmdParmCount () const;
00100
00101
00102 inline const char* GetCmdParm (
00103 int idx
00104 ) const;
00105
00106 #if defined(WIN32_MFC)
00107 static CFont* GetDefaultFont (
00108 );
00109 #endif
00110
00111 #ifdef USE_MGUI
00112
00113
00114 static MDLGPARENT GetTopDlgParent (
00115 );
00116 #endif
00117
00118 protected:
00119
00120
00121 APP_BASE (
00122 UINT32 AllowedProduct1 = 0,
00123 UINT32 AllowedProduct2 = 0,
00124 UINT32 AllowedProduct3 = 0,
00125 UINT32 AllowedProduct4 = 0
00126 );
00127
00128
00129 virtual ~APP_BASE ();
00130
00131 #ifdef X_NATIVE
00132
00133
00134
00135 Widget MxInitLegacy (LEGACYINIT flags = LEGACYINIT_Default);
00136 #endif
00137
00138 #ifdef X_NATIVE
00139
00140
00141
00142 void SetLegacyAllowShellResize (
00143 ) { m_LegacyAllowShellResize = true; }
00144 #endif
00145
00146 private:
00147
00148 #ifndef GENERATING_DOXYGEN_OUTPUT
00149
00150 #ifdef X_NATIVE
00151 LEGACYINIT m_LegacyInitFlags;
00152 bool m_LegacyAllowShellResize;
00153 #endif
00154 #if defined(X_NATIVE) || defined(WIN32_MFC)
00155 MDLGPARENT m_TopParent;
00156 #endif
00157 #if defined(WIN32_MFC)
00158 CFont m_DftFont;
00159 CWnd m_TopWnd;
00160 #endif
00161 UINT32 m_ProductCode;
00162 UINT32 m_AllowedProducts[4];
00163
00164 UINT32 DetermineProductCode ()
00165 { return (v_DetermineProductCode()); }
00166 void ExitInstance ();
00167 const char* GetProcessName () const
00168 { return (v_GetProcessName()); }
00169 bool InitInstance ();
00170 bool IsProductAllowed (UINT32) const;
00171
00172 friend class MGUI::APP_MAIN;
00173
00174 APP_BASE (const APP_BASE&);
00175 APP_BASE& operator= (const APP_BASE&);
00176
00177 #endif
00178
00179
00180
00181
00182
00183
00184 virtual UINT32 v_DetermineProductCode () const;
00185
00186
00187 virtual void v_ExitInstance ();
00188
00189
00190
00191 virtual const char* v_GetProcessName () const = 0;
00192
00193
00194
00195
00196
00197 virtual bool v_InitInstance () = 0;
00198
00199
00200
00201 virtual bool v_PreInitInstance ();
00202
00203 };
00204 #ifdef X_NATIVE
00205 DEFINE_ENUM_OP_BITWISE(APP_BASE::LEGACYINIT);
00206 #endif
00207
00208
00209
00210
00211
00212
00213
00214 class APP_MAIN {
00215 public:
00216
00217
00218 static void Exit () { s_pMainInstance->DoExit(); }
00219
00220
00221 static APP_BASE* GetBaseInstance ()
00222 { return (s_pBaseInstance); }
00223
00224
00225 static APP_MAIN* GetMainInstance ()
00226 { return (s_pMainInstance); }
00227
00228
00229 APP_MAIN ();
00230
00231
00232 virtual ~APP_MAIN () = 0;
00233
00234
00235 int GetCmdParmCount () const
00236 { return (m_CmdParmCount); }
00237
00238
00239 const char* GetCmdParm (
00240 int idx
00241 ) const { return ((idx < 0 || idx >= m_CmdParmCount) ? NULL : m_CmdParmArray[idx]); }
00242
00243 #ifdef WIN32
00244
00245 void *GetInstanceHandle () const
00246 { return (m_hInstance); }
00247 #endif
00248
00249
00250
00251 void RemoveCmdParm (
00252 int idx
00253 );
00254
00255 #ifndef GENERATING_DOXYGEN_OUTPUT
00256 #if defined(WIN32) && !defined(WIN32_NATIVE)
00257 void DoWinMain (void *hInstance, const char *cmdline);
00258 #else
00259
00260
00261 #if !defined(WIN32_MFC)
00262 void Run();
00263 #endif
00264 void SetCmdParms (const char**, int);
00265 #endif
00266 #endif // GENERATING_DOXYGEN_OUTPUT
00267
00268 private:
00269
00270 #ifndef GENERATING_DOXYGEN_OUTPUT
00271
00272 static APP_MAIN *s_pMainInstance;
00273 static APP_BASE *s_pBaseInstance;
00274 #ifdef WIN32
00275 void *m_hInstance;
00276 char *m_ModNameStr;
00277 char *m_CmdLineStr;
00278 #endif
00279
00280 void DoExit ();
00281 void ExitInstance ();
00282 bool InitInstance ();
00283 static void OnExitXServer (McbAnyCallbackStruct*, void*);
00284 static void OnTerminate ();
00285 #if defined(WIN32) && !defined(WIN32_NATIVE)
00286 #if !defined(WIN32_MFC)
00287 void Run ();
00288 #endif
00289 void SetCmdLine (const char*);
00290 #endif
00291 #if defined(WIN32_MFC)
00292 class MyCWinApp : public CWinApp {
00293 public:
00294 MyCWinApp (
00295 APP_MAIN* AppMain
00296 ) : m_AppMain(AppMain) {}
00297
00298 private:
00299 APP_MAIN* m_AppMain;
00300
00301 virtual BOOL InitInstance ();
00302 virtual BOOL ExitInstance ();
00303
00304 friend class APP_MAIN;
00305 };
00306 friend class MyCWinApp;
00307
00308 MyCWinApp m_AppInst;
00309 #endif
00310 char **m_CmdParmArray;
00311 int m_CmdParmCount;
00312
00313 friend class MGUI::APP_BASE;
00314
00315 APP_MAIN (const APP_MAIN&);
00316 APP_MAIN& operator= (const APP_MAIN&);
00317
00318 #endif // GENERATING_DOXYGEN_OUTPUT
00319
00320
00321
00322
00323
00324 virtual void v_ExitInstance ();
00325
00326
00327
00328
00329
00330
00331 virtual bool v_InitInstance ();
00332
00333 };
00334
00335
00336 #ifndef GENERATING_DOXYGEN_OUTPUT
00337
00338
00339 inline int APP_BASE::GetCmdParmCount (
00340 ) const {
00341 APP_MAIN *pMain = APP_MAIN::GetMainInstance();
00342 return ((pMain == 0) ? 0 : pMain->GetCmdParmCount());
00343 }
00344
00345
00346 inline const char* APP_BASE::GetCmdParm (
00347 int idx
00348 ) const {
00349 APP_MAIN *pMain = APP_MAIN::GetMainInstance();
00350 return ((pMain == 0) ? 0 : pMain->GetCmdParm(idx));
00351 }
00352
00353 #endif // GENERATING_DOXYGEN_OUTPUT
00354
00355 }
00356
00357 #endif // INC_MGUI_APPMAIN_H