Show cursor on exit
[utui.git] / dialog.cc
blob5ad563abee373f0c4cddd2348abea7407d4ba265
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 // dialog.cc
7 //
9 #include "dialog.h"
11 /// Default constructor.
12 CDialog::CDialog (void)
16 /// Draws the dialog window.
17 void CDialog::OnDraw (CGC& gc)
19 gc.Color (black, cyan);
20 CWindow::OnDraw (gc);
21 gc.Box (WindowArea());
24 /// Processes \p key.
25 void CDialog::OnKey (wchar_t key)
27 switch (key) {
28 case kv_Tab: SetFocus (GetNextFocus()); break;
29 case kv_Tab | kvm_Shift:
30 SetFocus (GetNextFocus(-1)); break;
31 default: CWindow::OnKey (key); break;
35 /// Closes the dialog when a control closes itself.
36 /// This allows delegation of command closings to controls.
37 void CDialog::OnChildClose (uoff_t i)
39 CWindow::OnChildClose (i);
40 Close (CW(i).Status());
43 /// Returns the recommended area of the window when in \p r.
44 void CDialog::SizeHints (rrect_t wr) const
46 const Size2d scrsz (wr.Size());
47 CWindow::SizeHints (wr);
48 wr += (scrsz - wr.Size()) / 2; // Center the dialog on the screen.