changeset 129:18ca5d3c6dfc

Chg to SWT: Allow MessageBox without parent, when instantiated over special ctor.
author Frank Benoit <benoit@tionex.de>
date Wed, 13 Feb 2008 00:56:11 +0100
parents 07e8963537b7
children 8e3ca45497b0
files README.txt dwt/widgets/MessageBox.d
diffstat 2 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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.
 
 
 
--- 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);
     }