diff dwt/internal/cocoa/NSAlert.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children 62202ce0039f
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSAlert.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSAlert.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,196 +1,71 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *     IBM Corporation - initial API and implementation
+ *    IBM Corporation - initial API and implementation
  *     
  * Port to the D programming language:
- *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *     Jacob Carlborg <doob@me.com>
  *******************************************************************************/
 module dwt.internal.cocoa.NSAlert;
 
-import dwt.internal.cocoa.id;
+import cocoa = dwt.internal.cocoa.id;
 import dwt.internal.cocoa.NSArray;
 import dwt.internal.cocoa.NSButton;
 import dwt.internal.cocoa.NSError;
 import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
 import dwt.internal.cocoa.NSObject;
 import dwt.internal.cocoa.NSString;
 import dwt.internal.cocoa.NSView;
 import dwt.internal.cocoa.NSWindow;
 import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
 import objc = dwt.internal.objc.runtime;
 
-alias NSUInteger NSAlertStyle;
-
-public class NSAlert : NSObject
+enum NSAlertStyle : NSUInteger
 {
-
-    public this ()
-    {
-        super();
-    }
-
-    public this (objc.id id)
-    {
-        super(id);
-    }
+    NSWarningAlertStyle = 0,
+    NSInformationalAlertStyle = 1,
+    NSCriticalAlertStyle = 2
+}
 
-    public NSView accessoryView ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_accessoryView);
-        return result !is null ? new NSView(result) : null;
-    }
-
-    public NSButton addButtonWithTitle (NSString title)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_addButtonWithTitle_1, title !is null ? title.id_ : null);
-        return result !is null  ? new NSButton(result) : null;
-    }
-
-    public NSAlertStyle alertStyle ()
-    {
-        return cast(NSAlertStyle) OS.objc_msgSend(this.id_, OS.sel_alertStyle);
-    }
-
-    public static NSAlert alertWithError (NSError error)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSAlert, OS.sel_alertWithError_1, error !is null ? error.id_ : null);
-        return result !is null ? new NSAlert(result) : null;
-    }
+public class NSAlert : NSObject {
 
-    public static NSAlert alertWithMessageText (NSString message, NSString defaultButton, NSString alternateButton, NSString otherButton,
-            NSString informativeTextWithFormat)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSAlert,
-                OS.sel_alertWithMessageText_1defaultButton_1alternateButton_1otherButton_1informativeTextWithFormat_1,
-                message !is null ? message.id_ : null, defaultButton !is null ? defaultButton.id_ : null,
-                alternateButton !is null ? alternateButton.id_ : null, otherButton !is null ? otherButton.id_ : null,
-                informativeTextWithFormat !is null ? informativeTextWithFormat.id_ : null);
-        return result !is null ? new NSAlert(result) : null;
-    }
-
-    public void beginSheetModalForWindow (NSWindow window, id delegatee, objc.SEL didEndSelector, void* contextInfo)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_beginSheetModalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1, window !is null ? window.id_ : null,
-                delegatee !is null ? delegatee.id_ : null, didEndSelector, contextInfo);
-    }
+public this () {
+    super();
+}
 
-    public NSArray buttons ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_buttons);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public id delegatee ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
-        return result !is null ? new id(result) : null;
-    }
+public this (objc.id id) {
+    super(id);
+}
 
-    public NSString helpAnchor ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_helpAnchor);
-        return result !is null ? new NSString(result) : null;
-    }
+public this (cocoa.id id) {
+    super(id);
 
-    public NSImage icon ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_icon);
-        return result !is null ? new NSImage(result) : null;
-    }
+}
 
-    public NSString informativeText ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_informativeText);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public void layout ()
-    {
-        OS.objc_msgSend(this.id_, OS.sel_layout);
-    }
-
-    public NSString messageText ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_messageText);
-        return result !is null ? new NSString(result) : null;
-    }
+public static NSAlert alertWithMessageText (NSString message, NSString defaultButton, NSString alternateButton, NSString otherButton, NSString informativeTextWithFormat) {
+    objc.id result = OS.objc_msgSend(OS.class_NSAlert, OS.sel_alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_, message !is null ? message.id : null, defaultButton !is null ? defaultButton.id : null, alternateButton !is null ? alternateButton.id : null, otherButton !is null ? otherButton.id : null, informativeTextWithFormat !is null ? informativeTextWithFormat.id : null);
+    return result !is null ? new NSAlert(result) : null;
+}
 
-    public NSInteger runModal ()
-    {
-        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_runModal);
-    }
-
-    public void setAccessoryView (NSView view)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setAccessoryView_1, view !is null ? view.id_ : null);
-    }
+public NSInteger runModal () {
 
-    public void setAlertStyle (NSAlertStyle style)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setAlertStyle_1, style);
-    }
-
-    public void setDelegate (id delegatee)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null);
-    }
-
-    public void setHelpAnchor (NSString anchor)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setHelpAnchor_1, anchor !is null ? anchor.id_ : null);
-    }
+    return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModal);
+}
 
-    public void setIcon (NSImage icon)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setIcon_1, icon !is null ? icon.id_ : null);
-    }
-
-    public void setInformativeText (NSString informativeText)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setInformativeText_1, informativeText !is null ? informativeText.id_ : null);
-    }
+public void setAlertStyle (NSAlertStyle style) {
+    OS.objc_msgSend(this.id, OS.sel_setAlertStyle_, style);
 
-    public void setMessageText (NSString messageText)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setMessageText_1, messageText !is null ? messageText.id_ : null);
-    }
-
-    public void setShowsHelp (bool showsHelp)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setShowsHelp_1, showsHelp);
-    }
+}
 
-    public void setShowsSuppressionButton (bool flag)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setShowsSuppressionButton_1, flag);
-    }
-
-    public bool showsHelp ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_showsHelp) !is null;
-    }
+public NSWindow window () {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_window);
+    return result !is null ? new NSWindow(result) : null;
+}
 
-    public bool showsSuppressionButton ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_showsSuppressionButton) !is null;
-    }
-
-    public NSButton suppressionButton ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_suppressionButton);
-        return result !is null ? new NSButton(result) : null;
-    }
-
-    public id window ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_window);
-        return result !is null ? new id(result) : null;
-    }
 }