changeset 128:07399639c0c8

Added DWT extension to dwt.widgets.MessageBox
author Jacob Carlborg <doob@me.com>
date Sat, 17 Jan 2009 16:26:49 +0100
parents 8086e7b181a3
children ad4e1fe71a5a
files .hgignore dwt/accessibility/Accessible.d dwt/browser/Mozilla.d dwt/custom/AnimatedProgress.d dwt/custom/BusyIndicator.d dwt/custom/CCombo.d dwt/custom/StyledText.d dwt/custom/StyledTextRenderer.d dwt/custom/TableEditor.d dwt/custom/TableTreeEditor.d dwt/custom/TreeEditor.d dwt/dnd/DropTarget.d dwt/dwthelper/System.d dwt/dwthelper/utils.d dwt/graphics/Device.d dwt/internal/BidiUtil.d dwt/internal/objc/runtime.d dwt/program/Program.d dwt/widgets/Display.d dwt/widgets/MessageBox.d dwt/widgets/RunnableLock.d dwt/widgets/Synchronizer.d dwt/widgets/Text.d dwt/widgets/ToolTip.d
diffstat 24 files changed, 87 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Jan 16 23:36:08 2009 +0100
+++ b/.hgignore	Sat Jan 17 16:26:49 2009 +0100
@@ -6,4 +6,6 @@
 *.orig
 dsss_imports
 *.sh
-*.a
\ No newline at end of file
+*.a
+*.rf
+*.dylib
\ No newline at end of file
--- a/dwt/accessibility/Accessible.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/accessibility/Accessible.d	Sat Jan 17 16:26:49 2009 +0100
@@ -47,7 +47,6 @@
 import dwt.accessibility.AccessibleTextEvent;
 import dwt.accessibility.AccessibleTextListener;
 import dwt.accessibility.SWTAccessibleDelegate;
-import dwt.dwthelper.array;
 
 /**
  * Instances of this class provide a bridge between application
--- a/dwt/browser/Mozilla.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/browser/Mozilla.d	Sat Jan 17 16:26:49 2009 +0100
@@ -125,8 +125,6 @@
 import dwt.widgets.Shell;
 import dwt.widgets.Control;
 
-import dwt.dwthelper.array;
-
 class Mozilla : WebBrowser, 
                 nsIWeakReference, 
                 nsIWebProgressListener, 
--- a/dwt/custom/AnimatedProgress.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/AnimatedProgress.d	Sat Jan 17 16:26:49 2009 +0100
@@ -12,6 +12,7 @@
  *******************************************************************************/
 module dwt.custom.AnimatedProgress;
 
+import dwt.dwthelper.utils;
 
 import dwt.DWT;
 import dwt.DWTException;
@@ -28,7 +29,6 @@
 import dwt.widgets.Canvas;
 import dwt.widgets.Composite;
 import dwt.widgets.Display;
