mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-01 14:22:41 -06:00
Core: Exit
git-svn-id: svn://ultimatepp.org/upp/trunk@4982 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
47ddcf1b55
commit
426fb85cd3
4 changed files with 204 additions and 197 deletions
|
|
@ -305,6 +305,23 @@ void CommonInit()
|
|||
sMainRunning = true;
|
||||
}
|
||||
|
||||
void Exit(int code)
|
||||
{
|
||||
SetExitCode(code);
|
||||
throw ExitExc();
|
||||
}
|
||||
|
||||
void AppExecute__(void (*app)())
|
||||
{
|
||||
try {
|
||||
(*app)();
|
||||
}
|
||||
catch(Exc e) {
|
||||
Panic(e);
|
||||
}
|
||||
catch(ExitExc) {}
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
|
||||
void s_ill_handler(int)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,12 @@ bool IsMainRunning();
|
|||
//void Main(); // By console application
|
||||
#endif
|
||||
|
||||
struct ExitExc {};
|
||||
|
||||
void Exit(int code = 1);
|
||||
|
||||
void AppExit__();
|
||||
void AppExecute__(void (*app)());
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
|
|
@ -42,16 +47,11 @@ void AppInitEnvironment__();
|
|||
void ConsoleMainFn_(); \
|
||||
\
|
||||
int main(int argc, char *argv[]) { \
|
||||
try { \
|
||||
UPP::AppInit__(argc, (const char **)argv); \
|
||||
ConsoleMainFn_(); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
catch(Exc e) { \
|
||||
Panic(e); \
|
||||
} \
|
||||
UPP::AppInit__(argc, (const char **)argv); \
|
||||
UPP::AppExecute__(ConsoleMainFn_); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void ConsoleMainFn_()
|
||||
|
|
@ -67,7 +67,7 @@ void ConsoleMainFn_(); \
|
|||
\
|
||||
int main(int argc, const char **argv, const char **envptr) { \
|
||||
UPP::AppInit__(argc, argv, envptr); \
|
||||
ConsoleMainFn_(); \
|
||||
UPP::AppExecute__(ConsoleMainFn_); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
|
|
|
|||
|
|
@ -1,112 +1,107 @@
|
|||
class ViewDraw : public SystemDraw {
|
||||
public:
|
||||
ViewDraw(Ctrl *ctrl);
|
||||
~ViewDraw();
|
||||
|
||||
protected:
|
||||
HWND hwnd;
|
||||
};
|
||||
|
||||
|
||||
Vector<WString>& coreCmdLine__();
|
||||
Vector<WString> SplitCmdLine__(const char *cmd);
|
||||
|
||||
#ifdef PLATFORM_WINCE
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_();\
|
||||
\
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow) \
|
||||
{ \
|
||||
UPP::Ctrl::InitWin32(hInstance); \
|
||||
UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); \
|
||||
UPP::AppInitEnvironment__(); \
|
||||
try { \
|
||||
GuiMainFn_(); \
|
||||
} \
|
||||
catch(Exc e) { \
|
||||
Panic(e); \
|
||||
} \
|
||||
UPP::UsrLog("---------- About to delete this log..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::Ctrl::ExitWin32(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#else
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_();\
|
||||
\
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow) \
|
||||
{ \
|
||||
UPP::Ctrl::InitWin32(hInstance); \
|
||||
UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); \
|
||||
UPP::AppInitEnvironment__(); \
|
||||
try { \
|
||||
GuiMainFn_(); \
|
||||
} \
|
||||
catch(Exc e) { \
|
||||
Panic(e); \
|
||||
} \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
UPP::UsrLog("---------- About to delete this log..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::Ctrl::ExitWin32(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#define DLL_APP_MAIN \
|
||||
void _DllMainAppInit(); \
|
||||
\
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpReserved) \
|
||||
{ \
|
||||
if(fdwReason == DLL_PROCESS_ATTACH) { \
|
||||
Ctrl::InitWin32(AppGetHandle()); \
|
||||
AppInitEnvironment__(); \
|
||||
_DllMainAppInit(); \
|
||||
} \
|
||||
else \
|
||||
if(fdwReason == DLL_PROCESS_DETACH) { \
|
||||
Ctrl::ExitWin32(); \
|
||||
} \
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
void _DllMainAppInit()
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
|
||||
class DHCtrl : public Ctrl {
|
||||
public:
|
||||
virtual void State(int reason);
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
virtual void NcCreate(HWND hwnd);
|
||||
virtual void NcDestroy();
|
||||
|
||||
private:
|
||||
void OpenHWND();
|
||||
void SyncHWND();
|
||||
|
||||
protected:
|
||||
void CloseHWND();
|
||||
HWND hwnd;
|
||||
|
||||
public:
|
||||
HWND GetHWND() { return hwnd; }
|
||||
// void Refresh() { InvalidateRect(GetHWND(), NULL, false); }
|
||||
|
||||
DHCtrl();
|
||||
~DHCtrl();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class ViewDraw : public SystemDraw {
|
||||
public:
|
||||
ViewDraw(Ctrl *ctrl);
|
||||
~ViewDraw();
|
||||
|
||||
protected:
|
||||
HWND hwnd;
|
||||
};
|
||||
|
||||
|
||||
Vector<WString>& coreCmdLine__();
|
||||
Vector<WString> SplitCmdLine__(const char *cmd);
|
||||
|
||||
#ifdef PLATFORM_WINCE
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_();\
|
||||
\
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow) \
|
||||
{ \
|
||||
UPP::Ctrl::InitWin32(hInstance); \
|
||||
UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); \
|
||||
UPP::AppInitEnvironment__(); \
|
||||
try { \
|
||||
GuiMainFn_(); \
|
||||
} \
|
||||
catch(Exc e) { \
|
||||
Panic(e); \
|
||||
} \
|
||||
UPP::UsrLog("---------- About to delete this log..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::Ctrl::ExitWin32(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#else
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_();\
|
||||
\
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow) \
|
||||
{ \
|
||||
UPP::Ctrl::InitWin32(hInstance); \
|
||||
UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); \
|
||||
UPP::AppInitEnvironment__(); \
|
||||
UPP::AppExecute__(GuiMainFn_); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
UPP::UsrLog("---------- About to delete this log..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::Ctrl::ExitWin32(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#define DLL_APP_MAIN \
|
||||
void _DllMainAppInit(); \
|
||||
\
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpReserved) \
|
||||
{ \
|
||||
if(fdwReason == DLL_PROCESS_ATTACH) { \
|
||||
Ctrl::InitWin32(AppGetHandle()); \
|
||||
AppInitEnvironment__(); \
|
||||
UPP::AppExecute__(_DllMainAppInit); \
|
||||
} \
|
||||
else \
|
||||
if(fdwReason == DLL_PROCESS_DETACH) { \
|
||||
Ctrl::ExitWin32(); \
|
||||
} \
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
void _DllMainAppInit()
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
|
||||
class DHCtrl : public Ctrl {
|
||||
public:
|
||||
virtual void State(int reason);
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
virtual void NcCreate(HWND hwnd);
|
||||
virtual void NcDestroy();
|
||||
|
||||
private:
|
||||
void OpenHWND();
|
||||
void SyncHWND();
|
||||
|
||||
protected:
|
||||
void CloseHWND();
|
||||
HWND hwnd;
|
||||
|
||||
public:
|
||||
HWND GetHWND() { return hwnd; }
|
||||
// void Refresh() { InvalidateRect(GetHWND(), NULL, false); }
|
||||
|
||||
DHCtrl();
|
||||
~DHCtrl();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,74 +1,69 @@
|
|||
class ViewDraw : public SystemDraw {
|
||||
public:
|
||||
ViewDraw(Ctrl *ctrl);
|
||||
~ViewDraw();
|
||||
|
||||
protected:
|
||||
bool caret;
|
||||
};
|
||||
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_(); \
|
||||
\
|
||||
int main(int argc, const char **argv, const char **envptr) { \
|
||||
UPP::AppInit__(argc, argv, envptr); \
|
||||
UPP::Ctrl::InitX11(NULL); \
|
||||
try { \
|
||||
GuiMainFn_(); \
|
||||
} \
|
||||
catch(Exc e) { \
|
||||
Panic(e); \
|
||||
} \
|
||||
UPP::UsrLog("---------- About to delete this log..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::Ctrl::ExitX11(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
class DHCtrl : public Ctrl {
|
||||
int isError;
|
||||
bool isMapped;
|
||||
Size CurrentSize;
|
||||
XVisualInfo* UserVisualInfo;
|
||||
String ErrorMessage;
|
||||
|
||||
void MapWindow(bool map);
|
||||
bool Init(void);
|
||||
void Terminate(void);
|
||||
|
||||
protected:
|
||||
Visual *GetVisual(void);
|
||||
XVisualInfo GetVisualInfo(void);
|
||||
|
||||
virtual XVisualInfo *CreateVisual(void) {return 0;}
|
||||
virtual void SetAttributes(unsigned long &ValueMask, XSetWindowAttributes &attr) {}
|
||||
virtual void Paint(Draw &draw) {}
|
||||
virtual void BeforeInit(void) {}
|
||||
virtual void AfterInit(bool Error) {}
|
||||
virtual void BeforeTerminate(void) {}
|
||||
virtual void AfterTerminate(void) {}
|
||||
virtual void Resize(int w, int h) {}
|
||||
|
||||
void SetError(bool err) { isError = err; }
|
||||
void SetErrorMessage(String const &msg) { ErrorMessage = msg; }
|
||||
|
||||
virtual void State(int reason);
|
||||
|
||||
Window hwnd;
|
||||
bool isInitialized;
|
||||
|
||||
public:
|
||||
typedef DHCtrl CLASSNAME;
|
||||
|
||||
bool IsInitialized(void) { return isInitialized; }
|
||||
|
||||
bool GetError(void) { return isError; }
|
||||
String GetErrorMessage(void) { return ErrorMessage; }
|
||||
|
||||
DHCtrl();
|
||||
~DHCtrl();
|
||||
};
|
||||
class ViewDraw : public SystemDraw {
|
||||
public:
|
||||
ViewDraw(Ctrl *ctrl);
|
||||
~ViewDraw();
|
||||
|
||||
protected:
|
||||
bool caret;
|
||||
};
|
||||
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_(); \
|
||||
\
|
||||
int main(int argc, const char **argv, const char **envptr) { \
|
||||
UPP::AppInit__(argc, argv, envptr); \
|
||||
UPP::Ctrl::InitX11(NULL); \
|
||||
UPP::AppExecute__(GuiMainFn_); \
|
||||
UPP::UsrLog("---------- About to delete this log..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
UPP::Ctrl::ExitX11(); \
|
||||
UPP::AppExit__(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
class DHCtrl : public Ctrl {
|
||||
int isError;
|
||||
bool isMapped;
|
||||
Size CurrentSize;
|
||||
XVisualInfo* UserVisualInfo;
|
||||
String ErrorMessage;
|
||||
|
||||
void MapWindow(bool map);
|
||||
bool Init(void);
|
||||
void Terminate(void);
|
||||
|
||||
protected:
|
||||
Visual *GetVisual(void);
|
||||
XVisualInfo GetVisualInfo(void);
|
||||
|
||||
virtual XVisualInfo *CreateVisual(void) {return 0;}
|
||||
virtual void SetAttributes(unsigned long &ValueMask, XSetWindowAttributes &attr) {}
|
||||
virtual void Paint(Draw &draw) {}
|
||||
virtual void BeforeInit(void) {}
|
||||
virtual void AfterInit(bool Error) {}
|
||||
virtual void BeforeTerminate(void) {}
|
||||
virtual void AfterTerminate(void) {}
|
||||
virtual void Resize(int w, int h) {}
|
||||
|
||||
void SetError(bool err) { isError = err; }
|
||||
void SetErrorMessage(String const &msg) { ErrorMessage = msg; }
|
||||
|
||||
virtual void State(int reason);
|
||||
|
||||
Window hwnd;
|
||||
bool isInitialized;
|
||||
|
||||
public:
|
||||
typedef DHCtrl CLASSNAME;
|
||||
|
||||
bool IsInitialized(void) { return isInitialized; }
|
||||
|
||||
bool GetError(void) { return isError; }
|
||||
String GetErrorMessage(void) { return ErrorMessage; }
|
||||
|
||||
DHCtrl();
|
||||
~DHCtrl();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue