1 /** DGui project file.
2 
3 Copyright: Trogu Antonio Davide 2011-2013
4 
5 License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 
7 Authors: Trogu Antonio Davide
8 */
9 module dgui.messagebox;
10 
11 import std.utf: toUTFz;
12 private import dgui.core.winapi;
13 public import dgui.core.dialogs.dialogresult;
14 
15 enum MsgBoxButtons: uint
16 {
17 	ok = MB_OK,
18 	yesNo = MB_YESNO,
19 	okCancel = MB_OKCANCEL,
20 	retryCancel = MB_RETRYCANCEL,
21 	yesNoCancel = MB_YESNOCANCEL,
22 	abortRetryIgnore = MB_ABORTRETRYIGNORE,
23 }
24 
25 enum MsgBoxIcons: uint
26 {
27 	none = 0,
28 	warning = MB_ICONWARNING,
29 	information = MB_ICONINFORMATION,
30 	question = MB_ICONQUESTION,
31 	error = MB_ICONERROR,
32 }
33 
34 final class MsgBox
35 {
36 	private this()
37 	{
38 
39 	}
40 
41 	public static DialogResult show(string title, string text, MsgBoxButtons button, MsgBoxIcons icon)
42 	{
43 		return cast(DialogResult)MessageBoxW(GetActiveWindow(), toUTFz!(wchar*)(text), toUTFz!(wchar*)(title), button | icon);
44 	}
45 
46 	public static DialogResult show(string title, string text, MsgBoxButtons button)
47 	{
48 		return MsgBox.show(title, text, button, MsgBoxIcons.none);
49 	}
50 
51 	public static DialogResult show(string title, string text, MsgBoxIcons icon)
52 	{
53 		return MsgBox.show(title, text, MsgBoxButtons.ok, icon);
54 	}
55 
56 	public static DialogResult show(string title, string text)
57 	{
58 		return MsgBox.show(title, text, MsgBoxButtons.ok, MsgBoxIcons.none);
59 	}
60 }