Show cursor on exit
[utui.git] / rootwin.h
blob1d495c858d0f783332351612b497cb6250cf4923
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 // rootwin.h
7 //
9 #ifndef ROOTWIN_H_66E7B71D025F65121A9EDB8A49C962B3
10 #define ROOTWIN_H_66E7B71D025F65121A9EDB8A49C962B3
12 #include "window.h"
14 class CDialog;
16 /// \class CRootWindow rootwin.h utui.h
17 ///
18 /// This is the one and only root window of an application. It handles
19 /// combining the output of all its child windows and rendering the result
20 /// to the terminal. It also manages the event loop, receives and routes
21 /// user input, and rations idle processing.
22 ///
23 class CRootWindow : public CWindow {
24 public:
25 static CRootWindow& Instance (void);
26 virtual ~CRootWindow (void);
27 virtual void OnCreate (void);
28 virtual void OnDestroy (void);
29 virtual void OnResize (rcrect_t wr);
30 void OnError (exception& e);
31 int Run (void);
32 int RunModal (CDialog* pw);
33 static inline void SetIdleTimeout (long v) { s_IdleTimeout = v; }
34 static inline void SetMinIdleTimeout (long v) { s_IdleTimeout = min (s_IdleTimeout, v); }
35 protected:
36 void Flush (void);
37 virtual void OnChildClose (uoff_t i);
38 private:
39 CRootWindow (void);
40 wchar_t GetKey (void) const;
41 private:
42 CTerminfo m_TI; ///< The terminfo rendering backend object.
43 CKeyboard m_Kb; ///< The terminal keyboard driver.
44 CGC m_Screen; ///< Currently visible screen buffer.
45 Point2d m_ScreenPos; ///< Cursor position on the screen, if any.
46 static long s_IdleTimeout; ///< How often to call OnIdle in absence of keystrokes.
47 static int s_ModalStack [15]; ///< Return values of currently active modal dialogs.
48 static unsigned int s_ModalDepth; ///< Depth of the current modal call stack.
51 #endif