Mercurial > projects > dwt-win
comparison dwt/widgets/MessageBox.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | fd9c62a2998e |
comparison
equal
deleted
inserted
replaced
212:ab60f3309436 | 213:36f5cb12e1a2 |
---|---|
40 * IMPORTANT: This class is intended to be subclassed <em>only</em> | 40 * IMPORTANT: This class is intended to be subclassed <em>only</em> |
41 * within the DWT implementation. | 41 * within the DWT implementation. |
42 * </p> | 42 * </p> |
43 */ | 43 */ |
44 public class MessageBox : Dialog { | 44 public class MessageBox : Dialog { |
45 | |
46 alias Dialog.checkStyle checkStyle; | |
47 | |
45 String message = ""; | 48 String message = ""; |
46 private bool allowNullParent = false; | 49 private bool allowNullParent = false; |
47 | 50 |
48 /** | 51 /** |
49 * Constructs a new instance of this class given only its parent. | 52 * Constructs a new instance of this class given only its parent. |
84 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | 87 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
85 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | 88 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> |
86 * </ul> | 89 * </ul> |
87 */ | 90 */ |
88 public this (Shell parent, int style) { | 91 public this (Shell parent, int style) { |
89 super (parent, checkStyle (style)); | 92 super (parent, checkStyle (parent, checkStyle (style))); |
90 checkSubclass (); | 93 checkSubclass (); |
91 } | 94 } |
92 | 95 |
93 /++ | 96 /++ |
94 + DWT extension, a MessageBox with no parent | 97 + DWT extension, a MessageBox with no parent |
95 +/ | 98 +/ |
96 public this (int style) { | 99 public this (int style) { |
97 allowNullParent = true; | 100 allowNullParent = true; |
98 super (parent, checkStyle (style)); | 101 this( null, style ); |
99 checkSubclass (); | |
100 } | 102 } |
101 // PORT | 103 // PORT |
102 // actually, the parent can be null | 104 // actually, the parent can be null |
103 override void checkParent (Shell parent){ | 105 override void checkParent (Shell parent){ |
104 if( !allowNullParent ){ | 106 if( !allowNullParent ){ |
105 super.checkParent( parent ); | 107 super.checkParent( parent ); |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 static int checkStyle (int style) { | 111 static int checkStyle (int style) { |
110 if ((style & (DWT.PRIMARY_MODAL | DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) is 0) style |= DWT.APPLICATION_MODAL; | |
111 int mask = (DWT.YES | DWT.NO | DWT.OK | DWT.CANCEL | DWT.ABORT | DWT.RETRY | DWT.IGNORE); | 112 int mask = (DWT.YES | DWT.NO | DWT.OK | DWT.CANCEL | DWT.ABORT | DWT.RETRY | DWT.IGNORE); |
112 int bits = style & mask; | 113 int bits = style & mask; |
113 if (bits is DWT.OK || bits is DWT.CANCEL || bits is (DWT.OK | DWT.CANCEL)) return style; | 114 if (bits is DWT.OK || bits is DWT.CANCEL || bits is (DWT.OK | DWT.CANCEL)) return style; |
114 if (bits is DWT.YES || bits is DWT.NO || bits is (DWT.YES | DWT.NO) || bits is (DWT.YES | DWT.NO | DWT.CANCEL)) return style; | 115 if (bits is DWT.YES || bits is DWT.NO || bits is (DWT.YES | DWT.NO) || bits is (DWT.YES | DWT.NO | DWT.CANCEL)) return style; |
115 if (bits is (DWT.RETRY | DWT.CANCEL) || bits is (DWT.ABORT | DWT.RETRY | DWT.IGNORE)) return style; | 116 if (bits is (DWT.RETRY | DWT.CANCEL) || bits is (DWT.ABORT | DWT.RETRY | DWT.IGNORE)) return style; |
198 * same as MB_APPLMODAL. The fix to set the parent HWND | 199 * same as MB_APPLMODAL. The fix to set the parent HWND |
199 * anyway and not rely on MB_MODAL to work by making the | 200 * anyway and not rely on MB_MODAL to work by making the |
200 * parent be temporarily modal. | 201 * parent be temporarily modal. |
201 */ | 202 */ |
202 HWND hwndOwner = parent !is null ? parent.handle : null; | 203 HWND hwndOwner = parent !is null ? parent.handle : null; |
203 Shell oldModal = null; | 204 Dialog oldModal = null; |
204 Display display = null; | 205 Display display = null; |
205 if ((bits & OS.MB_TASKMODAL) !is 0) { | 206 if ((bits & OS.MB_TASKMODAL) !is 0) { |
206 display = ( allowNullParent && parent is null ) ? Display.getCurrent() : parent.getDisplay (); | 207 display = ( allowNullParent && parent is null ) ? Display.getCurrent() : parent.getDisplay (); |
207 oldModal = display.getModalDialogShell (); | 208 oldModal = display.getModalDialog (); |
208 display.setModalDialogShell (parent); | 209 display.setModalDialog (this); |
209 } | 210 } |
210 | 211 |
211 /* Open the message box */ | 212 /* Open the message box */ |
212 /* Use the character encoding for the default locale */ | 213 /* Use the character encoding for the default locale */ |
213 TCHAR[] buffer1 = StrToTCHARs (0, message, true); | 214 TCHAR[] buffer1 = StrToTCHARs (0, message, true); |
214 TCHAR[] buffer2 = StrToTCHARs (0, title, true); | 215 TCHAR[] buffer2 = StrToTCHARs (0, title, true); |
215 int code = OS.MessageBox (hwndOwner, buffer1.ptr, buffer2.ptr, bits); | 216 int code = OS.MessageBox (hwndOwner, buffer1.ptr, buffer2.ptr, bits); |
216 | 217 |
217 /* Clear the temporarily dialog modal parent */ | 218 /* Clear the temporarily dialog modal parent */ |
218 if ((bits & OS.MB_TASKMODAL) !is 0) { | 219 if ((bits & OS.MB_TASKMODAL) !is 0) { |
219 display.setModalDialogShell (oldModal); | 220 display.setModalDialog (oldModal); |
220 } | 221 } |
221 | 222 |
222 /* | 223 /* |
223 * This code is intentionally commented. On some | 224 * This code is intentionally commented. On some |
224 * platforms, the owner window is repainted right | 225 * platforms, the owner window is repainted right |