Show cursor on exit
[utui.git] / app.h
blobb7ad36aec1e2842daac03419f65c9fe7de1ca3f4
1 // This file is part of the utui library, a terminal UI framework.
2 //
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
5 //
6 // app.h
7 //
9 #ifndef APP_H_226555EB37A021D97E5DB2EB1D8A12CD
10 #define APP_H_226555EB37A021D97E5DB2EB1D8A12CD
12 /// \class CApplication app.h utui.h
13 ///
14 /// This is the main application class base. To create a utui application,
15 /// derive a singleton class from CApplication and use the WinMain macro
16 /// to instantiate it.
17 ///
18 class CApplication {
19 public:
20 typedef int argc_t;
21 typedef const char* const* argv_t;
22 public:
23 inline virtual ~CApplication (void) { }
24 int Run (argc_t argc, argv_t argv);
25 protected:
26 CApplication (void);
27 virtual void OnCreate (argc_t argc, argv_t argv);
28 virtual void OnDestroy (void);
31 //----------------------------------------------------------------------
33 extern "C" void InstallCleanupHandlers (void);
35 //----------------------------------------------------------------------
37 template <typename T>
38 inline int TWinMain (int argc, const char* const* argv)
40 InstallCleanupHandlers();
41 return (T::Instance().Run (argc, argv));
44 #define WinMain(AppClass) \
45 int main (int argc, const char* const* argv) \
46 { \
47 return (TWinMain<AppClass> (argc, argv)); \
50 //----------------------------------------------------------------------
52 #endif