changeset 208:fff9f748b33b

Added convinience methods in MessageBox now they are same as in dwt-win
author Frank Benoit <benoit@tionex.de>
date Sat, 15 Mar 2008 17:48:15 +0100
parents 12feeed18183
children ce1c1d1e97f8
files dwt/widgets/MessageBox.d
diffstat 1 files changed, 48 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/MessageBox.d	Sun Mar 09 10:58:49 2008 +0100
+++ b/dwt/widgets/MessageBox.d	Sat Mar 15 17:48:15 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -47,6 +47,7 @@
 
     char[] message = "";
     GtkWidget* handle;
+    private bool allowNullParent = false;
 /**
  * Constructs a new instance of this class given only its parent.
  *
@@ -92,6 +93,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 );
+    }
+}
+
 /**
  * Returns the dialog's message, or an empty string if it does not have one.
  * The message is a description of the purpose for which the dialog was opened.
@@ -197,4 +214,34 @@
     }
     return result[ 0 .. j ];
 }
+
+
+/**
+ * DWT extension
+ */
+public static int showMessageBox(char[] str, char[] title, Shell shell, int style) {
+    MessageBox msgBox = (shell is null ) ? new MessageBox( style ) : new MessageBox(shell, style);
+    msgBox.setMessage(str);
+    if(title !is null){
+        msgBox.setText(title);
+    }
+    return msgBox.open();
 }
+
+/// DWT extension
+public static int showInfo(char[] str, char[] title = null, Shell shell = null) {
+    return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_INFORMATION );
+}
+/// DWT extension
+alias showInfo showInformation;
+
+/// DWT extension
+public static int showWarning(char[] str, char[] title = null, Shell shell = null) {
+    return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_WARNING );
+}
+/// DWT extension
+public static int showError(char[] str, char[] title = null, Shell shell = null) {
+    return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_ERROR );
+}
+
+}