# HG changeset patch # User Frank Benoit # Date 1202860571 -3600 # Node ID 18ca5d3c6dfc64c834ed7f4d8ad72b0375af7bc5 # Parent 07e8963537b7b1f797baee734eff433ccf7ece71 Chg to SWT: Allow MessageBox without parent, when instantiated over special ctor. diff -r 07e8963537b7 -r 18ca5d3c6dfc README.txt --- a/README.txt Tue Feb 12 21:25:00 2008 +0100 +++ b/README.txt Wed Feb 13 00:56:11 2008 +0100 @@ -42,6 +42,10 @@ +Changes/Additions to SWT +======================== + o MessageBox can be instantiated without parent. Use the Ctor "this( int style )", + calling the other ctors will still force a non-null parent. diff -r 07e8963537b7 -r 18ca5d3c6dfc dwt/widgets/MessageBox.d --- a/dwt/widgets/MessageBox.d Tue Feb 12 21:25:00 2008 +0100 +++ b/dwt/widgets/MessageBox.d Wed Feb 13 00:56:11 2008 +0100 @@ -42,6 +42,7 @@ */ public class MessageBox : Dialog { char[] message = ""; + private bool allowNullParent = false; /** * Constructs a new instance of this class given only its parent. @@ -88,6 +89,22 @@ checkSubclass (); } +/** + * DWT extension, a MessageBox with no parent + */ +public this (int style) { + allowNullParent = true; + super (parent, checkStyle (style)); + checkSubclass (); +} +// PORT +// actually, the parent can be null +override void checkParent (Shell parent){ + if( !allowNullParent ){ + super.checkParent( parent ); + } +} + static int checkStyle (int style) { if ((style & (DWT.PRIMARY_MODAL | DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) is 0) style |= DWT.APPLICATION_MODAL; int mask = (DWT.YES | DWT.NO | DWT.OK | DWT.CANCEL | DWT.ABORT | DWT.RETRY | DWT.IGNORE); @@ -185,7 +202,7 @@ Shell oldModal = null; Display display = null; if ((bits & OS.MB_TASKMODAL) !is 0) { - display = parent.getDisplay (); + display = ( allowNullParent && parent is null ) ? Display.getCurrent() : parent.getDisplay (); oldModal = display.getModalDialogShell (); display.setModalDialogShell (parent); }