00001
00040 #ifndef INC_MGUI_APPMAIN_H
00041 #define INC_MGUI_APPMAIN_H
00042
00043 #ifndef INC_MI32_ICONID_H
00044 #include <mi32/iconid.h>
00045 #endif
00046
00047 #if !defined(_XtIntrinsic_h)
00048 #include <X11/Intrinsic.h>
00049 #endif
00050
00051 #ifndef INC_MI32_MILIST_H
00052 #include <mi32/milist.h>
00053 #endif
00054
00055 #ifndef INC_MI32_DELEGATE_H
00056 #include <mi32/delegate.h>
00057 #endif
00058
00059 #ifndef INC_MI32_CRITSEC_H
00060 #include <mi32/critsec.h>
00061 #endif
00062
00063
00064 #ifndef GENERATING_DOXYGEN_OUTPUT
00065
00066 struct McbAnyCallbackStruct;
00067 class FILEPATH;
00068 namespace MGUI {
00069 class APP_MAIN;
00070 class TIMER;
00071 }
00072 #endif
00073
00074
00075 namespace MGUI {
00076
00077
00078
00084 class APP_BASE {
00085 public:
00086
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
00099 static MDLGPARENT GetTopDlgParent ();
00100
00102 inline int GetCmdParmCount () const;
00103
00105 inline const char* GetCmdParm (
00106 int idx
00107 ) const;
00108
00111 bool GetCmdParmPath (
00112 int idx,
00113 FILEPATH& pathret
00114 ) const;
00115
00117 ICONID GetDefaultIconID (
00118 ) const { return (v_GetDefaultIconID()); }
00119
00120 protected:
00121
00123 APP_BASE (
00124 UINT32 AllowedProduct1 = 0,
00125 UINT32 AllowedProduct2 = 0,
00126 UINT32 AllowedProduct3 = 0,
00127 UINT32 AllowedProduct4 = 0
00128 );
00129
00131 virtual ~APP_BASE ();
00132
00137 DEPRECATED Widget MxInitLegacy (LEGACYINIT flags = LEGACYINIT_Default);
00138
00142 void SetLegacyAllowShellResize (
00143 ) { m_LegacyAllowShellResize = true; }
00144
00145 private:
00146 #ifndef GENERATING_DOXYGEN_OUTPUT
00147
00148 LEGACYINIT m_LegacyInitFlags;
00149 bool m_LegacyAllowShellResize;
00150 MDLGPARENT m_TopParent;
00151 UINT32 m_ProductCode;
00152 UINT32 m_AllowedProducts[4];
00153 MILIST<DELEGATE_VOID_NOPARMS> m_QueuedDelegates;
00154 MGUI::TIMER *m_pQueueTimer;
00155 MITHREAD::CRITICALSECTION m_QueueCritSec;
00156
00157 void AddQueuedDelegate (DELEGATE_VOID_NOPARMS delegate);
00158 void EnableQueueDelegates (bool enable);
00159 UINT32 DetermineProductCode ()
00160 { return (v_DetermineProductCode()); }
00161 void ExitInstance ();
00162 const char* GetProcessName () const
00163 { return (v_GetProcessName()); }
00164 bool InitInstance ();
00165 bool IsProductAllowed (UINT32) const;
00166 void OnQueueTimer ();
00167 void RemoveQueuedDelegate (DELEGATE_VOID_NOPARMS delegate);
00168
00169 friend class MGUI::APP_MAIN;
00170
00171 APP_BASE (const APP_BASE&);
00172 APP_BASE& operator= (const APP_BASE&);
00173
00174 #endif // GENERATING_DOXYGEN_OUTPUT
00175
00176
00177
00181 virtual UINT32 v_DetermineProductCode () const;
00182
00184 virtual void v_ExitInstance ();
00185
00190 virtual ICONID v_GetDefaultIconID () const;
00191
00194 virtual const char* v_GetProcessName () const = 0;
00195
00197 virtual void v_GetSessionLogPath (FILEPATH& path);
00198
00203 virtual bool v_InitInstance () = 0;
00204
00207 virtual bool v_PreInitInstance ();
00208
00209 };
00210
00211 #ifndef GENERATING_DOXYGEN_OUTPUT
00212 DEFINE_ENUM_OP_BITWISE(APP_BASE::LEGACYINIT)
00213 #endif
00214
00215
00216
00222 class APP_MAIN {
00223 public:
00224
00228 static void AddQueuedDelegate (
00229 DELEGATE_VOID_NOPARMS delegate
00230 );
00231
00233 static void EnableQueueDelegates (
00234 bool enable = true
00235 );
00236
00238 static void Exit () { s_pMainInstance->DoExit(); }
00239
00241 static APP_BASE* GetBaseInstance ()
00242 { return (s_pBaseInstance); }
00243
00245 static ICONID GetDefaultIconID ();
00246
00248 static APP_MAIN* GetMainInstance ()
00249 { return (s_pMainInstance); }
00250
00254 static void ProcessPendingEvent ();
00255
00259 static void ProcessPendingEvents ();
00260
00262 static void RemoveQueuedDelegate (
00263 DELEGATE_VOID_NOPARMS delegate
00264 );
00265
00267 APP_MAIN ();
00268
00270 virtual ~APP_MAIN () = 0;
00271
00273 int GetCmdParmCount () const
00274 { return (m_CmdParmCount); }
00275
00277 const char* GetCmdParm (
00278 int idx
00279 ) const { return ((idx < 0 || idx >= m_CmdParmCount) ? NULL : m_CmdParmArray[idx]); }
00280
00281 #ifdef WIN32
00283 void *GetInstanceHandle () const
00284 { return (m_hInstance); }
00285 #endif
00286
00289 void RemoveCmdParm (
00290 int idx
00291 );
00292
00293 #ifndef GENERATING_DOXYGEN_OUTPUT
00294 #if defined(WIN32)
00295 void DoWinMain (void *hInstance, const char *cmdline);
00296 #else
00297
00298
00299 void Run();
00300 void SetCmdParms (const char**, int);
00301 #endif
00302 #endif // GENERATING_DOXYGEN_OUTPUT
00303
00304 private:
00305
00306 #ifndef GENERATING_DOXYGEN_OUTPUT
00307
00308 static APP_MAIN *s_pMainInstance;
00309 static APP_BASE *s_pBaseInstance;
00310 #ifdef WIN32
00311 void *m_hInstance;
00312 char *m_ModNameStr;
00313 char *m_CmdLineStr;
00314 #endif
00315
00316 void DoExit ();
00317 void ExitInstance ();
00318 bool InitInstance ();
00319 static void OnExitXServer (McbAnyCallbackStruct*, void*);
00320 static void OnTerminate ();
00321
00322 #if defined(WIN32)
00323 void Run ();
00324 #endif
00325
00326 #if defined(WIN32)
00327 void SetCmdLine (const char*);
00328 #endif
00329 char **m_CmdParmArray;
00330 int m_CmdParmCount;
00331
00332 friend class MGUI::APP_BASE;
00333
00334 APP_MAIN (const APP_MAIN&);
00335 APP_MAIN& operator= (const APP_MAIN&);
00336
00337 #endif // GENERATING_DOXYGEN_OUTPUT
00338
00339
00340
00343 virtual void v_ExitInstance ();
00344
00350 virtual bool v_InitInstance ();
00351
00352 };
00353
00354
00355
00357 class APP_JOB : public APP_BASE {
00358 public:
00359 APP_JOB (
00360 UINT32 AllowedProduct1 = 0,
00361 UINT32 AllowedProduct2 = 0,
00362 UINT32 AllowedProduct3 = 0,
00363 UINT32 AllowedProduct4 = 0
00364 );
00365 ~APP_JOB () {}
00366
00367 protected:
00368 virtual bool v_InitInstance ();
00369
00370 private:
00371 #ifndef GENERATING_DOXYGEN_OUTPUT
00372 void ExecuteJob (FILEPATH path);
00373
00374 virtual ERRVALUE v_RunJob(const FILEPATH& path);
00375
00376
00377 virtual void v_GetSessionLogPath (FILEPATH& path);
00378 #endif // GENERATING_DOXYGEN_OUTPUT
00379 };
00380
00381
00382
00383 #ifndef GENERATING_DOXYGEN_OUTPUT
00384
00386 inline int APP_BASE::GetCmdParmCount (
00387 ) const {
00388 APP_MAIN *pMain = APP_MAIN::GetMainInstance();
00389 return ((pMain == 0) ? 0 : pMain->GetCmdParmCount());
00390 }
00391
00393 inline const char* APP_BASE::GetCmdParm (
00394 int idx
00395 ) const {
00396 APP_MAIN *pMain = APP_MAIN::GetMainInstance();
00397 return ((pMain == 0) ? 0 : pMain->GetCmdParm(idx));
00398 }
00399
00400 #endif // GENERATING_DOXYGEN_OUTPUT
00401
00402
00403
00404 }
00405
00406 #endif // INC_MGUI_APPMAIN_H