1 // Written by Christopher E. Miller
2 // See the included license.txt for copyright and license details.
3 
4 
5 ///
6 module dfl.messagebox;
7 
8 private import dfl.internal.winapi, dfl.internal.dlib, dfl.base;
9 
10 
11 ///
12 enum MsgBoxButtons
13 {
14 	ABORT_RETRY_IGNORE = MB_ABORTRETRYIGNORE, ///
15 	OK = MB_OK, /// ditto
16 	OK_CANCEL = MB_OKCANCEL, /// ditto
17 	RETRY_CANCEL = MB_RETRYCANCEL, /// ditto
18 	YES_NO = MB_YESNO, /// ditto
19 	YES_NO_CANCEL = MB_YESNOCANCEL, /// ditto
20 }
21 
22 
23 ///
24 enum MsgBoxIcon
25 {
26 	NONE = 0, ///
27 	
28 	ASTERISK = MB_ICONASTERISK, /// ditto
29 	ERROR = MB_ICONERROR, /// ditto
30 	EXCLAMATION = MB_ICONEXCLAMATION, /// ditto
31 	HAND = MB_ICONHAND, /// ditto
32 	INFORMATION = MB_ICONINFORMATION, /// ditto
33 	QUESTION = MB_ICONQUESTION, /// ditto
34 	STOP = MB_ICONSTOP, /// ditto
35 	WARNING = MB_ICONWARNING, /// ditto
36 }
37 
38 
39 enum MsgBoxDefaultButton
40 {
41 	BUTTON1 = MB_DEFBUTTON1, ///
42 	BUTTON2 = MB_DEFBUTTON2, /// ditto
43 	BUTTON3 = MB_DEFBUTTON3, /// ditto
44 	
45 	// Extra.
46 	BUTTON4 = MB_DEFBUTTON4,
47 }
48 
49 
50 ///
51 enum MsgBoxOptions
52 {
53 	DEFAULT_DESKTOP_ONLY = MB_DEFAULT_DESKTOP_ONLY, ///
54 	RIGHT_ALIGN = MB_RIGHT, /// ditto
55 	LEFT_ALIGN = MB_RTLREADING, /// ditto
56 	SERVICE_NOTIFICATION = MB_SERVICE_NOTIFICATION, /// ditto
57 }
58 
59 
60 ///
61 DialogResult msgBox(Dstring txt) // docmain
62 {
63 	return cast(DialogResult)dfl.internal.utf.messageBox(GetActiveWindow(), txt, "\0", MB_OK);
64 }
65 
66 /// ditto
67 DialogResult msgBox(IWindow owner, Dstring txt) // docmain
68 {
69 	return cast(DialogResult)dfl.internal.utf.messageBox(owner ? owner.handle : GetActiveWindow(),
70 		txt, "\0", MB_OK);
71 }
72 
73 /// ditto
74 DialogResult msgBox(Dstring txt, Dstring caption) // docmain
75 {
76 	return cast(DialogResult)dfl.internal.utf.messageBox(GetActiveWindow(), txt, caption, MB_OK);
77 }
78 
79 /// ditto
80 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption) // docmain
81 {
82 	return cast(DialogResult)dfl.internal.utf.messageBox(owner ? owner.handle : GetActiveWindow(),
83 		txt, caption, MB_OK);
84 }
85 
86 /// ditto
87 DialogResult msgBox(Dstring txt, Dstring caption, MsgBoxButtons buttons) // docmain
88 {
89 	return cast(DialogResult)dfl.internal.utf.messageBox(GetActiveWindow(), txt, caption, buttons);
90 }
91 
92 /// ditto
93 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption,
94 	MsgBoxButtons buttons) // docmain
95 {
96 	return cast(DialogResult)dfl.internal.utf.messageBox(owner ? owner.handle : GetActiveWindow(),
97 		txt, caption, buttons);
98 }
99 
100 /// ditto
101 DialogResult msgBox(Dstring txt, Dstring caption, MsgBoxButtons buttons,
102 	MsgBoxIcon icon) // docmain
103 {
104 	return cast(DialogResult)dfl.internal.utf.messageBox(GetActiveWindow(), txt,
105 		caption, buttons | icon);
106 }
107 
108 /// ditto
109 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, MsgBoxButtons buttons,
110 	MsgBoxIcon icon) // docmain
111 {
112 	return cast(DialogResult)dfl.internal.utf.messageBox(owner ? owner.handle : GetActiveWindow(),
113 		txt, caption, buttons | icon);
114 }
115 
116 /// ditto
117 DialogResult msgBox(Dstring txt, Dstring caption, MsgBoxButtons buttons, MsgBoxIcon icon,
118 	MsgBoxDefaultButton defaultButton) // docmain
119 {
120 	return cast(DialogResult)dfl.internal.utf.messageBox(GetActiveWindow(), txt,
121 		caption, buttons | icon | defaultButton);
122 }
123 
124 /// ditto
125 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, MsgBoxButtons buttons,
126 	MsgBoxIcon icon, MsgBoxDefaultButton defaultButton) // docmain
127 {
128 	return cast(DialogResult)dfl.internal.utf.messageBox(owner ? owner.handle : GetActiveWindow(),
129 		txt, caption, buttons | icon | defaultButton);
130 }
131 
132 /// ditto
133 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, MsgBoxButtons buttons,
134 	MsgBoxIcon icon, MsgBoxDefaultButton defaultButton, MsgBoxOptions options) // docmain
135 {
136 	return cast(DialogResult)dfl.internal.utf.messageBox(owner ? owner.handle : GetActiveWindow(),
137 		txt, caption, buttons | icon | defaultButton | options);
138 }
139 
140 
141 deprecated final class MessageBox
142 {
143 	private this() {}
144 	
145 	
146 	static:
147 	deprecated alias msgBox show;
148 }
149 
150 
151 deprecated alias msgBox messageBox;
152 
153 deprecated alias MsgBoxOptions MessageBoxOptions;
154 deprecated alias MsgBoxDefaultButton MessageBoxDefaultButton;
155 deprecated alias MsgBoxButtons MessageBoxButtons;
156 deprecated alias MsgBoxIcon MessageBoxIcon;
157