-import dwt.dwthelper.Runnable;
 
 /**
  * A control for showing progress feedback for a long running operation.
--- a/dwt/custom/BusyIndicator.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/BusyIndicator.d	Sat Jan 17 16:26:49 2009 +0100
@@ -18,7 +18,7 @@
 import dwt.graphics.Cursor;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
-import dwt.dwthelper.Runnable;
+
 import dwt.dwthelper.utils;
 
 /**
--- a/dwt/custom/CCombo.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/CCombo.d	Sat Jan 17 16:26:49 2009 +0100
@@ -50,8 +50,8 @@
 static import tango.text.convert.Utf;
 static import tango.text.Unicode;
 static import tango.text.convert.Format;
+
 import dwt.dwthelper.utils;
-import dwt.dwthelper.Runnable;
 
 /**
  * The CCombo class represents a selectable user interface object
--- a/dwt/custom/StyledText.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/StyledText.d	Sat Jan 17 16:26:49 2009 +0100
@@ -81,7 +81,6 @@
 import dwt.custom.StyledTextDropTargetEffect;
 import dwt.custom.StyledTextListener;
 import dwt.custom.ST;
-import dwt.dwthelper.Runnable;
 
 static import tango.text.Text;
 static import tango.text.Util;
--- a/dwt/custom/StyledTextRenderer.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/StyledTextRenderer.d	Sat Jan 17 16:26:49 2009 +0100
@@ -38,7 +38,6 @@
 import dwt.custom.ST;
 import dwt.custom.StyledTextEvent;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.utils;
 
 static import tango.text.Text;
--- a/dwt/custom/TableEditor.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/TableEditor.d	Sat Jan 17 16:26:49 2009 +0100
@@ -26,7 +26,6 @@
 import dwt.widgets.TableColumn;
 import dwt.widgets.TableItem;
 import dwt.custom.ControlEditor;
-import dwt.dwthelper.Runnable;
 
 /**
 *
--- a/dwt/custom/TableTreeEditor.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/TableTreeEditor.d	Sat Jan 17 16:26:49 2009 +0100
@@ -28,8 +28,6 @@
 import dwt.custom.TableTree;
 import dwt.custom.TableTreeItem;
 
-import dwt.dwthelper.Runnable;
-
 /**
 *
 * A TableTreeEditor is a manager for a Control that appears above a cell in a TableTree
--- a/dwt/custom/TreeEditor.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/custom/TreeEditor.d	Sat Jan 17 16:26:49 2009 +0100
@@ -27,7 +27,6 @@
 import dwt.widgets.TreeColumn;
 import dwt.widgets.TreeItem;
 import dwt.custom.ControlEditor;
-import dwt.dwthelper.Runnable;
 
 /**
 *
--- a/dwt/dnd/DropTarget.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/dnd/DropTarget.d	Sat Jan 17 16:26:49 2009 +0100
@@ -51,7 +51,6 @@
 import dwt.dnd.Transfer;
 import dwt.dnd.TransferData;
 import dwt.dnd.TreeDropTargetEffect;
-import dwt.dwthelper.array;
 import dwt.internal.objc.cocoa.Cocoa;
 import objc = dwt.internal.objc.runtime;
 
--- a/dwt/dwthelper/System.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/dwthelper/System.d	Sat Jan 17 16:26:49 2009 +0100
@@ -21,8 +21,6 @@
 import tango.sys.Environment;
 import tango.time.Clock;
 
-import dwt.dwthelper.utils;
-
 template SimpleType(T) {
     debug{
         static void validCheck(uint SrcLen, uint DestLen, uint copyLen){
@@ -175,15 +173,15 @@
         return (*cast(Object *)&x).toHash();
     }
 
-    public static String getProperty( String key, String defval ){
-        String res = getProperty(key);
+    public static char[] getProperty( char[] key, char[] defval ){
+        char[] res = getProperty(key);
         if( res ){
             return res;
         }
         return defval;
     }
     
-    public static String getProperty( String key ){
+    public static char[] getProperty( char[] key ){
         /* get values for global system keys (environment) */
         switch( key ) {
                 // Ubuntu Gutsy:Environment.get for OSTYPE is not working
@@ -208,11 +206,11 @@
         }
         
         /* Get values for local dwt specific keys */
-        String* p;
+        char[]* p;
         return ((p = key in localProperties) != null) ? *p : null;
     }
     
-    public static void setProperty ( String key, String value ) {
+    public static void setProperty ( char[] key, char[] value ) {
         /* set property for LOCAL dwt keys */
         if (key !is null && value !is null)
             localProperties[ key ] = value;
@@ -221,5 +219,5 @@
     static Out out_;
     static Err err;
     
-    private static String[String] localProperties;
+    private static char[][char[]] localProperties;
 }
--- a/dwt/dwthelper/utils.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/dwthelper/utils.d	Sat Jan 17 16:26:49 2009 +0100
@@ -577,9 +577,9 @@
     int res = tango.text.Util.locate( str, searched, startpos );
     if( res is str.length ) res = -1;
     return res;
-}*/
+}
 
