1 // This file is part of the utui library, a terminal UI framework.
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
11 /// Default constructor.
12 CDialog::CDialog (void)
16 /// Draws the dialog window.
17 void CDialog::OnDraw (CGC
& gc
)
19 gc
.Color (black
, cyan
);
21 gc
.Box (WindowArea());
25 void CDialog::OnKey (wchar_t 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.