-/*public int indexOf(String str, String ch){
+public int indexOf(String str, String ch){
     return indexOf( str, ch, 0 );
 }
 
--- a/dwt/graphics/Device.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/graphics/Device.d	Sat Jan 17 16:26:49 2009 +0100
@@ -32,7 +32,6 @@
 import dwt.internal.cocoa.OS;
 import cocoa = dwt.internal.cocoa.id;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.System;
 import dwt.dwthelper.utils;
 import dwt.graphics.Drawable;
--- a/dwt/internal/BidiUtil.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/internal/BidiUtil.d	Sat Jan 17 16:26:49 2009 +0100
@@ -13,11 +13,12 @@
  *******************************************************************************/
 module dwt.internal.BidiUtil;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.utils;
 import dwt.graphics.GC;
 import dwt.widgets.Control;
 
+import objc = dwt.internal.objc.runtime;
+
 /*
  * This class is supplied so that the StyledText code that supports bidi text (supported
  * for win platforms) is not platform dependent.  Bidi text is not implemented on 
@@ -47,7 +48,7 @@
 /*
  * Not implemented.
  */
-public static void addLanguageListener(int /*long*/ hwnd, Runnable runnable) {
+public static void addLanguageListener(objc.id hwnd, Runnable runnable) {
 }
 public static void addLanguageListener (Control control, Runnable runnable) {
 }
@@ -98,7 +99,7 @@
 /*
  * Not implemented.
  */
-public static void removeLanguageListener(int /*long*/ hwnd) {
+public static void removeLanguageListener(objc.id hwnd) {
 }   
 public static void removeLanguageListener (Control control) {
 }
@@ -110,7 +111,7 @@
 /*
  * Not implemented.
  */
-public static boolean setOrientation(int /*long*/ hwnd, int orientation) {
+public static boolean setOrientation(objc.id hwnd, int orientation) {
     return false;
 }
 public static boolean setOrientation (Control control, int orientation) {
--- a/dwt/internal/objc/runtime.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/internal/objc/runtime.d	Sat Jan 17 16:26:49 2009 +0100
@@ -222,4 +222,12 @@
     {
         return (cast(double (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend_fpret)(self, op, args);
     }
+}
+
+else
+{
+    double objc_msgSend_fpret(ARGS...) (id self, SEL op, ARGS args)
+    {
+        return (cast(double (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend)(self, op, args);
+    }
 }
\ No newline at end of file
--- a/dwt/program/Program.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/program/Program.d	Sat Jan 17 16:26:49 2009 +0100
@@ -38,7 +38,6 @@
 import dwt.internal.cocoa.OS;
 import cocoa = dwt.internal.cocoa.id;
 
-import dwt.dwthelper.array;
 import dwt.internal.c.Carbon;
 import dwt.internal.objc.cocoa.Cocoa;
 import objc = dwt.internal.objc.runtime;
--- a/dwt/widgets/Display.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/widgets/Display.d	Sat Jan 17 16:26:49 2009 +0100
@@ -73,7 +73,6 @@
 import tango.core.Thread;
 import tango.stdc.stringz;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.System;
 import dwt.dwthelper.utils;
 import Carbon = dwt.internal.c.Carbon;
--- a/dwt/widgets/MessageBox.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/widgets/MessageBox.d	Sat Jan 17 16:26:49 2009 +0100
@@ -52,6 +52,7 @@
  */
 public  class MessageBox : Dialog {
     String message = "";
+    private bool allowNullParent = false;
     
 
 /**
@@ -99,6 +100,22 @@
     checkSubclass ();
 }
 
+/++
+ + DWT extension, a MessageBox with no parent
+ +/
+public this (int style) {
+   allowNullParent = true;
+   super (parent, super.checkStyle (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) {
     int mask = (DWT.YES | DWT.NO | DWT.OK | DWT.CANCEL | DWT.ABORT | DWT.RETRY | DWT.IGNORE);
     int bits = style & mask;
@@ -175,6 +192,7 @@
             alternateButton = NSString.stringWith(DWT.getMessage("DWT_Retry"));
             otherButton = NSString.stringWith(DWT.getMessage("DWT_Ignore"));
             break;
+        default:
     }
     NSString title = NSString.stringWith(this.title !is null ? this.title : "");
     NSString message = NSString.stringWith(this.message !is null ? this.message : "");
@@ -187,12 +205,14 @@
             switch (response) {
                 case OS.NSAlertDefaultReturn:
                     return DWT.OK;
+                default:
             }
             break;
         case DWT.CANCEL:
             switch (response) {
                 case OS.NSAlertDefaultReturn:
                     return DWT.CANCEL;
+                default:
             }
             break;
         case DWT.OK | DWT.CANCEL:
@@ -201,18 +221,21 @@
                     return DWT.OK;
                 case OS.NSAlertAlternateReturn:
                     return DWT.CANCEL;
+                default:
             }
             break;
         case DWT.YES:
             switch (response) {
                 case OS.NSAlertDefaultReturn:
                     return DWT.YES;
+                default:
             }
             break;
         case DWT.NO:
             switch (response) {
                 case OS.NSAlertDefaultReturn:
                     return DWT.NO;
+                default:
             }
             break;
         case DWT.YES | DWT.NO:
@@ -221,6 +244,7 @@
                     return DWT.YES;
                 case OS.NSAlertAlternateReturn:
                     return DWT.NO;
+                default:
             }
             break;
         case DWT.YES | DWT.NO | DWT.CANCEL:             
@@ -231,6 +255,7 @@
                     return DWT.NO;
                 case OS.NSAlertOtherReturn:
                     return DWT.CANCEL;
+                default:
             }
             break;
         case DWT.RETRY | DWT.CANCEL:
@@ -239,6 +264,7 @@
                     return DWT.RETRY;
                 case OS.NSAlertAlternateReturn:
                     return DWT.CANCEL;
+                default:
             }
             break;
         case DWT.ABORT | DWT.RETRY | DWT.IGNORE:
@@ -249,8 +275,10 @@
                     return DWT.RETRY;
                 case OS.NSAlertOtherReturn:
                     return DWT.IGNORE;
+                default:
             }
             break;
+        default:
     }
     return DWT.CANCEL;
 }
@@ -271,4 +299,34 @@
     message = string;
 }
 
+/++
+ + DWT extension
+ +/
+public static int showMessageBox(String str, String 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(String str, String 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(String str, String title = null, Shell shell = null) {
+   return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_WARNING );
+}
+
+/// DWT extension
+public static int showError(String str, String title = null, Shell shell = null) {
+   return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_ERROR );
+}
+
+}
--- a/dwt/widgets/RunnableLock.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/widgets/RunnableLock.d	Sat Jan 17 16:26:49 2009 +0100
@@ -19,7 +19,6 @@
 import tango.core.sync.Mutex;
 import tango.core.Thread;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.utils;
 
 /**
--- a/dwt/widgets/Synchronizer.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/widgets/Synchronizer.d	Sat Jan 17 16:26:49 2009 +0100
@@ -22,7 +22,6 @@
 import tango.core.Thread;
 import tango.core.Exception;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.utils;
 import dwt.widgets.Display;
 import dwt.widgets.RunnableLock;
--- a/dwt/widgets/Text.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/widgets/Text.d	Sat Jan 17 16:26:49 2009 +0100
@@ -1324,6 +1324,7 @@
             case 9: /* V */
                 paste ();
                 return false;
+            default:
         }
     }
     if ((style & DWT.SINGLE) !is 0) {
@@ -1332,6 +1333,7 @@
             case 76: /* KP Enter */
             case 36: /* Return */
                 postEvent (DWT.DefaultSelection);
+            default:
         }
     }
     if ((stateMask & DWT.COMMAND) !is 0) return result;
--- a/dwt/widgets/ToolTip.d	Fri Jan 16 23:36:08 2009 +0100
+++ b/dwt/widgets/ToolTip.d	Sat Jan 17 16:26:49 2009 +0100
@@ -29,7 +29,6 @@
 import dwt.graphics.TextLayout;
 import dwt.graphics.TextStyle;
 
-import dwt.dwthelper.Runnable;
 import dwt.dwthelper.utils;
 import dwt.graphics.Device;
 import dwt.widgets.Display;